From 18261b1682f7d29d3d871fa77b094dc7efc418b6 Mon Sep 17 00:00:00 2001 From: liangcheng <1546584672@qq.com> Date: Thu, 19 Mar 2026 13:39:04 +0800 Subject: [PATCH] 251001 init --- .../service/impl/KQAttSetBrowserService.java | 141 + .../impl/KQDeductTiaoxiuBrowserService.java | 230 + .../service/impl/KQGroupBrowserService.java | 334 ++ .../service/impl/KQLeaveBrowserService.java | 94 + .../impl/KQLeaveTypeBrowserService.java | 208 + .../impl/KQOvertimeRuleBrowserService.java | 152 + .../service/impl/MutiShiftBrowserService.java | 101 + .../impl/ShiftBrowser4FlowService.java | 141 + .../service/impl/ShiftBrowserService.java | 144 + .../jucailin/KQCycleSetBrowserService.java | 97 + src/com/api/kq/web/ImportLogAction.java | 10 + .../api/kq/web/KQAttendanceButtonAction.java | 8 + .../api/kq/web/KQAttendanceEventAction.java | 8 + src/com/api/kq/web/KQAttendanceSetAction.java | 8 + src/com/api/kq/web/KQBalanceDetailAction.java | 11 + .../api/kq/web/KQBalanceOfLeaveAction.java | 10 + .../api/kq/web/KQBalanceOfLeaveRpAction.java | 10 + src/com/api/kq/web/KQGroupAction.java | 9 + src/com/api/kq/web/KQGroupLocationAction.java | 8 + src/com/api/kq/web/KQGroupMemberAction.java | 8 + src/com/api/kq/web/KQGroupWifiAction.java | 8 + src/com/api/kq/web/KQHolidaySetAction.java | 7 + src/com/api/kq/web/KQLeaveParentalAction.java | 10 + src/com/api/kq/web/KQLeaveRulesAction.java | 10 + src/com/api/kq/web/KQLeaveTypesAction.java | 12 + src/com/api/kq/web/KQMyAttendanceAction.java | 10 + .../api/kq/web/KQOriginalPunchRpAction.java | 10 + src/com/api/kq/web/KQOvertimeRulesAction.java | 10 + src/com/api/kq/web/KQRemindMsgAction.java | 8 + src/com/api/kq/web/KQRemindOnPCAction.java | 11 + src/com/api/kq/web/KQReport4EAction.java | 8 + src/com/api/kq/web/KQReportAction.java | 10 + src/com/api/kq/web/KQReportDetailAction.java | 10 + .../api/kq/web/KQReportFieldDefineAction.java | 10 + src/com/api/kq/web/KQReportShareAction.java | 10 + src/com/api/kq/web/KQScheduleCodeAction.java | 9 + .../kq/web/KQScheduleSignImportAction.java | 9 + src/com/api/kq/web/KQSettingsAction.java | 10 + src/com/api/kq/web/KQSetupWizardAction.java | 10 + .../api/kq/web/KQShiftManagementAction.java | 8 + src/com/api/kq/web/KQShiftScheduleAction.java | 8 + src/com/api/kq/web/KQTravelRulesAction.java | 10 + src/com/api/kq/web/KQUpgradeAction.java | 8 + src/com/api/kq/web/KqPunchButton4EAction.java | 7 + .../jucailin/KQCalendarSettingActionApi.java | 17 + .../kq/web/jucailin/KQCommonActionApi.java | 13 + .../web/jucailin/KQCycleSettingActionApi.java | 12 + .../web/jucailin/KQPersonGroupActionApi.java | 12 + src/com/engine/kq/bean/ImportSetting.java | 115 + src/com/engine/kq/bean/KQBalanceDetail.java | 395 ++ src/com/engine/kq/bean/KQBalanceDetail2.java | 360 ++ src/com/engine/kq/bean/KQBalanceOfLeave.java | 479 ++ src/com/engine/kq/bean/KQChildrenBean.java | 46 + src/com/engine/kq/bean/KQHolidaySet.java | 258 + src/com/engine/kq/bean/KQHrmScheduleSign.java | 215 + src/com/engine/kq/bean/KQRepeatBean.java | 69 + src/com/engine/kq/bean/KQScheduleCode.java | 200 + src/com/engine/kq/bean/KqLockAttenda.java | 74 + .../kq/bean/KqOldCardFlowFlushBean.java | 85 + .../kq/bean/KqShiftscheduleOperateLog.java | 126 + .../engine/kq/bean/KqShiftscheduleRole.java | 56 + src/com/engine/kq/bean/RightMenu.java | 141 + src/com/engine/kq/bean/RightMenuType.java | 118 + src/com/engine/kq/bean/TreeNode.java | 136 + src/com/engine/kq/biz/KQ4ScheduleManager.java | 177 + .../engine/kq/biz/KQAttFlowFieldsSetBiz.java | 78 + src/com/engine/kq/biz/KQAttFlowSetBiz.java | 1176 ++++ .../engine/kq/biz/KQAttFlowSetComInfo.java | 371 ++ .../engine/kq/biz/KQAttProcSetComInfo.java | 104 + src/com/engine/kq/biz/KQAutoCheckBiz.java | 1379 +++++ src/com/engine/kq/biz/KQAutoCheckComInfo.java | 55 + .../engine/kq/biz/KQAutoTimeRangeComInfo.java | 36 + .../engine/kq/biz/KQBalanceOfLeaveBiz.java | 5191 +++++++++++++++++ .../engine/kq/biz/KQBalanceOfLeaveJob.java | 21 + src/com/engine/kq/biz/KQCardFlowFlushJob.java | 89 + src/com/engine/kq/biz/KQCardLogBiz.java | 101 + src/com/engine/kq/biz/KQChildrenComInfo.java | 81 + src/com/engine/kq/biz/KQClearCardLogJob.java | 49 + src/com/engine/kq/biz/KQConfigComInfo.java | 35 + .../engine/kq/biz/KQDingTalkImportJob.java | 34 + .../kq/biz/KQEditFieldInWorkflowBiz.java | 55 + .../engine/kq/biz/KQEmailRemindComInfo.java | 166 + src/com/engine/kq/biz/KQExitRulesBiz.java | 80 + src/com/engine/kq/biz/KQExitRulesComInfo.java | 122 + src/com/engine/kq/biz/KQFLowEventLogBiz.java | 226 + .../kq/biz/KQFixedSchedulceComInfo.java | 123 + src/com/engine/kq/biz/KQFlowActiontBiz.java | 1406 +++++ src/com/engine/kq/biz/KQFlowDataBiz.java | 849 +++ src/com/engine/kq/biz/KQFormat4ReportJob.java | 20 + src/com/engine/kq/biz/KQFormatBiz.java | 371 ++ src/com/engine/kq/biz/KQFormatData.java | 1735 ++++++ .../engine/kq/biz/KQFormatDateChangeJob.java | 48 + src/com/engine/kq/biz/KQFormatFreeData.java | 358 ++ src/com/engine/kq/biz/KQFormatJob.java | 87 + src/com/engine/kq/biz/KQFormatShiftRule.java | 561 ++ src/com/engine/kq/biz/KQFormatSignData.java | 758 +++ src/com/engine/kq/biz/KQFormatThread.java | 67 + ...KQFormatThreadManagerExceptionHandler.java | 49 + src/com/engine/kq/biz/KQFormatTimer.java | 24 + src/com/engine/kq/biz/KQGroupBiz.java | 714 +++ src/com/engine/kq/biz/KQGroupComInfo.java | 466 ++ src/com/engine/kq/biz/KQGroupInit.java | 147 + .../engine/kq/biz/KQGroupMemberComInfo.java | 1000 ++++ src/com/engine/kq/biz/KQHolidaySetBiz.java | 499 ++ .../engine/kq/biz/KQHolidaySetComInfo.java | 197 + src/com/engine/kq/biz/KQHolidaySetThread.java | 37 + .../engine/kq/biz/KQInitializationBiz.java | 673 +++ .../engine/kq/biz/KQLeaveCarryOverJob.java | 225 + src/com/engine/kq/biz/KQLeaveRulesBiz.java | 1307 +++++ .../engine/kq/biz/KQLeaveRulesComInfo.java | 319 + .../kq/biz/KQLeaveRulesDetailComInfo.java | 1329 +++++ src/com/engine/kq/biz/KQLoactionComInfo.java | 71 + .../engine/kq/biz/KQMessageRemindComInfo.java | 138 + src/com/engine/kq/biz/KQOneStopUp.java | 2270 +++++++ src/com/engine/kq/biz/KQOverTimeFlowBiz.java | 774 +++ .../engine/kq/biz/KQOverTimeRuleCalBiz.java | 3094 ++++++++++ src/com/engine/kq/biz/KQOvertimeLogBiz.java | 240 + src/com/engine/kq/biz/KQOvertimeRulesBiz.java | 1054 ++++ .../engine/kq/biz/KQRepeatLengthContext.java | 100 + src/com/engine/kq/biz/KQReportBiz.java | 3669 ++++++++++++ .../engine/kq/biz/KQReportFieldComInfo.java | 239 + .../kq/biz/KQReportFieldGroupComInfo.java | 51 + src/com/engine/kq/biz/KQScheduleSign.java | 211 + src/com/engine/kq/biz/KQScheduleSignBiz.java | 602 ++ .../engine/kq/biz/KQScheduleSignImport.java | 873 +++ .../kq/biz/KQScheduleSignImportJob.java | 30 + src/com/engine/kq/biz/KQSettingsBiz.java | 220 + src/com/engine/kq/biz/KQSettingsComInfo.java | 42 + .../kq/biz/KQShiftCycleSerialComInfo.java | 76 + .../kq/biz/KQShiftManagementComInfo.java | 814 +++ .../engine/kq/biz/KQShiftManagementRedis.java | 280 + .../biz/KQShiftOnOffWorkSectionComInfo.java | 262 + .../biz/KQShiftPersonalizedRuleCominfo.java | 246 + .../KQShiftPersonalizedRuleDetailComInfo.java | 308 + .../kq/biz/KQShiftRestTimeSectionComInfo.java | 242 + src/com/engine/kq/biz/KQShiftRuleInfoBiz.java | 1558 +++++ .../engine/kq/biz/KQShiftScheduleComInfo.java | 167 + src/com/engine/kq/biz/KQShiftscheduleBiz.java | 196 + src/com/engine/kq/biz/KQSignDataFormat.java | 916 +++ src/com/engine/kq/biz/KQSignRemindJob.java | 605 ++ .../engine/kq/biz/KQTimeSelectionComInfo.java | 158 + .../engine/kq/biz/KQTimesArrayComInfo.java | 280 + src/com/engine/kq/biz/KQTodayFormatJob.java | 38 + src/com/engine/kq/biz/KQTravelRulesBiz.java | 80 + .../engine/kq/biz/KQTravelRulesComInfo.java | 122 + src/com/engine/kq/biz/KQUnitBiz.java | 29 + src/com/engine/kq/biz/KQUsageHistoryBiz.java | 419 ++ src/com/engine/kq/biz/KQWifiComInfo.java | 44 + src/com/engine/kq/biz/KQWorkTime.java | 471 ++ .../kq/biz/KQYesterdayAbnormalRemindJob.java | 220 + .../engine/kq/biz/KQYesterdayFormatJob.java | 40 + .../engine/kq/biz/KqAutoNotifyCheckBiz.java | 71 + .../engine/kq/biz/KqFormatPoolRecordBiz.java | 17 + .../engine/kq/biz/KqMembersValidateBiz.java | 232 + .../engine/kq/biz/KqShiftScheduleRoleBiz.java | 127 + .../kq/biz/KqYesterdayAbnormalRemindBiz.java | 96 + src/com/engine/kq/biz/Test.java | 355 ++ .../biz/chain/cominfo/HalfShiftComIndex.java | 202 + .../biz/chain/cominfo/RestShiftComIndex.java | 36 + .../kq/biz/chain/cominfo/ShiftComIndex.java | 797 +++ .../chain/cominfo/ShiftInfoCominfoBean.java | 521 ++ .../biz/chain/cominfo/WorkShiftComIndex.java | 37 + .../chain/duration/NonDayUnitSplitChain.java | 30 + .../chain/duration/NonHalfUnitSplitChain.java | 165 + .../chain/duration/NonHourUnitSplitChain.java | 31 + .../duration/NonWholeUnitSplitChain.java | 119 + .../chain/duration/NonWorkDurationChain.java | 149 + .../chain/duration/WorkDayUnitSplitChain.java | 26 + .../biz/chain/duration/WorkDurationChain.java | 49 + .../duration/WorkHalfUnitSplitChain.java | 472 ++ .../duration/WorkHourUnitSplitChain.java | 26 + .../duration/WorkWholeUnitSplitChain.java | 268 + .../kq/biz/chain/overtime/OvertimeChain.java | 807 +++ .../OvertimeHoliday2HolidayChain.java | 26 + .../OvertimeHoliday2RestdayChain.java | 27 + .../OvertimeHoliday2WorkdayChain.java | 154 + .../OvertimeRestday2HolidayChain.java | 26 + .../OvertimeRestday2RestdayChain.java | 24 + .../OvertimeRestday2WorkdayChain.java | 158 + .../OvertimeWorkday2HolidayChain.java | 68 + .../OvertimeWorkday2RestdayChain.java | 64 + .../OvertimeWorkday2WorkdayChain.java | 85 + .../kq/biz/chain/shiftinfo/DurationIndex.java | 83 + .../shiftinfo/OverTimeDurationIndex.java | 240 + .../kq/biz/chain/shiftinfo/ShiftInfoBean.java | 804 +++ .../GetAbnormalremindConditionCmd.java | 66 + .../GetAbnormalremindInfoCmd.java | 128 + .../attendanceButton/ButtonStatusEnum.java | 34 + .../cmd/attendanceButton/GetAutoEMSetCmd.java | 159 + .../GetButtonBaseInfoCmd.java | 272 + .../cmd/attendanceButton/GetButtonsCmd.java | 1719 ++++++ .../GetExtraMapConfigCmd.java | 52 + .../GetOutButtonConditionCmd.java | 87 + .../GetOutButtonRangeCmd.java | 133 + .../attendanceButton/GetOutButtonsCmd.java | 232 + .../attendanceButton/GetOutSearchListCmd.java | 250 + .../attendanceButton/GetOutSignSetting.java | 144 + .../attendanceButton/GetUserLastMapCmd.java | 53 + .../cmd/attendanceButton/PunchButton4E.java | 287 + .../cmd/attendanceButton/PunchButtonCmd.java | 658 +++ .../attendanceButton/PunchOutButtonCmd.java | 405 ++ .../cmd/attendanceButton/ResetSerialCmd.java | 68 + .../cmd/attendanceButton/ResetUserMapCmd.java | 53 + .../attendanceButton/SaveAutoEMSetCmd.java | 77 + .../SaveExtraMapConfigCmd.java | 53 + .../SaveOutSignSettingCmd.java | 60 + .../cmd/attendanceEvent/AttendanceUtil.java | 102 + .../kq/cmd/attendanceEvent/CheckCardCmd.java | 65 + .../cmd/attendanceEvent/CheckEvectionCmd.java | 65 + .../attendanceEvent/CheckLeaveBackCmd.java | 305 + .../kq/cmd/attendanceEvent/CheckLeaveCmd.java | 656 +++ .../kq/cmd/attendanceEvent/CheckOutCmd.java | 65 + .../cmd/attendanceEvent/CheckOvertimeCmd.java | 67 + .../CheckProcessChangeCmd.java | 154 + .../kq/cmd/attendanceEvent/CheckRuleUtil.java | 1451 +++++ .../cmd/attendanceEvent/CheckRuleUtil4E.java | 56 + .../kq/cmd/attendanceEvent/CheckShiftCmd.java | 116 + .../attendanceEvent/GetAttendanceCardCmd.java | 209 + .../GetEvectionWorkDurationCmd.java | 75 + .../GetLeaveBackDurationCmd.java | 57 + .../attendanceEvent/GetLeaveBackInfoCmd.java | 181 + .../GetLeaveWorkDurationCmd.java | 141 + .../GetOutWorkDurationCmd.java | 76 + .../GetOverTimeWorkDurationCmd.java | 91 + .../GetProcessChangeInfoCmd.java | 272 + .../GetProcessChangeTypeCmd.java | 80 + .../GetProcessChangeWorkDurationCmd.java | 68 + .../attendanceEvent/GetVacationInfoCmd.java | 159 + .../attendanceEvent/GetWorkDurationCmd.java | 56 + .../balanceofleave/BatchProcessingCmd.java | 152 + .../cmd/balanceofleave/GetImportFormCmd.java | 182 + .../cmd/balanceofleave/GetRightMenuCmd.java | 73 + .../balanceofleave/GetSearchConditionCmd.java | 103 + .../cmd/balanceofleave/GetSearchListCmd.java | 323 + .../kq/cmd/balanceofleave/GetTabCmd.java | 66 + .../balanceofleave/SaveBalanceOfLeaveCmd.java | 293 + .../kq/cmd/balanceofleave/SaveImportCmd.java | 69 + .../DeleteBalanceCmd.java | 162 + .../balanceofleavedetail/EditBalanceCmd.java | 207 + .../GetBalanceFormCmd.java | 387 ++ .../balanceofleavedetail/GetRightMenuCmd.java | 60 + .../GetSearchListCmd.java | 135 + .../cmd/balanceofleaverp/ExportExcelCmd.java | 490 ++ .../balanceofleaverp/GetChangeTypeCmd.java | 62 + .../GetDetailPageInfoCmd.java | 53 + .../cmd/balanceofleaverp/GetPageInfoCmd.java | 127 + .../cmd/balanceofleaverp/GetRightMenuCmd.java | 45 + .../GetSearchConditionCmd.java | 313 + .../balanceofleaverp/GetSearchListCmd.java | 435 ++ .../kq/cmd/balanceofleaverp/GetTabCmd.java | 83 + .../GetUsageRecordDetailCmd.java | 205 + src/com/engine/kq/cmd/group/DelGroupCmd.java | 91 + .../engine/kq/cmd/group/ExportExcelCmd.java | 138 + .../cmd/group/GetAddMemberConditionCmd.java | 102 + .../engine/kq/cmd/group/GetGroupFormCmd.java | 965 +++ .../cmd/group/GetGroupMemberConditionCmd.java | 109 + .../kq/cmd/group/GetGroupMemberListCmd.java | 353 ++ .../cmd/group/GetGroupSearchConditionCmd.java | 118 + .../kq/cmd/group/GetGroupSearchListCmd.java | 171 + .../engine/kq/cmd/group/GetGroupTreeCmd.java | 110 + .../engine/kq/cmd/group/GetMainTabsCmd.java | 65 + .../kq/cmd/group/GetShiftCycleFormCmd.java | 119 + src/com/engine/kq/cmd/group/GetTabsCmd.java | 69 + .../engine/kq/cmd/group/ImportExcelCmd.java | 128 + .../engine/kq/cmd/group/SaveAddMemberCmd.java | 120 + src/com/engine/kq/cmd/group/SaveGroupCmd.java | 618 ++ .../grouplocation/DelGroupLocationCmd.java | 119 + .../GetGroupLocationFormCmd.java | 109 + .../GetGroupLocationListCmd.java | 54 + .../grouplocation/SaveGroupLocationCmd.java | 123 + .../cmd/groupmemeber/DelGroupMemberCmd.java | 109 + .../groupmemeber/GetGroupMemberFormCmd.java | 301 + .../GetGroupMemberSearchConditionCmd.java | 124 + .../GetGroupMemberSearchListCmd.java | 162 + .../cmd/groupmemeber/SaveGroupMemberCmd.java | 390 ++ .../SaveValidateDateGroupMemberCmd.java | 267 + .../kq/cmd/groupwifi/DelGroupWifiCmd.java | 118 + .../kq/cmd/groupwifi/GetGroupWifiFormCmd.java | 101 + .../kq/cmd/groupwifi/GetGroupWifiListCmd.java | 54 + .../kq/cmd/groupwifi/SaveGroupWifiCmd.java | 115 + .../kq/cmd/holidaySet/AddHolidaySetCmd.java | 190 + .../cmd/holidaySet/DeleteHolidaySetCmd.java | 124 + .../kq/cmd/holidaySet/EditHolidaySetCmd.java | 148 + .../kq/cmd/holidaySet/GetHolidayCountCmd.java | 102 + .../holidaySet/GetHolidaySetCalendarCmd.java | 185 + .../cmd/holidaySet/GetHolidaySetFormCmd.java | 238 + .../kq/cmd/holidaySet/GetImportFormCmd.java | 123 + .../kq/cmd/holidaySet/GetRightMenuCmd.java | 90 + .../cmd/holidaySet/GetSearchConditionCmd.java | 47 + .../kq/cmd/holidaySet/GetSearchListCmd.java | 96 + .../kq/cmd/holidaySet/GetSyncFormCmd.java | 67 + .../kq/cmd/holidaySet/HasRepeatDataCmd.java | 89 + .../kq/cmd/holidaySet/InitHolidaySetCmd.java | 85 + .../kq/cmd/holidaySet/SaveImportCmd.java | 68 + .../kq/cmd/holidaySet/SyncHolidaySetCmd.java | 131 + .../ChangeStateProcSetStatusCmd.java | 95 + .../cmd/hrmAttProcSet/DelCustomKQFlowCmd.java | 66 + .../DelStateProcCheckRuleCmd.java | 89 + .../cmd/hrmAttProcSet/DelStateProcSetCmd.java | 73 + .../hrmAttProcSet/GetCustomKQFlowFormCmd.java | 302 + .../GetCustomKQFlowSearchConditionCmd.java | 79 + .../GetCustomKQFlowSearchListCmd.java | 66 + .../hrmAttProcSet/GetCustomKQFlowTabCmd.java | 66 + .../hrmAttProcSet/GetProcSetCheckRuleCmd.java | 455 ++ .../hrmAttProcSet/GetProcSetTempletCmd.java | 105 + .../GetStateProcSetCreateFormCmd.java | 77 + .../GetStateProcSetFlowCheckRuleListCmd.java | 87 + .../GetStateProcSetFlowFormCmd.java | 396 ++ .../GetStateProcSetFlowWfFieldsCmd.java | 347 ++ .../GetStateProcSetFlowWfSetCmd.java | 227 + ...GetStateProcSetListSearchConditionCmd.java | 128 + .../GetStateProcSetListSearchListCmd.java | 216 + .../GetStateProcSetTabInfoCmd.java | 109 + .../hrmAttProcSet/GetStateRightMenuCmd.java | 73 + .../hrmAttProcSet/HrmAttProcSetLogUtil.java | 92 + .../cmd/hrmAttProcSet/KqSplitActionEnum.java | 74 + .../kq/cmd/hrmAttProcSet/KqTempletEnum.java | 94 + .../hrmAttProcSet/SaveCustomKQFlowCmd.java | 66 + .../SaveStateProcCheckRuleCmd.java | 265 + .../SaveStateProcSetCreateFormCmd.java | 243 + .../SaveStateProcSetFlowCmd.java | 156 + .../SaveStateProcSetFlowWfFieldsCmd.java | 94 + .../SaveStateProcSetFlowWfSetCmd.java | 90 + .../GetHistorySearchConditionCmd.java | 106 + .../importlog/GetImportColResultLogCmd.java | 117 + .../kq/cmd/importlog/GetImportHistoryCmd.java | 74 + .../cmd/importlog/GetImportProcessLogCmd.java | 102 + .../kq/cmd/importlog/GetImportResultCmd.java | 87 + .../cmd/importlog/SaveImportDeitalLogCmd.java | 49 + .../kq/cmd/importlog/SaveImportLogCmd.java | 57 + .../cmd/importlog/SaveImportLogStatusCmd.java | 47 + .../GetLeaveRulesFormCmd.java | 209 + .../kq/cmd/leaverules/AddLeaveRulesCmd.java | 465 ++ .../cmd/leaverules/DeleteLeaveRulesCmd.java | 95 + .../kq/cmd/leaverules/EditLeaveRulesCmd.java | 496 ++ .../cmd/leaverules/GetLeaveRulesFormCmd.java | 1065 ++++ .../kq/cmd/leaverules/GetRightMenuCmd.java | 62 + .../cmd/leaverules/GetSearchConditionCmd.java | 78 + .../kq/cmd/leaverules/GetSearchListCmd.java | 86 + .../kq/cmd/leaverules/GetUnitNameCmd.java | 56 + .../kq/cmd/leaverules/IsNameRepeatCmd.java | 50 + .../kq/cmd/leavetypes/AddLeaveTypesCmd.java | 162 + .../cmd/leavetypes/DeleteLeaveTypesCmd.java | 111 + .../kq/cmd/leavetypes/EditLeaveTypesCmd.java | 381 ++ .../cmd/leavetypes/GetLeaveTypesFormCmd.java | 510 ++ .../kq/cmd/leavetypes/GetRightMenuCmd.java | 63 + .../cmd/leavetypes/GetSearchConditionCmd.java | 108 + .../kq/cmd/leavetypes/GetSearchListCmd.java | 93 + .../leavetypes/GetTimeSelectionFormCmd.java | 133 + .../kq/cmd/leavetypes/IsNameRepeatCmd.java | 61 + .../leavetypes/SaveDisableLeaveTypesCmd.java | 100 + .../leavetypes/SaveTimeSelectionFormCmd.java | 81 + .../GetDetailCondition4MobileCmd.java | 98 + .../myattendance/GetDetailList4MobileCmd.java | 1083 ++++ .../GetHrmKQMonthReportInfoCmd.java | 1228 ++++ .../GetHrmKQReportDetialInfoCmd.java | 1407 +++++ .../myattendance/GetHrmKQReportInfoCmd.java | 446 ++ .../cmd/myattendance/GetHrmKQSignInfoCmd.java | 508 ++ .../cmd/originalpunchrp/ExportExcelCmd.java | 347 ++ .../cmd/originalpunchrp/GetRightMenuCmd.java | 46 + .../GetSearchConditionCmd.java | 281 + .../cmd/originalpunchrp/GetSearchListCmd.java | 204 + .../overtimerules/AddOvertimeRulesCmd.java | 482 ++ .../overtimerules/DeleteOvertimeRulesCmd.java | 102 + .../overtimerules/EditOverTimeRulesCmd.java | 566 ++ .../GetOvertimeRulesFormCmd.java | 795 +++ .../GetOvertimeSearchConditionCmd.java | 112 + .../overtimerules/GetOvertimeUnitFormCmd.java | 163 + .../kq/cmd/overtimerules/GetRightMenuCmd.java | 75 + .../cmd/overtimerules/GetSearchListCmd.java | 94 + .../cmd/overtimerules/IsRepeatSettingCmd.java | 70 + .../kq/cmd/overtimerules/SaveDefaultCmd.java | 67 + .../overtimerules/SaveOvertimeUnitCmd.java | 115 + .../kq/cmd/remindOnPC/GetRemindInfoCmd.java | 258 + .../kq/cmd/report/ExportDailyExcelCmd.java | 708 +++ .../engine/kq/cmd/report/ExportExcelCmd.java | 729 +++ .../engine/kq/cmd/report/FormatReportCmd.java | 187 + .../kq/cmd/report/GetKQDailyReportCmd.java | 728 +++ .../engine/kq/cmd/report/GetKQReportCmd.java | 837 +++ .../engine/kq/cmd/report/GetRightMenuCmd.java | 57 + .../kq/cmd/report/GetSearchConditionCmd.java | 261 + .../kq/cmd/report4E/GetBalanceInfoCmd.java | 59 + .../kq/cmd/report4E/GetScheduleDataCmd.java | 332 ++ .../kq/cmd/report4E/PunchButton4ECmd.java | 344 ++ .../reportdetial/GetAbsenteeismInfoCmd.java | 161 + .../kq/cmd/reportdetial/GetBeLateInfoCmd.java | 177 + .../reportdetial/GetDailyDetialInfoCmd.java | 436 ++ .../reportdetial/GetForgotCheckInfoCmd.java | 162 + .../reportdetial/GetLeaveEearlyInfoCmd.java | 177 + .../kq/cmd/reportdetial/GetLeaveInfoCmd.java | 86 + .../cmd/reportdetial/GetNeedSignInfoCmd.java | 236 + .../kq/cmd/reportdetial/GetSignInfoCmd.java | 167 + .../kq/cmd/reportdetial/GetTabsCmd.java | 109 + .../cmd/reportdetial/GetWorkDayInfoCmd.java | 157 + .../ChangeFieldGroupCmd.java | 82 + .../DeleteFieldDefineCmd.java | 97 + .../cmd/reportfielddefine/DeleteGroupCmd.java | 98 + .../DeleteReportMoudleCmd.java | 54 + .../GetFieldDefineFormCmd.java | 160 + .../GetFieldDefineListCmd.java | 182 + .../GetFieldDefineTabsCmd.java | 63 + .../GetFieldOrderDefineCmd.java | 118 + .../reportfielddefine/GetGroupFormCmd.java | 106 + .../reportfielddefine/GetGroupListCmd.java | 150 + .../GetReportMoudleFormCmd.java | 99 + .../GetReportMoudleTabsCmd.java | 157 + .../reportfielddefine/GetRightMenuCmd.java | 47 + .../reportfielddefine/SaveFieldDefineCmd.java | 213 + .../SaveFieldDefineListCmd.java | 109 + .../SaveFieldOrderDefineCmd.java | 102 + .../cmd/reportfielddefine/SaveGroupCmd.java | 188 + .../SaveReportMoudleCmd.java | 58 + .../cmd/reportshare/DeleteReportShareCmd.java | 86 + .../reportshare/GetReportShareFormCmd.java | 183 + .../kq/cmd/reportshare/GetRightMenuCmd.java | 55 + .../reportshare/GetSearchConditionCmd.java | 65 + .../kq/cmd/reportshare/GetSearchListCmd.java | 76 + .../cmd/reportshare/SaveReportShareCmd.java | 127 + .../schedulecode/DelScheduleDeviceCmd.java | 86 + .../GetScheduleCodeConditionCmd.java | 120 + .../schedulecode/GetScheduleCodeFormCmd.java | 137 + .../GetScheduleCodeImportFormCmd.java | 118 + .../schedulecode/GetScheduleCodeListCmd.java | 214 + .../GetScheduleDeviceConditionCmd.java | 102 + .../GetScheduleDeviceFormCmd.java | 134 + .../GetScheduleDeviceListCmd.java | 112 + .../cmd/schedulecode/SaveScheduleCodeCmd.java | 233 + .../SaveScheduleCodeImportCmd.java | 63 + .../schedulecode/SaveScheduleDeviceCmd.java | 106 + .../schedulesignimport/GetImportFormCmd.java | 125 + .../GetImportSetFormCmd.java | 275 + .../cmd/schedulesignimport/SaveImportCmd.java | 104 + .../schedulesignimport/SaveImportSetCmd.java | 156 + .../kq/cmd/schedulesignimport/SynDataCmd.java | 98 + .../schedulesignimport/SynDataOpenCmd.java | 246 + .../SynDingTalkDataCmd.java | 168 + .../cmd/schedulesignimport/UpLoadDataCmd.java | 212 + .../kq/cmd/settings/GetRightMenuCmd.java | 46 + .../kq/cmd/settings/GetSettingsFormCmd.java | 82 + .../kq/cmd/settings/SaveSettingsCmd.java | 82 + .../kq/cmd/setupwizard/CheckNeedInitCmd.java | 70 + .../kq/cmd/setupwizard/GetRightMenuCmd.java | 51 + .../kq/cmd/setupwizard/GetSetupFormCmd.java | 235 + .../kq/cmd/setupwizard/GetSetupStepsCmd.java | 75 + .../setupwizard/PerformInitializationCmd.java | 94 + .../DelShiftManagementFormCmd.java | 147 + .../GetDetachOperatelevelCmd.java | 60 + .../GetEmailRemindFormCmd.java | 126 + .../GetMessageRemindFormCmd.java | 114 + .../cmd/shiftmanagement/GetRightMenuCmd.java | 54 + .../GetShiftManagementBaseFormCmd.java | 481 ++ ...GetShiftManagementPersonalizedFormCmd.java | 256 + .../GetShiftManagementSearchConditionCmd.java | 71 + .../GetShiftManagementSearchListCmd.java | 145 + .../kq/cmd/shiftmanagement/GetTabsCmd.java | 69 + .../shiftmanagement/SaveEmailRemindCmd.java | 85 + .../shiftmanagement/SaveMessageRemindCmd.java | 87 + .../SaveShiftManagementBaseFormCmd.java | 535 ++ ...aveShiftManagementPersonalizedFormCmd.java | 376 ++ .../toolkit/ShiftManagementToolKit.java | 405 ++ .../shiftschedule/DelShiftScheduleCmd.java | 177 + .../kq/cmd/shiftschedule/ExportExcelCmd.java | 342 ++ .../GetBatchShiftScheduleFromCmd.java | 278 + .../GetHrmScheduleReportInfoCmd.java | 147 + .../shiftschedule/GetSearchConditionCmd.java | 117 + .../shiftschedule/GetShiftScheduleCmd.java | 363 ++ .../GetShiftScheduleMembersValidateCmd.java | 50 + .../GetShiftScheduleTotalCmd.java | 127 + .../kq/cmd/shiftschedule/GetTabsCmd.java | 64 + .../kq/cmd/shiftschedule/ImportExcelCmd.java | 380 ++ .../SaveBatchShiftScheduleCmd.java | 475 ++ .../shiftschedule/SaveShiftScheduleCmd.java | 258 + .../kq/cmd/travelrules/GetRightMenuCmd.java | 52 + .../travelrules/GetTravelRulesFormCmd.java | 280 + .../cmd/travelrules/SaveTravelRulesCmd.java | 136 + .../engine/kq/cmd/upgrade/DoUpgrade10Cmd.java | 167 + .../engine/kq/cmd/upgrade/DoUpgrade12Cmd.java | 78 + .../engine/kq/cmd/upgrade/DoUpgrade1Cmd.java | 91 + .../engine/kq/cmd/upgrade/DoUpgrade2Cmd.java | 90 + .../engine/kq/cmd/upgrade/DoUpgrade3Cmd.java | 67 + .../engine/kq/cmd/upgrade/DoUpgrade4Cmd.java | 73 + .../engine/kq/cmd/upgrade/DoUpgrade5Cmd.java | 79 + .../engine/kq/cmd/upgrade/DoUpgrade6Cmd.java | 86 + .../engine/kq/cmd/upgrade/DoUpgrade7Cmd.java | 79 + .../engine/kq/cmd/upgrade/DoUpgrade8Cmd.java | 70 + .../engine/kq/cmd/upgrade/DoUpgrade9Cmd.java | 62 + .../engine/kq/cmd/upgrade/GetTreeTabsCmd.java | 111 + .../kq/cmd/upgrade/GetUpgrade10Cmd.java | 132 + .../kq/cmd/upgrade/GetUpgrade12Cmd.java | 84 + .../kq/cmd/upgrade/GetUpgrade12DataCmd.java | 55 + .../engine/kq/cmd/upgrade/GetUpgrade1Cmd.java | 56 + .../engine/kq/cmd/upgrade/GetUpgrade2Cmd.java | 62 + .../engine/kq/cmd/upgrade/GetUpgrade3Cmd.java | 56 + .../engine/kq/cmd/upgrade/GetUpgrade4Cmd.java | 56 + .../engine/kq/cmd/upgrade/GetUpgrade5Cmd.java | 56 + .../engine/kq/cmd/upgrade/GetUpgrade6Cmd.java | 56 + .../engine/kq/cmd/upgrade/GetUpgrade7Cmd.java | 77 + .../engine/kq/cmd/upgrade/GetUpgrade8Cmd.java | 56 + .../engine/kq/cmd/upgrade/GetUpgrade9Cmd.java | 56 + .../kq/cmd/upgrade/KQUpgradeTabEnum.java | 112 + .../engine/kq/cmd/upgrade/UpgradeUtil.java | 24 + .../kq/entity/KQBalanceOfLeaveEntity.java | 234 + src/com/engine/kq/entity/KQGroupEntity.java | 235 + .../engine/kq/entity/KQLeaveInfoEntity.java | 26 + .../entity/KQOvertimeRulesDetailEntity.java | 253 + src/com/engine/kq/entity/KQReportEntity.java | 178 + .../kq/entity/KQScheduleSignEntity.java | 98 + .../engine/kq/entity/KQShiftRuleEntity.java | 189 + .../kq/entity/KQUsageHistoryEntity.java | 386 ++ src/com/engine/kq/entity/TimeScopeEntity.java | 76 + .../engine/kq/entity/TimeSignScopeEntity.java | 56 + src/com/engine/kq/entity/WorkTimeEntity.java | 220 + src/com/engine/kq/enums/DurationTypeEnum.java | 57 + .../engine/kq/enums/FlowReportTypeEnum.java | 100 + src/com/engine/kq/enums/KQSettingsEnum.java | 106 + .../engine/kq/enums/KqSplitFlowTypeEnum.java | 82 + .../kq/enums/OverTimeComputingModeEnum.java | 66 + src/com/engine/kq/enums/ReportColumnEnum.java | 42 + .../calendar/GetCalendarSettingFormCmd.java | 132 + .../calendar/GetCalendarSettingListCmd.java | 88 + .../cmd/common/DeleteDataCommonCmd.java | 42 + .../cmd/common/InsertDataCommonCmd.java | 70 + .../cmd/common/QueryDataCommonCmd.java | 41 + .../cmd/common/UpdateDataCommonCmd.java | 74 + .../jucailin/cmd/cycle/GetCycleFormCmd.java | 219 + .../jucailin/cmd/cycle/GetCycleListCmd.java | 113 + .../cmd/cycle/GetCycleSearchConditionCmd.java | 95 + .../cmd/cycle/GetCycleSettingFormCmd.java | 136 + .../cmd/cycle/GetCycleSettingListCmd.java | 102 + .../cmd/cycle/GetCycleSettingTreeCmd.java | 58 + .../cmd/cycle/GetCycledetailFormCmd.java | 129 + .../cmd/cycle/GetCycledetailListCmd.java | 104 + .../personGroup/GetPersonGroupListCmd.java | 113 + .../GetSuitOrganzationFormCmd.java | 304 + .../GetSuitOrganzationListCmd.java | 174 + .../personGroup/SaveSuitOrganzationCmd.java | 296 + .../kq/jucailin/enums/FieldHtmlTypeEnum.java | 36 + .../exception/AttendanceRunTimeException.java | 15 + .../kq/jucailin/exception/ExceptionUtil.java | 17 + .../kq/jucailin/genid/DefaultWorker.java | 52 + .../engine/kq/jucailin/genid/IdGenerator.java | 16 + .../engine/kq/jucailin/genid/SnowflakeId.java | 93 + src/com/engine/kq/jucailin/genid/Worker.java | 5 + .../service/KQCalendarSettingService.java | 9 + .../kq/jucailin/service/KQCommonService.java | 12 + .../service/KQCycleSettingService.java | 21 + .../service/KQPersonGroupService.java | 17 + .../impl/KQCalendarSettingServiceImpl.java | 25 + .../service/impl/KQCommonServiceImpl.java | 48 + .../impl/KQCycleSettingServiceImpl.java | 50 + .../impl/KQPersonGroupServiceImpl.java | 45 + .../engine/kq/jucailin/util/CommonUtil.java | 312 + src/com/engine/kq/jucailin/util/Constant.java | 13 + src/com/engine/kq/jucailin/util/DateUtil.java | 248 + src/com/engine/kq/jucailin/util/DbTools.java | 132 + .../engine/kq/jucailin/util/KQDateUtil.java | 19 + .../jucailin/util/ListConversionMethod.java | 83 + .../kq/jucailin/util/PageUidFactory.java | 36 + .../kq/jucailin/util/ResponseResult.java | 185 + .../jucailin/web/KQCalendarSettingAction.java | 60 + .../kq/jucailin/web/KQCommonAction.java | 76 + .../kq/jucailin/web/KQCycleSettingAction.java | 146 + .../kq/jucailin/web/KQPersonGroupAction.java | 106 + .../jucailin/web/common/KQCommonAction.java | 59 + .../web/persongroup/KQCycleSettingAction.java | 74 + .../web/persongroup/KQPersonGroupAction.java | 47 + src/com/engine/kq/log/KQLog.java | 232 + .../engine/kq/service/ImportLogService.java | 67 + .../kq/service/KQAttendanceButtonService.java | 136 + .../kq/service/KQAttendanceEventService.java | 163 + .../kq/service/KQAttendanceSetService.java | 176 + .../kq/service/KQBalanceDetailService.java | 49 + .../kq/service/KQBalanceOfLeaveRpService.java | 95 + .../kq/service/KQBalanceOfLeaveService.java | 76 + .../kq/service/KQGroupLocationService.java | 40 + .../kq/service/KQGroupMemberService.java | 56 + src/com/engine/kq/service/KQGroupService.java | 146 + .../engine/kq/service/KQGroupWifiService.java | 40 + .../kq/service/KQHolidaySetService.java | 132 + .../kq/service/KQLeaveParentalService.java | 21 + .../kq/service/KQLeaveRulesService.java | 84 + .../kq/service/KQLeaveTypesService.java | 94 + .../kq/service/KQMyAttendanceService.java | 59 + .../kq/service/KQOriginalPunchRpService.java | 50 + .../kq/service/KQOvertimeRulesService.java | 99 + .../engine/kq/service/KQRemindMsgService.java | 13 + .../kq/service/KQRemindOnPCService.java | 23 + .../engine/kq/service/KQReport4EService.java | 40 + .../kq/service/KQReportDetailService.java | 83 + .../service/KQReportFieldDefineService.java | 152 + .../engine/kq/service/KQReportService.java | 69 + .../kq/service/KQReportShareService.java | 65 + .../kq/service/KQScheduleCodeService.java | 97 + .../service/KQScheduleSignImportService.java | 70 + .../engine/kq/service/KQSettingsService.java | 38 + .../kq/service/KQSetupWizardService.java | 51 + .../kq/service/KQShiftManagementService.java | 119 + .../kq/service/KQShiftScheduleService.java | 108 + .../kq/service/KQTravelRulesService.java | 35 + .../engine/kq/service/KQUpgradeService.java | 200 + .../kq/service/impl/ImportLogServiceImpl.java | 53 + .../impl/KQAttendanceButtonServiceImpl.java | 96 + .../impl/KQAttendanceEventServiceImpl.java | 124 + .../impl/KQAttendanceSetServiceImpl.java | 114 + .../impl/KQBalanceDetailServiceImpl.java | 37 + .../impl/KQBalanceOfLeaveRpServiceImpl.java | 61 + .../impl/KQBalanceOfLeaveServiceImpl.java | 55 + .../impl/KQGroupLocationServiceImpl.java | 33 + .../impl/KQGroupMemberServiceImpl.java | 41 + .../kq/service/impl/KQGroupServiceImpl.java | 88 + .../service/impl/KQGroupWifiServiceImpl.java | 34 + .../service/impl/KQHolidaySetServiceImpl.java | 90 + .../impl/KQLeaveParentalServiceImpl.java | 19 + .../service/impl/KQLeaveRulesServiceImpl.java | 56 + .../service/impl/KQLeaveTypesServiceImpl.java | 71 + .../impl/KQMyAttendanceServiceImpl.java | 107 + .../impl/KQOriginalPunchRpServiceImpl.java | 36 + .../impl/KQOvertimeRulesServiceImpl.java | 69 + .../service/impl/KQRemindMsgServiceImpl.java | 24 + .../service/impl/KQRemindOnPCServiceImpl.java | 28 + .../service/impl/KQReport4EServiceImpl.java | 31 + .../impl/KQReportDetailServiceImpl.java | 54 + .../impl/KQReportFieldDefineServiceImpl.java | 226 + .../kq/service/impl/KQReportServiceImpl.java | 48 + .../impl/KQReportShareServiceImpl.java | 44 + .../impl/KQScheduleCodeServiceImpl.java | 68 + .../impl/KQScheduleSignImportServiceImpl.java | 51 + .../service/impl/KQSettingsServiceImpl.java | 26 + .../impl/KQSetupWizardServiceImpl.java | 43 + .../impl/KQShiftManagementServiceImpl.java | 88 + .../impl/KQShiftScheduleServiceImpl.java | 74 + .../impl/KQTravelRulesServiceImpl.java | 26 + .../kq/service/impl/KQUpgradeServiceImpl.java | 136 + .../engine/kq/timer/KQOvertimeCardBean.java | 94 + src/com/engine/kq/timer/KQQueue.java | 56 + src/com/engine/kq/timer/KQTask.java | 45 + src/com/engine/kq/timer/KQTaskBean.java | 229 + .../engine/kq/timer/KQTaskTimerSchedule.java | 31 + src/com/engine/kq/util/ExcelUtil.java | 832 +++ src/com/engine/kq/util/ImportProcessUtil.java | 885 +++ .../kq/util/KQDurationCalculatorUtil.java | 616 ++ src/com/engine/kq/util/KQLockAttendaUtil.java | 1382 +++++ src/com/engine/kq/util/KQTransMethod.java | 1668 ++++++ src/com/engine/kq/util/PageUidFactory.java | 56 + src/com/engine/kq/util/ResponseResult.java | 187 + src/com/engine/kq/util/TransMethod.java | 924 +++ src/com/engine/kq/util/UtilKQ.java | 143 + .../KqPunchButton4EWebServiceManager.java | 49 + src/com/engine/kq/web/GetKQDatasAction.java | 967 +++ src/com/engine/kq/web/ImportLogAction.java | 126 + .../kq/web/KQAttendanceButtonAction.java | 372 ++ .../kq/web/KQAttendanceEventAction.java | 449 ++ .../engine/kq/web/KQAttendanceSetAction.java | 494 ++ .../engine/kq/web/KQBalanceDetailAction.java | 172 + .../engine/kq/web/KQBalanceOfLeaveAction.java | 249 + .../kq/web/KQBalanceOfLeaveRpAction.java | 301 + src/com/engine/kq/web/KQGroupAction.java | 393 ++ .../engine/kq/web/KQGroupLocationAction.java | 148 + .../engine/kq/web/KQGroupMemberAction.java | 164 + src/com/engine/kq/web/KQGroupWifiAction.java | 120 + src/com/engine/kq/web/KQHolidaySetAction.java | 419 ++ .../engine/kq/web/KQLeaveParentalAction.java | 56 + src/com/engine/kq/web/KQLeaveRulesAction.java | 270 + src/com/engine/kq/web/KQLeaveTypesAction.java | 308 + .../engine/kq/web/KQMyAttendanceAction.java | 323 + .../kq/web/KQOriginalPunchRpAction.java | 161 + .../engine/kq/web/KQOvertimeRulesAction.java | 317 + src/com/engine/kq/web/KQRemindMsgAction.java | 313 + src/com/engine/kq/web/KQRemindOnPCAction.java | 95 + src/com/engine/kq/web/KQReport4EAction.java | 106 + src/com/engine/kq/web/KQReportAction.java | 1106 ++++ .../engine/kq/web/KQReportDetailAction.java | 174 + .../kq/web/KQReportFieldDefineAction.java | 435 ++ .../engine/kq/web/KQReportShareAction.java | 179 + .../engine/kq/web/KQScheduleCodeAction.java | 288 + .../kq/web/KQScheduleSignImportAction.java | 251 + src/com/engine/kq/web/KQSettingsAction.java | 137 + .../engine/kq/web/KQSetupWizardAction.java | 165 + .../kq/web/KQShiftManagementAction.java | 347 ++ .../engine/kq/web/KQShiftScheduleAction.java | 306 + .../engine/kq/web/KQTravelRulesAction.java | 127 + src/com/engine/kq/web/KQUpgradeAction.java | 582 ++ .../engine/kq/web/KqPunchButton4EAction.java | 253 + .../kq/wfset/action/KqCheckLockAction.java | 85 + .../action/KqDeductionVacationAction.java | 107 + .../wfset/action/KqFreezeVacationAction.java | 169 + .../kq/wfset/action/KqPaidLeaveAction.java | 100 + .../wfset/action/KqReleaseVacationAction.java | 56 + .../engine/kq/wfset/action/KqSplitAction.java | 80 + .../attendance/dao/HrmAttFlowVersionDao.java | 78 + .../attendance/dao/HrmAttProcActionDao.java | 359 ++ .../attendance/dao/HrmAttProcFieldsDao.java | 210 + .../attendance/dao/HrmAttProcRelationDao.java | 191 + .../attendance/dao/HrmAttProcSetDao.java | 498 ++ .../wfset/attendance/dao/WorkflowBaseDao.java | 1742 ++++++ .../attendance/dao/WorkflowBillfieldDao.java | 322 + .../attendance/domain/HrmAttFlowType.java | 33 + .../attendance/domain/HrmAttFlowVersion.java | 93 + .../attendance/domain/HrmAttProcAction.java | 170 + .../attendance/domain/HrmAttProcFields.java | 227 + .../attendance/domain/HrmAttProcRelation.java | 124 + .../attendance/domain/HrmAttProcSet.java | 371 ++ .../wfset/attendance/domain/WorkflowBase.java | 1101 ++++ .../attendance/domain/WorkflowBillfield.java | 242 + .../wfset/attendance/framework/BaseCache.java | 67 + .../attendance/framework/BaseConnection.java | 180 + .../attendance/framework/BaseController.java | 407 ++ .../wfset/attendance/framework/BaseDao.java | 23 + .../attendance/framework/BaseEntity.java | 86 + .../attendance/framework/BaseManager.java | 492 ++ .../manager/HrmAttFlowVersionManager.java | 270 + .../manager/HrmAttProcActionManager.java | 126 + .../manager/HrmAttProcActionManagerE9.java | 216 + .../manager/HrmAttProcFieldsManager.java | 28 + .../manager/HrmAttProcRelationManager.java | 259 + .../manager/HrmAttProcSetManager.java | 1253 ++++ .../manager/WorkflowBaseManager.java | 40 + .../manager/WorkflowBillfieldManager.java | 28 + .../engine/kq/wfset/auto/AutoInitWFSet.java | 3383 +++++++++++ .../kq/wfset/bean/LeavebackSplitBean.java | 146 + .../wfset/bean/OvertimeBalanceTimeBean.java | 97 + .../kq/wfset/bean/ProcessChangeSplitBean.java | 96 + src/com/engine/kq/wfset/bean/SplitBean.java | 713 +++ .../engine/kq/wfset/job/HrmTimesArrayJob.java | 110 + .../engine/kq/wfset/test/DateTimeTest.java | 18 + src/com/engine/kq/wfset/util/KQ122Util.java | 49 + .../kq/wfset/util/KQAttFlowCheckUtil.java | 681 +++ .../engine/kq/wfset/util/KQFlowCardUtil.java | 373 ++ .../kq/wfset/util/KQFlowEvectionUtil.java | 112 + .../kq/wfset/util/KQFlowLeaveBackUtil.java | 449 ++ .../engine/kq/wfset/util/KQFlowLeaveUtil.java | 96 + .../engine/kq/wfset/util/KQFlowOtherUtil.java | 33 + .../engine/kq/wfset/util/KQFlowOutUtil.java | 56 + .../kq/wfset/util/KQFlowOvertimeUtil.java | 169 + .../wfset/util/KQFlowProcessChangeUtil.java | 681 +++ .../engine/kq/wfset/util/KQFlowShiftUtil.java | 232 + src/com/engine/kq/wfset/util/KQFlowUtil.java | 523 ++ src/com/engine/kq/wfset/util/KQSignUtil.java | 359 ++ .../engine/kq/wfset/util/SplitActionUtil.java | 3487 +++++++++++ .../engine/kq/wfset/util/SplitSelectSet.java | 95 + 740 files changed, 166304 insertions(+) create mode 100644 src/com/api/kq/browser/service/impl/KQAttSetBrowserService.java create mode 100644 src/com/api/kq/browser/service/impl/KQDeductTiaoxiuBrowserService.java create mode 100644 src/com/api/kq/browser/service/impl/KQGroupBrowserService.java create mode 100644 src/com/api/kq/browser/service/impl/KQLeaveBrowserService.java create mode 100644 src/com/api/kq/browser/service/impl/KQLeaveTypeBrowserService.java create mode 100644 src/com/api/kq/browser/service/impl/KQOvertimeRuleBrowserService.java create mode 100644 src/com/api/kq/browser/service/impl/MutiShiftBrowserService.java create mode 100644 src/com/api/kq/browser/service/impl/ShiftBrowser4FlowService.java create mode 100644 src/com/api/kq/browser/service/impl/ShiftBrowserService.java create mode 100644 src/com/api/kq/browser/service/impl/jucailin/KQCycleSetBrowserService.java create mode 100644 src/com/api/kq/web/ImportLogAction.java create mode 100644 src/com/api/kq/web/KQAttendanceButtonAction.java create mode 100644 src/com/api/kq/web/KQAttendanceEventAction.java create mode 100644 src/com/api/kq/web/KQAttendanceSetAction.java create mode 100644 src/com/api/kq/web/KQBalanceDetailAction.java create mode 100644 src/com/api/kq/web/KQBalanceOfLeaveAction.java create mode 100644 src/com/api/kq/web/KQBalanceOfLeaveRpAction.java create mode 100644 src/com/api/kq/web/KQGroupAction.java create mode 100644 src/com/api/kq/web/KQGroupLocationAction.java create mode 100644 src/com/api/kq/web/KQGroupMemberAction.java create mode 100644 src/com/api/kq/web/KQGroupWifiAction.java create mode 100644 src/com/api/kq/web/KQHolidaySetAction.java create mode 100644 src/com/api/kq/web/KQLeaveParentalAction.java create mode 100644 src/com/api/kq/web/KQLeaveRulesAction.java create mode 100644 src/com/api/kq/web/KQLeaveTypesAction.java create mode 100644 src/com/api/kq/web/KQMyAttendanceAction.java create mode 100644 src/com/api/kq/web/KQOriginalPunchRpAction.java create mode 100644 src/com/api/kq/web/KQOvertimeRulesAction.java create mode 100644 src/com/api/kq/web/KQRemindMsgAction.java create mode 100644 src/com/api/kq/web/KQRemindOnPCAction.java create mode 100644 src/com/api/kq/web/KQReport4EAction.java create mode 100644 src/com/api/kq/web/KQReportAction.java create mode 100644 src/com/api/kq/web/KQReportDetailAction.java create mode 100644 src/com/api/kq/web/KQReportFieldDefineAction.java create mode 100644 src/com/api/kq/web/KQReportShareAction.java create mode 100644 src/com/api/kq/web/KQScheduleCodeAction.java create mode 100644 src/com/api/kq/web/KQScheduleSignImportAction.java create mode 100644 src/com/api/kq/web/KQSettingsAction.java create mode 100644 src/com/api/kq/web/KQSetupWizardAction.java create mode 100644 src/com/api/kq/web/KQShiftManagementAction.java create mode 100644 src/com/api/kq/web/KQShiftScheduleAction.java create mode 100644 src/com/api/kq/web/KQTravelRulesAction.java create mode 100644 src/com/api/kq/web/KQUpgradeAction.java create mode 100644 src/com/api/kq/web/KqPunchButton4EAction.java create mode 100644 src/com/api/kq/web/jucailin/KQCalendarSettingActionApi.java create mode 100644 src/com/api/kq/web/jucailin/KQCommonActionApi.java create mode 100644 src/com/api/kq/web/jucailin/KQCycleSettingActionApi.java create mode 100644 src/com/api/kq/web/jucailin/KQPersonGroupActionApi.java create mode 100644 src/com/engine/kq/bean/ImportSetting.java create mode 100644 src/com/engine/kq/bean/KQBalanceDetail.java create mode 100644 src/com/engine/kq/bean/KQBalanceDetail2.java create mode 100644 src/com/engine/kq/bean/KQBalanceOfLeave.java create mode 100644 src/com/engine/kq/bean/KQChildrenBean.java create mode 100644 src/com/engine/kq/bean/KQHolidaySet.java create mode 100644 src/com/engine/kq/bean/KQHrmScheduleSign.java create mode 100644 src/com/engine/kq/bean/KQRepeatBean.java create mode 100644 src/com/engine/kq/bean/KQScheduleCode.java create mode 100644 src/com/engine/kq/bean/KqLockAttenda.java create mode 100644 src/com/engine/kq/bean/KqOldCardFlowFlushBean.java create mode 100644 src/com/engine/kq/bean/KqShiftscheduleOperateLog.java create mode 100644 src/com/engine/kq/bean/KqShiftscheduleRole.java create mode 100644 src/com/engine/kq/bean/RightMenu.java create mode 100644 src/com/engine/kq/bean/RightMenuType.java create mode 100644 src/com/engine/kq/bean/TreeNode.java create mode 100644 src/com/engine/kq/biz/KQ4ScheduleManager.java create mode 100644 src/com/engine/kq/biz/KQAttFlowFieldsSetBiz.java create mode 100644 src/com/engine/kq/biz/KQAttFlowSetBiz.java create mode 100644 src/com/engine/kq/biz/KQAttFlowSetComInfo.java create mode 100644 src/com/engine/kq/biz/KQAttProcSetComInfo.java create mode 100644 src/com/engine/kq/biz/KQAutoCheckBiz.java create mode 100644 src/com/engine/kq/biz/KQAutoCheckComInfo.java create mode 100644 src/com/engine/kq/biz/KQAutoTimeRangeComInfo.java create mode 100644 src/com/engine/kq/biz/KQBalanceOfLeaveBiz.java create mode 100644 src/com/engine/kq/biz/KQBalanceOfLeaveJob.java create mode 100644 src/com/engine/kq/biz/KQCardFlowFlushJob.java create mode 100644 src/com/engine/kq/biz/KQCardLogBiz.java create mode 100644 src/com/engine/kq/biz/KQChildrenComInfo.java create mode 100644 src/com/engine/kq/biz/KQClearCardLogJob.java create mode 100644 src/com/engine/kq/biz/KQConfigComInfo.java create mode 100644 src/com/engine/kq/biz/KQDingTalkImportJob.java create mode 100644 src/com/engine/kq/biz/KQEditFieldInWorkflowBiz.java create mode 100644 src/com/engine/kq/biz/KQEmailRemindComInfo.java create mode 100644 src/com/engine/kq/biz/KQExitRulesBiz.java create mode 100644 src/com/engine/kq/biz/KQExitRulesComInfo.java create mode 100644 src/com/engine/kq/biz/KQFLowEventLogBiz.java create mode 100644 src/com/engine/kq/biz/KQFixedSchedulceComInfo.java create mode 100644 src/com/engine/kq/biz/KQFlowActiontBiz.java create mode 100644 src/com/engine/kq/biz/KQFlowDataBiz.java create mode 100644 src/com/engine/kq/biz/KQFormat4ReportJob.java create mode 100644 src/com/engine/kq/biz/KQFormatBiz.java create mode 100644 src/com/engine/kq/biz/KQFormatData.java create mode 100644 src/com/engine/kq/biz/KQFormatDateChangeJob.java create mode 100644 src/com/engine/kq/biz/KQFormatFreeData.java create mode 100644 src/com/engine/kq/biz/KQFormatJob.java create mode 100644 src/com/engine/kq/biz/KQFormatShiftRule.java create mode 100644 src/com/engine/kq/biz/KQFormatSignData.java create mode 100644 src/com/engine/kq/biz/KQFormatThread.java create mode 100644 src/com/engine/kq/biz/KQFormatThreadManagerExceptionHandler.java create mode 100644 src/com/engine/kq/biz/KQFormatTimer.java create mode 100644 src/com/engine/kq/biz/KQGroupBiz.java create mode 100644 src/com/engine/kq/biz/KQGroupComInfo.java create mode 100644 src/com/engine/kq/biz/KQGroupInit.java create mode 100644 src/com/engine/kq/biz/KQGroupMemberComInfo.java create mode 100644 src/com/engine/kq/biz/KQHolidaySetBiz.java create mode 100644 src/com/engine/kq/biz/KQHolidaySetComInfo.java create mode 100644 src/com/engine/kq/biz/KQHolidaySetThread.java create mode 100644 src/com/engine/kq/biz/KQInitializationBiz.java create mode 100644 src/com/engine/kq/biz/KQLeaveCarryOverJob.java create mode 100644 src/com/engine/kq/biz/KQLeaveRulesBiz.java create mode 100644 src/com/engine/kq/biz/KQLeaveRulesComInfo.java create mode 100644 src/com/engine/kq/biz/KQLeaveRulesDetailComInfo.java create mode 100644 src/com/engine/kq/biz/KQLoactionComInfo.java create mode 100644 src/com/engine/kq/biz/KQMessageRemindComInfo.java create mode 100644 src/com/engine/kq/biz/KQOneStopUp.java create mode 100644 src/com/engine/kq/biz/KQOverTimeFlowBiz.java create mode 100644 src/com/engine/kq/biz/KQOverTimeRuleCalBiz.java create mode 100644 src/com/engine/kq/biz/KQOvertimeLogBiz.java create mode 100644 src/com/engine/kq/biz/KQOvertimeRulesBiz.java create mode 100644 src/com/engine/kq/biz/KQRepeatLengthContext.java create mode 100644 src/com/engine/kq/biz/KQReportBiz.java create mode 100644 src/com/engine/kq/biz/KQReportFieldComInfo.java create mode 100644 src/com/engine/kq/biz/KQReportFieldGroupComInfo.java create mode 100644 src/com/engine/kq/biz/KQScheduleSign.java create mode 100644 src/com/engine/kq/biz/KQScheduleSignBiz.java create mode 100644 src/com/engine/kq/biz/KQScheduleSignImport.java create mode 100644 src/com/engine/kq/biz/KQScheduleSignImportJob.java create mode 100644 src/com/engine/kq/biz/KQSettingsBiz.java create mode 100644 src/com/engine/kq/biz/KQSettingsComInfo.java create mode 100644 src/com/engine/kq/biz/KQShiftCycleSerialComInfo.java create mode 100644 src/com/engine/kq/biz/KQShiftManagementComInfo.java create mode 100644 src/com/engine/kq/biz/KQShiftManagementRedis.java create mode 100644 src/com/engine/kq/biz/KQShiftOnOffWorkSectionComInfo.java create mode 100644 src/com/engine/kq/biz/KQShiftPersonalizedRuleCominfo.java create mode 100644 src/com/engine/kq/biz/KQShiftPersonalizedRuleDetailComInfo.java create mode 100644 src/com/engine/kq/biz/KQShiftRestTimeSectionComInfo.java create mode 100644 src/com/engine/kq/biz/KQShiftRuleInfoBiz.java create mode 100644 src/com/engine/kq/biz/KQShiftScheduleComInfo.java create mode 100644 src/com/engine/kq/biz/KQShiftscheduleBiz.java create mode 100644 src/com/engine/kq/biz/KQSignDataFormat.java create mode 100644 src/com/engine/kq/biz/KQSignRemindJob.java create mode 100644 src/com/engine/kq/biz/KQTimeSelectionComInfo.java create mode 100644 src/com/engine/kq/biz/KQTimesArrayComInfo.java create mode 100644 src/com/engine/kq/biz/KQTodayFormatJob.java create mode 100644 src/com/engine/kq/biz/KQTravelRulesBiz.java create mode 100644 src/com/engine/kq/biz/KQTravelRulesComInfo.java create mode 100644 src/com/engine/kq/biz/KQUnitBiz.java create mode 100644 src/com/engine/kq/biz/KQUsageHistoryBiz.java create mode 100644 src/com/engine/kq/biz/KQWifiComInfo.java create mode 100644 src/com/engine/kq/biz/KQWorkTime.java create mode 100644 src/com/engine/kq/biz/KQYesterdayAbnormalRemindJob.java create mode 100644 src/com/engine/kq/biz/KQYesterdayFormatJob.java create mode 100644 src/com/engine/kq/biz/KqAutoNotifyCheckBiz.java create mode 100644 src/com/engine/kq/biz/KqFormatPoolRecordBiz.java create mode 100644 src/com/engine/kq/biz/KqMembersValidateBiz.java create mode 100644 src/com/engine/kq/biz/KqShiftScheduleRoleBiz.java create mode 100644 src/com/engine/kq/biz/KqYesterdayAbnormalRemindBiz.java create mode 100644 src/com/engine/kq/biz/Test.java create mode 100644 src/com/engine/kq/biz/chain/cominfo/HalfShiftComIndex.java create mode 100644 src/com/engine/kq/biz/chain/cominfo/RestShiftComIndex.java create mode 100644 src/com/engine/kq/biz/chain/cominfo/ShiftComIndex.java create mode 100644 src/com/engine/kq/biz/chain/cominfo/ShiftInfoCominfoBean.java create mode 100644 src/com/engine/kq/biz/chain/cominfo/WorkShiftComIndex.java create mode 100644 src/com/engine/kq/biz/chain/duration/NonDayUnitSplitChain.java create mode 100644 src/com/engine/kq/biz/chain/duration/NonHalfUnitSplitChain.java create mode 100644 src/com/engine/kq/biz/chain/duration/NonHourUnitSplitChain.java create mode 100644 src/com/engine/kq/biz/chain/duration/NonWholeUnitSplitChain.java create mode 100644 src/com/engine/kq/biz/chain/duration/NonWorkDurationChain.java create mode 100644 src/com/engine/kq/biz/chain/duration/WorkDayUnitSplitChain.java create mode 100644 src/com/engine/kq/biz/chain/duration/WorkDurationChain.java create mode 100644 src/com/engine/kq/biz/chain/duration/WorkHalfUnitSplitChain.java create mode 100644 src/com/engine/kq/biz/chain/duration/WorkHourUnitSplitChain.java create mode 100644 src/com/engine/kq/biz/chain/duration/WorkWholeUnitSplitChain.java create mode 100644 src/com/engine/kq/biz/chain/overtime/OvertimeChain.java create mode 100644 src/com/engine/kq/biz/chain/overtime/OvertimeHoliday2HolidayChain.java create mode 100644 src/com/engine/kq/biz/chain/overtime/OvertimeHoliday2RestdayChain.java create mode 100644 src/com/engine/kq/biz/chain/overtime/OvertimeHoliday2WorkdayChain.java create mode 100644 src/com/engine/kq/biz/chain/overtime/OvertimeRestday2HolidayChain.java create mode 100644 src/com/engine/kq/biz/chain/overtime/OvertimeRestday2RestdayChain.java create mode 100644 src/com/engine/kq/biz/chain/overtime/OvertimeRestday2WorkdayChain.java create mode 100644 src/com/engine/kq/biz/chain/overtime/OvertimeWorkday2HolidayChain.java create mode 100644 src/com/engine/kq/biz/chain/overtime/OvertimeWorkday2RestdayChain.java create mode 100644 src/com/engine/kq/biz/chain/overtime/OvertimeWorkday2WorkdayChain.java create mode 100644 src/com/engine/kq/biz/chain/shiftinfo/DurationIndex.java create mode 100644 src/com/engine/kq/biz/chain/shiftinfo/OverTimeDurationIndex.java create mode 100644 src/com/engine/kq/biz/chain/shiftinfo/ShiftInfoBean.java create mode 100644 src/com/engine/kq/cmd/abnormalremind/GetAbnormalremindConditionCmd.java create mode 100644 src/com/engine/kq/cmd/abnormalremind/GetAbnormalremindInfoCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/ButtonStatusEnum.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/GetAutoEMSetCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/GetButtonBaseInfoCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/GetButtonsCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/GetExtraMapConfigCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/GetOutButtonConditionCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/GetOutButtonRangeCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/GetOutButtonsCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/GetOutSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/GetOutSignSetting.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/GetUserLastMapCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/PunchButton4E.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/PunchButtonCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/PunchOutButtonCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/ResetSerialCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/ResetUserMapCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/SaveAutoEMSetCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/SaveExtraMapConfigCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceButton/SaveOutSignSettingCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/AttendanceUtil.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/CheckCardCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/CheckEvectionCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/CheckLeaveBackCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/CheckLeaveCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/CheckOutCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/CheckOvertimeCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/CheckProcessChangeCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/CheckRuleUtil.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/CheckRuleUtil4E.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/CheckShiftCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/GetAttendanceCardCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/GetEvectionWorkDurationCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/GetLeaveBackDurationCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/GetLeaveBackInfoCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/GetLeaveWorkDurationCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/GetOutWorkDurationCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/GetOverTimeWorkDurationCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/GetProcessChangeInfoCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/GetProcessChangeTypeCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/GetProcessChangeWorkDurationCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/GetVacationInfoCmd.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/GetWorkDurationCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleave/BatchProcessingCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleave/GetImportFormCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleave/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleave/GetSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleave/GetSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleave/GetTabCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleave/SaveBalanceOfLeaveCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleave/SaveImportCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleavedetail/DeleteBalanceCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleavedetail/EditBalanceCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleavedetail/GetBalanceFormCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleavedetail/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleavedetail/GetSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleaverp/ExportExcelCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleaverp/GetChangeTypeCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleaverp/GetDetailPageInfoCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleaverp/GetPageInfoCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleaverp/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleaverp/GetSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleaverp/GetSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleaverp/GetTabCmd.java create mode 100644 src/com/engine/kq/cmd/balanceofleaverp/GetUsageRecordDetailCmd.java create mode 100644 src/com/engine/kq/cmd/group/DelGroupCmd.java create mode 100644 src/com/engine/kq/cmd/group/ExportExcelCmd.java create mode 100644 src/com/engine/kq/cmd/group/GetAddMemberConditionCmd.java create mode 100644 src/com/engine/kq/cmd/group/GetGroupFormCmd.java create mode 100644 src/com/engine/kq/cmd/group/GetGroupMemberConditionCmd.java create mode 100644 src/com/engine/kq/cmd/group/GetGroupMemberListCmd.java create mode 100644 src/com/engine/kq/cmd/group/GetGroupSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/group/GetGroupSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/group/GetGroupTreeCmd.java create mode 100644 src/com/engine/kq/cmd/group/GetMainTabsCmd.java create mode 100644 src/com/engine/kq/cmd/group/GetShiftCycleFormCmd.java create mode 100644 src/com/engine/kq/cmd/group/GetTabsCmd.java create mode 100644 src/com/engine/kq/cmd/group/ImportExcelCmd.java create mode 100644 src/com/engine/kq/cmd/group/SaveAddMemberCmd.java create mode 100644 src/com/engine/kq/cmd/group/SaveGroupCmd.java create mode 100644 src/com/engine/kq/cmd/grouplocation/DelGroupLocationCmd.java create mode 100644 src/com/engine/kq/cmd/grouplocation/GetGroupLocationFormCmd.java create mode 100644 src/com/engine/kq/cmd/grouplocation/GetGroupLocationListCmd.java create mode 100644 src/com/engine/kq/cmd/grouplocation/SaveGroupLocationCmd.java create mode 100644 src/com/engine/kq/cmd/groupmemeber/DelGroupMemberCmd.java create mode 100644 src/com/engine/kq/cmd/groupmemeber/GetGroupMemberFormCmd.java create mode 100644 src/com/engine/kq/cmd/groupmemeber/GetGroupMemberSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/groupmemeber/GetGroupMemberSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/groupmemeber/SaveGroupMemberCmd.java create mode 100644 src/com/engine/kq/cmd/groupmemeber/SaveValidateDateGroupMemberCmd.java create mode 100644 src/com/engine/kq/cmd/groupwifi/DelGroupWifiCmd.java create mode 100644 src/com/engine/kq/cmd/groupwifi/GetGroupWifiFormCmd.java create mode 100644 src/com/engine/kq/cmd/groupwifi/GetGroupWifiListCmd.java create mode 100644 src/com/engine/kq/cmd/groupwifi/SaveGroupWifiCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/AddHolidaySetCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/DeleteHolidaySetCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/EditHolidaySetCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/GetHolidayCountCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/GetHolidaySetCalendarCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/GetHolidaySetFormCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/GetImportFormCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/GetSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/GetSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/GetSyncFormCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/HasRepeatDataCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/InitHolidaySetCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/SaveImportCmd.java create mode 100644 src/com/engine/kq/cmd/holidaySet/SyncHolidaySetCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/ChangeStateProcSetStatusCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/DelCustomKQFlowCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/DelStateProcCheckRuleCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/DelStateProcSetCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetCustomKQFlowFormCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetCustomKQFlowSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetCustomKQFlowSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetCustomKQFlowTabCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetProcSetCheckRuleCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetProcSetTempletCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetCreateFormCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetFlowCheckRuleListCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetFlowFormCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetFlowWfFieldsCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetFlowWfSetCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetListSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetListSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetTabInfoCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/GetStateRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/HrmAttProcSetLogUtil.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/KqSplitActionEnum.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/KqTempletEnum.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/SaveCustomKQFlowCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcCheckRuleCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcSetCreateFormCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcSetFlowCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcSetFlowWfFieldsCmd.java create mode 100644 src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcSetFlowWfSetCmd.java create mode 100644 src/com/engine/kq/cmd/importlog/GetHistorySearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/importlog/GetImportColResultLogCmd.java create mode 100644 src/com/engine/kq/cmd/importlog/GetImportHistoryCmd.java create mode 100644 src/com/engine/kq/cmd/importlog/GetImportProcessLogCmd.java create mode 100644 src/com/engine/kq/cmd/importlog/GetImportResultCmd.java create mode 100644 src/com/engine/kq/cmd/importlog/SaveImportDeitalLogCmd.java create mode 100644 src/com/engine/kq/cmd/importlog/SaveImportLogCmd.java create mode 100644 src/com/engine/kq/cmd/importlog/SaveImportLogStatusCmd.java create mode 100644 src/com/engine/kq/cmd/leaveParentalrules/GetLeaveRulesFormCmd.java create mode 100644 src/com/engine/kq/cmd/leaverules/AddLeaveRulesCmd.java create mode 100644 src/com/engine/kq/cmd/leaverules/DeleteLeaveRulesCmd.java create mode 100644 src/com/engine/kq/cmd/leaverules/EditLeaveRulesCmd.java create mode 100644 src/com/engine/kq/cmd/leaverules/GetLeaveRulesFormCmd.java create mode 100644 src/com/engine/kq/cmd/leaverules/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/leaverules/GetSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/leaverules/GetSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/leaverules/GetUnitNameCmd.java create mode 100644 src/com/engine/kq/cmd/leaverules/IsNameRepeatCmd.java create mode 100644 src/com/engine/kq/cmd/leavetypes/AddLeaveTypesCmd.java create mode 100644 src/com/engine/kq/cmd/leavetypes/DeleteLeaveTypesCmd.java create mode 100644 src/com/engine/kq/cmd/leavetypes/EditLeaveTypesCmd.java create mode 100644 src/com/engine/kq/cmd/leavetypes/GetLeaveTypesFormCmd.java create mode 100644 src/com/engine/kq/cmd/leavetypes/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/leavetypes/GetSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/leavetypes/GetSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/leavetypes/GetTimeSelectionFormCmd.java create mode 100644 src/com/engine/kq/cmd/leavetypes/IsNameRepeatCmd.java create mode 100644 src/com/engine/kq/cmd/leavetypes/SaveDisableLeaveTypesCmd.java create mode 100644 src/com/engine/kq/cmd/leavetypes/SaveTimeSelectionFormCmd.java create mode 100644 src/com/engine/kq/cmd/myattendance/GetDetailCondition4MobileCmd.java create mode 100644 src/com/engine/kq/cmd/myattendance/GetDetailList4MobileCmd.java create mode 100644 src/com/engine/kq/cmd/myattendance/GetHrmKQMonthReportInfoCmd.java create mode 100644 src/com/engine/kq/cmd/myattendance/GetHrmKQReportDetialInfoCmd.java create mode 100644 src/com/engine/kq/cmd/myattendance/GetHrmKQReportInfoCmd.java create mode 100644 src/com/engine/kq/cmd/myattendance/GetHrmKQSignInfoCmd.java create mode 100644 src/com/engine/kq/cmd/originalpunchrp/ExportExcelCmd.java create mode 100644 src/com/engine/kq/cmd/originalpunchrp/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/originalpunchrp/GetSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/originalpunchrp/GetSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/overtimerules/AddOvertimeRulesCmd.java create mode 100644 src/com/engine/kq/cmd/overtimerules/DeleteOvertimeRulesCmd.java create mode 100644 src/com/engine/kq/cmd/overtimerules/EditOverTimeRulesCmd.java create mode 100644 src/com/engine/kq/cmd/overtimerules/GetOvertimeRulesFormCmd.java create mode 100644 src/com/engine/kq/cmd/overtimerules/GetOvertimeSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/overtimerules/GetOvertimeUnitFormCmd.java create mode 100644 src/com/engine/kq/cmd/overtimerules/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/overtimerules/GetSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/overtimerules/IsRepeatSettingCmd.java create mode 100644 src/com/engine/kq/cmd/overtimerules/SaveDefaultCmd.java create mode 100644 src/com/engine/kq/cmd/overtimerules/SaveOvertimeUnitCmd.java create mode 100644 src/com/engine/kq/cmd/remindOnPC/GetRemindInfoCmd.java create mode 100644 src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java create mode 100644 src/com/engine/kq/cmd/report/ExportExcelCmd.java create mode 100644 src/com/engine/kq/cmd/report/FormatReportCmd.java create mode 100644 src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java create mode 100644 src/com/engine/kq/cmd/report/GetKQReportCmd.java create mode 100644 src/com/engine/kq/cmd/report/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/report/GetSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/report4E/GetBalanceInfoCmd.java create mode 100644 src/com/engine/kq/cmd/report4E/GetScheduleDataCmd.java create mode 100644 src/com/engine/kq/cmd/report4E/PunchButton4ECmd.java create mode 100644 src/com/engine/kq/cmd/reportdetial/GetAbsenteeismInfoCmd.java create mode 100644 src/com/engine/kq/cmd/reportdetial/GetBeLateInfoCmd.java create mode 100644 src/com/engine/kq/cmd/reportdetial/GetDailyDetialInfoCmd.java create mode 100644 src/com/engine/kq/cmd/reportdetial/GetForgotCheckInfoCmd.java create mode 100644 src/com/engine/kq/cmd/reportdetial/GetLeaveEearlyInfoCmd.java create mode 100644 src/com/engine/kq/cmd/reportdetial/GetLeaveInfoCmd.java create mode 100644 src/com/engine/kq/cmd/reportdetial/GetNeedSignInfoCmd.java create mode 100644 src/com/engine/kq/cmd/reportdetial/GetSignInfoCmd.java create mode 100644 src/com/engine/kq/cmd/reportdetial/GetTabsCmd.java create mode 100644 src/com/engine/kq/cmd/reportdetial/GetWorkDayInfoCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/ChangeFieldGroupCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/DeleteFieldDefineCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/DeleteGroupCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/DeleteReportMoudleCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/GetFieldDefineFormCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/GetFieldDefineListCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/GetFieldDefineTabsCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/GetFieldOrderDefineCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/GetGroupFormCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/GetGroupListCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/GetReportMoudleFormCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/GetReportMoudleTabsCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/SaveFieldDefineCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/SaveFieldDefineListCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/SaveFieldOrderDefineCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/SaveGroupCmd.java create mode 100644 src/com/engine/kq/cmd/reportfielddefine/SaveReportMoudleCmd.java create mode 100644 src/com/engine/kq/cmd/reportshare/DeleteReportShareCmd.java create mode 100644 src/com/engine/kq/cmd/reportshare/GetReportShareFormCmd.java create mode 100644 src/com/engine/kq/cmd/reportshare/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/reportshare/GetSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/reportshare/GetSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/reportshare/SaveReportShareCmd.java create mode 100644 src/com/engine/kq/cmd/schedulecode/DelScheduleDeviceCmd.java create mode 100644 src/com/engine/kq/cmd/schedulecode/GetScheduleCodeConditionCmd.java create mode 100644 src/com/engine/kq/cmd/schedulecode/GetScheduleCodeFormCmd.java create mode 100644 src/com/engine/kq/cmd/schedulecode/GetScheduleCodeImportFormCmd.java create mode 100644 src/com/engine/kq/cmd/schedulecode/GetScheduleCodeListCmd.java create mode 100644 src/com/engine/kq/cmd/schedulecode/GetScheduleDeviceConditionCmd.java create mode 100644 src/com/engine/kq/cmd/schedulecode/GetScheduleDeviceFormCmd.java create mode 100644 src/com/engine/kq/cmd/schedulecode/GetScheduleDeviceListCmd.java create mode 100644 src/com/engine/kq/cmd/schedulecode/SaveScheduleCodeCmd.java create mode 100644 src/com/engine/kq/cmd/schedulecode/SaveScheduleCodeImportCmd.java create mode 100644 src/com/engine/kq/cmd/schedulecode/SaveScheduleDeviceCmd.java create mode 100644 src/com/engine/kq/cmd/schedulesignimport/GetImportFormCmd.java create mode 100644 src/com/engine/kq/cmd/schedulesignimport/GetImportSetFormCmd.java create mode 100644 src/com/engine/kq/cmd/schedulesignimport/SaveImportCmd.java create mode 100644 src/com/engine/kq/cmd/schedulesignimport/SaveImportSetCmd.java create mode 100644 src/com/engine/kq/cmd/schedulesignimport/SynDataCmd.java create mode 100644 src/com/engine/kq/cmd/schedulesignimport/SynDataOpenCmd.java create mode 100644 src/com/engine/kq/cmd/schedulesignimport/SynDingTalkDataCmd.java create mode 100644 src/com/engine/kq/cmd/schedulesignimport/UpLoadDataCmd.java create mode 100644 src/com/engine/kq/cmd/settings/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/settings/GetSettingsFormCmd.java create mode 100644 src/com/engine/kq/cmd/settings/SaveSettingsCmd.java create mode 100644 src/com/engine/kq/cmd/setupwizard/CheckNeedInitCmd.java create mode 100644 src/com/engine/kq/cmd/setupwizard/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/setupwizard/GetSetupFormCmd.java create mode 100644 src/com/engine/kq/cmd/setupwizard/GetSetupStepsCmd.java create mode 100644 src/com/engine/kq/cmd/setupwizard/PerformInitializationCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/DelShiftManagementFormCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/GetDetachOperatelevelCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/GetEmailRemindFormCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/GetMessageRemindFormCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementBaseFormCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementPersonalizedFormCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementSearchListCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/GetTabsCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/SaveEmailRemindCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/SaveMessageRemindCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/SaveShiftManagementBaseFormCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/SaveShiftManagementPersonalizedFormCmd.java create mode 100644 src/com/engine/kq/cmd/shiftmanagement/toolkit/ShiftManagementToolKit.java create mode 100644 src/com/engine/kq/cmd/shiftschedule/DelShiftScheduleCmd.java create mode 100644 src/com/engine/kq/cmd/shiftschedule/ExportExcelCmd.java create mode 100644 src/com/engine/kq/cmd/shiftschedule/GetBatchShiftScheduleFromCmd.java create mode 100644 src/com/engine/kq/cmd/shiftschedule/GetHrmScheduleReportInfoCmd.java create mode 100644 src/com/engine/kq/cmd/shiftschedule/GetSearchConditionCmd.java create mode 100644 src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleCmd.java create mode 100644 src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleMembersValidateCmd.java create mode 100644 src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleTotalCmd.java create mode 100644 src/com/engine/kq/cmd/shiftschedule/GetTabsCmd.java create mode 100644 src/com/engine/kq/cmd/shiftschedule/ImportExcelCmd.java create mode 100644 src/com/engine/kq/cmd/shiftschedule/SaveBatchShiftScheduleCmd.java create mode 100644 src/com/engine/kq/cmd/shiftschedule/SaveShiftScheduleCmd.java create mode 100644 src/com/engine/kq/cmd/travelrules/GetRightMenuCmd.java create mode 100644 src/com/engine/kq/cmd/travelrules/GetTravelRulesFormCmd.java create mode 100644 src/com/engine/kq/cmd/travelrules/SaveTravelRulesCmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/DoUpgrade10Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/DoUpgrade12Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/DoUpgrade1Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/DoUpgrade2Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/DoUpgrade3Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/DoUpgrade4Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/DoUpgrade5Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/DoUpgrade6Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/DoUpgrade7Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/DoUpgrade8Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/DoUpgrade9Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/GetTreeTabsCmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/GetUpgrade10Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/GetUpgrade12Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/GetUpgrade12DataCmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/GetUpgrade1Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/GetUpgrade2Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/GetUpgrade3Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/GetUpgrade4Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/GetUpgrade5Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/GetUpgrade6Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/GetUpgrade7Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/GetUpgrade8Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/GetUpgrade9Cmd.java create mode 100644 src/com/engine/kq/cmd/upgrade/KQUpgradeTabEnum.java create mode 100644 src/com/engine/kq/cmd/upgrade/UpgradeUtil.java create mode 100644 src/com/engine/kq/entity/KQBalanceOfLeaveEntity.java create mode 100644 src/com/engine/kq/entity/KQGroupEntity.java create mode 100644 src/com/engine/kq/entity/KQLeaveInfoEntity.java create mode 100644 src/com/engine/kq/entity/KQOvertimeRulesDetailEntity.java create mode 100644 src/com/engine/kq/entity/KQReportEntity.java create mode 100644 src/com/engine/kq/entity/KQScheduleSignEntity.java create mode 100644 src/com/engine/kq/entity/KQShiftRuleEntity.java create mode 100644 src/com/engine/kq/entity/KQUsageHistoryEntity.java create mode 100644 src/com/engine/kq/entity/TimeScopeEntity.java create mode 100644 src/com/engine/kq/entity/TimeSignScopeEntity.java create mode 100644 src/com/engine/kq/entity/WorkTimeEntity.java create mode 100644 src/com/engine/kq/enums/DurationTypeEnum.java create mode 100644 src/com/engine/kq/enums/FlowReportTypeEnum.java create mode 100644 src/com/engine/kq/enums/KQSettingsEnum.java create mode 100644 src/com/engine/kq/enums/KqSplitFlowTypeEnum.java create mode 100644 src/com/engine/kq/enums/OverTimeComputingModeEnum.java create mode 100644 src/com/engine/kq/enums/ReportColumnEnum.java create mode 100644 src/com/engine/kq/jucailin/cmd/calendar/GetCalendarSettingFormCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/calendar/GetCalendarSettingListCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/common/DeleteDataCommonCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/common/InsertDataCommonCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/common/QueryDataCommonCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/common/UpdateDataCommonCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/cycle/GetCycleFormCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/cycle/GetCycleListCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/cycle/GetCycleSearchConditionCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/cycle/GetCycleSettingFormCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/cycle/GetCycleSettingListCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/cycle/GetCycleSettingTreeCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/cycle/GetCycledetailFormCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/cycle/GetCycledetailListCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/personGroup/GetPersonGroupListCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/personGroup/GetSuitOrganzationFormCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/personGroup/GetSuitOrganzationListCmd.java create mode 100644 src/com/engine/kq/jucailin/cmd/personGroup/SaveSuitOrganzationCmd.java create mode 100644 src/com/engine/kq/jucailin/enums/FieldHtmlTypeEnum.java create mode 100644 src/com/engine/kq/jucailin/exception/AttendanceRunTimeException.java create mode 100644 src/com/engine/kq/jucailin/exception/ExceptionUtil.java create mode 100644 src/com/engine/kq/jucailin/genid/DefaultWorker.java create mode 100644 src/com/engine/kq/jucailin/genid/IdGenerator.java create mode 100644 src/com/engine/kq/jucailin/genid/SnowflakeId.java create mode 100644 src/com/engine/kq/jucailin/genid/Worker.java create mode 100644 src/com/engine/kq/jucailin/service/KQCalendarSettingService.java create mode 100644 src/com/engine/kq/jucailin/service/KQCommonService.java create mode 100644 src/com/engine/kq/jucailin/service/KQCycleSettingService.java create mode 100644 src/com/engine/kq/jucailin/service/KQPersonGroupService.java create mode 100644 src/com/engine/kq/jucailin/service/impl/KQCalendarSettingServiceImpl.java create mode 100644 src/com/engine/kq/jucailin/service/impl/KQCommonServiceImpl.java create mode 100644 src/com/engine/kq/jucailin/service/impl/KQCycleSettingServiceImpl.java create mode 100644 src/com/engine/kq/jucailin/service/impl/KQPersonGroupServiceImpl.java create mode 100644 src/com/engine/kq/jucailin/util/CommonUtil.java create mode 100644 src/com/engine/kq/jucailin/util/Constant.java create mode 100644 src/com/engine/kq/jucailin/util/DateUtil.java create mode 100644 src/com/engine/kq/jucailin/util/DbTools.java create mode 100644 src/com/engine/kq/jucailin/util/KQDateUtil.java create mode 100644 src/com/engine/kq/jucailin/util/ListConversionMethod.java create mode 100644 src/com/engine/kq/jucailin/util/PageUidFactory.java create mode 100644 src/com/engine/kq/jucailin/util/ResponseResult.java create mode 100644 src/com/engine/kq/jucailin/web/KQCalendarSettingAction.java create mode 100644 src/com/engine/kq/jucailin/web/KQCommonAction.java create mode 100644 src/com/engine/kq/jucailin/web/KQCycleSettingAction.java create mode 100644 src/com/engine/kq/jucailin/web/KQPersonGroupAction.java create mode 100644 src/com/engine/kq/jucailin/web/common/KQCommonAction.java create mode 100644 src/com/engine/kq/jucailin/web/persongroup/KQCycleSettingAction.java create mode 100644 src/com/engine/kq/jucailin/web/persongroup/KQPersonGroupAction.java create mode 100644 src/com/engine/kq/log/KQLog.java create mode 100644 src/com/engine/kq/service/ImportLogService.java create mode 100644 src/com/engine/kq/service/KQAttendanceButtonService.java create mode 100644 src/com/engine/kq/service/KQAttendanceEventService.java create mode 100644 src/com/engine/kq/service/KQAttendanceSetService.java create mode 100644 src/com/engine/kq/service/KQBalanceDetailService.java create mode 100644 src/com/engine/kq/service/KQBalanceOfLeaveRpService.java create mode 100644 src/com/engine/kq/service/KQBalanceOfLeaveService.java create mode 100644 src/com/engine/kq/service/KQGroupLocationService.java create mode 100644 src/com/engine/kq/service/KQGroupMemberService.java create mode 100644 src/com/engine/kq/service/KQGroupService.java create mode 100644 src/com/engine/kq/service/KQGroupWifiService.java create mode 100644 src/com/engine/kq/service/KQHolidaySetService.java create mode 100644 src/com/engine/kq/service/KQLeaveParentalService.java create mode 100644 src/com/engine/kq/service/KQLeaveRulesService.java create mode 100644 src/com/engine/kq/service/KQLeaveTypesService.java create mode 100644 src/com/engine/kq/service/KQMyAttendanceService.java create mode 100644 src/com/engine/kq/service/KQOriginalPunchRpService.java create mode 100644 src/com/engine/kq/service/KQOvertimeRulesService.java create mode 100644 src/com/engine/kq/service/KQRemindMsgService.java create mode 100644 src/com/engine/kq/service/KQRemindOnPCService.java create mode 100644 src/com/engine/kq/service/KQReport4EService.java create mode 100644 src/com/engine/kq/service/KQReportDetailService.java create mode 100644 src/com/engine/kq/service/KQReportFieldDefineService.java create mode 100644 src/com/engine/kq/service/KQReportService.java create mode 100644 src/com/engine/kq/service/KQReportShareService.java create mode 100644 src/com/engine/kq/service/KQScheduleCodeService.java create mode 100644 src/com/engine/kq/service/KQScheduleSignImportService.java create mode 100644 src/com/engine/kq/service/KQSettingsService.java create mode 100644 src/com/engine/kq/service/KQSetupWizardService.java create mode 100644 src/com/engine/kq/service/KQShiftManagementService.java create mode 100644 src/com/engine/kq/service/KQShiftScheduleService.java create mode 100644 src/com/engine/kq/service/KQTravelRulesService.java create mode 100644 src/com/engine/kq/service/KQUpgradeService.java create mode 100644 src/com/engine/kq/service/impl/ImportLogServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQAttendanceButtonServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQAttendanceEventServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQAttendanceSetServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQBalanceDetailServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQBalanceOfLeaveRpServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQBalanceOfLeaveServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQGroupLocationServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQGroupMemberServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQGroupServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQGroupWifiServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQHolidaySetServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQLeaveParentalServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQLeaveRulesServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQLeaveTypesServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQMyAttendanceServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQOriginalPunchRpServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQOvertimeRulesServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQRemindMsgServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQRemindOnPCServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQReport4EServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQReportDetailServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQReportFieldDefineServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQReportServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQReportShareServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQScheduleCodeServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQScheduleSignImportServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQSettingsServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQSetupWizardServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQShiftManagementServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQShiftScheduleServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQTravelRulesServiceImpl.java create mode 100644 src/com/engine/kq/service/impl/KQUpgradeServiceImpl.java create mode 100644 src/com/engine/kq/timer/KQOvertimeCardBean.java create mode 100644 src/com/engine/kq/timer/KQQueue.java create mode 100644 src/com/engine/kq/timer/KQTask.java create mode 100644 src/com/engine/kq/timer/KQTaskBean.java create mode 100644 src/com/engine/kq/timer/KQTaskTimerSchedule.java create mode 100644 src/com/engine/kq/util/ExcelUtil.java create mode 100644 src/com/engine/kq/util/ImportProcessUtil.java create mode 100644 src/com/engine/kq/util/KQDurationCalculatorUtil.java create mode 100644 src/com/engine/kq/util/KQLockAttendaUtil.java create mode 100644 src/com/engine/kq/util/KQTransMethod.java create mode 100644 src/com/engine/kq/util/PageUidFactory.java create mode 100644 src/com/engine/kq/util/ResponseResult.java create mode 100644 src/com/engine/kq/util/TransMethod.java create mode 100644 src/com/engine/kq/util/UtilKQ.java create mode 100644 src/com/engine/kq/util/face/hrmrestful/service/KqPunchButton4EWebServiceManager.java create mode 100644 src/com/engine/kq/web/GetKQDatasAction.java create mode 100644 src/com/engine/kq/web/ImportLogAction.java create mode 100644 src/com/engine/kq/web/KQAttendanceButtonAction.java create mode 100644 src/com/engine/kq/web/KQAttendanceEventAction.java create mode 100644 src/com/engine/kq/web/KQAttendanceSetAction.java create mode 100644 src/com/engine/kq/web/KQBalanceDetailAction.java create mode 100644 src/com/engine/kq/web/KQBalanceOfLeaveAction.java create mode 100644 src/com/engine/kq/web/KQBalanceOfLeaveRpAction.java create mode 100644 src/com/engine/kq/web/KQGroupAction.java create mode 100644 src/com/engine/kq/web/KQGroupLocationAction.java create mode 100644 src/com/engine/kq/web/KQGroupMemberAction.java create mode 100644 src/com/engine/kq/web/KQGroupWifiAction.java create mode 100644 src/com/engine/kq/web/KQHolidaySetAction.java create mode 100644 src/com/engine/kq/web/KQLeaveParentalAction.java create mode 100644 src/com/engine/kq/web/KQLeaveRulesAction.java create mode 100644 src/com/engine/kq/web/KQLeaveTypesAction.java create mode 100644 src/com/engine/kq/web/KQMyAttendanceAction.java create mode 100644 src/com/engine/kq/web/KQOriginalPunchRpAction.java create mode 100644 src/com/engine/kq/web/KQOvertimeRulesAction.java create mode 100644 src/com/engine/kq/web/KQRemindMsgAction.java create mode 100644 src/com/engine/kq/web/KQRemindOnPCAction.java create mode 100644 src/com/engine/kq/web/KQReport4EAction.java create mode 100644 src/com/engine/kq/web/KQReportAction.java create mode 100644 src/com/engine/kq/web/KQReportDetailAction.java create mode 100644 src/com/engine/kq/web/KQReportFieldDefineAction.java create mode 100644 src/com/engine/kq/web/KQReportShareAction.java create mode 100644 src/com/engine/kq/web/KQScheduleCodeAction.java create mode 100644 src/com/engine/kq/web/KQScheduleSignImportAction.java create mode 100644 src/com/engine/kq/web/KQSettingsAction.java create mode 100644 src/com/engine/kq/web/KQSetupWizardAction.java create mode 100644 src/com/engine/kq/web/KQShiftManagementAction.java create mode 100644 src/com/engine/kq/web/KQShiftScheduleAction.java create mode 100644 src/com/engine/kq/web/KQTravelRulesAction.java create mode 100644 src/com/engine/kq/web/KQUpgradeAction.java create mode 100644 src/com/engine/kq/web/KqPunchButton4EAction.java create mode 100644 src/com/engine/kq/wfset/action/KqCheckLockAction.java create mode 100644 src/com/engine/kq/wfset/action/KqDeductionVacationAction.java create mode 100644 src/com/engine/kq/wfset/action/KqFreezeVacationAction.java create mode 100644 src/com/engine/kq/wfset/action/KqPaidLeaveAction.java create mode 100644 src/com/engine/kq/wfset/action/KqReleaseVacationAction.java create mode 100644 src/com/engine/kq/wfset/action/KqSplitAction.java create mode 100644 src/com/engine/kq/wfset/attendance/dao/HrmAttFlowVersionDao.java create mode 100644 src/com/engine/kq/wfset/attendance/dao/HrmAttProcActionDao.java create mode 100644 src/com/engine/kq/wfset/attendance/dao/HrmAttProcFieldsDao.java create mode 100644 src/com/engine/kq/wfset/attendance/dao/HrmAttProcRelationDao.java create mode 100644 src/com/engine/kq/wfset/attendance/dao/HrmAttProcSetDao.java create mode 100644 src/com/engine/kq/wfset/attendance/dao/WorkflowBaseDao.java create mode 100644 src/com/engine/kq/wfset/attendance/dao/WorkflowBillfieldDao.java create mode 100644 src/com/engine/kq/wfset/attendance/domain/HrmAttFlowType.java create mode 100644 src/com/engine/kq/wfset/attendance/domain/HrmAttFlowVersion.java create mode 100644 src/com/engine/kq/wfset/attendance/domain/HrmAttProcAction.java create mode 100644 src/com/engine/kq/wfset/attendance/domain/HrmAttProcFields.java create mode 100644 src/com/engine/kq/wfset/attendance/domain/HrmAttProcRelation.java create mode 100644 src/com/engine/kq/wfset/attendance/domain/HrmAttProcSet.java create mode 100644 src/com/engine/kq/wfset/attendance/domain/WorkflowBase.java create mode 100644 src/com/engine/kq/wfset/attendance/domain/WorkflowBillfield.java create mode 100644 src/com/engine/kq/wfset/attendance/framework/BaseCache.java create mode 100644 src/com/engine/kq/wfset/attendance/framework/BaseConnection.java create mode 100644 src/com/engine/kq/wfset/attendance/framework/BaseController.java create mode 100644 src/com/engine/kq/wfset/attendance/framework/BaseDao.java create mode 100644 src/com/engine/kq/wfset/attendance/framework/BaseEntity.java create mode 100644 src/com/engine/kq/wfset/attendance/framework/BaseManager.java create mode 100644 src/com/engine/kq/wfset/attendance/manager/HrmAttFlowVersionManager.java create mode 100644 src/com/engine/kq/wfset/attendance/manager/HrmAttProcActionManager.java create mode 100644 src/com/engine/kq/wfset/attendance/manager/HrmAttProcActionManagerE9.java create mode 100644 src/com/engine/kq/wfset/attendance/manager/HrmAttProcFieldsManager.java create mode 100644 src/com/engine/kq/wfset/attendance/manager/HrmAttProcRelationManager.java create mode 100644 src/com/engine/kq/wfset/attendance/manager/HrmAttProcSetManager.java create mode 100644 src/com/engine/kq/wfset/attendance/manager/WorkflowBaseManager.java create mode 100644 src/com/engine/kq/wfset/attendance/manager/WorkflowBillfieldManager.java create mode 100644 src/com/engine/kq/wfset/auto/AutoInitWFSet.java create mode 100644 src/com/engine/kq/wfset/bean/LeavebackSplitBean.java create mode 100644 src/com/engine/kq/wfset/bean/OvertimeBalanceTimeBean.java create mode 100644 src/com/engine/kq/wfset/bean/ProcessChangeSplitBean.java create mode 100644 src/com/engine/kq/wfset/bean/SplitBean.java create mode 100644 src/com/engine/kq/wfset/job/HrmTimesArrayJob.java create mode 100644 src/com/engine/kq/wfset/test/DateTimeTest.java create mode 100644 src/com/engine/kq/wfset/util/KQ122Util.java create mode 100644 src/com/engine/kq/wfset/util/KQAttFlowCheckUtil.java create mode 100644 src/com/engine/kq/wfset/util/KQFlowCardUtil.java create mode 100644 src/com/engine/kq/wfset/util/KQFlowEvectionUtil.java create mode 100644 src/com/engine/kq/wfset/util/KQFlowLeaveBackUtil.java create mode 100644 src/com/engine/kq/wfset/util/KQFlowLeaveUtil.java create mode 100644 src/com/engine/kq/wfset/util/KQFlowOtherUtil.java create mode 100644 src/com/engine/kq/wfset/util/KQFlowOutUtil.java create mode 100644 src/com/engine/kq/wfset/util/KQFlowOvertimeUtil.java create mode 100644 src/com/engine/kq/wfset/util/KQFlowProcessChangeUtil.java create mode 100644 src/com/engine/kq/wfset/util/KQFlowShiftUtil.java create mode 100644 src/com/engine/kq/wfset/util/KQFlowUtil.java create mode 100644 src/com/engine/kq/wfset/util/KQSignUtil.java create mode 100644 src/com/engine/kq/wfset/util/SplitActionUtil.java create mode 100644 src/com/engine/kq/wfset/util/SplitSelectSet.java diff --git a/src/com/api/kq/browser/service/impl/KQAttSetBrowserService.java b/src/com/api/kq/browser/service/impl/KQAttSetBrowserService.java new file mode 100644 index 0000000..a5a1957 --- /dev/null +++ b/src/com/api/kq/browser/service/impl/KQAttSetBrowserService.java @@ -0,0 +1,141 @@ +package com.api.kq.browser.service.impl; + +import com.api.browser.bean.ListHeadBean; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SplitTableBean; +import com.api.browser.bean.SplitTableColBean; +import com.api.browser.service.BrowserService; +import com.api.browser.util.BoolAttr; +import com.api.browser.util.BrowserConstant; +import com.api.browser.util.BrowserDataType; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.api.browser.util.SplitTableUtil; +import com.api.browser.util.SqlUtils; +import com.engine.kq.util.TransMethod; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import weaver.conn.RecordSet; +import weaver.formmode.interfaces.WfToModeTransmethod; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +/** + * 考勤流程设置 浏览按钮 + * type : KQAttSet + */ +public class KQAttSetBrowserService extends BrowserService { + + @Override + public Map getBrowserData(Map params) throws Exception { + Map apidatas = new HashMap(); + + String workflowname = Util.null2String(params.get("workflowname")); + String kqtype = Util.null2String(params.get("kqtype")); + String sqlwhere = " where 1=1 "; + if(!workflowname.equals("")){ + String sql = " select id from workflow_base where workflowname like '%"+workflowname+"%' "; + sqlwhere += " and field001 in("+sql+")"; + } + if(!kqtype.equals("")){ + sqlwhere += " and field006 in ("+kqtype+")"; + } + + sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere); + // 设置好搜索条件 + String backFields = " field001 as id ,field001, field006 "; + String fromSql = " kq_att_proc_set "; + + List cols = new ArrayList(); + cols.add(new SplitTableColBean("true","id")); + cols.add(new SplitTableColBean("50%",SystemEnv.getHtmlLabelName(18104, user.getLanguage()),"field001","field001","weaver.formmode.interfaces.WfToModeTransmethod.getWorkflowNameBlank",""+user.getLanguage()).setIsInputCol(BoolAttr.TRUE).setShowType(1)); + cols.add(new SplitTableColBean("50%",SystemEnv.getHtmlLabelName(16070,user.getLanguage()),"field006","field006","com.engine.kq.util.TransMethod.getFlowTypeName",""+user.getLanguage()).setShowType(0)); + + SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + @Override + public Map getBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + ConditionFactory conditionFactory = new ConditionFactory(user); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 18104, "workflowname", true)); + return apidatas; + } + + @Override + public Map getMultBrowserDestData(Map params) throws Exception { + Map apidatas = new HashMap(); + List> datas = new ArrayList>(); + String selectids = Util.null2String(params.get(BrowserConstant.BROWSER_MULT_DEST_SELECTIDS)); + if(user==null||"".equals(selectids)){ + return apidatas; + } + WfToModeTransmethod wfToModeTransmethod = new WfToModeTransmethod(); + TransMethod transMethod = new TransMethod(); + RecordSet recordSet = new RecordSet(); + String tempSql = " select field001 as id ,field001, field006 from kq_att_proc_set where 1=1 and field001 in ("+selectids+") "; + recordSet.executeQuery(tempSql); + while (recordSet.next()){ + String kqtype = Util.null2String(recordSet.getString("kqtype")); + String kqtypeShow = transMethod.getKQTypeName(kqtype,""+user.getLanguage()); + + Map item = new HashMap(); + item.put("id", recordSet.getString("id")); + item.put("field001", wfToModeTransmethod.getWorkflowNameBlank(recordSet.getString("field001"),user.getLanguage()+"")); + item.put("field006", new TransMethod().getFlowTypeName(recordSet.getString("field006"), ""+user.getLanguage())); + datas.add(item); + } + List tableHeadColumns = new ArrayList(); + tableHeadColumns.add(new ListHeadBean("id",BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("field001","",1,BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("field006","",0)); + + apidatas.put(BrowserConstant.BROWSER_RESULT_COLUMN, tableHeadColumns); + apidatas.put(BrowserConstant.BROWSER_RESULT_DATA, datas); + apidatas.put(BrowserConstant.BROWSER_RESULT_TYPE, BrowserDataType.LIST_ALL_DATA.getTypeid()); + return apidatas; + } + + @Override + public Map browserAutoComplete( + HttpServletRequest request, HttpServletResponse response) throws Exception { + + Map apidatas = new HashMap(); + String workflowname=request.getParameter("q"); + String kqtype = Util.null2String(request.getParameter("kqtype")); + RecordSet rs=new RecordSet(); + String sqlwhere = " where 1=1 "; + if(!workflowname.equals("")){ + String sql = " select id from workflow_base where workflowname like '%"+workflowname+"%' "; + sqlwhere += " and field001 in("+sql+")"; + } + if(!kqtype.equals("")){ + sqlwhere += " and field006 in ("+kqtype+")"; + } + // 设置好搜索条件 + String backFields = " field001 as id ,field001, field006 "; + String fromSql = " kq_att_proc_set "; + String sql = "select "+backFields+" from "+fromSql+sqlwhere; + + WfToModeTransmethod wfToModeTransmethod = new WfToModeTransmethod(); + rs.executeQuery(sql); + List> datas = new ArrayList>(); + while(rs.next()){ + Map item = new HashMap(); + item.put("id", Util.null2String(rs.getString("field001"))); + String name = Util.null2String(wfToModeTransmethod.getWorkflowNameBlank(rs.getString("field001"),user.getLanguage()+"")); + item.put("name", name); + datas.add(item); + } + apidatas.put("datas",datas); + return apidatas; + } +} diff --git a/src/com/api/kq/browser/service/impl/KQDeductTiaoxiuBrowserService.java b/src/com/api/kq/browser/service/impl/KQDeductTiaoxiuBrowserService.java new file mode 100644 index 0000000..e238f90 --- /dev/null +++ b/src/com/api/kq/browser/service/impl/KQDeductTiaoxiuBrowserService.java @@ -0,0 +1,230 @@ +package com.api.kq.browser.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.api.browser.bean.*; +import com.api.browser.service.BrowserService; +import com.api.browser.util.*; +import com.engine.kq.util.TransMethod; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 假期类型浏览按钮 + * type : KQLeaveType + */ +public class KQDeductTiaoxiuBrowserService extends BrowserService { + private BaseBean log = new BaseBean(); + + @Override + public Map getBrowserData(Map params) throws Exception { + String advance = Util.null2String(params.get("advance")); + if("".equals(advance) || "0".equals(advance)) + return getBasicData(params); + return getAdvanceData(params); + } + + private Map getBasicData(Map params) throws Exception { + Map apidatas = new HashMap(); + + String groupname = Util.null2String(params.get("name")); + String sqlWhere = Util.null2String(params.get("sqlWhere")); + String sqlwhere = " where 1=1 "; + if(!groupname.equals("")){ + sqlwhere += " and name like '%"; + sqlwhere += Util.fromScreen2(groupname,user.getLanguage()); + sqlwhere += "%'"; + } + +// if(!sqlWhere.equals("")){ +// sqlwhere += " and "+sqlWhere; +// } + + sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere); + // 设置好搜索条件 + String backFields = " id ,name "; + String fromSql = " kq_deduct_tiaoxiu "; + log.writeLog("1.name="+groupname+",sqlwhere="+sqlwhere); + + List cols = new ArrayList(); + cols.add(new SplitTableColBean("true","id")); + cols.add(new SplitTableColBean("100%",SystemEnv.getHtmlLabelName(17666, user.getLanguage()),"name","name").setIsInputCol(BoolAttr.TRUE).setShowType(1)); + + SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + private Map getAdvanceData(Map params) throws Exception { + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + + Map apidatas = new HashMap(); + + String groupname = Util.null2String(params.get("name")); + String sqlWhere = Util.null2String(params.get("sqlWhere")); + String sqlwhere = " where 1=1 "; + if(!groupname.equals("")){ + sqlwhere += " and name like '%"; + sqlwhere += Util.fromScreen2(groupname,user.getLanguage()); + sqlwhere += "%'"; + } + + if(!sqlWhere.equals("")){ + sqlwhere += " and "+sqlWhere; + } + + sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere); + // 设置好搜索条件 + String backFields = " id,id as id1,id as id2,name "; + String fromSql = " kq_deduct_tiaoxiu "; + + log.writeLog("2.name="+groupname+",sqlwhere="+sqlwhere); + List cols = new ArrayList(); + cols.add(new SplitTableColBean("true","id")); + cols.add(new SplitTableColBean("100%",SystemEnv.getHtmlLabelName(17666, user.getLanguage()),"name","name", "", "column:id+++" + user.getLanguage()).setIsInputCol(BoolAttr.TRUE).setShowType(1)); + SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + @Override + public Map getBrowserConditionInfo(Map params) throws Exception { + String advance = Util.null2String(params.get("advance")); + if("".equals(advance) || "0".equals(advance)) + return getBasicBrowserConditionInfo(params); + return getAdvanceBrowserConditionInfo(params); + } + + public Map getBasicBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + + ConditionFactory conditionFactory = new ConditionFactory(user); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 17666, "name", true)); + + return apidatas; + } + + public Map getAdvanceBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + + ConditionFactory conditionFactory = new ConditionFactory(user); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 17666, "name")); + + + return apidatas; + } + + @Override + public Map getMultBrowserDestData(Map params) throws Exception { + Map apidatas = new HashMap(); + List> datas = new ArrayList>(); + String selectids = Util.null2String(params.get(BrowserConstant.BROWSER_MULT_DEST_SELECTIDS)); + if(user==null||"".equals(selectids)){ + return apidatas; + } + TransMethod transMethod = new TransMethod(); + String tmp_order = Util.null2String(selectids); + Map item = null; + if(tmp_order.length()>0){ + String[] orders = tmp_order.split(","); + if(null != orders && orders.length>0){ + for (int i = 0; i < orders.length; i++) { + item = new HashMap(); + if("1".equals(orders[i])){ + item.put("id", "1"); + item.put("name", "节假日"); + datas.add(item); + }else if("2".equals(orders[i])){ + item.put("id", "2"); + item.put("name", "工作日"); + datas.add(item); + }else if("3".equals(orders[i])){ + item.put("id", "3"); + item.put("name", "休息日"); + datas.add(item); + } + } + } + } + + RecordSet recordSet = new RecordSet(); + String tempSql = " select id,name from kq_deduct_tiaoxiu where 1=1 and id in ("+selectids+") "; + log.writeLog("3.selectids="+selectids+",datas="+ JSONObject.toJSONString(datas)); +// recordSet.executeQuery(tempSql); +// while (recordSet.next()){ +// String id = recordSet.getString("id"); +// if(tmp_order.length()>0){ +// String[] orders = tmp_order.split(","); +// if(null != orders && orders.length>0){ +// for (int i = 0; i < orders.length; i++) { +// item = new HashMap(); +// +// } +// } +// } +// } + List tableHeadColumns = new ArrayList(); + tableHeadColumns.add(new ListHeadBean("id",BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("name","",1,BoolAttr.TRUE)); + + apidatas.put(BrowserConstant.BROWSER_RESULT_COLUMN, tableHeadColumns); + apidatas.put(BrowserConstant.BROWSER_RESULT_DATA, datas); + apidatas.put(BrowserConstant.BROWSER_RESULT_TYPE, BrowserDataType.LIST_ALL_DATA.getTypeid()); + return apidatas; + } + + @Override + public Map browserAutoComplete(HttpServletRequest request, HttpServletResponse response) throws Exception { + + Map apidatas = new HashMap(); + String outSqlWhere=request.getParameter("sqlWhere"); + String groupname=request.getParameter("q"); + String includeAll=request.getParameter("includeAll"); + RecordSet rs=new RecordSet(); + String sqlwhere = " where 1=1 "; + + if(!groupname.equals("")){ + sqlwhere += " and name like '%"; + sqlwhere += Util.fromScreen2(groupname,user.getLanguage()); + sqlwhere += "%'"; + } + + if(!outSqlWhere.equals("")){ + sqlwhere += " and "+outSqlWhere; + } + // 设置好搜索条件 + String backFields = " id ,name "; + String fromSql = " kq_deduct_tiaoxiu "; + String sql = "select "+backFields+" from "+fromSql+sqlwhere; + + log.writeLog("4.sql="+sql); + rs.executeQuery(sql); + List> datas = new ArrayList>(); + while(rs.next()){ + Map item = new HashMap(); + item.put("id", Util.null2String(rs.getString("id"))); + String name = Util.null2String(rs.getString("name")); + item.put("name", name); + datas.add(item); + } + apidatas.put("datas",datas); + return apidatas; + } + +} diff --git a/src/com/api/kq/browser/service/impl/KQGroupBrowserService.java b/src/com/api/kq/browser/service/impl/KQGroupBrowserService.java new file mode 100644 index 0000000..c3e55fd --- /dev/null +++ b/src/com/api/kq/browser/service/impl/KQGroupBrowserService.java @@ -0,0 +1,334 @@ +package com.api.kq.browser.service.impl; + +import com.alibaba.fastjson.JSON; +import com.api.browser.bean.*; +import com.api.browser.service.BrowserService; +import com.api.browser.util.*; +import com.api.hrm.bean.HrmFieldBean; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.TransMethod; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 考勤组浏览按钮 + * type : KQGroup + */ +public class KQGroupBrowserService extends BrowserService { + + private KQLog kqLog = new KQLog(); + + @Override + public Map getBrowserData(Map params) throws Exception { + String advance = Util.null2String(params.get("advance")); + if("".equals(advance) || "0".equals(advance)) + return getBasicData(params); + return getAdvanceData(params); + } + + private Map getBasicData(Map params) throws Exception { + kqLog.info("params:::::::::::"+ JSON.toJSONString(params)); + + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + + Map apidatas = new HashMap(); + boolean isBindGroup = "1".equals(Util.null2String(params.get("isBindGroup"))); // 0:未绑定考勤组; 1:绑定了考勤组 + + String groupname = Util.null2String(params.get("groupname")); + String kqtype = Util.null2String(params.get("kqtype")); + String sqlWhere = Util.null2String(params.get("sqlWhere")); + String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') "; + + if(isBindGroup) { + String resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + if(fromDate.length() == 0){ + fromDate = DateUtil.getCurrentDate(); + } + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupIds = kqGroupMemberComInfo.getKQGroupIds(resourceId, fromDate); + if(!"".equals(groupIds)) { + kqtype = "2"; + sqlwhere += " and id in("+groupIds+") "; + } else { + sqlwhere = " where 1=2 "; + } + } + + if(!groupname.equals("")){ + sqlwhere += " and groupname like '%"; + sqlwhere += Util.fromScreen2(groupname,user.getLanguage()); + sqlwhere += "%'"; + } + + if(!kqtype.equals("")){ + sqlwhere += " and kqtype ="+kqtype; + } + + if(hrmdetachable){ + int[] arrSubcompanyids = checkSubCompanyRight.getSubComByUserRightId(user.getUID(),"HrmKQGroup:Add"); + String subcompanyids = ""; + if(user.getUID() != 1){ + for(int i=0;arrSubcompanyids!=null&&i0)subcompanyids+=","; + subcompanyids += arrSubcompanyids[i]; + } + if(subcompanyids.length() > 0 ){ + sqlwhere += " and subcompanyid in("+subcompanyids+")"; + }else{ + sqlwhere += " and 1=2 "; + } + } + } + + if(!sqlWhere.equals("")){ + sqlwhere += " and "+sqlWhere; + } + + sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere); + // 设置好搜索条件 + String backFields = " id ,groupname, kqtype "; + String fromSql = " kq_group "; + + String sql = "select "+backFields+" from "+fromSql+" "+sqlwhere; + kqLog.info("sql:::::::::"+sql); + + List cols = new ArrayList(); + cols.add(new SplitTableColBean("true","id")); + cols.add(new SplitTableColBean("50%",SystemEnv.getHtmlLabelName(388700, user.getLanguage()),"groupname","groupname").setIsInputCol(BoolAttr.TRUE).setShowType(1)); + cols.add(new SplitTableColBean("50%",SystemEnv.getHtmlLabelName(388704,user.getLanguage()),"kqtype","kqtype","com.engine.kq.util.TransMethod.getKQTypeName",""+user.getLanguage()).setShowType(0)); + + SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + private Map getAdvanceData(Map params) throws Exception { + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + + Map apidatas = new HashMap(); + + String groupname = Util.null2String(params.get("groupname")); + String kqtype = Util.null2String(params.get("kqtype")); + String sqlWhere = Util.null2String(params.get("sqlWhere")); + String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') "; + if(!groupname.equals("")){ + sqlwhere += " and groupname like '%"; + sqlwhere += Util.fromScreen2(groupname,user.getLanguage()); + sqlwhere += "%'"; + } + + if(!kqtype.equals("")){ + sqlwhere += " and kqtype ="+kqtype; + } + + if(!sqlWhere.equals("")){ + sqlwhere += " and "+sqlWhere; + } + + if(hrmdetachable){ + int[] arrSubcompanyids = checkSubCompanyRight.getSubComByUserRightId(user.getUID(),"HrmKQGroup:Add"); + String subcompanyids = ""; + if(user.getUID() != 1){ + for(int i=0;arrSubcompanyids!=null&&i0)subcompanyids+=","; + subcompanyids += arrSubcompanyids[i]; + } + if(subcompanyids.length() > 0 ){ + sqlwhere += " and subcompanyid in("+subcompanyids+")"; + }else{ + sqlwhere += " and 1=2 "; + } + } + } + + sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere); + // 设置好搜索条件 + String backFields = " id,id as id1,id as id2,groupname,subcompanyid,kqtype,excludeid,signintype,ipscope,locationcheck,locationcheckscope,wificheck,isdelete "; + String fromSql = " kq_group "; + + List cols = new ArrayList(); + cols.add(new SplitTableColBean("true","id")); + cols.add(new SplitTableColBean("30%",SystemEnv.getHtmlLabelName(388700, user.getLanguage()),"groupname","groupname", "com.engine.kq.util.TransMethod.getKQGroupName", "column:id+++" + user.getLanguage()).setIsInputCol(BoolAttr.TRUE).setShowType(1)); + cols.add(new SplitTableColBean("20%",SystemEnv.getHtmlLabelName(1859, user.getLanguage()),"id1",null, "com.engine.kq.util.TransMethod.getGroupUserCount")); + cols.add(new SplitTableColBean("20%",SystemEnv.getHtmlLabelName(63,user.getLanguage()),"kqtype","kqtype","com.engine.kq.util.TransMethod.getKQTypeName",""+user.getLanguage()).setShowType(0)); + cols.add(new SplitTableColBean("30%",SystemEnv.getHtmlLabelName(27961, user.getLanguage()),"id2",null, "com.engine.kq.util.TransMethod.getKQGroupDetial", "column:kqtype+"+user.getLanguage())); + + SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + @Override + public Map getBrowserConditionInfo(Map params) throws Exception { + String advance = Util.null2String(params.get("advance")); + if("".equals(advance) || "0".equals(advance)) + return getBasicBrowserConditionInfo(params); + return getAdvanceBrowserConditionInfo(params); + } + + public Map getBasicBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + + ConditionFactory conditionFactory = new ConditionFactory(user); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 388700, "groupname", true)); + + List options = new ArrayList(); + options.add(new SearchConditionOption("","")); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(389127, user.getLanguage()))); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(389128, user.getLanguage()))); + options.add(new SearchConditionOption("3",SystemEnv.getHtmlLabelName(389129, user.getLanguage()))); + conditions.add(conditionFactory.createCondition(ConditionType.SELECT, 388704, "kqtype", options)); + + return apidatas; + } + + public Map getAdvanceBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + + ConditionFactory conditionFactory = new ConditionFactory(user); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 388700, "groupname")); + + List options = new ArrayList(); + options.add(new SearchConditionOption("","")); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(389127, user.getLanguage()))); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(389128, user.getLanguage()))); + options.add(new SearchConditionOption("3",SystemEnv.getHtmlLabelName(389129, user.getLanguage()))); + conditions.add(conditionFactory.createCondition(ConditionType.SELECT, 388704, "kqtype", options)); + + return apidatas; + } + + @Override + public Map getMultBrowserDestData(Map params) throws Exception { + Map apidatas = new HashMap(); + List> datas = new ArrayList>(); + String selectids = Util.null2String(params.get(BrowserConstant.BROWSER_MULT_DEST_SELECTIDS)); + if(user==null||"".equals(selectids)){ + return apidatas; + } + TransMethod transMethod = new TransMethod(); + RecordSet recordSet = new RecordSet(); + String tempSql = " select id,groupname, kqtype from kq_group where 1=1 and (isdelete is null or isdelete <> '1') and id in ("+selectids+") "; + recordSet.executeQuery(tempSql); + while (recordSet.next()){ + String kqtype = Util.null2String(recordSet.getString("kqtype")); + String kqtypeShow = transMethod.getKQTypeName(kqtype,""+user.getLanguage()); + + Map item = new HashMap(); + item.put("id", recordSet.getString("id")); + item.put("groupname", Util.null2String(recordSet.getString("groupname"))); + item.put("kqtype", kqtypeShow); + datas.add(item); + } + List tableHeadColumns = new ArrayList(); + tableHeadColumns.add(new ListHeadBean("id",BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("groupname","",1,BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("kqtype","",0)); + + apidatas.put(BrowserConstant.BROWSER_RESULT_COLUMN, tableHeadColumns); + apidatas.put(BrowserConstant.BROWSER_RESULT_DATA, datas); + apidatas.put(BrowserConstant.BROWSER_RESULT_TYPE, BrowserDataType.LIST_ALL_DATA.getTypeid()); + return apidatas; + } + + @Override + public Map browserAutoComplete(HttpServletRequest request, HttpServletResponse response) throws Exception { + + Map apidatas = new HashMap(); + String isBindGroup=Util.null2s(request.getParameter("isBindGroup"),""); + + String outSqlWhere=Util.null2s(request.getParameter("sqlWhere"),""); + String groupname=Util.null2s(request.getParameter("q"),""); + String includeAll=Util.null2s(request.getParameter("includeAll"),""); + RecordSet rs=new RecordSet(); + String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') "; + if("1".equals(isBindGroup)) { + String resourceId=Util.null2s(request.getParameter("resourceId"),""); + String fromDate=Util.null2s(request.getParameter("fromDate"),""); + if(fromDate.length() == 0){ + fromDate = DateUtil.getCurrentDate(); + } + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupIds = kqGroupMemberComInfo.getKQGroupIds(resourceId, fromDate); + if(!"".equals(groupIds)) { + sqlwhere += " and id in("+groupIds+") and kqType=2 "; + } else { + sqlwhere = " where 1=2 "; + } + } else { + sqlwhere += " and kqType <>3 "; + } + //String groupids = getSettedGroupIds(); +// if(groupids.length()>0 && "".equals(includeAll)){ +// sqlwhere+=" and id not in ( "+groupids+" ) "; +// } + if(!groupname.equals("")){ + sqlwhere += " and groupname like '%"; + sqlwhere += Util.fromScreen2(groupname,user.getLanguage()); + sqlwhere += "%'"; + } + + if(!outSqlWhere.equals("")){ + sqlwhere += " and "+outSqlWhere; + } + // 设置好搜索条件 + String backFields = " id ,groupname, kqtype "; + String fromSql = " kq_group "; + String sql = "select "+backFields+" from "+fromSql+sqlwhere; + + rs.executeQuery(sql); + List> datas = new ArrayList>(); + while(rs.next()){ + Map item = new HashMap(); + item.put("id", Util.null2String(rs.getString("id"))); + String name = Util.null2String(rs.getString("groupname")); + item.put("name", name); + datas.add(item); + } + apidatas.put("datas",datas); + return apidatas; + } + + /** + * 获取已经设置过加班规则得考勤组ids + * @return + */ + private String getSettedGroupIds(){ + RecordSet rs = new RecordSet(); + String settedGroupIds = ""; + try{ + rs.executeQuery("select groupids from kq_OvertimeRules where isdelete is null or isdelete <>'1'"); + while(rs.next()){ + String groupids = Util.null2String(rs.getString("groupids")); + if(groupids.length()>0){ + if(settedGroupIds.length()>0)settedGroupIds+=","; + settedGroupIds+=groupids; + } + } + }catch (Exception e){ + rs.writeLog(e); + } + return settedGroupIds; + } +} diff --git a/src/com/api/kq/browser/service/impl/KQLeaveBrowserService.java b/src/com/api/kq/browser/service/impl/KQLeaveBrowserService.java new file mode 100644 index 0000000..e249fe6 --- /dev/null +++ b/src/com/api/kq/browser/service/impl/KQLeaveBrowserService.java @@ -0,0 +1,94 @@ +package com.api.kq.browser.service.impl; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.browser.bean.SplitTableBean; +import com.api.browser.bean.SplitTableColBean; +import com.api.browser.service.BrowserService; +import com.api.browser.util.*; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 假期浏览按钮 + */ +public class KQLeaveBrowserService extends BrowserService { + + @Override + public Map getBrowserData(Map params) throws Exception { + Map apidatas = new HashMap(); + String resourceId = Util.null2String(params.get("resourceId"));//人员ID + String leaveName = Util.null2String(params.get("leaveName"));//假期名称 + String minimumUnit = Util.null2String(params.get("minimumUnit"));//请假单位 + String computingMode = Util.null2String(params.get("computingMode"));//计算请假时长方式 + + String backFields = " * "; + String sqlFrom = " kq_leaveRules "; + String sqlWhere = " where (isdelete is null or isdelete!=1) "; + if (!leaveName.equals("")) { + sqlWhere += " and leaveName like '%" + leaveName + "%'"; + } + if (!minimumUnit.equals("") && !minimumUnit.equals("0")) { + sqlWhere += " and minimumUnit=" + minimumUnit; + } + if (!computingMode.equals("") && !computingMode.equals("0")) { + sqlWhere += " and computingMode=" + computingMode; + } + if (resourceId.equals("")) { + sqlWhere += " and 1=2 "; + } else { + try{ + ResourceComInfo resourceComInfo = new ResourceComInfo(); + sqlWhere += " and organizationType=1 and organizationId=" + resourceComInfo.getSubCompanyID(resourceId) + + " union select * from kq_leaveRules " + sqlWhere + " and organizationType=0 " + + " and leaveName not in (select leaveName from kq_leaverules where organizationType=1 and organizationId=" + resourceComInfo.getSubCompanyID(resourceId) + ")"; + }catch (Exception e){ + e.printStackTrace(); + } + } + + List cols = new ArrayList(); + cols.add(new SplitTableColBean("true", "id")); + cols.add(new SplitTableColBean("25%", SystemEnv.getHtmlLabelName(388883, user.getLanguage()), "leaveName").setIsInputCol(BoolAttr.TRUE)); + cols.add(new SplitTableColBean("25%", SystemEnv.getHtmlLabelName(388884, user.getLanguage()), "minimumUnit", "", "com.engine.kq.util.KQTransMethod.getMinimumUnitName", "" + user.getLanguage())); + cols.add(new SplitTableColBean("25%", SystemEnv.getHtmlLabelName(388888, user.getLanguage()), "computingMode", "", "com.engine.kq.util.KQTransMethod.getComputingModeName", "" + user.getLanguage())); + cols.add(new SplitTableColBean("25%", SystemEnv.getHtmlLabelName(388892, user.getLanguage()), "distributionMode", "", "com.engine.kq.util.KQTransMethod.getDistributionModName", "column:balanceEnable+" + user.getLanguage())); + + SplitTableBean tableBean = new SplitTableBean(backFields, sqlFrom, sqlWhere, "", "id", "asc", cols); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + @Override + public Map getBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + ConditionFactory conditionFactory = new ConditionFactory(user); + /*假期名称*/ + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 388883, "leaveName", true)); + + /*请假单位*/ + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(337, user.getLanguage()))); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388885, user.getLanguage()))); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(388886, user.getLanguage()))); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(388887, user.getLanguage()))); + conditions.add(conditionFactory.createCondition(ConditionType.SELECT, 388884, "minimumUnit", optionsList)); + + /*计算请假时长方式*/ + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(337, user.getLanguage()))); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388890, user.getLanguage()))); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(388889, user.getLanguage()))); + conditions.add(conditionFactory.createCondition(ConditionType.SELECT, 388884, "computingMode", optionsList)); + + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + return apidatas; + } +} diff --git a/src/com/api/kq/browser/service/impl/KQLeaveTypeBrowserService.java b/src/com/api/kq/browser/service/impl/KQLeaveTypeBrowserService.java new file mode 100644 index 0000000..59c1ec0 --- /dev/null +++ b/src/com/api/kq/browser/service/impl/KQLeaveTypeBrowserService.java @@ -0,0 +1,208 @@ +package com.api.kq.browser.service.impl; + +import com.api.browser.bean.*; +import com.api.browser.service.BrowserService; +import com.api.browser.util.*; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 假期类型浏览按钮 + * type : KQLeaveType + */ +public class KQLeaveTypeBrowserService extends BrowserService { + + @Override + public Map getBrowserData(Map params) throws Exception { + String advance = Util.null2String(params.get("advance")); + if("".equals(advance) || "0".equals(advance)) + return getBasicData(params); + return getAdvanceData(params); + } + + private Map getBasicData(Map params) throws Exception { + Map apidatas = new HashMap(); + + String groupname = Util.null2String(params.get("leavename")); + String sqlWhere = Util.null2String(params.get("sqlWhere")); + String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') and isEnable=1 and balanceEnable=1 "; + if(!groupname.equals("")){ + sqlwhere += " and leavename like '%"; + sqlwhere += Util.fromScreen2(groupname,user.getLanguage()); + sqlwhere += "%'"; + } + + if(!sqlWhere.equals("")){ + sqlwhere += " and "+sqlWhere; + } + + sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere); + // 设置好搜索条件 + String backFields = " id ,leavename "; + String fromSql = " kq_leaverules "; + + List cols = new ArrayList(); + cols.add(new SplitTableColBean("true","id")); + cols.add(new SplitTableColBean("100%",SystemEnv.getHtmlLabelName(388883, user.getLanguage()),"leavename","leavename").setIsInputCol(BoolAttr.TRUE).setShowType(1)); + + SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + private Map getAdvanceData(Map params) throws Exception { + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + + Map apidatas = new HashMap(); + + String groupname = Util.null2String(params.get("leavename")); + String sqlWhere = Util.null2String(params.get("sqlWhere")); + String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') and isEnable=1 and balanceEnable=1 "; + if(!groupname.equals("")){ + sqlwhere += " and leavename like '%"; + sqlwhere += Util.fromScreen2(groupname,user.getLanguage()); + sqlwhere += "%'"; + } + + if(!sqlWhere.equals("")){ + sqlwhere += " and "+sqlWhere; + } + + sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere); + // 设置好搜索条件 + String backFields = " id,id as id1,id as id2,leavename,isdelete "; + String fromSql = " kq_leaverules "; + + List cols = new ArrayList(); + cols.add(new SplitTableColBean("true","id")); + cols.add(new SplitTableColBean("100%",SystemEnv.getHtmlLabelName(388883, user.getLanguage()),"leavename","leavename", "", "column:id+++" + user.getLanguage()).setIsInputCol(BoolAttr.TRUE).setShowType(1)); + SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + @Override + public Map getBrowserConditionInfo(Map params) throws Exception { + String advance = Util.null2String(params.get("advance")); + if("".equals(advance) || "0".equals(advance)) + return getBasicBrowserConditionInfo(params); + return getAdvanceBrowserConditionInfo(params); + } + + public Map getBasicBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + + ConditionFactory conditionFactory = new ConditionFactory(user); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 388883, "leavename", true)); + + return apidatas; + } + + public Map getAdvanceBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + + ConditionFactory conditionFactory = new ConditionFactory(user); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 388883, "leavename")); + + + return apidatas; + } + + @Override + public Map getMultBrowserDestData(Map params) throws Exception { + Map apidatas = new HashMap(); + List> datas = new ArrayList>(); + String selectids = Util.null2String(params.get(BrowserConstant.BROWSER_MULT_DEST_SELECTIDS)); + if(user==null||"".equals(selectids)){ + return apidatas; + } + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String tmp_order = Util.null2String(selectids); + Map item = null; + if(tmp_order.length()>0){ + String[] orders = tmp_order.split(","); + if(null != orders && orders.length>0){ + for (int i = 0; i < orders.length; i++) { + item = new HashMap(); + item.put("id", orders[i]); + item.put("leavename", kqLeaveRulesComInfo.getLeaveName(orders[i])); + datas.add(item); + } + } + } +// RecordSet recordSet = new RecordSet(); +// String tempSql = " select id,leavename from kq_leaverules where (isdelete is null or isdelete <> '1') and isEnable=1 and id in ("+selectids+") "; +// recordSet.executeQuery(tempSql); +// while (recordSet.next()){ +// +// Map item = new HashMap(); +// item.put("id", recordSet.getString("id")); +// item.put("leavename", Util.null2String(recordSet.getString("leavename"))); +// +// datas.add(item); +// } + List tableHeadColumns = new ArrayList(); + tableHeadColumns.add(new ListHeadBean("id",BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("leavename","",1,BoolAttr.TRUE)); + + apidatas.put(BrowserConstant.BROWSER_RESULT_COLUMN, tableHeadColumns); + apidatas.put(BrowserConstant.BROWSER_RESULT_DATA, datas); + apidatas.put(BrowserConstant.BROWSER_RESULT_TYPE, BrowserDataType.LIST_ALL_DATA.getTypeid()); + return apidatas; + } + + @Override + public Map browserAutoComplete(HttpServletRequest request, HttpServletResponse response) throws Exception { + + Map apidatas = new HashMap(); + String outSqlWhere=request.getParameter("sqlWhere"); + String groupname=request.getParameter("q"); + String includeAll=request.getParameter("includeAll"); + RecordSet rs=new RecordSet(); + String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') and isEnable=1 and balanceEnable=1 "; + + if(!groupname.equals("")){ + sqlwhere += " and leavename like '%"; + sqlwhere += Util.fromScreen2(groupname,user.getLanguage()); + sqlwhere += "%'"; + } + + if(!outSqlWhere.equals("")){ + sqlwhere += " and "+outSqlWhere; + } + // 设置好搜索条件 + String backFields = " id ,leavename "; + String fromSql = " kq_leaverules "; + String sql = "select "+backFields+" from "+fromSql+sqlwhere; + + rs.executeQuery(sql); + List> datas = new ArrayList>(); + while(rs.next()){ + Map item = new HashMap(); + item.put("id", Util.null2String(rs.getString("id"))); + String name = Util.null2String(rs.getString("leavename")); + item.put("name", name); + datas.add(item); + } + apidatas.put("datas",datas); + return apidatas; + } + +} diff --git a/src/com/api/kq/browser/service/impl/KQOvertimeRuleBrowserService.java b/src/com/api/kq/browser/service/impl/KQOvertimeRuleBrowserService.java new file mode 100644 index 0000000..ec9c58a --- /dev/null +++ b/src/com/api/kq/browser/service/impl/KQOvertimeRuleBrowserService.java @@ -0,0 +1,152 @@ +package com.api.kq.browser.service.impl; + +import com.api.browser.bean.ListHeadBean; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SplitTableBean; +import com.api.browser.bean.SplitTableColBean; +import com.api.browser.service.BrowserService; +import com.api.browser.util.BoolAttr; +import com.api.browser.util.BrowserConstant; +import com.api.browser.util.BrowserDataType; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.api.browser.util.SplitTableUtil; +import com.api.browser.util.SqlUtils; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.util.KQTransMethod; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +/** + * 加班浏览按钮 + * type : kqovertimerule + */ +public class KQOvertimeRuleBrowserService extends BrowserService { + + @Override + public Map getBrowserData(Map params) throws Exception { + Map apidatas = new HashMap(); + + String name = Util.null2String(params.get("name")); + String sqlWhere = Util.null2String(params.get("sqlWhere")); + String sqlwhere = " where (isdelete is null or isdelete <> '1') "; + if(!name.equals("")){ + sqlwhere += " and name like '%"; + sqlwhere += Util.fromScreen2(name,user.getLanguage()); + sqlwhere += "%'"; + } + + if(!sqlWhere.equals("")){ + sqlwhere += " and "+sqlWhere; + } + sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere); + // 设置好搜索条件 + String backFields = " id ,name,groupIds,id as aliasid "; + String fromSql = " kq_overtimerules "; + + List cols = new ArrayList(); + cols.add(new SplitTableColBean("true","id")); + cols.add(new SplitTableColBean("20%",SystemEnv.getHtmlLabelName(19829, user.getLanguage()),"name","name").setIsInputCol(BoolAttr.TRUE)); + cols.add(new SplitTableColBean("40%",SystemEnv.getHtmlLabelName(388832,user.getLanguage()),"aliasid","aliasid","com.engine.kq.util.KQTransMethod.getRuleContent",user.getLanguage()+"")); + cols.add(new SplitTableColBean("40%",SystemEnv.getHtmlLabelName(546281,user.getLanguage()),"groupIds","groupIds","com.engine.kq.util.KQTransMethod.getGroupName",user.getLanguage()+"")); + + SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + @Override + public Map getBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + ConditionFactory conditionFactory = new ConditionFactory(user); + SearchConditionItem searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, 19829, "name", true); + searchConditionItem.setLabelcol(8); + searchConditionItem.setFieldcol(16); + conditions.add(searchConditionItem); + return apidatas; + } + + @Override + public Map getMultBrowserDestData(Map params) throws Exception { + Map apidatas = new HashMap(); + List> datas = new ArrayList>(); + String selectids = Util.null2String(params.get(BrowserConstant.BROWSER_MULT_DEST_SELECTIDS)); + if(user == null || "".equals(selectids)) { + return apidatas; + } + RecordSet rs = new RecordSet(); + String selSql = "select * from kq_overtimerules "; + String sqlwhere = " where 1=1 "; + String[] ids = Util.splitString(selectids, ","); + if(selectids.length() > 0){ + sqlwhere += " and "+Util.getSubINClause(selectids, "id", "in"); + } + rs.executeSql(selSql+sqlwhere); + KQTransMethod kqTransMethod = new KQTransMethod(); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + while (rs.next()){ + Map item = new HashMap(); + String id = rs.getString("id"); + item.put("id", id); + item.put("aliasid", Util.null2String(kqTransMethod.getRuleContent(id, StringUtil.vString(user.getLanguage())))); + item.put("name", Util.null2String(rs.getString("name"))); + datas.add(item); + } + + List tableHeadColumns = new ArrayList(); + tableHeadColumns.add(new ListHeadBean("id","").setHide(BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("name","")); + tableHeadColumns.add(new ListHeadBean("aliasid","",1,BoolAttr.TRUE)); + + apidatas.put(BrowserConstant.BROWSER_RESULT_COLUMN, tableHeadColumns); + apidatas.put(BrowserConstant.BROWSER_RESULT_DATA, datas); + apidatas.put(BrowserConstant.BROWSER_RESULT_TYPE, BrowserDataType.LIST_ALL_DATA.getTypeid()); + return apidatas; + } + @Override + public Map browserAutoComplete( + HttpServletRequest request, HttpServletResponse response) throws Exception { + + Map apidatas = new HashMap(); + String name=Util.null2s(request.getParameter("q"),""); + String outSqlWhere=Util.null2s(request.getParameter("sqlWhere"),""); + RecordSet rs=new RecordSet(); + String sqlwhere = " where 1=1 "; + if(!name.equals("")){ + sqlwhere += " and name like '%"; + sqlwhere += Util.fromScreen2(name,user.getLanguage()); + sqlwhere += "%'"; + } + + if(!outSqlWhere.equals("")){ + sqlwhere += " and "+outSqlWhere; + } + + // 设置好搜索条件 + String backFields = " id ,name,id as aliasid "; + String fromSql = " kq_overtimerules "; + String sql = "select "+backFields+" from "+fromSql+sqlwhere; + + rs.executeQuery(sql); + List> datas = new ArrayList>(); + while(rs.next()){ + Map item = new HashMap(); + item.put("id", Util.null2String(rs.getString("id"))); + String name1 = Util.null2String(rs.getString("name")); + item.put("name", name1); + datas.add(item); + } + apidatas.put("datas",datas); + return apidatas; + } +} diff --git a/src/com/api/kq/browser/service/impl/MutiShiftBrowserService.java b/src/com/api/kq/browser/service/impl/MutiShiftBrowserService.java new file mode 100644 index 0000000..1f2fa6c --- /dev/null +++ b/src/com/api/kq/browser/service/impl/MutiShiftBrowserService.java @@ -0,0 +1,101 @@ +package com.api.kq.browser.service.impl; + +import com.api.browser.bean.ListHeadBean; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SplitTableBean; +import com.api.browser.bean.SplitTableColBean; +import com.api.browser.service.BrowserService; +import com.api.browser.util.BoolAttr; +import com.api.browser.util.BrowserConstant; +import com.api.browser.util.BrowserDataType; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.api.browser.util.SplitTableUtil; +import com.api.browser.util.SqlUtils; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +/** + * 多班次浏览按钮 + * type : mkqshift + * + */ +public class MutiShiftBrowserService extends BrowserService { + + @Override + public Map getBrowserData(Map params) throws Exception { + Map apidatas = new HashMap(); + + String serial = Util.null2String(params.get("serial")); + String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') "; + if(!serial.equals("")){ + sqlwhere += " and serial like '%"; + sqlwhere += Util.fromScreen2(serial,user.getLanguage()); + sqlwhere += "%'"; + } + sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere); + // 设置好搜索条件 + String backFields = " id ,id as aliasid,serial "; + String fromSql = " kq_ShiftManagement "; + + List cols = new ArrayList(); + cols.add(new SplitTableColBean("true","id")); + cols.add(new SplitTableColBean("50%",SystemEnv.getHtmlLabelName(27961,user.getLanguage()),"aliasid","aliasid","com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit.getShiftOnOffWorkSections",user.getLanguage()+"").setIsInputCol(BoolAttr.TRUE)); + + SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + + } + + @Override + public Map getBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + ConditionFactory conditionFactory = new ConditionFactory(user); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 125818, "serial", true)); + return apidatas; + } + + @Override + public Map getMultBrowserDestData(Map params) throws Exception { + Map apidatas = new HashMap(); + List> datas = new ArrayList>(); + String selectids = Util.null2String(params.get(BrowserConstant.BROWSER_MULT_DEST_SELECTIDS)); + if(user == null || "".equals(selectids)) return apidatas; + RecordSet rs = new RecordSet(); + String selSql = "select * from kq_ShiftManagement "; + String sqlwhere = " where 1=1 "; + String[] ids = Util.splitString(selectids, ","); + if(selectids.length() > 0){ + sqlwhere += " and "+Util.getSubINClause(selectids, "id", "in"); + } + rs.executeSql(selSql+sqlwhere); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + while (rs.next()){ + Map item = new HashMap(); + String id = rs.getString("id"); + item.put("id", id); + item.put("aliasid", Util.null2String(shiftManagementToolKit.getShiftOnOffWorkSections(id,user.getLanguage()))); + item.put("serial", Util.null2String(rs.getString("serial"))); + datas.add(item); + } + + List tableHeadColumns = new ArrayList(); + tableHeadColumns.add(new ListHeadBean("id","").setHide(BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("serial","")); + tableHeadColumns.add(new ListHeadBean("aliasid","",1,BoolAttr.TRUE)); + + apidatas.put(BrowserConstant.BROWSER_RESULT_COLUMN, tableHeadColumns); + apidatas.put(BrowserConstant.BROWSER_RESULT_DATA, datas); + apidatas.put(BrowserConstant.BROWSER_RESULT_TYPE, BrowserDataType.LIST_ALL_DATA.getTypeid()); + return apidatas; + } +} diff --git a/src/com/api/kq/browser/service/impl/ShiftBrowser4FlowService.java b/src/com/api/kq/browser/service/impl/ShiftBrowser4FlowService.java new file mode 100644 index 0000000..18e76c1 --- /dev/null +++ b/src/com/api/kq/browser/service/impl/ShiftBrowser4FlowService.java @@ -0,0 +1,141 @@ +package com.api.kq.browser.service.impl; + +import com.alibaba.fastjson.JSON; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SplitTableBean; +import com.api.browser.bean.SplitTableColBean; +import com.api.browser.service.BrowserService; +import com.api.browser.util.BoolAttr; +import com.api.browser.util.BrowserConstant; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.api.browser.util.SplitTableUtil; +import com.api.browser.util.SqlUtils; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.entity.KQGroupEntity; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.engine.kq.log.KQLog; +import weaver.common.DateUtil; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +/** + * 排班考勤流程使用的班次浏览按钮 + * type : kqshift + */ +public class ShiftBrowser4FlowService extends BrowserService { + private KQLog kqLog = new KQLog(); + + @Override + public Map getBrowserData(Map params) throws Exception { + kqLog.info("params:::::::::::"+JSON.toJSONString(params)); + Map apidatas = new HashMap(); + + String serial = Util.null2String(params.get("serial")); + String resourceId = Util.null2String(params.get("resourceId")); + boolean isBindGroup = "1".equals(Util.null2String(params.get("isBindGroup"))); // 0:未绑定考勤组; 1:绑定了考勤组 + String fromDate = Util.null2String(params.get("fromDate")); + if(fromDate.length() == 0){ + fromDate = DateUtil.getCurrentDate(); + } + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + + String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') "; + if(!serial.equals("")){ + sqlwhere += " and serial like '%"; + sqlwhere += Util.fromScreen2(serial,user.getLanguage()); + sqlwhere += "%'"; + } + + KQGroupEntity kQGroupEntity = null; + if(isBindGroup) { + String groupId = Util.null2String(params.get("groupId")); + if("".equals(groupId)) { // 绑定了考勤组,但是没有填写考勤组数据的话,返回空 + sqlwhere = " where 1=2 "; + } else { + kQGroupEntity = getUserKQGroupInfo(groupId); + } + } else { + kQGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(resourceId,fromDate,true); + } + if(kQGroupEntity == null){ + sqlwhere = " where 1=2 "; + }else{ + writeLog("kQGroupEntity:"+JSON.toJSONString(kQGroupEntity)); + String kqtype = kQGroupEntity.getKqtype(); + if ("2".equalsIgnoreCase(kqtype)) { + String serialids = kQGroupEntity.getSerialids(); + if (serialids.length() > 0) { + sqlwhere += " and ( "+Util.getSubINClause(serialids, "id", "in")+" or id = -1 )"; + }else{ + sqlwhere += " and (1=2 or or id = -1)"; + } + }else{ + sqlwhere = " where 1=2 "; + } + } + + sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere); + // 设置好搜索条件 + String backFields = " id ,id as aliasid,serial "; + String fromSql = " kq_ShiftManagement_view "; + String sql = "select "+backFields+" from "+fromSql+" "+sqlwhere; + kqLog.info("sql:::::::::"+sql); + + List cols = new ArrayList(); + cols.add(new SplitTableColBean("true","id")); + cols.add(new SplitTableColBean("50%",SystemEnv.getHtmlLabelName(125818, user.getLanguage()),"serial","serial").setIsInputCol(BoolAttr.TRUE)); + cols.add(new SplitTableColBean("50%",SystemEnv.getHtmlLabelName(27961,user.getLanguage()),"aliasid","aliasid","com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit.getShiftOnOffWorkSections",user.getLanguage()+"").setIsInputCol(BoolAttr.FALSE)); + + SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + @Override + public Map getBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + ConditionFactory conditionFactory = new ConditionFactory(user); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 125818, "serial", true)); + return apidatas; + } + + private KQGroupEntity getUserKQGroupInfo(String groupid) { + KQGroupEntity kqGroupEntity = null; + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + try { + if (groupid.length() > 0) { + kqGroupEntity = new KQGroupEntity(); + kqGroupEntity.setId(groupid); + kqGroupEntity.setGroupname(kqGroupComInfo.getGroupname(groupid)); + kqGroupEntity.setExcludeid(kqGroupComInfo.getExcludeid(groupid)); + kqGroupEntity.setSubcompanyid(kqGroupComInfo.getSubcompanyid(groupid)); + kqGroupEntity.setKqtype(kqGroupComInfo.getKqtype(groupid)); + kqGroupEntity.setSerialids(kqGroupComInfo.getSerialids(groupid)); + kqGroupEntity.setWeekday(kqGroupComInfo.getWeekday(groupid)); + kqGroupEntity.setSignstart(kqGroupComInfo.getSignstart(groupid)); + kqGroupEntity.setWorkhour(kqGroupComInfo.getWorkhour(groupid)); + kqGroupEntity.setIsdelete(kqGroupComInfo.getIsdelete(groupid)); + kqGroupEntity.setSignintype(kqGroupComInfo.getSignintype(groupid)); + kqGroupEntity.setIpscope(kqGroupComInfo.getIpscope(groupid)); + kqGroupEntity.setLocationcheck(kqGroupComInfo.getLocationcheck(groupid)); + kqGroupEntity.setLocationcheckscope(kqGroupComInfo.getLocationcheckscope(groupid)); + kqGroupEntity.setWificheck(kqGroupComInfo.getWificheck(groupid)); + kqGroupEntity.setOutsidesign(kqGroupComInfo.getOutsidesign(groupid)); + kqGroupEntity.setOutsignapprove(kqGroupComInfo.getOutsignApprove(groupid)); + kqGroupEntity.setCalmethod(kqGroupComInfo.getCalmethod(groupid)); + kqGroupEntity.setLocationshowaddress(kqGroupComInfo.getLocationshowaddress(groupid)); + } + } catch (Exception e) { + } + return kqGroupEntity; + } + +} diff --git a/src/com/api/kq/browser/service/impl/ShiftBrowserService.java b/src/com/api/kq/browser/service/impl/ShiftBrowserService.java new file mode 100644 index 0000000..36f031e --- /dev/null +++ b/src/com/api/kq/browser/service/impl/ShiftBrowserService.java @@ -0,0 +1,144 @@ +package com.api.kq.browser.service.impl; + +import com.api.browser.bean.ListHeadBean; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SplitTableBean; +import com.api.browser.bean.SplitTableColBean; +import com.api.browser.service.BrowserService; +import com.api.browser.util.BoolAttr; +import com.api.browser.util.BrowserConstant; +import com.api.browser.util.BrowserDataType; +import com.api.browser.util.ConditionFactory; +import com.api.browser.util.ConditionType; +import com.api.browser.util.SplitTableUtil; +import com.api.browser.util.SqlUtils; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +/** + * 班次浏览按钮 + * type : kqshift + */ +public class ShiftBrowserService extends BrowserService { + + @Override + public Map getBrowserData(Map params) throws Exception { + Map apidatas = new HashMap(); + + String serial = Util.null2String(params.get("serial")); + String sqlWhere = Util.null2String(params.get("sqlWhere")); + String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') "; + if(!serial.equals("")){ + sqlwhere += " and serial like '%"; + sqlwhere += Util.fromScreen2(serial,user.getLanguage()); + sqlwhere += "%'"; + } + + if(!sqlWhere.equals("")){ + sqlwhere += " and "+sqlWhere; + } + sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere); + // 设置好搜索条件 + String backFields = " id ,id as aliasid,serial "; + String fromSql = " kq_ShiftManagement "; + + List cols = new ArrayList(); + cols.add(new SplitTableColBean("true","id")); + cols.add(new SplitTableColBean("50%",SystemEnv.getHtmlLabelName(125818, user.getLanguage()),"serial","serial").setIsInputCol(BoolAttr.TRUE)); + cols.add(new SplitTableColBean("50%",SystemEnv.getHtmlLabelName(27961,user.getLanguage()),"aliasid","aliasid","com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit.getShiftOnOffWorkSections",user.getLanguage()+"")); + + SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + @Override + public Map getBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + ConditionFactory conditionFactory = new ConditionFactory(user); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 125818, "serial", true)); + return apidatas; + } + + @Override + public Map getMultBrowserDestData(Map params) throws Exception { + Map apidatas = new HashMap(); + List> datas = new ArrayList>(); + String selectids = Util.null2String(params.get(BrowserConstant.BROWSER_MULT_DEST_SELECTIDS)); + if(user == null || "".equals(selectids)) return apidatas; + RecordSet rs = new RecordSet(); + String selSql = "select * from kq_ShiftManagement "; + String sqlwhere = " where 1=1 "; + String[] ids = Util.splitString(selectids, ","); + if(selectids.length() > 0){ + sqlwhere += " and "+Util.getSubINClause(selectids, "id", "in"); + } + rs.executeSql(selSql+sqlwhere); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + while (rs.next()){ + Map item = new HashMap(); + String id = rs.getString("id"); + item.put("id", id); + item.put("aliasid", Util.null2String(shiftManagementToolKit.getShiftOnOffWorkSections(id,user.getLanguage()))); + item.put("serial", Util.null2String(rs.getString("serial"))); + datas.add(item); + } + + List tableHeadColumns = new ArrayList(); + tableHeadColumns.add(new ListHeadBean("id","").setHide(BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("serial","")); + tableHeadColumns.add(new ListHeadBean("aliasid","",1,BoolAttr.TRUE)); + + apidatas.put(BrowserConstant.BROWSER_RESULT_COLUMN, tableHeadColumns); + apidatas.put(BrowserConstant.BROWSER_RESULT_DATA, datas); + apidatas.put(BrowserConstant.BROWSER_RESULT_TYPE, BrowserDataType.LIST_ALL_DATA.getTypeid()); + return apidatas; + } + + @Override + public Map browserAutoComplete( + HttpServletRequest request, HttpServletResponse response) throws Exception { + + Map apidatas = new HashMap(); + String serial=Util.null2s(request.getParameter("q"),""); + String outSqlWhere=Util.null2s(request.getParameter("sqlWhere"),""); + RecordSet rs=new RecordSet(); + String sqlwhere = " where 1=1 "; + if(!serial.equals("")){ + sqlwhere += " and serial like '%"; + sqlwhere += Util.fromScreen2(serial,user.getLanguage()); + sqlwhere += "%'"; + } + + if(!outSqlWhere.equals("")){ + sqlwhere += " and "+outSqlWhere; + } + + // 设置好搜索条件 + String backFields = " id ,id as aliasid,serial "; + String fromSql = " kq_ShiftManagement "; + String sql = "select "+backFields+" from "+fromSql+sqlwhere; + + rs.executeQuery(sql); + List> datas = new ArrayList>(); + while(rs.next()){ + Map item = new HashMap(); + item.put("id", Util.null2String(rs.getString("id"))); + String name = Util.null2String(rs.getString("serial")); + item.put("name", name); + datas.add(item); + } + apidatas.put("datas",datas); + return apidatas; + } +} diff --git a/src/com/api/kq/browser/service/impl/jucailin/KQCycleSetBrowserService.java b/src/com/api/kq/browser/service/impl/jucailin/KQCycleSetBrowserService.java new file mode 100644 index 0000000..f52a0ca --- /dev/null +++ b/src/com/api/kq/browser/service/impl/jucailin/KQCycleSetBrowserService.java @@ -0,0 +1,97 @@ +package com.api.kq.browser.service.impl.jucailin; + +import com.api.browser.bean.*; +import com.api.browser.service.BrowserService; +import com.api.browser.util.*; +import com.engine.kq.util.TransMethod; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 周期设置浏览按钮 + * type : KQGroup + */ +public class KQCycleSetBrowserService extends BrowserService { + + @Override + public Map getBrowserData(Map params) throws Exception { + Map apidatas = new HashMap(); + + String cyclename = Util.null2String(params.get("cyclename")); + + String sqlWhere = Util.null2String(params.get("sqlWhere")); + String sqlwhere = " where 1=1 and (isdelete is null or isdelete <> '1') "; + if(!cyclename.equals("")){ + sqlwhere += " and cyclename like '%"; + sqlwhere += Util.fromScreen2(cyclename,user.getLanguage()); + sqlwhere += "%'"; + } + + if(!sqlWhere.equals("")){ + sqlwhere += " and "+sqlWhere; + } + + sqlwhere = SqlUtils.replaceFirstAnd(sqlwhere); + // 设置好搜索条件 + String backFields = " id ,cyclename "; + String fromSql = " kq_cycle_setting "; + + List cols = new ArrayList(); + cols.add(new SplitTableColBean("true","id")); + cols.add(new SplitTableColBean("100%",SystemEnv.getHtmlLabelName(388722, user.getLanguage()),"cyclename","cyclename").setIsInputCol(BoolAttr.TRUE).setShowType(1)); + + SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,"id","id","asc",cols); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + @Override + public Map getBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + + ConditionFactory conditionFactory = new ConditionFactory(user); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 388722, "cyclename", true)); + + return apidatas; + } + + @Override + public Map getMultBrowserDestData(Map params) throws Exception { + Map apidatas = new HashMap(); + List> datas = new ArrayList>(); + String selectids = Util.null2String(params.get(BrowserConstant.BROWSER_MULT_DEST_SELECTIDS)); + if(user==null||"".equals(selectids)){ + return apidatas; + } + RecordSet recordSet = new RecordSet(); + String tempSql = " select id,cyclename from kq_cycle_setting where 1=1 and (isdelete is null or isdelete <> '1') and id in ("+selectids+") "; + recordSet.executeQuery(tempSql); + while (recordSet.next()){ + Map item = new HashMap(); + item.put("id", recordSet.getString("id")); + item.put("cyclename", Util.null2String(recordSet.getString("cyclename"))); + datas.add(item); + } + List tableHeadColumns = new ArrayList(); + tableHeadColumns.add(new ListHeadBean("id",BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("cyclename","",1,BoolAttr.TRUE)); + + apidatas.put(BrowserConstant.BROWSER_RESULT_COLUMN, tableHeadColumns); + apidatas.put(BrowserConstant.BROWSER_RESULT_DATA, datas); + apidatas.put(BrowserConstant.BROWSER_RESULT_TYPE, BrowserDataType.LIST_ALL_DATA.getTypeid()); + return apidatas; + } + +} diff --git a/src/com/api/kq/web/ImportLogAction.java b/src/com/api/kq/web/ImportLogAction.java new file mode 100644 index 0000000..b9ea482 --- /dev/null +++ b/src/com/api/kq/web/ImportLogAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * Excel导入记录 + */ +@Path("kq/importlog") +public class ImportLogAction extends com.engine.kq.web.ImportLogAction { +} diff --git a/src/com/api/kq/web/KQAttendanceButtonAction.java b/src/com/api/kq/web/KQAttendanceButtonAction.java new file mode 100644 index 0000000..4ba34ac --- /dev/null +++ b/src/com/api/kq/web/KQAttendanceButtonAction.java @@ -0,0 +1,8 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/hrm/kq/attendanceButton") +public class KQAttendanceButtonAction extends com.engine.kq.web.KQAttendanceButtonAction{ + +} diff --git a/src/com/api/kq/web/KQAttendanceEventAction.java b/src/com/api/kq/web/KQAttendanceEventAction.java new file mode 100644 index 0000000..ac913a4 --- /dev/null +++ b/src/com/api/kq/web/KQAttendanceEventAction.java @@ -0,0 +1,8 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/hrm/kq/attendanceEvent") +public class KQAttendanceEventAction extends com.engine.kq.web.KQAttendanceEventAction { + +} diff --git a/src/com/api/kq/web/KQAttendanceSetAction.java b/src/com/api/kq/web/KQAttendanceSetAction.java new file mode 100644 index 0000000..3268aaa --- /dev/null +++ b/src/com/api/kq/web/KQAttendanceSetAction.java @@ -0,0 +1,8 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/kq/wfSetting/statesShedule") +public class KQAttendanceSetAction extends com.engine.kq.web.KQAttendanceSetAction{ + +} diff --git a/src/com/api/kq/web/KQBalanceDetailAction.java b/src/com/api/kq/web/KQBalanceDetailAction.java new file mode 100644 index 0000000..463edf4 --- /dev/null +++ b/src/com/api/kq/web/KQBalanceDetailAction.java @@ -0,0 +1,11 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 加班调休 + * 单独为客户改造 + */ +@Path("/kq/balancedetail") +public class KQBalanceDetailAction extends com.engine.kq.web.KQBalanceDetailAction { +} diff --git a/src/com/api/kq/web/KQBalanceOfLeaveAction.java b/src/com/api/kq/web/KQBalanceOfLeaveAction.java new file mode 100644 index 0000000..afc883e --- /dev/null +++ b/src/com/api/kq/web/KQBalanceOfLeaveAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 假期余额 + */ +@Path("/kq/balanceofleave") +public class KQBalanceOfLeaveAction extends com.engine.kq.web.KQBalanceOfLeaveAction { +} diff --git a/src/com/api/kq/web/KQBalanceOfLeaveRpAction.java b/src/com/api/kq/web/KQBalanceOfLeaveRpAction.java new file mode 100644 index 0000000..b4b6c09 --- /dev/null +++ b/src/com/api/kq/web/KQBalanceOfLeaveRpAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 员工假期余额报表 + */ +@Path("/kq/balanceofleaverp") +public class KQBalanceOfLeaveRpAction extends com.engine.kq.web.KQBalanceOfLeaveRpAction { +} diff --git a/src/com/api/kq/web/KQGroupAction.java b/src/com/api/kq/web/KQGroupAction.java new file mode 100644 index 0000000..b248cb9 --- /dev/null +++ b/src/com/api/kq/web/KQGroupAction.java @@ -0,0 +1,9 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/hrm/kq/group") +public class KQGroupAction extends com.engine.kq.web.KQGroupAction { + +} + \ No newline at end of file diff --git a/src/com/api/kq/web/KQGroupLocationAction.java b/src/com/api/kq/web/KQGroupLocationAction.java new file mode 100644 index 0000000..5f648bd --- /dev/null +++ b/src/com/api/kq/web/KQGroupLocationAction.java @@ -0,0 +1,8 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/hrm/kq/grouplocation") +public class KQGroupLocationAction extends com.engine.kq.web.KQGroupLocationAction { + +} diff --git a/src/com/api/kq/web/KQGroupMemberAction.java b/src/com/api/kq/web/KQGroupMemberAction.java new file mode 100644 index 0000000..5945ea4 --- /dev/null +++ b/src/com/api/kq/web/KQGroupMemberAction.java @@ -0,0 +1,8 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/hrm/kq/groupmember") +public class KQGroupMemberAction extends com.engine.kq.web.KQGroupMemberAction { + +} diff --git a/src/com/api/kq/web/KQGroupWifiAction.java b/src/com/api/kq/web/KQGroupWifiAction.java new file mode 100644 index 0000000..f89ad60 --- /dev/null +++ b/src/com/api/kq/web/KQGroupWifiAction.java @@ -0,0 +1,8 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/hrm/kq/groupwifi") +public class KQGroupWifiAction extends com.engine.kq.web.KQGroupWifiAction { + +} diff --git a/src/com/api/kq/web/KQHolidaySetAction.java b/src/com/api/kq/web/KQHolidaySetAction.java new file mode 100644 index 0000000..2858fdc --- /dev/null +++ b/src/com/api/kq/web/KQHolidaySetAction.java @@ -0,0 +1,7 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/kq/holidayset") +public class KQHolidaySetAction extends com.engine.kq.web.KQHolidaySetAction { +} diff --git a/src/com/api/kq/web/KQLeaveParentalAction.java b/src/com/api/kq/web/KQLeaveParentalAction.java new file mode 100644 index 0000000..99ec00f --- /dev/null +++ b/src/com/api/kq/web/KQLeaveParentalAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 假期规则 + */ +@Path("/kq/leaveparental") +public class KQLeaveParentalAction extends com.engine.kq.web.KQLeaveParentalAction { +} diff --git a/src/com/api/kq/web/KQLeaveRulesAction.java b/src/com/api/kq/web/KQLeaveRulesAction.java new file mode 100644 index 0000000..7b18b88 --- /dev/null +++ b/src/com/api/kq/web/KQLeaveRulesAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 假期规则 + */ +@Path("/kq/leaverules") +public class KQLeaveRulesAction extends com.engine.kq.web.KQLeaveRulesAction { +} diff --git a/src/com/api/kq/web/KQLeaveTypesAction.java b/src/com/api/kq/web/KQLeaveTypesAction.java new file mode 100644 index 0000000..fd7ef4f --- /dev/null +++ b/src/com/api/kq/web/KQLeaveTypesAction.java @@ -0,0 +1,12 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * @Auther: Administrator + * @Date: 2019-03-12 11:22 + * @Description: + */ +@Path("/kq/leavetypes") +public class KQLeaveTypesAction extends com.engine.kq.web.KQLeaveTypesAction { +} diff --git a/src/com/api/kq/web/KQMyAttendanceAction.java b/src/com/api/kq/web/KQMyAttendanceAction.java new file mode 100644 index 0000000..515ab60 --- /dev/null +++ b/src/com/api/kq/web/KQMyAttendanceAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 前台--人事--我的考勤 + */ +@Path("/kq/myattendance") +public class KQMyAttendanceAction extends com.engine.kq.web.KQMyAttendanceAction { +} diff --git a/src/com/api/kq/web/KQOriginalPunchRpAction.java b/src/com/api/kq/web/KQOriginalPunchRpAction.java new file mode 100644 index 0000000..c478e11 --- /dev/null +++ b/src/com/api/kq/web/KQOriginalPunchRpAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 原始打卡记录报表 + */ +@Path("/kq/originalpunchrp") +public class KQOriginalPunchRpAction extends com.engine.kq.web.KQOriginalPunchRpAction { +} diff --git a/src/com/api/kq/web/KQOvertimeRulesAction.java b/src/com/api/kq/web/KQOvertimeRulesAction.java new file mode 100644 index 0000000..f116842 --- /dev/null +++ b/src/com/api/kq/web/KQOvertimeRulesAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 加班规则 + */ +@Path("/kq/overtimerules") +public class KQOvertimeRulesAction extends com.engine.kq.web.KQOvertimeRulesAction { +} diff --git a/src/com/api/kq/web/KQRemindMsgAction.java b/src/com/api/kq/web/KQRemindMsgAction.java new file mode 100644 index 0000000..1b5620f --- /dev/null +++ b/src/com/api/kq/web/KQRemindMsgAction.java @@ -0,0 +1,8 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/hrm/kq/abnormalremindMsg") +public class KQRemindMsgAction extends com.engine.kq.web.KQRemindMsgAction{ + +} diff --git a/src/com/api/kq/web/KQRemindOnPCAction.java b/src/com/api/kq/web/KQRemindOnPCAction.java new file mode 100644 index 0000000..fb7a1c2 --- /dev/null +++ b/src/com/api/kq/web/KQRemindOnPCAction.java @@ -0,0 +1,11 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 考勤提醒 + * 登录PC端后的弹窗提醒 + */ +@Path("/kq/remindOnPC") +public class KQRemindOnPCAction extends com.engine.kq.web.KQRemindOnPCAction { +} diff --git a/src/com/api/kq/web/KQReport4EAction.java b/src/com/api/kq/web/KQReport4EAction.java new file mode 100644 index 0000000..003bc0c --- /dev/null +++ b/src/com/api/kq/web/KQReport4EAction.java @@ -0,0 +1,8 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/hrm/kq/report4e") +public class KQReport4EAction extends com.engine.kq.web.KQReport4EAction{ + +} diff --git a/src/com/api/kq/web/KQReportAction.java b/src/com/api/kq/web/KQReportAction.java new file mode 100644 index 0000000..b047e51 --- /dev/null +++ b/src/com/api/kq/web/KQReportAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 考勤报表 + */ +@Path("/kq/report") +public class KQReportAction extends com.engine.kq.web.KQReportAction { +} diff --git a/src/com/api/kq/web/KQReportDetailAction.java b/src/com/api/kq/web/KQReportDetailAction.java new file mode 100644 index 0000000..070ef54 --- /dev/null +++ b/src/com/api/kq/web/KQReportDetailAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 考勤报表明细 + */ +@Path("/kq/report/detail/") +public class KQReportDetailAction extends com.engine.kq.web.KQReportDetailAction { +} diff --git a/src/com/api/kq/web/KQReportFieldDefineAction.java b/src/com/api/kq/web/KQReportFieldDefineAction.java new file mode 100644 index 0000000..f4ff1cc --- /dev/null +++ b/src/com/api/kq/web/KQReportFieldDefineAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 勤报表展示列支持定制 + */ +@Path("/hrm/kq/reportFieldDefine") +public class KQReportFieldDefineAction extends com.engine.kq.web.KQReportFieldDefineAction { +} diff --git a/src/com/api/kq/web/KQReportShareAction.java b/src/com/api/kq/web/KQReportShareAction.java new file mode 100644 index 0000000..21cd1a0 --- /dev/null +++ b/src/com/api/kq/web/KQReportShareAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 考勤报表权限共享 + */ +@Path("/kq/reportshare") +public class KQReportShareAction extends com.engine.kq.web.KQReportShareAction { +} diff --git a/src/com/api/kq/web/KQScheduleCodeAction.java b/src/com/api/kq/web/KQScheduleCodeAction.java new file mode 100644 index 0000000..d290cef --- /dev/null +++ b/src/com/api/kq/web/KQScheduleCodeAction.java @@ -0,0 +1,9 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/hrm/kq/schedulecode") +public class KQScheduleCodeAction extends com.engine.kq.web.KQScheduleCodeAction { + +} + \ No newline at end of file diff --git a/src/com/api/kq/web/KQScheduleSignImportAction.java b/src/com/api/kq/web/KQScheduleSignImportAction.java new file mode 100644 index 0000000..50b6b00 --- /dev/null +++ b/src/com/api/kq/web/KQScheduleSignImportAction.java @@ -0,0 +1,9 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/hrm/kq/schedulesignimport") +public class KQScheduleSignImportAction extends com.engine.kq.web.KQScheduleSignImportAction { + +} + \ No newline at end of file diff --git a/src/com/api/kq/web/KQSettingsAction.java b/src/com/api/kq/web/KQSettingsAction.java new file mode 100644 index 0000000..8bedc90 --- /dev/null +++ b/src/com/api/kq/web/KQSettingsAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 考勤-应用设置 + */ +@Path("/kq/settings") +public class KQSettingsAction extends com.engine.kq.web.KQSettingsAction { +} diff --git a/src/com/api/kq/web/KQSetupWizardAction.java b/src/com/api/kq/web/KQSetupWizardAction.java new file mode 100644 index 0000000..5b628d2 --- /dev/null +++ b/src/com/api/kq/web/KQSetupWizardAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 一键开启考勤 + */ +@Path("/kq/setupwizard") +public class KQSetupWizardAction extends com.engine.kq.web.KQSetupWizardAction { +} diff --git a/src/com/api/kq/web/KQShiftManagementAction.java b/src/com/api/kq/web/KQShiftManagementAction.java new file mode 100644 index 0000000..e745f2a --- /dev/null +++ b/src/com/api/kq/web/KQShiftManagementAction.java @@ -0,0 +1,8 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/hrm/kq/shiftManagement") +public class KQShiftManagementAction extends com.engine.kq.web.KQShiftManagementAction { + +} diff --git a/src/com/api/kq/web/KQShiftScheduleAction.java b/src/com/api/kq/web/KQShiftScheduleAction.java new file mode 100644 index 0000000..e2161f6 --- /dev/null +++ b/src/com/api/kq/web/KQShiftScheduleAction.java @@ -0,0 +1,8 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/hrm/kq/shiftschedulce") +public class KQShiftScheduleAction extends com.engine.kq.web.KQShiftScheduleAction{ + +} diff --git a/src/com/api/kq/web/KQTravelRulesAction.java b/src/com/api/kq/web/KQTravelRulesAction.java new file mode 100644 index 0000000..71d29fd --- /dev/null +++ b/src/com/api/kq/web/KQTravelRulesAction.java @@ -0,0 +1,10 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +/** + * 出差规则 + */ +@Path("/kq/travelrules") +public class KQTravelRulesAction extends com.engine.kq.web.KQTravelRulesAction { +} diff --git a/src/com/api/kq/web/KQUpgradeAction.java b/src/com/api/kq/web/KQUpgradeAction.java new file mode 100644 index 0000000..08e58fb --- /dev/null +++ b/src/com/api/kq/web/KQUpgradeAction.java @@ -0,0 +1,8 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/hrm/kq/upgrade") +public class KQUpgradeAction extends com.engine.kq.web.KQUpgradeAction { + +} diff --git a/src/com/api/kq/web/KqPunchButton4EAction.java b/src/com/api/kq/web/KqPunchButton4EAction.java new file mode 100644 index 0000000..90ff71b --- /dev/null +++ b/src/com/api/kq/web/KqPunchButton4EAction.java @@ -0,0 +1,7 @@ +package com.api.kq.web; + +import javax.ws.rs.Path; + +@Path("/kq/resful/") +public class KqPunchButton4EAction extends com.engine.kq.web.KqPunchButton4EAction { +} diff --git a/src/com/api/kq/web/jucailin/KQCalendarSettingActionApi.java b/src/com/api/kq/web/jucailin/KQCalendarSettingActionApi.java new file mode 100644 index 0000000..70876bb --- /dev/null +++ b/src/com/api/kq/web/jucailin/KQCalendarSettingActionApi.java @@ -0,0 +1,17 @@ +package com.api.kq.web.jucailin; + +import com.engine.kq.jucailin.web.KQCalendarSettingAction; +import lombok.extern.slf4j.Slf4j; + +import javax.ws.rs.Path; + +/** + * @Author: sy + * @Description: + * @Date: 2024/2/27 + **/ + +@Path("/hrm/kq/jucailin/calendarsetting") +@Slf4j +public class KQCalendarSettingActionApi extends KQCalendarSettingAction { +} diff --git a/src/com/api/kq/web/jucailin/KQCommonActionApi.java b/src/com/api/kq/web/jucailin/KQCommonActionApi.java new file mode 100644 index 0000000..7bebe9a --- /dev/null +++ b/src/com/api/kq/web/jucailin/KQCommonActionApi.java @@ -0,0 +1,13 @@ +package com.api.kq.web.jucailin; + + +import com.engine.kq.jucailin.web.KQCommonAction; +import lombok.extern.slf4j.Slf4j; + +import javax.ws.rs.Path; + + +@Path("/hrm/kq/jucailin/common") +@Slf4j +public class KQCommonActionApi extends KQCommonAction { +} diff --git a/src/com/api/kq/web/jucailin/KQCycleSettingActionApi.java b/src/com/api/kq/web/jucailin/KQCycleSettingActionApi.java new file mode 100644 index 0000000..4cf6282 --- /dev/null +++ b/src/com/api/kq/web/jucailin/KQCycleSettingActionApi.java @@ -0,0 +1,12 @@ +package com.api.kq.web.jucailin; + +import com.engine.kq.jucailin.web.KQCycleSettingAction; +import lombok.extern.slf4j.Slf4j; + +import javax.ws.rs.Path; + + +@Path("/hrm/kq/jucailin/cyclesetting") +@Slf4j +public class KQCycleSettingActionApi extends KQCycleSettingAction { +} diff --git a/src/com/api/kq/web/jucailin/KQPersonGroupActionApi.java b/src/com/api/kq/web/jucailin/KQPersonGroupActionApi.java new file mode 100644 index 0000000..2d61086 --- /dev/null +++ b/src/com/api/kq/web/jucailin/KQPersonGroupActionApi.java @@ -0,0 +1,12 @@ +package com.api.kq.web.jucailin; + +import com.engine.kq.jucailin.web.KQPersonGroupAction; +import lombok.extern.slf4j.Slf4j; + +import javax.ws.rs.Path; + + +@Path("/hrm/kq/jucailin/persongroup") +@Slf4j +public class KQPersonGroupActionApi extends KQPersonGroupAction { +} diff --git a/src/com/engine/kq/bean/ImportSetting.java b/src/com/engine/kq/bean/ImportSetting.java new file mode 100644 index 0000000..41e0554 --- /dev/null +++ b/src/com/engine/kq/bean/ImportSetting.java @@ -0,0 +1,115 @@ +package com.engine.kq.bean; + +/** + * 考勤外部数据同步配置信息 + */ +public class ImportSetting { + String datasourceid = ""; + String loginid = ""; + String workcode = ""; + String lastname = ""; + String signdate = ""; + String signtime = ""; + String tablename = ""; + String clientaddress = ""; + String longitude = ""; + String latitude = ""; + String addr = ""; + String memo = ""; + + public String getLoginid() { + return loginid; + } + + public void setLoginid(String loginid) { + this.loginid = loginid; + } + + public String getDatasourceid() { + return datasourceid; + } + + public void setDatasourceid(String datasourceid) { + this.datasourceid = datasourceid; + } + + public String getWorkcode() { + return workcode; + } + + public void setWorkcode(String workcode) { + this.workcode = workcode; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public String getSigndate() { + return signdate; + } + + public void setSigndate(String signdate) { + this.signdate = signdate; + } + + public String getSigntime() { + return signtime; + } + + public void setSigntime(String signtime) { + this.signtime = signtime; + } + + public String getTablename() { + return tablename; + } + + public void setTablename(String tablename) { + this.tablename = tablename; + } + + public String getClientaddress() { + return clientaddress; + } + + public void setClientaddress(String clientaddress) { + this.clientaddress = clientaddress; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getAddr() { + return addr; + } + + public void setAddr(String addr) { + this.addr = addr; + } + + public String getMemo() { + return memo; + } + + public void setMemo(String memo) { + this.memo = memo; + } +} \ No newline at end of file diff --git a/src/com/engine/kq/bean/KQBalanceDetail.java b/src/com/engine/kq/bean/KQBalanceDetail.java new file mode 100644 index 0000000..3557dfc --- /dev/null +++ b/src/com/engine/kq/bean/KQBalanceDetail.java @@ -0,0 +1,395 @@ +package com.engine.kq.bean; + +import com.engine.kq.biz.*; +import com.engine.kq.entity.KQUsageHistoryEntity; +import com.engine.kq.jucailin.util.KQDateUtil; +import java.sql.Date; +import java.sql.Timestamp; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.common.database.dialect.DialectUtil; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 用于调休明细的导入 + */ +public class KQBalanceDetail extends BaseBean { + + /** + * 人员ID + */ + private String resourceId; + /** + * 人员姓名 + */ + private String lastName; + /** + * 工号 + */ + private String workCode; + /** + * 年份 + */ + private String belongYear; + /** + * 月份 + */ + private String belongMonth; + /** + * 假期类型ID + */ + private String leaveRulesId; + /** + * 操作类型: + * 3--加班流程生成调休 + * 4--打卡数据生成调休 + * 7--管理员Excel导入 + */ + private String overtimeType = "7"; + /** + * 总数 + */ + private String totalAmount; + /** + * 已休 + */ + private String usedAmount; + /** + * 生效日期 + */ + private String effectiveDate; + /** + * 失效日期 + */ + private String expirationDate; + /** + * 用户语言 + */ + private int userLanguage = 7; + /** + * 关键字 + */ + private String keyField; + /** + * 操作者 + */ + private String operator; + + /** + * 验证模板数据有效性 + * + * @return + */ + public String valExcelData() { + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String allow_negative = Util.null2String(kqSettingsComInfo.getMain_val("allow_negative"),"0"); + String errorInfo = ""; + if (!isExist()) { + errorInfo = SystemEnv.getHtmlLabelName(83535, userLanguage);//人员未找到 + return errorInfo; + } + if (this.belongYear == null || this.belongYear.equals("")) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005283,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + Pattern p_belongYear = Pattern.compile("^\\d{4}$"); + Matcher m_belongYear = p_belongYear.matcher(this.belongYear); + if (!m_belongYear.matches()) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005284,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + if (this.belongMonth == null || this.belongMonth.equals("")) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005285,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + Pattern p_belongMonth = Pattern.compile("^01|02|03|04|05|06|07|08|09|10|11|12$"); + Matcher m_belongMonth = p_belongMonth.matcher(this.belongMonth); + if (!m_belongMonth.matches()) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005286,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + double _totalAmount = Util.getDoubleValue(this.totalAmount, 0.00); + if (!"1".equals(allow_negative) && _totalAmount < 0) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005287,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + double _usedAmount = Util.getDoubleValue(this.usedAmount, 0.00); + if (_usedAmount < 0) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005288,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + if (!"1".equals(allow_negative) && (_totalAmount < _usedAmount)) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(508124,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + if (this.leaveRulesId.equals("")) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005289,weaver.general.ThreadVarLanguage.getLang())+"ID"; + return errorInfo; + } + if (this.effectiveDate == null || this.effectiveDate.equals("")) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005290,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + Pattern p = Pattern.compile("^\\d{4}\\-\\d{2}\\-\\d{2}$"); + Matcher m = p.matcher(this.effectiveDate); + if (!m.matches()) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005291,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + if (this.expirationDate == null || this.effectiveDate.equals("")) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005292,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + m = p.matcher(this.expirationDate); + if (!m.matches()) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005293,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + if (this.effectiveDate.compareTo(this.expirationDate) > 0) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005294,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + if(checkDate(this.expirationDate)){ + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005293,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + if(checkDate(this.effectiveDate)){ + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005291,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + return errorInfo; + } + + /** + * 判断ID和姓名是否匹配,系统中是否存在此人员 + * + * @return + */ + private boolean isExist() { + String sql = "select 1 from HrmResource where id=? "; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, resourceId); + if (recordSet.next()) { + return true; + } else { + return false; + } + } + /** + * 判断日期字段是否符合正常 + * + * @return + */ + private boolean checkDate(String expirationDate) { + try { + LocalDate localDate = LocalDate.parse(expirationDate); + return false; + } catch (Exception e) { + return true; + } + } + + /** + * 保存数据 + * + * @return + */ + public String save() { + String resultStr = "false"; + try { + /*获取当前日期,当前时间*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String subCompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + String minimumUnit = rulesComInfo.getMinimumUnit(this.leaveRulesId); + + int changeType = KQOvertimeRulesBiz.getChangeType(this.resourceId, this.effectiveDate); + String order = KQBalanceOfLeaveBiz.getDeductOrder("" + changeType, detailComInfo.getId(leaveRulesId, subCompanyId, departmentId, resourceId)); + if(Util.getIntValue(order) <= 0){ + order = ""; + } + + Timestamp date = KQDateUtil.getUpdateTimeStamp(); + String sql = "INSERT INTO KQ_BalanceOfLeave(resourceId,leaveRulesId,belongYear,belongMonth,overtimeType,baseAmount,extraAmount,usedAmount,effectiveDate,expirationDate,create_time,update_time,creator,changetype,deductorder) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + RecordSet recordSet = new RecordSet(); + if (recordSet.getDBType().equals("postgresql")) { + sql = "INSERT INTO KQ_BalanceOfLeave(resourceId,leaveRulesId,belongYear,belongMonth,overtimeType,baseAmount,extraAmount,usedAmount,effectiveDate,expirationDate,create_time,update_time,creator,changetype,deductorder) VALUES(?,?,?,?,?,?,?,?,?,?,?::timestamp,?::timestamp,?,?,?)"; + } + boolean flag = recordSet.executeUpdate(sql, this.resourceId, this.leaveRulesId, this.belongYear, this.belongMonth, this.overtimeType, 0, this.totalAmount, this.usedAmount, this.effectiveDate, this.expirationDate, date, date, Util.getIntValue(resourceId), changeType, order); + resultStr = String.valueOf(flag); + if (flag) { + BigDecimal _totalAmount = new BigDecimal(this.totalAmount); + BigDecimal _usedAmount = new BigDecimal(this.usedAmount); + + /*员工假期余额变更记录*/ + KQUsageHistoryEntity usageHistoryEntity = new KQUsageHistoryEntity(); + List usageHistoryEntityList = new ArrayList(); + + /*员工假期余额变更记录*/ + usageHistoryEntity = new KQUsageHistoryEntity(); + usageHistoryEntity.setLeaveRulesId(this.leaveRulesId); + usageHistoryEntity.setRelatedId(this.resourceId); + usageHistoryEntity.setWfRequestId(""); + usageHistoryEntity.setOperator(this.operator); + usageHistoryEntity.setOperateDate(currentDate); + usageHistoryEntity.setOperateTime(currentTime); + usageHistoryEntity.setOperateType("7"); + usageHistoryEntity.setInsertOrUpdate("INSERT"); + usageHistoryEntity.setBelongYear(this.belongYear); + usageHistoryEntity.setOldExtraAmount("0"); + usageHistoryEntity.setNewExtraAmount(_totalAmount.subtract(_usedAmount).setScale(2, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setOldMinimumUnit(minimumUnit); + usageHistoryEntity.setNewMinimumUnit(minimumUnit); + usageHistoryEntityList.add(usageHistoryEntity); + KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz(); + flag = usageHistoryBiz.save(usageHistoryEntityList); + + resultStr = String.valueOf(flag); + /*员工假期余额变更记录*/ + } + } catch (Exception e) { + writeLog(e); + } + return resultStr; + } + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getWorkCode() { + return workCode; + } + + public void setWorkCode(String workCode) { + this.workCode = workCode; + } + + public String getBelongYear() { + return belongYear; + } + + public void setBelongYear(String belongYear) { + this.belongYear = belongYear; + } + + public String getBelongMonth() { + return belongMonth; + } + + public void setBelongMonth(String belongMonth) { + this.belongMonth = belongMonth; + } + + public String getLeaveRulesId() { + return leaveRulesId; + } + + public void setLeaveRulesId(String leaveRulesId) { + this.leaveRulesId = leaveRulesId; + } + + public String getOvertimeType() { + return overtimeType; + } + + public void setOvertimeType(String overtimeType) { + this.overtimeType = overtimeType; + } + + public String getTotalAmount() { + return totalAmount; + } + + public void setTotalAmount(String totalAmount) { + BigDecimal _totalAmount = new BigDecimal(Util.getDoubleValue(totalAmount, 0)); + this.totalAmount = _totalAmount.setScale(2, RoundingMode.HALF_UP).toPlainString(); + } + + public String getUsedAmount() { + return usedAmount; + } + + public void setUsedAmount(String usedAmount) { + BigDecimal _usedAmount = new BigDecimal(Util.getDoubleValue(usedAmount, 0)); + this.usedAmount = _usedAmount.setScale(2, RoundingMode.HALF_UP).toPlainString(); + } + + public String getEffectiveDate() { + return effectiveDate; + } + + public void setEffectiveDate(String effectiveDate) { + this.effectiveDate = effectiveDate; + } + + public String getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(String expirationDate) { + this.expirationDate = expirationDate; + } + + public int getUserLanguage() { + return userLanguage; + } + + public void setUserLanguage(int userLanguage) { + this.userLanguage = userLanguage; + } + + public void setUserLanguage(String userLanguage) { + this.userLanguage = Util.getIntValue(userLanguage, 7); + } + + public String getKeyField() { + return keyField; + } + + public void setKeyField(String keyField) { + this.keyField = keyField; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } +} diff --git a/src/com/engine/kq/bean/KQBalanceDetail2.java b/src/com/engine/kq/bean/KQBalanceDetail2.java new file mode 100644 index 0000000..48812e8 --- /dev/null +++ b/src/com/engine/kq/bean/KQBalanceDetail2.java @@ -0,0 +1,360 @@ +package com.engine.kq.bean; + +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQLeaveRulesDetailComInfo; +import com.engine.kq.biz.KQSettingsComInfo; +import com.engine.kq.biz.KQUsageHistoryBiz; +import com.engine.kq.entity.KQUsageHistoryEntity; +import com.weaver.general.TimeUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 用于调休明细的导入 + */ +public class KQBalanceDetail2 extends BaseBean { + + /** + * 人员ID + */ + private String resourceId; + /** + * 人员姓名 + */ + private String lastName; + /** + * 工号 + */ + private String workCode; + /** + * 年份 + */ + private String belongYear; + + /** + * 假期类型ID + */ + private String leaveRulesId; + /** + * 操作类型: + * 3--加班流程生成调休 + * 4--打卡数据生成调休 + * 7--管理员Excel导入 + */ + private String overtimeType = "7"; + /** + * 育儿假基数 + */ + private String baseAmount; + /** + * 额外 + */ + private String extraAmount; + /** + * 已休 + */ + private String usedAmount; + /** + * 生效日期 + */ + private String effectiveDate; + + /** + * 用户语言 + */ + private int userLanguage = 7; + /** + * 关键字 + */ + private String keyField; + /** + * 操作者 + */ + private String operator; + + public String getBaseAmount() { + return baseAmount; + } + + public void setBaseAmount(String baseAmount) { + this.baseAmount = baseAmount; + } + + public String getExtraAmount() { + return extraAmount; + } + + public void setExtraAmount(String extraAmount) { + this.extraAmount = extraAmount; + } + + /** + * 验证模板数据有效性 + * + * @return + */ + public String valExcelData() { + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String allow_negative = Util.null2String(kqSettingsComInfo.getMain_val("allow_negative"),"0"); + String errorInfo = ""; + if (!isExist()) { + errorInfo = SystemEnv.getHtmlLabelName(83535, userLanguage);//人员未找到 + return errorInfo; + } + if (this.belongYear == null || this.belongYear.equals("")) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005283,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + + double _baseAmount = Util.getDoubleValue(this.baseAmount, 0.00); + if (!"1".equals(allow_negative) && _baseAmount < 0) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005287,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + if (this.leaveRulesId.equals("")) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005289,weaver.general.ThreadVarLanguage.getLang())+"ID"; + return errorInfo; + } + if (this.effectiveDate == null || this.effectiveDate.equals("")) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005290,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + Pattern p = Pattern.compile("^\\d{4}\\-\\d{2}\\-\\d{2}$"); + Matcher m = p.matcher(this.effectiveDate); + if (!m.matches()) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005291,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + if (this.effectiveDate.equals("")) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005292,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + if(checkDate(this.effectiveDate)){ + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005291,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + return errorInfo; + } + + /** + * 判断ID和姓名是否匹配,系统中是否存在此人员 + * + * @return + */ + private boolean isExist() { + String sql = "select 1 from HrmResource where id=? "; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, resourceId); + if (recordSet.next()) { + return true; + } else { + return false; + } + } + /** + * 判断日期字段是否符合正常 + * + * @return + */ + private boolean checkDate(String expirationDate) { + try { + LocalDate localDate = LocalDate.parse(expirationDate); + return false; + } catch (Exception e) { + return true; + } + } + + /** + * 保存数据 + * + * @return + */ + public String save() { + String resultStr = "false"; + try { + /*获取当前日期,当前时间*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + + //假期规则缓存类 + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + String minimumUnit = rulesComInfo.getMinimumUnit(this.leaveRulesId); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + + String subcompanyId = resourceComInfo.getSubCompanyID(this.resourceId); + String departmentId = resourceComInfo.getDepartmentID(this.resourceId); + int validityRule = Util.getIntValue(detailComInfo.getValidityRule(this.leaveRulesId, subcompanyId, departmentId, resourceId)); + String expirationDate = "2222-12-31"; + if (validityRule != 0) { + expirationDate = TimeUtil.dateAdd(TimeUtil.yearAdd(this.effectiveDate, 1), -1); + } + String baseAmountValue=Util.null2s(this.baseAmount,"0"); + String extraAmountValue=Util.null2s(this.extraAmount,"0"); + String usedAmountValue=Util.null2s(this.usedAmount,"0"); + String sql = "INSERT INTO KQ_BalanceOfLeave(resourceId,leaveRulesId,belongYear,overtimeType,baseAmount,extraAmount,usedAmount,effectiveDate,expirationDate) VALUES(?,?,?,?,?,?,?,?,?)"; + RecordSet recordSet = new RecordSet(); + boolean flag = recordSet.executeUpdate(sql, this.resourceId, this.leaveRulesId, this.belongYear, this.overtimeType,baseAmountValue,extraAmountValue, usedAmountValue, this.effectiveDate, expirationDate); + resultStr = String.valueOf(flag); + if (flag) { + BigDecimal _baseAmount = new BigDecimal(baseAmountValue); + BigDecimal _extraAmount = new BigDecimal(extraAmountValue); + BigDecimal _usedAmount = new BigDecimal(usedAmountValue); + + /*员工假期余额变更记录*/ + KQUsageHistoryEntity usageHistoryEntity = new KQUsageHistoryEntity(); + List usageHistoryEntityList = new ArrayList(); + String balanceOfLeaveId = ""; + //获取刚才插入的调休明细的ID + sql = "select max(id) from kq_balanceOfLeave where leaveRulesId=? and resourceId=? and belongYear=?"; + recordSet.executeQuery(sql, this.leaveRulesId, this.resourceId, this.belongYear); + if (recordSet.next()) { + balanceOfLeaveId = recordSet.getString(1); + } + + /*员工假期余额变更记录*/ + usageHistoryEntity = new KQUsageHistoryEntity(); + usageHistoryEntity.setLeaveRulesId(this.leaveRulesId); + usageHistoryEntity.setRelatedId(this.resourceId); + usageHistoryEntity.setWfRequestId(""); + usageHistoryEntity.setOperator(this.operator); + usageHistoryEntity.setOperateDate(currentDate); + usageHistoryEntity.setOperateTime(currentTime); + usageHistoryEntity.setOperateType("7"); + usageHistoryEntity.setInsertOrUpdate("INSERT"); + usageHistoryEntity.setBelongYear(this.belongYear); + usageHistoryEntity.setOldExtraAmount("0"); + usageHistoryEntity.setOldBaseAmount("0"); + usageHistoryEntity.setOldUsedAmount("0"); + usageHistoryEntity.setNewUsedAmount(_usedAmount.toString()); + usageHistoryEntity.setNewBaseAmount(_baseAmount.toString()); + usageHistoryEntity.setNewExtraAmount(_extraAmount.setScale(2, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setOldMinimumUnit(minimumUnit); + usageHistoryEntity.setNewMinimumUnit(minimumUnit); + usageHistoryEntity.setBalanceOfLeaveId(balanceOfLeaveId); + usageHistoryEntityList.add(usageHistoryEntity); + KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz(); + flag = usageHistoryBiz.save(usageHistoryEntityList); + + resultStr = String.valueOf(flag); + /*员工假期余额变更记录*/ + } + } catch (Exception e) { + writeLog(e); + } + return resultStr; + } + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getWorkCode() { + return workCode; + } + + public void setWorkCode(String workCode) { + this.workCode = workCode; + } + + public String getBelongYear() { + return belongYear; + } + + public void setBelongYear(String belongYear) { + this.belongYear = belongYear; + } + + public String getLeaveRulesId() { + return leaveRulesId; + } + + public void setLeaveRulesId(String leaveRulesId) { + this.leaveRulesId = leaveRulesId; + } + + public String getOvertimeType() { + return overtimeType; + } + + public void setOvertimeType(String overtimeType) { + this.overtimeType = overtimeType; + } + + + + public String getUsedAmount() { + return usedAmount; + } + + public void setUsedAmount(String usedAmount) { + BigDecimal _usedAmount = new BigDecimal(Util.getDoubleValue(usedAmount, 0)); + this.usedAmount = _usedAmount.setScale(2, RoundingMode.HALF_UP).toPlainString(); + } + + public String getEffectiveDate() { + return effectiveDate; + } + + public void setEffectiveDate(String effectiveDate) { + this.effectiveDate = effectiveDate; + } + + public int getUserLanguage() { + return userLanguage; + } + + public void setUserLanguage(int userLanguage) { + this.userLanguage = userLanguage; + } + + public void setUserLanguage(String userLanguage) { + this.userLanguage = Util.getIntValue(userLanguage, 7); + } + + public String getKeyField() { + return keyField; + } + + public void setKeyField(String keyField) { + this.keyField = keyField; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } +} diff --git a/src/com/engine/kq/bean/KQBalanceOfLeave.java b/src/com/engine/kq/bean/KQBalanceOfLeave.java new file mode 100644 index 0000000..62da630 --- /dev/null +++ b/src/com/engine/kq/bean/KQBalanceOfLeave.java @@ -0,0 +1,479 @@ +package com.engine.kq.bean; + +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQLeaveRulesDetailComInfo; +import com.engine.kq.biz.KQSettingsComInfo; +import com.engine.kq.biz.KQUsageHistoryBiz; +import com.engine.kq.entity.KQUsageHistoryEntity; +import com.engine.kq.jucailin.util.KQDateUtil; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +/** + * 假期余额--用于Excel导入 + */ +public class KQBalanceOfLeave extends BaseBean { + + /** + * 人员ID + */ + private String resourceId; + /** + * 编号 + */ + private String workcode ; + + /** + * 人员姓名 + */ + private String lastName; + /** + * 假期类型ID + */ + private String leaveRulesId; + /** + * 所属年份 + */ + private String belongYear; + /** + * (混合模式下为法定年假)假期余额基数 + */ + private double baseAmount = 0.00; + /** + * (混合模式下为法定年假)已使用的假期余额 + */ + private double usedAmount = 0.00; + /** + * (混合模式下为法定年假)额外的假期余额 + */ + private double extraAmount = 0.00; + /** + * (仅混合模式下使用,为福利年假)假期余额基数 + */ + private double baseAmount2 = 0.00; + /** + * (仅混合模式下使用,为福利年假)已使用的假期余额 + */ + private double usedAmount2 = 0.00; + /** + * (仅混合模式下使用,为福利年假)额外的假期余额 + */ + private double extraAmount2 = 0.00; + /** + * 用户语言 + */ + private int userlanguage = 7; + /** + * 导入Excel的操作者 + */ + private String operator; + + /** + * 验证模板数据有效性--用于Excel导入 + * + * @return + */ + public String valExcelData() { + + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String allow_negative = Util.null2String(kqSettingsComInfo.getMain_val("allow_negative"),"0"); + String errorInfo = ""; + if (!isExist(resourceId, lastName)) { + errorInfo = SystemEnv.getHtmlLabelName(389985, userlanguage);//ID和姓名不匹配 + return errorInfo; + } + + if (!"1".equals(allow_negative) && this.baseAmount < 0) { + errorInfo = "基数不能为负数"; + return errorInfo; + } + if (!"1".equals(allow_negative) && this.extraAmount < 0) { + errorInfo = "额外不能为负数"; + return errorInfo; + } + if (this.usedAmount < 0) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(10005288,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + double _totalAmount = this.baseAmount+this.extraAmount; + if (!"1".equals(allow_negative) && _totalAmount < this.usedAmount) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(508124,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + + if (!"1".equals(allow_negative) && this.baseAmount2 < 0) { + errorInfo = "福利基数不能为负数"; + return errorInfo; + } + if (!"1".equals(allow_negative) && this.extraAmount2 < 0) { + errorInfo = "福利额外不能为负数"; + return errorInfo; + } + if (this.usedAmount2 < 0) { + errorInfo = "福利已休不能大于总数"; + return errorInfo; + } + double _totalAmount2 = this.baseAmount2+this.extraAmount2; + if (!"1".equals(allow_negative) && _totalAmount2 < this.usedAmount2) { + errorInfo = ""+ SystemEnv.getHtmlLabelName(508124,weaver.general.ThreadVarLanguage.getLang())+""; + return errorInfo; + } + + return errorInfo; + } + + /** + * 保存数据 + * + * @return + */ + public String save() { + String resultStr = "false"; + try { + /*获取当前日期,当前时间*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + + /********************************************************************************************************/ + + /*获取人员的相关信息*/ + ResourceComInfo resourceComInfo = new ResourceComInfo(); + + /*分部ID*/ + String subcompanyId = resourceComInfo.getSubCompanyID(this.resourceId); + //部门ID + String departmentId = resourceComInfo.getDepartmentID(this.resourceId); + /*入职日期*/ + String companyStartDate = resourceComInfo.getCompanyStartDate(this.resourceId); + + /********************************************************************************************************/ + + /*获取假期类型的相关设置*/ + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + + /*请假最小单位*/ + String minimumUnit = rulesComInfo.getMinimumUnit(this.leaveRulesId); + + /********************************************************************************************************/ + + /*获取假期规则(一个假期类型下可能存在多个假期规则)的相关设置*/ + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + + /*请假时长计算方式:1-按工作日计算请假时长、2-按自然日计算请假时长*/ + int distributionMode = Util.getIntValue(detailComInfo.getDistributionMode(this.leaveRulesId, subcompanyId, departmentId, this.resourceId), 1); + + /*有效期规则:0-永久有效、1-按自然年(1月1日-12月31日)、2-按入职日期起12个月、3-自定义次年失效日期*/ + int validityRule = validityRule = Util.getIntValue(detailComInfo.getValidityRule(this.leaveRulesId, subcompanyId, departmentId, this.resourceId), 0); + + /*失效日期--月(当有效期规则选择4-自定义次年失效日期时有效)*/ + String expirationMonth = detailComInfo.getExpirationMonth(this.leaveRulesId, subcompanyId ,departmentId, this.resourceId); + + /*失效日期--日(当有效期规则选择4-自定义次年失效日期时有效)*/ + String expirationDay = detailComInfo.getExpirationDay(this.leaveRulesId, subcompanyId, departmentId, this.resourceId); + + /*允许延长有效期:0-不允许、1-允许*/ + int extensionEnable = Util.getIntValue(detailComInfo.getExtensionEnable(this.leaveRulesId, subcompanyId, departmentId, this.resourceId), 0); + + /*允许超过有效期天数*/ + int extendedDays = Util.getIntValue(detailComInfo.getExtendedDays(this.leaveRulesId, subcompanyId, departmentId, this.resourceId), 0); + + /********************************************************************************************************/ + + /*员工假期余额变更记录*/ + String insertOrUpdate = ""; + KQUsageHistoryEntity usageHistoryEntity = new KQUsageHistoryEntity();//员工假期余额变更记录实体类 + List usageHistoryEntityList = new ArrayList();//员工假期余额变更记录集合 + + /********************************************************************************************************/ + + double oldBaseAmount = 0.00; + double oldUsedAmount = 0.00; + double oldExtraAmount = 0.00; + double oldBaseAmount2 = 0.00; + double oldUsedAmount2 = 0.00; + double oldExtraAmount2 = 0.00; + + double newBaseAmount = 0.00; + double newUsedAmount = 0.00; + double newExtraAmount = 0.00; + double newBaseAmount2 = 0.00; + double newUsedAmount2 = 0.00; + double newExtraAmount2 = 0.00; + int status = 0; + String expirationDate = ""; + + /*计算有效期 start*/ + if (validityRule == 0) { + /*不限制有效期,默认永久有效*/ + status = 0; + } else if (validityRule == 1) { + /*按自然年(1月1日-12月31日)*/ + if (extensionEnable == 1) { + /*允许延长有效期*/ + expirationDate = DateUtil.addDate(this.belongYear + "-12-31", extendedDays); + if (Util.dayDiff(expirationDate, currentDate) > 1) { + status = 1; + } + } else { + expirationDate = this.belongYear + "-12-31"; + if (Util.dayDiff(expirationDate, currentDate) > 1) { + status = 1; + } + } + } else if (validityRule == 2) { + /*按入职日期起12个月*/ + if (companyStartDate.equals("")) { + status = 1; + } else if (extensionEnable == 1) { + /*允许延长有效期*/ + expirationDate = DateUtil.addDate((Util.getIntValue(this.belongYear) + 1) + companyStartDate.substring(4), extendedDays); + if (Util.dayDiff(expirationDate, currentDate) > 1) { + status = 1; + } + } else { + expirationDate = (Util.getIntValue(this.belongYear) + 1) + companyStartDate.substring(4); + if (Util.dayDiff(expirationDate, currentDate) > 1) { + status = 1; + } + } + } else if (validityRule == 3) { + /*自定义次年失效日期*/ + if (extensionEnable == 1) { + /*允许延长有效期*/ + expirationDate = DateUtil.addDate((Util.getIntValue(this.belongYear) + 1) + "-" + expirationMonth + "-" + expirationDay, extendedDays); + if (Util.dayDiff(expirationDate, currentDate) > 1) { + status = 1; + } + } else { + expirationDate = (Util.getIntValue(this.belongYear) + 1) + "-" + expirationMonth + "-" + expirationDay; + if (Util.dayDiff(expirationDate, currentDate) > 1) { + status = 1; + } + } + } + /*计算有效期 end*/ + + newBaseAmount = this.baseAmount; + newExtraAmount = this.extraAmount; + newUsedAmount = this.usedAmount; + if (distributionMode == 6) { + newBaseAmount2 = this.baseAmount2; + newExtraAmount2 = this.extraAmount2; + newUsedAmount2 = this.usedAmount2; + } + + Timestamp date = KQDateUtil.getUpdateTimeStamp(); + boolean flag = true;//记录SQL操作是否成功 + String searchSql = "select * from kq_BalanceOfLeave where leaveRulesId=? and resourceId=? and belongYear=?"; + String updateSql = "update kq_BalanceOfLeave set baseAmount=?,extraAmount=?,usedAmount=?,baseAmount2=?,extraAmount2=?,usedAmount2=?,status=?,expirationDate=?,update_time=? where leaveRulesId=? and resourceId=? and belongYear=? "; + String insertSql = "insert into kq_BalanceOfLeave(baseAmount,extraAmount,usedAmount,baseAmount2,extraAmount2,usedAmount2,status,expirationDate,leaveRulesId,resourceId,belongYear,create_time,update_time,creator) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + RecordSet recordSet = new RecordSet(); + if (recordSet.getDBType().equals("postgresql")) { + updateSql = "update kq_BalanceOfLeave set baseAmount=?,extraAmount=?,usedAmount=?,baseAmount2=?,extraAmount2=?,usedAmount2=?,status=?,expirationDate=?,update_time=?::timestamp where leaveRulesId=? and resourceId=? and belongYear=? "; + insertSql = "insert into kq_BalanceOfLeave(baseAmount,extraAmount,usedAmount,baseAmount2,extraAmount2,usedAmount2,status,expirationDate,leaveRulesId,resourceId,belongYear,create_time,update_time,creator) values(?,?,?,?,?,?,?,?,?,?,?,?::timestamp,?::timestamp,?) "; + } + recordSet.executeQuery(searchSql, this.leaveRulesId, this.resourceId, this.belongYear); + if (recordSet.next()) { + oldBaseAmount = Util.getDoubleValue(recordSet.getString("baseAmount"), 0.00); + oldExtraAmount = Util.getDoubleValue(recordSet.getString("extraAmount"), 0.00); + oldUsedAmount = Util.getDoubleValue(recordSet.getString("usedAmount"), 0.00); + if (distributionMode == 6) { + oldBaseAmount2 = Util.getDoubleValue(recordSet.getString("baseAmount2"), 0.00); + oldExtraAmount2 = Util.getDoubleValue(recordSet.getString("extraAmount2"), 0.00); + oldUsedAmount2 = Util.getDoubleValue(recordSet.getString("usedAmount2"), 0.00); + } + + /*更新员工假期余额 start*/ + flag = recordSet.executeUpdate(updateSql, String.format("%.2f", newBaseAmount), String.format("%.2f", newExtraAmount), String.format("%.2f", newUsedAmount), String.format("%.2f", newBaseAmount2), String.format("%.2f", newExtraAmount2), String.format("%.2f", newUsedAmount2), status, expirationDate,date, this.leaveRulesId, this.resourceId, this.belongYear); + resultStr = String.valueOf(flag); + if (!flag) { + resultStr = "false"; + return resultStr; + } + /*更新员工假期余额 end*/ + + insertOrUpdate = "update"; + } else { + /*新增员工假期余额 start*/ + flag = recordSet.executeUpdate(insertSql, String.format("%.2f", newBaseAmount), String.format("%.2f", newExtraAmount), String.format("%.2f", newUsedAmount), String.format("%.2f", newBaseAmount2), String.format("%.2f", newExtraAmount2), String.format("%.2f", newUsedAmount2), status, expirationDate, this.leaveRulesId, this.resourceId, this.belongYear,date,date,Util.getIntValue(resourceId)); + resultStr = String.valueOf(flag); + if (!flag) { + return resultStr; + } + /*新增员工假期余额 end*/ + + insertOrUpdate = "insert"; + } + + /*员工假期余额变更记录 start*/ + usageHistoryEntity = new KQUsageHistoryEntity(); + usageHistoryEntity.setLeaveRulesId(this.leaveRulesId); + usageHistoryEntity.setRelatedId(this.resourceId); + usageHistoryEntity.setWfRequestId(""); + usageHistoryEntity.setOperator(this.operator); + usageHistoryEntity.setOperateDate(currentDate); + usageHistoryEntity.setOperateTime(currentTime); + usageHistoryEntity.setOperateType("7"); + usageHistoryEntity.setBelongYear(this.belongYear); + usageHistoryEntity.setOldBaseAmount(String.format("%.2f", oldBaseAmount)); + usageHistoryEntity.setNewBaseAmount(String.format("%.2f", newBaseAmount)); + usageHistoryEntity.setOldExtraAmount(String.format("%.2f", oldExtraAmount)); + usageHistoryEntity.setNewExtraAmount(String.format("%.2f", newExtraAmount)); + usageHistoryEntity.setOldUsedAmount(String.format("%.2f", oldUsedAmount)); + usageHistoryEntity.setNewUsedAmount(String.format("%.2f", newUsedAmount)); + usageHistoryEntity.setOldBaseAmount2(String.format("%.2f", oldBaseAmount2)); + usageHistoryEntity.setNewBaseAmount2(String.format("%.2f", newBaseAmount2)); + usageHistoryEntity.setOldExtraAmount2(String.format("%.2f", oldExtraAmount2)); + usageHistoryEntity.setNewExtraAmount2(String.format("%.2f", newExtraAmount2)); + usageHistoryEntity.setOldUsedAmount2(String.format("%.2f", oldUsedAmount2)); + usageHistoryEntity.setNewUsedAmount2(String.format("%.2f", newUsedAmount2)); + usageHistoryEntity.setOldMinimumUnit(minimumUnit); + usageHistoryEntity.setNewMinimumUnit(minimumUnit); + usageHistoryEntity.setInsertOrUpdate(insertOrUpdate); + + usageHistoryEntityList.add(usageHistoryEntity); + KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz(); + flag = usageHistoryBiz.save(usageHistoryEntityList); + resultStr = String.valueOf(flag); + if (!flag) { + return resultStr; + } + /*员工假期余额变更记录 end*/ + } catch (Exception e) { + writeLog(e); + } + return resultStr; + } + + /** + * 判断ID和姓名是否匹配,系统中是否存在此人员 + * + * @param resourceId + * @param lastName + * @return + */ + private boolean isExist(String resourceId, String lastName) { + String sql = "select 1 from HrmResource where id=? "; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, resourceId); + if (recordSet.next()) { + return true; + } else { + return false; + } + } + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getLeaveRulesId() { + return leaveRulesId; + } + + public void setLeaveRulesId(String leaveRulesId) { + this.leaveRulesId = leaveRulesId; + } + + public String getBelongYear() { + return belongYear; + } + + public void setBelongYear(String belongYear) { + this.belongYear = belongYear; + } + + public double getBaseAmount() { + return baseAmount; + } + + public void setBaseAmount(double baseAmount) { + this.baseAmount = baseAmount; + } + + public double getUsedAmount() { + return usedAmount; + } + + public void setUsedAmount(double usedAmount) { + this.usedAmount = usedAmount; + } + + public double getExtraAmount() { + return extraAmount; + } + + public void setExtraAmount(double extraAmount) { + this.extraAmount = extraAmount; + } + + public double getBaseAmount2() { + return baseAmount2; + } + + public void setBaseAmount2(double baseAmount2) { + this.baseAmount2 = baseAmount2; + } + + public double getUsedAmount2() { + return usedAmount2; + } + + public void setUsedAmount2(double usedAmount2) { + this.usedAmount2 = usedAmount2; + } + + public double getExtraAmount2() { + return extraAmount2; + } + + public void setExtraAmount2(double extraAmount2) { + this.extraAmount2 = extraAmount2; + } + + public void setUserLanguage(String languageId) { + this.userlanguage = Util.getIntValue(languageId, 7); + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getWorkcode() { + return workcode; + } + + public void setWorkcode(String workcode) { + this.workcode = workcode; + } +} diff --git a/src/com/engine/kq/bean/KQChildrenBean.java b/src/com/engine/kq/bean/KQChildrenBean.java new file mode 100644 index 0000000..472b343 --- /dev/null +++ b/src/com/engine/kq/bean/KQChildrenBean.java @@ -0,0 +1,46 @@ +package com.engine.kq.bean; + +/** + * 排班制考勤组----排班设置权限(数据存储在建模表中) + */ +public class KQChildrenBean { + private String id; + + private String birthday; + + private String title; + + private String resourceid; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getBirthday() { + return birthday; + } + + public void setBirthday(String birthday) { + this.birthday = birthday; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getResourceid() { + return resourceid; + } + + public void setResourceid(String resourceid) { + this.resourceid = resourceid; + } +} diff --git a/src/com/engine/kq/bean/KQHolidaySet.java b/src/com/engine/kq/bean/KQHolidaySet.java new file mode 100644 index 0000000..e835378 --- /dev/null +++ b/src/com/engine/kq/bean/KQHolidaySet.java @@ -0,0 +1,258 @@ +package com.engine.kq.bean; + +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQHolidaySetComInfo; +import com.engine.kq.biz.KQHolidaySetThread; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.ThreadVarLanguage; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; + +/** + * 节假日设置--用于Excel导入 + */ +public class KQHolidaySet extends BaseBean { + + /** + * 考勤组名称 + */ + private String groupName; + /** + * 考勤组ID + */ + private String groupId; + /** + * 日期 + */ + private String holidayDate; + /** + * 类型:公众假日、调配工作日、调配休息日 + */ + private String changeTypeName; + /** + * 类型对应的数值:1-公众假日、2-调配工作日、3-调配休息日 + */ + private int changeType = 1; + /** + * 说明 + */ + private String holidayDesc; + /** + * 对应工作日:星期日、星期一、星期二、星期三、星期四、星期五、星期六 + * 当考勤组的考勤类型为固定班制和自由班制的时启用 + */ + private String relatedDayName; + /** + * 6-星期日、0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六 + * 当考勤组的考勤类型为固定班制和自由班制的时启用 + */ + private int relatedDay = -1; + /** + * 用户语言 + */ + private int userlanguage = 7; + + public void setUserLanguage(String userlanguage) { + this.userlanguage = Util.getIntValue((String) userlanguage, 7); + } + + /** + * 校验数据有效性--用于Excel导入 + * + * @return + */ + public String valExcelData() { + //简单校验日期格式 + String str = "[0-9]{4}-[0-1]{1}[0-9]{1}-[0-3]{1}[0-9]{1}"; + + String errorInfo = ""; + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + + if (Util.null2String(this.groupName).length() == 0) { + errorInfo = SystemEnv.getHtmlLabelName(390305, userlanguage);//考勤组不能为空 + return errorInfo; + } else if (getGroupId(this.groupName).equals("")) { + errorInfo = SystemEnv.getHtmlLabelName(390306, userlanguage);//没有找到对应的考勤组 + return errorInfo; + } else if (Util.null2String(this.holidayDate).length() == 0) { + errorInfo = SystemEnv.getHtmlLabelName(388723, userlanguage);//日期不能为空 + return errorInfo; + } else if(Util.null2String(this.holidayDate).length()!=0 && !Pattern.matches(str,this.holidayDate)){ + errorInfo = SystemEnv.getHtmlLabelName(130208, userlanguage);//无效日期格式 + return errorInfo; + }else if (getChengeType(this.changeTypeName) != 1 && getChengeType(this.changeTypeName) != 2 && getChengeType(this.changeTypeName) != 3) { + errorInfo = SystemEnv.getHtmlLabelName(83411, userlanguage);//类型不匹配 + return errorInfo; + } else if (getChengeType(this.changeTypeName) == 2) { + String kqType = kqGroupComInfo.getKqtype(this.groupId); + if (kqType.equals("2")) { + errorInfo = SystemEnv.getHtmlLabelName(526272, userlanguage);//暂时不支持排班制的考勤组设置调配工作日 + return errorInfo; + }else if (getRelatedDay(this.relatedDayName) < 0 || getRelatedDay(this.relatedDayName) > 6) { + errorInfo = SystemEnv.getHtmlLabelName(388724, userlanguage);//未找到对应的工作日 + return errorInfo; + } + } + return errorInfo; + } + + /** + * 保存数据 + * + * @return + */ + public String save() { + boolean flag = false; + try { + RecordSet recordSet = new RecordSet(); + + String sql = "select 1 from kq_HolidaySet where groupId=" + this.groupId + " and holidayDate='" + this.holidayDate + "'"; + recordSet.executeQuery(sql); + if (recordSet.next()) { + sql = "delete from kq_HolidaySet where groupId=" + this.groupId + " and holidayDate='" + this.holidayDate + "'"; + recordSet.executeUpdate(sql); + } + + sql = " insert into kq_HolidaySet(groupId,holidayDate,changeType,holidayDesc,relatedDay) values(?,?,?,?,?)"; + flag = recordSet.executeUpdate(sql, this.groupId, this.holidayDate, this.changeType, this.holidayDesc, this.relatedDay); + } catch (Exception e) { + writeLog(e); + } finally { + KQHolidaySetComInfo kqHolidaySetComInfo = new KQHolidaySetComInfo(); + kqHolidaySetComInfo.removeCache(); + + /*刷新考勤报表*/ + List groupIdList = new ArrayList(); + groupIdList.add(this.groupId); + List holidayDateList = new ArrayList(); + holidayDateList.add(this.holidayDate); + new KQHolidaySetThread(groupIdList,holidayDateList).start(); + } + return String.valueOf(flag); + } + + /** + * 根据考勤组名称获取考勤组ID + * + * @param groupName + * @return + */ + public String getGroupId(String groupName) { + String groupId = ""; + String sql = "select id from kq_Group where (isDelete is null or isDelete <>1) and groupName='" + groupName + "' "; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + groupId = recordSet.getString("id"); + } + this.groupId = groupId; + return groupId; + } + + /** + * 获取类型 + * + * @param changeTypeName + * @return + */ + public int getChengeType(String changeTypeName) { + int changeType = -1; + if (Util.null2String(changeTypeName).trim().equals(SystemEnv.getHtmlLabelName(16478, ThreadVarLanguage.getLang()).trim())) { + changeType = 1; + } else if (Util.null2String(changeTypeName).trim().equals(SystemEnv.getHtmlLabelName(16751, ThreadVarLanguage.getLang()).trim())) { + changeType = 2; + } else if (Util.null2String(changeTypeName).trim().equals(SystemEnv.getHtmlLabelName(16752, ThreadVarLanguage.getLang()).trim())) { + changeType = 3; + } else { + changeType = -1; + } + this.changeType = changeType; + return changeType; + } + + /** + * 获取对应工作日 + * + * @param relatedDayName 对应工作日:0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六、6-星期日 + * @return + */ + public int getRelatedDay(String relatedDayName) { + int relatedDay = -1; + if (Util.null2String(relatedDayName).trim().equals(SystemEnv.getHtmlLabelName(528000, ThreadVarLanguage.getLang()).trim())) { + relatedDay = 0; + } else if (Util.null2String(relatedDayName).trim().equals(SystemEnv.getHtmlLabelName(528001, ThreadVarLanguage.getLang()).trim())) { + relatedDay = 1; + } else if (Util.null2String(relatedDayName).trim().equals(SystemEnv.getHtmlLabelName(528002, ThreadVarLanguage.getLang()).trim())) { + relatedDay = 2; + } else if (Util.null2String(relatedDayName).trim().equals( SystemEnv.getHtmlLabelName(528003, ThreadVarLanguage.getLang()).trim())) { + relatedDay = 3; + } else if (Util.null2String(relatedDayName).trim().equals(SystemEnv.getHtmlLabelName(528004, ThreadVarLanguage.getLang()).trim())) { + relatedDay = 4; + } else if (Util.null2String(relatedDayName).trim().equals(SystemEnv.getHtmlLabelName(528005, ThreadVarLanguage.getLang()).trim())) { + relatedDay = 5; + } else if (Util.null2String(relatedDayName).trim().equals( SystemEnv.getHtmlLabelName(527999, ThreadVarLanguage.getLang()).trim())) { + relatedDay = 6; + } else { + relatedDay = -1; + } + this.relatedDay = relatedDay; + return relatedDay; + } + + /** + * 加载缓存 + */ + public void removeCache() { + try { + KQHolidaySetComInfo kqHolidaySetComInfo = new KQHolidaySetComInfo(); + kqHolidaySetComInfo.removeCache(); + } catch (Exception e) { + writeLog(e); + } + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String getHolidayDate() { + return holidayDate; + } + + public void setHolidayDate(String holidayDate) { + this.holidayDate = holidayDate; + } + + public String getChangeTypeName() { + return changeTypeName; + } + + public void setChangeTypeName(String changeTypeName) { + this.changeTypeName = changeTypeName; + } + + public String getHolidayDesc() { + return holidayDesc; + } + + public void setHolidayDesc(String holidayDesc) { + this.holidayDesc = holidayDesc; + } + + public String getRelatedDayName() { + return relatedDayName; + } + + public void setRelatedDayName(String relatedDayName) { + this.relatedDayName = relatedDayName; + } +} diff --git a/src/com/engine/kq/bean/KQHrmScheduleSign.java b/src/com/engine/kq/bean/KQHrmScheduleSign.java new file mode 100644 index 0000000..af58c30 --- /dev/null +++ b/src/com/engine/kq/bean/KQHrmScheduleSign.java @@ -0,0 +1,215 @@ +package com.engine.kq.bean; + +import java.util.Calendar; +import java.util.Objects; + +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; + +public class KQHrmScheduleSign extends BaseBean { + private String id; + private String userid; + private String usertype; + private String signtype; + private String signdate; + private String signtime; + private String clientaddress; + private String signfrom; + private String longitude; + private String latitude; + private String addr; + private String isincom; + private String isimport; + private String uuid; + private String suuid; + private String importsql; + /** + * 针对跨天的数据设置的所属日期 + */ + private String belongdate; + /** + * 这条考勤签到签退数据对应的班次id,历史班次数据的处理 + */ + private String serialid; + /** + * 获取工作时段 + * 这样写 上班-下班;上班-下班 + */ + private String worksections; + + /** + * 粗布的记录考勤状态 迟到、早退 + */ + private String signstatus; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getUserid() { + return userid; + } + + public void setUserid(String userid) { + this.userid = userid; + } + + public String getUsertype() { + return usertype; + } + + public void setUsertype(String usertype) { + this.usertype = usertype; + } + + public String getSigntype() { + return signtype; + } + + public void setSigntype(String signtype) { + this.signtype = signtype; + } + + public String getSigndate() { + return signdate; + } + + public void setSigndate(String signdate) { + this.signdate = signdate; + } + + public String getSigntime() { + return signtime; + } + + public void setSigntime(String signtime) { + this.signtime = signtime; + } + + public String getClientaddress() { + return clientaddress; + } + + public void setClientaddress(String clientaddress) { + this.clientaddress = clientaddress; + } + + public String getSignfrom() { + return signfrom; + } + + public void setSignfrom(String signfrom) { + this.signfrom = signfrom; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getAddr() { + return addr; + } + + public void setAddr(String addr) { + this.addr = addr; + } + + public String getIsincom() { + return isincom; + } + + public void setIsincom(String isincom) { + this.isincom = isincom; + } + + public String getIsimport() { + return isimport; + } + + public void setIsimport(String isimport) { + this.isimport = isimport; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getSuuid() { + return suuid; + } + + public void setSuuid(String suuid) { + this.suuid = suuid; + } + + public String getImportsql() { + return importsql; + } + + public void setImportsql(String importsql) { + this.importsql = importsql; + } + + public String getBelongdate() { + return belongdate; + } + + public void setBelongdate(String belongdate) { + this.belongdate = belongdate; + } + + public String getSerialid() { + return serialid; + } + + public void setSerialid(String serialid) { + this.serialid = serialid; + } + + public String getWorksections() { + return worksections; + } + + public void setWorksections(String worksections) { + this.worksections = worksections; + } + + public String getSignstatus() { + return signstatus; + } + + public void setSignstatus(String signstatus) { + this.signstatus = signstatus; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + KQHrmScheduleSign that = (KQHrmScheduleSign) o; + return Objects.equals(id, that.id) && Objects.equals(userid, that.userid) && Objects.equals(usertype, that.usertype) && Objects.equals(signtype, that.signtype) && Objects.equals(signdate, that.signdate) && Objects.equals(signtime, that.signtime) && Objects.equals(clientaddress, that.clientaddress) && Objects.equals(signfrom, that.signfrom) && Objects.equals(longitude, that.longitude) && Objects.equals(latitude, that.latitude) && Objects.equals(addr, that.addr) && Objects.equals(isincom, that.isincom) && Objects.equals(isimport, that.isimport) && Objects.equals(uuid, that.uuid) && Objects.equals(suuid, that.suuid) && Objects.equals(importsql, that.importsql) && Objects.equals(belongdate, that.belongdate) && Objects.equals(serialid, that.serialid) && Objects.equals(worksections, that.worksections) && Objects.equals(signstatus, that.signstatus); + } + +} diff --git a/src/com/engine/kq/bean/KQRepeatBean.java b/src/com/engine/kq/bean/KQRepeatBean.java new file mode 100644 index 0000000..6efbcc0 --- /dev/null +++ b/src/com/engine/kq/bean/KQRepeatBean.java @@ -0,0 +1,69 @@ +package com.engine.kq.bean; + +public class KQRepeatBean { + + /** + * 重复请假方式 0-晚到,1-早走,2-晚到+早走 + */ + private String repeatType; + + /** + * 晚到时长 分钟 + */ + private Long repeatLate; + + /** + * 早走时长 分钟 + */ + private Long repeatEarly; + + /** + * 流程抵扣了晚到时长分钟 + */ + private Long repeatLateLink; + + /** + * 流程抵扣了的早走时长分钟 + */ + private Long repeatEarlyLink; + + public Long getRepeatLateLink() { + return repeatLateLink; + } + + public void setRepeatLateLink(Long repeatLateLink) { + this.repeatLateLink = repeatLateLink; + } + + public Long getRepeatEarlyLink() { + return repeatEarlyLink; + } + + public void setRepeatEarlyLink(Long repeatEarlyLink) { + this.repeatEarlyLink = repeatEarlyLink; + } + + public Long getRepeatLate() { + return repeatLate; + } + + public void setRepeatLate(Long repeatLate) { + this.repeatLate = repeatLate; + } + + public Long getRepeatEarly() { + return repeatEarly; + } + + public void setRepeatEarly(Long repeatEarly) { + this.repeatEarly = repeatEarly; + } + + public String getRepeatType() { + return repeatType; + } + + public void setRepeatType(String repeatType) { + this.repeatType = repeatType; + } +} diff --git a/src/com/engine/kq/bean/KQScheduleCode.java b/src/com/engine/kq/bean/KQScheduleCode.java new file mode 100644 index 0000000..ee593ff --- /dev/null +++ b/src/com/engine/kq/bean/KQScheduleCode.java @@ -0,0 +1,200 @@ +package com.engine.kq.bean; + +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +/** + * 考勤人员编号--用于Excel导入 + */ +public class KQScheduleCode extends BaseBean { + private String keyField = ""; + private String workcode = ""; + private String lastname = ""; + private String devicecode = ""; + private String schedulecode = ""; + private int userlanguage = 7; + + /** + * 校验数据有效性--用于Excel导入 + * + * @return + */ + public String valExcelData() { + String sql = ""; + RecordSet rs = new RecordSet(); + String errorInfo = ""; + int userid = 0; + if (this.keyField.equals("workcode")) { + if (workcode.length() == 0) { + errorInfo = SystemEnv.getHtmlLabelName(83770, userlanguage); + } else { + userid = getUserId(workcode); + if (userid == 0) { + errorInfo = SystemEnv.getHtmlLabelName(83772, userlanguage); + } + } + } else if (this.keyField.equals("lastname")) { + if (lastname.length() == 0) { + errorInfo = SystemEnv.getHtmlLabelName(83774, userlanguage); + } else { + userid = getUserId(lastname); + if (userid == 0) { + errorInfo = SystemEnv.getHtmlLabelName(83777, userlanguage); + } + } + } + if (schedulecode.length() == 0) { + errorInfo = SystemEnv.getHtmlLabelName(511425, userlanguage); + } + boolean isOneDevice = true; + sql = " select count(1) from kq_schedule_device "; + rs.executeQuery(sql); + if(rs.next()){ + if(rs.getInt(1)>1){ + isOneDevice = false; + } + } + if(!isOneDevice){ + if (devicecode.length() == 0) { + errorInfo = SystemEnv.getHtmlLabelName( 513724, userlanguage); + }else{ + boolean flag = false; + sql = " select count(1) from kq_schedule_device where devicecode='"+this.devicecode+"'"; + rs.executeQuery(sql); + if(rs.next()){ + if(rs.getInt(1)>0){ + flag = true; + } + } + if(!flag) { + errorInfo = SystemEnv.getHtmlLabelName(513724, userlanguage); + } + } + } + return errorInfo; + } + + /** + * 保存数据 + * + * @return + */ + public String save() { + boolean flag = false; + RecordSet rs = new RecordSet(); + RecordSetTrans rst = new RecordSetTrans(); + String sql = ""; + try { + rst.setAutoCommit(false); + String[] tmpScheduleCodes = Util.splitString(this.schedulecode, ","); + int tmpUserId = 0; + if (keyField.equals("workcode")) { + tmpUserId = getUserId(this.workcode); + } else if (keyField.equals("lastname")) { + tmpUserId = getUserId(this.lastname); + } + if (tmpUserId > 0) { + String tmpDeviceId = ""; + sql = " select * from kq_schedule_device where devicecode='" + this.devicecode + "'"; + rs.executeQuery(sql); + if (rs.next()) { + tmpDeviceId = rs.getString("id"); + } + + if(tmpDeviceId.length()==0){ + sql = " select id from kq_schedule_device "; + rs.executeQuery(sql); + if(rs.getCounts()==1){ + if(rs.next()){ + if(rs.getInt(1)>1){ + tmpDeviceId = Util.null2String(rs.getString("id")); + } + } + } + } + + for (int k = 0; k < tmpScheduleCodes.length; k++) { + //删除本次同步数据 + sql = " delete from kq_schedule_code where resourceid=? and schedulecode=? and deviceid=? "; + rst.executeUpdate(sql, tmpUserId,tmpScheduleCodes[k],tmpDeviceId.length()==0?null:tmpDeviceId); + + sql = " insert into kq_schedule_code (resourceid ,schedulecode ,deviceid) " + + " values(?,?,?)"; + rst.executeUpdate(sql, tmpUserId,tmpScheduleCodes[k],tmpDeviceId.length()==0?null:tmpDeviceId); + } + sql = " SELECT deviceid,schedulecode,COUNT(1) AS num from kq_schedule_code group BY deviceid,schedulecode HAVING COUNT(1)>1 "; + rst.executeQuery(sql); + if(rst.next()){ + flag = false; + rst.rollback(); + }else{ + flag = true; + rst.commit(); + } + } + } catch (Exception e) { + rst.rollback(); + writeLog(e); + } + return String.valueOf(flag); + } + + private int getUserId(String val) { + int userid = 0; + RecordSet rs = new RecordSet(); + String sql = ""; + if(Util.isEnableMultiLang()) { + if (rs.getDBType().equalsIgnoreCase("sqlserver")) { + sql = "select id from hrmresource where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))='" + Util.null2String(val).trim() + "'"; + } else { + sql = "select id from hrmresource where ltrim(rtrim(convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))='" + Util.null2String(val).trim() + "'"; + } + }else{ + sql = "select id from hrmresource where ltrim(rtrim( "+ keyField +"))='" + Util.null2String(val).trim() + "'"; + } + rs.execute(sql); + if (rs.next()) { + userid = rs.getInt("id"); + } + return userid; + } + + public String getWorkcode() { + return this.workcode; + } + + public void setWorkcode(String workcode) { + this.workcode = workcode; + } + + public String getLastname() { + return this.lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public void setDevicecode(String devicecode) { + this.devicecode = devicecode; + } + + public String getSchedulecode() { + return this.schedulecode; + } + + public void setSchedulecode(String schedulecode) { + this.schedulecode = schedulecode; + } + + public void setKeyField(String keyField) { + this.keyField = keyField; + } + + public void setUserLanguage(String userlanguage) { + this.userlanguage = Util.getIntValue((String) userlanguage); + } +} diff --git a/src/com/engine/kq/bean/KqLockAttenda.java b/src/com/engine/kq/bean/KqLockAttenda.java new file mode 100644 index 0000000..2eb52c6 --- /dev/null +++ b/src/com/engine/kq/bean/KqLockAttenda.java @@ -0,0 +1,74 @@ +package com.engine.kq.bean; + +/** + * 排班制考勤组----排班设置权限(数据存储在建模表中) + */ +public class KqLockAttenda { + private String LOCK_COM; + + private String LOCK_SUBCOM; + + private String LOCK_DEPT; + + private String LOCK_RESOURCE; + + private String LOCK_FROMDATE; + private String LOCK_TODATE; + private String LOCK_LOCK; + + public String getLOCK_COM() { + return LOCK_COM; + } + + public void setLOCK_COM(String LOCK_COM) { + this.LOCK_COM = LOCK_COM; + } + + public String getLOCK_SUBCOM() { + return LOCK_SUBCOM; + } + + public void setLOCK_SUBCOM(String LOCK_SUBCOM) { + this.LOCK_SUBCOM = LOCK_SUBCOM; + } + + public String getLOCK_DEPT() { + return LOCK_DEPT; + } + + public void setLOCK_DEPT(String LOCK_DEPT) { + this.LOCK_DEPT = LOCK_DEPT; + } + + public String getLOCK_RESOURCE() { + return LOCK_RESOURCE; + } + + public void setLOCK_RESOURCE(String LOCK_RESOURCE) { + this.LOCK_RESOURCE = LOCK_RESOURCE; + } + + public String getLOCK_FROMDATE() { + return LOCK_FROMDATE; + } + + public void setLOCK_FROMDATE(String LOCK_FROMDATE) { + this.LOCK_FROMDATE = LOCK_FROMDATE; + } + + public String getLOCK_TODATE() { + return LOCK_TODATE; + } + + public void setLOCK_TODATE(String LOCK_TODATE) { + this.LOCK_TODATE = LOCK_TODATE; + } + + public String getLOCK_LOCK() { + return LOCK_LOCK; + } + + public void setLOCK_LOCK(String LOCK_LOCK) { + this.LOCK_LOCK = LOCK_LOCK; + } +} diff --git a/src/com/engine/kq/bean/KqOldCardFlowFlushBean.java b/src/com/engine/kq/bean/KqOldCardFlowFlushBean.java new file mode 100644 index 0000000..f21b839 --- /dev/null +++ b/src/com/engine/kq/bean/KqOldCardFlowFlushBean.java @@ -0,0 +1,85 @@ +package com.engine.kq.bean; + +public class KqOldCardFlowFlushBean { + private int id; + private int prosetid; + private int workflowid; + private int billid; + private String maintablename; + private String detailtablename; + private String mainresourcefield; + private String detailresourcefield; + private int isexecute; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getProsetid() { + return prosetid; + } + + public void setProsetid(int prosetid) { + this.prosetid = prosetid; + } + + public int getWorkflowid() { + return workflowid; + } + + public void setWorkflowid(int workflowid) { + this.workflowid = workflowid; + } + + public int getBillid() { + return billid; + } + + public void setBillid(int billid) { + this.billid = billid; + } + + public String getMaintablename() { + return maintablename; + } + + public void setMaintablename(String maintablename) { + this.maintablename = maintablename; + } + + public String getDetailtablename() { + return detailtablename; + } + + public void setDetailtablename(String detailtablename) { + this.detailtablename = detailtablename; + } + + public String getMainresourcefield() { + return mainresourcefield; + } + + public void setMainresourcefield(String mainresourcefield) { + this.mainresourcefield = mainresourcefield; + } + + public String getDetailresourcefield() { + return detailresourcefield; + } + + public void setDetailresourcefield(String detailresourcefield) { + this.detailresourcefield = detailresourcefield; + } + + public int getIsexecute() { + return isexecute; + } + + public void setIsexecute(int isexecute) { + this.isexecute = isexecute; + } +} diff --git a/src/com/engine/kq/bean/KqShiftscheduleOperateLog.java b/src/com/engine/kq/bean/KqShiftscheduleOperateLog.java new file mode 100644 index 0000000..cc2cf36 --- /dev/null +++ b/src/com/engine/kq/bean/KqShiftscheduleOperateLog.java @@ -0,0 +1,126 @@ +package com.engine.kq.bean; + +import weaver.systeminfo.SystemEnv; + +/** + * 排班制考勤组----排班设置日志 + */ +public class KqShiftscheduleOperateLog { + /** + * 操作类型 + */ + private String operatetype; + + /** + * 操作人 + */ + private String operator; + + /** + * 考勤组名称+id + */ + private String kqgroupname; + + /** + * 被修改人 + */ + private String changeduser; + + /** + * 被修改班次日期 + */ + private String changedshiftdate; + + /** + * 被修改班次+id + */ + private String changedshiftname; + + /** + * 排班设置行id + */ + private String kqshiftid; + + public KqShiftscheduleOperateLog() { + } + + public KqShiftscheduleOperateLog(int type, String operator, String kqgroupname, String changeduser, String changedshiftdate, String oldShiftname, String kqshiftid, String newSerialName, int languageId) { + switch (type) { + case 0: + this.operatetype = SystemEnv.getHtmlLabelName(1421, languageId); + this.changedshiftname = SystemEnv.getHtmlLabelName(546713, languageId)+": <"+newSerialName+">"; + break; + case 1: + this.operatetype = SystemEnv.getHtmlLabelName(17744, languageId); + this.changedshiftname = SystemEnv.getHtmlLabelName(546715, languageId)+": <"+oldShiftname+">"+SystemEnv.getHtmlLabelName(546716, languageId)+"<"+newSerialName+">"; + break; + case 2: + this.operatetype = SystemEnv.getHtmlLabelName(91, languageId); + this.changedshiftname = SystemEnv.getHtmlLabelName(546714, languageId)+": <"+oldShiftname+">"; + break; + default: + break; + } + this.operator = operator; + this.kqgroupname = kqgroupname; + this.changeduser = changeduser; + this.changedshiftdate = changedshiftdate; + this.kqshiftid = kqshiftid; + } + + public String getOperatetype() { + return operatetype; + } + + public void setOperatetype(String operatetype) { + this.operatetype = operatetype; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getKqgroupname() { + return kqgroupname; + } + + public void setKqgroupname(String kqgroupname) { + this.kqgroupname = kqgroupname; + } + + public String getChangeduser() { + return changeduser; + } + + public void setChangeduser(String changeduser) { + this.changeduser = changeduser; + } + + public String getChangedshiftdate() { + return changedshiftdate; + } + + public void setChangedshiftdate(String changedshiftdate) { + this.changedshiftdate = changedshiftdate; + } + + public String getChangedshiftname() { + return changedshiftname; + } + + public void setChangedshiftname(String changedshiftname) { + this.changedshiftname = changedshiftname; + } + + public String getKqshiftid() { + return kqshiftid; + } + + public void setKqshiftid(String kqshiftid) { + this.kqshiftid = kqshiftid; + } +} diff --git a/src/com/engine/kq/bean/KqShiftscheduleRole.java b/src/com/engine/kq/bean/KqShiftscheduleRole.java new file mode 100644 index 0000000..6109998 --- /dev/null +++ b/src/com/engine/kq/bean/KqShiftscheduleRole.java @@ -0,0 +1,56 @@ +package com.engine.kq.bean; + +/** + * 排班制考勤组----排班设置权限(数据存储在建模表中) + */ +public class KqShiftscheduleRole { + private String kqShiftRoleManagerIds; + + private String kqShiftRoleGroupIds; + + private String kqShiftRoleSubcompanyIds; + + private String kqShiftRoleDepartmentIds; + + private String kqShiftRoleResourceIds; + + public String getKqShiftRoleManagerIds() { + return kqShiftRoleManagerIds; + } + + public void setKqShiftRoleManagerIds(String kqShiftRoleManagerIds) { + this.kqShiftRoleManagerIds = kqShiftRoleManagerIds; + } + + public String getKqShiftRoleGroupIds() { + return kqShiftRoleGroupIds; + } + + public void setKqShiftRoleGroupIds(String kqShiftRoleGroupIds) { + this.kqShiftRoleGroupIds = kqShiftRoleGroupIds; + } + + public String getKqShiftRoleSubcompanyIds() { + return kqShiftRoleSubcompanyIds; + } + + public void setKqShiftRoleSubcompanyIds(String kqShiftRoleSubcompanyIds) { + this.kqShiftRoleSubcompanyIds = kqShiftRoleSubcompanyIds; + } + + public String getKqShiftRoleDepartmentIds() { + return kqShiftRoleDepartmentIds; + } + + public void setKqShiftRoleDepartmentIds(String kqShiftRoleDepartmentIds) { + this.kqShiftRoleDepartmentIds = kqShiftRoleDepartmentIds; + } + + public String getKqShiftRoleResourceIds() { + return kqShiftRoleResourceIds; + } + + public void setKqShiftRoleResourceIds(String kqShiftRoleResourceIds) { + this.kqShiftRoleResourceIds = kqShiftRoleResourceIds; + } +} diff --git a/src/com/engine/kq/bean/RightMenu.java b/src/com/engine/kq/bean/RightMenu.java new file mode 100644 index 0000000..3e33363 --- /dev/null +++ b/src/com/engine/kq/bean/RightMenu.java @@ -0,0 +1,141 @@ +package com.engine.kq.bean; + +import weaver.systeminfo.SystemEnv; + +import java.util.Map; + +/** + * 右键菜单 + * @wangqs + * */ +public class RightMenu { + private String menuName; //名称 + private String menuFun; //回调 + private String menuIcon; //图标 + private RightMenuType type; // 类型 + private String isTop; //是否有顶部按钮 + private String isControl ; //是否受控(即有选中列 才可点击) + private String isBatch ; //是否为批量按钮 + private Map params; //请求附带参数 + + public RightMenu(int languageid, RightMenuType type, String menuFun) { + this.menuName = SystemEnv.getHtmlLabelNames(type.getLabelids(),languageid); + this.menuFun = menuFun; + this.menuIcon = type.getIcon(); + this.type = type; + this.isTop = "0"; + } + + public RightMenu(int languageid, RightMenuType type, String menuFun, Map params) { + this.menuName = SystemEnv.getHtmlLabelNames(type.getLabelids(),languageid); + this.menuFun = menuFun; + this.menuIcon = type.getIcon(); + this.type = type; + this.isTop = "0"; + this.params = params; + } + + public RightMenu(int languageid, RightMenuType type, String menuFun, boolean isTop) { + this.menuName = SystemEnv.getHtmlLabelNames(type.getLabelids(),languageid); + this.menuFun = menuFun; + this.menuIcon = type.getIcon(); + this.type = type; + this.isTop = isTop ? "1" : "0"; + } + + public RightMenu(int languageid, RightMenuType type, String menuFun, boolean isTop, Map params) { + this.menuName = SystemEnv.getHtmlLabelNames(type.getLabelids(),languageid); + this.menuFun = menuFun; + this.menuIcon = type.getIcon(); + this.type = type; + this.isTop = isTop ? "1" : "0"; + this.params = params; + } + + public RightMenu(int languageid, RightMenuType type, String menuFun,boolean isTop, boolean isBatch) { + this.menuName = SystemEnv.getHtmlLabelNames(type.getLabelids(),languageid); + this.menuFun = menuFun; + this.menuIcon = type.getIcon(); + this.type = type; + this.isBatch = isBatch ? "1" : "0"; + this.isTop = isTop ? "1" : "0"; + } + + public RightMenu(int languageid, RightMenuType type, String menuFun,boolean isTop, boolean isBatch, Map params) { + this.menuName = SystemEnv.getHtmlLabelNames(type.getLabelids(),languageid); + this.menuFun = menuFun; + this.menuIcon = type.getIcon(); + this.type = type; + this.isBatch = isBatch ? "1" : "0"; + this.isTop = isTop ? "1" : "0"; + this.params = params; + } + + public RightMenu() { + + } + public RightMenuType getType() { + return type; + } + + public void setType(RightMenuType type) { + this.type = type; + } + + public String getMenuName() { + return menuName; + } + + public void setMenuName(String menuName) { + this.menuName = menuName; + } + + public String getMenuFun() { + return menuFun; + } + + public void setMenuFun(String menuFun) { + this.menuFun = menuFun; + } + + public String getMenuIcon() { + return menuIcon; + } + + public void setMenuIcon(String menuIcon) { + this.menuIcon = menuIcon; + } + + public String getIsTop() { + return isTop; + } + + public void setIsTop(String isTop) { + this.isTop = isTop; + } + + public Map getParams() { + return params; + } + + public void setParams(Map params) { + this.params = params; + } + + public String getIsControl() { + return isControl; + } + + public void setIsControl(String isControl) { + this.isControl = isControl; + } + + public String getIsBatch() { + return isBatch; + } + + public void setIsBatch(String isBatch) { + this.isBatch = isBatch; + } + +} diff --git a/src/com/engine/kq/bean/RightMenuType.java b/src/com/engine/kq/bean/RightMenuType.java new file mode 100644 index 0000000..dc173cf --- /dev/null +++ b/src/com/engine/kq/bean/RightMenuType.java @@ -0,0 +1,118 @@ +package com.engine.kq.bean; + +/** + * 右键菜单 + * @author lvyi + * */ +public enum RightMenuType { + BTN_SENDMAIL("2051","icon-coms-Send-emails"),//发送邮件 + BTN_SENDSMSMESSAGE("16635","icon-coms-New-SMS"),//发送短信 + BTN_ADDCOWORK("18034","icon-coms-cowork"),//新建协作 + BTN_DOADDWORKPLANBYHRM("18481","icon-coms-Planning-tasks"),//新建日程 + BTN_EDIT("93","icon-coms-edit"),//编辑 + BTN_EditCompanyVirtual("93,34069","icon-coms-edit"),//编辑组织维度 + BTN_SENDEMESSAGE("130343","icon-coms-e-message"),//发起群聊 + BTN_SEARCH("197","icon-coms-search"),//搜索 + BTN_RESEARCH("364","icon-coms-go-back"),//重新搜索 + BTN_EXPORTEXCEL("28343","icon-coms-export"),//EXCEL导出 + BTN_ADDTOGROUP("130759","icon-coms-search"),//加入到组 + BTN_COLUMN("32535","icon-coms-task-list"),//显示列定制 + //BTN_STORE("28111","icon-coms-Collection"),//收藏 + //BTN_HELP("275","icon-coms-help"),//帮助 + BTN_log("83","icon-coms-Print-log"),//日志 + //BTN_PageAddress("21682","icon-coms-PageAddress"),//显示页面地址 + BTN_AddCounrty("82,377","icon-coms-New-Flow"),//新建国家 + BTN_AddProvince("82,800","icon-coms-New-Flow"),//新建省份 + BTN_AddCity("82,493","icon-coms-New-Flow"),//新建城市 + BTN_AddCityTwo("82,81764","icon-coms-New-Flow"),//新建区县 + BTN_Cancel("22151","icon-coms-hide"),//封存 + BTN_DoIsCanceled("22152","icon-coms-display"),//解封 + BTN_BatchCancel("33619","icon-coms-Batch-add-hot"),//批量封存 + BTN_BatchDoIsCanceled("33620","icon-coms-Batch-add"),//批量解封 + BTN_BatchDelete("32136","icon-coms-Batch-delete"),//批量删除 + BTN_BatchRomove("383696","icon-coms-Batch-delete"),//批量移除 + BTN_BatchOrder("25164","icon-coms-task-list"),//批量排序 + BTN_BatchCode("382686","icon-coms-Need-feedback"),//批量编号 + BTN_BatchSetManager("34078","icon-coms-Need-feedback"),//批量编号 + BTN_Import("18596","icon-coms-leading-in"),//导入 + BTN_Import_Resource("17887","icon-coms-leading-in"),//人员导入 + BTN_Import_Org("125523","icon-coms-leading-in"),//组织结构导入 + BTN_Addnew("82","icon-coms-New-Flow"),//新建 + BTN_AddSignature("16387","icon-coms-New-Flow"),//新建签章 + BTN_AddCompanyVirtual("82,34069","icon-coms-New-Flow"),//新建组织维度 + BTN_AddSubCompany("82,141","icon-coms-New-Flow"),//新建分部 + BTN_AddSubCompanySibling("82,17897","icon-coms-New-Flow"),//新建同级分部 + BTN_AddSubCompanyChild("82,17898","icon-coms-New-Flow"),//新建下级分部 + BTN_AddDepartment("82,124","icon-coms-New-Flow"),//新建部门 + BTN_AddDepartmentSibling("82,17899","icon-coms-New-Flow"),//新建同级部门 + BTN_AddDepartmentChild("82,17587","icon-coms-New-Flow"),//新建下级部门 + BTN_AddResource("15005","icon-coms-New-Flow"),//新建人员 + BTN_AddResourceVirtual("34100","icon-coms-New-Flow"),//加入到多维组织 + BTN_AddResourceToVirtual("383694","icon-coms-New-Flow"),//添加人员 + BTN_AddResourceToGroup("130759","icon-coms-New-Flow"),//加入到组 + BTN_AddVirtualCompany("82,34069","icon-coms-New-Flow"),//新建组织维度 + BTN_FnaBudgetView("386","icon-coms-Detailed"),//预算 + BTN_FnaExpenseDetail("428","icon-coms-Detailed"),//收支 + BTN_Delete("91","icon-coms-delete"),//删除 + BTN_AddJobGroup("82,805","icon-coms-New-Flow"),//新建职务类别 + BTN_ImportJobTitle("125443","icon-coms-leading-in"),//岗位体系导入 + BTN_AddJobActivity("82,1915","icon-coms-New-Flow"),//新建职务 + BTN_AddJobTitle("125302","icon-coms-New-Flow"),//新建岗位 + BTN_Save("86","icon-coms-Preservation"),//保存 + BTN_DepartmentRoles("122","icon-coms-currency-Customer"),//角色 + BTN_Commit("615","icon-coms-Branch"),//保存 + BTN_CreateSalary("15845","icon-coms-content-o"),//生成工资单 + BTN_CloseSalary("19575","icon-coms-integration-o"),//关闭工资单 + BTN_ChangeSalary("19580","icon-coms-currency-Process"),//调整薪酬设置 + BTN_SendSalary("15848","icon-coms-Collection"),//发送工资单 + BTN_ExportSalary("17416,503","icon-coms-PageAddress"),//导出工资单 + BTN_HistorySalary("19576","icon-coms-reportform"),//历史工资单 + BTN_Return("1290","icon-coms-Return"),//返回 + BTN_Export_Excel("28343","icon-coms-export"),//导出Excel + BTN_Copy("77","icon-coms-edit"),//复制 + BTN_Join("2195","icon-coms-Branch"),//保存 + BTN_Apply("129","icon-coms-Branch"),//申请 + BTN_Range("6104","icon-coms-Branch"),//公开范围 + BTN_BatchSet("33511","icon-coms-Flow-setting"),//批量设置 + BTN_SyncSet("385814","icon-coms-Update-synchronization"),//同步默认方式 + BTN_DetailInfo("15729","icon-coms-investigate"),//具体信息 + BTN_SetUserIcon("28062","icon-coms-upload"),//设置头像 + BTN_Rp_Excel("383381","icon-coms-export"),//导出清单到Excel + BTN_KQ_TYPE("383381","icon-coms-investigate"),//考勤方式 + BTN_BatchEditing("15839","icon-coms-BatchEditing-Hot"),//批处理 + BTN_Initialization("390425","icon-coms-Flow-setting"),//开始初始化 + BTN_Init("20873","icon-coms-Flow-setting"),//初始化 + BTN_SHOW_NOACCOUNT("500013","icon-coms-Flow-setting"),//不显示无账号人员 + BTN_KQ_REPORT_FORMAT("510380","icon-coms-investigate"),//重新计算考勤数据 + BTN_KQ_Refresh("354","icon-coms-Update-synchronization"),//刷新 + BTN_CREATE_GROUP("30131","icon-coms-New-Flow"),//新建分组 + BTN_EDIT_GROUP("383049","icon-coms-edit"),//分组维护 + BTN_SAVE_TEMPLETE("18418","icon-coms-Branch"),//存为模板 + BTN_SET_ORDER("389339","icon-coms-Flow-setting"),//设置默认排序 + ; + + private String labelids; + private String icon; + + private RightMenuType(String labelids,String icon){ + this.labelids = labelids; + this.icon = icon; + } + + public String getLabelids() { + return labelids; + } + + public void setLabelids(String labelids) { + this.labelids = labelids; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + +} diff --git a/src/com/engine/kq/bean/TreeNode.java b/src/com/engine/kq/bean/TreeNode.java new file mode 100644 index 0000000..95640e9 --- /dev/null +++ b/src/com/engine/kq/bean/TreeNode.java @@ -0,0 +1,136 @@ +package com.engine.kq.bean; + +import java.util.List; +import java.util.Map; + +/** + * 属性节点 + */ +public class TreeNode { + + private String id; //节点ID 【在树上不一定唯一,需要和type共同使用】 + private String name; //节点显示名 + private String desc; //节点描述 + private String linkUrl; //节点链接 + private String icon; //节点图标 + private String pid; //父节点ID + private boolean isParent; //是否为父节点 + private List subs; //子节点数据 + private String type; //类型 + //其他属性 + private Map prop; + private boolean isSelected; //是否默认选中 + private boolean canClick; //当前节点是否可点击 + private String title; + + public TreeNode() { + } + + public TreeNode(String id, String name, String pid, boolean isParent) { + this.id = id; + this.name = name; + this.pid = pid; + this.isParent = isParent; + } + public TreeNode(String id, String name, String pid, boolean isParent, List subs) { + this.id = id; + this.name = name; + this.pid = pid; + this.isParent = isParent; + this.subs = subs; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getLinkUrl() { + return linkUrl; + } + public void setLinkUrl(String linkUrl) { + this.linkUrl = linkUrl; + } + public String getPid() { + return pid; + } + public void setPid(String pid) { + this.pid = pid; + } + public boolean getIsParent() { + return isParent; + } + public void setIsParent(boolean isParent) { + this.isParent = isParent; + } + public List getSubs() { + return subs; + } + public void setSubs(List subs) { + this.subs = subs; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getDesc() { + return desc; + } + public void setDesc(String desc) { + this.desc = desc; + } + + public Map getProp() { + return prop; + } + + public void setProp(Map prop) { + this.prop = prop; + } + + public void setParent(boolean isParent) { + this.isParent = isParent; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public boolean isSelected() { + return isSelected; + } + + public void setSelected(boolean isSelected) { + this.isSelected = isSelected; + } + + public boolean isCanClick() { + return canClick; + } + + public void setCanClick(boolean canClick) { + this.canClick = canClick; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQ4ScheduleManager.java b/src/com/engine/kq/biz/KQ4ScheduleManager.java new file mode 100644 index 0000000..8c894d5 --- /dev/null +++ b/src/com/engine/kq/biz/KQ4ScheduleManager.java @@ -0,0 +1,177 @@ +package com.engine.kq.biz; + +import com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.hrm.schedule.domain.HrmSchedule; +import weaver.hrm.schedule.manager.HrmScheduleManager; +import weaver.systeminfo.SystemEnv; + +/** + * 新版考勤为原考勤类HrmScheduleManager的通用方法做单独的处理 + */ +public class KQ4ScheduleManager extends BaseBean { + + private int scale = 2; + + private User user; + + private static final String B_TIME = "00:00"; + + private static final String E_TIME = "23:59"; + + private KQWorkTime kqWorkTime; + + public KQ4ScheduleManager(User user) { + this.user = user; + this.kqWorkTime = new KQWorkTime(); + } + + + /** + * HrmScheduleManager里的getTotalWorkData方法 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param $user + * @return + */ + public String[] getTotalWorkData(String fromDate, String fromTime, String toDate, String toTime, User $user) { + + String[] result = {"", ""}; + if($user == null){ + $user = user; + } + if(fromTime.length() == 0){ + fromTime = B_TIME; + } + if(toTime.length() == 0){ + toTime = E_TIME; + } + String ressourceid = $user.getUID()+""; + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(ressourceid). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).durationRuleParam("1") + .computingModeParam("1").durationTypeEnumParam(DurationTypeEnum.COMMON_CAL).build(); + + Map durationMap = kqDurationCalculatorUtil.getWorkDuration(); + String duration4day = Util.null2s(Util.null2String(durationMap.get("duration")),"0"); + String duration4min = Util.null2s(Util.null2String(durationMap.get("min_duration")),"0"); + double duration4hour = Util.getDoubleValue(duration4min)/60.0; + + result[0] = String.valueOf(StringUtil.round(Util.getDoubleValue(duration4day), 5)); + result[1] = String.valueOf(StringUtil.round(duration4hour, 5)); + return result; + } + + /** + * HrmScheduleManager里的getTotalRestHours方法 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param $user + * @return + */ + public String getTotalRestHours(String fromDate, String fromTime, String toDate, String toTime, User $user) { + if($user == null){ + $user = user; + } + String ressourceid = $user.getUID()+""; + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(ressourceid). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).computingModeParam("1"). + durationRuleParam("3").durationTypeEnumParam(DurationTypeEnum.OVERTIME).build(); + Map durationMap = kqDurationCalculatorUtil.getNonWorkDuration(); + String duration = Util.null2String(durationMap.get("duration")); + + return Util.null2String(Util.getDoubleValue(duration,0.0)); + + } + + /** + * 判断是否为工作日 + * @param currentDate + * @return + */ + + public boolean isWorkday(String currentDate){ + return isWorkday(currentDate, user); + } + + /** + * 判断是否为工作日 + * @param currentDate + * @param user + * @return + */ + public boolean isWorkday(String currentDate, User user){ + boolean isWorkday = false; + if(user!=null){ + isWorkday = kqWorkTime.isWorkDay(""+user.getUID(),currentDate); + } + return isWorkday; + } + + public Map getOnDutyAndOffDutyTimeMap(String currentDate) { + Map map = new HashMap<>(); + if(user!=null){ + ShiftInfoCominfoBean shiftInfoCominfoBean = kqWorkTime.getShiftInfoCominfoBean(""+user.getUID(), currentDate); + if(shiftInfoCominfoBean != null){ + //只有一次签到签退的 且设置了休息时间的才能对应上这个方法 + List allWorkTime = shiftInfoCominfoBean.getAllWorkTime(); + List restTimes = shiftInfoCominfoBean.getAllRestTime(); + if(allWorkTime != null && !allWorkTime.isEmpty()){ + //一天一次 + if(allWorkTime.size() == 2){ + if(restTimes != null && !restTimes.isEmpty() && restTimes.size() == 2){ + map.put("onDutyTimeAM", allWorkTime.get(0)); + map.put("offDutyTimeAM", restTimes.get(0)); + map.put("onDutyTimePM", restTimes.get(1)); + map.put("offDutyTimePM",allWorkTime.get(1)); + map.put("signType", "1"); + map.put("signStartTime", ""); + } + } + //一天两次 + if(allWorkTime.size() == 4){ + map.put("onDutyTimeAM", allWorkTime.get(0)); + map.put("offDutyTimeAM", allWorkTime.get(1)); + map.put("onDutyTimePM", allWorkTime.get(2)); + map.put("offDutyTimePM",allWorkTime.get(3)); + map.put("signType", "1"); + map.put("signStartTime", ""); + } + } + + } + } + return map; + } + + public int getScale() { + return scale; + } + + public void setScale(int scale) { + this.scale = scale; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQAttFlowFieldsSetBiz.java b/src/com/engine/kq/biz/KQAttFlowFieldsSetBiz.java new file mode 100644 index 0000000..9faea20 --- /dev/null +++ b/src/com/engine/kq/biz/KQAttFlowFieldsSetBiz.java @@ -0,0 +1,78 @@ +package com.engine.kq.biz; + +import java.util.ArrayList; +import java.util.List; + +/** + * 考勤流程 字段对应 设置类 + */ +public class KQAttFlowFieldsSetBiz { + + /** + * 请假主表流程的规定字段 + */ + public static String[] leaveFields = {"resourceId","departmentId","newLeaveType","fromDate","fromTime","toDate","toTime","duration"}; + + /** + * 出差主表流程的规定字段 + */ + public static String[] evectionFields = {"resourceId","departmentId","fromDate","fromTime","toDate","toTime","duration","companion"}; + + /** + * 公出主表流程的规定字段 + */ + public static String[] outFields = {"resourceId","departmentId","fromDate","fromTime","toDate","toTime","duration"}; + + /** + * 加班主表流程的规定字段 + */ + public static String[] overtimeFields = {"resourceId","departmentId","fromDate","fromTime","toDate","toTime","duration"}; + + /** + * 异常流程主表流程的规定字段 + */ + public static String[] otherFields = {"resourceId","departmentId","fromDate","fromTime","toDate","toTime"}; + + /** + * 排班流程明细流程的规定字段 + */ + public static String[] shiftDetailFields = {"detail_resourceId","detail_fromDate","detail_toDate","detail_shift","detail_group"}; + + /** + * 销假流程的规定字段 + */ + public static String[] leavebackFields = {"resourceId","leaverequestid","detail_fromDate","detail_fromTime","detail_toDate","detail_toTime","detail_duration"}; + + /** + * 销假流程的规定主字段 + */ + public static String[] leavebackMainFields = {"resourceId","leaverequestid"}; + + /** + * 补卡流程的规定字段 + */ + public static String[] cardFields = {"resourceId","fromDate","toDate","detail_signdate","detail_scheduletime","detail_atteStatus","detail_signtype","detail_signtime","resourceIds","detail_resourceid"}; + + /** + * 补卡流程的规定字段 + */ + public static String[] cardMainFields = {"resourceId","fromDate","toDate","resourceIds"}; + + /** + * 考勤变更流程的规定主字段 + */ + public static String[] processchangeMainFields = {"resourceId","changerequestid","changetype"}; + + /** + * 考勤变更流程的规定明细字段 + */ + public static String[] processchangeFields = {"resourceId","changerequestid","changetype","detail_attendancefromDate","detail_attendancefromTime","detail_attendancetoDate","detail_attendancetoTime","detail_attendanceduration","detail_fromDate","detail_fromTime","detail_toDate","detail_toTime","detail_duration"}; + + /** + * 根据类型映射查找字段对应 + */ + public static String[][] fieldsRefect = {leaveFields,evectionFields,outFields,overtimeFields,otherFields,shiftDetailFields,leavebackFields,cardFields,processchangeFields}; + + + +} diff --git a/src/com/engine/kq/biz/KQAttFlowSetBiz.java b/src/com/engine/kq/biz/KQAttFlowSetBiz.java new file mode 100644 index 0000000..b641829 --- /dev/null +++ b/src/com/engine/kq/biz/KQAttFlowSetBiz.java @@ -0,0 +1,1176 @@ +package com.engine.kq.biz; + +import com.api.hrm.util.PageUidFactory; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.hrm.util.HrmUtil; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.enums.OverTimeComputingModeEnum; +import com.engine.kq.log.KQLog; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +/** + * 考勤流程 设置类 + */ +public class KQAttFlowSetBiz { + + private KQLog kqLog = new KQLog(); + + public String getFieldInfo(Map attSetMap){ + String unionSql = ""; + if(attSetMap.isEmpty()){ + return ""; + } + String[][] fieldsRefect = KQAttFlowFieldsSetBiz.fieldsRefect; + String[] leavebackMainFields = KQAttFlowFieldsSetBiz.leavebackMainFields; + String[] cardMainFields = KQAttFlowFieldsSetBiz.cardMainFields; + String[] processchangeMainFields = KQAttFlowFieldsSetBiz.processchangeMainFields; + + String prefiex = "detail_"; + String mainPrefix = "a"; + String detailPrefix = "b"; + String allPrefix = "c"; + + String attId = Util.null2String(attSetMap.get("attId")); + int kqtype = Util.getIntValue(Util.null2String(attSetMap.get("kqtype")),0); + String usedetail = Util.null2String(attSetMap.get("usedetail")); + String tablename = Util.null2String(attSetMap.get("tablename")); + tablename = tablename+" "+mainPrefix; + String detailtablename = Util.null2String(attSetMap.get("detailtablename")); + detailtablename = detailtablename+" "+detailPrefix; + + String custome_sql = Util.null2String(attSetMap.get("custome_sql")); + + if(attId.length() > 0){ + String backfields = ""; + Map fieldidMap = new HashMap<>(); + Map fieldnameMap = new HashMap<>(); + Map backfieldMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String dbtype = rs.getDBType(); + boolean cardBindMorePerson = false; // 判断补卡流程是不是绑定了多人力浏览按钮 + String detailResourceField = ""; + String detailResourceBackField = ""; + String sql = "select a.field003 fieldid,a.field004 fieldname,b.field002 wffieldname from kq_att_proc_relation a left join kq_att_proc_fields b on a.field002=b.id where a.field001 = ? "; + if(KqSplitFlowTypeEnum.CARD.getFlowtype() == Util.getIntValue(kqtype)) { + String cardSql = sql; + rs.executeQuery(cardSql, attId); + String mainResourceIdField = ""; + while (rs.next()) { + String wffieldname = rs.getString("wffieldname"); + if("resourceIds".equals(wffieldname)) { + mainResourceIdField = rs.getString("fieldname"); + } + if("detail_resourceid".equals(wffieldname)) { + detailResourceField = rs.getString("fieldname"); + detailResourceBackField = detailPrefix+"."+detailResourceField +" as resourceId"; + } + } + if(!"".equals(mainResourceIdField)) { // 如果绑定了主表的多人员,则where需要调整 + cardBindMorePerson = true; + } + } + rs.executeQuery(sql, attId); + while(rs.next()){ + String fieldid = Util.null2String(rs.getString("fieldid")); + String fieldname = Util.null2String(rs.getString("fieldname")); + String wffieldname = Util.null2String(rs.getString("wffieldname")); + if(Util.getIntValue(fieldid,0) <= 0){ + kqLog.info("getFieldInfo:考勤流程字段对应有误 :fieldid is null: :attId:"+attId); + break; + } + if("1".equalsIgnoreCase(usedetail)){ + if(KqSplitFlowTypeEnum.CARD.getFlowtype() == kqtype) { + if("resourceIds".equals(wffieldname)) { + continue; + } + } else if(KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype() == kqtype + || KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype() == kqtype){ + }else{ + if(wffieldname.indexOf(prefiex) > -1){ + wffieldname = wffieldname.substring(prefiex.length()); + }else{ + kqLog.info("getFieldInfo:考勤流程字段对应有误 :usedetail wffieldname is error: :attId:"+attId); +// break; + } + } + } + String backfield = ""; + fieldidMap.put(wffieldname, fieldid); + fieldnameMap.put(wffieldname, fieldname); + if(KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype() == kqtype){ + if(Arrays.asList(leavebackMainFields).contains(wffieldname)){ + backfield = mainPrefix+"."+fieldname +" as "+wffieldname; + }else{ + backfield = detailPrefix+"."+fieldname +" as "+wffieldname; + } + }else if(KqSplitFlowTypeEnum.CARD.getFlowtype() == kqtype){ + if(Arrays.asList(cardMainFields).contains(wffieldname)){ + if(cardBindMorePerson && "resourceId".equals(wffieldname)) { + backfield = detailPrefix+"."+detailResourceField +" as "+wffieldname; + } else { + backfield = mainPrefix+"."+fieldname +" as "+wffieldname; + } + }else{ + if("detail_signtype".equalsIgnoreCase(wffieldname)){ + if("mysql".equalsIgnoreCase(dbtype)){ + backfield = "CAST("+detailPrefix+"."+fieldname +" as SIGNED) as "+wffieldname; + }else { + backfield = "cast("+detailPrefix+"."+fieldname +" as int) as "+wffieldname; + } + }else{ + backfield = detailPrefix+"."+fieldname +" as "+wffieldname; + } + } + }else if(KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype() == kqtype){ + if(Arrays.asList(processchangeMainFields).contains(wffieldname)){ + backfield = mainPrefix+"."+fieldname +" as "+wffieldname; + }else{ + backfield = detailPrefix+"."+fieldname +" as "+wffieldname; + } + }else{ + if("1".equalsIgnoreCase(usedetail)){ + if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == kqtype && "companion".equalsIgnoreCase(wffieldname)){ + if("oracle".equalsIgnoreCase(dbtype)||"postgresql".equalsIgnoreCase(dbtype)){ + backfield = "to_char("+detailPrefix+"."+fieldname +") as "+wffieldname; + }else if("mysql".equalsIgnoreCase(dbtype)){ + backfield = "CONVERT("+detailPrefix+"."+fieldname +", char ) as "+wffieldname; + }else { + backfield = "cast("+detailPrefix+"."+fieldname +" as varchar(max) ) as "+wffieldname; + } + }else{ + backfield = detailPrefix+"."+fieldname +" as "+wffieldname; + } + }else{ + if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == kqtype && "companion".equalsIgnoreCase(wffieldname)){ + if("oracle".equalsIgnoreCase(dbtype)||"postgresql".equalsIgnoreCase(dbtype)){ + backfield = "to_char("+mainPrefix+"."+fieldname +") as "+wffieldname; + }else if("mysql".equalsIgnoreCase(dbtype)){ + backfield = "CONVERT("+mainPrefix+"."+fieldname +", char ) as "+wffieldname; + }else { + backfield = "cast("+mainPrefix+"."+fieldname +" as varchar(max) ) as "+wffieldname; + } + }else{ + backfield = mainPrefix+"."+fieldname +" as "+wffieldname; + } + } + } + if(!"".equalsIgnoreCase(wffieldname)){ + backfieldMap.put(wffieldname, backfield); + } + } + if(backfieldMap.isEmpty()){ + kqLog.info("getFieldInfo:考勤流程表字段对应為空 :attId:"+attId+":kqtype:"+kqtype); + return ""; + } + if(cardBindMorePerson && "".equals(Util.null2String(backfieldMap.get("resourceId")))) { // 补卡明细多人员特殊处理 + backfieldMap.put("resourceId", detailResourceBackField); + } + //TODO 这里需要改 + boolean isReflect = true; + String[] fieldsType = fieldsRefect[kqtype]; + for(int i = 0 ;i < fieldsType.length ;i++){ + if(KqSplitFlowTypeEnum.CARD.getFlowtype() == kqtype) { + if("resourceIds".equals(fieldsType[i])) { + continue; + } + } + String backfield = Util.null2String(backfieldMap.get(fieldsType[i])); + if(backfield.length() > 0){ + backfields += ","+backfieldMap.get(fieldsType[i]); + }else{ + kqLog.info("getFieldInfo:考勤流程表字段对应未找到 :attId:"+attId+":kqtype:"+kqtype+":fieldsType[i]:"+fieldsType[i]); + if(fieldsType[i].indexOf("duration") > -1){ + backfields += ", 0 as "+fieldsType[i]; + }else{ + backfields += ", '' as "+fieldsType[i]; + } + } + } + if(backfields.length() > 0){ + backfields = backfields.substring(1); + backfields += ","+mainPrefix+".requestid "; + } + if(KqSplitFlowTypeEnum.SHIFT.getFlowtype() == kqtype || KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype() == kqtype + || KqSplitFlowTypeEnum.CARD.getFlowtype() == kqtype || KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype() == kqtype){ + if(KqSplitFlowTypeEnum.SHIFT.getFlowtype() == kqtype){ + unionSql = "select "+backfields+" from "+detailtablename; + }else{ + unionSql = "select "+backfields+" from "+tablename+" left join "+detailtablename+" on "+mainPrefix+".id = "+detailPrefix+".mainid" ; + if(KqSplitFlowTypeEnum.CARD.getFlowtype() == kqtype){ + unionSql = "select "+allPrefix+".* from ("+ "select "+backfields+" from "+tablename+" left join "+detailtablename+" on "+mainPrefix+".id = "+detailPrefix+".mainid" +") "+allPrefix+" where ("+custome_sql+")"; + } + } + }else{ + if("1".equalsIgnoreCase(usedetail)){ + unionSql = "select "+backfields+" from "+detailtablename+" left join "+tablename+" on "+mainPrefix+".id = "+detailPrefix+".mainid" ; + if(KqSplitFlowTypeEnum.OVERTIME.getFlowtype() == kqtype){ + unionSql = "select "+allPrefix+".* from ("+ "select "+backfields+" from "+tablename+" left join "+detailtablename+" on "+mainPrefix+".id = "+detailPrefix+".mainid" +") "+allPrefix+" where ("+custome_sql+")"; + } + }else{ + unionSql = "select "+backfields+" from "+tablename; + } + } + } + return unionSql; + } + + /** + * + * @param kqtype + * @param user + * @param isMyKQ 是否来自我的考勤 + * @param params + * @return + */ + public String getFieldInfoByKQType(String kqtype, User user, String isMyKQ, + Map params){ + String workflowid =Util.null2String(params.get("workflowid")); + String custome_sql =Util.null2String(params.get("custome_sql")); + RecordSet rs = new RecordSet(); + List formids = new ArrayList<>(); + String unionSqls = ""; + String sql = "select * from kq_att_proc_set where field006= ?"; + if(workflowid.length() > 0 && Util.getIntValue(workflowid) > 0){ + sql += " and field001 = ? "; + rs.executeQuery(sql,kqtype,workflowid); + }else{ + rs.executeQuery(sql,kqtype); + } + String whereCondition = " u.resourceid = a.id "; + while(rs.next()){ + Map attSetMap = new HashMap<>(); + String formid = Util.null2s(rs.getString("field002"),""); + String field005 = Util.null2s(rs.getString("field005"),""); + if(field005.equals("0")){ + continue; + } + //TODO 这里需要改 如果一个表单被多个表单使用的情况 +// if(formid.length() == 0){ +// continue; +// } +// if(formids.contains(formid)){ +// continue; +// }else{ +// formids.add(formid); +// } + String attId = Util.null2String(rs.getString("id")); + String usedetail = Util.null2String(rs.getString("usedetail")); + String tablename = Util.null2String(rs.getString("tablename")); + String detailtablename = Util.null2String(rs.getString("detailtablename")); + attSetMap.put("attId", attId); + attSetMap.put("kqtype", kqtype); + attSetMap.put("usedetail", usedetail); + attSetMap.put("tablename", tablename); + attSetMap.put("detailtablename", detailtablename); + attSetMap.put("custome_sql", custome_sql); + if("1".equalsIgnoreCase(usedetail)){ + if("".equalsIgnoreCase(detailtablename)){ + kqLog.info("getFieldInfoByKQType:考勤流程明细表单不存在 :attId:"+attId+":kqtype:"+kqtype); + continue; + } + }else { + if("".equalsIgnoreCase(tablename)){ + kqLog.info("getFieldInfoByKQType:考勤流程主表表单不存在 :attId:"+attId+":kqtype:"+kqtype); + continue; + } + } + String fieldSql = getFieldInfo(attSetMap); + + if(fieldSql.length() > 0){ + if(unionSqls.length() > 0){ + unionSqls += " union all "+ fieldSql; + }else{ + unionSqls += fieldSql; + } + } + } + + if(unionSqls.length() > 0){ + + String unionsql = ""; + if("1".equalsIgnoreCase(isMyKQ)){ + String hrmSql = " select * from hrmresource a where 1=1 "; + unionSqls = " select distinct u.*,w.currentnodetype,w.status as flowstatus,w.workflowid ,w.requestid as req_requestid,w.requestname,a.managerid,a.managerstr,a.loginid,a.subcompanyid1 as asubcompanyid1,a.departmentid as adepartmentid,a.lastname from (" +unionSqls+") u left join Workflow_Requestbase w on u.requestid = w.requestid left join ("+hrmSql+") a on "+whereCondition; + }else{ + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a"); + String hrmSql = " select * from hrmresource a where 1=1 "+rightSql; + unionSqls = " select distinct u.*,w.currentnodetype,w.status as flowstatus,w.workflowid ,w.requestid as req_requestid,w.requestname,a.managerid,a.managerstr,a.loginid,a.subcompanyid1 as asubcompanyid1,a.departmentid as adepartmentid,a.lastname from (" +unionSqls+") u left join Workflow_Requestbase w on u.requestid = w.requestid left join ("+hrmSql+") a on "+whereCondition; + } + + } + return unionSqls; + } + + /** + * 拼接流程查询sql + * @param params + * @return + */ + public Map getFLowSql(Map params, User user){ + RecordSet rs = new RecordSet(); + Map sqlMap = new HashMap<>(); + + String tabkey = Util.null2String(params.get("tabKey")); + int kqtype = Util.getIntValue(Util.null2String(params.get("kqtype")),-1); + String resourceId = Util.null2String(params.get("resourceId")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + + String keyWord = Util.null2String(params.get("keyWord")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.get("typeselect")); + String requestId =Util.null2String(params.get("requestId")); + String viewScope = Util.null2String(params.get("viewScope")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + + String isMyKQ = Util.null2String(params.get("isMyKQ")); + String not_start_node = Util.null2String(params.get("not_start_node")); + String not_requestId =Util.null2String(params.get("not_requestId")); + String custome_sql =Util.null2String(params.get("custome_sql")); + String workflowid =Util.null2String(params.get("workflowid")); + + String fromSql = " "; + //req_requestid 表示只显示Workflow_Requestbase里有的数据 + String sqlWhere = " where 1=1 and req_requestid > 0 "; + + 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"); + } + } + + boolean isFinished = false; + if("1".equalsIgnoreCase(tabkey)){ + //已归档 + isFinished = true; + } + //不区分归档不归档 查所有 + boolean isAll = false; + if("3".equalsIgnoreCase(tabkey)){ + isAll = true; + } + + + if(kqtype == 0){ + String newleavetype = Util.null2String(params.get("newleavetype")); + if(newleavetype.length() > 0){ + sqlWhere += " and newleavetype= "+newleavetype; + } + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if(resourceId.length() > 0){ + sqlWhere += " and resourceId in("+resourceId+")"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and asubcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and adepartmentid in("+departmentId+") "; + } + + if(requestId.length() > 0){ + sqlWhere += " and requestId ="+requestId+""; + } + + if(not_requestId.length() > 0){ + sqlWhere += " and requestId not in("+not_requestId+")"; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and loginid is not null "+(rs.getDBType().equals("oracle")?"":" and loginid<>'' "); + } + + if(!isFinished){ + if (fromDate.length() > 0 && toDate.length() > 0){ + sqlWhere += " and ( fromDate between '"+fromDate+"' and '"+toDate+"' or toDate between '"+fromDate+"' and '"+toDate+"' " + + " or '"+fromDate+"' between fromDate and toDate or '"+toDate+"' between fromDate and toDate) "; + } + } + + if(isFinished){ + sqlWhere += " and (currentnodetype = '3') "; + }else{ + if(!isAll){ + sqlWhere += " and (currentnodetype is null or currentnodetype != '3') "; + } + } + if("1".equalsIgnoreCase(not_start_node)){ + sqlWhere += " and (currentnodetype != '0') "; + } + if(workflowid.length() > 0){ + sqlWhere += " and workflowid= "+workflowid; + } + if(custome_sql.length() > 0){ + sqlWhere += " and ("+custome_sql+") "; + } + if (kqtype == 3) { + if (custome_sql.length() <= 0 && resourceId.length() > 0) { + params.put("custome_sql", " resourceId in(" + resourceId + ")"); + } + } + if(kqtype > -1){ + if(isFinished){ + fromSql = getFinishedByKQType(""+kqtype,fromDate,toDate,user,isMyKQ); + }else { + fromSql = getFieldInfoByKQType(""+kqtype,user,isMyKQ,params); + } + } + if(fromSql.length() == 0){ + return sqlMap; + }else{ + fromSql = "from ("+fromSql+") f "; + } + + if("1".equalsIgnoreCase(isMyKQ)){ + }else{ + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a"); + String hrmSql = " select id from hrmresource a where 1=1 "+rightSql; + sqlWhere += " and resourceId in("+hrmSql+")"; + } + kqLog.info("buildFlowSetTableString"+kqtype+":流程明细sql输出下:fromSql:"+fromSql); + kqLog.info("buildFlowSetTableString"+kqtype+":流程明细sql输出下:sqlWhere:"+sqlWhere); + sqlMap.put("from", fromSql); + sqlMap.put("where", sqlWhere); + return sqlMap; + } + + + /** + * 获取归档后的考勤流程数据 + * @param kqtype + * @param fromDate + * @param toDate + * @param user + * @param isMyKQ 是否来自我的考勤 + * @return + */ + private String getFinishedByKQType(String kqtype, String fromDate, String toDate, User user, + String isMyKQ) { + boolean isLeave = false; + boolean isEvection = false; + boolean isOut = false; + boolean isOvertime = false; + String tableName = ""; + String fields = " distinct requestid,resourceid as resourceId,subcompanyid,departmentid,newleavetype,fromdatedb as fromDate,fromtimedb as fromTime,todatedb as toDate,totimedb as toTime,durationdb,durationrule,SUM(duration) as duration "; + switch (kqtype){ + case "0": + isLeave= true; + tableName = KqSplitFlowTypeEnum.LEAVE.getTablename(); + break; + case "1": + isEvection= true; + tableName = KqSplitFlowTypeEnum.EVECTION.getTablename(); + break; + case "2": + isOut= true; + tableName = KqSplitFlowTypeEnum.OUT.getTablename(); + break; + case "3": + isOvertime=true; + tableName = KqSplitFlowTypeEnum.OVERTIME.getTablename(); + break; + default: + break; + } + if(tableName.length() == 0){ + kqLog.info("getFinishedByKQType:获取归档的考勤流程出问题了:kqtype:"+kqtype); + return ""; + } + if(isLeave){ + String back_table_name= KqSplitFlowTypeEnum.LEAVEBACK.getTablename(); + String table_name= KqSplitFlowTypeEnum.LEAVE.getTablename(); + String backSql = "select sum(duration) from "+back_table_name+" where "+back_table_name+".leavebackrequestid="+table_name+".requestid and "+back_table_name+".newleavetype="+table_name+".newleavetype and "+back_table_name+".resourceid="+table_name+".resourceid "; + if(fromDate.length() > 0 && toDate.length() > 0){ + if("1".equalsIgnoreCase(isMyKQ)){ + backSql += " and belongdate between'"+fromDate+"' and '"+toDate+"'"; + }else{ + backSql += " and belongdate between'"+fromDate+"' and '"+toDate+"'"; + } + + } + fields = " distinct requestid,resourceid as resourceId,subcompanyid,departmentid,newleavetype,fromdatedb as fromDate,fromtimedb as fromTime,todatedb as toDate,totimedb as toTime,durationdb,durationrule,SUM(duration) as duration," + + "("+backSql+") as backduraion "; + } + + String baseSql = " select "+fields+" from "+tableName+" where tablenamedb is not null and (status is null or status != 1) "; + if(fromDate.length() > 0 && toDate.length() > 0){ + if("1".equalsIgnoreCase(isMyKQ)){ + + if(isOvertime){//加班存在默认归属情况,比如1号加班归属到前一天(上个月),导致不显示 + baseSql += " and fromdatedb between'"+fromDate+"' and '"+toDate+"'"; + }else{ + baseSql += " and belongdate between'"+fromDate+"' and '"+toDate+"'"; + } + }else{ + baseSql += " and belongdate between'"+fromDate+"' and '"+toDate+"'"; + } + } + baseSql += " GROUP BY requestid,resourceid,subcompanyid,departmentid,newleavetype,fromdatedb,fromtimedb,todatedb,totimedb,durationdb,durationrule "; + + String unionsql = " select u.*,w.currentnodetype,w.requestname,w.requestid as req_requestid,w.status as flowstatus,w.workflowid,a.managerid,a.managerstr,a.loginid,a.subcompanyid1 as asubcompanyid1,a.departmentid as adepartmentid,a.lastname from ("+baseSql+") u left join Workflow_Requestbase w on u.requestid = w.requestid left join hrmresource a on u.resourceid = a.id "; + return unionsql; + } + + /** + * 考勤报表明细 + * @param params + * @param user + * @return + */ + public String buildFlowSetTableString(Map params, User user){ + int kqtype = Util.getIntValue(Util.null2String(params.get("kqtype")),-1); + String isMyKQ = Util.null2String(params.get("isMyKQ")); + if(!"1".equalsIgnoreCase(isMyKQ)){ + if(kqtype == 3){ + String tabkey = Util.null2String(params.get("tabKey")); + //加班的单独走一个列表显示 + if(OverTimeComputingModeEnum.FLOW.getComputingMode().equalsIgnoreCase(tabkey)){ + return buildTableString4OvertimeFlow(params,user); + }else if(OverTimeComputingModeEnum.FLOW2CARD.getComputingMode().equalsIgnoreCase(tabkey)){ + return buildTableString4OvertimeFlow2Card(params,user); + }else if(OverTimeComputingModeEnum.CARD.getComputingMode().equalsIgnoreCase(tabkey)){ + return buildTableString4OvertimeCard(params,user); + }else if(OverTimeComputingModeEnum.FLOWINCARD.getComputingMode().equalsIgnoreCase(tabkey)){ + return buildTableString4OvertimeFlowInCard(params,user); + } + } + } + + String backfields = " * "; + String fromSql = ""; + String sqlWhere = ""; + String tableString = ""; + String tabletype="none"; + String orderby = " resourceId,fromDate "; + boolean isFinished = false; + String tabkey = Util.null2String(params.get("tabKey")); + if("1".equalsIgnoreCase(tabkey)){ + //已归档 + isFinished = true; + } + String typeselect =Util.null2String(params.get("typeselect")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + + //在这里生成sql语句 + Map sqlMap = getFLowSql(params,user); + if(sqlMap.isEmpty()){ + //给个默认表 比如请假表,因为表结构都是一样的 + String tableName = KqSplitFlowTypeEnum.LEAVE.getTablename(); + fromSql = tableName; + sqlWhere = " where 1=2 "; + }else{ + fromSql = Util.null2String(sqlMap.get("from")); + sqlWhere = Util.null2String(sqlMap.get("where")); + } + + String fromTimePram = kqtype+"+0+"+user.getLanguage()+"+column:newLeaveType"; + if(isFinished){ + fromTimePram = kqtype+"+0+"+user.getLanguage()+"+column:newLeaveType"+"+column:durationrule"; + } + String toTimePram = kqtype+"+1+"+user.getLanguage()+"+column:newLeaveType"; + if(isFinished){ + toTimePram = kqtype+"+1+"+user.getLanguage()+"+column:newLeaveType"+"+column:durationrule"; + } + + String otherPram = kqtype+"+column:durationrule+"+user.getLanguage(); + if(kqtype == 0){ + otherPram +="+column:newLeaveType+column:requestid+column:backduraion"; + } + + int languageId = user.getLanguage(); + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = "cb9b9b02-a34c-4468-b871-08167bcaeb6c"; + + tableString =" "+ +// " "+ + " "+ + " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + + tableString += " "; + tableString += " "; + tableString += " "; + if(kqtype == 0){ + tableString += " "; + } + tableString += " "; + if(isFinished){ + tableString += " "; + } + tableString +=" "+ + "
"; + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + return sessionkey; + } + + + /** + * 流程 生成加班明细 + * @param params + * @param user + * @return + */ + public String buildTableString4OvertimeFlow(Map params, User user){ + String dbType = new RecordSet().getDBType(); + String orgindbtype = new RecordSet().getOrgindbtype(); + String backfields = " * "; + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.get("typeselect")); + String belongdateWhere = ""; + 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"); + } + } + + if (fromDate.length() > 0 && toDate.length() > 0){ + belongdateWhere += " and ( belongdate between '"+fromDate+"' and '"+toDate+"' or belongdate between '"+fromDate+"' and '"+toDate+"' " + + " or '"+fromDate+"' between belongdate and belongdate or '"+toDate+"' between belongdate and belongdate) "; + } + + String overtimeTable = ""; + + if("oracle".equalsIgnoreCase(dbType)){ + overtimeTable = " select requestid,resourceid,fromdatedb fromdate,fromtimedb fromtime,todatedb todate,totimedb totime,computingmode,paidLeaveEnable,expiringdate,durationrule,to_char(sum(duration_min)) duration_min from kq_flow_overtime where computingmode=1 "+(belongdateWhere.length() == 0 ? "" : belongdateWhere)+" group by requestid,resourceid,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,durationrule "; + if("jc".equalsIgnoreCase(orgindbtype)){ + overtimeTable = " select requestid,resourceid,fromdatedb fromdate,fromtimedb fromtime,todatedb todate,totimedb totime,computingmode,paidLeaveEnable,expiringdate,durationrule,to_char(sum(cast(duration_min as NUMERIC))) duration_min from kq_flow_overtime where computingmode=1 "+(belongdateWhere.length() == 0 ? "" : belongdateWhere)+" group by requestid,resourceid,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,durationrule "; + } + }else if("postgresql".equalsIgnoreCase(dbType)){ + overtimeTable = " select requestid,resourceid,fromdatedb fromdate,fromtimedb fromtime,todatedb todate,totimedb totime,computingmode,paidLeaveEnable,expiringdate,durationrule,sum(cast(duration_min as NUMERIC)) duration_min from kq_flow_overtime where computingmode=1 "+(belongdateWhere.length() == 0 ? "" : belongdateWhere)+" group by requestid,resourceid,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,durationrule "; + }else if("mysql".equalsIgnoreCase(dbType)) { + overtimeTable = " select requestid,resourceid,fromdatedb fromdate,fromtimedb fromtime,todatedb todate,totimedb totime,computingmode,paidLeaveEnable,expiringdate,durationrule,CONVERT (sum(duration_min), CHAR ) duration_min from kq_flow_overtime where computingmode=1 " + (belongdateWhere.length() == 0 ? "" : belongdateWhere) + " group by requestid,resourceid,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,durationrule "; + }else{ + overtimeTable = " select requestid,resourceid,fromdatedb fromdate,fromtimedb fromtime,todatedb todate,totimedb totime,computingmode,paidLeaveEnable,expiringdate,durationrule,convert(varchar,sum(cast(duration_min as NUMERIC))) duration_min from kq_flow_overtime where computingmode=1 "+(belongdateWhere.length() == 0 ? "" : belongdateWhere)+" group by requestid,resourceid,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,durationrule "; + } + String fromSql = " (select b.lastname,b.loginid,b.subcompanyid1,b.departmentid,b.jobtitle,b.managerid,b.managerstr,a.* from ("+overtimeTable+") a left join hrmresource b on a.resourceid = b.id) f "; + String sqlWhere = " 1=1 "; + String tableString = ""; + String tabletype="none"; + String orderby = " computingmode "; + + String tabkey = Util.null2String(params.get("tabKey")); + int kqtype = Util.getIntValue(Util.null2String(params.get("kqtype")),-1); + String resourceId = Util.null2String(params.get("resourceId")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + + //来自我的考勤,resourceid为空时,默认取当前用户的id + String source =Util.null2String(params.get("source")); + if(source.equals("isMyKq")){ + if(resourceId.equals("")){ + resourceId = user.getUID()+""; + } + } + kqLog.info(">>>>>>source:"+source+">>>>>resourceId:"+resourceId); + + String keyWord = Util.null2String(params.get("keyWord")); + String requestId =Util.null2String(params.get("requestId")); + String viewScope = Util.null2String(params.get("viewScope")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + + String isMyKQ = Util.null2String(params.get("isMyKQ")); + + boolean isFinished = false; + if("1".equalsIgnoreCase(tabkey)){ + //已归档 + isFinished = true; + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if(resourceId.length() > 0){ + sqlWhere += " and resourceId in("+resourceId+")"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and departmentid in("+departmentId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and loginid is not null "+(new RecordSet().getDBType().equals("oracle")?"":" and loginid<>'' "); + } + + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"aa"); + String hrmSql = " select id from hrmresource aa where 1=1 "+rightSql; + if (null != rightSql && rightSql.length()>0) { + sqlWhere += " and resourceId in("+hrmSql+")"; + } + +// if (fromDate.length() > 0 && toDate.length() > 0){ +// sqlWhere += " and ( fromDate between '"+fromDate+"' and '"+toDate+"' or toDate between '"+fromDate+"' and '"+toDate+"' " +// + " or '"+fromDate+"' between fromDate and toDate or '"+toDate+"' between fromDate and toDate) "; +// } + String otherPram = user.getLanguage()+""; + + String fromTimePram = kqtype+"+0+"+user.getLanguage()+"++column:durationrule"; + String toTimePram = kqtype+"+1+"+user.getLanguage()+"++column:durationrule"; + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQ_OvertimeTotal_Detail_Flow"); + String sql = "backfields>>>>"+backfields+">>>fromSql>>>"+fromSql+">>>sqlWhere>>>"+sqlWhere; + new BaseBean().writeLog("sql>>>>>>>>>"+sql); + tableString =" "+ + " "+ + " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString +=" "+ + "
"; + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + return sessionkey; + } + + /** + * 打卡+流程 生成加班明细 + * @param params + * @param user + */ + private String buildTableString4OvertimeFlow2Card(Map params, User user) { + String backfields = " * "; + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.get("typeselect")); + String belongdateWhere = ""; + 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"); + } + } + + if (fromDate.length() > 0 && toDate.length() > 0){ + belongdateWhere += " and ( belongdate between '"+fromDate+"' and '"+toDate+"' or belongdate between '"+fromDate+"' and '"+toDate+"' " + + " or '"+fromDate+"' between belongdate and belongdate or '"+toDate+"' between belongdate and belongdate) "; + } + String overtimeTable = " select requestid,resourceid,fromdate,fromtime,todate,totime,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,duration_min,durationrule from kq_flow_overtime where computingmode = 2 "+(belongdateWhere.length() == 0 ? "" :belongdateWhere); + + String fromSql = " (select b.lastname,b.loginid,b.subcompanyid1,b.departmentid,b.jobtitle,b.managerid,b.managerstr,a.* from ("+overtimeTable+") a left join hrmresource b on a.resourceid = b.id) f "; + String sqlWhere = " 1=1 "; + String tableString = ""; + String tabletype="none"; + String orderby = " computingmode "; + + String tabkey = Util.null2String(params.get("tabKey")); + int kqtype = Util.getIntValue(Util.null2String(params.get("kqtype")),-1); + String resourceId = Util.null2String(params.get("resourceId")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + + //来自我的考勤,resourceid为空时,默认取当前用户的id + String source =Util.null2String(params.get("source")); + if(source.equals("isMyKq")){ + if(resourceId.equals("")){ + resourceId = user.getUID()+""; + } + } + + String keyWord = Util.null2String(params.get("keyWord")); + String requestId =Util.null2String(params.get("requestId")); + String viewScope = Util.null2String(params.get("viewScope")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + + String isMyKQ = Util.null2String(params.get("isMyKQ")); + + boolean isFinished = false; + if("1".equalsIgnoreCase(tabkey)){ + //已归档 + isFinished = true; + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if(resourceId.length() > 0){ + sqlWhere += " and resourceId in("+resourceId+")"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and departmentid in("+departmentId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and loginid is not null "+(new RecordSet().getDBType().equals("oracle")?"":" and loginid<>'' "); + } + + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"aa"); + String hrmSql = " select id from hrmresource aa where 1=1 "+rightSql; + if (null != rightSql && rightSql.length()>0) { + sqlWhere += " and resourceId in("+hrmSql+")"; + } + + kqLog.info("buildTableString4OvertimeFlow2Card>>>>>>backfields:"+backfields+">>>>>fromSql:"+fromSql + +">>>>>sqlWhere:"+sqlWhere); + String otherPram = user.getLanguage()+""; + String timePram = "column:fromtimedb+column:todatedb+column:totimedb"; + String fromTimePram = kqtype+"+0+"+user.getLanguage()+"++column:durationrule"; + String toTimePram = kqtype+"+1+"+user.getLanguage()+"++column:durationrule"; + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQ_OvertimeTotal_Detail_Flow2Card"); + + tableString =" "+ + " "+ + " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString +=" "+ + "
"; + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + return sessionkey; + } + + /** + * 打卡 生成加班明细 + * @param params + * @param user + */ + private String buildTableString4OvertimeCard(Map params, User user) { + String backfields = " * "; + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.get("typeselect")); + String belongdateWhere = ""; + 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"); + } + } + + if (fromDate.length() > 0 && toDate.length() > 0){ + belongdateWhere += " and ( belongdate between '"+fromDate+"' and '"+toDate+"' or belongdate between '"+fromDate+"' and '"+toDate+"' " + + " or '"+fromDate+"' between belongdate and belongdate or '"+toDate+"' between belongdate and belongdate) "; + } + String overtimeTable = " select requestid,resourceid,fromdate,fromtime,todate,totime,computingmode,paidLeaveEnable,expiringdate,duration_min from kq_flow_overtime where computingmode = 3 "+(belongdateWhere.length() == 0 ? "" : belongdateWhere); + + String fromSql = " (select b.lastname,b.loginid,b.subcompanyid1,b.departmentid,b.jobtitle,b.managerid,b.managerstr,a.* from ("+overtimeTable+") a left join hrmresource b on a.resourceid = b.id) f "; + String sqlWhere = " 1=1 "; + String tableString = ""; + String tabletype="none"; + String orderby = " computingmode "; + + String tabkey = Util.null2String(params.get("tabKey")); + int kqtype = Util.getIntValue(Util.null2String(params.get("kqtype")),-1); + String resourceId = Util.null2String(params.get("resourceId")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + + //来自我的考勤,resourceid为空时,默认取当前用户的id + String source =Util.null2String(params.get("source")); + if(source.equals("isMyKq")){ + if(resourceId.equals("")){ + resourceId = user.getUID()+""; + } + } + kqLog.info(">>>>>>source:"+source+">>>>>resourceId:"+resourceId); + + String keyWord = Util.null2String(params.get("keyWord")); + String requestId =Util.null2String(params.get("requestId")); + String viewScope = Util.null2String(params.get("viewScope")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + + String isMyKQ = Util.null2String(params.get("isMyKQ")); + + boolean isFinished = false; + if("1".equalsIgnoreCase(tabkey)){ + //已归档 + isFinished = true; + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if(resourceId.length() > 0){ + sqlWhere += " and resourceId in("+resourceId+")"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and departmentid in("+departmentId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and loginid is not null "+(new RecordSet().getDBType().equals("oracle")?"":" and loginid<>'' "); + } + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"aa"); + String hrmSql = " select id from hrmresource aa where 1=1 "+rightSql; + if (null != rightSql && rightSql.length()>0) { + sqlWhere += " and resourceId in("+hrmSql+")"; + } + +// if (fromDate.length() > 0 && toDate.length() > 0){ +// sqlWhere += " and ( fromDate between '"+fromDate+"' and '"+toDate+"' or toDate between '"+fromDate+"' and '"+toDate+"' " +// + " or '"+fromDate+"' between fromDate and toDate or '"+toDate+"' between fromDate and toDate) "; +// } + String otherPram = user.getLanguage()+""; + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQ_OvertimeTotal_Detail_Card"); + + tableString =" "+ + " "+ + " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString +=" "+ + "
"; + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + return sessionkey; + } + + /** + * 打卡+流程 取交集 生成加班明细 + * @param params + * @param user + */ + private String buildTableString4OvertimeFlowInCard(Map params, User user) { + String backfields = " * "; + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.get("typeselect")); + String belongdateWhere = ""; + 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"); + } + } + + if (fromDate.length() > 0 && toDate.length() > 0){ + belongdateWhere += " and ( belongdate between '"+fromDate+"' and '"+toDate+"' or belongdate between '"+fromDate+"' and '"+toDate+"' " + + " or '"+fromDate+"' between belongdate and belongdate or '"+toDate+"' between belongdate and belongdate) "; + } + String overtimeTable = " select requestid,resourceid,fromdate,fromtime,todate,totime,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,duration_min,durationrule from kq_flow_overtime where computingmode = 4 "+(belongdateWhere.length() == 0 ? "" :belongdateWhere); + + String fromSql = " (select b.lastname,b.loginid,b.subcompanyid1,b.departmentid,b.jobtitle,b.managerid,b.managerstr,a.* from ("+overtimeTable+") a left join hrmresource b on a.resourceid = b.id) f "; + String sqlWhere = " 1=1 "; + String tableString = ""; + String tabletype="none"; + String orderby = " computingmode "; + + String tabkey = Util.null2String(params.get("tabKey")); + int kqtype = Util.getIntValue(Util.null2String(params.get("kqtype")),-1); + String resourceId = Util.null2String(params.get("resourceId")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + + //来自我的考勤,resourceid为空时,默认取当前用户的id + String source =Util.null2String(params.get("source")); + if(source.equals("isMyKq")){ + if(resourceId.equals("")){ + resourceId = user.getUID()+""; + } + } + + String keyWord = Util.null2String(params.get("keyWord")); + String requestId =Util.null2String(params.get("requestId")); + String viewScope = Util.null2String(params.get("viewScope")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + + String isMyKQ = Util.null2String(params.get("isMyKQ")); + + boolean isFinished = false; + if("1".equalsIgnoreCase(tabkey)){ + //已归档 + isFinished = true; + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if(resourceId.length() > 0){ + sqlWhere += " and resourceId in("+resourceId+")"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and departmentid in("+departmentId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and loginid is not null "+(new RecordSet().getDBType().equals("oracle")?"":" and loginid<>'' "); + } + + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"aa"); + String hrmSql = " select id from hrmresource aa where 1=1 "+rightSql; + if (null != rightSql && rightSql.length()>0) { + sqlWhere += " and resourceId in("+hrmSql+")"; + } + + kqLog.info("KQ_OvertimeTotal_Detail_FlowInCard>>>>>>backfields:"+backfields+">>>>>fromSql:"+fromSql + +">>>>>sqlWhere:"+sqlWhere); + String otherPram = user.getLanguage()+""; + String timePram = "column:fromtime+column:todate+column:totime"; + String fromTimePram = kqtype+"+0+"+user.getLanguage()+"++column:durationrule"; + String toTimePram = kqtype+"+1+"+user.getLanguage()+"++column:durationrule"; + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQ_OvertimeTotal_Detail_FlowInCard"); + + tableString =" "+ + " "+ + " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString +=" "+ + "
"; + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + return sessionkey; + } +} diff --git a/src/com/engine/kq/biz/KQAttFlowSetComInfo.java b/src/com/engine/kq/biz/KQAttFlowSetComInfo.java new file mode 100644 index 0000000..83c159b --- /dev/null +++ b/src/com/engine/kq/biz/KQAttFlowSetComInfo.java @@ -0,0 +1,371 @@ +package com.engine.kq.biz; + +import com.api.hrm.bean.SelectOption; +import com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.StaticObj; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 考勤流程设置缓存类 + * 1、给流程上半天和天下拉框对应关系用的 + * 2、给根据人员id不同带出不同的请假类型用的 + * 主要是给HrmTimeSelWorkflowService这个地方用,流程调用 + */ +public class KQAttFlowSetComInfo extends BaseBean { + private ArrayList ids = null; + + private StaticObj staticobj = null; + + public KQAttFlowSetComInfo(User user) { + staticobj = StaticObj.getInstance(); + if(user != null){ + setKQAttFlowSetComInfo(user); + } + } + + public KQAttFlowSetComInfo() { + staticobj = StaticObj.getInstance(); + getKQAttFlowSetComInfo() ; + } + + private void getKQAttFlowSetComInfo(User user) { + if(staticobj.getObject("KQAttFlowSetComInfo&KQShift") == null || ((Hashtable)staticobj.getObject("KQAttFlowSetComInfo&KQShift")).size()==0) { + setKQAttFlowSetComInfo(user); + } + ids = (ArrayList)(staticobj.getRecordFromObj("KQAttFlowSetComInfo&KQShift", "ids")); + if(ids==null){ + setKQAttFlowSetComInfo(user); + } + } + + private void getKQAttFlowSetComInfo() { + if(staticobj.getObject("KQAttFlowSetComInfo&KQShift") == null || ((Hashtable)staticobj.getObject("KQAttFlowSetComInfo&KQShift")).size()==0) { + setKQAttFlowSetComInfo(); + } + ids = (ArrayList)(staticobj.getRecordFromObj("KQAttFlowSetComInfo&KQShift", "ids")); + if(ids==null){ + setKQAttFlowSetComInfo(); + } + } + private void setKQAttFlowSetComInfo() { + setKQAttFlowSetComInfo(null); + } + + private void setKQAttFlowSetComInfo(User user) { + if(ids != null){ + ids.clear(); + }else{ + ids = new ArrayList(); + } + + Map attFLowlinkMap = new HashMap<>(); + Map attFLowDependCfgMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + //现在只有请假流程有特殊处理 + String getAttFLowInfo = "select * from kq_att_proc_set where field005 = 1 and field006 in(0,6) "; + try { + rs.execute(getAttFLowInfo); + while(rs.next()){ + String prefix = ""; + int type = 0; + String id = rs.getString("id"); + String workflowid = rs.getString("field001"); + String attrType = rs.getString("field006"); + String setId = rs.getString("id"); + String usedetail = rs.getString("usedetail"); + if(usedetail.equalsIgnoreCase("1")){ + prefix = "detail_"; + type = 1; + } + + //请假类型存储的list + Map linkageCfg = new HashMap();//联动 + Map dependCfg = new HashMap();//请假类型数据过滤 + + Map map0 = new HashMap<>(); + String fieldSql = "select a.*,b.field002 fieldname from kq_att_proc_relation a left join kq_att_proc_fields b on a.field002 = b.id where b.field001=180 and a.field001="+setId+" and b.field002 in('"+prefix+"resourceId','"+prefix+"newLeaveType','"+prefix+"fromTime','"+prefix+"toTime') "; + if("6".equalsIgnoreCase(attrType)){ + fieldSql = "select a.*,b.field002 fieldname from kq_att_proc_relation a left join kq_att_proc_fields b on a.field002 = b.id where b.field001=6 and a.field001="+setId+" and b.field002 in('resourceId','detail_newLeaveType','detail_leavefromTime','detail_leavetoTime','detail_fromTime','detail_toTime') "; + } + rs1.execute(fieldSql); + while(rs1.next()){ + String fieldid = rs1.getString("field003"); + String fieldName = rs1.getString("fieldname"); + if("6".equalsIgnoreCase(attrType)){ + if(("resourceId").equalsIgnoreCase(fieldName)){ + map0.put("resourceId", fieldid); + } + if(("detail_newLeaveType").equalsIgnoreCase(fieldName)){ + map0.put("newLeaveType", fieldid); + } + if(("detail_leavefromTime").equalsIgnoreCase(fieldName)){ + map0.put("fromTime", fieldid); + } + if(("detail_leavetoTime").equalsIgnoreCase(fieldName)){ + map0.put("toTime", fieldid); + } + if(("detail_fromTime").equalsIgnoreCase(fieldName)){ + map0.put("back_fromTime", fieldid); + } + if(("detail_toTime").equalsIgnoreCase(fieldName)){ + map0.put("back_toTime", fieldid); + } + }else{ + if((prefix+"resourceId").equalsIgnoreCase(fieldName)){ + map0.put("resourceId", fieldid); + } + if((prefix+"newLeaveType").equalsIgnoreCase(fieldName)){ + map0.put("newLeaveType", fieldid); + } + if((prefix+"fromTime").equalsIgnoreCase(fieldName)){ + map0.put("fromTime", fieldid); + } + if((prefix+"toTime").equalsIgnoreCase(fieldName)){ + map0.put("toTime", fieldid); + } + } + } + + if(!map0.isEmpty()){ + String resourceId_f = Util.null2String(map0.get("resourceId")); + String newLeaveType_f = Util.null2String(map0.get("newLeaveType")); + String fromTime_f = Util.null2String(map0.get("fromTime")); + String toTime_f = Util.null2String(map0.get("toTime")); + String back_fromTime_f = Util.null2String(map0.get("back_fromTime")); + String back_toTime_f = Util.null2String(map0.get("back_toTime")); + // 根据人员id联动请假类型 + resIdLinkLeaveType(resourceId_f,newLeaveType_f, dependCfg, type); + //请假类型联动出时间或者上午下午下拉框 + leaveTypeLinkTime(newLeaveType_f, fromTime_f, toTime_f, linkageCfg, type, null,user,back_fromTime_f,back_toTime_f); + attFLowlinkMap.put(workflowid, linkageCfg); + attFLowDependCfgMap.put(workflowid, dependCfg); + } + ids.add(id); + } + + } catch (Exception e) { + writeLog(e) ; + throw e ; + } + staticobj.putRecordToObj("KQAttFlowSetComInfo&KQShift", "ids", ids); + staticobj.putRecordToObj("KQAttFlowSetComInfo&KQShift", "linkageCfg", attFLowlinkMap); + staticobj.putRecordToObj("KQAttFlowSetComInfo&KQShift", "dependCfg", attFLowDependCfgMap); + } + + /** + * 根据人员id联动请假类型 + * {field83333_1:[field8555_1,field866639_1]} + * 接口说明: + * 请假类型选择的值field83333_1(表示主表明细表):[人力资源浏览按钮field8555_1(用数组表示如果以后要增加多个)] + * @param resourceId_f + * @param newLeaveType_f + * @param linkageCfg + * @param type + */ + private void resIdLinkLeaveType(String resourceId_f, String newLeaveType_f, Map linkageCfg, int type) { + List linkageCfg1 = new ArrayList(); + linkageCfg1.add(resourceId_f+"_"+type); + linkageCfg.put(newLeaveType_f, linkageCfg1); + } + + /** + * 请假类型fieldid_主表还是明细表(0,1){ + * { + * 请假类型选择的值:{ + * changeType:"5-1"/"3-19" 选择了类型之后变成时间还是下拉框 + * fieldid:"112_1", 时间浏览按钮对应的fieldid_主表还是明细表 + * option:[ 变成下拉框之后下拉框里面的值 + * {key:"09:00",showname:"上午"}, + * {key:"13:00",showname:"下午"}, + * {key:"23:00",showname:"整天"} + * ] + * } + * } + * } + * 请假类型选择框联动时间控件,下拉框 + * @param leaveTypeFieldId 请假类型fieldid + * @param fromtimefieldId 时间浏览框fieldid + * @param totimefieldId 时间浏览框fieldid + * @param linkageCfg + * @param type 0:主表; 1:明细表1; 2:明细表2; 3:明细表3 + * @param deafultValue + * @param user + * @param back_fromTime_f 销假时间浏览框fieldid + * @param back_toTime_f 销假时间浏览框fieldid + */ + private void leaveTypeLinkTime(String leaveTypeFieldId, String fromtimefieldId, + String totimefieldId, Map linkageCfg, int type, String[] deafultValue,User user, + String back_fromTime_f,String back_toTime_f){ + int lan = user != null ? user.getLanguage() : 7; + String allday = SystemEnv.getHtmlLabelName(390728, lan); + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + KQTimeSelectionComInfo kqTimeSelectionComInfo = new KQTimeSelectionComInfo(); + + Map selectChangeMapLinkage = new HashMap(); + + kqLeaveRulesComInfo.setTofirstRow(); + while(kqLeaveRulesComInfo.next()){ + String am = SystemEnv.getHtmlLabelName(16689, lan); + String pm = SystemEnv.getHtmlLabelName(16690, lan); + String ruleid = kqLeaveRulesComInfo.getId(); + String changeType = kqLeaveRulesComInfo.getMinimumUnit(); + String timeselection = kqLeaveRulesComInfo.getTimeSelection(); + String selectiontype = ""+KqSplitFlowTypeEnum.LEAVE.getFlowtype(); + Map map = kqTimeSelectionComInfo.getTimeselections(selectiontype,ruleid,changeType); + if(!map.isEmpty()){ + am = Util.null2String(map.get("half_on")); + pm = Util.null2String(map.get("half_off")); + if(am.length() == 0){ + am = SystemEnv.getHtmlLabelName(16689, lan); + } + if(pm.length() == 0){ + pm = SystemEnv.getHtmlLabelName(16690, lan); + } + } + boolean isHalf = "2".equals(changeType); + boolean isWhole = "4".equals(changeType); + changeType = (isHalf||isWhole)?"5-1":"3-19"; + if(isHalf && "2".equalsIgnoreCase(timeselection)){ + //如果不是下拉框形式,还是按照时间浏览按钮显示 + changeType = "3-19"; + } + + List fromHalfOption = new ArrayList<>(); + fromHalfOption.add(new SelectOption("08:00", am)); + fromHalfOption.add(new SelectOption("13:00", pm)); + + List toHalfOption = new ArrayList<>(); + toHalfOption.add(new SelectOption("13:00", am)); + toHalfOption.add(new SelectOption("18:00", pm)); + + List fromWholeOption = new ArrayList<>(); + fromWholeOption.add(new SelectOption("08:00", allday)); + + List toWholeOption = new ArrayList<>(); + toWholeOption.add(new SelectOption("18:00", allday)); + + List> linkageCfg1 = new ArrayList>(); + selectChangeMapLinkage.put(ruleid, linkageCfg1); + Map cfg1 = new HashMap(); + cfg1.put("fieldid", fromtimefieldId+"_"+type); //改变的浏览框ID(_0为主字段,_1为明细字段) + cfg1.put("changeType", changeType); + List _new = new ArrayList<>(); + if(isHalf){ + List _new_half = new ArrayList<>(); + _new_half.addAll(fromHalfOption); + _new.addAll(_new_half); + } + if(isWhole){ + List _new_half = new ArrayList<>(); + _new_half.addAll(fromWholeOption); + _new.addAll(_new_half); + } + cfg1.put("selectOption", _new); //下拉框里的值对应关系 + linkageCfg1.add(cfg1); + cfg1 = new HashMap(); + cfg1.put("fieldid", totimefieldId+"_"+type); //改变的浏览框ID(_0为主字段,_1为明细字段) + cfg1.put("changeType", changeType); + List _new1 = new ArrayList<>(); + if(isHalf){ + List _new_whole = new ArrayList<>(); + _new_whole.addAll(toHalfOption); + _new1.addAll(_new_whole); + } + if(isWhole){ + List _new_whole = new ArrayList<>(); + _new_whole.addAll(toWholeOption); + _new1.addAll(_new_whole); + } + cfg1.put("selectOption", _new1); //下拉框里的值对应关系 + linkageCfg1.add(cfg1); + + if(back_fromTime_f.length() > 0 && back_toTime_f.length() > 0){ + cfg1 = new HashMap(); + cfg1.put("fieldid", back_fromTime_f+"_"+type); //改变的浏览框ID(_0为主字段,_1为明细字段) + cfg1.put("changeType", changeType); + List _new2 = new ArrayList<>(); + if(isHalf){ + List _new_whole = new ArrayList<>(); + _new_whole.addAll(fromHalfOption); + _new2.addAll(_new_whole); + } + if(isWhole){ + List _new_whole = new ArrayList<>(); + _new_whole.addAll(fromWholeOption); + _new2.addAll(_new_whole); + } + cfg1.put("selectOption", _new2); //下拉框里的值对应关系 + linkageCfg1.add(cfg1); + + cfg1 = new HashMap(); + cfg1.put("fieldid", back_toTime_f+"_"+type); //改变的浏览框ID(_0为主字段,_1为明细字段) + cfg1.put("changeType", changeType); + List _new3 = new ArrayList<>(); + if(isHalf){ + List _new_whole = new ArrayList<>(); + _new_whole.addAll(toHalfOption); + _new3.addAll(_new_whole); + } + if(isWhole){ + List _new_whole = new ArrayList<>(); + _new_whole.addAll(toWholeOption); + _new3.addAll(_new_whole); + } + cfg1.put("selectOption", _new3); //下拉框里的值对应关系 + linkageCfg1.add(cfg1); + } + + } + + linkageCfg.put(leaveTypeFieldId+"_"+type, selectChangeMapLinkage); + + } + + /** + * 和流程联调的根据请假类型不同带出不同的时间选择框 + * @param workflowid + * @return + */ + public Map getLinkageCfgByWfId(String workflowid){ + Map attFLowlinkMap = (Map)staticobj.getRecordFromObj("KQAttFlowSetComInfo&KQShift", "linkageCfg"); + if(attFLowlinkMap != null && attFLowlinkMap.get(workflowid) != null){ + return (Map) attFLowlinkMap.get(workflowid); + }else{ + return null; + } + } + + /** + * com/api/hrm/service/HrmTimeSelWorkflowService.java + * 这个地方会调用,控制流程的半天和整天下拉框的 + * 和流程联调的根据不同的人员带出不同的请假类型 + * @param workflowid + * @return + */ + public Map getDependCfgByWfId(String workflowid){ + Map attFLowDependCfgMap = (Map)staticobj.getRecordFromObj("KQAttFlowSetComInfo&KQShift", "dependCfg"); + if(attFLowDependCfgMap != null && attFLowDependCfgMap.get(workflowid) != null){ + return (Map) attFLowDependCfgMap.get(workflowid); + }else{ + return null; + } + } + + public void removeKQAttFlowSetComInfoCache(){ + staticobj.removeObject("KQAttFlowSetComInfo&KQShift"); + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + kqAttProcSetComInfo.removeCache(); + } + +} diff --git a/src/com/engine/kq/biz/KQAttProcSetComInfo.java b/src/com/engine/kq/biz/KQAttProcSetComInfo.java new file mode 100644 index 0000000..27db111 --- /dev/null +++ b/src/com/engine/kq/biz/KQAttProcSetComInfo.java @@ -0,0 +1,104 @@ +package com.engine.kq.biz; + +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; + +/** + * 考勤流程设置基础信息缓存类 + */ +public class KQAttProcSetComInfo extends CacheBase{ + protected static String TABLE_NAME = "kq_att_proc_set"; + /** sql中的where信息,不要以where开始 */ + protected static String TABLE_WHERE = null; + /** sql中的order by信息,不要以order by开始 */ + protected static String TABLE_ORDER = "field001"; + + /** + * 这个就是流程id + */ + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "field001"; + + /** + * 对应表单id + */ + @CacheColumn(name = "field002") + protected static int field002; + + /** + * 是否启用 + */ + @CacheColumn(name = "field005") + protected static int field005; + + /** + * 变更流程类型,0表示请假,1表示出差,2表示公出,3表示加班,4表示异常,5表示调班,6表示销假,7表示补卡 + */ + @CacheColumn(name = "field006") + protected static int field006; + + /** + * 是否启用明细表,默认不启用,1表示启用 + */ + @CacheColumn(name = "usedetail") + protected static int usedetail; + + /** + * 流程可抵扣打卡記錄,默认不启用,1表示启用 + */ + @CacheColumn(name = "flow_deduct_card") + protected static int flow_deduct_card; + + /** + * 考勤流程设置id + */ + @CacheColumn(name = "id") + protected static int attid; + + public String getId(){ + return (String)getRowValue(PK_INDEX); + } + public String getWorkflowId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getFormid() { return (String)getRowValue(field002); } + + public String getFormid(String key) + { + return (String)getValue(field002,key); + } + + public String getEnable() { return (String)getRowValue(field005); } + public String getEnable(String key) + { + return (String)getValue(field005,key); + } + + public String getkqType() { return (String)getRowValue(field006); } + public String getkqType(String key) + { + return (String)getValue(field006,key); + } + + public String getUsedetail() { return (String)getRowValue(usedetail); } + public String getUsedetail(String key) + { + return (String)getValue(usedetail,key); + } + + public String getFlow_deduct_card() { return (String)getRowValue(flow_deduct_card); } + public String getFlow_deduct_card(String key) + { + return (String)getValue(flow_deduct_card,key); + } + + public String getAttid() { return (String)getRowValue(attid); } + public String getAttid(String key) + { + return (String)getValue(attid,key); + } + +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQAutoCheckBiz.java b/src/com/engine/kq/biz/KQAutoCheckBiz.java new file mode 100644 index 0000000..adede99 --- /dev/null +++ b/src/com/engine/kq/biz/KQAutoCheckBiz.java @@ -0,0 +1,1379 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.cloudstore.dev.api.bean.MessageBean; +import com.cloudstore.dev.api.bean.MessageType; +import com.cloudstore.dev.api.service.task.impl.KQAutoCardTaskServiceImpl; +import com.cloudstore.dev.api.util.Util_Message; +import com.engine.kq.bean.KQHrmScheduleSign; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.TimeSignScopeEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.util.KQSignUtil; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.engine.msgcenter.biz.ConfigManager; +import com.engine.msgcenter.biz.WeaMessageTypeConfig; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.dateformat.DateTransformer; +import weaver.dateformat.TimeZoneVar; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 自动打卡 给云桥提供接口 + */ +public class KQAutoCheckBiz extends BaseBean { + + //是否开启日志 + public boolean isLog = false; + public KQLog kqLog = new KQLog(); + private DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + private DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + private DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + private DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + private DateTimeFormatter fullTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + public static String task_id = "hrm_auto_card_"; + + public KQAutoCheckBiz() { + KQConfigComInfo kqConfigComInfo = new KQConfigComInfo(); + isLog = "1".equalsIgnoreCase(Util.null2String(kqConfigComInfo.getValue("auto_card_log"))); + } + + public void autoLog(String info){ + if(isLog){ + kqLog.info(info); + } + } + + public Map auto_punch_card(HttpServletRequest request, + HttpServletResponse response, String json,String uuid) throws Exception{ + JSONObject jsonObject = JSON.parseObject(json); + if(jsonObject != null && !jsonObject.isEmpty()){ + RecordSet rs = new RecordSet(); + String userid = Util.null2String(jsonObject.get("userid")); + String json_task_id = Util.null2String(jsonObject.get("task_id")); + String report_type = Util.null2String(jsonObject.get("report_type")); + if(userid.length() > 0 && report_type.length() > 0){ + if(!(json_task_id.indexOf(task_id) > -1)){ + autoLog(userid+"::auto_punch_card task_id is not right:"+json_task_id+":uuid:"+uuid); + return null; + } + if(!"1".equalsIgnoreCase(report_type) && !"2".equalsIgnoreCase(report_type) && !"3".equalsIgnoreCase(report_type)){ + autoLog(userid+"::auto_punch_card report_type is not right:"+report_type+":uuid:"+uuid); + return null; + } + KQAutoCardTaskServiceImpl kqAutoCardTaskService = new KQAutoCardTaskServiceImpl(); + + if(!kqAutoCardTaskService.show_auto_card_schedule()){ + //没有启用计划任务 report_type的不做打卡 + if("1".equalsIgnoreCase(report_type)){ + autoLog(userid+"::auto_punch_card 没有启用计划任务上报 report_type:"+report_type+" 不做打卡"+":uuid:"+uuid); + return null; + } + + } + if(!jsonObject.containsKey("location_info")){ + autoLog(userid+"::auto_punch_card location_info is null"+":uuid:"+uuid); + return null; + } + if(!jsonObject.containsKey("client_info")){ + autoLog(userid+"::auto_punch_card client_info is null"+":uuid:"+uuid); + return null; + } + JSONObject location_info = (JSONObject) jsonObject.get("location_info"); + if(location_info == null || location_info.isEmpty()){ + autoLog(userid+"::auto_punch_card client_info isEmpty"+":uuid:"+uuid); + return null; + } + String longitude = Util.null2String(location_info.get("longitude")); + String latitude = Util.null2String(location_info.get("latitude")); + String addr = Util.null2String(location_info.get("address")); + String locating = Util.null2String(location_info.get("locating")); + if(addr.length() == 0){ + //ios传的是locating作为地理位置的说明,安卓又是传的addr,没办法,只能这样兼容下了 + addr = locating; + } + + JSONObject client_info = (JSONObject) jsonObject.get("client_info"); + if(client_info == null || client_info.isEmpty()){ + autoLog(userid+"::auto_punch_card client_info isEmpty"+":uuid:"+uuid); + return null; + } + String SSID = Util.null2String(client_info.get("SSID")); + String BSSID = Util.null2String(client_info.get("BSSID")); + + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + LocalDateTime localDateTime = LocalDateTime.now(); + String curdatetime = localDateTime.format(fullFormatter); + String signTime =localDateTime.format(dateTimeFormatter); + String signDate = localDateTime.format(dateFormatter); + + String belongdate = ""; + boolean isInRange = false; + boolean can_punch_card = true; + String today = DateUtil.getCurrentDate();//今天 + Map rangeInfoMap = Maps.newHashMap(); + KQConfigComInfo kqConfigComInfo = new KQConfigComInfo(); + String auto_card_cominfo = Util.null2String(kqConfigComInfo.getValue("auto_card_cominfo"),"0"); + autoLog(userid+"::auto_card_cominfo:::"+auto_card_cominfo+":uuid:"+uuid); + if("1".equalsIgnoreCase(auto_card_cominfo)){ + //如果性能差再走缓存,1表示开启缓存 + getRangeInfoFromCominfo(userid,today,rangeInfoMap); + }else{ + getRangeInfo(userid,today,rangeInfoMap); + } + autoLog("userid::"+userid+"::auto_punch_card:rangeInfoMap:"+rangeInfoMap+":uuid:"+uuid); + String card_type = ""; + String beginSignScope = ""; + if(!rangeInfoMap.isEmpty()){ + isInRange = (boolean) rangeInfoMap.get("isInRange"); + can_punch_card = (boolean) rangeInfoMap.get("can_punch_card"); + belongdate = Util.null2String(rangeInfoMap.get("belongdate")); + card_type = Util.null2String(rangeInfoMap.get("card_type")); + beginSignScope = Util.null2String(rangeInfoMap.get("beginSignScope")); + } + if(!isInRange){ + autoLog("userid::"+userid+"::auto_punch_card isInRange not in "+":uuid:"+uuid); + return null; + } + if(!can_punch_card){ + autoLog("userid::"+userid+"::auto_punch_card can_punch_card not in "+":uuid:"+uuid); + return null; + } + + String deviceInfo = ""; + if(!client_info.isEmpty()){ + deviceInfo = client_info.toJSONString(); + } + + //自动打开的时间是否在范围内 + boolean isInCom = true; + boolean needLocationRange = false; + boolean needWifiRange = false; + boolean isLocationRange = false; + boolean isWifiRange = false; + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map locationMap = kqGroupBiz.checkLocationScope(userid,longitude,latitude); + String locationNeedCheck = Util.null2String(locationMap.get("needCheck")); + String locationfacecheck = Util.null2String(locationMap.get("locationfacecheck")); + boolean locationInScope = Boolean.parseBoolean(Util.null2String(locationMap.get("inScope"))); + if("1".equalsIgnoreCase(locationNeedCheck)){ + needLocationRange = true; + if(locationInScope){ + String locationshowaddress = Util.null2String(locationMap.get("locationshowaddress")); + //记录统一地址 + if(locationshowaddress.equals("1")) { + Map loactionInfo = (Map) locationMap.get("loactionInfo"); + String rangename = Util.null2String(loactionInfo.get("locationname")); + if(rangename.length() > 0){ + addr = rangename; + } + } + isLocationRange = true; + } + if("1".equalsIgnoreCase(locationfacecheck)){ +// 只要开启了任何一个人脸打卡,就不允许自动打卡了 + isInCom = false; + autoLog("userid::"+userid+"::initAutoInfo:地理位置的人脸识别考勤开启了:所以把isInCom置位false"+":uuid:"+uuid); + } + } + String wifiNeedCheck = ""; + Map wifiMap = kqGroupBiz.checkWifiScope(userid, SSID, BSSID); + wifiNeedCheck = Util.null2String(wifiMap.get("needCheck")); + String wififacecheck = Util.null2String(locationMap.get("wififacecheck")); + boolean wifiInScope = Boolean.parseBoolean(Util.null2String(wifiMap.get("inScope"))); + if("1".equalsIgnoreCase(wifiNeedCheck)){ + needWifiRange = true; + if(wifiInScope){ + isWifiRange = true; + } + if("1".equalsIgnoreCase(wififacecheck)){ +// 只要开启了任何一个人脸打卡,就不允许自动打卡了 + isInCom = false; + autoLog("userid::"+userid+"::initAutoInfo:wifi的人脸识别考勤开启了:所以把isInCom置位false"+":uuid:"+uuid); + } + } + autoLog("userid::"+userid+"::auto_punch_card:needLocationRange:"+needLocationRange+":isLocationRange:"+isLocationRange+ + ":needWifiRange:"+needWifiRange+":isWifiRange:"+isWifiRange+":uuid:"+uuid); + if(needLocationRange){ + if(isLocationRange){ + }else{ + if(needWifiRange){ + if(isWifiRange){ + }else{ + //地理位置开启,而且不在范围内,且开启wifi验证,不在范围内 + isInCom = false; + } + }else { + //地理位置开启,而且不在范围内,且未开启wifi验证 + isInCom = false; + } + } + }else{ + if(needWifiRange) { + if (isWifiRange) { + } else { + //地理位置未开启,且开启wifi验证,不在范围内 + isInCom = false; + } + } + } + if(!isInCom){ + return null; + } + + User tmp_user = new User(Util.getIntValue(userid)); + String userType = tmp_user.getLogintype(); + String signType = ""; + String clientAddress = Util.getIpAddr(request); + String isInComs = "1"; + String signfrom = "auto_card"; + if(belongdate.length() == 0){ + belongdate = signDate; + } + + String timeZone = Util.null2String(TimeZoneVar.getTimeZone(),""); + //处理多时区 + String timeZoneConversion = Util.null2String(new BaseBean().getPropValue("weaver_timezone_conversion","timeZoneConversion")).trim(); + if("1".equals(timeZoneConversion)) { + DateTransformer dateTransformer=new DateTransformer(); + String[] zone_localTime = dateTransformer.getLocaleDateAndTime(signDate,signTime); + if(zone_localTime != null && zone_localTime.length == 2){ + signDate = zone_localTime[0]; + signTime = zone_localTime[1]; + } + } + + if("1".equalsIgnoreCase(report_type)){ + //如果是定时上报 + try { + //如果同时满足定时上报和唤醒,那么就意味着会并发触发两次打卡,移动端是不处理的,只能要求服务端处理,检测下如果是定时上报,就等2分钟再上报 + Thread.sleep(10*1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + if("3".equalsIgnoreCase(report_type)){ + //如果是唤醒上报 + try { + //因为存在登录后又触发唤醒的操作,对于这样的数据,只能在检测到是唤醒上报的时候,等一个60s + Thread.sleep(5*1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + //需要增加下判断,同样时间是否已经有数据了 + boolean has_same_card = check_same_card(userid,signDate,card_type,beginSignScope); + autoLog("userid::"+userid+"::auto_punch_card:has_same_card:"+has_same_card+":userid:"+userid+ + ":signDate:"+signDate+":signTime:"+signTime+":uuid:"+uuid); + if(has_same_card){ + return null; + } + + signType = "on".equals(card_type)?"1":"2"; + String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo) "+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + boolean isOk = rs.executeUpdate(punchSql,userid,userType,signType,signDate,signTime,clientAddress,isInComs, + timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo); + //同步更新考勤数据到考勤报表 + new KQFormatBiz().formatDate(userid,belongdate); + // 处理加班规则 + SplitActionUtil.pushOverTimeTasksAll(belongdate,belongdate,""+userid); + autoLog("userid::"+userid+"::auto_punch_card:punchSql KQFormatBiz: isOk:"+isOk+":userid:"+userid+":belongdate:"+belongdate+":signDate:"+signDate+":signTime:"+signTime+":uuid:"+uuid); + appNotification(userid,curdatetime,tmp_user.getLanguage()); + Map result = Maps.newHashMap(); + if(isOk){ + String title = SystemEnv.getHtmlLabelName(519318, tmp_user.getLanguage())+"("+curdatetime+")"; + result.put("title",title); + result.put("status","1"); + return result; + }else{ + return null; + } + } + } + + return null; + } + + public Map auto_punch_card_toem(HttpServletRequest request, + HttpServletResponse response, String json,String uuid) throws Exception{ + JSONObject jsonObject = JSON.parseObject(json); + Map result = Maps.newHashMap(); + if(jsonObject != null && !jsonObject.isEmpty()){ + RecordSet rs = new RecordSet(); + String userid = Util.null2String(jsonObject.get("userid")); + String json_task_id = Util.null2String(jsonObject.get("task_id")); + String report_type = Util.null2String(jsonObject.get("report_type")); + if(userid.length() > 0 && report_type.length() > 0){ + if(!(json_task_id.indexOf(task_id) > -1)){ + autoLog(userid+"::auto_punch_card task_id is not right:"+json_task_id+":uuid:"+uuid); + return null; + } + if(!"1".equalsIgnoreCase(report_type) && !"2".equalsIgnoreCase(report_type) && !"3".equalsIgnoreCase(report_type)){ + autoLog(userid+"::auto_punch_card report_type is not right:"+report_type+":uuid:"+uuid); + return null; + } + KQAutoCardTaskServiceImpl kqAutoCardTaskService = new KQAutoCardTaskServiceImpl(); + + if(!kqAutoCardTaskService.show_auto_card_schedule()){ + //没有启用计划任务 report_type的不做打卡 + if("1".equalsIgnoreCase(report_type)){ + autoLog(userid+"::auto_punch_card 没有启用计划任务上报 report_type:"+report_type+" 不做打卡"+":uuid:"+uuid); + return null; + } + + } + if(!jsonObject.containsKey("location_info")){ + autoLog(userid+"::auto_punch_card location_info is null"+":uuid:"+uuid); + return null; + } + if(!jsonObject.containsKey("client_info")){ + autoLog(userid+"::auto_punch_card client_info is null"+":uuid:"+uuid); + return null; + } + JSONObject location_info = (JSONObject) jsonObject.get("location_info"); + if(location_info == null || location_info.isEmpty()){ + autoLog(userid+"::auto_punch_card client_info isEmpty"+":uuid:"+uuid); + return null; + } + String longitude = Util.null2String(location_info.get("longitude")); + String latitude = Util.null2String(location_info.get("latitude")); + String addr = Util.null2String(location_info.get("address")); + String locating = Util.null2String(location_info.get("locating")); + if(addr.length() == 0){ + //ios传的是locating作为地理位置的说明,安卓又是传的addr,没办法,只能这样兼容下了 + addr = locating; + } + + JSONObject client_info = (JSONObject) jsonObject.get("client_info"); + if(client_info == null || client_info.isEmpty()){ + autoLog(userid+"::auto_punch_card client_info isEmpty"+":uuid:"+uuid); + return null; + } + String SSID = Util.null2String(client_info.get("SSID")); + String BSSID = Util.null2String(client_info.get("BSSID")); + + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + LocalDateTime localDateTime = LocalDateTime.now(); + String curdatetime = localDateTime.format(fullFormatter); + String signTime =localDateTime.format(dateTimeFormatter); + String signDate = localDateTime.format(dateFormatter); + + String belongdate = ""; + boolean isInRange = false; + boolean can_punch_card = true; + String today = DateUtil.getCurrentDate();//今天 + Map rangeInfoMap = Maps.newHashMap(); + KQConfigComInfo kqConfigComInfo = new KQConfigComInfo(); + String auto_card_cominfo = Util.null2String(kqConfigComInfo.getValue("auto_card_cominfo"),"0"); + autoLog(userid+"::auto_card_cominfo:::"+auto_card_cominfo+":uuid:"+uuid); + if("1".equalsIgnoreCase(auto_card_cominfo)){ + //如果性能差再走缓存,1表示开启缓存 + getRangeInfoFromCominfo(userid,today,rangeInfoMap); + }else{ + getRangeInfo(userid,today,rangeInfoMap); + } + autoLog("userid::"+userid+"::auto_punch_card:rangeInfoMap:"+rangeInfoMap+":uuid:"+uuid); + String card_type = ""; + String beginSignScope = ""; + if(!rangeInfoMap.isEmpty()){ + isInRange = (boolean) rangeInfoMap.get("isInRange"); + can_punch_card = (boolean) rangeInfoMap.get("can_punch_card"); + belongdate = Util.null2String(rangeInfoMap.get("belongdate")); + card_type = Util.null2String(rangeInfoMap.get("card_type")); + beginSignScope = Util.null2String(rangeInfoMap.get("beginSignScope")); + } + if(!isInRange){ + autoLog("userid::"+userid+"::auto_punch_card isInRange not in "+":uuid:"+uuid); + return null; + } + if(!can_punch_card){ + autoLog("userid::"+userid+"::auto_punch_card can_punch_card not in "+":uuid:"+uuid); + return null; + } + + String deviceInfo = ""; + if(!client_info.isEmpty()){ + deviceInfo = client_info.toJSONString(); + } + + //自动打开的时间是否在范围内 + boolean isInCom = true; + boolean needLocationRange = false; + boolean needWifiRange = false; + boolean isLocationRange = false; + boolean isWifiRange = false; + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map locationMap = kqGroupBiz.checkLocationScope(userid,longitude,latitude); + autoLog("userid::"+userid+"::longitude:"+longitude+":latitude:"+latitude+":locationMap:"+JSON.toJSONString(locationMap)+":uuid:"+uuid); + String locationNeedCheck = Util.null2String(locationMap.get("needCheck")); + String locationfacecheck = Util.null2String(locationMap.get("locationfacecheck")); + boolean locationInScope = Boolean.parseBoolean(Util.null2String(locationMap.get("inScope"))); + if("1".equalsIgnoreCase(locationNeedCheck)){ + needLocationRange = true; + if(locationInScope){ + String locationshowaddress = Util.null2String(locationMap.get("locationshowaddress")); + //记录统一地址 + if(locationshowaddress.equals("1")) { + Map loactionInfo = (Map) locationMap.get("loactionInfo"); + String rangename = Util.null2String(loactionInfo.get("locationname")); + if(rangename.length() > 0){ + addr = rangename; + } + } + isLocationRange = true; + } + if("1".equalsIgnoreCase(locationfacecheck)){ +// 只要开启了任何一个人脸打卡,就不允许自动打卡了 + isInCom = false; + autoLog("userid::"+userid+"::initAutoInfo:地理位置的人脸识别考勤开启了:所以把isInCom置位false"+":uuid:"+uuid); + } + } + String wifiNeedCheck = ""; + Map wifiMap = kqGroupBiz.checkWifiScope(userid, SSID, BSSID); + autoLog("userid::"+userid+"::SSID:"+SSID+":BSSID:"+BSSID+":wifiMap:"+JSON.toJSONString(wifiMap)+":uuid:"+uuid); + wifiNeedCheck = Util.null2String(wifiMap.get("needCheck")); + String wififacecheck = Util.null2String(locationMap.get("wififacecheck")); + boolean wifiInScope = Boolean.parseBoolean(Util.null2String(wifiMap.get("inScope"))); + if("1".equalsIgnoreCase(wifiNeedCheck)){ + needWifiRange = true; + if(wifiInScope){ + isWifiRange = true; + } + if("1".equalsIgnoreCase(wififacecheck)){ +// 只要开启了任何一个人脸打卡,就不允许自动打卡了 + isInCom = false; + autoLog("userid::"+userid+"::initAutoInfo:wifi的人脸识别考勤开启了:所以把isInCom置位false"+":uuid:"+uuid); + } + } + autoLog("userid::"+userid+"::auto_punch_card:needLocationRange:"+needLocationRange+":isLocationRange:"+isLocationRange+ + ":needWifiRange:"+needWifiRange+":isWifiRange:"+isWifiRange+":uuid:"+uuid); + if(needLocationRange){ + if(isLocationRange){ + }else{ + if(needWifiRange){ + if(isWifiRange){ + }else{ + Map loactionInfo = (Map) locationMap.get("loactionInfo"); + //地理位置开启,而且不在范围内,且开启wifi验证,不在范围内 + String longitudefromoa = Util.null2String(loactionInfo.get("longitudefromoa")); + String latitudefromoa = Util.null2String(loactionInfo.get("latitudefromoa")); + String lengthfromoa = Util.null2String(loactionInfo.get("lengthfromoa")); + String lengthfromem = Util.null2String(loactionInfo.get("lengthfromem")); +// isInCom = false; + result.put("status", "-1"); + result.put("longitudefromoa", longitudefromoa); + result.put("latitudefromoa", latitudefromoa); + result.put("lengthfromoa", lengthfromoa); + result.put("longitudefromem", longitude); + result.put("latitudefromem", latitude); + result.put("lengthfromem", lengthfromem); + autoLog(userid+":自动打卡成功返回值:result:"+result+":uuid:"+uuid); + return result; + } + }else { + Map loactionInfo = (Map) locationMap.get("loactionInfo"); + //地理位置开启,而且不在范围内,且未开启wifi验证 + String longitudefromoa = Util.null2String(loactionInfo.get("longitudefromoa")); + String latitudefromoa = Util.null2String(loactionInfo.get("latitudefromoa")); + String lengthfromoa = Util.null2String(loactionInfo.get("lengthfromoa")); + String lengthfromem = Util.null2String(loactionInfo.get("lengthfromem")); +// isInCom = false; + result.put("status", "-1"); + result.put("longitudefromoa", longitudefromoa); + result.put("latitudefromoa", latitudefromoa); + result.put("lengthfromoa", lengthfromoa); + result.put("longitudefromem", longitude); + result.put("latitudefromem", latitude); + result.put("lengthfromem", lengthfromem); + autoLog(userid+":自动打卡失败返回值:result:"+result+":uuid:"+uuid); +// isInCom = false; + return result; + } + } + }else{ + if(needWifiRange) { + if (isWifiRange) { + } else { + //地理位置未开启,且开启wifi验证,不在范围内 + isInCom = false; + } + } + } + if(!isInCom){ + return null; + } + + User tmp_user = new User(Util.getIntValue(userid)); + String userType = tmp_user.getLogintype(); + String signType = ""; + String clientAddress = Util.getIpAddr(request); + String isInComs = "1"; + String signfrom = "auto_card"; + if(belongdate.length() == 0){ + belongdate = signDate; + } + + String timeZone = Util.null2String(TimeZoneVar.getTimeZone(),""); + //处理多时区 + String timeZoneConversion = Util.null2String(new BaseBean().getPropValue("weaver_timezone_conversion","timeZoneConversion")).trim(); + if("1".equals(timeZoneConversion)) { + DateTransformer dateTransformer=new DateTransformer(); + String[] zone_localTime = dateTransformer.getLocaleDateAndTime(signDate,signTime); + if(zone_localTime != null && zone_localTime.length == 2){ + signDate = zone_localTime[0]; + signTime = zone_localTime[1]; + } + } + + if("1".equalsIgnoreCase(report_type)){ + //如果是定时上报 + try { + //如果同时满足定时上报和唤醒,那么就意味着会并发触发两次打卡,移动端是不处理的,只能要求服务端处理,检测下如果是定时上报,就等2分钟再上报 + Thread.sleep(10*1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + if("3".equalsIgnoreCase(report_type)){ + //如果是唤醒上报 + try { + //因为存在登录后又触发唤醒的操作,对于这样的数据,只能在检测到是唤醒上报的时候,等一个60s + Thread.sleep(5*1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + //需要增加下判断,同样时间是否已经有数据了 + boolean has_same_card = check_same_card(userid,signDate,card_type,beginSignScope); + autoLog("userid::"+userid+"::auto_punch_card:has_same_card:"+has_same_card+":userid:"+userid+ + ":signDate:"+signDate+":signTime:"+signTime+":uuid:"+uuid); + if(has_same_card){ + return null; + } + + signType = "on".equals(card_type)?"1":"2"; + String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo) "+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + boolean isOk = rs.executeUpdate(punchSql,userid,userType,signType,signDate,signTime,clientAddress,isInComs, + timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo); + //同步更新考勤数据到考勤报表 + new KQFormatBiz().formatDate(userid,belongdate); + // 处理加班规则 + SplitActionUtil.pushOverTimeTasksAll(belongdate,belongdate,""+userid); + autoLog("userid::"+userid+"::auto_punch_card:punchSql KQFormatBiz: isOk:"+isOk+":userid:"+userid+":belongdate:"+belongdate+":signDate:"+signDate+":signTime:"+signTime+":uuid:"+uuid); + appNotification(userid,curdatetime,tmp_user.getLanguage()); + if(isOk){ + String title = SystemEnv.getHtmlLabelName(519318, tmp_user.getLanguage())+"("+curdatetime+")"; + result.put("title",title); + result.put("status","1"); + return result; + }else{ + return null; + } + } + } + + return null; + } + + /** + * 判断下同样时间是否已经有数据了 + * @param userid + * @param signDate + * @param card_type + * @param beginSignScope + * @return + */ + public boolean check_same_card(String userid, String signDate, String card_type, + String beginSignScope) { + RecordSet rs = new RecordSet(); + String signtype = "on".equals(card_type)?"1":"2"; + StringBuffer sb = new StringBuffer(); + if(beginSignScope.length() > 0){ + String beginSignDateTime = beginSignScope+":00"; + if(rs.getDBType().equals("oracle")){ + sb.append(" signDate||' '||signTime>='").append(beginSignDateTime).append("' "); + }else if(rs.getDBType().equals("mysql")){ + sb.append(" concat(signDate,' ',signTime)>='").append(beginSignDateTime).append("' "); + }else{ + sb.append(" signDate+' '+signTime>='").append(beginSignDateTime).append("' "); + } + } + String sql = "select 1 from HrmScheduleSign where userid = ? and signtype=? "; + if(sb.toString().length() > 0){ + sql += " and "+sb.toString(); + } + rs.executeQuery(sql, userid,signtype); + if(rs.next()){ + return true; + } + return false; + } + + /** + * 实时获取当前的班次获取到需要的区间 + * @param userid + * @param today + * @param rangeInfoMap + */ + public void getRangeInfo(String userid, String today, Map rangeInfoMap) throws Exception{ + boolean isInRange = false; + boolean can_punch_card = true; + //允许打卡的时间范围 用于判断是否已经打过卡,如果打过卡就不需要打了 + String beginSignScope = ""; + String endSignScope = ""; + //打卡类型,签到还是签退卡 on是签到卡,off是签退卡 + String card_type = ""; + //是否班次设置了打卡归属,设置了的话,签到和签退是独立的,只要查询到有一条数据就表示打卡过了,如果没设置的话,签退是需要有签到才可以签退的 + boolean hasSetSignScope = false; + String locationcheck = ""; + String wificheck = ""; + String locationfacecheck = ""; + String wififacecheck = ""; + String belongdate = ""; + + String preDay = DateUtil.addDate(today, -1);//昨天 + String nextDay = DateUtil.addDate(today, 1);//明天 + + List> auto_list_all = Lists.newArrayList(); + List> auto_list = Lists.newArrayList(); + initAutoInfo(userid,today,auto_list); + if(!auto_list.isEmpty()){ + auto_list_all.addAll(auto_list); + } + auto_list = Lists.newArrayList(); + initAutoInfo(userid,preDay,auto_list); + if(!auto_list.isEmpty()){ + auto_list_all.addAll(auto_list); + } + auto_list = Lists.newArrayList(); + initAutoInfo(userid,nextDay,auto_list); + if(!auto_list.isEmpty()){ + auto_list_all.addAll(auto_list); + } + LocalTime now_time = LocalTime.now(); + if(!auto_list_all.isEmpty()){ + JSONArray jsonArray = new JSONArray(); + for(Map auto_map : auto_list_all){ + String starttime_key = today+"_task_starttime"; + String task_endtime_key = today+"_task_endtime"; + if(auto_map.containsKey(starttime_key) && auto_map.containsKey(task_endtime_key)){ + + String task_starttime = auto_map.get(starttime_key); + String task_endtime = auto_map.get(task_endtime_key); + String task_beginSignScope = auto_map.get("beginSignScope"); + String task_endSignScope = auto_map.get("endSignScope"); + String task_hasSetSignScope = auto_map.get("hasSetSignScope"); + String task_card_type = auto_map.get("card_type"); + String task_locationcheck = auto_map.get("locationcheck"); + String task_wificheck = auto_map.get("wificheck"); + String task_locationfacecheck = auto_map.get("locationfacecheck"); + String task_wififacecheck = auto_map.get("wififacecheck"); + String task_belongdate = auto_map.get("belongdate"); + + task_starttime = task_starttime +":00"; + task_endtime = task_endtime +":00"; + LocalTime local_task_starttime = LocalTime.parse(task_starttime,fullTimeFormatter); + LocalTime local_task_endtime = LocalTime.parse(task_endtime,fullTimeFormatter); + if(!local_task_starttime.isAfter(now_time) && !local_task_endtime.isBefore(now_time)){ + isInRange = true; + beginSignScope = Util.null2String(task_beginSignScope); + endSignScope = Util.null2String(task_endSignScope); + hasSetSignScope = "1".equalsIgnoreCase(Util.null2String(task_hasSetSignScope)); + card_type = Util.null2String(task_card_type); + locationcheck = Util.null2String(task_locationcheck); + wificheck = Util.null2String(task_wificheck); + locationfacecheck = Util.null2String(task_locationfacecheck); + wififacecheck = Util.null2String(task_wififacecheck); + belongdate = task_belongdate; + + if(beginSignScope.length() > 0 && endSignScope.length() > 0){ + can_punch_card = can_punch_card(userid,beginSignScope,endSignScope,card_type,hasSetSignScope); + } + break; + } + } + } + } + rangeInfoMap.put("isInRange", isInRange); + rangeInfoMap.put("can_punch_card", can_punch_card); + rangeInfoMap.put("beginSignScope", beginSignScope); + rangeInfoMap.put("endSignScope", endSignScope); + rangeInfoMap.put("card_type", card_type); + rangeInfoMap.put("hasSetSignScope", hasSetSignScope); + rangeInfoMap.put("locationcheck",locationcheck); + rangeInfoMap.put("wificheck",wificheck); + rangeInfoMap.put("locationfacecheck",locationfacecheck); + rangeInfoMap.put("wififacecheck",wififacecheck); + rangeInfoMap.put("belongdate",belongdate); + } + + /** + * 从缓存里获取数据 + * @param userid + * @param today + * @param rangeInfoMap + */ + public void getRangeInfoFromCominfo(String userid, String today, + Map rangeInfoMap) throws Exception{ + boolean isInRange = false; + boolean can_punch_card = true; + //允许打卡的时间范围 用于判断是否已经打过卡,如果打过卡就不需要打了 + String beginSignScope = ""; + String endSignScope = ""; + //打卡类型,签到还是签退卡 on是签到卡,off是签退卡 + String card_type = ""; + //是否班次设置了打卡归属,设置了的话,签到和签退是独立的,只要查询到有一条数据就表示打卡过了,如果没设置的话,签退是需要有签到才可以签退的 + boolean hasSetSignScope = false; + + KQAutoTimeRangeComInfo kqAutoTimeRangeComInfo = new KQAutoTimeRangeComInfo(); + String user_kq_date = userid+"_"+today; + String kq_param = Util.null2s(kqAutoTimeRangeComInfo.getKq_param(user_kq_date),""); + autoLog("auto_punch_card kq_param :"+kq_param); + LocalTime now_time = LocalTime.now(); + if(kq_param.length() > 0){ + JSONArray jsonArray = JSON.parseArray(kq_param); + if(jsonArray != null && !jsonArray.isEmpty()){ + for(int i = 0 ; i < jsonArray.size() ; i++){ + JSONObject otherparam = (JSONObject) jsonArray.get(i); + String task_starttime = Util.null2String(otherparam.get("task_starttime")); + String task_endtime = Util.null2String(otherparam.get("task_endtime")); + task_starttime = task_starttime +":00"; + task_endtime = task_endtime +":00"; + LocalTime local_task_starttime = LocalTime.parse(task_starttime,fullTimeFormatter); + LocalTime local_task_endtime = LocalTime.parse(task_endtime,fullTimeFormatter); + if(!local_task_starttime.isAfter(now_time) && !local_task_endtime.isBefore(now_time)){ + isInRange = true; + beginSignScope = Util.null2String(otherparam.get("beginSignScope")); + endSignScope = Util.null2String(otherparam.get("endSignScope")); + hasSetSignScope = "1".equalsIgnoreCase(Util.null2String(otherparam.get("hasSetSignScope"))); + card_type = Util.null2String(otherparam.get("card_type")); + + if(beginSignScope.length() > 0 && endSignScope.length() > 0){ + can_punch_card = can_punch_card(userid,beginSignScope,endSignScope,card_type,hasSetSignScope); + } + break; + } + + } + } + } + rangeInfoMap.put("isInRange", isInRange); + rangeInfoMap.put("can_punch_card", can_punch_card); + rangeInfoMap.put("beginSignScope", beginSignScope); + rangeInfoMap.put("endSignScope", endSignScope); + rangeInfoMap.put("card_type", card_type); + rangeInfoMap.put("hasSetSignScope", hasSetSignScope); + } + + public void appNotification(String resourceId, String curdatetime, int language) { + try { + String detailTitle = "528466"; + String title = SystemEnv.getHtmlLabelName(519318, language)+"("+curdatetime+")"; + String content = ""; + int createrId = 1; + String pcUrl = ""; + String mobileUrl = "/spa/hrm/static4mobile/index.html#/sign"; + ConfigManager configManager = new ConfigManager(); + // 2、默认规则检查用户配置,返回后台自定义消息类型和对应通过配置的用户 + // @param singPath 与需求变更之前的path参数含义一致,代表该消息类型详细配置中唯一标志值,各模块参考自己的值(有疑问请联系云商店-田泽法) + // @param userid 按默认规则检查的用户配置信息(检查多人参考重载方法) + Map> accessConfig = configManager.defaultRuleCheckConfig( + MessageType.HRM_AUTOCARD_REMIND, resourceId, null); + + // 3、遍历自定义消息类型集合 + for (Map.Entry> entry : accessConfig.entrySet()) { + // 4、构造消息实体 + MessageBean bean = Util_Message + .createMessage(MessageType.HRM_AUTOCARD_REMIND, 0, title, detailTitle, content, pcUrl, mobileUrl, createrId); + + // 5、获取新的自定义消息类型 + WeaMessageTypeConfig config = entry.getKey(); + + // 6、新的自定义消息类型相关信息通知到消息实体bean上 + bean.setMessageConfig(config); + + // 7、设置检查配置通过需要发送消息的用户 + bean.setUserList(Sets.newHashSet(entry.getValue())); + + // 8、发送消息 + autoLog("appNotification:bean:"+ JSON.toJSONString(bean)); + Util_Message.sendAndpublishMessage(bean); + } + } catch (Exception e) { + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + } + } + + /** + * 判断指定人员是否已经打卡了 + * @param userid + * @param beginSignScope + * @param endSignScope + * @param card_type + * @param hasSetSignScope + * @return + * false 表示已经打卡了。不能再继续搞了 + */ + public boolean can_punch_card(String userid, String beginSignScope, String endSignScope, + String card_type,boolean hasSetSignScope) throws Exception{ + boolean can_punch_card = true; + + String buildSql = KQSignUtil.buildSignSql(beginSignScope, endSignScope); + autoLog("can_punch_card:buildSql:"+buildSql); + KQScheduleSignBiz kqScheduleSignBiz = new KQScheduleSignBiz.KQScheduleSignParamBuilder().resourceidParam(userid). + signDateTimeSqlParam(buildSql).build(); + Map signMap = kqScheduleSignBiz.getScheduleSignInfo(); + autoLog("can_punch_card:signMap:"+signMap); + if(signMap != null && !signMap.isEmpty()){ + if("on".equalsIgnoreCase(card_type)){ + if(signMap.size() >= 1){ + //说明有签到了。不需要再签到了 + can_punch_card = false; + } + } + if("off".equalsIgnoreCase(card_type)){ + if(hasSetSignScope){ + //如果设置了打卡归属 有一条打卡都算签退卡 + if(signMap.size() >= 1){ + //说明有签退了。不需要再签退了 + can_punch_card = false; + } + }else{ + if(signMap.size() > 1){ + //超过一条打卡 说明有签退了。不需要再签退了 + can_punch_card = false; + } + } + } + } + autoLog("can_punch_card:can_punch_card:"+can_punch_card); + return can_punch_card; + } + + /** + * 根据后台的考勤组获取到需要处理的自动打卡的考勤组信息 + * @param resourceid + * @param date + * @param auto_list + */ + public void initAutoInfo(String resourceid, String date,List> auto_list) throws Exception{ + autoLog("initAutoInfo:resourceid:"+resourceid+":date:"+date); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceid, date); + if(workTime == null){ + autoLog("initAutoInfo:workTime is null"); + return ; + } + if (workTime.getNonWorkShift() == 1) { + autoLog("initAutoInfo:workTime.getNonWorkShift() == 1"); + return ; + } + List lsSignTime = new ArrayList<>(); + List lsWorkTime = new ArrayList<>(); + lsSignTime = workTime.getSignTime();//允许打卡时间 + lsWorkTime = workTime.getWorkTime();//工作时间 + String groupId = workTime.getGroupId(); + String auto_checkin = kqGroupComInfo.getAuto_checkin(groupId); + String auto_checkout = kqGroupComInfo.getAuto_checkout(groupId); + autoLog("initAutoInfo:groupId:"+groupId+":auto_checkin:"+auto_checkin+":auto_checkout:"+auto_checkout); + if(!"1".equalsIgnoreCase(auto_checkin) && !"1".equalsIgnoreCase(auto_checkout)){ + //如果上班自动打卡没开启,下班自动打卡也没开启,直接不要搞了 + autoLog("initAutoInfo:如果上班自动打卡没开启,下班自动打卡也没开启,直接不要搞了:"); + return ; + } + //判断下个人自动打卡是否开启了 + String self_auto_checkin = ""; + String self_auto_checkout = ""; + Map selfMap = isSelfAutoCard(resourceid); + if(!selfMap.isEmpty()){ + self_auto_checkin = Util.null2String(selfMap.get("auto_checkin")); + self_auto_checkout = Util.null2String(selfMap.get("auto_checkout")); + if("0".equalsIgnoreCase(self_auto_checkin) && "0".equalsIgnoreCase(self_auto_checkout)){ + autoLog("initAutoInfo:isSelfAutoCard:用户自定义自动打卡给关闭了"); + return ; + } + autoLog("initAutoInfo:isSelfAutoCard:self_auto_checkin:"+self_auto_checkin+":self_auto_checkout:"+self_auto_checkout); + } + + String auto_checkin_before = Util.null2String(kqGroupComInfo.getAuto_checkin_before(groupId)); + String auto_checkin_after = Util.null2String(kqGroupComInfo.getAuto_checkin_after(groupId)); + String locationcheck = Util.null2String(kqGroupComInfo.getLocationcheck(groupId)); + String wificheck = Util.null2String(kqGroupComInfo.getWificheck(groupId)); + String locationfacecheck = Util.null2String(kqGroupComInfo.getLocationfacecheck(groupId)); + String wififacecheck = Util.null2String(kqGroupComInfo.getWififacecheck(groupId)); + if(!"1".equalsIgnoreCase(locationcheck) && !"1".equalsIgnoreCase(wificheck)){ + //如果wifi和地理位置检测都没有开启 + autoLog("initAutoInfo:locationcheck:wificheck都没开启"); + return ; + } + if("1".equalsIgnoreCase(locationcheck)){ + if("1".equalsIgnoreCase(locationfacecheck)){ + //wifi和地理位置的人脸识别任何一个开启了。那自动打卡就没效果了 + autoLog("initAutoInfo:wifi和地理位置的人脸识别考勤也都开启了。那就没效果了自动打卡"); + return; + }else{ + if("1".equalsIgnoreCase(wificheck)){ + if("1".equalsIgnoreCase(wififacecheck)){ + //wifi和地理位置的人脸识别任何一个开启了。那自动打卡就没效果了 + autoLog("initAutoInfo:wifi的人脸识别考勤开启了。那就没效果了自动打卡"); + return ; + } + } + } + }else{ + if("1".equalsIgnoreCase(wificheck)){ + //如果只开启了wifi考勤 + if("1".equalsIgnoreCase(wififacecheck)){ + autoLog("initAutoInfo:wifi的人脸识别考勤开启了。那就没效果了自动打卡"); + return ; + } + } + } + + int auto_checkin_before_min = Util.getIntValue(auto_checkin_before); + int auto_checkin_after_min = Util.getIntValue(auto_checkin_after); + + String auto_checkout_before = Util.null2String(kqGroupComInfo.getAuto_checkout_before(groupId)); + String auto_checkout_after = Util.null2String(kqGroupComInfo.getAuto_checkout_after(groupId)); + int auto_checkout_before_min = Util.getIntValue(auto_checkout_before); + int auto_checkout_after_min = Util.getIntValue(auto_checkout_after); + autoLog("initAutoInfo:auto_checkin_before:"+auto_checkin_before+":auto_checkin_after:"+auto_checkin_after+ + ":auto_checkout_before:"+auto_checkout_before+":auto_checkout_after:"+auto_checkout_after); + + if(lsWorkTime != null && !lsWorkTime.isEmpty()){ + for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) { + TimeScopeEntity signTimeScope = lsSignTime.get(i); + TimeScopeEntity workTimeScope = lsWorkTime.get(i); + + if("1".equalsIgnoreCase(auto_checkin)){ + if("0".equalsIgnoreCase(self_auto_checkin)){ + //个人没开启的话,就不处理 + autoLog("initAutoInfo:个人没开启的话:上班打卡:"+self_auto_checkin); + }else{ + if(auto_checkin_before_min > 0 && auto_checkin_after_min >= 0){ + do_auto_checkin(auto_checkin_before_min,auto_checkin_after_min,auto_list,workTimeScope,signTimeScope,date,resourceid); + } + } + } + + if("1".equalsIgnoreCase(auto_checkout)){ + if("0".equalsIgnoreCase(self_auto_checkout)){ + //个人没开启的话,就不处理 + autoLog("initAutoInfo:个人没开启的话:下班打卡:"+self_auto_checkout); + }else{ + if(auto_checkout_before_min >= 0 && auto_checkout_after_min >= 0){ + do_auto_checkout(auto_checkout_before_min,auto_checkout_after_min,auto_list,workTimeScope,signTimeScope,date,resourceid); + } + } + } + } + } + + if(!auto_list.isEmpty()){ + for(Map auto_map : auto_list){ + auto_map.put("locationcheck",locationcheck); + auto_map.put("wificheck",wificheck); + auto_map.put("locationfacecheck",locationfacecheck); + auto_map.put("wififacecheck",wififacecheck); + } + } + autoLog("initAutoInfo:auto_list:"+auto_list); + } + + /** + * 判断个人自动打卡是否开启了 + * @param resourceid + */ + public Map isSelfAutoCard(String resourceid) { + Map selfMap = Maps.newHashMap(); + RecordSet rs = new RecordSet(); + String auto_checkin = ""; + String auto_checkout = ""; + String sql = " select * from kq_autocheck_set where resourceid=? "; + rs.executeQuery(sql, resourceid); + if (rs.next()){ + auto_checkin = rs.getString("auto_checkin"); + auto_checkout = rs.getString("auto_checkout"); + selfMap.put("auto_checkin", auto_checkin); + selfMap.put("auto_checkout", auto_checkout); + } + return selfMap; + } + + public void do_auto_checkout(int auto_checkout_before_min, int auto_checkout_after_min, + List> auto_list, TimeScopeEntity workTimeScope, + TimeScopeEntity signTimeScope, String date, String resourceid) throws Exception{ + Map auto_map = Maps.newHashMap(); + //昨日的跨天的上报数据 + Map pre_auto_map = Maps.newHashMap(); + //明日的跨天的上报数据 + Map next_auto_map = Maps.newHashMap(); + LocalDate localDate = LocalDate.parse(date,dateFormatter); + LocalDate next_localDate = localDate.plusDays(1); + LocalDate pre_localDate = localDate.minusDays(1); + + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + + String signBeginTime = signTimeScope.getBeginTime(); + LocalTime localTime = LocalTime.parse(signBeginTime, timeFormatter); + String signEndTime = signTimeScope.getEndTime(); + String beginSignScope = ""; + String endSignScope = localDate.format(dateFormatter)+" "+signEndTime; + int signEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(signEndTime); + boolean signEndTimeAcross = signTimeScope.getEndTimeAcross(); + if(signEndTimeAcross){ + endSignScope = next_localDate.format(dateFormatter)+" "+signEndTime; + signEndIdx = kqTimesArrayComInfo.turn24to48TimeIndex(signEndIdx); + } + int signBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(signBeginTime); + //上班允许打卡是否跨天,跨到第二天 + boolean signBenginTimeAcross = signTimeScope.getBeginTimeAcross(); + //上班允许打卡是否跨到前一天 + boolean beginTimePreAcross = signTimeScope.isBeginTimePreAcross(); + + TimeSignScopeEntity timeSignScopeEntity = signTimeScope.getTimeSignScopeEntity(); + boolean hasSetSignScope = false; + String endTimeStart = ""; + boolean endTimeStartAcross = false; + + if(timeSignScopeEntity == null){ + //没有设置 签到最晚时间和签退最早时间 + beginSignScope = localDate.format(dateFormatter)+" "+localTime.plusMinutes(1).format(timeFormatter); + if(signBenginTimeAcross){ + beginSignScope = next_localDate.format(dateFormatter)+" "+signBeginTime; + signBeginIdx = kqTimesArrayComInfo.turn24to48TimeIndex(signBeginIdx); + } + if(beginTimePreAcross){ + beginSignScope = pre_localDate.format(dateFormatter)+" "+signBeginTime; + } + }else{ + hasSetSignScope = true; + endTimeStart = timeSignScopeEntity.getEndTimeStart(); + endTimeStartAcross = timeSignScopeEntity.isBeginTimeEndAcross(); + beginSignScope = localDate.format(dateFormatter)+" "+endTimeStart; + if(endTimeStartAcross){ + beginSignScope = next_localDate.format(dateFormatter)+" "+endTimeStart; + endTimeStart = kqTimesArrayComInfo.turn24to48Time(endTimeStart); + } + } + + String workEndTime = Util.null2String(workTimeScope.getEndTime()); + int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + boolean workEndTimeAcross = workTimeScope.getEndTimeAcross(); + + autoLog("do_auto_checkout:workEndTimeAcross:"+workEndTimeAcross+":workEndTime:"+workEndTime+ + ":signEndTime:"+signEndTime+":signEndTimeAcross:"+signEndTimeAcross); + //处理下班自动打卡 + if(workEndTimeAcross){ + //下班时间跨天的话,意味着今天没有需要自动打卡的 + //如果下班时间跨天,因为下班打卡都是往后推的,所以只有一种可能,跨天 + int before_workEndIdx = workEndIdx + auto_checkout_before_min; + //自动打卡时间还是要和允许打卡时间进行比较下 + if(signEndIdx < before_workEndIdx){ + before_workEndIdx = signEndIdx; + } + next_auto_map.put(next_localDate.format(dateFormatter)+"_task_starttime", kqTimesArrayComInfo.getTimesByArrayindex(kqTimesArrayComInfo.turn48to24TimeIndex(before_workEndIdx))); + + //下面开始处理下班后自动打卡 + int after_workEndIdx = workEndIdx + auto_checkout_after_min; + //自动打卡时间还是要和允许打卡时间进行比较下 + if(signEndIdx < after_workEndIdx){ + after_workEndIdx = signEndIdx; + } + next_auto_map.put(next_localDate.format(dateFormatter)+"_task_endtime", kqTimesArrayComInfo.getTimesByArrayindex(kqTimesArrayComInfo.turn48to24TimeIndex(after_workEndIdx))); + + next_auto_map.put("endSignScope", endSignScope); + next_auto_map.put("beginSignScope", beginSignScope); + next_auto_map.put("hasSetSignScope", hasSetSignScope?"1":"0"); + next_auto_map.put("card_type", "off"); + next_auto_map.put("belongdate", date); + auto_list.add(next_auto_map); + }else{ + //如果下班时间不跨天,因为下班打卡都是往后推的,所以只有两种可能,或者跨天或者不跨天 + int before_workEndIdx = workEndIdx + auto_checkout_before_min; + if(before_workEndIdx >= 1440){ + before_workEndIdx = before_workEndIdx - 1440; + } + //自动打卡时间还是要和允许打卡时间进行比较下 + if(signEndIdx < before_workEndIdx){ + before_workEndIdx = signEndIdx; + } + //如果自动打卡时间比下班时间还小,说明自动打卡跨天了 + if(before_workEndIdx < workEndIdx){ + next_auto_map.put(next_localDate.format(dateFormatter)+"_task_starttime", kqTimesArrayComInfo.getTimesByArrayindex(before_workEndIdx)); + }else{ + auto_map.put(localDate.format(dateFormatter)+"_task_starttime", kqTimesArrayComInfo.getTimesByArrayindex(before_workEndIdx)); + } + + //下面开始处理下班后自动打卡 + int after_workEndIdx = workEndIdx + auto_checkout_after_min; + if(after_workEndIdx >= 1440){ + after_workEndIdx = after_workEndIdx - 1440; + } + //自动打卡时间还是要和允许打卡时间进行比较下 + if(signEndIdx < after_workEndIdx){ + after_workEndIdx = signEndIdx; + } + if(after_workEndIdx < workEndIdx){ + next_auto_map.put(next_localDate.format(dateFormatter)+"_task_endtime", kqTimesArrayComInfo.getTimesByArrayindex(after_workEndIdx)); + if(!next_auto_map.containsKey(next_localDate.format(dateFormatter)+"_task_starttime")){ + next_auto_map.put(next_localDate.format(dateFormatter)+"_task_starttime", kqTimesArrayComInfo.getTimesByArrayindex(0)); + } + if(auto_map.containsKey(localDate.format(dateFormatter)+"_task_starttime")){ + auto_map.put(localDate.format(dateFormatter)+"_task_endtime", kqTimesArrayComInfo.getTimesByArrayindex(1439)); + } + }else{ + auto_map.put(localDate.format(dateFormatter)+"_task_endtime", kqTimesArrayComInfo.getTimesByArrayindex(after_workEndIdx)); + } + boolean can_punch_card = can_punch_card(resourceid,beginSignScope,endSignScope,"off",hasSetSignScope); + if(!can_punch_card){ + autoLog("do_auto_checkout:beginSignScope:"+beginSignScope+":endSignScope:"+endSignScope+ + ":hasSetSignScope:"+hasSetSignScope+":can_punch_card:"+can_punch_card); + return ; + } + auto_map.put("endSignScope", endSignScope); + auto_map.put("beginSignScope", beginSignScope); + auto_map.put("hasSetSignScope", hasSetSignScope?"1":"0"); + auto_map.put("card_type", "off"); + auto_map.put("belongdate", date); + auto_list.add(auto_map); + if(!next_auto_map.isEmpty()){ + next_auto_map.put("endSignScope", endSignScope); + next_auto_map.put("beginSignScope", beginSignScope); + next_auto_map.put("hasSetSignScope", hasSetSignScope?"1":"0"); + next_auto_map.put("card_type", "off"); + next_auto_map.put("belongdate", date); + auto_list.add(next_auto_map); + } + } + } + + /** + * 获取需要打上班卡的时间 + * @param auto_checkin_before_min + * @param auto_checkin_after_min + * @param auto_list + * @param workTimeScope + * @param signTimeScope + * @param date + * @param resourceid + */ + public void do_auto_checkin(int auto_checkin_before_min, int auto_checkin_after_min, + List> auto_list, TimeScopeEntity workTimeScope, + TimeScopeEntity signTimeScope, String date, String resourceid) throws Exception{ + + Map auto_map = Maps.newHashMap(); + //昨日的跨天的上报数据 + Map pre_auto_map = Maps.newHashMap(); + //明日的跨天的上报数据 + Map next_auto_map = Maps.newHashMap(); + + LocalDate localDate = LocalDate.parse(date,dateFormatter); + LocalDate next_localDate = localDate.plusDays(1); + LocalDate pre_localDate = localDate.minusDays(1); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + String signBeginTime = signTimeScope.getBeginTime(); + String signEndTime = signTimeScope.getEndTime(); + + String beginSignScope = localDate.format(dateFormatter)+" "+signBeginTime; + String endSignScope = localDate.format(dateFormatter)+" "+signEndTime; + int signBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(signBeginTime); + //上班允许打卡是否跨天,跨到第二天 + boolean signBenginTimeAcross = signTimeScope.getBeginTimeAcross(); + //上班允许打卡是否跨到前一天 + boolean beginTimePreAcross = signTimeScope.isBeginTimePreAcross(); + if(signBenginTimeAcross){ + beginSignScope = next_localDate.format(dateFormatter)+" "+signBeginTime; + signBeginIdx = kqTimesArrayComInfo.turn24to48TimeIndex(signBeginIdx); + } + if(beginTimePreAcross){ + beginSignScope = pre_localDate.format(dateFormatter)+" "+signBeginTime; + } + int signEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(signEndTime); + boolean signEndTimeAcross = signTimeScope.getEndTimeAcross(); + if(signEndTimeAcross){ + endSignScope = next_localDate.format(dateFormatter)+" "+signEndTime; + signEndIdx = kqTimesArrayComInfo.turn24to48TimeIndex(signEndIdx); + } + TimeSignScopeEntity timeSignScopeEntity = signTimeScope.getTimeSignScopeEntity(); + boolean hasSetSignScope = false; + String beginTimeEnd = ""; + boolean beginTimeEndAcross = false; + + if(timeSignScopeEntity == null){ + //没有设置 签到最晚时间和签退最早时间 + }else{ + hasSetSignScope = true; + beginTimeEnd = timeSignScopeEntity.getBeginTimeEnd(); + beginTimeEndAcross = timeSignScopeEntity.isBeginTimeEndAcross(); + endSignScope = localDate.format(dateFormatter)+" "+beginTimeEnd; + if(beginTimeEndAcross){ + endSignScope = next_localDate.format(dateFormatter)+" "+beginTimeEnd; + beginTimeEnd = kqTimesArrayComInfo.turn24to48Time(beginTimeEnd); + } + } + + String workBeginTime = Util.null2String(workTimeScope.getBeginTime()); + int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime); + boolean workBenginTimeAcross = workTimeScope.getBeginTimeAcross(); + + autoLog("do_auto_checkin:workBenginTimeAcross:"+workBenginTimeAcross+":workBeginTime:"+workBeginTime+ + ":signBeginTime:"+signBeginTime+":signBenginTimeAcross:"+signBenginTimeAcross+":beginTimePreAcross:"+beginTimePreAcross); + //先处理上班的 + if(workBenginTimeAcross){ + + //如果上班时间跨天,那只有一种可能,就是一天多次打卡,然后上班时间跨到第二天去了 + int before_workBeginIdx = workBeginIdx - auto_checkin_before_min; + if(before_workBeginIdx < 0){ + before_workBeginIdx = 1440-(auto_checkin_before_min-(workBeginIdx-0)); + } + //自动打卡时间还是要和允许打卡时间进行比较下 + if(signBeginIdx > before_workBeginIdx){ + before_workBeginIdx = signBeginIdx; + } + //上班时间和自动上班前打卡时间混合完之后,如果自动打卡的时间还是比上班时间小,表示这俩时间还是在同一天,都是跨天的,否则就是不跨天了的 + if(before_workBeginIdx <= workBeginIdx){ + next_auto_map.put(next_localDate.format(dateFormatter)+"_task_starttime", kqTimesArrayComInfo.getTimesByArrayindex(before_workBeginIdx)); + }else{ + auto_map.put(localDate.format(dateFormatter)+"_task_starttime", kqTimesArrayComInfo.getTimesByArrayindex(before_workBeginIdx)); + auto_map.put(localDate.format(dateFormatter)+"_task_endtime", kqTimesArrayComInfo.getTimesByArrayindex(1439)); + } + //下面开始处理上班后自动打卡 + int after_workBeginIdx = workBeginIdx + auto_checkin_after_min; + if(hasSetSignScope){ + if(beginTimeEnd.length() > 0){ + int beginTimeEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(beginTimeEnd); + if(after_workBeginIdx > beginTimeEndIdx){ + after_workBeginIdx = beginTimeEndIdx; + } + } + } + //自动打卡时间还是要和允许打卡时间进行比较下 + if(signEndIdx < after_workBeginIdx){ + after_workBeginIdx = signEndIdx; + } + next_auto_map.put(next_localDate.format(dateFormatter)+"_task_endtime", kqTimesArrayComInfo.getTimesByArrayindex(after_workBeginIdx)); + if(!next_auto_map.containsKey(next_localDate.format(dateFormatter)+"_task_starttime")){ + next_auto_map.put(next_localDate.format(dateFormatter)+"_task_starttime", kqTimesArrayComInfo.getTimesByArrayindex(0)); + } + + auto_map.put("endSignScope", endSignScope); + auto_map.put("beginSignScope", beginSignScope); + auto_map.put("hasSetSignScope", hasSetSignScope?"1":"0"); + auto_map.put("card_type", "on"); + auto_map.put("belongdate", date); + auto_list.add(auto_map); + + if(!next_auto_map.isEmpty()){ + next_auto_map.put("endSignScope", endSignScope); + next_auto_map.put("beginSignScope", beginSignScope); + next_auto_map.put("hasSetSignScope", hasSetSignScope?"1":"0"); + next_auto_map.put("card_type", "on"); + next_auto_map.put("belongdate", date); + auto_list.add(next_auto_map); + } + }else{ + //如果上班时间不跨天,需要考虑上班时间向前或者向后推算的自动打卡时间可能是跨天的 + int before_workBeginIdx = workBeginIdx - auto_checkin_before_min; + if(before_workBeginIdx < 0){ + before_workBeginIdx = 1440-(auto_checkin_before_min-(workBeginIdx-0)); + } + //自动打卡时间还是要和允许打卡时间进行比较下 + if(signBeginIdx > before_workBeginIdx){ + before_workBeginIdx = signBeginIdx; + } + //上班时间和自动上班前打卡时间混合完之后,如果自动打卡的时间还是比上班时间小,表示这俩时间还是在同一天,否则就是自动打卡的再前一天了 + if(before_workBeginIdx <= workBeginIdx){ + auto_map.put(localDate.format(dateFormatter)+"_task_starttime", kqTimesArrayComInfo.getTimesByArrayindex(before_workBeginIdx)); + }else{ + pre_auto_map.put(pre_localDate.format(dateFormatter)+"_task_starttime", kqTimesArrayComInfo.getTimesByArrayindex(before_workBeginIdx)); + pre_auto_map.put(pre_localDate.format(dateFormatter)+"_task_endtime", kqTimesArrayComInfo.getTimesByArrayindex(1439)); + auto_map.put(localDate.format(dateFormatter)+"_task_starttime", kqTimesArrayComInfo.getTimesByArrayindex(0)); + } + int after_workBeginIdx = workBeginIdx + auto_checkin_after_min; + if(hasSetSignScope){ + if(beginTimeEnd.length() > 0){ + int beginTimeEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(beginTimeEnd); + if(after_workBeginIdx > beginTimeEndIdx){ + after_workBeginIdx = beginTimeEndIdx; + } + } + } + //自动打卡时间还是要和允许打卡时间进行比较下 + if(signEndIdx < after_workBeginIdx){ + after_workBeginIdx = signEndIdx; + } + + if(after_workBeginIdx < workBeginIdx){ + //这表示自动打卡的时间跨天了 + next_auto_map.put(next_localDate.format(dateFormatter)+"_task_starttime", kqTimesArrayComInfo.getTimesByArrayindex(0)); + next_auto_map.put(next_localDate.format(dateFormatter)+"_task_endtime", kqTimesArrayComInfo.getTimesByArrayindex(after_workBeginIdx)); + + auto_map.put(localDate.format(dateFormatter)+"_task_endtime", kqTimesArrayComInfo.getTimesByArrayindex(1439)); + }else{ + auto_map.put(localDate.format(dateFormatter)+"_task_endtime", kqTimesArrayComInfo.getTimesByArrayindex(after_workBeginIdx)); + } + boolean can_punch_card = can_punch_card(resourceid,beginSignScope,endSignScope,"on",hasSetSignScope); + if(!can_punch_card){ + return ; + } + auto_map.put("endSignScope", endSignScope); + auto_map.put("beginSignScope", beginSignScope); + auto_map.put("hasSetSignScope", hasSetSignScope?"1":"0"); + auto_map.put("card_type", "on"); + auto_map.put("belongdate", date); + auto_list.add(auto_map); + + if(!next_auto_map.isEmpty()){ + next_auto_map.put("endSignScope", endSignScope); + next_auto_map.put("beginSignScope", beginSignScope); + next_auto_map.put("hasSetSignScope", hasSetSignScope?"1":"0"); + next_auto_map.put("card_type", "on"); + next_auto_map.put("belongdate", date); + auto_list.add(next_auto_map); + } + + if(!pre_auto_map.isEmpty()){ + pre_auto_map.put("endSignScope", endSignScope); + pre_auto_map.put("beginSignScope", beginSignScope); + pre_auto_map.put("hasSetSignScope", hasSetSignScope?"1":"0"); + pre_auto_map.put("card_type", "on"); + pre_auto_map.put("belongdate", date); + auto_list.add(pre_auto_map); + } + + } + } + +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQAutoCheckComInfo.java b/src/com/engine/kq/biz/KQAutoCheckComInfo.java new file mode 100644 index 0000000..633de0e --- /dev/null +++ b/src/com/engine/kq/biz/KQAutoCheckComInfo.java @@ -0,0 +1,55 @@ +package com.engine.kq.biz; + +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; + +/** + * EM端设置过自定义的自动打卡对应的缓存类 + */ +public class KQAutoCheckComInfo extends CacheBase{ + protected static String TABLE_NAME = "kq_autocheck_set"; + /** sql中的where信息,不要以where开始 */ + protected static String TABLE_WHERE = null; + /** sql中的order by信息,不要以order by开始 */ + protected static String TABLE_ORDER = "resourceid"; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "resourceid"; + + @CacheColumn(name = "auto_checkin") + protected static int auto_checkin; + + @CacheColumn(name = "auto_checkout") + protected static int auto_checkout; + + @CacheColumn(name = "groupid") + protected static int groupid; + + public String getId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getAuto_checkin() { + return (String)getRowValue(auto_checkin); + } + public String getAuto_checkin(String key) { + return (String)getValue(auto_checkin,key); + } + + public String getAuto_checkout() { + return (String)getRowValue(auto_checkout); + } + public String getAuto_checkout(String key) { + return (String)getValue(auto_checkout,key); + } + + public String getGroupid() { + return (String)getRowValue(groupid); + } + public String getGroupid(String key) { + return (String)getValue(groupid,key); + } + +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQAutoTimeRangeComInfo.java b/src/com/engine/kq/biz/KQAutoTimeRangeComInfo.java new file mode 100644 index 0000000..8332976 --- /dev/null +++ b/src/com/engine/kq/biz/KQAutoTimeRangeComInfo.java @@ -0,0 +1,36 @@ +package com.engine.kq.biz; + +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; + +/** + * 自动打卡 + * 打卡范围缓存类 + */ +public class KQAutoTimeRangeComInfo extends CacheBase{ + protected static String TABLE_NAME = "kq_auto_timerange"; + /** sql中的where信息,不要以where开始 */ + protected static String TABLE_WHERE = null; + /** sql中的order by信息,不要以order by开始 */ + protected static String TABLE_ORDER = "id"; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "user_kq_date"; + + @CacheColumn(name = "kq_param") + protected static int kq_param; + + public String getId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getKq_param() { return (String)getRowValue(kq_param); } + + public String getKq_param(String key) + { + return (String)getValue(kq_param,key); + } + +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQBalanceOfLeaveBiz.java b/src/com/engine/kq/biz/KQBalanceOfLeaveBiz.java new file mode 100644 index 0000000..6b00afd --- /dev/null +++ b/src/com/engine/kq/biz/KQBalanceOfLeaveBiz.java @@ -0,0 +1,5191 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.bean.KQChildrenBean; +import com.engine.kq.entity.KQBalanceOfLeaveEntity; +import com.engine.kq.entity.KQLeaveInfoEntity; +import com.engine.kq.entity.KQOvertimeRulesDetailEntity; +import com.engine.kq.entity.KQUsageHistoryEntity; +import com.engine.kq.jucailin.util.KQDateUtil; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.OvertimeBalanceTimeBean; +import com.google.common.collect.Maps; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.SimpleDateFormat; +import java.time.*; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 假期余额相关接口 + */ +public class KQBalanceOfLeaveBiz { + + private static KQLog logger = new KQLog();//用于记录日志信息 + + public static String getBalanceOfLeave(String resourceId, String ruleId, String date) { + return getBalanceOfLeave(resourceId, ruleId, date, true); + } + + public static String getBalanceOfLeave(String resourceId, String ruleId, String date, boolean isAll) { + return getBalanceOfLeave(resourceId, ruleId, date, false, isAll); + } + + public static String getBalanceOfLeave(String resourceId, String ruleId, String searchDate, boolean calcByCurrentDate, boolean isAll) { + return getRestAmount(resourceId, ruleId, searchDate, calcByCurrentDate, isAll); + } + + /** + * 获取指定人员的指定假期的有效的假期余额 + * + * @param resourceId 指定的人员ID + * @param ruleId 指定的假期类型的ID(表kq_leaveRules的主键ID) + * @param date 请假日期(根据此日期计算释放规则以及判断员工假期余额是否失效) + * @return 如果传入的指定假期类型没有开启假期余额,则返回0.00 + */ + public static String getRestAmount(String resourceId, String ruleId, String date) { + return getRestAmount(resourceId, ruleId, date, true); + } + + /** + * 获取指定人员的指定假期的有效的假期余额 + * + * @param resourceId 指定的人员ID + * @param ruleId 指定的假期类型的ID(表kq_leaveRules的主键ID) + * @param date 请假日期(根据此日期计算释放规则以及判断员工假期余额是否失效) + * @param isAll true--查询所有年份加起来的总有效余额、false--仅仅查询指定请假日期那一年的有效余额 + * @return 如果传入的指定假期没有开启假期余额,则返回0.00 + */ + public static String getRestAmount(String resourceId, String ruleId, String date, boolean isAll) { + return getRestAmount(resourceId, ruleId, date, false, isAll); + } + + /** + * 获取指定人员的指定假期的有效的假期余额 + * + * @param resourceId 指定的人员ID + * @param ruleId 指定的假期类型的ID(表kq_leaveRules的主键ID) + * @param searchDate 请假日期(不可为空) + * @param calcByCurrentDate true--根据当前日期计算释放规则以及判断员工假期余额是否失效、false--根据请假日期来计算释放规则以及判断员工假期余额是否失效 + * @param isAll true--查询所有年份加起来的总有效余额、false--仅仅查询指定请假日期那一年的有效余额 + * @return 如果传入的指定假期没有开启假期余额,则返回0.00 + */ + public static String getRestAmount(String resourceId, String ruleId, String searchDate, boolean calcByCurrentDate, boolean isAll) { + //员工的假期余额 + String balanceOfLeave = "0"; + Map params = new HashMap<>(); + params.put("resourceId",resourceId); + params.put("ruleId",ruleId); + params.put("searchDate",searchDate); + params.put("calcByCurrentDate",calcByCurrentDate); + params.put("isAll",isAll); + try { + BigDecimal restAmount = new BigDecimal("0"); + //获取当前日期 + Calendar today = Calendar.getInstance(); + //当前日期 + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + //所属年份 + String searchYear = searchDate.substring(0, 4); + + /**********************************************************************************************************/ + + //假期类型缓存类 + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + //是否启用假期余额:0-未开启、1-开启 + int balanceEnable = Util.getIntValue(rulesComInfo.getBalanceEnable(ruleId), 0); + + /**********************************************************************************************************/ + + //人员缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + //分部ID + String subCompanyId = resourceComInfo.getSubCompanyID(resourceId); + //部门ID + String departmentId = resourceComInfo.getDepartmentID(resourceId); + /**********************************************************************************************************/ + + //假期规则缓存类 + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //余额发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按司龄+工龄自动发放 + int distributionMode = Util.getIntValue(detailComInfo.getDistributionMode(ruleId, subCompanyId, departmentId, resourceId), 1); + // + int decimalDigit = Util.getIntValue(detailComInfo.getDecimalDigit(ruleId, subCompanyId, departmentId, resourceId), 2); + + /**********************************************************************************************************/ + + //该假期没有启用假期余额,记录错误日志,返回假期余额0 + if (balanceEnable != 1) { + logger.info("获取员工假期余额失败,此假期类型没有开启假期余额。params=" + JSONObject.toJSONString(params)); + return "0"; + } + //传入的请假日期为空,记录错误日期,返回假期余额0 + if (searchDate.equals("")) { + logger.info("获取员工假期余额失败,传入的请假日期为空。params=" + JSONObject.toJSONString(params)); + return "0"; + } + //传入的指定日期格式不对,记录错误日期,返回假期余额0 + Pattern pattern = Pattern.compile("^\\d{4}\\-\\d{2}\\-\\d{2}$"); + Matcher matcher = pattern.matcher(searchDate); + if (!matcher.matches()) { + logger.info("获取员工假期余额失败,传入的请假日期格式不对。params=" + JSONObject.toJSONString(params)); + return "0"; + } + //根据指定日期(或者根据当前日期)判断假期是否已经过了有效期 + String date = calcByCurrentDate ? currentDate : searchDate; + + //如果是调休,获取假期余额的逻辑会不太一样 + if (distributionMode == 5) { + restAmount = getRestAmountByDis5(ruleId, resourceId, searchDate, calcByCurrentDate, isAll); + return restAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + } + if (distributionMode == 8) { + restAmount = getRestAmountByDis8(ruleId, resourceId, searchDate, calcByCurrentDate, isAll); + return restAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + } + + //计算员工假期余额总和 + RecordSet recordSet = new RecordSet(); + String sql = "select * from kq_BalanceOfLeave where resourceId=? and leaveRulesId=? and (isDelete is null or isDelete<>1) "; + //是查询所有有效的假期余额还是仅仅查询指定日期当年的 + if(KQSettingsBiz.is_balanceofleave()){//开启开关 + if (!isAll) { + sql += " and belongYear='" + searchYear + "'"; + }else{ + sql += " and belongYear<='" + searchYear + "'"; + } + }else{ + if (!isAll) { + sql += " and belongYear='" + searchYear + "'"; + } + } + recordSet.executeQuery(sql, resourceId, ruleId); + while (recordSet.next()) { + //所属年份 + String belongYear = recordSet.getString("belongYear"); + //生效日期 + String effectiveDate = recordSet.getString("effectiveDate"); + //失效日期 + String expirationDate = recordSet.getString("expirationDate"); + //是否失效 + boolean status = getBalanceStatus(ruleId, resourceId, belongYear, date, effectiveDate, expirationDate); + if (!status) { + continue; + } + + if (distributionMode == 6) { + BigDecimal baseAmount = new BigDecimal(Util.null2s(recordSet.getString("baseAmount"), "0"));//混合模式下的法定年假基数 + BigDecimal usedAmount = new BigDecimal(Util.null2s(recordSet.getString("usedAmount"), "0"));//混合模式下的已休法定年假数 + BigDecimal extraAmount = new BigDecimal(Util.null2s(recordSet.getString("extraAmount"), "0"));//混合模式下的额外法定年假数 + //根据释放规则获取已释放的天数/小时数 + baseAmount = getCanUseAmount(resourceId, ruleId, belongYear, baseAmount, "legal", date); + + BigDecimal baseAmount2 = new BigDecimal(Util.null2s(recordSet.getString("baseAmount2"), "0"));//混合模式下的福利年假基数 + BigDecimal usedAmount2 = new BigDecimal(Util.null2s(recordSet.getString("usedAmount2"), "0"));//混合模式下的已休福利年假数 + BigDecimal extraAmount2 = new BigDecimal(Util.null2s(recordSet.getString("extraAmount2"), "0"));//混合模式下的额外福利年假数 + //根据释放规则获取已释放的天数/小时数 + baseAmount2 = getCanUseAmount(resourceId, ruleId, belongYear, baseAmount2, "welfare", date); + //剩余=已释放+额外-已休 + restAmount = restAmount.add(baseAmount.add(extraAmount).subtract(usedAmount).add(baseAmount2).add(extraAmount2).subtract(usedAmount2)); + } else { + BigDecimal baseAmount = new BigDecimal(Util.null2s(recordSet.getString("baseAmount"), "0"));//假期余额基数 + BigDecimal usedAmount = new BigDecimal(Util.null2s(recordSet.getString("usedAmount"), "0"));//已休的假期时长 + BigDecimal extraAmount = new BigDecimal(Util.null2s(recordSet.getString("extraAmount"), "0"));//额外的假期时长 + //根据释放规则获取已释放的天数/小时数 + baseAmount = getCanUseAmount(resourceId, ruleId, belongYear, baseAmount, "", date); + //剩余=已释放+额外-已休 + restAmount = restAmount.add(baseAmount.add(extraAmount).subtract(usedAmount)); + } + } + balanceOfLeave = restAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + } catch (Exception e) { + logger.info(e.getMessage()); + logger.info("获取员工假期余额失败。params=" + JSONObject.toJSONString(params)); + } + return balanceOfLeave; + } + + /** + * 获取指定人员的指定假期类型的指定年份在指定日期的可用余额(假期基数*释放比例) + * + * @param resourceId 指定的人员ID + * @param ruleId 指定的假期类型ID(对应于数据库表kq_leaveRules的主键ID) + * @param belongYear 指定的所属年份(格式yyyy) + * @param baseAmount 假期基数 + * @param legalOrWelfare 是计算[法定年假]还是计算[福利年假]:legal-法定年假、welfare-福利年假 + * @param date 指定日期(获取的就是此日期的假期可用余额) + * @return + */ + public static BigDecimal getCanUseAmount(String resourceId, String ruleId, String belongYear, BigDecimal baseAmount, String legalOrWelfare, String date) { + BigDecimal canUseAmount = new BigDecimal("0"); + try { + //人员缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + //分部ID + String subCompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + //创建日期 + String createDate = resourceComInfo.getCreatedate(resourceId); + //入职日期 + String companyStartDate = resourceComInfo.getCompanyStartDate(resourceId); + //没有维护入职日期时取创建日期 + companyStartDate = companyStartDate.equals("") ? createDate : companyStartDate; + //参加工作日期 + String workStartDate = resourceComInfo.getWorkStartDate(resourceId); + //没有维护参加工作日期时取创建日期 + workStartDate = workStartDate.equals("") ? createDate : workStartDate; + + /*********************************************************************************/ + + //指定日期--用于计算已释放天数的日期 + Calendar searchDate = DateUtil.getCalendar(date); + //指定日期的年份 + String searchYear = Util.add0(searchDate.get(Calendar.YEAR), 4); + //指定日期那年一共多少天 + BigDecimal actualMaximum = new BigDecimal("" + searchDate.getActualMaximum(Calendar.DAY_OF_YEAR)); + //指定日期是那年的第几天 + BigDecimal dayOfYear = new BigDecimal("" + searchDate.get(Calendar.DAY_OF_YEAR)); + //指定日期是那年的第几月 + BigDecimal monthOfYear = new BigDecimal("" + (searchDate.get(Calendar.MONTH) + 1)); + + /*********************************************************************************/ + + //如果人员已离职--根据合同结束日期计算年假天数 + String resourcestatus = Util.null2String(resourceComInfo.getStatus(resourceId)); + if(resourcestatus.equals("5")){ + try{ + String enddate = Util.null2String(resourceComInfo.getEndDate(resourceId));//合同结束日期 + Calendar calenddate = DateUtil.getCalendar(enddate); + //指定日期是那年的第几天 + dayOfYear = new BigDecimal("" + calenddate.get(Calendar.DAY_OF_YEAR)); + //指定日期是那年的第几月 + monthOfYear = new BigDecimal("" + (calenddate.get(Calendar.MONTH) + 1)); + }catch (Exception e){ + e.printStackTrace(); + } + } + /*********************************************************************************/ + //获取此假期类型下,该人员所在分部对应的假期规则 + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //余额发放方式 + int distributionMode = Util.getIntValue(detailComInfo.getDistributionMode(ruleId, subCompanyId, departmentId, resourceId), 1); + //释放规则:0-不限制、1-按天释放、2-按月释放 + int releaseRule = Util.getIntValue(detailComInfo.getReleaseRule(ruleId, subCompanyId, departmentId, resourceId), 0); + //小数位数 + int decimalDigit = Util.getIntValue(detailComInfo.getDecimalDigit(ruleId, subCompanyId, departmentId, resourceId), 2); + + /*********************************************************************************/ + + //这几种发放方式不支持释放规则 + if (distributionMode == 5 || distributionMode == 7|| distributionMode == 8) { + return baseAmount; + } + + //指定日期小于入职日期时,释放出来的假期余额应为0(无人提出此要求,暂时不加此限制) + + /*********************************************************************************/ + + //这一年什么时候开始想有假期的 + Calendar calendar = null; + + //如果指定日期的年份大于假期余额的所属年份,则代表假期基数已经全部释放 + if (searchYear.compareTo(belongYear) > 0) { + return baseAmount; + } else if (searchYear.compareTo(belongYear) < 0) { + //如果指定日期的年份小于假期余额的所属年份,则代表假期基数还没有开始释放 + if (releaseRule != 0) { + return new BigDecimal("0"); + } + } else if (searchYear.compareTo(belongYear) == 0) { + } + if (distributionMode == 6) { + calendar = getReleaseDateByDis6(resourceId, ruleId, belongYear, legalOrWelfare); + } else { + calendar = getReleaseDate(resourceId, ruleId, belongYear); + } + + /****************************************************************************************/ + + /* 释放规则 start */ + if (releaseRule == 0) { + canUseAmount = baseAmount; + } else if (releaseRule == 1) { + BigDecimal dateIndex = new BigDecimal("" + (calendar.get(Calendar.DAY_OF_YEAR) - 1)); + canUseAmount = baseAmount.multiply(dayOfYear.subtract(dateIndex)).divide(actualMaximum.subtract(dateIndex), decimalDigit, RoundingMode.HALF_UP); + } else if (releaseRule == 2) { + BigDecimal monthIndex = new BigDecimal("" + calendar.get(Calendar.MONTH)); + canUseAmount = baseAmount.multiply(monthOfYear.subtract(monthIndex)).divide(new BigDecimal("12").subtract(monthIndex), decimalDigit, RoundingMode.HALF_UP); + } + /* 释放规则 end */ + //如果释放为负数,就修改为0 + int i=canUseAmount.compareTo(BigDecimal.ZERO); + if(i < 0){ + canUseAmount = new BigDecimal("0"); + } + } catch (Exception e) { + e.printStackTrace(); + } + return canUseAmount; + } + + /** + * 获取失效日期 + * + * @param ruleId 指定的假期类型ID(对应于数据库表kq_leaveRules的主键ID) + * @param resourceId 指定的人员ID + * @param belongYear 指定的所属年份(格式yyyy) + * @param effectiveDate 生效日期 + * @param expirationDate 失效日期(待计算返回的) + * @return + */ + public static String getExpirationDate(String ruleId, String resourceId, String belongYear, String effectiveDate, String expirationDate) { + try { + //人力资源缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + //入职日期 + String companyStartDate = resourceComInfo.getCompanyStartDate(resourceId); + //创建日期 + String createDate = resourceComInfo.getCreatedate(resourceId); + //如果入职日期为空,默认取创建日期 + companyStartDate = companyStartDate.equals("") ? createDate : companyStartDate; + //分部ID + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + + + //假期规则缓存类 + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //有效期规则:0-不限制、1-按自然年失效、2-按入职日期起12个月、3-自定义次年失效日期、4-按天数失效、5-按季度失效、6-按月数失效 + int validityRule = Util.getIntValue(detailComInfo.getValidityRule(ruleId, subcompanyId, departmentId, resourceId), 0); + //自定义有效天数([validityRule=4]时有效) + int effectiveDays = Util.getIntValue(detailComInfo.getEffectiveDays(ruleId, subcompanyId, departmentId, resourceId), 0); + //自定义有效月数([validityRule=6]时有效) + int effectiveMonths = Util.getIntValue(detailComInfo.getEffectiveMonths(ruleId, subcompanyId, departmentId, resourceId), 0); + //自定义次年失效的月份([validityRule=3]时有效) + String expirationMonth = detailComInfo.getExpirationMonth(ruleId, subcompanyId, departmentId, resourceId); + //自定义次年失效的日期([validityRule=3]时有效) + String expirationDay = detailComInfo.getExpirationDay(ruleId, subcompanyId, departmentId, resourceId); + //允许延长有效期:0--不允许、1--允许 + int extensionEnable = Util.getIntValue(detailComInfo.getExtensionEnable(ruleId, subcompanyId, departmentId, resourceId), 0); + //允许延长的有效天数 + int extendedDays = Util.getIntValue(detailComInfo.getExtendedDays(ruleId, subcompanyId, departmentId, resourceId)); + //获取当前日期 + String currentDate = DateUtil.getCurrentDate(); + //如果生效日期为空,默认取当前日期 + effectiveDate = effectiveDate.equals("") ? currentDate : effectiveDate; + + if (validityRule == 0) { + //不限制有效期,默认永久有效(永久有效时有效日期默认为2222-12-31) + expirationDate = "2222-12-31"; + } else if (validityRule == 1) { + //按自然年(1月1日-12月31日) + if (extensionEnable == 1) { + //允许延长有效期 + expirationDate = DateUtil.addDate(belongYear + "-12-31", extendedDays); + } else { + expirationDate = belongYear + "-12-31"; + } + } else if (validityRule == 2) { + //按入职日期起12个月 + if (companyStartDate.equals("")) { + expirationDate = effectiveDate; + } else if (extensionEnable == 1) { + /*允许延长有效期*/ + expirationDate = DateUtil.addDate((Util.getIntValue(belongYear) + 1) + companyStartDate.substring(4), extendedDays); + } else { + expirationDate = DateUtil.addDate((Util.getIntValue(belongYear) + 1) + companyStartDate.substring(4), -1); + } + } else if (validityRule == 3) { + /*自定义次年失效日期*/ + if (extensionEnable == 1) { + /*允许延长有效期*/ + expirationDate = DateUtil.addDate((Util.getIntValue(belongYear) + 1) + "-" + expirationMonth + "-" + expirationDay, extendedDays); + } else { + expirationDate = (Util.getIntValue(belongYear) + 1) + "-" + expirationMonth + "-" + expirationDay; + } + } else if (validityRule == 4) { + //按天数失效 + if(expirationDate.length() > 0){ + + }else{ + expirationDate = DateUtil.addDate(effectiveDate, effectiveDays); + } + } else if (validityRule == 5) { + //按季度失效 + expirationDate = DateUtil.getLastDayOfQuarter(effectiveDate); + if (extensionEnable == 1) { + /*允许延长有效期*/ + expirationDate = DateUtil.addDate(expirationDate, extendedDays); + } + } else if (validityRule == 6){ + Calendar calendar = DateUtil.addMonth(DateUtil.getCalendar(effectiveDate), effectiveMonths - 1); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String dateStr = sdf.format(calendar.getTime()); + //按月数失效 + expirationDate = DateUtil.getLastDayOfMonth(dateStr); + } + } catch (Exception e) { + e.printStackTrace(); + } + return expirationDate; + } + /** + * 获取育儿家失效日期 + * + * @param ruleId 指定的假期类型ID(对应于数据库表kq_leaveRules的主键ID) + * @param resourceId 指定的人员ID + * @param belongYear 指定的所属年份(格式yyyy) + * @param effectiveDate 生效日期 + * @param searchDate 查询搜索日期 + * @return + */ + public static boolean getParentalExpirationDate(String ruleId, String resourceId, String belongYear, String effectiveDate, String searchDate) { + boolean status = false; + try { + //人力资源缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + //分部ID + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + //假期规则缓存类 + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //有效期规则:0-不限制、1-按自然年失效、2-按入职日期起12个月、3-自定义次年失效日期、4-按天数失效、5-按季度失效、6-按月数失效 + String rulesDetailId = detailComInfo.getId(ruleId, subcompanyId, departmentId, resourceId); + int validityRule = Util.getIntValue(detailComInfo.getValidityRule(ruleId, subcompanyId, departmentId, resourceId), 0); + int yearsOld = StringUtil.parseToInt(detailComInfo.getYearsOld(ruleId, subcompanyId, departmentId, resourceId), 0); + String isprovince = Util.null2s(detailComInfo.getIsProvince(ruleId, subcompanyId, departmentId, resourceId), "1"); + if(isprovince.equals("2")){ + Map params = new HashMap<>(); + getChildrenProvinceId(rulesDetailId,resourceComInfo.getLocationid(resourceId),params); + yearsOld = Util.getIntValue(Util.null2String(params.get("yearsOld"))); + } + //自定义有效天数([validityRule=4]时有效) + if (validityRule == 0) { + //不限制有效期,默认永久有效(永久有效时有效日期默认为2222-12-31) + return true; + } else { + ArrayList listDates = getParentalLeaveDate(resourceId); + for (int i = 0; i < listDates.size(); i++) { + String dateOfBirth = listDates.get(i); + String baseAmountReleaseDate = belongYear + dateOfBirth.substring(4); + int ageLimit = getAgeLimit(dateOfBirth, baseAmountReleaseDate); + if (ageLimit >= 0 && ageLimit <= yearsOld-1) { + String expirationDate = (Util.getIntValue(belongYear) + 1) + dateOfBirth.substring(4); + if (expirationDate.compareTo(searchDate) > 0) { + status = true; + break; + } else { + status = false; + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return status; + } + + /** + * 判断假期余额是否有效 + * + * @param ruleId 指定的假期类型ID(对应于数据库表kq_leaveRules的主键ID) + * @param resourceId 指定的人员ID + * @param belongYear 指定的所属年份(格式yyyy) + * @param searchDate 指定日期(根据此日期判断假期余额是否有效) + * @param effectiveDate 数据库中存放的生效日期 + * @param expirationDate 数据库中存放的失效日期 + * @return + */ + public static boolean getBalanceStatus(String ruleId, String resourceId, String belongYear, String searchDate, String effectiveDate, String expirationDate) { + boolean status = true; + try { + //育儿假 + if (KQLeaveRulesBiz.isLeaveOfParental(ruleId)) { + return getParentalExpirationDate(ruleId, resourceId, belongYear, effectiveDate, searchDate); + } + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String subCompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + if (!KQLeaveRulesBiz.isTiaoXiu(ruleId,subCompanyId,departmentId,resourceId)) { + expirationDate = getExpirationDate(ruleId, resourceId, belongYear, effectiveDate, expirationDate); + } + if (!expirationDate.equals("") && expirationDate.compareTo(searchDate)<0) { + status = false; + } + } catch (Exception e) { + e.printStackTrace(); + } + return status; + } + + /** + * 保存加班时长转换成的调休时长,当加班时长的单位与调休单位不一致时根据【加班单位】中的日折算时长转换 + * + * @param resourceId 指定人员ID(根据人员ID判断属于哪个考勤组,根据考勤组获取加班规则ID) + * @param date 指定日期(根据指定日期判断是节假日还是工作日还是休息日、日期格式yyyy-MM-dd) + * @param durationOfOvertime 加班时长 + * @param type 加班时长单位:0-分钟、1-小时、2-天 + * 单位可为空(为空则默认取【加班单位】中设置的最小加班单位) + * @param hoursOfworkday 指定日期的工作时长(只有当指定日期为工作日的时候才有工作时长) + * 当最小加班单位与调休单位不一致时,且指定日期为工作日时使用此工作时长进行折算 + * @param requestId 加班流程的requestId(用于使用记录中可追溯至加班流程) + * @param fromCardOrFlow 是打卡数据还是审批数据:1--打卡、2--流程 + * @param fromDateDb 加班流程表单中的加班开始日期 + * @return + */ + public static boolean saveTimeOfLeave(String resourceId, String date, String durationOfOvertime, String type, String hoursOfworkday, String requestId, String fromCardOrFlow, String fromDateDb) { + //加班转调休是否成功 + boolean flag = true; + try { + String tiaoxiuId = addExtraAmountByDis5(resourceId,date,durationOfOvertime,type,hoursOfworkday,requestId,fromCardOrFlow,fromDateDb,null); + flag = Util.getIntValue(tiaoxiuId, -1) > 0; + } catch (Exception e) { + new BaseBean().writeLog(e); + } + return flag; + } + + /** + * 保存加班时长转换成的调休时长,当加班时长的单位与调休单位不一致时根据【加班单位】中的日折算时长转换 + * + * @param resourceId 指定人员ID(根据人员ID判断属于哪个考勤组,根据考勤组获取加班规则ID) + * @param date 指定日期(根据指定日期判断是节假日还是工作日还是休息日、日期格式yyyy-MM-dd) + * @param durationOfOvertime 加班时长 + * @param type 加班时长单位:0-分钟、1-小时、2-天 + * 单位可为空(为空则默认取【加班单位】中设置的最小加班单位) + * @param hoursOfworkday 指定日期的工作时长(只有当指定日期为工作日的时候才有工作时长) + * 当最小加班单位与调休单位不一致时,且指定日期为工作日时使用此工作时长进行折算 + * @param requestId 加班流程的requestId(用于使用记录中可追溯至加班流程) + * @param fromCardOrFlow 是打卡数据还是审批数据:1--打卡、2--流程 + * @param fromDateDb 加班流程表单中的加班开始日期 + * @return + */ + public static String addExtraAmountByDis5(String resourceId, String date, String durationOfOvertime, String type, String hoursOfworkday, String requestId, String fromCardOrFlow, String fromDateDb,Map otherParam) { + Map params = new HashMap(); + params.put("resourceId", resourceId); + params.put("date", date); + params.put("durationOfOvertime", durationOfOvertime); + params.put("type", type); + params.put("hoursOfworkday", hoursOfworkday); + params.put("requestId", requestId); + params.put("fromCardOrFlow", fromCardOrFlow); + params.put("fromDateDb", fromDateDb); + //加班转的调休明细ID(KQ_BalanceOfLeave的ID) + String tiaoxiuId = "-1"; + try { + String workflowid = "-1"; + RecordSet rs = new RecordSet(); + if(requestId.length() > 0 && Util.getIntValue(requestId) > 0){ + String workflow_sql = "select workflowid from workflow_requestbase where requestid = ? "; + rs.executeQuery(workflow_sql, requestId); + if(rs.next()){ + workflowid = Util.null2s(rs.getString("workflowid"),"-1"); + } + } + //加班转调休是否成功 + boolean flag = false; + //人员信息缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + //创建日期 + String createDate = Util.null2String(resourceComInfo.getCompanyStartDate(resourceId)); + //入职日期 + String companyStartDate = Util.null2String(resourceComInfo.getCompanyStartDate(resourceId)); + //如果入职日期为空,则取创建日期 + companyStartDate = "".equals(companyStartDate) ? createDate : companyStartDate; + //分部ID + String subCompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + //日期类型:1-节假日、2-工作日、3-休息日(节假日设置的优先级高于考勤组中的设置) + int changeType = KQOvertimeRulesBiz.getChangeType(resourceId, date); + //获取当前日期,当前时间 + Calendar today = Calendar.getInstance(); + //当前日期 + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + //当前时间 + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + + /****************************************************************************************************************/ + + //假期类型的缓存类 + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //[调休]的假期类型的ID + //找到[调休]的假期类型ID + rs.writeLog("lxr2018>addExtraAmountByDis5开始"); + String leaveRulesId = KQLeaveRulesBiz.getTiaoXiu(subCompanyId, departmentId, resourceId)+""; + rulesComInfo.setTofirstRow(); + rs.writeLog("lxr2018>addExtraAmountByDis5="+leaveRulesId); + //[调休]的假期类型的最小请假单位:1-按天、2-按半天、3-按小时、4-按整天 + int minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(leaveRulesId), -1); + //假期规则的缓存类 +// KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //有效期规则:0-永久有效、1-按自然年(1月1日-12月31日)、2-按入职日期起12个月、3-自定义次年失效日期、4-按天数失效 + int validityRule = Util.getIntValue(detailComInfo.getValidityRule(leaveRulesId, subCompanyId,departmentId,resourceId)); + //保留几位小数 + int decimalDigit = Util.getIntValue(detailComInfo.getDecimalDigit(leaveRulesId, subCompanyId,departmentId,resourceId), 2); + + String order = getDeductOrder(""+changeType,detailComInfo.getId(leaveRulesId, subCompanyId,departmentId,resourceId)); + rs.writeLog("lxr2018>order="+order+",changeType="+changeType+",getId="+detailComInfo.getId(leaveRulesId, subCompanyId,departmentId,resourceId)); + + /*如果没有设置调休的假期类型,则直接退出方法*/ + if ("".equals(leaveRulesId)) { + logger.info("未设置调休的假期类型或未调休的假期类型下未设置改人员所在分部可用的假期规则。params=" + JSONObject.toJSONString(params)); + return "-1"; + } + /*【调休】的假期规则的最小请假单位有误时,记录错误日志,直接返回*/ + if (minimumUnit < 1 || minimumUnit > 6) { + logger.info("调休的请假规则的最小请假单位有误。params=" + JSONObject.toJSONString(params)); + return "-1"; + } + /*【调休】的假期规则的有效期规则有误时,记录错误日志,直接返回*/ + if (validityRule < 0 || validityRule > 6) { + logger.info("调休的请假规则的有效期规则有误。params=" + JSONObject.toJSONString(params)); + return "-1"; + } + + /****************************************************************************************************************/ + + //所属年份 + String belongYear = date.substring(0, 4); + //失效日期 + String expirationDate = ""; + //根据有效期规则获取有效日期 + expirationDate = getExpirationDate(leaveRulesId, resourceId, belongYear, date, expirationDate); + + /****************************************************************************************************************/ + + //最小加班单位:1-按天、2-按半天、3-按小时、4-按整天、5-按半小时加班、6-整小时 + int minimumUnitOfOvertime = -1; + //日折算时长 + double hoursToDay = -1.00; + + String sql = "select * from kq_OvertimeUnit where (isDelete is null or isDelete !=1) and id=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + minimumUnitOfOvertime = Util.getIntValue(recordSet.getString("minimumUnit"), -1); + hoursToDay = Util.getDoubleValue(recordSet.getString("hoursToDay"), 8.00); + } + /*【加班单位】的相关设置获取有误时,记录错误日志,直接返回*/ + if (minimumUnitOfOvertime == -1 || hoursToDay < 0) { + logger.info("获取到的加班单位的相关设置有误。params=" + JSONObject.toJSONString(params)); + return "-1"; + } + + /** + * 加班单位与调休单位不一致,实现转换 + */ + if (changeType == 2) { + if (hoursOfworkday.equals("")) { + logger.info("指定日期为工作日,但未传入工作日的工作时长。params=" + JSONObject.toJSONString(params)); + } + //当最小加班单位与调休单位不一致时,且指定日期为工作日时使用此工作时长进行折算 + hoursToDay = Util.getDoubleValue(hoursOfworkday, hoursToDay); + } + BigDecimal _hoursToDay = new BigDecimal("" + hoursToDay); + //把加班时长只按照分钟先处理一下 + BigDecimal min_durationOfOvertime = new BigDecimal(Util.null2s(durationOfOvertime, "0")); + if (type.equals("0")) { + } else if (type.equals("1")) { + //加班时长类型为小时---将加班分钟时长*60 + min_durationOfOvertime = min_durationOfOvertime.multiply(new BigDecimal("60")); + } else if (type.equals("2")) { + //加班时长类型为天----将加班分钟时长*一天加班小时数*60 + min_durationOfOvertime = min_durationOfOvertime.multiply(_hoursToDay).multiply(new BigDecimal("60")); + } else if (type.equals("")) { + } + BigDecimal _durationOfOvertime = new BigDecimal(Util.null2s(durationOfOvertime, "0")); + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) {//调休单位为天 + if (type.equals("0")) { + //加班时长类型为分钟、调休单位为天----将加班时长转换为天 + _durationOfOvertime = _durationOfOvertime.divide(new BigDecimal("60").multiply(_hoursToDay), 5, RoundingMode.HALF_UP); + } else if (type.equals("1")) { + //加班时长类型为小时、调休单位为天----将加班时长转换为天 + _durationOfOvertime = _durationOfOvertime.divide(_hoursToDay, 5, RoundingMode.HALF_UP); + } else if (type.equals("2")) { + //加班时长类型为天、调休单位为天----不作转换 + } else if (type.equals("")) { + //加班时长类型为空,取【加班单位】中设置的最小加班单位 + if (minimumUnitOfOvertime == 3 || minimumUnitOfOvertime== 5 || minimumUnitOfOvertime== 6) { + //最小加班单位为小时、调休单位为天----将加班时长转换为天 + _durationOfOvertime = _durationOfOvertime.divide(_hoursToDay, 5, RoundingMode.HALF_UP); + } else { + //最小加班单位为天、调休单位为天----不作转换 + } + } + } else if (KQUnitBiz.isLeaveHour(minimumUnit+"")) {//调休单位为小时 + if (type.equals("0")) { + //加班时长类型为分钟、调休单位为小时----将加班时长转换为小时 + _durationOfOvertime = _durationOfOvertime.divide(new BigDecimal("60"), 5, RoundingMode.HALF_UP); + } else if (type.equals("1")) { + //加班时长类型为小时、调休单位为小时----不作转换 + } else if (type.equals("2")) { + //加班时长类型为天、调休单位为小时----将加班时长转换为小时 + _durationOfOvertime = _durationOfOvertime.multiply(_hoursToDay).setScale(5, RoundingMode.HALF_UP); + } else if (type.equals("")) { + //加班时长类型为空,取【加班单位】中设置的最小加班单位 + if (minimumUnitOfOvertime == 3 || minimumUnitOfOvertime== 5 || minimumUnitOfOvertime== 6) { + //最小加班单位为小时、调休单位为小时----不作转换 + } else { + //最小加班单位为天、调休单位为小时----将加班时长转换为小时 + _durationOfOvertime = _durationOfOvertime.multiply(_hoursToDay).setScale(5, RoundingMode.HALF_UP); + } + } + } + logger.info("记录一下【最小加班单位】和调休的【最小请假单位】。params=" + JSONObject.toJSONString(params)); + + /*员工假期余额变更记录*/ + KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz(); + KQUsageHistoryEntity usageHistoryEntity = new KQUsageHistoryEntity(); + List usageHistoryEntityList = new ArrayList(); + + Map changeTypeMap = Maps.newHashMap(); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + Map overRulesDetailMap = Maps.newHashMap(); + Map> restTimeMap = Maps.newHashMap(); + Map computingModeMap = Maps.newHashMap(); + KQOverTimeRuleCalBiz kqOverTimeRuleCalBiz = new KQOverTimeRuleCalBiz(); + kqOverTimeRuleCalBiz.getOverTimeDataMap(resourceId, date, date, dateFormatter,changeTypeMap,overRulesDetailMap,restTimeMap,computingModeMap); + + Map overtimeLogMap = null; + if (otherParam != null && !otherParam.isEmpty()) { + if (otherParam.containsKey("overtimeLogMap")) { + overtimeLogMap = (Map) otherParam.get("overtimeLogMap"); + } + } + String changeType_key = date+"_"+changeType; + KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key); + if(kqOvertimeRulesDetailEntity == null){ + logOvertimeMap(overtimeLogMap,changeType_key,"|加班规则为null|KQOvertimeRulesDetailEntity"); + logger.info("加班转调休记录日志保存失败。获取不到加班规则信息=" + JSONObject.toJSONString(changeType_key)); + return "-1"; + }else{ + logger.info("加班转调休记录。kqOvertimeRulesDetailEntity=" + JSONObject.toJSONString(kqOvertimeRulesDetailEntity)); + } + String timepoint_key = Util.null2String(otherParam.get("timepoint_key")); + /** + * 判断是否允许加班补偿,若未允许,则不累加调休时长,只记录记录使用记录 + * paidLeaveEnable:是否允许加班补偿:0-不允许、1-允许 + */ + String overtime_type = ""; + int paidLeaveEnable = kqOvertimeRulesDetailEntity.getPaidLeaveEnable(); + int paidLeaveEnableType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableType(); + if(2 == paidLeaveEnableType){ + if(otherParam != null && !otherParam.isEmpty()){ + if(otherParam.containsKey("overtime_type")){ + overtime_type = Util.null2String(otherParam.get("overtime_type")); + if("0".equalsIgnoreCase(overtime_type)){ + paidLeaveEnable = 1; + }else if("1".equalsIgnoreCase(overtime_type)){ + paidLeaveEnable = 0; + }else{ + paidLeaveEnable = -1; + } + } + } + } + logOvertimeMap(overtimeLogMap,params,timepoint_key+"|生成调休参数|params"); + logOvertimeMap(overtimeLogMap,paidLeaveEnable,timepoint_key+"|是否生成调休|paidLeaveEnable"); + + usageHistoryEntity = new KQUsageHistoryEntity(leaveRulesId,resourceId,requestId,resourceId,currentDate,currentTime,fromCardOrFlow.equals("1") ? "3" : "4",belongYear,"0","0","0","0","0" + ,"0","0","0","0","0","0","0",""+minimumUnit,""+minimumUnit,"","-1",workflowid,date,"0"); + + if (paidLeaveEnable != 1) { + logger.info("未开启加班转调休,记录使用日志。params=" + JSONObject.toJSONString(params)); + /*记录使用记录*/ + usageHistoryEntity.setInsertOrUpdate("PaidLeaveEnable"); + usageHistoryEntityList.add(usageHistoryEntity); + flag = usageHistoryBiz.save(usageHistoryEntityList); + if (!flag){ + logger.info("加班转调休记录日志保存失败。params=" + JSONObject.toJSONString(params)); + } + return "-1"; + }else { + String paidLeaveEnableInfo = "paidLeaveEnable:"+paidLeaveEnable+":paidLeaveEnableType:"+paidLeaveEnableType+":overtime_type:"+overtime_type; + logOvertimeMap(overtimeLogMap,paidLeaveEnableInfo,"|未开启调休|paidLeaveEnable"); + } + + Map paidMap = Maps.newHashMap(); + paidMap.put("changeType", String.valueOf(changeType)); + paidMap.put("order", order); + if(1 == paidLeaveEnableType){ +// 默认加班补偿规则 +// 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长 + int paidLeaveEnableDefaultType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableDefaultType(); + if(1 == paidLeaveEnableDefaultType){ + Map resultMap = save_paidLeaveEnableDefaultType1(kqOvertimeRulesDetailEntity,_durationOfOvertime,date,leaveRulesId, resourceId,belongYear,expirationDate,fromCardOrFlow,paidMap); + if(!resultMap.isEmpty()){ + return handleUsageHistory(resultMap,params,usageHistoryEntity); + } + }else if(2 == paidLeaveEnableDefaultType){ + int ruleDetailid = kqOvertimeRulesDetailEntity.getId(); + if(ruleDetailid > 0){ + Map resultMap = save_paidLeaveEnableDefaultType2(date,leaveRulesId, resourceId,belongYear,expirationDate,fromCardOrFlow,ruleDetailid,min_durationOfOvertime,minimumUnit,_hoursToDay,paidMap); + if(!resultMap.isEmpty()){ + return handleUsageHistory(resultMap,params,usageHistoryEntity); + } + } + }else if(3 == paidLeaveEnableDefaultType){ + int ruleDetailid = kqOvertimeRulesDetailEntity.getId(); + if(ruleDetailid > 0) { + if (otherParam != null && !otherParam.isEmpty()) { + if (otherParam.containsKey("OvertimeBalanceTimeBean")) { + OvertimeBalanceTimeBean overtimeBalanceTimeBean = (OvertimeBalanceTimeBean) otherParam.get("OvertimeBalanceTimeBean"); + if(overtimeBalanceTimeBean != null){ + int list_index = overtimeBalanceTimeBean.getList_index(); + if(list_index > -1) { + int timepoint_min = overtimeBalanceTimeBean.getTimepoint_mins(); + if(timepoint_min <= 0){ + logger.info("时间区间内加班生成为0。overtimeBalanceTimeBean=" + JSONObject.toJSONString(overtimeBalanceTimeBean)); + } + Map resultMap = save_paidLeaveEnableDefaultType3(date, + leaveRulesId, resourceId, belongYear, expirationDate, fromCardOrFlow, + ruleDetailid, overtimeBalanceTimeBean,list_index,minimumUnit,_hoursToDay,overtimeLogMap,timepoint_key,paidMap); + if(!resultMap.isEmpty()){ + return handleUsageHistory(resultMap,params,usageHistoryEntity); + } + }else{ + logger.info("时间区间内加班下标为-1,overtimeBalanceTimeBean=" + JSONObject.toJSONString(overtimeBalanceTimeBean)); + } + } + } + } + } + } + }else if(2 == paidLeaveEnableType){ + //根据员工在加班流程上选择的加班补偿类型进行补偿两种 +// 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长 + int paidLeaveEnableFlowType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableFlowType(); + if(1 == paidLeaveEnableFlowType){ + Map resultMap = save_paidLeaveEnableDefaultType1(kqOvertimeRulesDetailEntity,_durationOfOvertime,date,leaveRulesId, resourceId,belongYear,expirationDate,fromCardOrFlow,paidMap); + if(!resultMap.isEmpty()){ + return handleUsageHistory(resultMap,params,usageHistoryEntity); + } + }else if(2 == paidLeaveEnableFlowType){ + int ruleDetailid = kqOvertimeRulesDetailEntity.getId(); + if(ruleDetailid > 0){ + Map resultMap = save_paidLeaveEnableDefaultType2(date,leaveRulesId, resourceId,belongYear,expirationDate,fromCardOrFlow,ruleDetailid,min_durationOfOvertime, + minimumUnit, _hoursToDay,paidMap); + if(!resultMap.isEmpty()){ + return handleUsageHistory(resultMap,params,usageHistoryEntity); + } + } + }else if(3 == paidLeaveEnableFlowType){ + int ruleDetailid = kqOvertimeRulesDetailEntity.getId(); + if(ruleDetailid > 0) { + if (otherParam != null && !otherParam.isEmpty()) { + if (otherParam.containsKey("OvertimeBalanceTimeBean")) { + OvertimeBalanceTimeBean overtimeBalanceTimeBean = (OvertimeBalanceTimeBean) otherParam.get("OvertimeBalanceTimeBean"); + if(overtimeBalanceTimeBean != null){ + int list_index = overtimeBalanceTimeBean.getList_index(); + if(list_index > -1) { + int timepoint_min = overtimeBalanceTimeBean.getTimepoint_mins(); + if(timepoint_min <= 0){ + logger.info("时间区间内加班生成为0。overtimeBalanceTimeBean=" + JSONObject.toJSONString(overtimeBalanceTimeBean)); + } + Map resultMap = save_paidLeaveEnableDefaultType3(date, + leaveRulesId, resourceId, belongYear, expirationDate, fromCardOrFlow, + ruleDetailid, overtimeBalanceTimeBean,list_index, minimumUnit, + _hoursToDay, overtimeLogMap, timepoint_key,paidMap); + if(!resultMap.isEmpty()){ + return handleUsageHistory(resultMap,params,usageHistoryEntity); + } + }else{ + logger.info("时间区间内加班下标为-1,overtimeBalanceTimeBean=" + JSONObject.toJSONString(overtimeBalanceTimeBean)); + } + } + } + } + } + } + } + } catch (Exception e) { + logger.info("加班转调休出错。params=" + JSONObject.toJSONString(params)); + new BaseBean().writeLog(e); + } + return tiaoxiuId; + } + + + /** + * 输出日志并记录假期使用记录 + * @param resultMap + * @param params + * @param usageHistoryEntity + * @return + */ + private static String handleUsageHistory(Map resultMap, Map params, KQUsageHistoryEntity usageHistoryEntity) { + + boolean flag = false; + KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz(); + List usageHistoryEntityList = new ArrayList(); + + String result_status = Util.null2String(resultMap.get("status")); + String extraAmount = Util.null2s(Util.null2String(resultMap.get("extraAmount")),"0"); + String tiaoxiuId = Util.null2String(resultMap.get("tiaoxiuId")); + if("-1".equalsIgnoreCase(result_status)){ + logger.info("加班转调休余额为0,不产生调休明细,记录使用日志。params=" + JSONObject.toJSONString(params)); + usageHistoryEntity.setInsertOrUpdate("OnlyRecordLog"); + usageHistoryEntity.setNewExtraAmount("0"); + /*记录使用记录*/ + usageHistoryEntityList.add(usageHistoryEntity); + flag = usageHistoryBiz.save(usageHistoryEntityList); + if (!flag) { + logger.info("加班转调休记录日志保存失败。params=" + JSONObject.toJSONString(params)); + } + return "-1"; + } + if("-2".equalsIgnoreCase(result_status)){ + logger.info("加班转调休保存失败。params=" + JSONObject.toJSONString(params)); + return "-1"; + } + if("1".equalsIgnoreCase(result_status)){ + usageHistoryEntity.setInsertOrUpdate("insert"); + usageHistoryEntity.setNewExtraAmount(extraAmount); + usageHistoryEntity.setBalanceOfLeaveId(tiaoxiuId); + usageHistoryEntityList.add(usageHistoryEntity); + flag = usageHistoryBiz.save(usageHistoryEntityList); + if (!flag) { + logger.info("加班转调休记录日志保存失败。params=" + JSONObject.toJSONString(params)); + } + } + return tiaoxiuId; + } + + /** + * 按加班的时间段设置转调休时长 + */ + private static Map save_paidLeaveEnableDefaultType3(String date, + String leaveRulesId, String resourceId, String belongYear, String expirationDate, + String fromCardOrFlow, int ruleDetailid, OvertimeBalanceTimeBean overtimeBalanceTimeBean, + int list_index, int minimumUnit, BigDecimal _hoursToDay, + Map overtimeLogMap, String timepoint_key, + Map paidMap) { + int changeType = Util.getIntValue(Util.null2String(paidMap.get("changeType"))); + String order = Util.null2String(paidMap.get("order")); + if(Util.getIntValue(order) <= 0){ + order = ""; + } + Map resultMap = Maps.newHashMap(); + + String tiaoxiuId = "-1"; + boolean flag = false; + RecordSet recordSet = new RecordSet(); + String extraAmount = ""; + + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + Map> balanceLengthDetailMap = kqOvertimeRulesBiz.getBalanceTimeDetailMap(ruleDetailid); + + int timepoint_min = overtimeBalanceTimeBean.getTimepoint_mins(); + List lenOfOvertimeList = balanceLengthDetailMap.get("lenOfOvertimeList"); + List lenOfLeaveList = balanceLengthDetailMap.get("lenOfLeaveList"); + String lenOfOvertime = lenOfOvertimeList.get(list_index); + String lenOfLeave = lenOfLeaveList.get(list_index); + + BigDecimal _timepoint_min = new BigDecimal(Util.null2s(""+timepoint_min, "0")); + BigDecimal _lenOfLeave = new BigDecimal(lenOfLeave); + BigDecimal _lenOfOvertime = new BigDecimal(lenOfOvertime); + BigDecimal durationOfLeave = _timepoint_min.multiply(_lenOfLeave).divide(_lenOfOvertime, 5, RoundingMode.HALF_UP); + + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) {//调休单位为天 + durationOfLeave = durationOfLeave.divide(new BigDecimal("60").multiply(_hoursToDay), 5, RoundingMode.HALF_UP); + + } else if (KQUnitBiz.isLeaveHour(minimumUnit+"")) {//调休单位为小时 + durationOfLeave = durationOfLeave.divide(new BigDecimal("60"), 5, RoundingMode.HALF_UP); + } + + extraAmount = durationOfLeave.setScale(5, RoundingMode.HALF_UP).toPlainString(); + String paidLeaveEnableDefaultType3 = "minimumUnit:"+minimumUnit+":durationOfLeave:"+durationOfLeave + +":_lenOfLeave:"+_lenOfLeave+":_lenOfOvertime:"+_lenOfOvertime+":_timepoint_min:"+_timepoint_min+":_hoursToDay:"+_hoursToDay; + logOvertimeMap(overtimeLogMap,paidLeaveEnableDefaultType3,timepoint_key+"|生成调休|save_paidLeaveEnableDefaultType3"); + + if (Util.getDoubleValue(extraAmount) <= 0) { + resultMap.put("status", "-1"); + return resultMap; + } + java.sql.Timestamp date1 = KQDateUtil.getUpdateTimeStamp(); + /*插入调休时长*/ + String _belongYear = date.substring(0, 4); + String _belongMonth = date.substring(5, 7); + String sql = "insert into kq_balanceOfLeave(leaveRulesId,resourceId,belongYear,belongMonth,baseAmount,tiaoxiuamount,usedAmount,baseAmount2,extraAmount2,usedAmount2,status,expirationDate,effectiveDate,overtimeType,isDelete,create_time,update_time,creator,changetype,deductorder) " + + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + if (recordSet.getDBType().equals("postgresql")) { + sql = "insert into kq_balanceOfLeave(leaveRulesId,resourceId,belongYear,belongMonth,baseAmount,tiaoxiuamount,usedAmount,baseAmount2,extraAmount2,usedAmount2,status,expirationDate,effectiveDate,overtimeType,isDelete,create_time,update_time,creator,changetype,deductorder) " + + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?::timestamp,?::timestamp,?,?,?)"; + } + flag = recordSet.executeUpdate(sql, leaveRulesId, resourceId, _belongYear, _belongMonth, 0, extraAmount, 0, 0, 0, 0, 0, expirationDate, date, fromCardOrFlow.equals("0") ? "3" : "4", 0,date1,date1,Util.getIntValue(resourceId),changeType,order); + if (!flag) { + resultMap.put("status", "-2"); + return resultMap; + } + //获取刚才插入的调休明细的ID + sql = "select max(id) from kq_balanceOfLeave where leaveRulesId=? and resourceId=? and belongYear=?"; + recordSet.executeQuery(sql, leaveRulesId, resourceId, belongYear); + if (recordSet.next()) { + tiaoxiuId = recordSet.getString(1); + } + resultMap.put("status", "1"); + resultMap.put("tiaoxiuId", tiaoxiuId); + resultMap.put("extraAmount", extraAmount); + return resultMap; + } + + /** + * 按加班时长范围设置转调休时长 + */ + private static Map save_paidLeaveEnableDefaultType2( + String date, String leaveRulesId, String resourceId, + String belongYear, String expirationDate, String fromCardOrFlow, int ruleDetailid, + BigDecimal min_durationOfOvertime, int minimumUnit, BigDecimal _hoursToDay, + Map paidMap) { + int changeType = Util.getIntValue(Util.null2String(paidMap.get("changeType"))); + String order = Util.null2String(paidMap.get("order")); + if(Util.getIntValue(order) <= 0){ + order = ""; + } + Map resultMap = Maps.newHashMap(); + + String tiaoxiuId = "-1"; + boolean flag = false; + RecordSet recordSet = new RecordSet(); + String extraAmount = ""; + + int overtimelength_i = -1; + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + Map> balanceLengthDetailMap = kqOvertimeRulesBiz.getBalanceLengthDetailMap(ruleDetailid); + if(balanceLengthDetailMap != null && !balanceLengthDetailMap.isEmpty()){ + List overtimelengthList = balanceLengthDetailMap.get("overtimelengthList"); + for(int i = 0 ; i < overtimelengthList.size() ; i++){ + String overtimelength = Util.null2s(overtimelengthList.get(i),""); + if(overtimelength.length() == 0){ + continue; + } + BigDecimal b_60Mins = new BigDecimal(60); + BigDecimal b_overtimelength = new BigDecimal(overtimelength).multiply(b_60Mins); + if(min_durationOfOvertime.compareTo(b_overtimelength) >= 0){ + overtimelength_i = i; + break; + } + } + if(overtimelength_i > -1){ + List balancelengthList = balanceLengthDetailMap.get("balancelengthList"); + if(balancelengthList.size() > overtimelength_i){ + String balancelength = balancelengthList.get(overtimelength_i); + BigDecimal b_balancelength = new BigDecimal(balancelength); + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) {//调休单位为天 + b_balancelength = b_balancelength.divide(_hoursToDay, 5, RoundingMode.HALF_UP); + + } else if (KQUnitBiz.isLeaveHour(minimumUnit+"")) {//调休单位为小时 + } + extraAmount = Util.null2s(b_balancelength.toPlainString(), "0"); + } + } + } + new KQLog().info("save_paidLeaveEnableDefaultType2 balanceLengthDetailMap:"+balanceLengthDetailMap + +":min_durationOfOvertime:"+min_durationOfOvertime+":extraAmount:"+extraAmount); + + if (Util.getDoubleValue(extraAmount) <= 0) { + extraAmount = "0.0"; + } + if(overtimelength_i < 0){ + extraAmount = "0.0"; + } + java.sql.Timestamp date1 = KQDateUtil.getUpdateTimeStamp(); + /*插入调休时长*/ + String _belongYear = date.substring(0, 4); + String _belongMonth = date.substring(5, 7); + String sql = "insert into kq_balanceOfLeave(leaveRulesId,resourceId,belongYear,belongMonth,baseAmount,tiaoxiuamount,usedAmount,baseAmount2,extraAmount2,usedAmount2,status,expirationDate,effectiveDate,overtimeType,isDelete,create_time,update_time,creator,changetype,deductorder) " + + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + if (recordSet.getDBType().equals("postgresql")) { + sql = "insert into kq_balanceOfLeave(leaveRulesId,resourceId,belongYear,belongMonth,baseAmount,tiaoxiuamount,usedAmount,baseAmount2,extraAmount2,usedAmount2,status,expirationDate,effectiveDate,overtimeType,isDelete,create_time,update_time,creator,changetype,deductorder) " + + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?::timestamp,?::timestamp,?,?,?)"; + } + flag = recordSet.executeUpdate(sql, leaveRulesId, resourceId, _belongYear, _belongMonth, 0, extraAmount, 0, 0, 0, 0, 0, expirationDate, date, fromCardOrFlow.equals("0") ? "3" : "4", 0,date1,date1,Util.getIntValue(resourceId),changeType,order); + if (!flag) { + resultMap.put("status", "-2"); + return resultMap; + } + //获取刚才插入的调休明细的ID + sql = "select max(id) from kq_balanceOfLeave where leaveRulesId=? and resourceId=? and belongYear=?"; + recordSet.executeQuery(sql, leaveRulesId, resourceId, belongYear); + if (recordSet.next()) { + tiaoxiuId = recordSet.getString(1); + } + resultMap.put("status", "1"); + resultMap.put("tiaoxiuId", tiaoxiuId); + resultMap.put("extraAmount", extraAmount); + return resultMap; + } + + /** + * 按加班时长比例转调休时长 + */ + private static Map save_paidLeaveEnableDefaultType1( + KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity, + BigDecimal _durationOfOvertime, String date, String leaveRulesId, String resourceId, + String belongYear, String expirationDate, String fromCardOrFlow, + Map paidMap) { + int changeType = Util.getIntValue(Util.null2String(paidMap.get("changeType"))); + String order = Util.null2String(paidMap.get("order")); + if(Util.getIntValue(order) <= 0){ + order = ""; + } + Map resultMap = Maps.newHashMap(); + + String tiaoxiuId = "-1"; + boolean flag = false; + RecordSet recordSet = new RecordSet(); + String extraAmount = ""; + /** + * 计算调休时长并存入调休余额中 + */ + BigDecimal _lenOfLeave = new BigDecimal("" + kqOvertimeRulesDetailEntity.getLenOfLeave()); + BigDecimal _lenOfOvertime = new BigDecimal("" + kqOvertimeRulesDetailEntity.getLenOfOvertime()); + BigDecimal durationOfLeave = _durationOfOvertime.multiply(_lenOfLeave).divide(_lenOfOvertime, 5, RoundingMode.HALF_UP); + extraAmount = durationOfLeave.setScale(5, RoundingMode.HALF_UP).toPlainString(); + + if (durationOfLeave.doubleValue() <= 0) { + extraAmount = "0.0"; + } + java.sql.Timestamp date1 = KQDateUtil.getUpdateTimeStamp(); + /*插入调休时长*/ + String _belongYear = date.substring(0, 4); + String _belongMonth = date.substring(5, 7); + String sql = "insert into kq_balanceOfLeave(leaveRulesId,resourceId,belongYear,belongMonth,baseAmount,tiaoxiuamount,usedAmount,baseAmount2,extraAmount2,usedAmount2,status,expirationDate,effectiveDate,overtimeType,isDelete,create_time,update_time,creator,changetype,deductorder) " + + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + if (recordSet.getDBType().equals("postgresql")) { + sql = "insert into kq_balanceOfLeave(leaveRulesId,resourceId,belongYear,belongMonth,baseAmount,tiaoxiuamount,usedAmount,baseAmount2,extraAmount2,usedAmount2,status,expirationDate,effectiveDate,overtimeType,isDelete,create_time,update_time,creator,changetype,deductorder) " + + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?::timestamp,?::timestamp,?,?,?)"; + } + flag = recordSet.executeUpdate(sql, leaveRulesId, resourceId, _belongYear, _belongMonth, 0, extraAmount, 0, 0, 0, 0, 0, expirationDate, date, fromCardOrFlow.equals("0") ? "3" : "4", 0,date1,date1,Util.getIntValue(resourceId),changeType,order); + if (!flag) { + resultMap.put("status", "-2"); + return resultMap; + } + //获取刚才插入的调休明细的ID + sql = "select max(id) from kq_balanceOfLeave where leaveRulesId=? and resourceId=? and belongYear=?"; + recordSet.executeQuery(sql, leaveRulesId, resourceId, belongYear); + if (recordSet.next()) { + tiaoxiuId = recordSet.getString(1); + } + resultMap.put("status", "1"); + resultMap.put("tiaoxiuId", tiaoxiuId); + resultMap.put("extraAmount", extraAmount); + return resultMap; + } + + /** + * 根据员工假期余额的ID + * + * @param balanceOfLeaveId 调休余额的ID + * @param durationOfOvertime 加班时长,默认为分钟 + * @return + */ + public static boolean updateExtraAmountByDis5(String balanceOfLeaveId, double durationOfOvertime, String requestId) { + boolean result = false; + try { + if (balanceOfLeaveId == null && !balanceOfLeaveId.equals("")) { + logger.info("传入的员工假期余额ID为空。"); + logger.info("balanceOfLeaveId=" + balanceOfLeaveId + ",newExtraAmount=" + durationOfOvertime + ",requestId=" + requestId); + return false; + } + String workflowid = "-1"; + RecordSet rs = new RecordSet(); + if(requestId.length() > 0 && Util.getIntValue(requestId) > 0){ + String workflow_sql = "select workflowid from workflow_requestbase where requestid = ? "; + rs.executeQuery(workflow_sql, requestId); + if(rs.next()){ + workflowid = Util.null2s(rs.getString("workflowid"),"-1"); + } + } + + //获取当前日期,当前时间 + Calendar today = Calendar.getInstance(); + //当前日期 + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + //当前时间 + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + + //假期类型的缓存类 + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + + //add + ResourceComInfo resourceComInfo1 = null; + String resourceId1 = ""; + try { + resourceComInfo1 = new ResourceComInfo(); + } catch (Exception e) { + e.printStackTrace(); + } + RecordSet rs1 = new RecordSet(); + String sql1 = "select * from KQ_BalanceOfLeave where id=?"; + rs1.executeQuery(sql1, balanceOfLeaveId); + if (rs1.next()) { + String id = rs1.getString("id"); + resourceId1 = rs1.getString("resourceId"); + } + //分部ID + String subCompanyId = resourceComInfo1.getSubCompanyID(resourceId1); + String departmentId = resourceComInfo1.getDepartmentID(resourceId1); + //[调休]的假期类型的ID + String leaveRulesId = ""; + //找到[调休]的假期类型ID + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + if (KQLeaveRulesBiz.isTiaoXiu(rulesComInfo.getId(),subCompanyId,departmentId,resourceId1)) { + leaveRulesId = rulesComInfo.getId(); + break; + } + } + //[调休]的假期类型的最小请假单位:1-按天、2-按半天、3-按小时、4-按整天 + int minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(leaveRulesId), 3); + + /****************************************************************************************************************/ + + //加班单位中的日折算时长 + double hoursToDay = 8.00; + String overtimeSql = "select * from kq_OvertimeUnit where (isDelete is null or isDelete !=1) and id=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(overtimeSql); + if (recordSet.next()) { + hoursToDay = Util.getDoubleValue(recordSet.getString("hoursToDay"), 8.00); + } + + /****************************************************************************************************************/ + + BigDecimal _hoursToDay = new BigDecimal("" + hoursToDay); + BigDecimal _durationOfOvertime = new BigDecimal("" + durationOfOvertime); + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) {//调休单位为天 + //加班时长类型为分钟、调休单位为天----将加班时长转换为天 + _durationOfOvertime = _durationOfOvertime.divide(new BigDecimal("60").multiply(_hoursToDay), 5, RoundingMode.HALF_UP); + } else if (KQUnitBiz.isLeaveHour(minimumUnit+"")) {//调休单位为小时 + //加班时长类型为分钟、调休单位为小时----将加班时长转换为小时 + _durationOfOvertime = _durationOfOvertime.divide(new BigDecimal("60"), 5, RoundingMode.HALF_UP); + } + logger.info("记录一下需要重新生成调休时长的调休时长。"); + logger.info("balanceOfLeaveId=" + balanceOfLeaveId + ",newExtraAmount=" + durationOfOvertime + ",requestId=" + requestId + ",_durationOfOvertime=" + _durationOfOvertime.doubleValue()); + + boolean flag = true; + KQUsageHistoryBiz kqUsageHistoryBiz = new KQUsageHistoryBiz(); + KQUsageHistoryEntity kqUsageHistoryEntity = new KQUsageHistoryEntity(); + List kqUsageHistoryEntities = new ArrayList<>(); + + String sql = "select * from KQ_BalanceOfLeave where id=?"; + recordSet.executeQuery(sql, balanceOfLeaveId); + if (recordSet.next()) { + String id = recordSet.getString("id"); + String resourceId = recordSet.getString("resourceId"); + String belongYear = recordSet.getString("belongYear"); + String belongMonth = recordSet.getString("belongMonth"); + String baseAmount = recordSet.getString("baseAmount"); + String extraAmount = recordSet.getString("extraAmount"); + String usedAmount = recordSet.getString("usedAmount"); + String effectiveDate = recordSet.getString("effectiveDate"); + String expirationDate = recordSet.getString("expirationDate"); + + //根据加班时长以及转换比例得出调休时长 + BigDecimal _lenOfLeave = new BigDecimal("" + KQOvertimeRulesBiz.getLenOfLeave(resourceId, effectiveDate)); + BigDecimal _lenOfOvertime = new BigDecimal("" + KQOvertimeRulesBiz.getLenOfOvertime(resourceId, effectiveDate)); + BigDecimal durationOfLeave = _durationOfOvertime.multiply(_lenOfLeave).divide(_lenOfOvertime, 5, RoundingMode.HALF_UP); + + sql = "update KQ_BalanceOfLeave set extraAmount=?,update_time=? where id=?"; + if (recordSet.getDBType().equals("postgresql")) { + sql = "update KQ_BalanceOfLeave set extraAmount=?,update_time=?::timestamp where id=?"; + } + result = recordSet.executeUpdate(sql, durationOfLeave.setScale(5, RoundingMode.HALF_UP).doubleValue(), KQDateUtil.getUpdateTimeStamp(), id); + if (result) { + kqUsageHistoryEntities = new ArrayList<>(); + kqUsageHistoryEntity = new KQUsageHistoryEntity(leaveRulesId, resourceId, requestId, resourceId, currentDate, currentTime, "8", belongYear, baseAmount, baseAmount, extraAmount, durationOfLeave.setScale(5, RoundingMode.HALF_UP).toPlainString(), usedAmount + , usedAmount, "0", "0", "0", "0", "0", "0", "" + minimumUnit, "" + minimumUnit, "update", + id,workflowid,effectiveDate,"0"); + kqUsageHistoryEntities.add(kqUsageHistoryEntity); + kqUsageHistoryBiz.save(kqUsageHistoryEntities); + } else { + logger.info("加班重新生成调休,员工假期余额更新失败。"); + logger.info("balanceOfLeaveId=" + balanceOfLeaveId + ",newExtraAmount=" + durationOfOvertime + ",requestId=" + requestId + ",_durationOfOvertime=" + durationOfLeave.doubleValue()); + return false; + } + } else { + logger.info("未找到对应的员工假期余额。"); + logger.info("balanceOfLeaveId=" + balanceOfLeaveId + ",newExtraAmount=" + durationOfOvertime + ",requestId=" + requestId); + return false; + } + } catch (Exception e) { + new BaseBean().writeLog(e); + } + return result; + } + + public static String getDeductOrder(String changetype,String ruledetailid){ + RecordSet recordSet = new RecordSet(); + String deductorder = "-1"; + if(Util.null2String(ruledetailid).length() == 0 || Util.null2String(changetype).length() == 0){ + recordSet.writeLog("getDeductOrder.changetype="+changetype+",ruledetailid="+ruledetailid); + return deductorder; + } + String sql = "select ruleId,ruleName,scopeType,scopeValue,distributionMode,deductorder from kq_LeaveRulesDetail where id = '"+ruledetailid+"'"; + recordSet.executeQuery(sql); + if(recordSet.next()){ + String tmp_order = Util.null2String(recordSet.getString("deductorder")); + if(tmp_order.length()>0){ + String[] orders = tmp_order.split(","); + if(null != orders && orders.length>0){ + for (int i = 0; i < orders.length; i++) { + if(orders[i].equals(changetype) && i==0){ + deductorder = "1"; + }else if(orders[i].equals(changetype) && i==1){ + deductorder = "2"; + }else if(orders[i].equals(changetype) && i==2){ + deductorder = "3"; + } + } + } + } + } + recordSet.writeLog("getDeductOrder.changetype="+changetype+",ruledetailid="+ruledetailid+",deductorder="+deductorder+",sql="+sql); + + return deductorder; + } + + /** + * 累加已用的假期时长 + * + * @param resourceId 指定人员ID + * @param date 请假日期(目前请假扣减逻辑:如果请假跨了多天,会拆分成一天一天扣减) + * @param ruleId 指定假期规则 + * @param duration 请假时长 + * @param type 时长类型:0-分钟、1-小时、2-天 + * 传入空值则默认取假期规则设置中的单位 + * @param fromDateDb 请假流程表单中的请假开始日期(根据请假开始日期判断假期余额是否有效) + * @param requestId 请假流程的requestId + */ + public static void addUsedAmount(String resourceId, String date, String ruleId, String duration, String type, String requestId, String fromDateDb) { + try { + if(Util.getDoubleValue(duration) <= 0) { + logger.info("请假时长为0不做扣减。resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + return; + } + java.sql.Timestamp updateDate = KQDateUtil.getUpdateTimeStamp(); + /*获取当前日期,当前时间*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + + /****************************************************************************************************************/ + + //人力资源缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + //分部ID + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + /****************************************************************************************************************/ + + //假期类型缓存类 + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + //最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假 + int minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(ruleId)); + //最小请假单位获取有误,记录错误日志,直接退出方法 + if (minimumUnit < 1 || minimumUnit > 6) { + logger.info("最小请假单位获取有误。resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + return; + } + //是否启用假期余额:0-不启用、1-启用 + int balanceEnable = Util.getIntValue(rulesComInfo.getBalanceEnable(ruleId), 0); + //该假期未开启假期余额,记录错误日志,退出方法 + if (balanceEnable != 1) { + logger.info("该假期未开启假期余额。resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + return; + } + //前台传回的请假时长类型与后台设置的假期限制的最小请假单位不相符,暂不支持转换,记录错误日志,直接退出方法 + boolean flag = type.equals("") || ("1".equals(type) && KQUnitBiz.isLeaveHour(minimumUnit+"")) || ("2".equals(type) && (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4)); + if (!flag) { + logger.info("前台传回的请假时长类型与后台设置的请假类型限制的最小请假单位不相符。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + return; + } + + /****************************************************************************************************************/ + + //假期规则缓存类(每个假期类型下可能存在多个假期规则) + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //余额发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按入职时长+工龄自动发放 + int distributionMode = Util.getIntValue(detailComInfo.getDistributionMode(ruleId, subcompanyId, departmentId, resourceId)); + //扣减优先级:1-法定年假、2-福利年假 + int priority = Util.getIntValue(detailComInfo.getPriority(ruleId, subcompanyId, departmentId, resourceId), 1); + + /****************************************************************************************************************/ + + //如果请假开始日期为空,默认取请假日期 + fromDateDb = date; + + boolean istiaoxiu = false; + + + //员工假期余额变更记录 + KQUsageHistoryEntity usageHistoryEntity = new KQUsageHistoryEntity(); + List usageHistoryEntityList = new ArrayList(); + + List updateList = new ArrayList(); + BigDecimal _duration = new BigDecimal(Util.null2s(duration, "0")); + RecordSet recordSet = new RecordSet(); + String sql = "select * from kq_balanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and resourceId=" + resourceId + " order by belongYear"; + if (distributionMode == 5) { + istiaoxiu = true; + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") + || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql = " select * from kq_balanceOfLeave " + + " where (isDelete is null or isDelete<>1) and resourceId=" + resourceId + " and leaveRulesId=" + ruleId + " and (expirationDate is null or expirationDate='' or expirationDate>='" + fromDateDb + "') " + + " order by deductorder asc,belongYear asc,expirationDate asc,id asc "; + } else { + sql = " select * from kq_balanceOfLeave " + + " where (isDelete is null or isDelete<>1) and resourceId=" + resourceId + " and leaveRulesId=" + ruleId + " and (expirationDate is null or expirationDate>='" + fromDateDb + "') " + + " order by deductorder asc,belongYear asc,expirationDate asc,id asc "; + } + } + // 如果是育儿假 + boolean leaveOfParental = KQLeaveRulesBiz.isLeaveOfParentalNum(ruleId); + if(leaveOfParental){ + sql = " select * from kq_balanceOfLeave " + + " where (isDelete is null or isDelete<>1) and resourceId=" + resourceId + " and leaveRulesId=" + ruleId + " and (expirationDate is null or expirationDate='' or expirationDate>='" + fromDateDb + "') " + + " order by belongYear asc,expirationDate asc,id asc "; + } + new BaseBean().writeLog("==查询的sql==selectsql:"+sql); + recordSet.executeQuery(sql); + int total = recordSet.getCounts(); + int index = 0; + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String allow_negative = Util.null2String(kqSettingsComInfo.getMain_val("allow_negative"),"0"); + boolean allow_negative_flag = "1".equals(allow_negative); + int indexStatus = 0; + while (recordSet.next()) { + index++; + // + String id = recordSet.getString("id"); + //所属年份 + String belongYear = recordSet.getString("belongYear"); + //失效日期 + String expirationDate = recordSet.getString("expirationDate"); + //生效日期 + String effectiveDate = recordSet.getString("effectiveDate"); + //判断假期余额是否失效 + boolean status = getBalanceStatus(ruleId, resourceId, belongYear, fromDateDb, effectiveDate, expirationDate); + if (!status) { + //如果是调休+开启了负数+最后一行 + if(allow_negative_flag && index == total){ + indexStatus = 1; + } + continue; + } + + + String changetype = Util.null2String(recordSet.getString("changetype")); + //基数 + BigDecimal baseAmount = new BigDecimal(Util.null2s(recordSet.getString("baseAmount"), "0")); + //额外 + BigDecimal extraAmount = new BigDecimal(Util.null2s(recordSet.getString("extraAmount"), "0")); + + //加班生成调休 + BigDecimal tiaoxiuAmount = new BigDecimal(Util.null2s(recordSet.getString("tiaoxiuamount"), "0")); + //已休 + BigDecimal usedAmount = new BigDecimal(Util.null2s(recordSet.getString("usedAmount"), "0")); + //福利年假的基数 + BigDecimal baseAmount2 = new BigDecimal(Util.null2s(recordSet.getString("baseAmount2"), "0")); + //福利年假的额外 + BigDecimal usedAmount2 = new BigDecimal(Util.null2s(recordSet.getString("usedAmount2"), "0")); + //福利年假的已休 + BigDecimal extraAmount2 = new BigDecimal(Util.null2s(recordSet.getString("extraAmount2"), "0")); + if (distributionMode == 6) { + if (baseAmount.add(extraAmount).add(tiaoxiuAmount).subtract(usedAmount).add(baseAmount2).add(extraAmount2).subtract(usedAmount2).doubleValue() <= 0) { + if(!(allow_negative_flag && index == total)){ + continue; + } + } + + baseAmount = getCanUseAmount(resourceId, ruleId, belongYear, baseAmount, "legal", fromDateDb); + baseAmount2 = getCanUseAmount(resourceId, ruleId, belongYear, baseAmount2, "welfare", fromDateDb); + } else if(distributionMode == 5||leaveOfParental){ + //不过滤前端会有扣减为0的记录 + if (baseAmount.add(extraAmount).add(tiaoxiuAmount).subtract(usedAmount).doubleValue() <= 0) { + if(!(allow_negative_flag && index == total)) { + continue; + } + } + } else{ + if (baseAmount.add(extraAmount).add(tiaoxiuAmount).subtract(usedAmount).doubleValue() <= 0) { + if(!(allow_negative_flag && index == total)) { + continue; + } + } + baseAmount = getCanUseAmount(resourceId, ruleId, belongYear, baseAmount, "", fromDateDb); + } + + logger.info("addusedamount.id="+id+",indexStatus="+indexStatus+",baseAmount="+baseAmount+",baseAmount2="+baseAmount2+",distributionMode="+distributionMode+",extraAmount="+extraAmount+",usedAmount="+usedAmount); + + //员工假期余额使用记录 + usageHistoryEntity = new KQUsageHistoryEntity(); + usageHistoryEntity.setLeaveRulesId(ruleId); + usageHistoryEntity.setRelatedId(resourceId); + usageHistoryEntity.setWfRequestId(requestId); + usageHistoryEntity.setOperator(resourceId); + usageHistoryEntity.setOperateDate(currentDate); + usageHistoryEntity.setOperateTime(currentTime); + usageHistoryEntity.setOperateType("1"); + usageHistoryEntity.setInsertOrUpdate("update"); + usageHistoryEntity.setBelongYear(belongYear); + usageHistoryEntity.setOldUsedAmount(usedAmount.setScale(5, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setOldUsedAmount2(usedAmount2.setScale(5, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setOldMinimumUnit("" + minimumUnit); + usageHistoryEntity.setNewMinimumUnit("" + minimumUnit); + usageHistoryEntity.setBelongdate(fromDateDb); + usageHistoryEntityList.add(usageHistoryEntity); + + if (distributionMode == 6) {//如果年假为混合模式(法定年假+福利年假) + if (priority == 1) {//扣减优先级:先扣减法定年假、再扣减福利年假 + BigDecimal temp = baseAmount.add(extraAmount).subtract(usedAmount).subtract(_duration); + if (temp.doubleValue() >= 0) { + String newUsedAmount = usedAmount.add(_duration).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setDuration("1");//1表示法定年假,2表示福利年假 + usageHistoryEntity.setBalanceOfLeaveId(id); + + //请假时长扣减完了重置下,以免影响下面的新增逻辑 + _duration = new BigDecimal("0"); + break; + } else { + temp = baseAmount.add(extraAmount).subtract(usedAmount).add(baseAmount2).add(extraAmount2).subtract(usedAmount2).subtract(_duration); + //该假期剩余假期余额不足以扣减,记录错误日志,退出方法 + if (index == total && temp.doubleValue() < 0) { + logger.info("该人员的该假期所有的剩余假期余额都不足以扣减。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId + + ",baseAmount=" + baseAmount.doubleValue() + ",extraAmount=" + extraAmount.doubleValue() + ",usedAmount=" + usedAmount.doubleValue() + + ",baseAmount2=" + baseAmount2.doubleValue() + ",extraAmount2=" + extraAmount2.doubleValue() + ",usedAmount2=" + usedAmount2.doubleValue()); + String newUsedAmount = baseAmount.add(extraAmount).setScale(5,RoundingMode.HALF_UP).toPlainString(); + String newUsedAmount2 = _duration.subtract(baseAmount.add(extraAmount).subtract(usedAmount)).add(usedAmount2).setScale(5, RoundingMode.HALF_UP).toString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + ",usedAmount2=" + (newUsedAmount2) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setDuration("3");//0表示不区分,1表示只扣减法定年假,2表示只扣减福利年假,3 + // 表示先扣减法定,再扣减福利。4表示先扣减福利,再扣减法定。先扣法就要后返回。3这种就先返回福利年假,后返回法定年假 + usageHistoryEntity.setBalanceOfLeaveId(id); + + //请假时长扣减完了重置下,以免影响下面的新增逻辑 + _duration = new BigDecimal("0"); + break; + } + if (temp.doubleValue() >= 0) { + String newUsedAmount = baseAmount.add(extraAmount).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String newUsedAmount2 = _duration.subtract(baseAmount.add(extraAmount).subtract(usedAmount)).add(usedAmount2).setScale(5, RoundingMode.HALF_UP).toString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + ",usedAmount2=" + (newUsedAmount2) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setDuration("3"); + usageHistoryEntity.setBalanceOfLeaveId(id); + + //请假时长扣减完了重置下,以免影响下面的新增逻辑 + _duration = new BigDecimal("0"); + break; + } else { + _duration = new BigDecimal("0").subtract(temp); + String newUsedAmount = baseAmount.add(extraAmount).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String newUsedAmount2 = baseAmount2.add(extraAmount2).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + ",usedAmount2=" + (newUsedAmount2) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntity.setDuration("3"); + } + } + } else {//扣减优先级:先扣减福利年假、再扣减法定年假 + BigDecimal temp = baseAmount2.add(extraAmount2).subtract(usedAmount2).subtract(_duration); + if (temp.doubleValue() >= 0) { + String newUsedAmount2 = usedAmount2.add(_duration).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount2=" + (newUsedAmount2) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setDuration("2"); + usageHistoryEntity.setBalanceOfLeaveId(id); + break; + } else { + temp = baseAmount2.add(extraAmount2).subtract(usedAmount2).add(baseAmount).add(extraAmount).subtract(usedAmount).subtract(_duration); + /*该假期剩余假期余额不足以扣减,记录错误日志,退出方法*/ + if (index == total && temp.doubleValue() < 0) { + logger.info("该人员的该假期所有的剩余假期余额都不足以扣减。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId + + ",baseAmount=" + baseAmount.doubleValue() + ",extraAmount=" + extraAmount.doubleValue() + ",usedAmount=" + usedAmount.doubleValue() + + ",baseAmount2=" + baseAmount2.doubleValue() + ",extraAmount2=" + extraAmount2.doubleValue() + ",usedAmount2=" + usedAmount2.doubleValue()); + String newUsedAmount2 = baseAmount2.add(extraAmount2).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String newUsedAmount = _duration.subtract(baseAmount2.add(extraAmount2).subtract(usedAmount2)).add(usedAmount).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount2=" + (newUsedAmount2) + ",usedAmount=" + (newUsedAmount) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setDuration("4"); + usageHistoryEntity.setBalanceOfLeaveId(id); + + //请假时长扣减完了重置下,以免影响下面的新增逻辑 + _duration = new BigDecimal("0"); + break; + } + if (temp.doubleValue() >= 0) { + String newUsedAmount2 = baseAmount2.add(extraAmount2).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String newUsedAmount = _duration.subtract(baseAmount2.add(extraAmount2).subtract(usedAmount2)).add(usedAmount).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount2=" + (newUsedAmount2) + ",usedAmount=" + (newUsedAmount) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setDuration("4"); + usageHistoryEntity.setBalanceOfLeaveId(id); + + //请假时长扣减完了重置下,以免影响下面的新增逻辑 + _duration = new BigDecimal("0"); + break; + } else { + _duration = new BigDecimal("0").subtract(temp); + String newUsedAmount2 = baseAmount2.add(extraAmount2).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String newUsedAmount = baseAmount.add(extraAmount).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount2=" + (newUsedAmount2) + ",usedAmount=" + (newUsedAmount) + ", update_time=? where id=" + id; + updateList.add(updateSql); + usageHistoryEntity.setDuration("4"); + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setBalanceOfLeaveId(id); + + } + } + } + } else {//非混合模式 + BigDecimal temp = baseAmount.add(extraAmount).add(tiaoxiuAmount).subtract(usedAmount).subtract(_duration); + logger.info("addusedamount.temp="+temp+",index="+index+",total="+total); + /*该假期剩余假期余额不足以扣减,记录错误日志,退出方法*/ + if (index == total && temp.doubleValue() < 0) { + logger.info("该人员的该假期所有的剩余假期余额都不足以扣减。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId + + ",baseAmount=" + baseAmount.doubleValue() + ",extraAmount=" + extraAmount.doubleValue() + ",usedAmount=" + usedAmount.doubleValue()); + String newUsedAmount = usedAmount.add(_duration).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + logger.info("addusedamount.updateSql1="+updateSql); + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntity.setDuration("0"); + //请假时长扣减完了重置下,以免影响下面的新增逻辑 + _duration = new BigDecimal("0"); + break; + } + if (temp.doubleValue() >= 0) { + String newUsedAmount = usedAmount.add(_duration).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + logger.info("addusedamount.updateSql2="+updateSql); + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntity.setDuration("0"); + //请假时长扣减完了重置下,以免影响下面的新增逻辑 + _duration = new BigDecimal("0"); + break; + } else { + _duration = new BigDecimal("0").subtract(temp); + String newUsedAmount = baseAmount.add(extraAmount).add(tiaoxiuAmount).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + ", update_time=? where id=" + id; + updateList.add(updateSql); + usageHistoryEntity.setDuration("0"); + logger.info("addusedamount.updateSql3="+updateSql); + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setBalanceOfLeaveId(id); + continue; + } + } + } + + //index=0表示没有假期数据 + if (allow_negative_flag && (index == 0 || indexStatus==1)) { + //所属年份 + String belongYear = fromDateDb.substring(0, 4); + //基数 + BigDecimal baseAmount = new BigDecimal("0"); + //额外 + BigDecimal extraAmount = new BigDecimal("0"); + //加班生成调休 + BigDecimal tiaoxiuAmount = new BigDecimal("0"); + //已休 + BigDecimal usedAmount = new BigDecimal("0"); + + if(_duration.doubleValue()>0){ + //员工假期余额使用记录 + usageHistoryEntity = new KQUsageHistoryEntity(); + usageHistoryEntity.setLeaveRulesId(ruleId); + usageHistoryEntity.setRelatedId(resourceId); + usageHistoryEntity.setWfRequestId(requestId); + usageHistoryEntity.setOperator(resourceId); + usageHistoryEntity.setOperateDate(currentDate); + usageHistoryEntity.setOperateTime(currentTime); + usageHistoryEntity.setOperateType("1"); + usageHistoryEntity.setInsertOrUpdate("insert"); + usageHistoryEntity.setBelongYear(belongYear); + usageHistoryEntity.setOldUsedAmount("0"); + usageHistoryEntity.setOldMinimumUnit("" + minimumUnit); + usageHistoryEntity.setNewMinimumUnit("" + minimumUnit); + usageHistoryEntity.setDuration("0"); + usageHistoryEntity.setBelongdate(fromDateDb); + usageHistoryEntityList.add(usageHistoryEntity); + + + //非混合模式 + BigDecimal temp = baseAmount.add(extraAmount).add(tiaoxiuAmount).subtract(usedAmount).subtract(_duration); + /*该假期剩余假期余额不足以扣减,记录错误日志,退出方法*/ + if (temp.doubleValue() < 0) { + logger.info("该人员的该假期所有的剩余假期余额都不足以扣减。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId + + ",baseAmount=" + baseAmount.doubleValue() + ",extraAmount=" + extraAmount.doubleValue() + ",usedAmount=" + usedAmount.doubleValue()); + String newUsedAmount = usedAmount.add(_duration).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "INSERT INTO KQ_BalanceOfLeave(resourceId,leaveRulesId,belongYear,baseAmount,extraAmount,usedAmount,effectiveDate, update_time) " + + "VALUES(" + resourceId + "," + ruleId + ",'" + belongYear + "',0,0," + newUsedAmount + ",'" + fromDateDb + "',?)"; + if (recordSet.getDBType().equals("postgresql")) { + updateSql = "INSERT INTO KQ_BalanceOfLeave(resourceId,leaveRulesId,belongYear,baseAmount,extraAmount,usedAmount,effectiveDate, update_time) " + + "VALUES(" + resourceId + "," + ruleId + ",'" + belongYear + "',0,0," + newUsedAmount + ",'" + fromDateDb + "',?::timestamp)"; + } +// updateList.add(updateSql); + recordSet.executeUpdate(updateSql,updateDate); + //获取刚才插入的调休明细的ID + sql = "select max(id) from kq_balanceOfLeave where leaveRulesId=? and resourceId=? and " + + "belongYear=? and usedAmount=? "; + recordSet.executeQuery(sql, ruleId, resourceId, belongYear,newUsedAmount); + if (recordSet.next()) { + usageHistoryEntity.setBalanceOfLeaveId(recordSet.getString(1)); + } + logger.info("addusedamount.updateSql4="+updateSql); + } + } + } + + logger.info("requestId:"+requestId+"::updateList:"+updateList); + /*SQL操作批处理*/ + for (int i = 0; i < updateList.size(); i++) { + flag = recordSet.executeUpdate(updateList.get(i),updateDate); + if (!flag) { + logger.info("员工提交请假流程累计已休假期的SQL执行失败。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + return; + } + } + /*记录假期使用记录*/ + if (flag && usageHistoryEntityList.size() > 0) { + KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz(); + flag = usageHistoryBiz.save(usageHistoryEntityList); + if (!flag) { + logger.info("请假流程,员工假期余额变更记录SQL执行失败。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + } + } + } catch (Exception e) { + logger.info(e.getMessage()); + logger.info("请假流程扣减出错。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + } + } + + /** + * 销假流程归档时,需要将曾经扣减的假期余额返还给相应人员 + * + * @param resourceId 指定人员ID + * @param date 指定日期 + * 根据日期取指定指定日期年份之前的所有有效的余额,传入空值则取所有年份的有效余额 + * @param ruleId 指定假期规则 + * @param duration 请假时长 + * @param type 时长类型:1-小时、2-天 + * 传入空值则默认取假期规则设置中的单位 + * @param requestId 请假流程的requestId + * @return + */ +// public static void reduceUsedAmount(String resourceId, String date, String ruleId, String duration, String type, String requestId) { +// KQBalanceOfLeaveBiz.reduceUsedAmount(resourceId, date, ruleId, duration, type,requestId,null); +// } + public static void reduceUsedAmount(String resourceId, String date, String ruleId, String duration, String type, String requestId, String back_requestid) { + try { + if(Util.getDoubleValue(duration) <= 0) { + logger.info("时长为0不做返还。resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + return; + } + java.sql.Timestamp updateDate = KQDateUtil.getUpdateTimeStamp(); + /*获取当前日期,当前时间*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + + /****************************************************************************************************************/ + + //人力资源缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + //分部 + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + /****************************************************************************************************************/ + logger.info("reduceUsedAmount:resourceId:"+resourceId+":fromdatedb:"+date+":newLeaveType:"+ruleId+":duration:"+duration+":requestid:"+requestId+":back_requestid:"+back_requestid); + + //假期规则缓存类 + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + //最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假 + int minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(ruleId)); + //最小请假单位获取有误,记录错误日志,直接退出方法 + if (minimumUnit < 1 || minimumUnit > 6) { + logger.info("最小请假单位获取有误。resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + return; + } + //是否启用假期余额:0-不启用、1-启用 + int balanceEnable = Util.getIntValue(rulesComInfo.getBalanceEnable(ruleId), 0); + //该假期未开启假期余额,记录错误日志,退出方法 + if (balanceEnable != 1) { + logger.info("该假期未开启假期余额。resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + return; + } + //前台传回的请假时长类型与后台设置的假期限制的最小请假单位不相符,暂不支持转换,记录错误日志,直接退出方法 + boolean flag = type.equals("") || ("1".equals(type) && KQUnitBiz.isLeaveHour(minimumUnit+"")) || ("2".equals(type) && (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4)); + if (!flag) { + logger.info("前台传回的请假时长类型与后台设置的请假类型限制的最小请假单位不相符。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + return; + } + + /****************************************************************************************************************/ + + //假期规则缓存类(每个假期类型下可能存在多个假期规则) + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //余额发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按入职时长+工龄自动发放 + int distributionMode = Util.getIntValue(detailComInfo.getDistributionMode(ruleId, subcompanyId, departmentId, resourceId)); + //扣减优先级:1-法定年假、2-福利年假 + int priority = Util.getIntValue(detailComInfo.getDistributionMode(ruleId, subcompanyId, departmentId, resourceId)); + + /****************************************************************************************************************/ + + logger.info("reduceUsedAmount:distributionMode:"+distributionMode+":priority:"+priority); + + //员工假期余额变更记录 + KQUsageHistoryEntity usageHistoryEntity = new KQUsageHistoryEntity(); + + List usageHistoryEntityList = new ArrayList(); + + + String balanceOfLeaveIds = ""; + + Map leaveInfoMap = new HashMap<>(); + if(null != back_requestid && back_requestid.length()>0){ + int decimalDigit = 2; + RecordSet rs1 = new RecordSet(); + String historySql = "select * from kq_usagehistory where relatedId='"+resourceId+"' and leaveRulesId" + + "='"+ruleId+"' and wfRequestId='"+back_requestid+"' and belongdate='"+date+"'"; + rs1.executeQuery(historySql); + logger.info("reduceUsedAmount:historySql:"+historySql); + while (rs1.next()){ + String balanceOfLeaveId = Util.null2String(rs1.getString("balanceOfLeaveId")); + balanceOfLeaveIds += ","+balanceOfLeaveId; + String durationType = Util.null2String(rs1.getString("duration"));//0-不区分,1法定,2福利,3先法定后福利,4先福利后法定。 + + /*操作之前的员工已休假期余额*/ + BigDecimal _oldUsedAmount = new BigDecimal(Util.getDoubleValue(rs1.getString("oldUsedAmount"), 0)); + /*操作之后的员工已休假期余额*/ + BigDecimal _newUsedAmount = new BigDecimal(Util.getDoubleValue(rs1.getString("newUsedAmount"), 0)); + BigDecimal usedAmount = _newUsedAmount.subtract(_oldUsedAmount).setScale(decimalDigit, + RoundingMode.HALF_UP); + + /*操作之前的员工已休福利年假*/ + BigDecimal _oldUsedAmount2 = new BigDecimal(Util.getDoubleValue(rs1.getString("oldUsedAmount2"), 0)); + + /*操作之后的员工已休福利年假*/ + BigDecimal _newUsedAmount2 = new BigDecimal(Util.getDoubleValue(rs1.getString("newUsedAmount2"), 0)); + BigDecimal usedAmount2 = _newUsedAmount2.subtract(_oldUsedAmount2).setScale(decimalDigit, + RoundingMode.HALF_UP); + KQLeaveInfoEntity kqLeaveInfoEntity = new KQLeaveInfoEntity(); + kqLeaveInfoEntity.setBalanceOfLeaveId(balanceOfLeaveId); + kqLeaveInfoEntity.setDurationType(durationType); + kqLeaveInfoEntity.setUsedAmount(usedAmount); + kqLeaveInfoEntity.setUsedAmount2(usedAmount2); + leaveInfoMap.put(balanceOfLeaveId, kqLeaveInfoEntity); + } + } + logger.info("reduceUsedAmount:deductYear:"+balanceOfLeaveIds); + + BigDecimal _duration = new BigDecimal(Util.null2s(duration, "0")); + List updateList = new ArrayList(); + RecordSet recordSet = new RecordSet(); + String sql = "select * from kq_balanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and resourceId=" + resourceId + " order by belongYear desc"; + if(null != balanceOfLeaveIds && balanceOfLeaveIds.length()>0){ + balanceOfLeaveIds = balanceOfLeaveIds.startsWith(",")?balanceOfLeaveIds.substring(1):balanceOfLeaveIds; + sql = "select * from kq_balanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and resourceId=" + resourceId + + " and id in ("+balanceOfLeaveIds+") "; + } + boolean leaveOfParental = KQLeaveRulesBiz.isLeaveOfParentalNum(ruleId); + if(distributionMode == 5||leaveOfParental){ + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") + || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql = "select * from kq_balanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and resourceId=" + resourceId + " and (expirationDate is null or expirationDate='' or expirationDate>='" + date + "') order by belongYear asc, expirationDate asc, id asc "; + if(null != balanceOfLeaveIds && balanceOfLeaveIds.length()>0){ + //上面已经截取了一次,导致将下面的balanceOfLeaveIds不对,销假失败 + balanceOfLeaveIds = balanceOfLeaveIds.startsWith(",")?balanceOfLeaveIds.substring(1):balanceOfLeaveIds; + sql = "select * from kq_balanceOfLeave where (isDelete is null or isDelete<>1) and " + + "leaveRulesId=" + ruleId + " and resourceId=" + resourceId + " and (expirationDate is null or expirationDate='' or expirationDate>='" + date + "') and id in ("+balanceOfLeaveIds+") "; + } + } else { + sql = "select * from kq_balanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and resourceId=" + resourceId + " and (expirationDate is null or expirationDate>='" + date + "') order by belongYear asc, expirationDate asc, id asc "; + if(null != balanceOfLeaveIds && balanceOfLeaveIds.length()>0){ + //上面已经截取了一次,导致将下面的balanceOfLeaveIds不对,销假失败 + balanceOfLeaveIds = balanceOfLeaveIds.startsWith(",")?balanceOfLeaveIds.substring(1):balanceOfLeaveIds; + sql = "select * from kq_balanceOfLeave where (isDelete is null or isDelete<>1) and " + + "leaveRulesId=" + ruleId + " and resourceId=" + resourceId + " and (expirationDate is null or expirationDate>='" + date + "') and id in ("+balanceOfLeaveIds+") "; + } + } + + } + recordSet.executeQuery(sql); + int total = recordSet.getCounts(); + int index = 0; + logger.info("reduceUsedAmount:sql:"+sql); + while (recordSet.next()) { + index++; + // + String id = recordSet.getString("id"); + KQLeaveInfoEntity storedEntity = leaveInfoMap.get(id); + //所属年份 + String belongYear = recordSet.getString("belongYear"); + //已休 + BigDecimal usedAmount = new BigDecimal(Util.null2s(recordSet.getString("usedAmount"), "0")); + //福利年假的已休 + BigDecimal usedAmount2 = new BigDecimal(Util.null2s(recordSet.getString("usedAmount2"), "0")); + + //记录使用记录 + usageHistoryEntity = new KQUsageHistoryEntity(); + usageHistoryEntity.setLeaveRulesId(ruleId); + usageHistoryEntity.setRelatedId(resourceId); + usageHistoryEntity.setWfRequestId(requestId); + usageHistoryEntity.setOperator(resourceId); + usageHistoryEntity.setOperateDate(currentDate); + usageHistoryEntity.setOperateTime(currentTime); + usageHistoryEntity.setOperateType("2"); + usageHistoryEntity.setInsertOrUpdate("update"); + usageHistoryEntity.setBelongYear(belongYear); + usageHistoryEntity.setOldUsedAmount(usedAmount.setScale(5, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setOldUsedAmount2(usedAmount2.setScale(5, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setOldMinimumUnit("" + minimumUnit); + usageHistoryEntity.setNewMinimumUnit("" + minimumUnit); + + if (distributionMode == 6) {//如果年假为混合模式(法定年假+福利年假) + if (storedEntity != null) { + BigDecimal storedUsedAmount = storedEntity.getUsedAmount() != null + ? storedEntity.getUsedAmount() : BigDecimal.ZERO; + BigDecimal storedUsedAmount2 = storedEntity.getUsedAmount2() != null + ? storedEntity.getUsedAmount2() : BigDecimal.ZERO; + String durationType = storedEntity.getDurationType() != null + ? storedEntity.getDurationType() : ""; + switch(durationType) { + case "1": // 销假返回给法定 + deductSingleField(id, "usedAmount",usageHistoryEntity,storedUsedAmount, + usedAmount,_duration,updateList,usageHistoryEntityList,usedAmount2); + break; + case "2": // 销假返回给福利 + deductSingleField(id,"usedAmount2",usageHistoryEntity,storedUsedAmount2, + usedAmount2,_duration,updateList,usageHistoryEntityList,usedAmount); + break; + case "3": // 销假先福利后法定 + deductCombined(id, "usedAmount", "usedAmount2",usageHistoryEntity,storedUsedAmount, + storedUsedAmount2, + usedAmount,_duration,updateList,usageHistoryEntityList,usedAmount2,1); + break; + case "4": // 先法定后福利 + deductCombined(id, "usedAmount", "usedAmount2",usageHistoryEntity,storedUsedAmount, + storedUsedAmount2, + usedAmount,_duration,updateList,usageHistoryEntityList,usedAmount2,2); + break; + default: + logger.info("未知的扣减类型:{}"+durationType); + } + + }else { + if (priority == 1) { + BigDecimal temp = usedAmount.subtract(_duration); + logger.info("reduceUsedAmount:id1:" + id + ":belongYear:" + belongYear + ":usedAmount:" + usedAmount + ":usedAmount2:" + usedAmount2 + ":temp1:" + temp); + if (temp.doubleValue() >= 0) { + String newUsedAmount = temp.setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + newUsedAmount + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setNewUsedAmount2(usedAmount2.setScale(5, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + break; + } else { + temp = usedAmount.add(usedAmount2).subtract(_duration); + logger.info("reduceUsedAmount:id2:" + id + ":belongYear:" + belongYear + ":usedAmount:" + usedAmount + ":usedAmount2:" + usedAmount2 + ":temp2:" + temp); + /*此次销假流程的销假天数大于了他的已休假期,流程参数有误*/ + if (index == total && temp.doubleValue() < 0) { + String newUsedAmount = "0"; + String newUsedAmount2 = temp.setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=0,usedAmount2=" + newUsedAmount2 + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + + logger.info("此次销假流程的销假天数大于了他的已休假期,流程参数有误。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + break; + } + if (temp.doubleValue() >= 0) { + String newUsedAmount = "0"; + String newUsedAmount2 = temp.setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=0,usedAmount2=" + newUsedAmount2 + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + break; + } else { + _duration = new BigDecimal("0").subtract(temp); + String updateSql = "update kq_balanceOfLeave set usedAmount=0,usedAmount2=0,update_time=? where id=" + id; + if (recordSet.getDBType().equals("postgresql")) { + updateSql = "update kq_balanceOfLeave set usedAmount=0,usedAmount2=0,update_time=?::timestamp where id=" + id; + } + updateList.add(updateSql); + + if (usedAmount.doubleValue() != 0 || usedAmount2.doubleValue() != 0) { + usageHistoryEntity.setNewUsedAmount("0"); + usageHistoryEntity.setNewUsedAmount2("0"); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + } + + } + } + } else { + BigDecimal temp = usedAmount2.subtract(_duration); + if (temp.doubleValue() >= 0) { + String newUsedAmount2 = temp.setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount2=" + newUsedAmount2 + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setNewUsedAmount(usedAmount.setScale(5, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + break; + } else { + temp = usedAmount2.add(usedAmount).subtract(_duration); + /*此次销假流程的销假天数大于了他的已休假期,流程参数有误*/ + if (index == total && temp.doubleValue() < 0) { + String newUsedAmount = temp.setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount2=0,usedAmount=" + newUsedAmount + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount2("0.00"); + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + + logger.info("此次销假流程的销假天数大于了他的已休假期,流程参数有误。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + break; + } + if (temp.doubleValue() >= 0) { + String newUsedAmount = temp.setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount2=0,usedAmount=" + newUsedAmount + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount2("0.00"); + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + break; + } else { + _duration = new BigDecimal("0").subtract(temp); + String updateSql = "update kq_balanceOfLeave set usedAmount=0,usedAmount2=0,update_time=? where id=" + id; + if (recordSet.getDBType().equals("postgresql")) { + updateSql = "update kq_balanceOfLeave set usedAmount=0,usedAmount2=0,update_time=?::timestamp where id=" + id; + } + updateList.add(updateSql); + + if (usedAmount.doubleValue() != 0 || usedAmount2.doubleValue() != 0) { + usageHistoryEntity.setNewUsedAmount2("0"); + usageHistoryEntity.setNewUsedAmount("0"); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + } + + } + } + } + } + } else {//非混合模式 + if (storedEntity != null) { + BigDecimal storedUsedAmount = storedEntity.getUsedAmount() != null + ? storedEntity.getUsedAmount() : BigDecimal.ZERO; +// if (usedAmount.subtract(storedUsedAmount).doubleValue() >= 0){ +// usedAmount = storedUsedAmount; +// }else{ +// logger.info("此次销假流程的销假天数大于了他的已休假期,流程参数有误。" + +// "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",假期余额id=" + id +// + ",duration=" + duration + ",requestId=" + requestId + ",storedUsedAmount=" + storedUsedAmount + ",usedAmount=" + usedAmount); +// +// } + deductSingleField(id, "usedAmount",usageHistoryEntity,storedUsedAmount, + usedAmount,_duration,updateList,usageHistoryEntityList,usedAmount2); + }else { + BigDecimal temp = usedAmount.subtract(_duration); + /*此次销假流程的销假天数大于了他的已休假期,流程参数有误*/ + if (index == total && temp.doubleValue() < 0) { + String newUsedAmount = temp.setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + newUsedAmount + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + + logger.info("此次销假流程的销假天数大于了他的已休假期,流程参数有误。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + break; + } + if (temp.doubleValue() >= 0) { + String newUsedAmount = temp.setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + newUsedAmount + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + break; + } else { + _duration = new BigDecimal("0").subtract(temp); + String updateSql = "update kq_balanceOfLeave set usedAmount=0, update_time=? where id=" + id; + updateList.add(updateSql); + + if (usedAmount.doubleValue() != 0) { + usageHistoryEntity.setNewUsedAmount("0"); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + } + + } + } + + } + } + + logger.info("requestId:"+requestId+"::updateList:"+updateList); + /*SQL操作批处理*/ + for (int i = 0; i < updateList.size(); i++) { + flag = recordSet.executeUpdate(updateList.get(i),updateDate); + if (!flag) { + logger.info("提交销假流程,回退员工假期余额SQL执行失败。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + return; + } + } + /*记录假期使用记录*/ + if (flag && usageHistoryEntityList.size() > 0) { + KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz(); + flag = usageHistoryBiz.save(usageHistoryEntityList); + if (!flag) { + logger.info("提交销假流程,员工假期余额变更记录SQL执行失败。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + + } + } + } catch (Exception e) { + logger.info(e.getMessage()); + logger.info("销假流程恢复假期余额报错。" + + "resourceId=" + resourceId + ",date=" + date + ",ruleId=" + ruleId + ",type=" + type + ",duration=" + duration + ",requestId=" + requestId); + + } + } + + // 单字段扣减逻辑 deductSingleField(id, "usedAmount",usageHistoryEntity,storedUsedAmount, + // usedAmount,_duration,updateList,usageHistoryEntityList); + private static void deductSingleField(String id, String field, KQUsageHistoryEntity usageHistoryEntity, + BigDecimal storedUsedAmount, BigDecimal usedAmount, BigDecimal _duration, + List updateList, List usageHistoryEntityList, + BigDecimal usedAmount2) { + BigDecimal temp = usedAmount.subtract(storedUsedAmount); + if (temp.compareTo(BigDecimal.ZERO) >= 0) { + temp = storedUsedAmount.subtract(_duration); + if (temp.compareTo(BigDecimal.ZERO) >= 0) { + logger.info("reduceUsedAmount:id1:" + id + ":belongYear:" + ":usedAmount:" + usedAmount + + ":usedAmount2:" + ":temp1:" + temp); + + String newUsedAmount = + usedAmount.subtract(_duration).setScale(2, RoundingMode.HALF_UP).toPlainString(); + String updateSql = + "update kq_balanceOfLeave set " + field + "=" + newUsedAmount + ", update_time=? where id=" + id; + if (new RecordSet().getDBType().equals("postgresql")) { + updateSql = "update kq_balanceOfLeave set " + field + "=" + newUsedAmount + ", update_time" + + "=?::timestamp where id=" + id; + } + updateList.add(updateSql); + + if(field.equalsIgnoreCase("usedAmount")){ + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setNewUsedAmount2(usedAmount2.setScale(5, RoundingMode.HALF_UP).toPlainString()); + }else{ + usageHistoryEntity.setNewUsedAmount2(newUsedAmount); + usageHistoryEntity.setNewUsedAmount(usedAmount2.setScale(5, RoundingMode.HALF_UP).toPlainString()); + } + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + + } else { + + String newUsedAmount = + usedAmount.subtract(storedUsedAmount).setScale(2, RoundingMode.HALF_UP).toPlainString(); + String updateSql = + "update kq_balanceOfLeave set " + field + "=" + newUsedAmount + ", update_time=? where id=" + id; + if (new RecordSet().getDBType().equals("postgresql")) { + updateSql = "update kq_balanceOfLeave set " + field + "=" + newUsedAmount + ", update_time" + + "=?::timestamp where id=" + id; + } + updateList.add(updateSql); + if(field.equalsIgnoreCase("usedAmount")){ + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setNewUsedAmount2(usedAmount2.setScale(5, RoundingMode.HALF_UP).toPlainString()); + }else{ + usageHistoryEntity.setNewUsedAmount2(newUsedAmount); + usageHistoryEntity.setNewUsedAmount(usedAmount2.setScale(5, RoundingMode.HALF_UP).toPlainString()); + } + + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + _duration = _duration.subtract(storedUsedAmount); + + } + } else { + logger.info("销假报错,法定年假已休没有请假记录当时的已休数据了。假期余额id=" + id); + } + } + + // 组合扣减逻辑id, "usedAmount", "usedAmount2",usageHistoryEntity,storedUsedAmount, + // storedUsedAmount2, + // usedAmount,_duration,updateList,usageHistoryEntityList,usedAmount2 + private static void deductCombined(String id, String field1, String field2,KQUsageHistoryEntity usageHistoryEntity, + BigDecimal storedUsedAmount, BigDecimal storedUsedAmount2, BigDecimal usedAmount, BigDecimal _duration, + List updateList, List usageHistoryEntityList, + BigDecimal usedAmount2,int priority) { + BigDecimal temp1 = usedAmount.subtract(storedUsedAmount); + BigDecimal temp2 = usedAmount2.subtract(storedUsedAmount2); + if (temp1.compareTo(BigDecimal.ZERO) >= 0 && temp2.compareTo(BigDecimal.ZERO) >= 0) { + if (priority == 1) { + BigDecimal temp = storedUsedAmount2.subtract(_duration); + if (temp.compareTo(BigDecimal.ZERO) >= 0) { + logger.info("reduceUsedAmount:id1:" + id + ":belongYear:" + ":usedAmount:" + usedAmount + + ":usedAmount2:" + ":temp1:" + temp); + + String newUsedAmount2 = + usedAmount2.subtract(_duration).setScale(2, RoundingMode.HALF_UP).toPlainString(); + String updateSql = + "update kq_balanceOfLeave set " + field2 + "=" + newUsedAmount2 + ", update_time=? where " + + "id=" + id; + if (new RecordSet().getDBType().equals("postgresql")) { + updateSql = "update kq_balanceOfLeave set " + field2 + "=" + newUsedAmount2 + ", update_time" + + "=?::timestamp where id=" + id; + } + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount(usedAmount.setScale(2, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + _duration = new BigDecimal("0"); + } else { + + String newUsedAmount2 = + usedAmount2.subtract(storedUsedAmount2).setScale(2, RoundingMode.HALF_UP).toPlainString(); + + BigDecimal _duration2 = _duration.subtract(storedUsedAmount2); + + String newUsedAmount =usedAmount.toPlainString(); + if(_duration2.compareTo(BigDecimal.ZERO) > 0){ + temp = storedUsedAmount.subtract(_duration2); + if (temp.compareTo(BigDecimal.ZERO) >= 0) { + newUsedAmount = usedAmount.subtract(_duration2).setScale(2, RoundingMode.HALF_UP).toPlainString(); + _duration = new BigDecimal("0"); + } else { + newUsedAmount = + usedAmount.subtract(storedUsedAmount).setScale(2, RoundingMode.HALF_UP).toPlainString(); + _duration = _duration2.subtract(storedUsedAmount); + } + } + + String updateSql = "update kq_balanceOfLeave set " + field1 + "=" + newUsedAmount + ","+ field2 + "=" + + newUsedAmount2 +", update_time=? where " + + "id=" + id; + if (new RecordSet().getDBType().equals("postgresql")) { + updateSql = "update kq_balanceOfLeave set " + field1 + "=" + newUsedAmount + ","+ field2 + "=" + + newUsedAmount2 + ", update_time" + + "=?::timestamp where id=" + id; + + } + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + + updateList.add(updateSql); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + } + } else { + BigDecimal temp = storedUsedAmount.subtract(_duration); + if (temp.compareTo(BigDecimal.ZERO) >= 0) { + logger.info("reduceUsedAmount:id1:" + id + ":belongYear:" + ":usedAmount:" + usedAmount + + ":usedAmount2:" + ":temp1:" + temp); + + String newUsedAmount = + usedAmount.subtract(_duration).setScale(2, RoundingMode.HALF_UP).toPlainString(); + String updateSql = + "update kq_balanceOfLeave set " + field1 + "=" + newUsedAmount + ", update_time=? where " + + "id=" + id; + if (new RecordSet().getDBType().equals("postgresql")) { + updateSql = "update kq_balanceOfLeave set " + field1 + "=" + newUsedAmount + ", update_time" + + "=?::timestamp where id=" + id; + } + updateList.add(updateSql); + + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setNewUsedAmount2(usedAmount2.setScale(2, RoundingMode.HALF_UP).toPlainString()); + + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + _duration = new BigDecimal("0"); + } else { + + String newUsedAmount = + usedAmount.subtract(storedUsedAmount).setScale(2, RoundingMode.HALF_UP).toPlainString(); + + + BigDecimal _duration2 = _duration.subtract(storedUsedAmount); + + temp = storedUsedAmount2.subtract(_duration); + String newUsedAmount2 =usedAmount2.toPlainString(); + if(_duration2.compareTo(BigDecimal.ZERO) > 0) { + if (temp.compareTo(BigDecimal.ZERO) >= 0) { + newUsedAmount2 = + usedAmount2.subtract(_duration2).setScale(2, RoundingMode.HALF_UP).toPlainString(); + _duration = new BigDecimal("0"); + } else { + newUsedAmount2 = + usedAmount2.subtract(storedUsedAmount2).setScale(2, RoundingMode.HALF_UP).toPlainString(); + _duration = _duration2.subtract(storedUsedAmount2); + } + } + String updateSql = + "update kq_balanceOfLeave set " + field1 + "=" + newUsedAmount + "," + field2 + "=" + + newUsedAmount2 + ", update_time=? where " + + "id=" + id; + if (new RecordSet().getDBType().equals("postgresql")) { + updateSql = "update kq_balanceOfLeave set " + field1 + "=" + newUsedAmount + "," + field2 + "=" + + newUsedAmount2 + ", update_time" + + "=?::timestamp where id=" + id; + + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + } + updateList.add(updateSql); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + } + } + } else { + logger.info("销假报错,法定年假已休没有请假记录当时的已休数据了。假期余额id=" + id); + } + } + + + + + /** + * 初始化系统内所有假期的假期余额 + */ + public static void createBalanceOfLeave() { + try { + Calendar today = Calendar.getInstance(); + String currentYear = Util.add0(today.get(Calendar.YEAR), 4); + today.add(Calendar.YEAR,-1); + String lastYear = Util.add0(today.get(Calendar.YEAR), 4); + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + kqLeaveRulesComInfo.setTofirstRow(); + while (kqLeaveRulesComInfo.next()) { + if (!kqLeaveRulesComInfo.getIsEnable().equals("1") || !kqLeaveRulesComInfo.getBalanceEnable().equals("1")) { + continue; + } + createData(kqLeaveRulesComInfo.getId(), currentYear, 0, "", "1"); + + // createData(kqLeaveRulesComInfo.getId(), lastYear, 0, "", "1"); + + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 批处理指定机构的指定假期的指定年份的假期余额 + * + * @param leaveRulesId 指定假期类型的ID(对应的是数据库表kq_LeaveRules的主键ID) + * @param belongYear 指定的所属年份(格式yyyy) + * @param organizationType 机构类型:0-总部、1-分部、2-部门 + * @param organizationIds 指定机构的ID(例如当机构类型为分部时,此为分部ID) + * @param operator 批处理的操作人员的人员ID(-1表示是系统定时任务自动批处理) + * @return false--批处理失败、true--批处理成功 + */ + public static boolean createData(String leaveRulesId, String belongYear, int organizationType, String organizationIds, String operator) { + return createData(leaveRulesId, belongYear, organizationType, organizationIds, operator, false); + } + + /** + * 批处理指定机构的指定假期的指定年份的假期余额 + * + * @param ruleId 指定假期类型的ID(对应的是数据库表kq_LeaveRules的主键ID) + * @param belongYear 指定的所属年份(格式yyyy) + * @param organizationType 机构类型:0-总部、1-分部、2-部门 + * @param organizationIds 指定机构的ID(例如当机构类型为分部时,此为分部ID) + * @param operator 批处理的操作人员的人员ID(-1表示是系统定时任务自动批处理) + * @param canUpdate 是否按照规则更新员工的假期余额基数 + * 因为员工的假期基数可以编辑,会出现和规则计算得出的值不一致的情况,只有当假期规则发生变动的情况时,才会按照最新的规则更新员工的假期基数 + * @return false--批处理失败、true--批处理成功 + */ + public static boolean createData(String ruleId, String belongYear, int organizationType, String organizationIds, String operator, boolean canUpdate) { + boolean isSuccess = true; + try { + //假期类型缓存类 + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + //最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假 + String minimumUnit = rulesComInfo.getMinimumUnit(ruleId); + //假期类型的标识 + String leaveCode = rulesComInfo.getLeaveCode(ruleId); + + //假期规则缓存类 + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //假期规则的ID + String rulesDetailId = ""; + //余额发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按入职时长+工龄自动发放、7-按司龄自动发放(入职日期当天发放余额) + int distributionMode = 1; + //每人发放小时(天)数(当余额发放方式为每年自动发放固定天数时有效) + double annualAmount = 0; + //法定年假规则(当distributionMode=6时有效):0-工龄、1-司龄、2-工龄+司龄 + int legalKey = 0; + //福利年假规则(当distributionMode=6时有效):0-工龄、1-司龄、2-工龄+司龄 + int welfareKey = 1; + //年假基数计算方式: + // 0-假期基数发放日期和假期基数变动日期均为每年的01月01号(但是假期基数是结合 司龄/工龄 变化前后的值按天数比例折算出来的)、 + // 1-假期基数发放日期和假期基数变动日期均为每年的01月01号、 + // 2-假期基数发放日期发放日期为每年的01月01号,假期基数的变动日期为每年的 入职日期/参加工作日期 + int calcMethod = 0; + //假期基数的折算方式 + int convertMode = 0; + + //多孩叠加开关。 + int severalChildren = 0; + + //孩子多少周岁前发放。默认3岁 + int yearsOld = 3; + + int validityRule = 1; + + //是否按照省份发放育儿假。1否,2是 + String isprovince = "1"; + + //假期基数的小数位数 + int decimalDigit = 2; + //次账号是否能享受此假期:0-排除,即次账号不能享受此假期、1-不排除,即次账号正常享受此假期 + int excludeSubAccount = 1; + //转正之前是否能享受此假期:0-不允许、1-允许 + int beforeFormal = 1; + + //假期基数 + double baseAmount = 0.00; + //福利年假(当distributionMode=6时才有作用) + double baseAmount2 = 0.00; + //系统内原来的假期基数的合集 + Map oldBalanceEntities = getBalanceEntities(organizationType, organizationIds, ruleId, belongYear); + //员工假期余额实体类 + KQBalanceOfLeaveEntity oldBalanceEntity = null; + //此次批处理新计算的假期基数的合集 + List newBalanceEntities = new ArrayList(); + //员工假期余额实体类 + KQBalanceOfLeaveEntity newBalanceEntity = null; + // + Map params = null; + //今天的日期 + String currentDate = DateUtil.getCurrentDate(); + + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + //是否开启了人力资源模块的管理分权 + boolean isUseHrmManageDetach = manageDetachComInfo.isUseHrmManageDetach(); + + boolean addOrUpdate = false; + String expirationDate =DateUtil.getCurrentDate(); + String effectiveDate =""; + String belongYearTemp = belongYear; + String belongYearNew =""; + + String sql = " select * from HrmResource where status in (0,1,2,3) "; + if (organizationType == 1) { + sql += " and subCompanyId1 in (" + organizationIds + ") "; + } else if (organizationType == 2) { + sql += " and departmentId in (" + organizationIds + ") "; + } else if (organizationType == 3) { + sql += " and id in (" + organizationIds + ") "; + } + //如果开启了分权 + if (isUseHrmManageDetach) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + String allRightSubComIds = subCompanyComInfo.getRightSubCompany(Util.getIntValue(operator,1),"KQLeaveRulesEdit:Edit",0); + //机构权限只读的情况下,下面的allRightSubComIds是为空的,导致where会拼上一个 and (),导致sql报错 + if(Util.null2String(allRightSubComIds).length()>0){ + sql += " and " + Util.getSubINClause(allRightSubComIds, "subCompanyId1", "in"); + }else{//机构权限只读的情况下。就不让批处理 + sql += " and 1=2 "; + } + + } else { + if (!operator.equals("1")) { + User user = new User(Util.getIntValue(operator)); + String rightLevel = HrmUserVarify.getRightLevel("KQLeaveRulesEdit:Edit", user); + int departmentID = user.getUserDepartment(); + int subcompanyID = user.getUserSubCompany1(); + + if (rightLevel.equals("2")) { + // 总部级别的,什么也不返回 + } else if (rightLevel.equals("1")) { // 分部级别的 + sql += " and subCompanyId1=" + subcompanyID; + } else if (rightLevel.equals("0")) { // 部门级别 + sql += " and departmentId=" + departmentID; + } + } + } + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + /*获取人员的相关信息 start*/ + String resourceId = recordSet.getString("id"); + String accountType = Util.null2String(recordSet.getString("accountType")); + String status = Util.null2String(recordSet.getString("status")); + String createDate = Util.null2String(recordSet.getString("createDate")); + String workStartDate = Util.null2String(recordSet.getString("workStartDate")); + String companyStartDate = Util.null2String(recordSet.getString("companyStartDate")); + //如果参加工作日期为空,则默认采用创建日期 + workStartDate = (workStartDate.equals("")||workStartDate.length()<10||workStartDate.indexOf("-")<=0) ? createDate : workStartDate; + //如果入职日期为空,则默认采用创建日期 + companyStartDate = (companyStartDate.equals("")||companyStartDate.length()<10||companyStartDate.indexOf("-")<=0) ? createDate : companyStartDate; + String subCompanyId = Util.null2String(recordSet.getString("subCompanyId1")); + String departmentId = Util.null2String(recordSet.getString("departmentId")); + String locationid = Util.null2String(recordSet.getString("locationid")); + /*获取人员的相关信息 end*/ + + /*获取人员所属分部对应的假期规则 start*/ + rulesDetailId = detailComInfo.getId(ruleId, subCompanyId, departmentId, resourceId); + distributionMode = Util.getIntValue(detailComInfo.getDistributionMode(ruleId, subCompanyId, departmentId, resourceId), 1); + legalKey = Util.getIntValue(detailComInfo.getLegalKey(ruleId, subCompanyId, departmentId, resourceId), 0); + welfareKey = Util.getIntValue(detailComInfo.getWelfareKey(ruleId, subCompanyId, departmentId, resourceId), 1); + annualAmount = Util.getDoubleValue(detailComInfo.getAnnualAmount(ruleId, subCompanyId, departmentId, resourceId), 0.00); + calcMethod = Util.getIntValue(detailComInfo.getCalcMethod(ruleId, subCompanyId, departmentId, resourceId), 0); + convertMode = Util.getIntValue(detailComInfo.getConvertMode(ruleId, subCompanyId, departmentId, resourceId), 0); + decimalDigit = Util.getIntValue(detailComInfo.getDecimalDigit(ruleId, subCompanyId, departmentId, resourceId), 2); + excludeSubAccount = Util.getIntValue(detailComInfo.getExcludeSubAccount(ruleId, subCompanyId, departmentId, resourceId), 1); + beforeFormal = Util.getIntValue(detailComInfo.getBeforeFormal(ruleId, subCompanyId, departmentId, resourceId), 1); + severalChildren = StringUtil.parseToInt(detailComInfo.getSeveralChildren(ruleId, subCompanyId, departmentId, resourceId), 0); + yearsOld = StringUtil.parseToInt(detailComInfo.getYearsOld(ruleId, subCompanyId, departmentId, resourceId), 0); + isprovince = Util.null2s(detailComInfo.getIsProvince(ruleId, subCompanyId, departmentId, resourceId), "1"); + validityRule = Util.getIntValue(detailComInfo.getValidityRule(ruleId, subCompanyId,departmentId,resourceId)); + + /*获取人员所属分部对应的假期规则 end*/ + + //封装参数 start + params = new HashMap(); + params.put("resourceId", resourceId); + params.put("status", status); + params.put("createDate", createDate); + params.put("workStartDate", workStartDate); + params.put("companyStartDate", companyStartDate); + params.put("subCompanyId", subCompanyId); + + params.put("belongYear", belongYear); + params.put("rulesDetailId", rulesDetailId); + params.put("distributionMode", distributionMode); + params.put("annualAmount", annualAmount); + params.put("legalKey", legalKey); + params.put("welfareKey", welfareKey); + params.put("calcMethod", calcMethod); + params.put("convertMode", convertMode); + params.put("decimalDigit", decimalDigit); + params.put("excludeSubAccount", excludeSubAccount); + params.put("beforeFormal", beforeFormal); + // qc + params.put("operator", operator); + params.put("ruleId", ruleId); + //封装参数 end + + if (distributionMode == 1) { + continue; + } else if (distributionMode == 2 || distributionMode == 3) { + baseAmount = getBaseAmount(params); + } else if (distributionMode == 4) { + baseAmount = getBaseAmountByDis4(params); + } else if (distributionMode == 5) { + continue; + } else if (distributionMode == 6) { + params.put("legalOrWelfare", "legal"); + baseAmount = getBaseAmountByDis6(params); + params.put("legalOrWelfare", "welfare"); + baseAmount2 = getBaseAmountByDis6(params); + } else if (distributionMode == 7) { + baseAmount = getBaseAmountByDis7(params); + } else if (distributionMode == 8) { + params.put("validityRule", validityRule); + if(isprovince.equals("2")){ + getChildrenProvinceId(rulesDetailId,locationid,params); + }else{ + params.put("yearsOld",yearsOld); + } + if (severalChildren==0) { + Map baseAmountMaps = getBaseAmountByDis8(params); + baseAmount = (Double) baseAmountMaps.get("baseAmount"); + addOrUpdate = (boolean) baseAmountMaps.get("addOrUpdate"); + expirationDate = (String) baseAmountMaps.get("expirationDate"); + effectiveDate = (String) baseAmountMaps.get("effectiveDate"); + belongYearNew = (String) baseAmountMaps.get("belongYearNew"); + //这个是去年,育儿假有今年去更新去年的情况,所以对这个所属年份赋值。 + if (addOrUpdate && !belongYearNew.equals("")) { + belongYear = belongYearNew; + } + } else { + getBaseAmountByDis8Num(params); + continue; + } + } + if (beforeFormal == 0 && !status.equals("1")) { + //转正前不允许发放余额 + if (canUpdate) { + baseAmount = 0; + baseAmount2 = 0; + } else { + continue; + } + } + if (excludeSubAccount == 0 && accountType.equals("1")) { + //次账号不允许发放余额 + if (canUpdate) { + baseAmount = 0; + baseAmount2 = 0; + } else { + continue; + } + } + + oldBalanceEntity = (KQBalanceOfLeaveEntity) oldBalanceEntities.get(resourceId); + if (oldBalanceEntity != null) { + //如果假期基数没有发生变化,不需要更新 + if (!addOrUpdate&&oldBalanceEntity.getBaseAmount() == baseAmount && oldBalanceEntity.getBaseAmount2() == baseAmount2) { + continue; + } + //如果是系统自动批处理(默认系统自动批处理不允许修改假期余额基数) + if (!canUpdate) { + if (distributionMode == 8) { + + if (oldBalanceEntity.getExtraAmount() > 0 || oldBalanceEntity.getUsedAmount() > 0) { + if (!addOrUpdate) { + if(resourceId.equals("3858")){ + new BaseBean().writeLog("人员id3858:ExtraAmount="+oldBalanceEntity.getExtraAmount()+ + ";UsedAmount="+ oldBalanceEntity.getUsedAmount() + ); + } + continue; + } + } + } + if (distributionMode != 8&&(oldBalanceEntity.getBaseAmount() > 0 || oldBalanceEntity.getExtraAmount() > 0 || oldBalanceEntity.getUsedAmount() > 0 + || oldBalanceEntity.getBaseAmount2() > 0 + || oldBalanceEntity.getExtraAmount2() > 0 || oldBalanceEntity.getUsedAmount2() > 0)) { + if (calcMethod == 2) { + //但是如果【假期基数计算方式】选择【按最多的计算】时,允许在【工龄or司龄变动日期】更新假期基数 + if (distributionMode == 2) { + String ageLimitChangeDate = belongYear + companyStartDate.substring(4); + if (currentDate.compareTo(ageLimitChangeDate) < 0) { + continue; + } + } else if (distributionMode == 3) { + String ageLimitChangeDate = belongYear + workStartDate.substring(4); + if (currentDate.compareTo(ageLimitChangeDate) < 0) { + continue; + } + } else if (distributionMode == 6) { + String ageLimitChangeDate = belongYear + workStartDate.substring(4); + String ageLimitChangeDate2 = belongYear + companyStartDate.substring(4); + if (currentDate.compareTo(ageLimitChangeDate) < 0 && currentDate.compareTo(ageLimitChangeDate2) < 0) { + continue; + } + } + } else { + if (distributionMode == 6 && calcMethod == 0) { + String ageLimitChangeDate = belongYear + workStartDate.substring(4); + String ageLimitChangeDate2 = belongYear + companyStartDate.substring(4); + if (currentDate.compareTo(ageLimitChangeDate) < 0 && currentDate.compareTo(ageLimitChangeDate2) < 0) { + continue; + } + }else{ + if(!addOrUpdate){ + continue; + } + } + } + } + } + } else { + //如果没有生成过假期余额,但是此次生成的假期余额如果为0,则不新增,直接跳过 + if (baseAmount == 0 && baseAmount2 == 0) { + continue; + } + } + + newBalanceEntity = new KQBalanceOfLeaveEntity(); + newBalanceEntity.setResourceId(Util.getIntValue(resourceId)); + newBalanceEntity.setLeaveRulesId(Util.getIntValue(ruleId)); + newBalanceEntity.setBelongYear(belongYear); + newBalanceEntity.setBaseAmount(baseAmount); + newBalanceEntity.setBaseAmount2(baseAmount2); + newBalanceEntity.setEffectiveDate(effectiveDate); + newBalanceEntity.setExpirationDate(expirationDate); + newBalanceEntity.setMinimumUnit(Util.getIntValue(minimumUnit)); + if(addOrUpdate){ + newBalanceEntity.setUsedAmount(baseAmount); + newBalanceEntity.setExtraAmount(baseAmount); + newBalanceEntity.setStatus(1); + }else{ + newBalanceEntity.setStatus(0); + } + newBalanceEntities.add(newBalanceEntity); + belongYear = belongYearTemp; + } + isSuccess = insertOrUpdateBalance(newBalanceEntities, oldBalanceEntities, operator, canUpdate); + } catch (Exception e) { + e.printStackTrace(); + } + return isSuccess; + } + + /** + * 获取指定机构下的人员的假期余额 + * + * @param organizationType 指定机构类型:0-总部、1-分部、2-部门、3-热力资源 + * @param organizationIds 指定机构的ID,用英文逗号分隔 + * @param ruleId 假期类型的ID + * @param belongYear 所属年份 + * @return + */ + private static Map getBalanceEntities(int organizationType, String organizationIds, String ruleId, String belongYear) { + Map balanceEntities = new HashMap(); + try { + KQBalanceOfLeaveEntity balanceEntity = null; + + //假期类型缓存类 + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + //最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假 + String minimumUnit = rulesComInfo.getMinimumUnit(ruleId); + + RecordSet recordSet = new RecordSet(); + String sql = "select * from kq_BalanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and belongYear=" + belongYear; + if (organizationType == 1) { + sql += " and resourceId in (select id from HrmResource where subCompanyId1 in (" + organizationIds + "))"; + } else if (organizationType == 2) { + sql += " and resourceId in (select id from HrmResource where departmentId in (" + organizationIds + "))"; + } else if (organizationType == 3) { + sql += " and resourceId in (" + organizationIds + ")"; + } + recordSet.executeQuery(sql); + while (recordSet.next()) { + int id = recordSet.getInt("id"); + int resourceId = recordSet.getInt("resourceId"); + int leaveRuleId = recordSet.getInt("leaveRulesId"); + double baseAmount = Util.getDoubleValue(recordSet.getString("baseAmount"), 0.00); + double extraAmount = Util.getDoubleValue(recordSet.getString("extraAmount"), 0.00); + double usedAmount = Util.getDoubleValue(recordSet.getString("usedAmount"), 0.00); + double baseAmount2 = Util.getDoubleValue(recordSet.getString("baseAmount2"), 0.00); + double extraAmount2 = Util.getDoubleValue(recordSet.getString("extraAmount2"), 0.00); + double usedAmount2 = Util.getDoubleValue(recordSet.getString("usedAmount2"), 0.00); + + balanceEntity = new KQBalanceOfLeaveEntity(); + balanceEntity.setId(id); + balanceEntity.setResourceId(resourceId); + balanceEntity.setBelongYear(belongYear); + balanceEntity.setLeaveRulesId(leaveRuleId); + balanceEntity.setBaseAmount(baseAmount); + balanceEntity.setExtraAmount(extraAmount); + balanceEntity.setUsedAmount(usedAmount); + balanceEntity.setBaseAmount2(baseAmount2); + balanceEntity.setExtraAmount2(extraAmount2); + balanceEntity.setUsedAmount2(usedAmount2); + balanceEntity.setMinimumUnit(Util.getIntValue(minimumUnit)); + + balanceEntities.put("" + resourceId, balanceEntity); + } + } catch (Exception e) { + e.printStackTrace(); + } + return balanceEntities; + } + + /** + * 获取指定人员的指定假期的指定年份的假期基数发放日期 + * + * @param resourceId 指定人员的人员ID + * @param ruleId 指定假期类型的ID + * @param belongYear 指定年份 + * @return + */ + private static Calendar getReleaseDate(String resourceId, String ruleId, String belongYear) { + Calendar calendar = null; + try { + //人员缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + //分部ID + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + + //创建日期 + String createDate = resourceComInfo.getCreatedate(resourceId); + //入职日期 + String companyStartDate = resourceComInfo.getCompanyStartDate(resourceId); + //没有维护入职日期时取创建日期 + companyStartDate = companyStartDate.equals("") ? createDate : companyStartDate; + //参加工作日期 + String workStartDate = resourceComInfo.getWorkStartDate(resourceId); + //没有维护参加工作日期时取创建日期 + workStartDate = workStartDate.equals("") ? createDate : workStartDate; + + /**********************************************************************************************************/ + + //假期规则的缓存类 + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //假期规则的ID + String rulesDetailId = Util.null2String(detailComInfo.getId(ruleId, subcompanyId, departmentId, resourceId)); + //余额发放方式 + int distributionMode = Util.getIntValue(detailComInfo.getDistributionMode(ruleId, subcompanyId, departmentId, resourceId), 1); + //年假基数计算方式: + // 0-假期基数发放日期和假期基数变动日期均为每年的01月01号(但是假期基数是结合 司龄/工龄 变化前后的值按天数比例折算出来的)、 + // 1-假期基数发放日期和假期基数变动日期均为每年的01月01号、 + // 2-假期基数发放日期发放日期为每年的01月01号,假期基数的变动日期为每年的 入职日期/参加工作日期 + int calcMethod = Util.getIntValue(detailComInfo.getCalcMethod(ruleId, subcompanyId, departmentId, resourceId), 1); + + /***********************************************************************************************************/ + + //假期基数发放日期 + String baseAmountReleaseDate = ""; + //工龄or司令的变动日期 + String ageLimitChangeDate = ""; + //入职日期or参加工作日期 + String date4CalcAgeLimit = ""; + if (distributionMode == 1) { + baseAmountReleaseDate = belongYear + "-01-01"; + //默认情况下都是以【假期基数发放日期】作为释放的开始日期 + calendar = DateUtil.getCalendar(baseAmountReleaseDate); + //如果批处理年份等于入职年份,应该以入职日期作为释放的开始日期 + if (belongYear.compareTo(companyStartDate.substring(0, 4)) == 0) { + calendar = DateUtil.getCalendar(companyStartDate); + } + return calendar; + } else if (distributionMode == 2) { + date4CalcAgeLimit = companyStartDate; + //根据假期基数的计算方式得出【假期基数发放日期】、【入职年限/参加工作年限 的变动日期】 + if (calcMethod == 0 || calcMethod == 1) { + baseAmountReleaseDate = belongYear + "-01-01"; + ageLimitChangeDate = belongYear + companyStartDate.substring(4); + } else if (calcMethod == 2) { + baseAmountReleaseDate = belongYear + "-01-01"; + ageLimitChangeDate = belongYear + companyStartDate.substring(4); + } + } else if (distributionMode == 3) { + date4CalcAgeLimit = workStartDate; + //根据假期基数的计算方式得出【假期基数发放日期】、【入职年限/参加工作年限 的变动日期】 + if (calcMethod == 0 || calcMethod == 1) { + baseAmountReleaseDate = belongYear + "-01-01"; + ageLimitChangeDate = belongYear + workStartDate.substring(4); + } else if (calcMethod == 2) { + baseAmountReleaseDate = belongYear + "-01-01"; + ageLimitChangeDate = belongYear + workStartDate.substring(4); + } + } else if (distributionMode == 4) { + baseAmountReleaseDate = belongYear + "-01-01"; + //默认情况下都是以【假期基数发放日期】作为释放的开始日期 + calendar = DateUtil.getCalendar(baseAmountReleaseDate); + //如果批处理年份等于入职年份,应该以入职日期作为释放的开始日期 + if (belongYear.compareTo(companyStartDate.substring(0, 4)) == 0) { + calendar = DateUtil.getCalendar(companyStartDate); + } + return calendar; + } + + //人员在【假期基数发放日期】时对应的【工龄or司龄】 + int ageLimit = getAgeLimit(date4CalcAgeLimit, baseAmountReleaseDate); + //人员在【假期基数发放日期】时应有的【假期基数】 + BigDecimal baseAmount_releaseDate = getAmountByAgeLimit(distributionMode, rulesDetailId, -1, ageLimit, -1, -1, -1, ""); + + //人员在【工龄or司龄变动日期】时对应的【工龄or司龄】 + int ageLimit_ageLimitChangeDate = getAgeLimit(date4CalcAgeLimit, ageLimitChangeDate); + //人员在【工龄or司龄变动日期】时应有的【假期基数】 + BigDecimal baseAmount_ageLimitChangeDate = getAmountByAgeLimit(distributionMode, rulesDetailId, -1, ageLimit_ageLimitChangeDate, -1, -1, -1, ""); + + //默认情况下都是以【假期基数发放日期】作为释放的开始日期 + calendar = DateUtil.getCalendar(baseAmountReleaseDate); + //如果批处理年份等于入职年份,应该以入职日期作为释放的开始日期 + if (belongYear.compareTo(companyStartDate.substring(0, 4)) == 0) { + calendar = DateUtil.getCalendar(companyStartDate); + } + //如果是初始获得年(即年初01-01的时候假期基数为0,但是后面工龄or司龄增加后,假期基数就不再为0了)。应该以【工龄or司龄变动日期】作为释放的开始日期 + if (baseAmount_releaseDate.doubleValue() <= 0 && baseAmount_ageLimitChangeDate.doubleValue() > 0) { + calendar = DateUtil.getCalendar(ageLimitChangeDate); + //比如:参加工作日是:2020-02-01,入职日期是:2021-08-16,没有该处理会按:2021-02-01给用户计算“已释放”数值 + if(belongYear.compareTo(companyStartDate.substring(0, 4)) == 0 && ageLimitChangeDate.compareTo(companyStartDate)<0){ + calendar = DateUtil.getCalendar(companyStartDate); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return calendar; + } + + /** + * [6-按司龄+工龄自动发放]获取指定人员的指定假期的指定年份的假期基数发放日期 + * + * @param resourceId 指定人员的人员ID + * @param ruleId 指定假期类型的ID + * @param belongYear 指定年份 + * @param legalOrWelfare 是计算[法定年假]还是计算[福利年假]:legal-法定年假、welfare-福利年假 + * @return + */ + private static Calendar getReleaseDateByDis6(String resourceId, String ruleId, String belongYear, String legalOrWelfare) { + Calendar calendar = null; + try { + //人员缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + //分部ID + String subCompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + //创建日期 + String createDate = resourceComInfo.getCreatedate(resourceId); + //入职日期 + String companyStartDate = resourceComInfo.getCompanyStartDate(resourceId); + //没有维护入职日期时取创建日期 + companyStartDate = companyStartDate.equals("") ? createDate : companyStartDate; + //参加工作日期 + String workStartDate = resourceComInfo.getWorkStartDate(resourceId); + //没有维护参加工作日期时取创建日期 + workStartDate = workStartDate.equals("") ? createDate : workStartDate; + + /***********************************************************************************************************/ + + //假期规则的缓存类 + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //假期规则的ID + String rulesDetailId = Util.null2String(detailComInfo.getId(ruleId, subCompanyId, departmentId, resourceId)); + //余额发放方式 + int distributionMode = Util.getIntValue(detailComInfo.getDistributionMode(ruleId, subCompanyId, departmentId, resourceId), 1); + //年假基数计算方式: + // 0-假期基数发放日期和假期基数变动日期均为每年的01月01号(但是假期基数是结合 司龄/工龄 变化前后的值按天数比例折算出来的)、 + // 1-假期基数发放日期和假期基数变动日期均为每年的01月01号、 + // 2-假期基数发放日期发放日期为每年的01月01号,假期基数的变动日期为每年的 入职日期/参加工作日期 + int calcMethod = Util.getIntValue(detailComInfo.getCalcMethod(ruleId, subCompanyId, departmentId, resourceId), 1); + // + int legalKey = Util.getIntValue(detailComInfo.getLegalKey(ruleId, subCompanyId, departmentId, resourceId), 0); + // + int welfareKey = Util.getIntValue(detailComInfo.getWelfareKey(ruleId, subCompanyId, departmentId, resourceId), 1); + + /***********************************************************************************************************/ + + //假期基数发放日期 + String baseAmountReleaseDate = ""; + //工龄变动日期 + String ageLimitChangeDate = ""; + //司龄变动日期 + String ageLimitChangeDate2 = ""; + //根据假期基数的计算方式得出【假期基数发放日期】、【假期基数变动日期】、【工龄变动日期】、【司龄变动日期】 + if (calcMethod == 0 || calcMethod == 1) { + baseAmountReleaseDate = belongYear + "-01-01"; + ageLimitChangeDate = belongYear + workStartDate.substring(4); + ageLimitChangeDate2 = belongYear + companyStartDate.substring(4); + } else if (calcMethod == 2) { + baseAmountReleaseDate = belongYear + "-01-01"; + ageLimitChangeDate = belongYear + workStartDate.substring(4); + ageLimitChangeDate2 = belongYear + companyStartDate.substring(4); + } + + //人员在【假期基数发放日期】时对应的工龄 + int ageLimit_releaseDate = getAgeLimit(workStartDate, baseAmountReleaseDate); + //人员在【假期基数发放日期】时对应的司龄 + int ageLimit2_releaseDate = getAgeLimit(companyStartDate, baseAmountReleaseDate); + //人员在【假期基数发放日期】时对应的假期基数 + BigDecimal baseAmount_releaseDate = getAmountByAgeLimit(distributionMode, rulesDetailId, -1, ageLimit_releaseDate, ageLimit2_releaseDate, legalKey, welfareKey, legalOrWelfare); + + //人员在【工龄变动日期】时对应的工龄 + int ageLimit_ageLimitChangeDate = getAgeLimit(workStartDate, ageLimitChangeDate); + //人员在【工龄变动日期】时对应的司龄 + int ageLimit2_ageLimitChangeDate = getAgeLimit(companyStartDate, ageLimitChangeDate); + //人员在【工龄变动日期】时对应的假期基数 + BigDecimal baseAmount_ageLimitChangeDate = getAmountByAgeLimit(distributionMode, rulesDetailId, -1, ageLimit_ageLimitChangeDate, ageLimit2_ageLimitChangeDate, legalKey, welfareKey, legalOrWelfare); + + //人员在【司龄变动日期】时对应的司龄 + int ageLimit_ageLimitChangeDate2 = getAgeLimit(workStartDate, ageLimitChangeDate2); + //人员在【司龄变动日期】时对应的司龄 + int ageLimit2_ageLimitChangeDate2 = getAgeLimit(companyStartDate, ageLimitChangeDate2); + //人员在【司龄变动日期】时对应的假期基数 + BigDecimal baseAmount_ageLimitChangeDate2 = getAmountByAgeLimit(distributionMode, rulesDetailId, -1, ageLimit_ageLimitChangeDate2, ageLimit2_ageLimitChangeDate2, legalKey, welfareKey, legalOrWelfare); + + //默认情况下都是以【假期基数发放日期】作为释放的开始日期 + calendar = DateUtil.getCalendar(baseAmountReleaseDate); + //如果批处理年份等于入职年份,应该以入职日期作为释放的开始日期 + if (belongYear.compareTo(companyStartDate.substring(0, 4)) == 0) { + calendar = DateUtil.getCalendar(companyStartDate); + } + //如果是初始获得年(即年初01-01的时候假期基数为0,但是后面工龄or司龄增加后,假期基数就不再为0了) + if (ageLimitChangeDate.compareTo(ageLimitChangeDate2) <= 0) { + if (baseAmount_releaseDate.doubleValue() <= 0 && baseAmount_ageLimitChangeDate.doubleValue() > 0) { + calendar = DateUtil.getCalendar(ageLimitChangeDate); + } + if (baseAmount_releaseDate.doubleValue() <= 0 && baseAmount_ageLimitChangeDate.doubleValue() <= 0 && baseAmount_ageLimitChangeDate2.doubleValue() > 0) { + calendar = DateUtil.getCalendar(ageLimitChangeDate2); + } + } else { + if (baseAmount_releaseDate.doubleValue() <= 0 && baseAmount_ageLimitChangeDate2.doubleValue() > 0) { + calendar = DateUtil.getCalendar(ageLimitChangeDate2); + } + if (baseAmount_releaseDate.doubleValue() <= 0 && baseAmount_ageLimitChangeDate2.doubleValue() <= 0 && baseAmount_ageLimitChangeDate.doubleValue() > 0) { + calendar = DateUtil.getCalendar(ageLimitChangeDate2); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return calendar; + } + + /** + * 计算假期基数 + * + * @param params Map + * belongYear:所属年份 + * createDate:人员创建日期 + * workStartDate:参加工作日期 + * companyStartDate:入职日期 + * rulesDetailId:假期规则的ID + * distributionMode:当前假期规则发放方式 + * annualAmount:当[distributionMode]=[4-每年发放固定天数]时有效 + * legalKey:法定年假规则(当[distributionMode=6]时有效):0-工龄、1-司龄、2-工龄+司龄 + * welfareKey:福利年假规则(当[distributionMode=6]时有效):0-工龄、1-司龄、2-工龄+司龄 + * calcMethod:假期基数计算方式 + * convertMode:折算方式 + * decimalDigit:折算后的假期余额保留几位小数 + * @return + */ + private static double getBaseAmount(Map params) { + BigDecimal baseAmount = new BigDecimal("0"); + int decimalDigit = 2; + try { + //当前日期 + String currentDate = DateUtil.getCurrentDate(); + //当前年份 + String currentYear = currentDate.substring(0, 4); + //批处理年份 + String belongYear = Util.null2String(params.get("belongYear")); + //人员的参加工作日期 + String workStartDate = Util.null2String(params.get("workStartDate")); + //人员的入职日期 + String companyStartDate = Util.null2String(params.get("companyStartDate")); + + //假期规则的ID + String rulesDetailId = Util.null2String(params.get("rulesDetailId")); + //当前假期规则发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按入职时长+工龄自动发放 + int distributionMode = Util.getIntValue("" + params.get("distributionMode"), 1); + //当[distributionMode]=[4-每年发放固定天数]时有效 + double annualAmount = Util.getDoubleValue("" + params.get("annualAmount"), 0); + //法定年假规则(当distributionMode=6时有效):0-工龄、1-司龄、2-工龄+司龄 + int legalKey = Util.getIntValue("" + params.get("legalKey"), 0); + //福利年假规则(当distributionMode=6时有效):0-工龄、1-司龄、2-工龄+司龄 + int welfareKey = Util.getIntValue("" + params.get("welfareKey"), 1); + //年假基数计算方式: + // 0-假期基数发放日期和假期基数变动日期均为每年的01月01号(但是假期基数是结合 司龄/工龄 变化前后的值按天数比例折算出来的)、 + // 1-假期基数发放日期和假期基数变动日期均为每年的01月01号、 + // 2-假期基数发放日期发放日期为每年的01月01号,假期基数的变动日期为每年的 入职日期/参加工作日期 + int calcMethod = Util.getIntValue("" + params.get("calcMethod"), 1); + //假期基数发放日期 + String baseAmountReleaseDate = ""; + //假期基数变动日期 + String baseAmountChangeDate = ""; + //工龄or司龄的变动日期 + String ageLimitChangeDate = ""; + String ageLimitChangeDatetemp = ""; + //入职日期or参加工作日期 + String date4CalcAgeLimit = ""; + if (distributionMode == 2) { + date4CalcAgeLimit = companyStartDate; + //根据假期基数的计算方式得出【假期基数发放日期】、【假期基数变动日期】、【工龄or司龄的变动日期】 + if (calcMethod == 0 || calcMethod == 1) { + baseAmountReleaseDate = belongYear + "-01-01"; + baseAmountChangeDate = belongYear + "-01-01"; + ageLimitChangeDate = belongYear + companyStartDate.substring(4); + } else if (calcMethod == 2) { + baseAmountReleaseDate = belongYear + "-01-01"; + baseAmountChangeDate = belongYear + companyStartDate.substring(4); + ageLimitChangeDate = belongYear + companyStartDate.substring(4); + } + } else if (distributionMode == 3) { + date4CalcAgeLimit = workStartDate; + //根据假期基数的计算方式得出【假期基数发放日期】、【假期基数变动日期】、【工龄or司龄的变动日期】 + if (calcMethod == 0 || calcMethod == 1) { + baseAmountReleaseDate = belongYear + "-01-01"; + baseAmountChangeDate = belongYear + "-01-01"; + ageLimitChangeDate = belongYear + workStartDate.substring(4); + } else if (calcMethod == 2) { + baseAmountReleaseDate = belongYear + "-01-01"; + baseAmountChangeDate = belongYear + workStartDate.substring(4); + ageLimitChangeDate = belongYear + workStartDate.substring(4); + } + //如果是初始获得年,那么,入职日期和参加工作日期,取相对较晚的日期,作为变动日期 + if(companyStartDate.substring(4).compareTo(workStartDate.substring(4)) <= 0){ + ageLimitChangeDatetemp = belongYear + workStartDate.substring(4); + }else{ + ageLimitChangeDatetemp = belongYear + companyStartDate.substring(4); + } + } + + //批处理日期(因为存在当前年份批处理上一年份或者批处理下一年份,所以需要做一些特殊处理) + String date4CalcAmount = ""; + if (belongYear.compareTo(currentYear) < 0) { + date4CalcAmount = belongYear + "-12-31"; + } else if (belongYear.compareTo(currentYear) == 0) { + date4CalcAmount = currentDate; + } else { + date4CalcAmount = baseAmountReleaseDate; + } + //折算方式 + int convertMode = Util.getIntValue("" + params.get("convertMode"), 0); + //折算后的假期余额保留几位小数 + decimalDigit = Util.getIntValue("" + params.get("decimalDigit"), 2); + + //人员在【假期基数发放日期】时对应的【工龄or司龄】 + int ageLimit = getAgeLimit(date4CalcAgeLimit, baseAmountReleaseDate); + //人员在【假期基数发放日期】时应有的【假期基数】 + BigDecimal baseAmount_releaseDate = getAmountByAgeLimit(distributionMode, rulesDetailId, annualAmount, ageLimit, -1, -1, -1, ""); + + //人员在【工龄or司龄变动日期】时对应的【工龄or司龄】 + int ageLimit_ageLimitChangeDate = getAgeLimit(date4CalcAgeLimit, ageLimitChangeDate); + //人员在【工龄or司龄变动日期】时应有的【假期基数】 + BigDecimal baseAmount_ageLimitChangeDate = getAmountByAgeLimit(distributionMode, rulesDetailId, annualAmount, ageLimit_ageLimitChangeDate, -1, -1, -1, ""); + + //如果人员在【假期基数发放日期】时对应的【假期基数】为0,并且【批处理日期】小于【工龄or司龄变动日期】,则假期基数应该是0 + if (baseAmount_releaseDate.doubleValue() <= 0 && date4CalcAmount.compareTo(ageLimitChangeDate) < 0) { + return 0; + } + + //如果【calcMethod】==0?假期基数按比例精确计算 + boolean needCalc0 = false; + //是否需要折算 + boolean needConvert = false; + //以哪个日期来折算 + Calendar calendar = null; + //入职前的假期基数应该为0 + if (date4CalcAmount.compareTo(companyStartDate) < 0) { + return 0; + } + //如果批处理年份等于入职年份,那应该以【入职日期】来折算 + if (belongYear.compareTo(companyStartDate.substring(0, 4)) == 0) { + //需要折算 + needConvert = true; + //以【入职日期来折算】 + calendar = DateUtil.getCalendar(companyStartDate); + } + /** + * 年假基数的计算方法如下: + * 第一种情况:工龄or司龄的变动日期<假期基数发放日期<=假期基数变动日期 + * 批处理日期<假期基数发放日期?假期基数=0 + * 批处理日期>=假期基数基数发放日期?根据假期基数发放日期计算工龄or司龄,然后得出对应的假期基数 + * 第二种情况:假期基数发放日期<=工龄or司龄的变动日期<=假期基数变动日期 + * 批处理日期<假期基数发放日期?假期基数=0 + * 批处理日期=假期基数发放日期?根据假期基数发放日期计算工龄or司龄,然后得出对应的假期基数 + * 批处理日期>假期基数发放日期 && 批处理日期<工龄or司龄的变动日期?根据假期基数发放日期计算工龄or司龄,然后得出对应的假期基数 + * 批处理日期>假期基数发放日期 && 批处理日期>=工龄or司龄的变动日期? + * 如果是初始获得年(即年初01-01的时候假期基数为0,但是后面工龄or司龄增加后,假期基数就不再为0了)?根据【工龄or司龄的变动日期】计算工龄or司龄,然后得出对应的假期基数。此处得到的假期基数需要折算) + * 如果不是初始获得年?批处理日期>=假期基数变动日期?根据【工龄or司龄的变动日期】计算工龄or司龄,然后得出对应的假期基数。此处得到的假期基数不需要折算 + * 第三种情况:假期基数发放日期<假期基数变动日期<工龄or司龄的变动日期 + * 批处理日期<假期基数发放日期?假期基数=0 + * 批处理日期=假期基数发放日期? + * 如果【calcMethod】!=0?根据假期基数发放日期计算工龄or司龄,然后得出对应的假期基数 + * 如果【calcMethod】==0?假期基数按比例精确计算 + * 批处理日期>假期基数发放日期 && 批处理日期<工龄or司龄的变动日期? + * 如果【calcMethod】!=0?根据假期基数发放日期计算工龄or司龄,然后得出对应的假期基数 + * 如果【calcMethod】==0?假期基数按比例精确计算 + * 批处理日期>假期基数发放日期 && 批处理日期>=工龄or司龄的变动日期? + * 如果是初始获得年?根据【工龄or司龄的变动日期】计算工龄or司龄,然后得出对应的假期基数。此处得到的假期基数需要折算 + * 如果不是初始获得年? + * 如果【calcMethod】!=0?根据假期基数发放日期计算工龄or司龄,然后得出对应的假期基数 + * 如果【calcMethod】==0?假期基数按比例精确计算 + */ + if (ageLimitChangeDate.compareTo(baseAmountReleaseDate) < 0 && baseAmountReleaseDate.compareTo(baseAmountChangeDate) <= 0) { + if (date4CalcAmount.compareTo(baseAmountReleaseDate) < 0) { + return 0; + } else if (date4CalcAmount.compareTo(baseAmountReleaseDate) >= 0) { + baseAmount = baseAmount_releaseDate; + } + } else if (baseAmountReleaseDate.compareTo(ageLimitChangeDate) <= 0 && ageLimitChangeDate.compareTo(baseAmountChangeDate) <= 0) { + if (date4CalcAmount.compareTo(baseAmountReleaseDate) < 0) { + return 0; + } else if (date4CalcAmount.compareTo(baseAmountReleaseDate) == 0) { + baseAmount = baseAmount_releaseDate; + } else { + if (date4CalcAmount.compareTo(ageLimitChangeDate) < 0) { + baseAmount = baseAmount_releaseDate; + } else if (date4CalcAmount.compareTo(ageLimitChangeDate) >= 0) { + baseAmount = baseAmount_releaseDate; + if (baseAmount_releaseDate.doubleValue() <= 0) { + needConvert = true; + //如果是当年入职,则按照【入职日期折算】 + if (distributionMode == 3&&belongYear.compareTo(companyStartDate.substring(0, 4)) == 0) { + calendar = DateUtil.getCalendar(ageLimitChangeDatetemp); + }else{ + calendar = DateUtil.getCalendar(ageLimitChangeDate); + } + + baseAmount = baseAmount_ageLimitChangeDate; + } else { + if (date4CalcAmount.compareTo(baseAmountChangeDate) >= 0) { + baseAmount = baseAmount_ageLimitChangeDate; + } + } + } + } + } else if (baseAmountReleaseDate.compareTo(baseAmountChangeDate) <= 0 && baseAmountChangeDate.compareTo(ageLimitChangeDate) < 0) { + if (date4CalcAmount.compareTo(baseAmountReleaseDate) < 0) { + return 0; + } else if (date4CalcAmount.compareTo(baseAmountReleaseDate) == 0) { + baseAmount = baseAmount_releaseDate; + if (calcMethod == 0) { + needCalc0 = true; + } + } else { + if (date4CalcAmount.compareTo(ageLimitChangeDate) < 0) { + baseAmount = baseAmount_releaseDate; + if (calcMethod == 0) { + needCalc0 = true; + } + } else if (date4CalcAmount.compareTo(ageLimitChangeDate) >= 0) { + baseAmount = baseAmount_releaseDate; + if (baseAmount_releaseDate.doubleValue() <= 0) { + needConvert = true; + //如果是当年入职,则按照【入职日期折算】 + if (distributionMode == 3&&belongYear.compareTo(companyStartDate.substring(0, 4)) == 0) { + calendar = DateUtil.getCalendar(ageLimitChangeDatetemp); + }else{ + calendar = DateUtil.getCalendar(ageLimitChangeDate); + } + + baseAmount = baseAmount_ageLimitChangeDate; + } else if (calcMethod == 0) { + needCalc0 = true; + } + } + } + } + + if (needCalc0) { + baseAmount = baseAmount_releaseDate; + + Calendar _calendar1 = DateUtil.getCalendar(baseAmountReleaseDate); + BigDecimal _dayOfYear1 = new BigDecimal("" + (_calendar1.get(Calendar.DAY_OF_YEAR) - 1)); + BigDecimal _actualMaximum = new BigDecimal("" + _calendar1.getActualMaximum(Calendar.DAY_OF_YEAR)); + + Calendar _calendar2 = DateUtil.getCalendar(ageLimitChangeDate); + BigDecimal _dayOfYear2 = new BigDecimal("" + (_calendar2.get(Calendar.DAY_OF_YEAR) - 1)); + + baseAmount = (baseAmount_releaseDate.multiply(_dayOfYear2.subtract(_dayOfYear1)) + .add(baseAmount_ageLimitChangeDate.multiply(_actualMaximum.subtract(_dayOfYear2)))) + .divide(_actualMaximum.subtract(_dayOfYear1), decimalDigit, RoundingMode.HALF_UP); + + if (convertMode == 0) { + if (date4CalcAmount.compareTo(baseAmountReleaseDate) >= 0) { + baseAmount = baseAmount_releaseDate.setScale(decimalDigit, RoundingMode.HALF_UP); + } + if (date4CalcAmount.compareTo(baseAmountChangeDate) >= 0) { + baseAmount = baseAmount_ageLimitChangeDate.setScale(decimalDigit, RoundingMode.HALF_UP); + } + } else if (convertMode == 1) { + baseAmount = baseAmount; + } else if (convertMode == 2) { + baseAmount = baseAmount.setScale(0, RoundingMode.UP); + } else if (convertMode == 3) { + baseAmount = baseAmount.setScale(0, RoundingMode.DOWN); + } else if (convertMode == 4) { + baseAmount = baseAmount.divide(new BigDecimal("0.5"), 0, RoundingMode.UP).multiply(new BigDecimal("0.5")); + } else if (convertMode == 5) { + baseAmount = baseAmount.divide(new BigDecimal("0.5"), 0, RoundingMode.DOWN).multiply(new BigDecimal("0.5")); + } + } + + if (needConvert) { + //这一年一共有多少天 + BigDecimal actualMaximum = new BigDecimal("" + calendar.getActualMaximum(Calendar.DAY_OF_YEAR)); + //年假变动日期是这一天的第几天 + BigDecimal dayOfYear = new BigDecimal("" + (calendar.get(Calendar.DAY_OF_YEAR) - 1)); + + if (convertMode == 0) { + baseAmount = baseAmount; + } else if (convertMode == 1) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum, decimalDigit, RoundingMode.HALF_UP); + } else if (convertMode == 2) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum, 0, RoundingMode.UP); + } else if (convertMode == 3) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum, 0, RoundingMode.DOWN); + } else if (convertMode == 4) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum.multiply(new BigDecimal("0.5")), 0, RoundingMode.UP).multiply(new BigDecimal("0.5")); + } else if (convertMode == 5) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum.multiply(new BigDecimal("0.5")), 0, RoundingMode.DOWN).multiply(new BigDecimal("0.5")); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return baseAmount.setScale(decimalDigit, RoundingMode.HALF_UP).doubleValue(); + } + + /** + * [4-每年发放固定天数]计算假期基数 + * + * @param params Map + * belongYear:所属年份 + * createDate:人员创建日期 + * companyStartDate:入职日期 + * distributionMode:当前假期规则发放方式 + * annualAmount:当[distributionMode]=[4-每年发放固定天数]时有效 + * convertMode:折算方式 + * decimalDigit:折算后的假期余额保留几位小数 + * @return + */ + private static double getBaseAmountByDis4(Map params) { + BigDecimal baseAmount = new BigDecimal("0"); + int decimalDigit = 2; + try { + //当前日期 + String currentDate = DateUtil.getCurrentDate(); + //当前年份 + String currentYear = currentDate.substring(0, 4); + //批处理年份 + String belongYear = Util.null2String(params.get("belongYear")); + //人员的入职日期 + String companyStartDate = Util.null2String(params.get("companyStartDate")); + //当前假期规则发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按入职时长+工龄自动发放 + int distributionMode = Util.getIntValue("" + params.get("distributionMode"), 1); + //当[distributionMode]=[4-每年发放固定天数]时有效 + double annualAmount = Util.getDoubleValue("" + params.get("annualAmount"), 0); + //折算方式 + int convertMode = Util.getIntValue("" + params.get("convertMode"), 0); + //折算后的假期余额保留几位小数 + decimalDigit = Util.getIntValue("" + params.get("decimalDigit"), 2); + //批处理日期(因为存在当前年份批处理上一年份或者批处理下一年份,所以需要做一些特殊处理) + String date4CalcAmount = ""; + if (belongYear.compareTo(currentYear) < 0) { + date4CalcAmount = belongYear + "-12-31"; + } else if (belongYear.compareTo(currentYear) == 0) { + date4CalcAmount = currentDate; + } else { + date4CalcAmount = belongYear + "-01-01"; + } + if (distributionMode == 4) { + if (date4CalcAmount.compareTo(companyStartDate) < 0) { + return 0; + } + baseAmount = new BigDecimal("" + annualAmount); + //当批处理年份=入职年份时,需要折算 + if (!"".equals(companyStartDate) && belongYear.equals(companyStartDate.substring(0, 4))) { + //以入职日期来折算 + Calendar calendar = DateUtil.getCalendar(companyStartDate); + //这一年一共有多少天 + BigDecimal actualMaximum = new BigDecimal("" + calendar.getActualMaximum(Calendar.DAY_OF_YEAR)); + //年假变动日期是这一天的第几天 + BigDecimal dayOfYear = new BigDecimal("" + (calendar.get(Calendar.DAY_OF_YEAR) - 1)); + + if (convertMode == 0) { + baseAmount = baseAmount; + } else if (convertMode == 1) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum, decimalDigit, RoundingMode.HALF_UP); + } else if (convertMode == 2) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum, 0, RoundingMode.UP); + } else if (convertMode == 3) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum, 0, RoundingMode.DOWN); + } else if (convertMode == 4) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum.multiply(new BigDecimal("0.5")), 0, RoundingMode.UP).multiply(new BigDecimal("0.5")); + } else if (convertMode == 5) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum.multiply(new BigDecimal("0.5")), 0, RoundingMode.DOWN).multiply(new BigDecimal("0.5")); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return baseAmount.setScale(decimalDigit, RoundingMode.HALF_UP).doubleValue(); + } + + /** + * [6-按司龄+工龄自动发放]计算假期基数 + * + * @param params Map + * belongYear:所属年份 + * createDate:人员创建日期 + * workStartDate:参加工作日期 + * companyStartDate:入职日期 + * rulesDetailId:假期规则的ID + * distributionMode:当前假期规则发放方式 + * legalKey:法定年假规则(当[distributionMode=6]时有效):0-工龄、1-司龄、2-工龄+司龄 + * welfareKey:福利年假规则(当[distributionMode=6]时有效):0-工龄、1-司龄、2-工龄+司龄 + * calcMethod:假期基数计算方式 + * convertMode:折算方式 + * decimalDigit:折算后的假期余额保留几位小数 + * @return + */ + private static double getBaseAmountByDis6(Map params) { + //法定年假 + BigDecimal baseAmount = new BigDecimal("0"); + int decimalDigit = 2; + try { + //当前日期 + String currentDate = DateUtil.getCurrentDate(); + //当前年份 + String currentYear = currentDate.substring(0, 4); + //批处理年份 + String belongYear = Util.null2String(params.get("belongYear")); + //人员的参加工作日期 + String workStartDate = Util.null2String(params.get("workStartDate")); + //人员的入职日期 + String companyStartDate = Util.null2String(params.get("companyStartDate")); + //假期规则的ID + String rulesDetailId = Util.null2String(params.get("rulesDetailId")); + //当前假期规则发放规则:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按入职时长+工龄自动发放 + int distributionMode = Util.getIntValue("" + params.get("distributionMode"), 1); + //法定年假规则(当distributionMode=6时有效):0-工龄、1-司龄、2-工龄+司龄 + int legalKey = Util.getIntValue("" + params.get("legalKey"), 0); + //福利年假规则(当distributionMode=6时有效):0-工龄、1-司龄、2-工龄+司龄 + int welfareKey = Util.getIntValue("" + params.get("welfareKey"), 1); + //年假基数计算方式: + // 0-假期基数发放日期和假期基数变动日期均为每年的01月01号(但是假期基数是结合 司龄/工龄 变化前后的值按天数比例折算出来的)、 + // 1-假期基数发放日期和假期基数变动日期均为每年的01月01号、 + // 2-假期基数发放日期发放日期为每年的01月01号,假期基数的变动日期为每年的 入职日期/参加工作日期 + int calcMethod = Util.getIntValue("" + params.get("calcMethod"), 1); + //假期基数发放日期 + String baseAmountReleaseDate = ""; + //工龄变动日期 + String ageLimitChangeDate = ""; + //司龄变动日期 + String ageLimitChangeDate2 = ""; + //根据假期基数的计算方式得出【假期基数发放日期】、【假期基数变动日期】、【工龄变动日期】、【司龄变动日期】 + if (calcMethod == 0 || calcMethod == 1) { + baseAmountReleaseDate = belongYear + "-01-01"; + ageLimitChangeDate = belongYear + workStartDate.substring(4); + ageLimitChangeDate2 = belongYear + companyStartDate.substring(4); + } else if (calcMethod == 2) { + baseAmountReleaseDate = belongYear + "-01-01"; + ageLimitChangeDate = belongYear + workStartDate.substring(4); + ageLimitChangeDate2 = belongYear + companyStartDate.substring(4); + } + //批处理日期(因为存在当前年份批处理上一年份或者批处理下一年份,所以需要做一些特殊处理) + String date4CalcAmount = ""; + if (belongYear.compareTo(currentYear) < 0) { + date4CalcAmount = belongYear + "-12-31"; + } else if (belongYear.compareTo(currentYear) == 0) { + date4CalcAmount = currentDate; + } else { + date4CalcAmount = baseAmountReleaseDate; + } + //获取假期规则的【折算方式】 + int convertMode = Util.getIntValue("" + params.get("convertMode"), 0); + //获取假期规则的【假期余额小数位数】 + decimalDigit = Util.getIntValue("" + params.get("decimalDigit"), 2); + //是计算法定年假还是福利年假 + String legalOrWelfare = Util.null2String(params.get("legalOrWelfare")); + + //人员在【假期基数发放日期】时对应的工龄 + int ageLimit_releaseDate = getAgeLimit(workStartDate, baseAmountReleaseDate); + //人员在【假期基数发放日期】时对应的司龄 + int ageLimit2_releaseDate = getAgeLimit(companyStartDate, baseAmountReleaseDate); + //人员在【假期基数发放日期】时对应的假期基数 + BigDecimal baseAmount_releaseDate = getAmountByAgeLimit(distributionMode, rulesDetailId, -1, ageLimit_releaseDate, ageLimit2_releaseDate, legalKey, welfareKey, legalOrWelfare); + + //人员在【工龄变动日期】时对应的工龄 + int ageLimit_ageLimitChangeDate = getAgeLimit(workStartDate, ageLimitChangeDate); + //人员在【工龄变动日期】时对应的司龄 + int ageLimit2_ageLimitChangeDate = getAgeLimit(companyStartDate, ageLimitChangeDate); + //人员在【工龄变动日期】时对应的假期基数 + BigDecimal baseAmount_ageLimitChangeDate = getAmountByAgeLimit(distributionMode, rulesDetailId, -1, ageLimit_ageLimitChangeDate, ageLimit2_ageLimitChangeDate, legalKey, welfareKey, legalOrWelfare); + + //人员在【司龄变动日期】时对应的司龄 + int ageLimit_ageLimitChangeDate2 = getAgeLimit(workStartDate, ageLimitChangeDate2); + //人员在【司龄变动日期】时对应的司龄 + int ageLimit2_ageLimitChangeDate2 = getAgeLimit(companyStartDate, ageLimitChangeDate2); + //人员在【司龄变动日期】时对应的假期基数 + BigDecimal baseAmount_ageLimitChangeDate2 = getAmountByAgeLimit(distributionMode, rulesDetailId, -1, ageLimit_ageLimitChangeDate2, ageLimit2_ageLimitChangeDate2, legalKey, welfareKey, legalOrWelfare); + + //是否需要精确计算 + boolean needCalc0 = false; + //是否需要折算 + boolean needConvert = false; + //根据什么日期进行折算 + Calendar calendar = null; + //如果【批处理日期】小于【入职日期】,假期基数应该为0 + if (date4CalcAmount.compareTo(companyStartDate) < 0) { + return 0; + } + //如果批处理年份等于入职年份,那应该以【入职日期】来折算 + String ageLimitChangeDatetemp = ""; + if (belongYear.compareTo(companyStartDate.substring(0, 4)) == 0) { + //需要折算 + needConvert = true; + //以【入职日期来折算】 + calendar = DateUtil.getCalendar(companyStartDate); + //如果是按照司龄计算,就只按照司龄折算。 + if(legalKey==1||welfareKey==1){ + ageLimitChangeDatetemp = companyStartDate; + }else{ + //如果是初始获得年,那么,入职日期和参加工作日期,取相对较晚的日期,作为变动日期 + if(companyStartDate.substring(4).compareTo(workStartDate.substring(4)) <= 0){ + ageLimitChangeDatetemp = belongYear + workStartDate.substring(4); + }else{ + ageLimitChangeDatetemp = companyStartDate; + } + } + + + } + for (int i = 0; i < 1; i++) { + //如果【计算假期基数的日期】小于【假期基数发放日期】,假期基数应该为0 + if (date4CalcAmount.compareTo(baseAmountReleaseDate) < 0) { + return 0; + } else if (date4CalcAmount.compareTo(baseAmountReleaseDate) >= 0) { + baseAmount = baseAmount_releaseDate; + //暂定【假期基数发放日期】一定小于等于【工龄变动日期】、【司龄变动日期】 + //【假期基数发放日期】<=【工龄变动日期】<=【司龄变动日期】 + if (baseAmountReleaseDate.compareTo(ageLimitChangeDate) <= 0 && ageLimitChangeDate.compareTo(ageLimitChangeDate2) <= 0) { + if (calcMethod == 0 && baseAmount_releaseDate.doubleValue() > 0) { + Calendar _calendar1 = DateUtil.getCalendar(baseAmountReleaseDate); + BigDecimal _dayOfYear1 = new BigDecimal("" + (_calendar1.get(Calendar.DAY_OF_YEAR) - 1)); + BigDecimal _actualMaximum = new BigDecimal("" + (_calendar1.getActualMaximum(Calendar.DAY_OF_YEAR))); + + Calendar _calender2 = DateUtil.getCalendar(ageLimitChangeDate); + BigDecimal _dayOfYear2 = new BigDecimal("" + (_calender2.get(Calendar.DAY_OF_YEAR) - 1)); + + Calendar _calender3 = DateUtil.getCalendar(ageLimitChangeDate2); + BigDecimal _dayOfYear3 = new BigDecimal("" + (_calender3.get(Calendar.DAY_OF_YEAR) - 1)); + + baseAmount = ((baseAmount_releaseDate.multiply(_dayOfYear2.subtract(_dayOfYear1))) + .add(baseAmount_ageLimitChangeDate.multiply(_dayOfYear3.subtract(_dayOfYear2))) + .add(baseAmount_ageLimitChangeDate2.multiply(_actualMaximum.subtract(_dayOfYear3)))) + .divide(_actualMaximum, decimalDigit, RoundingMode.HALF_UP); + if (convertMode == 0) { + if (date4CalcAmount.compareTo(baseAmountReleaseDate) >= 0) { + baseAmount = baseAmount_releaseDate.setScale(decimalDigit, RoundingMode.HALF_UP); + } + if (date4CalcAmount.compareTo(ageLimitChangeDate) >= 0) { + baseAmount = baseAmount_ageLimitChangeDate.setScale(decimalDigit, RoundingMode.HALF_UP); + } + if (date4CalcAmount.compareTo(ageLimitChangeDate2) >= 0) { + baseAmount = baseAmount_ageLimitChangeDate2.setScale(decimalDigit, RoundingMode.HALF_UP); + } + } else if (convertMode == 1) { + baseAmount = baseAmount; + } else if (convertMode == 2) { + baseAmount = baseAmount.setScale(0, RoundingMode.UP); + } else if (convertMode == 3) { + baseAmount = baseAmount.setScale(0, RoundingMode.DOWN); + } else if (convertMode == 4) { + baseAmount = baseAmount.divide(new BigDecimal("0.5"), 0, RoundingMode.UP).multiply(new BigDecimal("0.5")); + } else if (convertMode == 5) { + baseAmount = baseAmount.divide(new BigDecimal("0.5"), 0, RoundingMode.DOWN).multiply(new BigDecimal("0.5")); + } + break; + } + //【批处理日期】>=【工龄变动日期】&& (人员在【假期基数发放日期】时对应的假期基数是0 || 【假期基数计算方式=2】时) + if ((date4CalcAmount.compareTo(ageLimitChangeDate) >= 0) + && (baseAmount_releaseDate.doubleValue() <= 0 || calcMethod == 2)) { + if (baseAmount_releaseDate.doubleValue() <= 0 && baseAmount_ageLimitChangeDate.doubleValue() > 0) { + needConvert = true; + //如果是当年入职,则按照【入职日期折算】 + if (belongYear.compareTo(companyStartDate.substring(0, 4)) == 0) { + calendar = DateUtil.getCalendar(ageLimitChangeDatetemp); + }else{ + calendar = DateUtil.getCalendar(ageLimitChangeDate); + } + + baseAmount = baseAmount_ageLimitChangeDate; + } else { + if (calcMethod == 2) { + baseAmount = baseAmount_ageLimitChangeDate; + } + } + } + //【批处理日期】>=【司龄变动日期】&& (人员在【工龄变动日期】时对应的假期基数是0||【假期基数计算方式=2】时) + if ((date4CalcAmount.compareTo(ageLimitChangeDate2) >= 0) + && (baseAmount_ageLimitChangeDate.doubleValue() <= 0 || calcMethod == 2)) { + if (baseAmount_ageLimitChangeDate.doubleValue() <= 0 && baseAmount_ageLimitChangeDate2.doubleValue() > 0) { + needConvert = true; + if (belongYear.compareTo(companyStartDate.substring(0, 4)) == 0) { + calendar = DateUtil.getCalendar(ageLimitChangeDatetemp); + }else{ + calendar = DateUtil.getCalendar(ageLimitChangeDate2); + } + baseAmount = baseAmount_ageLimitChangeDate2; + } else { + if (calcMethod == 2) { + baseAmount = baseAmount_ageLimitChangeDate2; + } + } + } + } else if (baseAmountReleaseDate.compareTo(ageLimitChangeDate2) <= 0 && ageLimitChangeDate2.compareTo(ageLimitChangeDate) <= 0) { + if (calcMethod == 0 && baseAmount_releaseDate.doubleValue() > 0) { + Calendar _calendar1 = DateUtil.getCalendar(baseAmountReleaseDate); + BigDecimal _dayOfYear1 = new BigDecimal("" + (_calendar1.get(Calendar.DAY_OF_YEAR) - 1)); + BigDecimal _actualMaximum = new BigDecimal("" + _calendar1.getActualMaximum(Calendar.DAY_OF_YEAR)); + + Calendar _calender2 = DateUtil.getCalendar(ageLimitChangeDate2); + BigDecimal _dayOfYear2 = new BigDecimal("" + (_calender2.get(Calendar.DAY_OF_YEAR) - 1)); + + Calendar _calender3 = DateUtil.getCalendar(ageLimitChangeDate); + BigDecimal _dayOfYear3 = new BigDecimal("" + (_calender3.get(Calendar.DAY_OF_YEAR) - 1)); + + baseAmount = ((baseAmount_releaseDate.multiply(_dayOfYear2.subtract(_dayOfYear1))) + .add(baseAmount_ageLimitChangeDate2.multiply(_dayOfYear3.subtract(_dayOfYear2))) + .add(baseAmount_ageLimitChangeDate.multiply(_actualMaximum.subtract(_dayOfYear3)))) + .divide(_actualMaximum, decimalDigit, RoundingMode.HALF_UP); + if (convertMode == 0) { + if (date4CalcAmount.compareTo(baseAmountReleaseDate) >= 0) { + baseAmount = baseAmount_releaseDate.setScale(decimalDigit, RoundingMode.HALF_UP); + } + if (date4CalcAmount.compareTo(ageLimitChangeDate2) >= 0) { + baseAmount = baseAmount_ageLimitChangeDate2.setScale(decimalDigit, RoundingMode.HALF_UP); + } + if (date4CalcAmount.compareTo(ageLimitChangeDate) >= 0) { + baseAmount = baseAmount_ageLimitChangeDate.setScale(decimalDigit, RoundingMode.HALF_UP); + } + } else if (convertMode == 1) { + baseAmount = baseAmount; + } else if (convertMode == 2) { + baseAmount = baseAmount.setScale(0, RoundingMode.UP); + } else if (convertMode == 3) { + baseAmount = baseAmount.setScale(0, RoundingMode.DOWN); + } else if (convertMode == 4) { + baseAmount = baseAmount.divide(new BigDecimal("0.5"), 0, RoundingMode.UP).multiply(new BigDecimal("0.5")); + } else if (convertMode == 5) { + baseAmount = baseAmount.divide(new BigDecimal("0.5"), 0, RoundingMode.DOWN).multiply(new BigDecimal("0.5")); + } + break; + } + if ((date4CalcAmount.compareTo(ageLimitChangeDate2) >= 0) + && (baseAmount_releaseDate.doubleValue() <= 0 || calcMethod == 2)) { + if (baseAmount_releaseDate.doubleValue() <= 0 && baseAmount_ageLimitChangeDate2.doubleValue() > 0) { + needConvert = true; + if (belongYear.compareTo(companyStartDate.substring(0, 4)) == 0) { + calendar = DateUtil.getCalendar(ageLimitChangeDatetemp); + }else{ + calendar = DateUtil.getCalendar(ageLimitChangeDate2); + } + + baseAmount = baseAmount_ageLimitChangeDate2; + } else { + if (calcMethod == 2) { + baseAmount = baseAmount_ageLimitChangeDate2; + } + } + } + if ((date4CalcAmount.compareTo(ageLimitChangeDate) >= 0) + && (baseAmount_ageLimitChangeDate2.doubleValue() <= 0 || calcMethod == 2)) { + if (baseAmount_ageLimitChangeDate2.doubleValue() <= 0 && baseAmount_ageLimitChangeDate.doubleValue() > 0) { + needConvert = true; + if (belongYear.compareTo(companyStartDate.substring(0, 4)) == 0) { + calendar = DateUtil.getCalendar(ageLimitChangeDatetemp); + }else{ + calendar = DateUtil.getCalendar(ageLimitChangeDate); + } + + baseAmount = baseAmount_ageLimitChangeDate; + } else { + if (calcMethod == 2) { + baseAmount = baseAmount_ageLimitChangeDate; + } + } + } + } + } + } + + if (needConvert) { + //这一年一共有多少天 + BigDecimal actualMaximum = new BigDecimal("" + calendar.getActualMaximum(Calendar.DAY_OF_YEAR)); + //年假变动日期是这一天的第几天 + BigDecimal dayOfYear = new BigDecimal("" + (calendar.get(Calendar.DAY_OF_YEAR) - 1)); + + if (convertMode == 0) { + baseAmount = baseAmount; + } else if (convertMode == 1) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum, decimalDigit, RoundingMode.HALF_UP); + } else if (convertMode == 2) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum, 0, RoundingMode.UP); + } else if (convertMode == 3) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum, 0, RoundingMode.DOWN); + } else if (convertMode == 4) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum.multiply(new BigDecimal("0.5")), 0, RoundingMode.UP).multiply(new BigDecimal("0.5")); + } else if (convertMode == 5) { + baseAmount = baseAmount.multiply(actualMaximum.subtract(dayOfYear)).divide(actualMaximum.multiply(new BigDecimal("0.5")), 0, RoundingMode.DOWN).multiply(new BigDecimal("0.5")); + } + } else { + baseAmount = baseAmount; + } + + } catch (Exception e) { + e.printStackTrace(); + } + return baseAmount.setScale(decimalDigit, RoundingMode.HALF_UP).doubleValue(); + } + + /** + * [8-育儿假]计算假期基数 + * + * @param params Map + * belongYear:所属年份 + * createDate:人员创建日期 + * workStartDate:参加工作日期 + * companyStartDate:入职日期 + * rulesDetailId:假期规则的ID + * distributionMode:当前假期规则发放方式 + * annualAmount:当[distributionMode]=[4-每年发放固定天数]时有效 + * legalKey:法定年假规则(当[distributionMode=6]时有效):0-工龄、1-司龄、2-工龄+司龄 + * welfareKey:福利年假规则(当[distributionMode=6]时有效):0-工龄、1-司龄、2-工龄+司龄 + * calcMethod:假期基数计算方式 + * convertMode:折算方式 + * decimalDigit:折算后的假期余额保留几位小数 + * @return + */ + private static Map getBaseAmountByDis8(Map params) { + Map returnMap = Maps.newHashMap(); + + try{ + String resourceId = Util.null2String(params.get("resourceId")); + ArrayList listDates = getParentalLeaveDate(resourceId); + //当前日期 + String currentDate = DateUtil.getCurrentDate(); + //批处理年份 + String belongYear = Util.null2String(params.get("belongYear")); + String belongYearNew = ""; + //当[distributionMode]=[8-每年发放固定天数]时有效 + double annualAmount = Util.getDoubleValue("" + params.get("annualAmount"), 0); + //孩子周岁 + int yearsOld = Util.getIntValue(Util.null2String(params.get("yearsOld")),3); + + + BigDecimal baseAmount = new BigDecimal("0"); + int decimalDigit = 2; + boolean addOrUpdate = false; + String expirationDate = ""; + String expirationDateNew = ""; + //折算后的假期余额保留几位小数 + decimalDigit = Util.getIntValue("" + params.get("decimalDigit"), 2); + //批处理日期(因为存在当前年份批处理上一年份或者批处理下一年份,所以需要做一些特殊处理) + String date4CalcAmount = currentDate; + String effectiveDate = ""; + int validityRule = Util.getIntValue(Util.null2String(params.get("validityRule")),1); + /* + * 1、考虑1个孩子,0年、1年、2年发放 + * 2、考虑2个孩子,0年、1年、2年发放,第一个孩子有效期到期了,才考虑第二个孩子的。如果当前日期在第二个孩子有效期内,那么就存到有效期对应的当前年份 + *第二个孩子的2021年1月1号 + * */ + for (int i = 0; i < listDates.size(); i++) { + String dateOfBirth=listDates.get(i); + + String yearOfBirth=dateOfBirth.substring(0,4); + + String baseAmountReleaseDate = belongYear + dateOfBirth.substring(4); + int ageLimit = getAgeLimit(dateOfBirth, baseAmountReleaseDate); + + if(ageLimit>=0&&ageLimit<=yearsOld-1){ + baseAmount = new BigDecimal("" + annualAmount); + }else{ + baseAmount = new BigDecimal("0"); + } + effectiveDate=baseAmountReleaseDate; +//第二个孩子的情况 + if(!expirationDateNew.equals("")&& belongYear.compareTo(expirationDateNew.substring(0, 4)) == 0){ + if(baseAmountReleaseDate.compareTo(expirationDateNew) > 0){ + if(date4CalcAmount.compareTo(expirationDateNew) > 0&&date4CalcAmount.compareTo(baseAmountReleaseDate) < 0){ + belongYearNew = (Util.getIntValue(belongYear) - 1) + ""; + addOrUpdate = true; + new BaseBean().writeLog("育儿假1:belongYearNew="+belongYearNew); + continue; + }else if(date4CalcAmount.compareTo(expirationDateNew) <= 0){ + baseAmount = new BigDecimal("0"); + new BaseBean().writeLog("育儿假2:baseAmount="+baseAmount); + continue; + } + }else{ + if(date4CalcAmount.compareTo(expirationDateNew) >= 0){ + new BaseBean().writeLog("育儿假3:baseAmount="+baseAmount); + break; + }else{ + baseAmount = new BigDecimal("0"); + new BaseBean().writeLog("育儿假4:baseAmount="+baseAmount); + continue; + } + } + } + expirationDateNew = (Util.getIntValue(yearOfBirth) + yearsOld) + dateOfBirth.substring(4); + + String _expirationDate = (Util.getIntValue(belongYear) + 1) + dateOfBirth.substring(4); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate yesterday = LocalDate.parse(_expirationDate, formatter).minusDays(1); + expirationDate = yesterday.toString(); // 过期日期提前了一天 + + if(ageLimit>=0&&ageLimit<=yearsOld-1){ + }else{ + baseAmount = new BigDecimal("0"); + new BaseBean().writeLog("育儿假5:baseAmount="+baseAmount); + continue; + } + + //批处理日期>=假期基数释放日期--出生日期 + if (date4CalcAmount.compareTo(baseAmountReleaseDate) >= 0) { + } else { + baseAmount = new BigDecimal("0"); + } + new BaseBean().writeLog("育儿假6:baseAmount="+baseAmount); + break; + } + new BaseBean().writeLog("育儿假7:baseAmount="+baseAmount); + if (validityRule == 0) { + + expirationDate = "2222-12-31"; + } + returnMap.put("baseAmount", baseAmount.setScale(decimalDigit, RoundingMode.HALF_UP).doubleValue()); + returnMap.put("addOrUpdate",addOrUpdate); + returnMap.put("expirationDate",expirationDate); + returnMap.put("effectiveDate",effectiveDate); + returnMap.put("belongYearNew",belongYearNew); + } catch (Exception e) { + e.printStackTrace(); + } + return returnMap; + } + /** + * [8-育儿假]计算假期基数 + * + * @param params Map + * belongYear:所属年份 + * createDate:人员创建日期 + * workStartDate:参加工作日期 + * companyStartDate:入职日期 + * rulesDetailId:假期规则的ID + * distributionMode:当前假期规则发放方式 + * annualAmount:当[distributionMode]=[4-每年发放固定天数]时有效 + * legalKey:法定年假规则(当[distributionMode=6]时有效):0-工龄、1-司龄、2-工龄+司龄 + * welfareKey:福利年假规则(当[distributionMode=6]时有效):0-工龄、1-司龄、2-工龄+司龄 + * calcMethod:假期基数计算方式 + * convertMode:折算方式 + * decimalDigit:折算后的假期余额保留几位小数 + * @return + */ + private static Map getBaseAmountByDis8Num(Map params) { + Map returnMap = Maps.newHashMap(); + + try{ + String resourceId = Util.null2String(params.get("resourceId")); + String ruleId = Util.null2String(params.get("ruleId")); + String operator = Util.null2String(params.get("operator")); + ArrayList listDates = getParentalLeaveDate(resourceId); + ArrayList listChildId = getChildId(resourceId); + //当前日期 + String currentDate = DateUtil.getCurrentDate(); + + /*获取当前日期,当前时间*/ + Calendar today = Calendar.getInstance(); + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + //当前年份 + String currentYear = currentDate.substring(0, 4); + //批处理年份 + String belongYear = Util.null2String(params.get("belongYear")); + String belongYearNew = ""; + //当[distributionMode]=[8-每年发放固定天数]时有效 + double annualAmount = Util.getDoubleValue("" + params.get("annualAmount"), 0); + //孩子周岁 + int yearsOld = Util.getIntValue(Util.null2String(params.get("yearsOld")),3); + BigDecimal baseAmount = new BigDecimal("0"); + int decimalDigit = 2; + boolean addOrUpdate = false; + String expirationDate = ""; + String expirationDateNew = currentDate; + + + //折算后的假期余额保留几位小数 + decimalDigit = Util.getIntValue("" + params.get("decimalDigit"), 2); + //批处理日期(因为存在当前年份批处理上一年份或者批处理下一年份,所以需要做一些特殊处理) + String date4CalcAmount = currentDate; + + int validityRule = Util.getIntValue(Util.null2String(params.get("validityRule")),1); + RecordSet rs = new RecordSet(); + // 查询当年育儿假数据 + String sql = "select * from kq_balanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId = "+ruleId+" and ( OVERTIMETYPE<>'7' or overtimeType is null ) and resourceId = "+resourceId + " and belongYear = "+belongYear; + KQBalanceOfLeaveEntity balanceEntity = null; + Map balanceEntities = new HashMap(); + rs.executeQuery(sql); + while (rs.next()) { + int id = rs.getInt("id"); + String childId = Util.null2s(rs.getString("childId"), ""); + if(StringUtils.isNotBlank(childId)){ + double baseAmountvalue = Util.getDoubleValue(rs.getString("baseAmount"), 0.00); + double extraAmountvalue = Util.getDoubleValue(rs.getString("extraAmount"), 0.00); + double usedAmountvalue = Util.getDoubleValue(rs.getString("usedAmount"), 0.00); + balanceEntity = new KQBalanceOfLeaveEntity(); + balanceEntity.setId(id); + balanceEntity.setBaseAmount(baseAmountvalue); + balanceEntity.setExtraAmount(extraAmountvalue); + balanceEntity.setUsedAmount(usedAmountvalue); + balanceEntities.put(childId, balanceEntity); + } + } + + for (int i = 0; i < listDates.size(); i++) { + // 孩子的生日 + String dateOfBirth=listDates.get(i); + // 孩子的id + String childId = listChildId.get(i); + String baseAmountReleaseDate = belongYear + dateOfBirth.substring(4); + int ageLimit = getAgeLimit(dateOfBirth, baseAmountReleaseDate); + new BaseBean().writeLog("==getBaseAmountByDis8Num==ageLimit"+ageLimit); + if(ageLimit>=0&&ageLimit<=yearsOld-1) { + baseAmount = new BigDecimal("" + annualAmount); + + // 首先是查询数据库中是否存在这条数据 + // 旧数据是不存在孩子id的,所以现在根据孩子id和是否导入判断删除旧数据 + sql = "select * from kq_balanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId = " + ruleId + " and childId IS NULL and ( OVERTIMETYPE<>'7' or overtimeType is null ) and resourceId = " + resourceId + " and belongYear = " + belongYear; + rs.executeQuery(sql); + double usedAmount = 0; + int id = -1; + if (rs.next()) { + // 旧数据使用量 + usedAmount = Util.getDoubleValue(rs.getString("usedamount"), 0.0); + // 旧数据记录id + id = rs.getInt("id"); + rs.writeLog("==lzl==resourceId=" + resourceId + "的旧数据id" + id + "使用情况:usedAmount" + usedAmount); + } + if (id > 0) { + // 删除旧数据 + rs.executeUpdate("DELETE FROM kq_balanceOfLeave WHERE id =" + id); + } + RecordSet recordSet = new RecordSet(); + KQBalanceOfLeaveEntity oldBalanceEntity = (KQBalanceOfLeaveEntity) balanceEntities.get(childId); + if (oldBalanceEntity != null) { + balanceEntities.remove(childId); + //如果假期基数没有发生变化,不需要更新 + if (oldBalanceEntity.getBaseAmount() == baseAmount.doubleValue()) { + continue; + } + // 如果存在数据就更新 baseAmount,为什么需要跟新这个数据呢?这是因为基数是可能发生改变的。 + int balanceOfLeaveId = oldBalanceEntity.getId(); + + String _expirationDate = (Util.getIntValue(belongYear) + 1) + dateOfBirth.substring(4); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate yesterday = LocalDate.parse(_expirationDate, formatter).minusDays(1); + expirationDate = yesterday.toString(); // 过期日期提前了一天 + if (validityRule == 0) { + //不限制有效期,默认永久有效(永久有效时有效日期默认为2222-12-31) + expirationDate = "2222-12-31"; + } + String updateSql = "UPDATE kq_balanceOfLeave SET baseAmount = " + baseAmount + ",expirationDate='" + expirationDate + "' WHERE id = " + balanceOfLeaveId; + recordSet.writeLog("==lzl==updateSql" + updateSql); + recordSet.executeUpdate(updateSql); + + /* 执行 update 操作的日志记录 */ + String sql3 = "insert into kq_UsageHistory(leaveRulesId,relatedId,operator,operateDate,operateTime,operateType," + + "belongYear,oldBaseAmount,newBaseAmount,insertOrUpdate,oldMinimumUnit,newMinimumUnit,balanceOfLeaveId)" + + "values(" + ruleId + "," + resourceId + "," + operator + ",'" + currentDate + "','" + currentTime + "',6,'" + belongYear + "'," + oldBalanceEntity.getBaseAmount() + "," + baseAmount + ",'update',1,1," + balanceOfLeaveId + ")"; + recordSet.executeUpdate(sql3); + } else { + // 发放日期的年份加1 + String _expirationDate = (Util.getIntValue(belongYear) + 1) + dateOfBirth.substring(4); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate yesterday = LocalDate.parse(_expirationDate, formatter).minusDays(1); + expirationDate = yesterday.toString(); // 过期日期提前了一天 + if (validityRule == 0) { + //不限制有效期,默认永久有效(永久有效时有效日期默认为2222-12-31) + expirationDate = "2222-12-31"; + } + // 解析日期字符串为 LocalDate 对象 + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate releaseDate = LocalDate.parse(baseAmountReleaseDate, dateFormatter); + LocalDate now = LocalDate.parse(currentDate, dateFormatter); + // 比较日期 只有当前日期大于发放日期才可以用 + int comparisonResult = releaseDate.compareTo(now); + if (comparisonResult <= 0) { + String insertSql = "INSERT INTO " + + "kq_balanceOfLeave (LEAVERULESID,RESOURCEID,BELONGYEAR,STATUS,EXPIRATIONDATE,EFFECTIVEDATE,BASEAMOUNT,EXTRAAMOUNT,USEDAMOUNT,BASEAMOUNT2,EXTRAAMOUNT2,USEDAMOUNT2,TIAOXIUAMOUNT,childId,isdelete) " + + "VALUES (" + ruleId + "," + resourceId + ",'" + belongYear + "',0,'" + expirationDate + "','" + baseAmountReleaseDate + "'," + baseAmount + " ,0," + usedAmount + ",0,0,0,0," + childId + ",0)"; + recordSet.writeLog("==lzl==insertSql" + insertSql); + recordSet.executeUpdate(insertSql); + String sql2 = "select * from kq_balanceOfLeave where leaveRulesId = " + ruleId + " and resourceId = " + resourceId + " and childId =" + childId + " and ( OVERTIMETYPE<>'7' or overtimeType is null ) and belongYear = '" + belongYear + "' and (isdelete <> 1 OR isdelete IS NULL)"; + recordSet.executeQuery(sql2); + String balanceOfLeaveId = ""; + if (recordSet.next()) { + balanceOfLeaveId = recordSet.getString("id"); + } + /* 执行 insert 操作的日志记录 */ + String sql3 = "insert into kq_UsageHistory(leaveRulesId,relatedId,operator,operateDate,operateTime,operateType," + + "belongYear,oldBaseAmount,newBaseAmount,insertOrUpdate,oldMinimumUnit,newMinimumUnit,oldExtraAmount,newExtraAmount,oldUsedAmount,newUsedAmount,oldBaseAmount2,newBaseAmount2,oldExtraAmount2,newExtraAmount2,oldUsedAmount2,newUsedAmount2,balanceOfLeaveId)" + + "values(" + ruleId + "," + resourceId + "," + operator + ",'" + currentDate + "','" + currentTime + "',6,'" + belongYear + "'," + 0 + "," + baseAmount + ",'insert',1,1,0,0,0,0,0,0,0,0,0,0," + balanceOfLeaveId + ")"; + recordSet.executeUpdate(sql3); + } + } + } + } + + // 删除不是当前孩子列表中的考勤数据 + + balanceEntities.forEach((key, value) -> { + String chlied = key; + KQBalanceOfLeaveEntity oldBalanceEntity = (KQBalanceOfLeaveEntity) value; + + String deleteSql = "UPDATE kq_balanceOfLeave SET isdelete=1 WHERE id = " + oldBalanceEntity.getId(); + String sql3 = "insert into kq_UsageHistory(leaveRulesId,relatedId,operator,operateDate,operateTime,operateType," + + "belongYear,oldBaseAmount,newBaseAmount,insertOrUpdate,oldMinimumUnit,newMinimumUnit,balanceOfLeaveId)" + + "values(" + ruleId + "," + resourceId + "," + operator + ",'" + currentDate + "','" + currentTime + "',6,'" + belongYear + "'," + oldBalanceEntity.getBaseAmount() + ",0,'update',1,1," + oldBalanceEntity.getId() + ")"; + if (oldBalanceEntity.getExtraAmount() > 0 || + oldBalanceEntity.getUsedAmount() > 0) { + deleteSql = "UPDATE kq_balanceOfLeave SET baseAmount=0 WHERE id = " + oldBalanceEntity.getId(); + } + rs.executeUpdate(deleteSql); + rs.executeUpdate(sql3); + }); + + returnMap.put("baseAmount", baseAmount.setScale(decimalDigit, RoundingMode.HALF_UP).doubleValue()); + returnMap.put("addOrUpdate",addOrUpdate); + returnMap.put("expirationDate",expirationDateNew); + returnMap.put("belongYearNew",belongYearNew); + } catch (Exception e) { + e.printStackTrace(); + } + return returnMap; + } + + + /** + * [7-按司龄自动发放(入职日期当天发放假期余额)]计算假期基数 + * + * @param params Map + * belongYear:所属年份 + * createDate:人员创建日期 + * workStartDate:参加工作日期 + * companyStartDate:入职日期 + * rulesDetailId:假期规则的ID + * distributionMode:当前假期规则发放方式 + * annualAmount:当[distributionMode]=[4-每年发放固定天数]时有效 + * legalKey:法定年假规则(当[distributionMode=6]时有效):0-工龄、1-司龄、2-工龄+司龄 + * welfareKey:福利年假规则(当[distributionMode=6]时有效):0-工龄、1-司龄、2-工龄+司龄 + * calcMethod:假期基数计算方式 + * convertMode:折算方式 + * decimalDigit:折算后的假期余额保留几位小数 + * @return + */ + private static double getBaseAmountByDis7(Map params) { + double baseAmount = 0; + try{ + //当前日期 + String currentDate = DateUtil.getCurrentDate(); + //当前年份 + String currentYear = currentDate.substring(0, 4); + //批处理年份 + String belongYear = Util.null2String(params.get("belongYear")); + //人员的参加工作日期 + String workStartDate = Util.null2String(params.get("workStartDate")); + //人员的入职日期 + String companyStartDate = Util.null2String(params.get("companyStartDate")); + + //假期规则的ID + String rulesDetailId = Util.null2String(params.get("rulesDetailId")); + //当前假期规则发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按入职时长+工龄自动发放 + int distributionMode = Util.getIntValue("" + params.get("distributionMode"), 1); + //假期基数发放日期 + String baseAmountReleaseDate = belongYear + companyStartDate.substring(4); + //默认保留两位小数 + int decimalDigit = Util.getIntValue("" + params.get("decimalDigit"), 2); + + if (distributionMode != 7) { + return baseAmount; + } + + //批处理日期 + String date4CalcAmount = currentDate; + + //人员在【假期基数发放日期】时对应的【司龄】 + int ageLimit = getAgeLimit(companyStartDate, baseAmountReleaseDate); + //人员在【假期基数发放日期】时应有的【假期基数】 + BigDecimal baseAmount_releaseDate = getAmountByAgeLimit(distributionMode, rulesDetailId, 0, ageLimit, -1, -1, -1, ""); + + //批处理日期>=假期基数释放日期 + if (date4CalcAmount.compareTo(baseAmountReleaseDate) >= 0) { + baseAmount = baseAmount_releaseDate.setScale(2, RoundingMode.HALF_UP).doubleValue(); + } else { + baseAmount = 0; + } + }catch (Exception e){ + e.printStackTrace(); + } + return baseAmount; + } + + /** + * 获取调休的余额 + * + * @param ruleId 假期类型的ID + * @param resourceId 人员ID + * @param searchDate 计算是否失效的指定日期 + * @param calcByCurrentDate 是根据当前日期计算还是根据指定日期计算假期是否失效:true-当前日期、false-指定日期 + * @param isAll 是获取所有年份的还是获取指定年份的:true-所有年份的、false-指定年份的 + * @return + */ + private static BigDecimal getRestAmountByDis5(String ruleId, String resourceId, String searchDate, boolean calcByCurrentDate, boolean isAll) { + BigDecimal restAmount = new BigDecimal("0"); + try { + //获取当前日期 + Calendar today = Calendar.getInstance(); + //当前日期 + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + //所属年份 + String searchYear = searchDate.substring(0, 4); + //根据指定日期(或者根据当前日期)判断假期是否已经过了有效期 + String date = calcByCurrentDate ? currentDate : searchDate; + String sql = ""; + RecordSet recordSet = new RecordSet(); + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") + || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql = " select sum(tiaoxiuamount) as allTiaoxiuamount,sum(baseAmount) as allBaseAmount,sum(extraAmount) as allExtraAmount,sum(usedAmount) as allUsedAmount from KQ_BalanceOfLeave " + + " where (isDelete is null or isDelete<>1) and resourceId=" + resourceId + " and leaveRulesId=" + ruleId + " and (expirationDate is null or expirationDate='' or expirationDate>='" + date + "') "; + } else { + sql = " select sum(tiaoxiuamount) as allTiaoxiuamount,sum(baseAmount) as allBaseAmount,sum(extraAmount) as allExtraAmount,sum(usedAmount) as allUsedAmount from KQ_BalanceOfLeave " + + " where (isDelete is null or isDelete<>1) and resourceId=" + resourceId + " and leaveRulesId=" + ruleId + " and (expirationDate is null or expirationDate>='" + date + "') "; + } + //是查询所有有效的假期余额还是仅仅查询指定日期当年的 + if(KQSettingsBiz.is_balanceofleave()){//开启开关 + if (!isAll) { + sql += " and belongYear='" + searchYear + "'"; + }else{ + sql += " and belongYear<='" + searchYear + "'"; + } + }else{ + if (!isAll) { + sql += " and belongYear='" + searchYear + "'"; + } + } + recordSet.executeQuery(sql); + while (recordSet.next()) { + BigDecimal _baseAmount = new BigDecimal(Util.null2s(recordSet.getString("allBaseAmount"), "0")); + BigDecimal _extraAmount = new BigDecimal(Util.null2s(recordSet.getString("allExtraAmount"), "0")); + BigDecimal _usedAmount = new BigDecimal(Util.null2s(recordSet.getString("allUsedAmount"), "0")); + BigDecimal _tiaoxiuamount = new BigDecimal(Util.null2s(recordSet.getString("allTiaoxiuamount"), "0"));//加班生成调休 + + restAmount = restAmount.add(_baseAmount).add(_tiaoxiuamount).add(_extraAmount).subtract(_usedAmount); + } + } catch (Exception e) { + e.printStackTrace(); + } + return restAmount; + } + + private static BigDecimal getRestAmountByDis8(String ruleId, String resourceId, String searchDate, boolean calcByCurrentDate, boolean isAll) { + BigDecimal restAmount = new BigDecimal("0"); + try { + //获取当前日期 + Calendar today = Calendar.getInstance(); + //当前日期 + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + //所属年份 + String searchYear = searchDate.substring(0, 4); + //根据指定日期(或者根据当前日期)判断假期是否已经过了有效期 + String date = calcByCurrentDate ? currentDate : searchDate; + String sql = ""; + RecordSet recordSet = new RecordSet(); + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") + || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql = " select sum(baseAmount) as allBaseAmount,sum(extraAmount) as allExtraAmount,sum(usedAmount) as allUsedAmount from KQ_BalanceOfLeave " + + " where (isDelete is null or isDelete<>1) and resourceId=" + resourceId + " and leaveRulesId=" + ruleId + " and (expirationDate is null or expirationDate='' or expirationDate>='" + date + "') "; + } else { + sql = " select sum(baseAmount) as allBaseAmount,sum(extraAmount) as allExtraAmount,sum(usedAmount) as allUsedAmount from KQ_BalanceOfLeave " + + " where (isDelete is null or isDelete<>1) and resourceId=" + resourceId + " and leaveRulesId=" + ruleId + " and (expirationDate is null or expirationDate>='" + date + "') "; + } + //是查询所有有效的假期余额还是仅仅查询指定日期当年的 + if(KQSettingsBiz.is_balanceofleave()){//开启开关 + if (!isAll) { + sql += " and belongYear='" + searchYear + "'"; + }else{ + sql += " and belongYear<='" + searchYear + "'"; + } + }else{ + if (!isAll) { + sql += " and belongYear='" + searchYear + "'"; + } + } + recordSet.executeQuery(sql); + while (recordSet.next()) { + BigDecimal _baseAmount = new BigDecimal(Util.null2s(recordSet.getString("allBaseAmount"), "0")); + BigDecimal _extraAmount = new BigDecimal(Util.null2s(recordSet.getString("allExtraAmount"), "0")); + BigDecimal _usedAmount = new BigDecimal(Util.null2s(recordSet.getString("allUsedAmount"), "0")); + restAmount = restAmount.add(_baseAmount).add(_extraAmount).subtract(_usedAmount); + } + } catch (Exception e) { + e.printStackTrace(); + } + return restAmount; + } + /** + * 获取调休的余额 + * + * @param params + * @param user + * @return + */ + public static Map getRestAmountMapByDis5(Map params, User user) { + Map balanceMap = new HashMap(); + try { + /** + * 分页控件返回的值 + * currentPage:当前页数 + * pageSize:每页多少条数据 + * showAll:是显示分页还是显示所有 + */ + int currentPage = Util.getIntValue((String) params.get("currentPage"), 1); + int pageSize = Util.getIntValue((String) params.get("pageSize"), 10); + boolean showAll = Util.null2s((String) params.get("showAll"), "true").equals("true"); + /** + * 时间范围选择的年份 + * 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")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + + /** + * isNoAccount:是否显示无账号人员:true-显示、false-不显示 + */ + String isNoAccount = Util.null2String(params.get("isNoAccount")); + /** + * 假期类型的ID + */ + String leaveRulesId = Util.null2String(params.get("leaveRulesId")); + /** + * 当前日期 + */ + String currentDate = DateUtil.getCurrentDate(); + /** + * 获取考勤报表权限共享设置 + */ + KQReportBiz kqReportBiz = new KQReportBiz(); + String rightStr = kqReportBiz.getReportRight("4", "" + user.getUID(), "a"); + + RecordSet recordSet = new RecordSet(); + String sql = "select a.id hrmResourceId,b.* from HrmResource a left join "; + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sql = "select a.id hrmResourceId,b.*,ROW_NUMBER() OVER(order by dspOrder,a.id) as rn from HrmResource a left join "; + } + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") + || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql += "(select resourceId, sum(baseAmount) as allBaseAmount, sum(tiaoxiuamount) as allTiaoxiuamount,sum(extraAmount) as allExtraAmount, sum(usedAmount) as allUsedAmount " + + "from kq_balanceOfLeave " + + "where 1=1 and (isDelete is null or isDelete<>1) and (expirationDate is null or expirationDate='' or expirationDate >= '" + currentDate + "') and belongYear='" + selectedYear + "' and leaveRulesId=" + leaveRulesId + " " + + "group by resourceId) b " + + "on a.id = b.resourceId where 1=1 "; + } else { + sql += "(select resourceId, sum(baseAmount) as allBaseAmount, sum(tiaoxiuamount) as allTiaoxiuamount,sum(extraAmount) as allExtraAmount, sum(usedAmount) as allUsedAmount " + + "from kq_balanceOfLeave " + + "where 1=1 and (isDelete is null or isDelete<>1) and (expirationDate is null or expirationDate >= '" + currentDate + "') and belongYear='" + selectedYear + "' and leaveRulesId=" + leaveRulesId + " " + + "group by resourceId) b " + + "on a.id = b.resourceId 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(resourceStatus.length()>0){ + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sql += " and a.status = "+resourceStatus+ ""; + }else if (resourceStatus.equals("8")) { + sql += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + 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 "; + } + if (!showAll) { + 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; + }else if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + pageSql = sql + " limit " + pageSize + " offset " + (currentPage - 1) * pageSize; + } + recordSet.executeQuery(pageSql); + } else { + recordSet.executeQuery(sql); + } + while (recordSet.next()) { + String hrmResourceId = Util.null2String(recordSet.getString("hrmResourceId")); + BigDecimal allBaseAmount = new BigDecimal(Util.null2s(recordSet.getString("allBaseAmount"), "0")); + BigDecimal allExtraAmount = new BigDecimal(Util.null2s(recordSet.getString("allExtraAmount"), "0")); + BigDecimal allUsedAmount = new BigDecimal(Util.null2s(recordSet.getString("allUsedAmount"), "0")); + BigDecimal allTiaoxiuamount = new BigDecimal(Util.null2s(recordSet.getString("allTiaoxiuamount"), "0")); + + balanceMap.put(hrmResourceId + "_" + leaveRulesId, allBaseAmount.add(allExtraAmount).add(allTiaoxiuamount).subtract(allUsedAmount)); + } + } catch (Exception e) { + e.printStackTrace(); + } + return balanceMap; + } + + + + /** + * qc 获取育儿假的余额 + * + * @param params + * @param user + * @return + */ + public static Map getRestAmountMapByDis8(Map params, User user) { + Map balanceMap = new HashMap(); + try { + /** + * 分页控件返回的值 + * currentPage:当前页数 + * pageSize:每页多少条数据 + * showAll:是显示分页还是显示所有 + */ + int currentPage = Util.getIntValue((String) params.get("currentPage"), 1); + int pageSize = Util.getIntValue((String) params.get("pageSize"), 10); + boolean showAll = Util.null2s((String) params.get("showAll"), "true").equals("true"); + /** + * 时间范围选择的年份 + * 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")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + + /** + * isNoAccount:是否显示无账号人员:true-显示、false-不显示 + */ + String isNoAccount = Util.null2String(params.get("isNoAccount")); + /** + * 假期类型的ID + */ + String leaveRulesId = Util.null2String(params.get("leaveRulesId")); + /** + * 当前日期 + */ + String currentDate = DateUtil.getCurrentDate(); + /** + * 获取考勤报表权限共享设置 + */ + KQReportBiz kqReportBiz = new KQReportBiz(); + String rightStr = kqReportBiz.getReportRight("4", "" + user.getUID(), "a"); + + RecordSet recordSet = new RecordSet(); + String sql = "select a.id hrmResourceId,b.* from HrmResource a left join "; + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sql = "select a.id hrmResourceId,b.*,ROW_NUMBER() OVER(order by dspOrder,a.id) as rn from HrmResource a left join "; + } + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") + || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql += "(select resourceId, sum(baseAmount) as allBaseAmount,sum(extraAmount) as allExtraAmount, sum(usedAmount) as allUsedAmount " + + "from kq_balanceOfLeave " + + "where 1=1 and (isDelete is null or isDelete<>1) and (expirationDate is null or expirationDate='' or expirationDate >= '" + currentDate + "') and belongYear='" + selectedYear + "' and leaveRulesId=" + leaveRulesId + " " + + "group by resourceId) b " + + "on a.id = b.resourceId where 1=1 "; + } else { + sql += "(select resourceId, sum(baseAmount) as allBaseAmount,sum(extraAmount) as allExtraAmount, sum(usedAmount) as allUsedAmount " + + "from kq_balanceOfLeave " + + "where 1=1 and (isDelete is null or isDelete<>1) and (expirationDate is null or expirationDate >= '" + currentDate + "') and belongYear='" + selectedYear + "' and leaveRulesId=" + leaveRulesId + " " + + "group by resourceId) b " + + "on a.id = b.resourceId 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(resourceStatus.length()>0){ + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sql += " and a.status = "+resourceStatus+ ""; + }else if (resourceStatus.equals("8")) { + sql += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + 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 "; + } + if (!showAll) { + 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; + }else if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + pageSql = sql + " limit " + pageSize + " offset " + (currentPage - 1) * pageSize; + } + recordSet.executeQuery(pageSql); + } else { + recordSet.executeQuery(sql); + } + while (recordSet.next()) { + String hrmResourceId = Util.null2String(recordSet.getString("hrmResourceId")); + BigDecimal allBaseAmount = new BigDecimal(Util.null2s(recordSet.getString("allBaseAmount"), "0")); + BigDecimal allExtraAmount = new BigDecimal(Util.null2s(recordSet.getString("allExtraAmount"), "0")); + BigDecimal allUsedAmount = new BigDecimal(Util.null2s(recordSet.getString("allUsedAmount"), "0")); + + balanceMap.put(hrmResourceId + "_" + leaveRulesId, allBaseAmount.add(allExtraAmount).subtract(allUsedAmount)); + } + } catch (Exception e) { + e.printStackTrace(); + } + return balanceMap; + } + + /** + * 插入或者更新员工假期余额 + * + * @param newBalanceEntities 新假期余额 + * @param oldBalanceEntities 旧假期余额 + * @param operator 操作者 + * @param canUpdate 是否允许更新 + * @return + */ + private static boolean insertOrUpdateBalance(List newBalanceEntities, Map oldBalanceEntities, String operator, boolean canUpdate) { + /*获取今天的日期、此刻的时间*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + + RecordSet recordSet1 = new RecordSet(); + java.sql.Timestamp date = KQDateUtil.getUpdateTimeStamp(); + String insertSql = "insert into kq_balanceOfLeave(leaveRulesId,resourceId,belongYear,baseAmount,extraAmount,usedAmount,baseAmount2,extraAmount2,usedAmount2,create_time,update_time,creator,effectiveDate,expirationDate) " + + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + if (recordSet1.getDBType().equals("postgresql")) { + insertSql = "insert into kq_balanceOfLeave(leaveRulesId,resourceId,belongYear,baseAmount,extraAmount,usedAmount,baseAmount2,extraAmount2,usedAmount2,create_time,update_time,creator,effectiveDate,expirationDate) " + + "values(?,?,?,?,?,?,?,?,?,?::timestamp,?::timestamp,?,?,?)"; + } + List insertList = new ArrayList(); + List insertParamList = new ArrayList(); + String updateSql = "update kq_balanceOfLeave set leaveRulesId=?,resourceId=?,belongYear=?,baseAmount=?,baseAmount2=?,update_time=?,effectiveDate=?,expirationDate=? where id=?"; + String updateSql2 ="update kq_balanceOfLeave set leaveRulesId=?,resourceId=?,belongYear=?,baseAmount=?,baseAmount2=?,usedAmount=?,extraAmount=?,update_time=?,effectiveDate=?,expirationDate=? where id=?"; + + if (recordSet1.getDBType().equals("postgresql")) { + updateSql = "update kq_balanceOfLeave set leaveRulesId=?,resourceId=?,belongYear=?,baseAmount=?,baseAmount2=?,update_time=?::timestamp,effectiveDate=?,expirationDate=? where id=?"; + updateSql2 ="update kq_balanceOfLeave set leaveRulesId=?,resourceId=?,belongYear=?,baseAmount=?,baseAmount2=?,usedAmount=?,extraAmount=?,update_time=?::timestamp,effectiveDate=?,expirationDate=? where id=?"; + } + List updateList = new ArrayList(); + List updateParamList = new ArrayList(); + List updateParamList2 = new ArrayList(); + List usageHistoryEntities = new ArrayList(); + KQUsageHistoryEntity usageHistoryEntity = null; + for (KQBalanceOfLeaveEntity newBalanceEntity : newBalanceEntities) { + int resourceId = newBalanceEntity.getResourceId(); + int status = newBalanceEntity.getStatus(); + KQBalanceOfLeaveEntity oldBalanceEntity = (KQBalanceOfLeaveEntity) oldBalanceEntities.get("" + resourceId); + if (status == 1) { + String belongYear = newBalanceEntity.getBelongYear(); + String ruleId = newBalanceEntity.getLeaveRulesId() + ""; + Map oldBalanceEntitiesLast = getBalanceEntities(3, resourceId + "", ruleId, belongYear); + oldBalanceEntity = (KQBalanceOfLeaveEntity) oldBalanceEntitiesLast.get("" + resourceId); + } + if (oldBalanceEntity == null || oldBalanceEntity.getId() <= 0) { + insertList = new ArrayList(); + insertList.add(newBalanceEntity.getLeaveRulesId()); + insertList.add(newBalanceEntity.getResourceId()); + insertList.add(newBalanceEntity.getBelongYear()); + insertList.add(newBalanceEntity.getBaseAmount()); + insertList.add(newBalanceEntity.getExtraAmount()); + insertList.add(newBalanceEntity.getUsedAmount()); + insertList.add(newBalanceEntity.getBaseAmount2()); + insertList.add(newBalanceEntity.getExtraAmount2()); + insertList.add(newBalanceEntity.getUsedAmount2()); + insertList.add(date); + insertList.add(date); + insertList.add(Util.getIntValue(resourceId)); + insertList.add(newBalanceEntity.getEffectiveDate()); + insertList.add(newBalanceEntity.getExpirationDate()); + insertParamList.add(insertList); + + usageHistoryEntity = new KQUsageHistoryEntity(); + usageHistoryEntity.setLeaveRulesId("" + newBalanceEntity.getLeaveRulesId()); + usageHistoryEntity.setRelatedId("" + newBalanceEntity.getResourceId()); + usageHistoryEntity.setOperator("" + operator); + usageHistoryEntity.setOperateDate(currentDate); + usageHistoryEntity.setOperateTime(currentTime); + usageHistoryEntity.setOperateType("6"); + usageHistoryEntity.setBelongYear(newBalanceEntity.getBelongYear()); + usageHistoryEntity.setNewBaseAmount("" + newBalanceEntity.getBaseAmount()); + usageHistoryEntity.setNewExtraAmount("" + newBalanceEntity.getExtraAmount()); + usageHistoryEntity.setNewUsedAmount("" + newBalanceEntity.getUsedAmount()); + usageHistoryEntity.setNewBaseAmount2("" + newBalanceEntity.getBaseAmount2()); + usageHistoryEntity.setNewExtraAmount2("" + newBalanceEntity.getExtraAmount2()); + usageHistoryEntity.setNewUsedAmount2("" + newBalanceEntity.getUsedAmount2()); + usageHistoryEntity.setOldMinimumUnit("" + newBalanceEntity.getMinimumUnit()); + usageHistoryEntity.setNewMinimumUnit("" + newBalanceEntity.getMinimumUnit()); + usageHistoryEntity.setInsertOrUpdate("insert"); + usageHistoryEntities.add(usageHistoryEntity); + } else { + updateList = new ArrayList(); + updateList.add(newBalanceEntity.getLeaveRulesId()); + updateList.add(newBalanceEntity.getResourceId()); + updateList.add(newBalanceEntity.getBelongYear()); + updateList.add(newBalanceEntity.getBaseAmount()); + updateList.add(newBalanceEntity.getBaseAmount2()); + if(status==1){ + updateList.add(newBalanceEntity.getUsedAmount()); + updateList.add(newBalanceEntity.getExtraAmount()); + } + updateList.add(date); + updateList.add(newBalanceEntity.getEffectiveDate()); + updateList.add(newBalanceEntity.getExpirationDate()); + updateList.add(oldBalanceEntity.getId()); + if(status==1){ + updateParamList2.add(updateList); + }else{ + updateParamList.add(updateList); + } + + usageHistoryEntity = new KQUsageHistoryEntity(); + usageHistoryEntity.setLeaveRulesId("" + newBalanceEntity.getLeaveRulesId()); + usageHistoryEntity.setRelatedId("" + newBalanceEntity.getResourceId()); + usageHistoryEntity.setOperator("" + operator); + usageHistoryEntity.setOperateDate(currentDate); + usageHistoryEntity.setOperateTime(currentTime); + usageHistoryEntity.setOperateType("6"); + usageHistoryEntity.setBelongYear(newBalanceEntity.getBelongYear()); + usageHistoryEntity.setOldBaseAmount("" + oldBalanceEntity.getBaseAmount()); + usageHistoryEntity.setNewBaseAmount("" + newBalanceEntity.getBaseAmount()); + if(status==1){ + usageHistoryEntity.setOldUsedAmount("" + oldBalanceEntity.getUsedAmount()); + usageHistoryEntity.setNewUsedAmount("" + newBalanceEntity.getUsedAmount()); + usageHistoryEntity.setOldExtraAmount("" + oldBalanceEntity.getExtraAmount()); + usageHistoryEntity.setNewExtraAmount("" + newBalanceEntity.getExtraAmount()); + } + usageHistoryEntity.setOldBaseAmount2("" + oldBalanceEntity.getBaseAmount2()); + usageHistoryEntity.setNewBaseAmount2("" + newBalanceEntity.getBaseAmount2()); + usageHistoryEntity.setOldMinimumUnit("" + oldBalanceEntity.getMinimumUnit()); + usageHistoryEntity.setNewMinimumUnit("" + newBalanceEntity.getMinimumUnit()); + usageHistoryEntity.setInsertOrUpdate("update"); + usageHistoryEntities.add(usageHistoryEntity); + } + } + + boolean isSuccess = true; + RecordSet recordSet = new RecordSet(); + /*新增员工假期余额数据 start*/ + if (insertParamList.size() > 0) { + isSuccess = recordSet.executeBatchSql(insertSql, insertParamList); + } + /*新增员工假期余额数据 end*/ + + /*更新员工假期余额数据 start*/ + if (updateParamList.size() > 0) { + isSuccess = recordSet.executeBatchSql(updateSql, updateParamList); + } + if (updateParamList2.size() > 0) { + isSuccess = recordSet.executeBatchSql(updateSql2, updateParamList2); + } + /*更新员工假期余额数据 end*/ + + /*记录员工假期余额变更记录 start*/ + KQUsageHistoryBiz kqUsageHistoryBiz = new KQUsageHistoryBiz(); + if (usageHistoryEntities.size() > 0) { + isSuccess = kqUsageHistoryBiz.save(usageHistoryEntities); + } + /*记录员工假期余额变更记录 end*/ + + return isSuccess; + } + + /** + * 根据[工龄]、[司龄]获取对应的假期基数 + * + * @param distributionMode [发放方式] + * @param rulesDetailId [假期规则的ID] + * @param annualAmount [发放方式]=[4-每年发放固定天数]时的[固定天数] + * @param ageLimit [工龄]or[司龄]、当[发放方式]=[6-按司龄+工龄自动发放]时的[工龄] + * @param ageLimit2 当[发放方式]=[6-按司龄+工龄自动发放]时的[司龄] + * @param legalKey [法定年假规则]:当[发放方式]=[6-按司龄+工龄自动发放]时有效 + * @param welfareKey [福利年假规则]:当[发放方式]=[6-按司龄+工龄自动发放]时有效 + * @param legalOrWelfare 是计算[法定年假]还是计算[福利年假]:legal-[法定年假]、welfare-[福利年假] + * @return [假期基数] + */ + private static BigDecimal getAmountByAgeLimit(int distributionMode, String rulesDetailId, double annualAmount, + int ageLimit, int ageLimit2, int legalKey, int welfareKey, String legalOrWelfare) { + BigDecimal amount = new BigDecimal("0"); + try { + RecordSet recordSet = new RecordSet(); + if (distributionMode == 2 || distributionMode == 7) { + String sql = "select * from kq_entryToLeave where leaveRulesId=? and lowerLimit<=? and upperLimit>?"; + recordSet.executeQuery(sql, rulesDetailId, ageLimit, ageLimit); + if (recordSet.next()) { + double _amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + amount = new BigDecimal("" + _amount); + } + } else if (distributionMode == 3) { + String sql = "select * from kq_workingAgeToLeave where leaveRulesId=? and lowerLimit<=? and upperLimit>?"; + recordSet.executeQuery(sql, rulesDetailId, ageLimit, ageLimit); + if (recordSet.next()) { + double _amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + amount = new BigDecimal("" + _amount); + } + } else if (distributionMode == 4) { + amount = new BigDecimal("" + annualAmount); + } else if (distributionMode == 6) { + String sql = ""; + if (legalOrWelfare.equals("legal")) { + sql = "select * from kq_MixModeToLegalLeave where 1=1 and leaveRulesId=" + rulesDetailId; + if (legalKey == 0) { + sql += " and limit1<=" + ageLimit; + } else if (legalKey == 1) { + sql += " and limit2<=" + ageLimit2; + } else if (legalKey == 2) { + sql += " and limit1<=" + ageLimit + " and limit2<=" + ageLimit2; + } + } else { + sql = "select * from kq_MixModeToWelfareLeave where 1=1 and leaveRulesId=" + rulesDetailId; + if (welfareKey == 0) { + sql += " and limit1<=" + ageLimit; + } else if (welfareKey == 1) { + sql += " and limit2<=" + ageLimit2; + } else if (welfareKey == 2) { + sql += " and limit1<=" + ageLimit + " and limit2<=" + ageLimit2; + } + } + sql += " order by id desc "; + recordSet.executeQuery(sql); + if (recordSet.next()) { + double _amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + amount = new BigDecimal("" + _amount); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return amount; + } + + + private static ThreadLocal simpleDateFormatThreadLocal = new ThreadLocal<>(); + + private static void init() { + if (simpleDateFormatThreadLocal.get() == null) { + simpleDateFormatThreadLocal.set(new SimpleDateFormat("yyyy-MM-dd")); + } + } + + /** + * 获取两个日期之间的时间差距有几年 + * + * @param fromDate 开始时间 + * @param toDate 结束时间 + * @return + */ + public static int getAgeLimit(String fromDate, String toDate) { + init(); + int ageLImit = 0; + try { + if (toDate.compareTo(fromDate) < 0) { + return -1; + } + Date fd = simpleDateFormatThreadLocal.get().parse(fromDate); + Date td = simpleDateFormatThreadLocal.get().parse(toDate); + Instant fInstant = fd.toInstant(); + Instant tInstant = td.toInstant(); + LocalDate localFromDate = LocalDateTime.ofInstant(fInstant, ZoneId.systemDefault()).toLocalDate(); + LocalDate localToDate = LocalDateTime.ofInstant(tInstant, ZoneId.systemDefault()).toLocalDate(); + + //LocalDate localFromDate = LocalDate.parse(fromDate); + //LocalDate localToDate = LocalDate.parse(toDate); + Period period = Period.between(localFromDate, localToDate); + ageLImit = period.getYears(); + } catch (Exception e) { + e.printStackTrace(); + } + return ageLImit; + } + + + /****************************************************下面是正式系统用的****************************************************/ + + /** + * 获取年假、带薪事假、带薪病假、调休的假期余额信息 + * + * @param resourceId 指定人员ID + * @param languageId 当前系统语言 + * @return + */ + public static List getBalanceInfo(String resourceId, int languageId) { + String resultStr = ""; + List dataList = new ArrayList(); + try { + /*获取当前日期,当前时间*/ + Calendar today = Calendar.getInstance(); + String lastDayOfLastYear = Util.add0(today.get(Calendar.YEAR) - 1, 4) + "-12-31"; + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + + Map itemMap = new HashMap(); + List itemList = new ArrayList(); + Map dataMap = new HashMap(); + + String sql = "select * from kq_LeaveRules where 1=1 and (isDelete is null or isDelete<>1) and isEnable=1 and leaveCode in ('annualLeave','paidCompassionateLeave','paidSickLeave','vacationLeave')"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String ruleId = recordSet.getString("id"); + String leaveCode = recordSet.getString("leaveCode"); + + String title = ""; + switch (leaveCode) { + case "annualLeave": + title = SystemEnv.getHtmlLabelName(501313, languageId); + break; + case "paidCompassionateLeave": + title = SystemEnv.getHtmlLabelName(501314, languageId); + break; + case "paidSickLeave": + title = SystemEnv.getHtmlLabelName(501315, languageId); + break; + case "vacationLeave": + title = SystemEnv.getHtmlLabelName(31297, languageId); + break; + default: + break; + } + + String minimumUnit = kqLeaveRulesComInfo.getMinimumUnit(ruleId);//最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假 + + String currentYearAmount = getRestAmount(resourceId, ruleId, currentDate, true, false);//本年剩余年假时长 + String allAmount = getRestAmount(resourceId, ruleId, currentDate, true, true);//当前剩余年假时长 + String lastYearAmount = String.format("%.2f", Util.getDoubleValue(allAmount, 0) - Util.getDoubleValue(currentYearAmount, 0));;//历年剩余年假时长 + + itemList = new ArrayList(); + if (!leaveCode.equals("vacationLeave")) { + itemMap = new HashMap(); + itemMap.put("name", KQUnitBiz.isLeaveHour(minimumUnit+"") ? SystemEnv.getHtmlLabelName(513286, languageId) : SystemEnv.getHtmlLabelName(513287, languageId)); + itemMap.put("value", lastYearAmount); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("name", KQUnitBiz.isLeaveHour(minimumUnit+"") ? SystemEnv.getHtmlLabelName(501311, languageId) : SystemEnv.getHtmlLabelName(132012, languageId)); + itemMap.put("value", currentYearAmount); + itemList.add(itemMap); + } + itemMap = new HashMap(); + itemMap.put("name", KQUnitBiz.isLeaveHour(minimumUnit+"") ? SystemEnv.getHtmlLabelName(513288, languageId) : SystemEnv.getHtmlLabelName(513289, languageId)); + itemMap.put("value", allAmount); + itemList.add(itemMap); + + dataMap = new HashMap(); + dataMap.put("detail", itemList); + dataMap.put("title", title); + dataMap.put("leaveCode", leaveCode); + + dataList.add(dataMap); + } + } catch (Exception e) { + e.printStackTrace(); + } + return dataList; + } + + /** + * 获取正式系统请假流程协同区所需的相关数据 + * + * @param resourceId + * @param searchYear + * @return + */ + public static Map getSynergyZoneInfo(String resourceId, String searchYear) { + Map resultMap = new HashMap(); + try { + /*获取当前日期,当前时间*/ + Calendar today = Calendar.getInstance(); + String lastDayOfLastYear = Util.add0(today.get(Calendar.YEAR) - 1, 4) + "-12-31"; + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + double usedAmount1 = 0.00;//年假已用 + double restAmount1 = 0.00;//年假剩余 + + String sql = "select * from kq_leaveRules where 1=1 and (isDelete is null or isDelete <>1) and leaveCode='annualLeave'"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + String ruleId = recordSet.getString("id"); + + sql = "select * from kq_BalanceOfLeave where belongYear=? and resourceId=? and leaveRulesId=?"; + recordSet.executeQuery(sql, searchYear, resourceId, ruleId); + if (recordSet.next()) { + usedAmount1 = Util.getDoubleValue(recordSet.getString("usedAmount"), 0.00); + } + restAmount1 = Util.getDoubleValue(getRestAmount(resourceId, ruleId, currentDate, true, false), 0.00); + } + + double usedAmount2 = 0.00;//带薪病假已用 + double restAmount2 = 0.00;//带薪病假剩余 + + sql = "select * from kq_leaveRules where 1=1 and (isDelete is null or isDelete <>1) and leaveCode='paidSickLeave'"; + recordSet.executeQuery(sql); + if (recordSet.next()) { + String ruleId = recordSet.getString("id"); + + sql = "select * from kq_BalanceOfLeave where belongYear=? and resourceId=? and leaveRulesId=?"; + recordSet.executeQuery(sql, searchYear, resourceId, ruleId); + if (recordSet.next()) { + usedAmount2 = Util.getDoubleValue(recordSet.getString("usedAmount"), 0.00); + } + restAmount2 = Util.getDoubleValue(getRestAmount(resourceId, ruleId, currentDate, true, false), 0.00); + } + + double usedAmount3 = 0.00;//带薪事假已用 + sql = "select * from kq_leaveRules where 1=1 and (isDelete is null or isDelete <>1) and leaveCode='paidCompassionateLeave'"; + recordSet.executeQuery(sql); + if (recordSet.next()) { + String ruleId = recordSet.getString("id"); + + sql = "select * from kq_BalanceOfLeave where belongYear=? and resourceId=? and leaveRulesId=?"; + recordSet.executeQuery(sql, searchYear, resourceId, ruleId); + if (recordSet.next()) { + usedAmount3 = Util.getDoubleValue(recordSet.getString("usedAmount"), 0.00); + } + } + + + double restAmount4 = 0.00;//调休剩余 + sql = "select * from kq_leaveRules where 1=1 and (isDelete is null or isDelete <>1) and leaveCode='vacationLeave'"; + recordSet.executeQuery(sql); + if (recordSet.next()) { + String ruleId = recordSet.getString("id"); + + restAmount4 = Util.getDoubleValue(getRestAmount(resourceId, ruleId, currentDate, true, false), 0.00); + } + + resultMap.put("usedAmount1", usedAmount1); + resultMap.put("restAmount1", restAmount1); + resultMap.put("usedAmount2", usedAmount2); + resultMap.put("restAmount2", restAmount2); + resultMap.put("usedAmount3", usedAmount3); + resultMap.put("restAmount4", restAmount4); + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } + + /** + * 获取年假开始日期 + * + * @param resourceId 人员ID + * @return + */ + private static String getAnnualDate(String resourceId) { + String result = ""; + try { + String sql = "select t2.field3 annualDate from hrmResource t1 left join cus_fielddata t2 on t1.id=t2.id and t2.scope='HrmCustomFieldByInfoType' and t2.scopeid=-1 where t1.id=" + resourceId; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + String annualDate = recordSet.getString("annualDate"); + if (annualDate.contains("\\/")) { + try { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/M/dd"); + Date date = simpleDateFormat.parse(annualDate); + simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + annualDate = simpleDateFormat.format(date); + } catch (Exception e) { + e.printStackTrace(); + annualDate = ""; + } + } + Pattern pattern = Pattern.compile("^\\d{4}\\-\\d{2}\\-\\d{2}$"); + Matcher matcher_1 = pattern.matcher(annualDate); + if (!annualDate.equals("") && matcher_1.matches()) { + result = annualDate; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + + public static void logOvertimeMap(Map overtimeLogMap,Object params, String keys){ + if(overtimeLogMap != null){ + overtimeLogMap.put(keys, params); + } + } + /** + * 获取育儿假开始日期 + * + * @param resourceId 人员ID + * @return + */ + public static ArrayList getParentalLeaveDate(String resourceId) { + ArrayList list = new ArrayList<>(); + try { + String sql = "select birthday from hrmfamilyinfo where WhetherChildren=1 and resourceid=? order by birthday "; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql,resourceId); + while (recordSet.next()) { + String annualDate = recordSet.getString("birthday"); + if (annualDate.contains("\\/")) { + try { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/M/dd"); + Date date = simpleDateFormat.parse(annualDate); + simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + annualDate = simpleDateFormat.format(date); + } catch (Exception e) { + e.printStackTrace(); + annualDate = ""; + } + } + Pattern pattern = Pattern.compile("^\\d{4}\\-\\d{2}\\-\\d{2}$"); + Matcher matcher_1 = pattern.matcher(annualDate); + if (!annualDate.equals("") && matcher_1.matches()) { + list.add(annualDate); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return list; + } + + /** + * 获取人员的省份 + * @return + */ + public static void getChildrenProvinceId(String leaveRulesId, String locationid, Map params ) { + RecordSet rs = new RecordSet(); + String provinceid = "0"; + params.put("yearsOld","0"); + params.put("annualAmount","0"); + try { + if(StringUtil.isNotNull(locationid)){ + String sql = "select * from hrmcity where id in (select locationcity from HrmLocations where id = " + locationid + " )"; + rs.executeSql(sql); + while (rs.next()) { + provinceid = Util.null2s(rs.getString("provinceid"),"0"); + } + } + if(!provinceid.equals("0")){ + String sql = "select * from kq_provinceToLeave where leaveRulesId = " + leaveRulesId + " and provinceid= " + provinceid; + rs.executeQuery(sql); + if (rs.next()) { + int yearsOldValue = rs.getInt("yearsOld"); + double amount = Util.getDoubleValue(rs.getString("amount"), 0); + params.put("yearsOld",yearsOldValue); + params.put("annualAmount",amount); + } + } + } catch (Exception e) { + rs.writeLog(e); + } + } + + // qc 获取孩子的记录id + public static ArrayList getChildId(String resourceId) { + ArrayList list = new ArrayList<>(); + try { + String sql = "select id from hrmfamilyinfo where WhetherChildren=1 and resourceid=? order by birthday "; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql,resourceId); + while (recordSet.next()) { + String id = recordSet.getString("id"); + list.add(id); + } + } catch (Exception e) { + e.printStackTrace(); + } + return list; + } + public static ArrayList getChildBean(String resourceId) { + ArrayList list = new ArrayList<>(); + try { + String sql = "select id,birthday,member from hrmfamilyinfo where WhetherChildren=1 and resourceid=? order by birthday "; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql,resourceId); + KQChildrenBean bean = null; + while (recordSet.next()) { + bean = new KQChildrenBean(); + String id = recordSet.getString("id"); + String birthday = recordSet.getString("birthday"); + String title = recordSet.getString("member"); + bean.setId(id); + bean.setBirthday(birthday); + bean.setTitle(title); + bean.setResourceid(resourceId); + list.add(bean); + } + } catch (Exception e) { + e.printStackTrace(); + } + return list; + } +} diff --git a/src/com/engine/kq/biz/KQBalanceOfLeaveJob.java b/src/com/engine/kq/biz/KQBalanceOfLeaveJob.java new file mode 100644 index 0000000..1a377e2 --- /dev/null +++ b/src/com/engine/kq/biz/KQBalanceOfLeaveJob.java @@ -0,0 +1,21 @@ +package com.engine.kq.biz; + +import com.engine.kq.log.KQLog; +import weaver.interfaces.schedule.BaseCronJob; + +/** + * 格式化昨天的考勤数据 + */ +public class KQBalanceOfLeaveJob extends BaseCronJob { + private KQLog kqLog = new KQLog(); + + public void execute() { + try { + kqLog.info("begin do KQBalanceOfLeaveJob invoke ..."); + KQBalanceOfLeaveBiz.createBalanceOfLeave(); + kqLog.info("end do KQBalanceOfLeaveJob invoke ..."); + } catch (Exception e) { + kqLog.info(e); + } + } +} diff --git a/src/com/engine/kq/biz/KQCardFlowFlushJob.java b/src/com/engine/kq/biz/KQCardFlowFlushJob.java new file mode 100644 index 0000000..5977e32 --- /dev/null +++ b/src/com/engine/kq/biz/KQCardFlowFlushJob.java @@ -0,0 +1,89 @@ +package com.engine.kq.biz; + +import com.engine.kq.bean.KqOldCardFlowFlushBean; +import weaver.conn.RecordSet; +import weaver.general.StaticObj; + +import java.util.*; + +/** + * 如果补卡流程绑定了多人力,那么历史的数据就会受到影响,因为明细表中添加了个人员字段,所以这里需要将主表的补卡人刷到明细表中的补卡人中去 + * 查看是否有历史的补卡流程需要调整数据处理,将主表的补卡人更新到明细表中的补卡人 + */ +public class KQCardFlowFlushJob extends TimerTask { + private static KQCardFlowFlushJob instance = new KQCardFlowFlushJob(); + + private StaticObj staticobj = null; + + public static KQCardFlowFlushJob getInstance(){ + return instance; + } + + public void run() { + staticobj = StaticObj.getInstance(); + if(staticobj.getObject("kq&oldcardflow") != null) { + return; + } + getNeedFlushList(); + if(staticobj.getObject("kq&oldcardflow") != null) { + RecordSet rs = new RecordSet(); + List beans = (List)staticobj.getObject("kq&oldcardflow"); + for(KqOldCardFlowFlushBean bean : beans) { + // 执行刷新历史补卡数据,刷新完后将flush_oldcard_flow表isexecute置为1 + int id=bean.getId(); + int prosetid = bean.getProsetid(); + int workflowid = bean.getWorkflowid(); + int billid = bean.getBillid(); + String maintablename = bean.getMaintablename(); + String detailtablename = bean.getDetailtablename(); + String mainresourcefield = bean.getMainresourcefield(); + String detailresourcefield = bean.getDetailresourcefield(); + String sql = "select id,"+mainresourcefield+" from "+maintablename; + rs.executeQuery(sql); + Map mainResourceIdMap = new HashMap<>(); + while (rs.next()) { + mainResourceIdMap.put(rs.getString("id"), rs.getString(mainresourcefield)); + } + boolean isSuccess = true; + for(Map.Entry entry : mainResourceIdMap.entrySet()) { + String mainId = entry.getKey(); + String mainUserId = entry.getValue(); + String updateSql = "update "+detailtablename+" set "+detailresourcefield+" = ? " + + "where mainid = ? and "+detailresourcefield+" is null "; + boolean flag = rs.executeUpdate(updateSql, mainUserId, mainId); + if(!flag) { + isSuccess = false; + } + } + if(isSuccess) { + rs.executeUpdate("update flush_oldcard_flow set isexecute=1 where id="+id); + } + } + staticobj.removeObject("kq&oldcardflow"); + } + } + + private void getNeedFlushList() { + RecordSet recordSet = new RecordSet(); + KqOldCardFlowFlushBean bean = null; + String sql = "select * from flush_oldcard_flow where isexecute=0"; + recordSet.executeQuery(sql); + List beans = new ArrayList<>(); + while (recordSet.next()) { + bean = new KqOldCardFlowFlushBean(); + int id = recordSet.getInt("id"); + bean.setId(id); + int prosetid = recordSet.getInt("prosetid"); + bean.setProsetid(prosetid); + bean.setWorkflowid(recordSet.getInt("workflowid")); + bean.setBillid(recordSet.getInt("billid")); + bean.setMaintablename(recordSet.getString("maintablename")); + bean.setDetailtablename(recordSet.getString("detailtablename")); + bean.setMainresourcefield(recordSet.getString("mainresourcefield")); + bean.setDetailresourcefield(recordSet.getString("detailresourcefield")); + bean.setIsexecute(recordSet.getInt("isexecute")); + beans.add(bean); + } + staticobj.putObject("kq&oldcardflow",beans); + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQCardLogBiz.java b/src/com/engine/kq/biz/KQCardLogBiz.java new file mode 100644 index 0000000..f9edb6d --- /dev/null +++ b/src/com/engine/kq/biz/KQCardLogBiz.java @@ -0,0 +1,101 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.kq.log.KQLog; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; +import java.util.UUID; +import weaver.conn.ConnStatement; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.common.DbFunctionUtil; + +/** + * 打卡数据做一个日志记录表 + */ +public class KQCardLogBiz { + private static KQLog kqLog = new KQLog(); + + /** + * 记录一下打卡相关的信息 + * @param resourceid + * @param logMap + * @param workTimeEntityLogMap + * @param cardtype + * @return + */ + public static String logCardInfo(String resourceid, Map logMap,Map workTimeEntityLogMap, String cardtype) { + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String cardlog_in_table = Util.null2String(kqSettingsComInfo.getMain_val("cardlog_in_table"),"0"); + if("0".equalsIgnoreCase(cardlog_in_table)){ + return ""; + } + String uuid = UUID.randomUUID().toString(); + try{ + RecordSet rs = new RecordSet(); + + String other_info = ""; + if(logMap != null){ + other_info = JSON.toJSONString(logMap,SerializerFeature.DisableCheckSpecialChar,SerializerFeature.DisableCircularReferenceDetect); + } + String serial_info = ""; + if(workTimeEntityLogMap != null){ + serial_info = JSON.toJSONString(workTimeEntityLogMap,SerializerFeature.DisableCheckSpecialChar,SerializerFeature.DisableCircularReferenceDetect); + } + boolean isok = false; + if(rs.getDBType().equalsIgnoreCase("oracle")&& Util.null2String(rs.getOrgindbtype()).equals("oracle")){ + String sql = "insert into kq_card_log(resourceid,createdatetime,serial_info,other_info,uuid,cardtype) " + + " values(?,"+DbFunctionUtil.getCurrentFullTimeFunction(rs.getDBType())+",empty_clob(),empty_clob(),?,?) "; + isok = rs.executeUpdate(sql,resourceid,uuid,cardtype); + }else{ + String sql = "insert into kq_card_log(resourceid,createdatetime,serial_info,other_info,uuid,cardtype) " + + " values(?,"+DbFunctionUtil.getCurrentFullTimeFunction(rs.getDBType())+",?,?,?,?) "; + boolean isRight = rs.executeUpdate(sql,resourceid,serial_info,other_info,uuid,cardtype); + kqLog.info("logCardInfo sql:"+sql+":isRight:"+isRight); + } + if(isok && rs.getDBType().equalsIgnoreCase("oracle")&& Util.null2String(rs.getOrgindbtype()).equals("oracle")){ + ConnStatement stat=null; + try { + stat = new ConnStatement(); + // 需要使用for update方法来进行更新, + // 但是,特别需要注意,如果原来CLOB字段有值,需要使用empty_clob()将其清空。 + // 如果原来是null,也不能更新,必须是empty_clob()返回的结果。 + stat.setStatementSql("select serial_info,other_info from kq_card_log where uuid=? for update", false); + stat.setString(1,uuid); + stat.executeQuery(); + if (stat.next()) { + oracle.sql.CLOB serial_clob = (oracle.sql.CLOB) stat.getClob("serial_info"); + Writer serial_outStream = serial_clob.getCharacterOutputStream(); + char[] serial_c = serial_info.toCharArray(); + serial_outStream.write(serial_c, 0, serial_c.length); + serial_outStream.flush(); + serial_outStream.close(); + + oracle.sql.CLOB other_clob = (oracle.sql.CLOB) stat.getClob("other_info"); + Writer other_outStream = other_clob.getCharacterOutputStream(); + char[] other_c = other_info.toCharArray(); + other_outStream.write(other_c, 0, other_c.length); + other_outStream.flush(); + other_outStream.close(); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (stat != null) { + stat.close(); + } + } + } + }catch (Exception e){ + kqLog.info("打卡日志报错:KQCardLogBiz:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + return uuid; + } +} diff --git a/src/com/engine/kq/biz/KQChildrenComInfo.java b/src/com/engine/kq/biz/KQChildrenComInfo.java new file mode 100644 index 0000000..b83815d --- /dev/null +++ b/src/com/engine/kq/biz/KQChildrenComInfo.java @@ -0,0 +1,81 @@ +package com.engine.kq.biz; + +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; + +/** + * 假期规则缓存类 + */ +public class KQChildrenComInfo extends CacheBase { + + /** + * 数据来源 + */ + protected static String TABLE_NAME = "hrmfamilyinfo"; + /** + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = " WhetherChildren=1 "; + /** + * sql中的order by信息,不要以order by开始 + */ + protected static String TABLE_ORDER = " id "; + + /** + * 主键 + */ + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + /** + * 出生日期 + */ + @CacheColumn(name = "birthday") + protected static int birthday; + /** + * 姓名 + */ + @CacheColumn(name = "member") + protected static int member; + /** + * 家长id + */ + @CacheColumn(name = "resourceid") + protected static int resourceid; + + + public String getId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getChildrenName() { + return (String)getRowValue(member); + } + + public String getChildrenName(String key){ + return (String) getValue(member,key); + } + + public String getBirthday() { + return (String)getRowValue(birthday); + } + + public String getBirthday(String key){ + return (String) getValue(birthday,key); + } + + public String getResourceid() { + return (String)getRowValue(resourceid); + } + + public String getResourceid(String key){ + return (String) getValue(resourceid,key); + } + + @Override + public void removeCache() { + super.removeCache(); + } +} diff --git a/src/com/engine/kq/biz/KQClearCardLogJob.java b/src/com/engine/kq/biz/KQClearCardLogJob.java new file mode 100644 index 0000000..88f99df --- /dev/null +++ b/src/com/engine/kq/biz/KQClearCardLogJob.java @@ -0,0 +1,49 @@ +package com.engine.kq.biz; + +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.interfaces.schedule.BaseCronJob; + +/** + * 只保留进10天的考勤打卡日志 + */ +public class KQClearCardLogJob extends BaseCronJob{ + + @Override + public void execute() { + BaseBean bb = new BaseBean(); + try{ + bb.writeLog("begin do KQClearCardLogJob invoke ..."); + RecordSet rs = new RecordSet(); + String curdate = DateUtil.getCurrentDate(); + String curdate_10 = DateUtil.addDate(curdate, -10); + String sql = "delete from kq_card_log where createdatetime < ? "; + if(rs.getDBType().equalsIgnoreCase("oracle")) { + sql = "delete from kq_card_log where to_char(createdatetime, 'yyyy-mm-dd') < ? "; + } + + boolean isok = rs.executeUpdate(sql,curdate_10); + bb.writeLog("KQClearCardLogJob invoke ...curdate::"+curdate+":curdate_10:"+curdate_10+":isok:"+isok); + //删除加班 + String curdate_30 = DateUtil.addDate(curdate, -30); + sql = "delete from kq_overtime_log where createdatetime < ? "; + if(rs.getDBType().equalsIgnoreCase("oracle")) { + sql = "delete from kq_overtime_log where to_char(createdatetime, 'yyyy-mm-dd') < ? "; + } + isok = rs.executeUpdate(sql,curdate_30); + bb.writeLog("KQClearCardLogJob invoke ...curdate::"+curdate+":curdate_30:"+curdate_30+":sql:"+sql+":isok:"+isok); + + sql = "delete from kq_overtime_log_detail where createdatetime < ? "; + if(rs.getDBType().equalsIgnoreCase("oracle")) { + sql = "delete from kq_overtime_log_detail where to_char(createdatetime, 'yyyy-mm-dd') < ? "; + } + isok = rs.executeUpdate(sql,curdate_30); + bb.writeLog("KQClearCardLogJob invoke ...curdate::"+curdate+":curdate_30:"+curdate_30+":sql:"+sql+":isok:"+isok); + + bb.writeLog("end do KQClearCardLogJob invoke ..."); + }catch (Exception e) { + bb.writeLog(e); + } + } +} diff --git a/src/com/engine/kq/biz/KQConfigComInfo.java b/src/com/engine/kq/biz/KQConfigComInfo.java new file mode 100644 index 0000000..6b65a5e --- /dev/null +++ b/src/com/engine/kq/biz/KQConfigComInfo.java @@ -0,0 +1,35 @@ +package com.engine.kq.biz; + +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; + +/** + * 考勤配置缓存表 + */ +public class KQConfigComInfo extends CacheBase{ + protected static String TABLE_NAME = "kq_config"; + /** sql中的where信息,不要以where开始 */ + protected static String TABLE_WHERE = null; + /** sql中的order by信息,不要以order by开始 */ + protected static String TABLE_ORDER = "name"; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "name"; + + @CacheColumn(name = "value") + protected static int value; + + public String getId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getValue() { + return (String)getRowValue(value); + } + public String getValue(String key) { + return (String)getValue(value,key); + } + +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQDingTalkImportJob.java b/src/com/engine/kq/biz/KQDingTalkImportJob.java new file mode 100644 index 0000000..6662051 --- /dev/null +++ b/src/com/engine/kq/biz/KQDingTalkImportJob.java @@ -0,0 +1,34 @@ +package com.engine.kq.biz; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQScheduleSignImportService; +import com.engine.kq.service.impl.KQScheduleSignImportServiceImpl; +import weaver.general.BaseBean; +import weaver.hrm.common.Tools; +import weaver.interfaces.schedule.BaseCronJob; + +import java.util.HashMap; +import java.util.Map; + +public class KQDingTalkImportJob extends BaseCronJob{ + public void execute() { + BaseBean bb = new BaseBean(); + try{ + + bb.writeLog("begin do KQDingTalkImportJob invoke ..."); + KQScheduleSignImportService kqScheduleSignImportService = (KQScheduleSignImportServiceImpl) ServiceUtil.getService(KQScheduleSignImportServiceImpl.class); + //导入策略 每天导入前一天和当天数据 + Map params = new HashMap<>(); + params.put("fromDate",Tools.getDate(Tools.getToday(),-1)); + params.put("toDate",Tools.getDate(Tools.getToday())); + + bb.writeLog("do KQDingTalkImportJob invoke.."+ JSONObject.toJSONString(params)); + + kqScheduleSignImportService.synDingTalkData(params); + + bb.writeLog("end do KQDingTalkImportJob invoke ..."); + }catch (Exception e) { + bb.writeLog(e); + } + } +} diff --git a/src/com/engine/kq/biz/KQEditFieldInWorkflowBiz.java b/src/com/engine/kq/biz/KQEditFieldInWorkflowBiz.java new file mode 100644 index 0000000..bdfdfab --- /dev/null +++ b/src/com/engine/kq/biz/KQEditFieldInWorkflowBiz.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2001-2017 泛微软件. + * 泛微协同商务系统,版权所有. + * + */ +package com.engine.kq.biz; + +import com.engine.kq.log.KQLog; +import com.google.common.collect.Lists; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; + +/** + * 给流程组提供方法,即使是只读字段也可以入库的 + */ +public class KQEditFieldInWorkflowBiz { + + /** + * 给流程组提供方法,即使是只读字段也可以入库的 + * @param workflowParam 流程id之类的一些流程的基本信息 + * @return + * @throws Exception + */ + public List getEditFieldInWorkflow(Map workflowParam) { + KQLog kqLog = new KQLog(); + + List fieldList = Lists.newArrayList(); + try{ + String workflowid = Util.null2String(workflowParam.get("workflowid")); + if(workflowid.length() > 0 && Util.getIntValue(workflowid) > 0){ + String editField = "duration"; + Map result = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_att_proc_relation where field002 in(select id from kq_att_proc_fields where field002 like '%"+editField+"%') and field001 in(select id from kq_att_proc_set where field001="+workflowid+" and field005 =1) "; + rs.executeQuery(sql); + while (rs.next()){ + String workflowFieldid = rs.getString("field003"); + String fieldid = workflowFieldid; + fieldList.add(fieldid); + } + } + }catch (Exception e){ + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info("getEditFieldInWorkflow :"+errorsWriter.toString()); + } + + return fieldList; + } +} diff --git a/src/com/engine/kq/biz/KQEmailRemindComInfo.java b/src/com/engine/kq/biz/KQEmailRemindComInfo.java new file mode 100644 index 0000000..6bee603 --- /dev/null +++ b/src/com/engine/kq/biz/KQEmailRemindComInfo.java @@ -0,0 +1,166 @@ +package com.engine.kq.biz; + +import weaver.cache.*; +import weaver.conn.RecordSet; +import weaver.general.ThreadVarLanguage; +import weaver.systeminfo.SystemEnv; + +/** + * 考勤提醒,邮件提醒模板缓存类 + */ +public class KQEmailRemindComInfo extends CacheBase { + + /** + * 数据来源 + */ + protected static String TABLE_NAME = " kq_emailRemindTemplate "; + /** + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = ""; + /** + * sql中的order by信息,不要以order by开始 + */ + protected static String TABLE_ORDER = "id"; + + /** + * 主键 + */ + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + /** + * ID + */ + @CacheColumn(name = "id") + protected static int id; + + /** + * 班次ID + */ + @CacheColumn(name = "serialId") + protected static int serialId; + + /** + * 签到还是签退 + */ + @CacheColumn(name = "signInOrSignOut") + protected static int signInOrSignOut; + + /** + * 邮件标题 + */ + @CacheColumn(name = "emailTitle") + protected static int emailTitle; + + /** + * 邮件内容 + */ + @CacheColumn(name = "emailContent") + protected static int emailContent; + + @Override + public CacheMap initCache() throws Exception { + CacheMap localData = super.createCacheMap(); + RecordSet recordSet = new RecordSet(); + String sql = "select * from kq_emailRemindTemplate"; + recordSet.executeQuery(sql); + while (recordSet.next()) { + String _id = recordSet.getString("id"); + String _serialId = recordSet.getString("serialId"); + String _signInOrSignOut = recordSet.getString("signInOrSignOut"); + String _emailTile = recordSet.getString("emailTtle"); + String _emailContent = recordSet.getString("emailContent"); + String PK = _serialId + "-" + _signInOrSignOut; + CacheItem cacheItem = createCacheItem(); + cacheItem.set(PK_INDEX, PK); + cacheItem.set(id, _id); + cacheItem.set(serialId, _serialId); + cacheItem.set(signInOrSignOut, _signInOrSignOut); + cacheItem.set(emailTitle, _emailTile); + cacheItem.set(emailContent, _emailContent); + modifyCacheItem(PK, cacheItem); + localData.put(PK, cacheItem); + } + return localData; + } + + @Override + public CacheItem initCache(String key) { + if (key == null || "".equals(key.trim())) { + return null; + } + + String[] keyArr = key.split("-"); + if (keyArr.length != 2) { + return null; + } + String sql = "select * from kq_emailRemindTemplate where serialId=? and signInOrSignOut=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, keyArr[0], keyArr[1]); + if (recordSet.next()) { + String _id = recordSet.getString("id"); + String _serialId = recordSet.getString("serialId"); + String _signInOrSignOut = recordSet.getString("signInOrSignOut"); + String _emailTile = recordSet.getString("emailTtle"); + String _emailContent = recordSet.getString("emailContent"); + String PK = _serialId + "-" + _signInOrSignOut; + CacheItem cacheItem = createCacheItem(); + cacheItem.set(PK_INDEX, PK); + cacheItem.set(id, _id); + cacheItem.set(serialId, _serialId); + cacheItem.set(signInOrSignOut, _signInOrSignOut); + cacheItem.set(emailTitle, _emailTile); + cacheItem.set(emailContent, _emailContent); + modifyCacheItem(key, cacheItem); + return cacheItem; + } else { + CacheItem cacheItem = createCacheItem(); + return cacheItem; + } + } + + private String getEmailTitle(String key) { + return (String) getValue(emailTitle, key); + } + + public String getEmailTitle(String serialId, String signInOrSignOut) { + String PK = serialId + "-" + signInOrSignOut; + String emailTitle = getEmailTitle(PK); + if ("".equals(emailTitle)) { + if ("1".equals(signInOrSignOut)) { + emailTitle = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005295,weaver.general.ThreadVarLanguage.getLang())+""; + } else { + emailTitle = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005296,weaver.general.ThreadVarLanguage.getLang())+""; + } + } + return emailTitle; + } + + private String getEmailContent(String key) { + return (String) getValue(emailContent, key); + } + + public String getEmailContent(String serialId, String signInOrSignOut) { + String PK = serialId + "-" + signInOrSignOut; + String emailContent = getEmailContent(PK); + if ("".equals(emailContent)) { + if ("1".equals(signInOrSignOut)) { + emailContent = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005295,weaver.general.ThreadVarLanguage.getLang())+""; + } else { + emailContent = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005296,weaver.general.ThreadVarLanguage.getLang())+""; + } + } + if (emailContent.contains("["+ SystemEnv.getHtmlLabelName(18843, ThreadVarLanguage.getLang())+"]") && "1".equals(signInOrSignOut)) { + KQShiftManagementComInfo shiftManagementComInfo = new KQShiftManagementComInfo(); + String minsBeforeSignIn = shiftManagementComInfo.getMinsBeforeSignIn(serialId); + emailContent = emailContent.replace("["+ SystemEnv.getHtmlLabelName(18843, ThreadVarLanguage.getLang())+"]", minsBeforeSignIn + ""+ SystemEnv.getHtmlLabelName(15049, ThreadVarLanguage.getLang())+""); + } + if (emailContent.contains("["+ SystemEnv.getHtmlLabelName(10005342, ThreadVarLanguage.getLang())+"]") && "2".equals(signInOrSignOut)) { + KQShiftManagementComInfo shiftManagementComInfo = new KQShiftManagementComInfo(); + String minsAfterSignOut = shiftManagementComInfo.getMinsAfterSignOut(serialId); + emailContent = emailContent.replace("["+ SystemEnv.getHtmlLabelName(10005342, ThreadVarLanguage.getLang())+"]", minsAfterSignOut + ""+ SystemEnv.getHtmlLabelName(15049, ThreadVarLanguage.getLang())+""); + } + return emailContent; + } +} diff --git a/src/com/engine/kq/biz/KQExitRulesBiz.java b/src/com/engine/kq/biz/KQExitRulesBiz.java new file mode 100644 index 0000000..37f9b01 --- /dev/null +++ b/src/com/engine/kq/biz/KQExitRulesBiz.java @@ -0,0 +1,80 @@ +package com.engine.kq.biz; + +import weaver.conn.RecordSet; +import weaver.general.Util; + +/** + * 公出规则 + */ +public class KQExitRulesBiz { + + /** + * 获取最小出差单位 + * 1-按天出差 + * 2-按半天出差 + * 3-按小时出差 + * 4-按整天出差 + * 其他:无效数据 + * + * @return + */ + public static String getMinimumUnit() { + KQExitRulesComInfo kqExitRulesComInfo = new KQExitRulesComInfo(); + return kqExitRulesComInfo.getMinimumUnit("1"); + } + + /** + * 获取换算比例 + * 当公出单位由天、半天、整天切换成小时或者由小时切换成天、半天、整天时,历史数据会按照此换算比例自动进行换算 + * + * @return + */ + public static String getProportion() { + KQExitRulesComInfo kqExitRulesComInfo = new KQExitRulesComInfo(); + return String.format("%.2f", Util.getDoubleValue(kqExitRulesComInfo.getProportion("1"))); + } + + /** + * 获取计算出差时长方式 + * 1-按工作日计算出差时长 + * 2-按自然日计算出差时长 + * 其他:无效数据 + * + * @return + */ + public static String getComputingMode() { + KQExitRulesComInfo kqExitRulesComInfo = new KQExitRulesComInfo(); + return kqExitRulesComInfo.getComputingMode("1"); + } + + /** + * 获取日折算时长 + * + * @return + */ + public static String getHoursToDay() { + int minimumUnit = -1;//最小出差单位 + int computingMode = -1;//计算出差时长方式 + double hoursToDay = -1;//日折算时长 + KQExitRulesComInfo kqExitRulesComInfo = new KQExitRulesComInfo(); + minimumUnit = Util.getIntValue(kqExitRulesComInfo.getMinimumUnit("1"), -1); + computingMode = Util.getIntValue(kqExitRulesComInfo.getComputingMode("1"), -1); + hoursToDay = Util.getDoubleValue(kqExitRulesComInfo.getHoursToDay("1"), -1); + return String.valueOf(hoursToDay); + } + + /** + * 获取半天显示类型,是时间还是下拉框 + * 半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + * @return + */ + public static String getTimeselection() { + KQExitRulesComInfo kqExitRulesComInfo = new KQExitRulesComInfo(); + String timeSelection = kqExitRulesComInfo.getTimeSelection("1"); + if("1".equalsIgnoreCase(timeSelection) || "2".equalsIgnoreCase(timeSelection)){ + return timeSelection; + }else{ + return "1"; + } + } +} diff --git a/src/com/engine/kq/biz/KQExitRulesComInfo.java b/src/com/engine/kq/biz/KQExitRulesComInfo.java new file mode 100644 index 0000000..83372ac --- /dev/null +++ b/src/com/engine/kq/biz/KQExitRulesComInfo.java @@ -0,0 +1,122 @@ +package com.engine.kq.biz; + +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; + +/** + * 公出规则缓存类 + */ +public class KQExitRulesComInfo extends CacheBase { + + /** + * 数据来源 + */ + protected static String TABLE_NAME = "kq_ExitRules"; + /** + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = " (isDelete is null or isDelete<>1) "; + /** + * sql中的order by信息,不要以order by开始 + */ + protected static String TABLE_ORDER = "id"; + + /** 主键ID */ + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + /** + * 获取最小公出单位 + * 1-按天公出 + * 2-按半天公出 + * 3-按小时公出 + * 4-按整天公出 + * 其他:无效数据 + */ + @CacheColumn(name = "minimumUnit") + protected static int minimumUnit; + + /** + * 获取换算比例 + * 当公出单位由天、半天、整天切换成小时或者由小时切换成天、半天、整天时,历史数据会按照此换算比例自动进行换算 + */ + @CacheColumn(name = "proportion") + protected static int proportion; + + /** + * 获取计算公出时长方式 + * 1-按工作日计算公出时长 + * 2-按自然日计算公出时长 + * 其他:无效数据 + */ + @CacheColumn(name = "computingMode") + protected static int computingMode; + + /** + * 获取日折算时长 + * 只有当按天公出、按半天公出、按整天公出并且按照自然日计算公出时长的时候才有效 + * -1:无效数据 + */ + @CacheColumn(name = "hoursToDay") + protected static int hoursToDay; + + /** + * 半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + */ + @CacheColumn(name = "timeselection") + protected static int timeselection; + + public String getId() { + return (String) getRowValue(PK_INDEX); + } + + public String getMinimumUnit() { + return (String) getRowValue(minimumUnit); + } + + public String getMinimumUnit(String key) { + return (String) getValue(minimumUnit, key); + } + + public String getProportion() { + return (String) getRowValue(proportion); + } + + public String getProportion(String key) { + return (String) getValue(proportion, key); + } + + public String getComputingMode() { + return (String) getRowValue(computingMode); + } + + public String getComputingMode(String key) { + return (String) getValue(computingMode, key); + } + + public String getHoursToDay() { + return (String) getRowValue(hoursToDay); + } + + public String getHoursToDay(String key) { + return (String) getValue(hoursToDay, key); + } + + public String getTimeSelection() { + String value = (String) getRowValue(timeselection); + if (value == null || value.equals("")) { + value = "1"; + } + return value; + } + + public String getTimeSelection(String key) { + String value = (String) getValue(timeselection, key); + if (value == null || value.equals("")) { + value = "1"; + } + return value; + } +} diff --git a/src/com/engine/kq/biz/KQFLowEventLogBiz.java b/src/com/engine/kq/biz/KQFLowEventLogBiz.java new file mode 100644 index 0000000..ca294b5 --- /dev/null +++ b/src/com/engine/kq/biz/KQFLowEventLogBiz.java @@ -0,0 +1,226 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.serializer.SerializerFeature; +import java.io.Writer; +import java.util.Map; +import java.util.UUID; +import weaver.conn.ConnStatement; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.common.DbFunctionUtil; + +/** + * 考勤流程action日志记录 + * 从流程action的触发到使用到最后进入表 + */ +public class KQFLowEventLogBiz { + + /** + * 记录一下流程开始日期结束日期的 + * @param resourceid + * @param eventLogMap + * @param eventType + * @return + */ + public String logEvent(String resourceid, Map eventLogMap, String eventType) { + RecordSet rs = new RecordSet(); + + String event_info = ""; + if(eventLogMap != null){ + event_info = JSON.toJSONString(eventLogMap,SerializerFeature.DisableCheckSpecialChar,SerializerFeature.DisableCircularReferenceDetect); + } + String uuid = UUID.randomUUID().toString(); + boolean isok = false; + if(rs.getDBType().equalsIgnoreCase("oracle")&& Util.null2String(rs.getOrgindbtype()).equals("oracle")){ + String sql = "insert into kq_flow_log(resourceid,createdatetime,event_info,uuid,flowtype) " + + " values('"+resourceid+"',"+ DbFunctionUtil.getCurrentFullTimeFunction(rs.getDBType())+",empty_clob(),'"+uuid+"','"+eventType+"') "; + isok = rs.executeUpdate(sql); + }else{ + String sql = "insert into kq_flow_log(resourceid,createdatetime,event_info,uuid,flowtype) " + + " values('"+resourceid+"',"+DbFunctionUtil.getCurrentFullTimeFunction(rs.getDBType())+",?,'"+uuid+"','"+eventType+"') "; + rs.executeUpdate(sql,event_info); + } + if(isok && rs.getDBType().equalsIgnoreCase("oracle")&& Util.null2String(rs.getOrgindbtype()).equals("oracle")){ + ConnStatement stat=null; + try { + stat = new ConnStatement(); + // 需要使用for update方法来进行更新, + // 但是,特别需要注意,如果原来CLOB字段有值,需要使用empty_clob()将其清空。 + // 如果原来是null,也不能更新,必须是empty_clob()返回的结果。 + stat.setStatementSql("select event_info from kq_flow_log where uuid=? for update", false); + stat.setString(1,uuid); + stat.executeQuery(); + if (stat.next()) { + oracle.sql.CLOB clob = (oracle.sql.CLOB) stat.getClob("event_info"); + Writer outStream = clob.getCharacterOutputStream(); + char[] c = event_info.toCharArray(); + outStream.write(c, 0, c.length); + outStream.flush(); + outStream.close(); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (stat != null) { + stat.close(); + } + } + } + return uuid; + } + + /** + * 明细表里记录一下班次和考勤组信息 + * @param resourceid + * @param workTimeEntityLogMap + * @param main_uuid + * @param worktimeType + * @return + */ + public String logDetailWorkTimeEntity(String resourceid, Map workTimeEntityLogMap, + String main_uuid,String worktimeType) { + RecordSet rs = new RecordSet(); + + String serial_info = ""; + if(workTimeEntityLogMap != null){ + serial_info = JSON.toJSONString(workTimeEntityLogMap,SerializerFeature.DisableCheckSpecialChar,SerializerFeature.DisableCircularReferenceDetect); + } + String uuid = UUID.randomUUID().toString(); + boolean isok = false; + if(rs.getDBType().equalsIgnoreCase("oracle")&& Util.null2String(rs.getOrgindbtype()).equals("oracle")){ + String sql = "insert into kq_flow_log_detail(resourceid,createdatetime,serial_info,flow_info,event_info,uuid,flowtype,main_uuid) " + + " values("+resourceid+","+ DbFunctionUtil.getCurrentFullTimeFunction(rs.getDBType())+",empty_clob(),empty_clob(),empty_clob(),'"+uuid+"','"+worktimeType+"','"+main_uuid+"') "; + isok = rs.executeUpdate(sql); + }else{ + String sql = "insert into kq_flow_log_detail(resourceid,createdatetime,serial_info,uuid,flowtype,main_uuid) " + + " values("+resourceid+","+DbFunctionUtil.getCurrentFullTimeFunction(rs.getDBType())+",?,'"+uuid+"','"+worktimeType+"','"+main_uuid+"') "; + rs.executeUpdate(sql,serial_info); + } + + if(rs.getDBType().equalsIgnoreCase("oracle")&& Util.null2String(rs.getOrgindbtype()).equals("oracle")){ + ConnStatement stat=null; + try { + stat = new ConnStatement(); + // 需要使用for update方法来进行更新, + // 但是,特别需要注意,如果原来CLOB字段有值,需要使用empty_clob()将其清空。 + // 如果原来是null,也不能更新,必须是empty_clob()返回的结果。 + stat.setStatementSql("select serial_info from kq_flow_log_detail where uuid=? for update", false); + stat.setString(1,uuid); + stat.executeQuery(); + if (stat.next()) { + oracle.sql.CLOB clob = (oracle.sql.CLOB) stat.getClob("serial_info"); + Writer outStream = clob.getCharacterOutputStream(); + char[] c = serial_info.toCharArray(); + outStream.write(c, 0, c.length); + outStream.flush(); + outStream.close(); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (stat != null) { + stat.close(); + } + } + } + + return uuid; + } + + /** + * 记录一下加班生成明细 + * @param resourceid + * @param overtimeLogMap + * @param uuid + */ + public void logDetailFlowMap(String resourceid, Map overtimeLogMap,String uuid) { + RecordSet rs = new RecordSet(); + + String flow_info = ""; + if(overtimeLogMap != null){ + flow_info = JSON.toJSONString(overtimeLogMap, SerializerFeature.DisableCheckSpecialChar,SerializerFeature.DisableCircularReferenceDetect); + } + if(rs.getDBType().equalsIgnoreCase("oracle")&&rs.getOrgindbtype().equalsIgnoreCase("oracle")){ + ConnStatement stat=null; + try { + stat = new ConnStatement(); + // 需要使用for update方法来进行更新, + // 但是,特别需要注意,如果原来CLOB字段有值,需要使用empty_clob()将其清空。 + // 如果原来是null,也不能更新,必须是empty_clob()返回的结果。 + stat.setStatementSql("select flow_info from kq_overtime_log_detail where uuid=? for update", false); + stat.setString(1,uuid); + stat.executeQuery(); + if (stat.next()) { + oracle.sql.CLOB clob = (oracle.sql.CLOB) stat.getClob("flow_info"); + Writer outStream = clob.getCharacterOutputStream(); + char[] c = flow_info.toCharArray(); + outStream.write(c, 0, c.length); + outStream.flush(); + outStream.close(); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (stat != null) { + stat.close(); + } + } + }else{ + String sql = "update kq_overtime_log_detail set flow_info='"+flow_info+"' where uuid='"+uuid+"'"; + rs.executeUpdate(sql); + } + + } + + /** + * 记录对应的加班生成过程中使用的表sql和表数据 + * @param resourceid + * @param eventLogMap + * @param uuid + * @param overtimetype + */ + public void logDetailEvent(String resourceid, Map eventLogMap, String uuid, String overtimetype) { + RecordSet rs = new RecordSet(); + + String event_info = ""; + if(eventLogMap != null){ + event_info = JSON.toJSONString(eventLogMap,SerializerFeature.DisableCheckSpecialChar,SerializerFeature.DisableCircularReferenceDetect); + } + + if(rs.getDBType().equalsIgnoreCase("oracle")&&rs.getOrgindbtype().equalsIgnoreCase("oracle")){ + ConnStatement stat=null; + try { + stat = new ConnStatement(); + // 需要使用for update方法来进行更新, + // 但是,特别需要注意,如果原来CLOB字段有值,需要使用empty_clob()将其清空。 + // 如果原来是null,也不能更新,必须是empty_clob()返回的结果。 + stat.setStatementSql("select event_info from kq_flow_log_detail where uuid=? for update", false); + stat.setString(1,uuid); + stat.executeQuery(); + if (stat.next()) { + oracle.sql.CLOB clob = (oracle.sql.CLOB) stat.getClob("event_info"); + Writer outStream = clob.getCharacterOutputStream(); + char[] c = event_info.toCharArray(); + outStream.write(c, 0, c.length); + outStream.flush(); + outStream.close(); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (stat != null) { + stat.close(); + } + } + }else{ + String sql = "update kq_overtime_log_detail set event_info='"+event_info+"' where uuid='"+uuid+"'"; + rs.executeUpdate(sql); + } + + } +} diff --git a/src/com/engine/kq/biz/KQFixedSchedulceComInfo.java b/src/com/engine/kq/biz/KQFixedSchedulceComInfo.java new file mode 100644 index 0000000..1f00ddb --- /dev/null +++ b/src/com/engine/kq/biz/KQFixedSchedulceComInfo.java @@ -0,0 +1,123 @@ +package com.engine.kq.biz; + +import com.engine.kq.log.KQLog; +import java.util.List; +import weaver.cache.*; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; + +/** + * 报表自定义字段 + */ +public class KQFixedSchedulceComInfo extends CacheBase { + protected static String TABLE_NAME = "kq_fixedschedulce"; + /** + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = null; + /** + * sql中的order by信息,不要以order by开始 + */ + protected static String TABLE_ORDER = "id"; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + @CacheColumn(name = "weekday") + protected static int weekday; + + @CacheColumn(name = "serialid") + protected static int serialid; + + @CacheColumn(name = "groupid") + protected static int groupid; + + // 需要关注:虚拟列,默认不是虚拟列 + @CacheColumn(isVirtual = true) + protected static int virtualKey; + + private boolean isFormat = false; + + private KQLog kqLog = new KQLog(); + + protected boolean autoInitIfNotFound() { + return false; + } + + @Override + public CacheMap initCache() throws Exception { + CacheMap localData = super.initCache(); + try { + RecordSet rs = new RecordSet(); + String sql = " "; + if ("mysql".equals(rs.getDBType())) { + sql += " select CONCAT(groupid,'_',weekday) as id, serialid from kq_fixedschedulce "; + } else if("sqlserver".equals(rs.getDBType())){ + sql += " select CONVERT(varchar,groupid)+'_'+CONVERT(varchar,weekday) as id, serialid from kq_fixedschedulce "; + }else { + sql = " select groupid || '_'|| weekday as id, serialid from kq_fixedschedulce "; + } + rs.executeQuery(sql); + while (rs.next()) { + String id = Util.null2String(rs.getString(PK_NAME)); + CacheItem row = createCacheItem(); + parseResultSetToCacheItem(rs, row); + modifyCacheItem(id, row); + localData.put(id, row); + } + } catch (Exception e) { + writeLog(e); + } + return localData; + } + + public String getId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getSerialid() { + return (String) getRowValue(serialid); + } + + public String getSerialid(String groupid, int weekday) { + + if(!this.isFormat){ + String key = groupid + "_" + weekday; + return (String) getValue(serialid, key); + } + return getSerialidBySql(groupid,weekday); + } + + private String getSerialidBySql(String groupid, int weekday) { + String sql_serialid = ""; + try { + String key = groupid + "_" + weekday; + RecordSet rs = new RecordSet(); + String sql = " "; + if ("mysql".equals(rs.getDBType())) { + sql += " select CONCAT(groupid,'_',weekday) as id, serialid from kq_fixedschedulce where CONCAT(groupid,'_',weekday)=? "; + } else if("sqlserver".equals(rs.getDBType())){ + sql += " select CONVERT(varchar,groupid)+'_'+CONVERT(varchar,weekday) as id, serialid from kq_fixedschedulce where CONVERT(varchar,groupid)+'_'+CONVERT(varchar,weekday)=? "; + }else { + sql = " select groupid || '_'|| weekday as id, serialid from kq_fixedschedulce where groupid || '_'|| weekday=? "; + } + rs.executeQuery(sql,key); + if (rs.next()) { + sql_serialid = rs.getString("serialid"); + } + kqLog.writeLog("KQFixedSchedulceComInfo getSerialidBySql :sql:"+sql+":sql_serialid:"+sql_serialid); + } catch (Exception e) { + writeLog(e); + } + return sql_serialid; + } + + public boolean isFormat() { + return isFormat; + } + + public void setFormat(boolean format) { + isFormat = format; + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQFlowActiontBiz.java b/src/com/engine/kq/biz/KQFlowActiontBiz.java new file mode 100644 index 0000000..5150921 --- /dev/null +++ b/src/com/engine/kq/biz/KQFlowActiontBiz.java @@ -0,0 +1,1406 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.biz.chain.duration.*; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQLockAttendaUtil; +import com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager; +import com.engine.kq.wfset.bean.ProcessChangeSplitBean; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.*; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 考勤流程action相关数据处理类 + */ +public class KQFlowActiontBiz { + public KQLog kqLog = new KQLog(); + + /** + * 强制收回操作 + * @param requestId + */ + public void handleDel(int requestId) { + RecordSet rs = new RecordSet(); + try { + String updateFreezeSql = "update KQ_ATT_VACATION set status=2 where requestId=? "; + boolean isUpdate = rs.executeUpdate(updateFreezeSql,requestId); + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog("handleDrawBack:删除action报错:"+e.getMessage()); + } + } + /** + * 强制收回操作 + * @param requestId + * @param workflowId + */ + public void handleDrawBack(int requestId, int workflowId) { + kqLog.writeLog("handleDrawBack:进入 强制收回:requestId:"+requestId+":workflowId:"+workflowId); + + RecordSet rs = new RecordSet(); + try { + String updateFreezeSql = "update KQ_ATT_VACATION set status=2 where requestId=? and workflowId = ? "; + boolean isUpdate = rs.executeUpdate(updateFreezeSql,requestId,workflowId); + kqLog.writeLog("handleDrawBack:强制收回isUpdate:"+isUpdate+":updateFreezeSql:"+updateFreezeSql+":requestId:"+requestId+":workflowId:"+workflowId); + }catch (Exception e){ + e.printStackTrace(); + kqLog.writeLog("handleDrawBack:强制收回action报错:"+e.getMessage()); + } + } + + /** + * 强制归档操作 + * @param requestId + * @param workflowId + */ + public void handleforceOver(int requestId, int workflowId) { + RecordSet rs = new RecordSet(); + try { + if(!KQSettingsBiz.isforceflow_attend()){ + return ; + } + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? "; + rs.executeQuery(proc_set_sql, workflowId); + if(rs.next()) { + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + int kqtype = Util.getIntValue(rs.getString("field006")); + kqLog.info("handleforceOver:proc_set_id:"+proc_set_id+":kqtype:"+kqtype+":requestId:"+requestId); + Map map = new HashMap(); + if(requestId > 0){ + map.put("requestId", "and t.requestId = " + requestId); + } + Map result = handleKQFlowAction(proc_set_id,usedetails,requestId,kqtype,workflowId,true,false,map); + if(!result.isEmpty()){ + kqLog.info("handleforceOver:强制归档action失败:requestId:"+requestId+":workflowId:"+workflowId+":proc_set_id:"+proc_set_id); + } + } + }catch (Exception e){ + e.printStackTrace(); + kqLog.info("handleforceOver:强制归档action报错:"+e.getMessage()); + } + } + public Map handleKQLockAction(String proc_set_id, String usedetails, int requestId, int kqtype, + int workflowId,boolean isForce,boolean isUpgrade,Map map) throws Exception{ + Map result = new HashMap<>(); + ResourceComInfo rci = new ResourceComInfo(); + List splitBeans = new ArrayList(); + + DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + //生成处理的sql + Map sqlMap = handleSql(proc_set_id, usedetails, requestId,kqtype,map); + if(sqlMap != null && !sqlMap.isEmpty()){ + KqSplitFlowTypeEnum flowTypeEnum = null; + if(kqtype == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + KQFlowLeaveUtil kqFlowLeaveUtil = new KQFlowLeaveUtil(); + result=kqFlowLeaveUtil.handleKQLeaveAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.LEAVE; + }else if(kqtype == KqSplitFlowTypeEnum.EVECTION.getFlowtype()){ + KQFlowEvectionUtil kqFlowEvectionUtil = new KQFlowEvectionUtil(); + result=kqFlowEvectionUtil.handleKQEvectionAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.EVECTION; + }else if(kqtype == KqSplitFlowTypeEnum.OUT.getFlowtype()){ + KQFlowOutUtil kqFlowOutUtil = new KQFlowOutUtil(); + result=kqFlowOutUtil.handleKQOutAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.OUT; + }else if(kqtype == KqSplitFlowTypeEnum.OVERTIME.getFlowtype()){ + KQFlowOvertimeUtil kqFlowOvertimeUtil = new KQFlowOvertimeUtil(); + result=kqFlowOvertimeUtil.handleKQOvertimeAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci,""); + flowTypeEnum = KqSplitFlowTypeEnum.OVERTIME; + }else if(kqtype == KqSplitFlowTypeEnum.SHIFT.getFlowtype()){ + KQFlowShiftUtil kqFlowShiftUtil = new KQFlowShiftUtil(); + result = kqFlowShiftUtil.handleKQShiftLockAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci,result,map); + flowTypeEnum = KqSplitFlowTypeEnum.SHIFT; + }else if(kqtype == KqSplitFlowTypeEnum.OTHER.getFlowtype()){ + KQFlowOtherUtil kqFlowOtherUtil = new KQFlowOtherUtil(); + result=kqFlowOtherUtil.handleKQOtherAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.OTHER; + }else if(kqtype == KqSplitFlowTypeEnum.CARD.getFlowtype()){ + KQFlowCardUtil kqFlowCardUtil = new KQFlowCardUtil(); + result=kqFlowCardUtil.handleKQCardLockAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.CARD; + }else if(kqtype == KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype()){ + KQFlowLeaveBackUtil kqFlowLeaveBackUtil = new KQFlowLeaveBackUtil(); + result=kqFlowLeaveBackUtil.handleKQLeaveBackAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.LEAVEBACK; + }else if(kqtype == KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype()){ + KQFlowProcessChangeUtil kqFlowProcessChangeUtil = new KQFlowProcessChangeUtil(); + result=kqFlowProcessChangeUtil.handleKQProcessChangeAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.PROCESSCHANGE; + }else{ + new BaseBean().writeLog("考勤流程没有找到对应类型:proc_set_id:"+proc_set_id+":requestId:"+requestId+":kqtype:"+kqtype); + } + if(!result.isEmpty()){ + if(!isUpgrade){ + return result; + } + } + if(!splitBeans.isEmpty() && flowTypeEnum != null&&kqtype != KqSplitFlowTypeEnum.CARD.getFlowtype()){ +// String LOCK_DEGREE=Util.null2String(Prop.getPropValue("kqLockAttenda", "LOCK_DEGREE")); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + kqLog.info("KqCheckLockAction:考勤校验action获取的bean:"+JSON.toJSONString(splitBeans)); + for(SplitBean bean : splitBeans){ + String resourceid = bean.getResourceId(); + String fromdate = bean.getBelongDate(); + //考勤变流程 + ProcessChangeSplitBean changeSplitBean = bean.getProcessChangeSplitBean(); + if (changeSplitBean != null) { + String fromdatedb = changeSplitBean.getFromdatedb(); + String todatedb = changeSplitBean.getTodatedb(); + if (fromdatedb != null && fromdatedb.length() > 0 && todatedb != null && todatedb.length() > 0) { + boolean isEnd = false; + Calendar cal = DateUtil.getCalendar(); + for (String date = fromdatedb; !isEnd; ) { + if (date.equals(todatedb)) isEnd = true; + if (new KQLockAttendaUtil().checkLockStatus(resourceid, date)) { + kqLog.info("" + resourceComInfo.getLastname(resourceid) + "在" + date + "的考勤数据已被锁定,不能提交考勤流程!"); + result.put("status", "-1"); + result.put("message", resourceComInfo.getLastname(resourceid) + SystemEnv.getHtmlLabelName(18805, weaver.general.ThreadVarLanguage.getLang()) + date + SystemEnv.getHtmlLabelName(547673, weaver.general.ThreadVarLanguage.getLang())); + } + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + } + } + if (fromdate != null && fromdate.length() > 0 && new KQLockAttendaUtil().checkLockStatus(resourceid, fromdate)) { + kqLog.info(""+resourceComInfo.getLastname(resourceid)+"在"+fromdate+"的考勤数据已被锁定,不能提交考勤流程!"); + result.put("status", "-1"); + result.put("message", resourceComInfo.getLastname(resourceid)+ SystemEnv.getHtmlLabelName(18805,weaver.general.ThreadVarLanguage.getLang())+fromdate+SystemEnv.getHtmlLabelName(547673,weaver.general.ThreadVarLanguage.getLang())); + } + } + } + } + return result; + } + public Map handleKQFlowAction(String proc_set_id, String usedetails, int requestId, int kqtype, + int workflowId,boolean isForce,boolean isUpgrade,Map map) throws Exception{ + Map result = new HashMap<>(); + ResourceComInfo rci = new ResourceComInfo(); + List splitBeans = new ArrayList(); + + DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + //生成处理的sql + Map sqlMap = handleSql(proc_set_id, usedetails, requestId,kqtype,map); + if(sqlMap != null && !sqlMap.isEmpty()){ + KqSplitFlowTypeEnum flowTypeEnum = null; + if(kqtype == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + KQFlowLeaveUtil kqFlowLeaveUtil = new KQFlowLeaveUtil(); + result=kqFlowLeaveUtil.handleKQLeaveAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.LEAVE; + }else if(kqtype == KqSplitFlowTypeEnum.EVECTION.getFlowtype()){ + KQFlowEvectionUtil kqFlowEvectionUtil = new KQFlowEvectionUtil(); + result=kqFlowEvectionUtil.handleKQEvectionAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.EVECTION; + }else if(kqtype == KqSplitFlowTypeEnum.OUT.getFlowtype()){ + KQFlowOutUtil kqFlowOutUtil = new KQFlowOutUtil(); + result=kqFlowOutUtil.handleKQOutAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.OUT; + }else if(kqtype == KqSplitFlowTypeEnum.OVERTIME.getFlowtype()){ + KQFlowOvertimeUtil kqFlowOvertimeUtil = new KQFlowOvertimeUtil(); + result=kqFlowOvertimeUtil.handleKQOvertimeAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci,""); + flowTypeEnum = KqSplitFlowTypeEnum.OVERTIME; + }else if(kqtype == KqSplitFlowTypeEnum.SHIFT.getFlowtype()){ + KQFlowShiftUtil kqFlowShiftUtil = new KQFlowShiftUtil(); + result = kqFlowShiftUtil.handleKQShiftAction2(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci,result,map); + flowTypeEnum = KqSplitFlowTypeEnum.SHIFT; + }else if(kqtype == KqSplitFlowTypeEnum.OTHER.getFlowtype()){ + KQFlowOtherUtil kqFlowOtherUtil = new KQFlowOtherUtil(); + result=kqFlowOtherUtil.handleKQOtherAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.OTHER; + }else if(kqtype == KqSplitFlowTypeEnum.CARD.getFlowtype()){ + KQFlowCardUtil kqFlowCardUtil = new KQFlowCardUtil(); + result=kqFlowCardUtil.handleKQCardAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.CARD; + }else if(kqtype == KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype()){ + KQFlowLeaveBackUtil kqFlowLeaveBackUtil = new KQFlowLeaveBackUtil(); + result=kqFlowLeaveBackUtil.handleKQLeaveBackAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.LEAVEBACK; + }else if(kqtype == KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype()){ + KQFlowProcessChangeUtil kqFlowProcessChangeUtil = new KQFlowProcessChangeUtil(); + result=kqFlowProcessChangeUtil.handleKQProcessChangeAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + flowTypeEnum = KqSplitFlowTypeEnum.PROCESSCHANGE; + }else{ + new BaseBean().writeLog("考勤流程没有找到对应类型:proc_set_id:"+proc_set_id+":requestId:"+requestId+":kqtype:"+kqtype); + } + if(!result.isEmpty()){ + if(!isUpgrade){ + return result; + } + } + if(!splitBeans.isEmpty() && flowTypeEnum != null){ + if(flowTypeEnum == KqSplitFlowTypeEnum.LEAVEBACK){ + KQFlowLeaveBackUtil kqFlowLeaveBackUtil = new KQFlowLeaveBackUtil(); + //销假流程需要再拆分下 + kqFlowLeaveBackUtil.handleSplitFLowActionData4LeaveBack(splitBeans,result,isUpgrade,requestId); + clear_flow_deduct_card(splitBeans,KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype()+"",requestId); + }else if(flowTypeEnum == KqSplitFlowTypeEnum.PROCESSCHANGE){ + KQFlowProcessChangeUtil kqFlowProcessChangeUtil = new KQFlowProcessChangeUtil(); + kqFlowProcessChangeUtil.handleSplitFLowActionData4ProcessChange(splitBeans,result,isUpgrade,requestId); + clear_flow_deduct_card(splitBeans,KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype()+"",requestId); + }else if(flowTypeEnum != KqSplitFlowTypeEnum.CARD && flowTypeEnum != KqSplitFlowTypeEnum.SHIFT){ + KQFlowUtil kqFlowUtil = new KQFlowUtil(); + kqFlowUtil.handleSplitFLowActionData(splitBeans,flowTypeEnum,rci,result,isForce,requestId,workflowId,isUpgrade); + //流程抵扣打卡 + handle_flow_deduct_card(workflowId,splitBeans,requestId); + } + } + } + return result; + } + + /** + * 流程抵扣打卡逻辑 + * @param workflowId + * @param splitBeans + * @param requestId + */ + public void handle_flow_deduct_card(int workflowId, + List splitBeans, int requestId) { + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + String flow_deduct_card = Util.null2String(kqAttProcSetComInfo.getFlow_deduct_card(""+workflowId)); + String kqType = Util.null2String(kqAttProcSetComInfo.getkqType(""+workflowId)); + kqLog.info("handle_flow_deduct_card:flow_deduct_card:"+ flow_deduct_card+":workflowId:"+workflowId+":requestId:"+requestId); + if("1".equalsIgnoreCase(flow_deduct_card)){ + do_flow_deduct_card(splitBeans,kqType,requestId); + }else{ +// 这里扩展个操作,如果没有开启就先把对应的requestid删除掉 + if(requestId > 0){ + RecordSet rs = new RecordSet(); + String sql1 = "select * from kq_flow_deduct_card where requestid = ? "; + rs.executeQuery(sql1,requestId); + List formateList = new ArrayList<>(); + while (rs.next()){ + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String key = resourceid+"_"+belongdate; + formateList.add(key); + } + String sql = "delete from kq_flow_deduct_card where requestid = ? "; + rs.executeUpdate(sql, requestId); + kqLog.info("clear_flow_deduct_card:formateList:"+formateList); + for(String format: formateList){ + kqLog.info("clear_flow_deduct_card:format:"+ JSON.toJSONString(format)); + String[] formats = format.split("_"); + new KQFormatData().formatKqDateByLock(formats[0],formats[1],17); + } + } + } + } + + /** + * 销假流程 消除流程抵扣打卡 + * @param splitBeans + * @param kqType + * @param requestId + */ + public void clear_flow_deduct_card(List splitBeans, String kqType, int requestId) { + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + List clear_ids = new ArrayList<>(); + List formateList = new ArrayList<>(); + List updateParamList = new ArrayList(); + List updateList = new ArrayList(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + for(SplitBean bean : splitBeans){ + String leavebackrequestid = bean.getLeavebackrequestid(); + String resourceId = bean.getResourceId(); + String belongDate = bean.getBelongDate(); + String fromdate = bean.getFromDate(); + String fromtime = bean.getFromTime(); + String todate = bean.getToDate(); + String totime = bean.getToTime(); + String key = resourceId+"_"+belongDate; + formateList.add(key); + String deduct_sql = "select * from kq_flow_deduct_card where requestid = '"+leavebackrequestid+"' and resourceId='"+resourceId+"' and belongDate='"+belongDate+"'"; + if((KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype()+"").equals(kqType) && !"".equals(bean.getNewLeaveType())) { // 考勤变更流程中的请假变更 + rs.executeQuery(deduct_sql); + while (rs.next()) { + String deduct_id = rs.getString("id"); + updateList = new ArrayList(); + clear_ids.add(deduct_id); + updateList.add(deduct_id); + updateParamList.add(updateList); + } + continue; + } + int fromtimeIdx = kqTimesArrayComInfo.getArrayindexByTimes(fromtime); + int totimeIdx = kqTimesArrayComInfo.getArrayindexByTimes(totime); + rs.executeQuery(deduct_sql); + while(rs.next()){ +// String deduct_id = rs.getString("id"); +// String signtype = rs.getString("signtype"); +// String deduct_fromtime = rs.getString("fromtime"); +// String deduct_totime = rs.getString("totime"); +// int deduct_fromtimeIdx = kqTimesArrayComInfo.getArrayindexByTimes(deduct_fromtime); +// int deduct_totimeIdx = kqTimesArrayComInfo.getArrayindexByTimes(deduct_totime); +// updateList = new ArrayList(); +// if("1".equalsIgnoreCase(signtype)){ +// if(fromtimeIdx == deduct_fromtimeIdx && !clear_ids.contains(deduct_id)){ +// clear_ids.add(deduct_id); +// updateList.add(deduct_id); +// updateParamList.add(updateList); +// } +// }else if("2".equalsIgnoreCase(signtype)){ +// if(totimeIdx == deduct_totimeIdx && !clear_ids.contains(deduct_id)){ +// clear_ids.add(deduct_id); +// updateList.add(deduct_id); +// updateParamList.add(updateList); +// } +// } + + + String deduct_id = rs.getString("id"); + String signtype = rs.getString("signtype"); + String deduct_fromtime = rs.getString("workBeginTime"); + String deduct_totime = rs.getString("workEndTime"); + int deduct_fromtimeIdx = kqTimesArrayComInfo.getArrayindexByTimes(deduct_fromtime); + int deduct_totimeIdx = kqTimesArrayComInfo.getArrayindexByTimes(deduct_totime); + updateList = new ArrayList(); + if("1".equalsIgnoreCase(signtype)){ + if(fromtimeIdx <= deduct_fromtimeIdx && !clear_ids.contains(deduct_id)){ + clear_ids.add(deduct_id); + updateList.add(deduct_id); + updateParamList.add(updateList); + } + }else if("2".equalsIgnoreCase(signtype)){ + if(totimeIdx >= deduct_totimeIdx && !clear_ids.contains(deduct_id)){ + clear_ids.add(deduct_id); + updateList.add(deduct_id); + updateParamList.add(updateList); + } + } + } + } + kqLog.info("clear_flow_deduct_card:clear_ids:"+ clear_ids.size()+":ids:"+JSONObject.toJSONString(clear_ids)); +// if(!clear_ids.isEmpty()){ +// for(String id : clear_ids){ +// String sql = "update kq_flow_deduct_card set isclear=1 where id = "+id; +// rs1.executeUpdate(sql); +// } + /*更新抵扣打卡数据 start*/ + boolean isSuccess = true; + String updateSql = "update kq_flow_deduct_card set isclear=1 where id=?"; + if (updateParamList.size() > 0) { + isSuccess = rs1.executeBatchSql(updateSql, updateParamList); + kqLog.info("clear_flow_deduct_card:formateList:"+formateList); + for(String format: formateList){ + kqLog.info("clear_flow_deduct_card:format:"+ JSON.toJSONString(format)); + String[] formats = format.split("_"); + new KQFormatData().formatKqDateByLock(formats[0],formats[1],17); + } + } + /*更新抵扣打卡数据 end*/ + +// } + } + + /** + * 流程抵扣打卡逻辑 + * @param splitBeans + * @param kqType + * @param requestId + */ + public void do_flow_deduct_card(List splitBeans, String kqType, int requestId) { + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String batchSql = "insert into kq_flow_deduct_card(requestid,resourceid,belongDate,fromdate,fromtime,todate,totime,workBeginTime,workEndTime,signtype,flowtype,serialnumber)"+ + " values(?,?,?,?,?,?,?,?,?,?,?,?) "; + List params = new ArrayList(); + List formateList = new ArrayList<>(); + kqLog.info("handle_flow_deduct_card:splitBeans:"+ JSON.toJSONString(splitBeans)); + for(SplitBean bean : splitBeans){ + do_flow_deduct_in_table(bean,formateList,params,kqType,requestId, ""); + + if(Util.getIntValue(kqType) == KqSplitFlowTypeEnum.EVECTION.getFlowtype()){ + String companion = Util.null2s(bean.getCompanion(), ""); + if(companion.length() > 0){ + String[] companions = companion.split(","); + if(companions != null && companions.length > 0 ) { + for (int i = 0; i < companions.length; i++) { + String compan_resid = companions[i]; + if(bean.getResourceId().equalsIgnoreCase(compan_resid)){ + //陪同人是自己的不要存到中间表里 + continue; + } + do_flow_deduct_in_table(bean,formateList,params,kqType,requestId,compan_resid); + } + } + } + } + } + if(!params.isEmpty()) { + //先根据requestid删除中间表里的数据,再做啥插入操作 + String delSql = "delete from kq_flow_deduct_card where requestid = " + requestId; + rs.executeUpdate(delSql); + boolean isOk = rs1.executeBatchSql(batchSql, params); + if(!isOk){ + kqLog.info("do_flow_deduct_card:requestId:"+requestId+":kq_flow_deduct_card error:"+params); + return ; + } + kqLog.info("do_flow_deduct_card:formateList:"+formateList); + for(String format: formateList){ + kqLog.info("do_flow_deduct_card:format:"+ JSON.toJSONString(format)); + String[] formats = format.split("_"); + new KQFormatData().formatKqDateByLock(formats[0],formats[1],17); + } + }else{ + if(!splitBeans.isEmpty()){ + //有流程数据,但是签到签退都不包含的情况,支持多次归档,所以需要先删除再插入 + String delSql = "delete from kq_flow_deduct_card where requestid = " + requestId; + rs.executeUpdate(delSql); + } + } + } + + /** + * 流程抵扣打卡数据整合到表里 + * @param bean + * @param formateList + * @param params + * @param kqType + * @param requestId + * @param compan_resid 出差流程的陪同人 + */ + public void do_flow_deduct_in_table(SplitBean bean, List formateList, + List params, String kqType, int requestId, String compan_resid) { + KQWorkTime kqWorkTime = new KQWorkTime(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + String resourceId = bean.getResourceId(); + if(compan_resid.length() > 0 && Util.getIntValue(kqType) == KqSplitFlowTypeEnum.EVECTION.getFlowtype()){ + resourceId = compan_resid; + } + String belongDate = bean.getBelongDate(); + String fromdate = bean.getFromDate(); + String fromtime = bean.getFromTime(); + String todate = bean.getToDate(); + String totime = bean.getToTime(); + boolean oneSign = false; + WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceId, belongDate); + String key = resourceId+"_"+belongDate; + formateList.add(key); + List lsWorkTime = new ArrayList<>(); + List lsSignTime = new ArrayList<>(); + if (workTime != null) { + lsWorkTime = workTime.getWorkTime();//工作时间 + lsSignTime = workTime.getSignTime();//允许打卡时间 + oneSign = lsWorkTime!=null&&lsWorkTime.size()==1; + for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) { + TimeScopeEntity workTimeScope = lsWorkTime.get(i); + String workBeginTime = Util.null2String(workTimeScope.getBeginTime()); + int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime); + boolean workBenginTimeAcross = workTimeScope.getBeginTimeAcross(); + String workEndTime = Util.null2String(workTimeScope.getEndTime()); + int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + boolean workEndTimeAcross = workTimeScope.getEndTimeAcross(); + int[] dayMins = new int[2880];//一天所有分钟数 + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(Util.null2String(fromtime)); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(Util.null2String(totime)); + if(beginIdx > endIdx){ + continue; + } + if(oneSign){ + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + if(is_flow_humanized){ + //个性化设置只支持一天一次上下班 + ShiftInfoBean shiftInfoBean = new ShiftInfoBean(); + Map shifRuleMap = Maps.newHashMap(); + shiftInfoBean.setSplitDate(belongDate); + shiftInfoBean.setShiftRuleMap(workTime.getShiftRuleInfo()); + shiftInfoBean.setSignTime(lsSignTime); + shiftInfoBean.setWorkTime(lsWorkTime); + KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, resourceId, shifRuleMap); + if(!shifRuleMap.isEmpty()){ + if(shifRuleMap.containsKey("shift_beginworktime")){ + String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime")); + if(shift_beginworktime.length() > 0){ + workBeginTime = Util.null2String(shift_beginworktime); + workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime); + } + } + if(shifRuleMap.containsKey("shift_endworktime")){ + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if(shift_endworktime.length() > 0){ + workEndTime = Util.null2String(shift_endworktime); + workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + } + } + } + } + } + if(Util.getIntValue(kqType) == KqSplitFlowTypeEnum.EVECTION.getFlowtype()){ + Arrays.fill(dayMins, beginIdx, endIdx, 7);//出差抵扣时段标识 7 + }else if(Util.getIntValue(kqType) == KqSplitFlowTypeEnum.OUT.getFlowtype()){ + Arrays.fill(dayMins, beginIdx, endIdx, 8);//公出抵扣时段标识 8 + }else if(Util.getIntValue(kqType) == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 5);//流程抵扣时段标识 5 + } + }else{ + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 99);//异常流程抵扣时段标识99 + } + } + + int cnt_7 = kqTimesArrayComInfo.getCnt(dayMins, workBeginIdx, workEndIdx, 7); + int cnt_8 = kqTimesArrayComInfo.getCnt(dayMins, workBeginIdx, workEndIdx, 8); + int cnt_5 = kqTimesArrayComInfo.getCnt(dayMins, workBeginIdx, workEndIdx, 5); + int cnt_99 = kqTimesArrayComInfo.getCnt(dayMins, workBeginIdx, workEndIdx, 99); + //流程时长大于0的才去做流程抵扣的处理 + if(cnt_7 > 0 || cnt_8 > 0 || cnt_5 > 0 || cnt_99 > 0){ + //如果流程时长大于0 结束时间因为是下标,需要补1分钟 + if(Util.getIntValue(kqType) == KqSplitFlowTypeEnum.EVECTION.getFlowtype()){ + Arrays.fill(dayMins, endIdx, endIdx+1, 7);//出差抵扣时段标识 7 + }else if(Util.getIntValue(kqType) == KqSplitFlowTypeEnum.OUT.getFlowtype()){ + Arrays.fill(dayMins, endIdx, endIdx+1, 8);//公出抵扣时段标识 8 + }else if(Util.getIntValue(kqType) == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + Arrays.fill(dayMins, endIdx, endIdx+1, 5);//流程抵扣时段标识 5 + }else{ + Arrays.fill(dayMins, endIdx, endIdx+1, 99);//异常流程抵扣时段标识99 + } + + if(dayMins[workBeginIdx]>=5){//签到时间点有流程 + List beanParams = new ArrayList(); + beanParams.add(requestId); + beanParams.add(resourceId); + beanParams.add(belongDate); + beanParams.add(fromdate); + beanParams.add(fromtime); + beanParams.add(todate); + beanParams.add(totime); + beanParams.add(workBeginTime); + beanParams.add(workEndTime); + beanParams.add("1"); + beanParams.add(kqType); + beanParams.add(i); + params.add(beanParams); + } + + if(dayMins[workEndIdx]>=5){//签退时间点有流程 + List beanParams = new ArrayList(); + beanParams.add(requestId); + beanParams.add(resourceId); + beanParams.add(belongDate); + beanParams.add(fromdate); + beanParams.add(fromtime); + beanParams.add(todate); + beanParams.add(totime); + beanParams.add(workBeginTime); + beanParams.add(workEndTime); + beanParams.add("2"); + beanParams.add(kqType); + beanParams.add(i); + params.add(beanParams); + } + }else{ + kqLog.info("handle_flow_deduct_card::i:"+i+":workBeginIdx:"+ workBeginIdx+":workEndIdx:"+ workEndIdx + +":cnt_7:"+cnt_7+":cnt_8:"+cnt_8+":cnt_5:"+cnt_5+":cnt_99:"+cnt_99); + } + } + }else{ + kqLog.info("handle_flow_deduct_card:workTime is null :resourceId:"+ resourceId+":belongDate:"+belongDate); + } + } + + + /** + * 拆分请假数据 生成splitBeans + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @param durationTypeEnum + * @return + * @throws Exception + */ + public Map handleAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci, DurationTypeEnum durationTypeEnum) throws Exception { + RecordSet rs1 = new RecordSet(); + KQFlowUtil kqFlowUtil = new KQFlowUtil(); + Map result = new HashMap<>(); + + if (!sqlMap.isEmpty()) { + Map detaiidmap = new HashMap<>(); + for (Map.Entry me : sqlMap.entrySet()) { + String key = me.getKey(); + String value = me.getValue(); + + rs1.execute(value); + while (rs1.next()) { + SplitBean splitBean = new SplitBean(); + boolean isFillRight = kqFlowUtil.fillSplitBean(splitBean, rs1, "" + requestId, rci, "" + workflowId, durationTypeEnum, key, result, datetimeFormatter, + ""); + if (!isFillRight) { + new BaseBean().writeLog("升级失败:" + requestId + ";;result>>>" + JSONObject.toJSONString(result)); + continue; + } + if (result.containsKey("isProcessDrawBack")) { + result.clear(); + splitBeans.add(splitBean); + } else { + doWorkSplitChain(splitBean, splitBeans); + } + +// if("6889".equals(splitBean.getResourceId())){ +// new BaseBean().writeLog("1:requestId" + requestId + ";;splitBean>>>" + JSON.toJSON(splitBean)); +// new BaseBean().writeLog("1:requestId" + requestId + ";;splitBeans>>>" + JSON.toJSON(splitBeans)); +// } + + + //先加个判断,以便后面调整 + if(durationTypeEnum == DurationTypeEnum.LEAVE || durationTypeEnum == DurationTypeEnum.EVECTION + || durationTypeEnum == DurationTypeEnum.OUT || durationTypeEnum == DurationTypeEnum.LEAVEBACK + || durationTypeEnum == DurationTypeEnum.PROCESSCHANGE){ + String edit_duration = splitBean.getEdit_duration().trim(); + + if(edit_duration.length() > 0){ + if("1".equals(splitBean.getUsedetail())){ + detaiidmap.put(splitBean.getDetailId(),edit_duration); + Map> collect = splitBeans.stream().collect(Collectors.groupingBy(SplitBean::getDetailId)); + if(null != collect && !collect.isEmpty()){ + for(Map.Entry> entry : collect.entrySet()){ + String mapkey = Util.null2String(entry.getKey()); + edit_duration = detaiidmap.get(mapkey); + List mapvalue = entry.getValue(); + if(null != mapkey && mapvalue.size()>0){ + Map> collect1 = mapvalue.stream().collect(Collectors.groupingBy(SplitBean::getResourceId)); + for(Map.Entry> entry1 : collect1.entrySet()){ + List mapvalue1 = entry1.getValue(); + for (int i = 0; i < mapvalue1.size(); i++) { + SplitBean splitBeanTemp = mapvalue1.get(i); + if(i==0){ + splitBeanTemp.setDuration(edit_duration); + splitBeanTemp.setDurationDB(edit_duration); + if("3".equals(splitBeanTemp.getDurationrule()) || "5".equals(splitBeanTemp.getDurationrule()) || "6".equals(splitBeanTemp.getDurationrule())){ + double D_Mins = Util.getDoubleValue(edit_duration,0.0)*60; + splitBeanTemp.setD_Mins(D_Mins); + }else{ + double D_Mins = Util.getDoubleValue(edit_duration,0.0)*splitBeanTemp.getWorkmins(); + splitBeanTemp.setD_Mins(D_Mins); + } + }else{//开会沟通:默认时长给第一天,其他的日期时长为0 + splitBeanTemp.setDuration("0"); + splitBeanTemp.setDurationDB(edit_duration); + splitBeanTemp.setD_Mins(0); + } + } + } + } + } + } + }else{ + for(int i=0;i 0) { + List companionList = Util.splitString2List(companion, ","); + for (int i = 0; i < companionList.size(); i++) { + String be_companion = Util.null2String(companionList.get(i)); + if (be_companion.length() > 0 && Util.getIntValue(be_companion) > 0) { + SplitBean compSplitBean = new SplitBean(); + boolean compFillRight = kqFlowUtil.fillSplitBean(compSplitBean, rs1, "" + requestId, + rci, "" + workflowId, durationTypeEnum, key, result, datetimeFormatter, ""); + if (!compFillRight) { + return result; + } + if (splitBean.getResourceId().equalsIgnoreCase(be_companion)) { + //陪同人是自己的不要存到中间表里 + continue; + } + compSplitBean.setResourceId(be_companion); + compSplitBean.setSubcompanyid(Util.null2s(rci.getSubCompanyID(be_companion), "0")); + compSplitBean.setDepartmentid(Util.null2s(rci.getDepartmentID(be_companion), "0")); + compSplitBean.setJobtitle(Util.null2s(rci.getJobTitle(be_companion), "0")); + compSplitBean.setIscompanion("1"); + compSplitBean.setCompanion(""); + + List splitBeans_tmp = new ArrayList<>(); + + if (result.containsKey("isProcessDrawBack")) { + result.clear(); + splitBeans_tmp.add(compSplitBean); + } else { + doWorkSplitChain(compSplitBean, splitBeans_tmp); + } + + String edit_duration = splitBean.getEdit_duration().trim(); + if(edit_duration.length() > 0 && null != splitBeans_tmp && splitBeans_tmp.size()>0){ +// if("1".equals(splitBean.getUsedetail())){ +// List detailIds = splitBeans_tmp.stream().map(SplitBean::getDetailId).distinct().collect(Collectors.toList()); +// if(null != detailIds && detailIds.size()>0){ +// for (String detailId : detailIds) { +// int index = -1; +// for(int j=0;j0){ + splitBeans.addAll(splitBeans_tmp); + }else{ + new BaseBean().writeLog("splitBeans_tmp is null:requestId" + requestId + ";;result>>>" + JSONObject.toJSONString(result)); + } + } + } + } + } + + } + } + } + + return result; + } + + /** + * 生成处理的sql + * @param proc_set_id + * @param usedetails + * @param requestidInt + * @return + */ + public Map handleSql(String proc_set_id,String usedetails,int requestidInt,int kqtype,Map map) { + HrmAttProcSetManager hrmAttProcSetManager= new HrmAttProcSetManager(); + Map sqlMap = new HashMap<>(); + sqlMap = hrmAttProcSetManager.getSQLByField006Map(kqtype, map, false, true, proc_set_id,usedetails); + + return sqlMap; + } + + /** + * 计算工作时长拆分 + * @param splitBean + * @param splitBeans + * @throws Exception + */ + public void doWorkSplitChain(SplitBean splitBean,List splitBeans) throws Exception{ + + WorkDurationChain hourUnitSplitChain = new WorkHourUnitSplitChain(splitBeans); + WorkDurationChain dayUnitSplitChain = new WorkDayUnitSplitChain(splitBeans); + WorkDurationChain halfUnitSplitChain = new WorkHalfUnitSplitChain(splitBeans); + WorkDurationChain wholeUnitSplitChain = new WorkWholeUnitSplitChain(splitBeans); + + //设置执行链 + hourUnitSplitChain.setDurationChain(dayUnitSplitChain); + dayUnitSplitChain.setDurationChain(halfUnitSplitChain); + halfUnitSplitChain.setDurationChain(wholeUnitSplitChain); + //把初始数据设置进去 + hourUnitSplitChain.handleDuration(splitBean); + } + + /** + * 测试流程,删除测试数据的同时 + * 1、需要把冻结数据释放 + * 2、中间表数据清除 + * 3、格式化考勤报表 + * @param temprequestid + * @param workflowid + */ + public void delTest(int temprequestid, String workflowid,String from) { + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + RecordSet rs3 = new RecordSet(); + try { + + kqLog.info("KQFlowActiontBiz delTest:workflowid:"+workflowid+":from:"+from+":temprequestid:"+temprequestid); + if(Util.null2s(workflowid,"").length() == 0){ + return ; + } + + String getkqType = "select * from kq_att_proc_set where field001=? "; + rs.executeQuery(getkqType,workflowid); + if(rs.next()){ + boolean isCard = false; + boolean isOvertime = false; + boolean isLeave = false; + boolean isProcessLeave = false; + String tablename = ""; + + //add + String carddate = ""; + String maintablename = ""; + String detailtablename = ""; + String proc_set_id = ""; + String usedetails = ""; + Map map = new HashMap(); + + int kqtype= Util.getIntValue(rs.getString("field006"),-1); + if(kqtype == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.LEAVE.getTablename(); + isLeave = true; + }else if(kqtype == KqSplitFlowTypeEnum.EVECTION.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.EVECTION.getTablename(); + }else if(kqtype == KqSplitFlowTypeEnum.OUT.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.OUT.getTablename(); + }else if(kqtype == KqSplitFlowTypeEnum.OVERTIME.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.OVERTIME.getTablename(); + isOvertime = true; + }else if(kqtype == KqSplitFlowTypeEnum.SHIFT.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.SHIFT.getTablename(); + }else if(kqtype == KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype()) { + isProcessLeave = true; + tablename = KqSplitFlowTypeEnum.LEAVE.getTablename(); + }else if(kqtype == KqSplitFlowTypeEnum.OTHER.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.OTHER.getTablename(); + }else if(kqtype == KqSplitFlowTypeEnum.CARD.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.CARD.getTablename(); + isCard = true; + + //add + proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + usedetails = rs.getString("usedetail"); + maintablename = rs.getString("tablename"); + detailtablename = rs.getString("detailtablename"); + if(temprequestid > 0){ + map.put("requestId", "and t.requestId = " + temprequestid); + } + //end + + }else if(kqtype == KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.LEAVEBACK.getTablename(); + }else{ + new BaseBean().writeLog("删除测试流程异常,未找到考勤流程类型:workflowid:"+workflowid); + } + if(tablename.length() > 0){ + KQFormatBiz kqFormatBiz = new KQFormatBiz(); + + List formateList = new ArrayList<>(); + if(isCard){ + + if(detailtablename.length()>0){ + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + boolean isForce1 = false; + boolean isUpgrade1 = false; + + Map sqlMap = handleSql(proc_set_id, usedetails, temprequestid,kqtype,map); + + KQFlowCardUtil kqFlowCardUtil = new KQFlowCardUtil(); + ResourceComInfo rci = new ResourceComInfo(); + List splitBeans = new ArrayList(); + + DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + Map result=delCardAction(sqlMap,splitBeans,datetimeFormatter,Util.getIntValue(workflowid),temprequestid,rci); + + } + }else if(isOvertime){ + SplitActionUtil.clearSameRequestTX(temprequestid+""); + String delTableSql = "delete from "+tablename+" where requestId= ? "; + boolean isUpdate = rs2.executeUpdate(delTableSql,temprequestid); + kqLog.info("KQFlowActiontBiz delTest:delTableSql:"+delTableSql+":temprequestid:"+temprequestid+":isUpdate:"+isUpdate); + }else{ + List backsplitBeans = new ArrayList<>(); + String sql = "select * from "+tablename+" where requestId= ? "; + rs2.executeQuery(sql, temprequestid); + kqLog.info("KQFlowActiontBiz delTest:sql:"+sql+":requestId:"+temprequestid+":counts:"+rs2.getCounts()); + while (rs2.next()){ + String resourceid = rs2.getString("resourceid"); + String belongdate = rs2.getString("belongdate"); + String key = resourceid+"_"+belongdate; + formateList.add(key); + if(isLeave || isProcessLeave) { + SplitBean splitBean = new SplitBean(); + String requestid = rs2.getString("requestid"); + String newLeaveType = rs2.getString("newleavetype"); + String duration = rs2.getString("duration"); + String durationrule = rs2.getString("durationrule"); + String fromdatedb = rs2.getString("fromdatedb"); + splitBean.setRequestId(requestid); + splitBean.setResourceId(resourceid); + splitBean.setNewLeaveType(newLeaveType); + splitBean.setDuration(duration); + splitBean.setDurationrule(durationrule); + splitBean.setFromdatedb(fromdatedb); + backsplitBeans.add(splitBean); + } + } + kqLog.info("KQFlowActiontBiz delTest:isLeave:"+isLeave+":backsplitBeans:"+JSON.toJSONString(backsplitBeans)); + String delTableSql = "delete from "+tablename+" where requestId= ? "; + boolean isUpdate = rs2.executeUpdate(delTableSql,temprequestid); + kqLog.info("KQFlowActiontBiz delTest:delTableSql:"+delTableSql+":temprequestid:"+temprequestid+":isUpdate:"+isUpdate); + //如果有流程抵扣,删除对应流程抵扣的数据 + String delSql = "delete from kq_flow_deduct_card where requestid = ? "; + isUpdate = rs3.executeUpdate(delSql,temprequestid); + kqLog.info("KQFlowActiontBiz delTest:delSql:"+delSql+":temprequestid:"+temprequestid+":isUpdate:"+isUpdate); + + kqLog.info("KQFlowActiontBiz delTest:formateList:"+formateList); + for(String formateStr : formateList){ + String[] formateStrs = formateStr.split("_"); + new KQFormatData().formatKqDateByLock(formateStrs[0],formateStrs[1],17); + } + if(isLeave || isProcessLeave) { + List processRequestIds = new ArrayList<>(); + for (SplitBean splitBean : backsplitBeans) { + String requestid = splitBean.getRequestId(); + String resourceId = splitBean.getResourceId(); + String newLeaveType = splitBean.getNewLeaveType(); + String duration = splitBean.getDuration(); + String durationrule = splitBean.getDurationrule(); + String fromdate = splitBean.getFromDate(); + boolean isLeaveFlowOver = isLeaveFlowOver(requestid); + kqLog.info("isLeaveFlowOver:"+isLeaveFlowOver); + if (isLeaveFlowOver) { + kqLog.info("流程退回后主动返还假期:delTest:resourceId:" + resourceId + ":duration:" + duration + ":newLeaveType:" + newLeaveType + ":durationrule:" + durationrule + ":requestid:" + requestid + ":fromdate:" + fromdate); + KQBalanceOfLeaveBiz.reduceUsedAmount(resourceId, fromdate, newLeaveType, duration, "", requestid,requestid); + } + if(isProcessLeave) { // 如果是变更请假流程,不仅要返还变更时长,还需要将原先历史请假时长扣减 + if(processRequestIds.contains(requestid)) { + continue; + } + processRequestIds.add(requestid); + String processSql = "select * from "+tablename+" where leavebackrequestid='"+requestid+"' and status='1'"; + kqLog.info("processSql:::::::"+processSql); + rs.executeQuery(processSql); + List processSplitBeans = new ArrayList<>(); + List processParam = new ArrayList<>(); + SplitBean processBean = null; + while (rs.next()) { + String oldRequestid = rs.getString("requestid"); + String oldUserId = rs.getString("resourceid"); + String oldNewleavetype = rs.getString("newleavetype"); + String oldFromDateDb = rs.getString("fromdatedb"); + String oldToDateDb = rs.getString("todatedb"); + String oldDurationDb = rs.getString("durationdb"); + String param = oldRequestid+"#"+oldUserId+"#"+oldNewleavetype+"#"+oldFromDateDb+"#"+oldToDateDb+"#"+oldDurationDb; + if(processParam.contains(param)) { + continue; + } + processParam.add(param); + processBean = new SplitBean(); + processBean.setRequestId(oldRequestid); + processBean.setResourceId(oldUserId); + processBean.setNewLeaveType(oldNewleavetype); + processBean.setFromdatedb(oldFromDateDb); + processBean.setTodatedb(oldToDateDb); + processBean.setDurationDB(oldDurationDb); + processSplitBeans.add(processBean); + } + for(SplitBean splitBean1 : processSplitBeans) { + String oldRquestId = splitBean1.getRequestId(); + String oldFromDateDb = splitBean1.getFromdatedb(); + String oldToDateDb = splitBean1.getTodatedb(); + handleProcessLeave(oldFromDateDb, oldToDateDb, oldRquestId); +// kqLog.info("请假扣减:oldUserId:" + oldUserId + ":oldFromDateDb:" + oldFromDateDb + ":oldDurationDb:" + oldDurationDb + ":oldNewleavetype:" + oldNewleavetype + ":durationrule:" + durationrule + ":requestid:" + requestid + ":fromdatedb:" + fromdatedb); +// KQBalanceOfLeaveBiz.addUsedAmount(oldUserId, oldFromDateDb, oldNewleavetype, oldDurationDb, "", requestid, oldFromDateDb); + } + } + } + String updateFreezeSql = "update KQ_ATT_VACATION set status=2 where requestId=? "; + isUpdate = rs1.executeUpdate(updateFreezeSql,temprequestid); + kqLog.info("KQFlowActiontBiz delTest:updateFreezeSql:"+updateFreezeSql+":temprequestid:"+temprequestid+":isUpdate:"+isUpdate); + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog("KQFlowActiontBiz delTest:temprequestid:"+temprequestid+":workflowid:"+workflowid+":报错:"+e.getMessage()); + } + } + + /** + * 看下请假流程是不是已经归档并生成了扣减 + * @param requestId + * @return + */ + private boolean isLeaveFlowOver(String requestId) { + RecordSet rs = new RecordSet(); + String sql = "select * from kq_UsageHistory where wfRequestId=?"; + rs.executeQuery(sql, requestId); + boolean isOver = false; + if(rs.next()) { + isOver = true; + } + return isOver; + } + + public Map delCardAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + + String[] cardFields = KQAttFlowFieldsSetBiz.cardFields; + + KQFormatData kqFormatData = new KQFormatData(); + Map result = new HashMap<>(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + + String resourceId = ""; + String resourceIds = ""; + String detail_scheduletime = ""; + String detail_signtype = ""; + String detail_signdate = ""; + String detail_signtime = ""; + String detail_resourceid = ""; + + String userId = ""; + String userType = "1";//默认给1 + String signType = ""; + String signDate = ""; + String signTime = ""; + String isInCom = "1"; + String signfrom = ""; + + String signStatus = ""; + List formateList = new ArrayList<>(); + if(!sqlMap.isEmpty()){ + for(Map.Entry me : sqlMap.entrySet()){ + String concort = "###" ; + String key = me.getKey(); + String value = me.getValue(); + + String wfId = key.split(concort)[3] ; + int usedetail = Util.getIntValue(key.split(concort)[2], 0); + String tableDetailName= key.split(concort)[1] ; + String tableName= key.split(concort)[0] ; + String idVal = ""; + String id = "dataId"; + if(usedetail == 1){ + id = "detailId"; + } + kqLog.info("findcardsql="+value); + rs1.execute(value); + List belongDateList = Lists.newArrayList(); + List overtimeList = Lists.newArrayList(); + Map> formatMap = Maps.newHashMap(); + Map> overtimeMap = Maps.newHashMap(); + while (rs1.next()) { + idVal = Util.null2s(rs1.getString(id), ""); + String signSource = "card:|wfid|"+wfId+"|requestid|"+requestId+"|detailId|"+idVal; + + String f_resourceId = cardFields[0]; + String f_detail_signdate = cardFields[3]; + String f_detail_scheduletime = cardFields[4]; + String f_detail_signtype = cardFields[6]; + String f_detail_signtime = cardFields[7]; + String f_resourceIds = cardFields[8]; + String f_detail_resourceid = cardFields[9]; + resourceId = Util.null2s(rs1.getString(f_resourceId), ""); + detail_scheduletime = Util.null2s(rs1.getString(f_detail_scheduletime), ""); + detail_signtype = Util.null2s(rs1.getString(f_detail_signtype), ""); + detail_signdate = Util.null2s(rs1.getString(f_detail_signdate), ""); + detail_signtime = Util.null2s(rs1.getString(f_detail_signtime), ""); + detail_resourceid = Util.null2s(rs1.getString(f_detail_resourceid), ""); + userId = "".equals(detail_resourceid) ? resourceId : detail_resourceid; + + signType = "0".equalsIgnoreCase(detail_signtype)?"1":"2"; + signDate = detail_signdate; + signTime = detail_signtime+":00"; + signfrom = signSource; + + StringBuffer sql = new StringBuffer("delete from HrmScheduleSign where userid='").append(userId).append("' and signdate='").append(signDate).append("'") + .append(" and signtime='").append(signTime).append("' and signfrom='").append(signfrom).append("'"); + kqLog.info("delcardsql="+sql.toString()); + boolean isOk = rs2.execute(sql.toString()); + + if(!isOk){ + result.put("status", "-1"); + result.put("message", "删除补卡数据失败!"); + return result; + } + kqLog.info("delCardAction:userId:"+userId+":signDate:"+signDate+":signTime:"+signTime); + + String format_key = userId+"_"+signDate; + formateList.add(format_key); + } + + } + kqLog.info("KQFlowActiontBiz isCard delTest:formateList:"+formateList); + if(null != formateList && formateList.size()>0){ + for(String formateStr : formateList){ + String[] formateStrs = formateStr.split("_"); + new KQFormatData().formatKqDateByLock(formateStrs[0],formateStrs[1],17); + } + } + } + + return result; + } + + /** + * 已归档考勤变更流程退回时对原请假流程的处理 + * @param fromDate + * @param toDate + * @param requestId + */ + private void handleProcessLeave(String fromDate, String toDate, String requestId) { + boolean isUpgrade1 = false; + User user = new User(1); + KQAttFlowSetBiz kqAttFlowSetBiz = new KQAttFlowSetBiz(); + Map params = new HashMap<>(); + params.put("typeselect", "6"); + params.put("tabKey", "3"); + params.put("kqtype", 0); + params.put("isMyKQ", "1"); + params.put("isNoAccount", "1"); + params.put("fromDate", fromDate); + params.put("toDate", toDate); + params.put("not_start_node", "1"); + params.put("requestId", requestId); + + Map sqlMap = kqAttFlowSetBiz.getFLowSql(params,user); + String backfields = " * "; + String fromSql = Util.null2String(sqlMap.get("from")); + String sqlWhere = Util.null2String(sqlMap.get("where")); + String allSql = "select "+ backfields + fromSql+sqlWhere; + RecordSet rs = new RecordSet(); + kqLog.info("allSql::::"+allSql); + rs.executeQuery(allSql); + Map infoMap = new HashMap<>(); + while (rs.next()) { + String currentnodetype = rs.getString("currentnodetype"); + if(!"3".equals(currentnodetype)) { + continue; + } + String workflowId = rs.getString("workflowid"); + infoMap.put(requestId, workflowId); + } + for(Map.Entry entry : infoMap.entrySet()) { + String requestid = entry.getKey(); + String workflowid = entry.getValue(); + //先根据requestid删除中间表里的数据,再做啥插入操作 + String delSql = "delete from "+ KqSplitFlowTypeEnum.LEAVE.getTablename()+" where requestid = "+requestid; + rs.executeUpdate(delSql); + + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? "; + rs.executeQuery(proc_set_sql, workflowid); + if(rs.next()) { + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + + int kqtype = Util.getIntValue(rs.getString("field006")); + + Map map = new HashMap(); + if (Util.getIntValue(requestid) > 0) { + map.put("requestId", "and t.requestId = " + requestid); + } + Map result = null; + try { + result = handleKQFlowAction(proc_set_id, usedetails, Util.getIntValue(requestid), kqtype, + Util.getIntValue(workflowid), true, isUpgrade1, map); + } catch (Exception e) { + throw new RuntimeException(e); + } + + kqLog.info("requestid:" + requestid + "执行完毕
"); + if (!result.isEmpty()) { + kqLog.info("do action on kqtype 失败:" + result + "
"); + } + } + } + } + + /** + * 拆分请假数据 生成splitBeans + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQLeaveAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + KQFlowLeaveUtil kqFlowLeaveUtil = new KQFlowLeaveUtil(); + return kqFlowLeaveUtil.handleKQLeaveAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + } + + /** + * 拆分出差数据 生成splitBeans + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQEvectionAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + KQFlowEvectionUtil kqFlowEvectionUtil = new KQFlowEvectionUtil(); + return kqFlowEvectionUtil.handleKQEvectionAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + } + + /** + * 拆分公出数据 生成splitBeans + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQOutAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + KQFlowOutUtil kqFlowOutUtil = new KQFlowOutUtil(); + return kqFlowOutUtil.handleKQOutAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + } + + /** + * 拆分加班数据 生成splitBeans + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQOvertimeAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + KQFlowOvertimeUtil kqFlowOvertimeUtil = new KQFlowOvertimeUtil(); + return kqFlowOvertimeUtil.handleKQOvertimeAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci,""); + } + /** + * 拆分排班数据 + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public void handleKQShiftAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + KQFlowShiftUtil kqFlowShiftUtil = new KQFlowShiftUtil(); + kqFlowShiftUtil.handleKQShiftAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + } + /** + * 补卡流程数据 生成签到签退数据并更新考勤报表 + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQCardAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + KQFlowCardUtil kqFlowCardUtil = new KQFlowCardUtil(); + return kqFlowCardUtil.handleKQCardAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + } + /** + * 拆分销假流程数据 生成数据到splitBeans和backsplitBeans + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQLeaveBackAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + KQFlowLeaveBackUtil kqFlowLeaveBackUtil = new KQFlowLeaveBackUtil(); + return kqFlowLeaveBackUtil.handleKQLeaveBackAction(sqlMap,splitBeans,datetimeFormatter,workflowId,requestId,rci); + } +} diff --git a/src/com/engine/kq/biz/KQFlowDataBiz.java b/src/com/engine/kq/biz/KQFlowDataBiz.java new file mode 100644 index 0000000..67cd8fc --- /dev/null +++ b/src/com/engine/kq/biz/KQFlowDataBiz.java @@ -0,0 +1,849 @@ +package com.engine.kq.biz; + +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.wfset.bean.SplitBean; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; + +/** + * 考勤流程数据 相关类 + */ +public class KQFlowDataBiz { + + private String resourceid; + private String fromDate; + private String toDate; + private String fromTime; + private String toTime; + private String belongDate; + private String newLeaveType; + private String orderby_sql; + + public KQFlowDataBiz(FlowDataParamBuilder build){ + this.resourceid = build.resourceid; + this.fromDate = build.fromDate; + this.toDate = build.toDate; + this.fromTime = build.fromTime; + this.toTime = build.toTime; + this.belongDate = build.belongDate; + this.newLeaveType = build.newLeaveType; + this.orderby_sql = build.orderby_sql; + } + + /** + * 获取所有的考勤数据 + * 请假,出差,公出,加班的 + * @param flowMaps + * @param isAll true的时候也返回加班的,false的时候不返回加班的,只返回可以抵扣异常的 + * @return + */ + public List getAllFlowData(Map flowMaps,boolean isAll){ + List allSplitBeans = new ArrayList<>(); + + Map flowDeductCard = getFlowDeductCard(); + + + allSplitBeans.addAll(getEvectionData(flowMaps,flowDeductCard)); + allSplitBeans.addAll(getOutData(flowMaps,flowDeductCard)); + allSplitBeans.addAll(getLeaveData(flowMaps,flowDeductCard)); + if(isAll){ + allSplitBeans.addAll(getOverTimeData(flowMaps)); + } + allSplitBeans.addAll(getOtherData(flowMaps)); + + return allSplitBeans; + } + + /** + * 流程抵扣考勤 + */ + public Map getFlowDeductCard() { + + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + Map flowDeductCard = new HashMap<>(); + + String flowDeductCardSql = "select * from kq_flow_deduct_card t where 1=1 and (isclear is null or isclear<>1) "; + String sqlWhere = sqlFlowCardParamWhere(); + if(sqlWhere.length() > 0){ + flowDeductCardSql += sqlWhere; + } + rs.execute(flowDeductCardSql); + while(rs.next()){ + String requestId= rs.getString("requestId"); + String resourceid= rs.getString("resourceid"); + String signtype= rs.getString("signtype"); + String serialnumber= rs.getString("serialnumber"); + String flowtype= rs.getString("flowtype"); + String key = requestId+"_"+resourceid+"_"+flowtype; + String serial_signtype = serialnumber+"_"+signtype; + if(flowDeductCard.containsKey(key)){ + String tmpSignType = Util.null2String(flowDeductCard.get(key)); + flowDeductCard.put(key, tmpSignType+","+serial_signtype); + }else{ + flowDeductCard.put(key, serial_signtype); + } + } + return flowDeductCard; + } + + /** + * 获取请假相关的数据 + */ + public List getLeaveData(Map flowMaps, + Map flowDeductCard){ + + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + + String tablename = "select a.* from "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 "; + String sqlWhere = sqlParamWhere(); + if(sqlWhere.length() > 0){ + tablename += sqlWhere; + } + String leaveSql = "select * from ("+tablename+") t where 1=1 and (status is null or status <> '1') "; + + if(sqlWhere.length() > 0){ + leaveSql += sqlWhere; + } + List splitBeans = new ArrayList<>(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + + int[] initArrays = kqTimesArrayComInfo.getInitArr(); + + rs.execute(leaveSql); + while(rs.next()){ + SplitBean splitBean = new SplitBean(); + String requestId= rs.getString("requestId"); + String resourceid= rs.getString("resourceid"); + String fromdate= rs.getString("fromdate"); + String belongdate= rs.getString("belongdate"); + String fromtime= rs.getString("fromtime"); + String todate= rs.getString("todate"); + String totime= rs.getString("totime"); + String newleavetype= rs.getString("newleavetype"); + String duration= rs.getString("duration"); + String durationrule= rs.getString("durationrule"); + String leavebackrequestid= Util.null2String(rs.getString("leavebackrequestid")); + + String fromtimedb= rs.getString("fromtimedb"); + String totimedb= rs.getString("totimedb"); + String repeatType = Util.null2String(rs.getString("repeat_type")); + String repeatLate = Util.null2String(rs.getString("repeat_late")); + String repeatEarly = Util.null2String(rs.getString("repeat_early")); + + if(Util.getDoubleValue(duration) <= 0){ + if(repeatType.length() > 0){ + //哺乳假的不需要时长 + }else{ +// continue; + } + } + //计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假 + String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2"; + String card_key = requestId+"_"+resourceid+"_"+KqSplitFlowTypeEnum.LEAVE.getFlowtype(); + String serial_signtype = ""; + String serial = ""; + String signtype = ""; + if(!flowDeductCard.isEmpty() && flowDeductCard.containsKey(card_key)){ + serial_signtype = Util.null2String(flowDeductCard.get(card_key)); + if(serial_signtype.split("_") != null && serial_signtype.split("_").length == 2){ + serial = serial_signtype.split("_")[0]; + signtype = serial_signtype.split("_")[1]; + } + } + + Map infoMap = new HashMap<>(); + infoMap.put("requestId", requestId); + infoMap.put(newleavetype, duration); + infoMap.put("begintime", fromtime); + infoMap.put("endtime", totime); + infoMap.put("unitType", unitType); + infoMap.put("durationrule", durationrule); + if("2".equals(durationrule) && Util.getDoubleValue(duration)<1){ + infoMap.put("ishalf", "true"); + }else{ + infoMap.put("ishalf", "false"); + } + infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType()); + infoMap.put("newleavetype", newleavetype); + infoMap.put("signtype", signtype); + infoMap.put("serial", serial); + infoMap.put("fromtimedb", fromtimedb); + infoMap.put("totimedb", totimedb); + infoMap.put("repeatType", repeatType); + infoMap.put("repeatLate", repeatLate); + infoMap.put("repeatEarly", repeatEarly); + + String key = resourceid+"|"+belongdate; + String keyRepeat = resourceid+"|"+belongdate+"|repeat"; + if(flowMaps != null){ + if(flowMaps.get(key) != null){ + if(leavebackrequestid.length() > 0 && leavebackrequestid.startsWith(",")){ + initArrays = kqTimesArrayComInfo.getInitArr(); + int fromTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime); + int toTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(totime); + Arrays.fill(initArrays, fromTimeIndex, toTimeIndex+1, 1); + leavebackrequestid = leavebackrequestid.substring(1); + String backSql = "select * from "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" where "+Util.getSubINClause(leavebackrequestid, "requestid", "in")+" and fromdate= '"+fromdate+"'"; + rs1.executeQuery(backSql); + + while (rs1.next()){ + String back_fromtime = rs1.getString("fromtime"); + String back_totime = rs1.getString("totime"); + if(repeatType.length() > 0){ + //如果是哺乳假似的重复校验,不需要考虑时间 + back_fromtime = fromtime; + back_totime = totime; + } + String back_duration= rs.getString("duration"); + if(Util.getDoubleValue(back_duration) <= 0){ +// continue; + } + if(back_fromtime.equalsIgnoreCase(fromtime)){ + Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime), kqTimesArrayComInfo.getArrayindexByTimes(back_totime)+1, -1); + }else{ + Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime)+1, kqTimesArrayComInfo.getArrayindexByTimes(back_totime)+1, -1); + } + } + List> backLists = new ArrayList<>(); + List backList = new ArrayList<>(); + for(int i = fromTimeIndex ; i <= toTimeIndex ; i ++){ + if(initArrays[i] == 1){ + backList.add(kqTimesArrayComInfo.getTimesByArrayindex(i)); + }else{ + if(!backList.isEmpty()){ + backLists.add(backList); + backList = new ArrayList<>(); + }else{ + continue; + } + } + } + if(!backList.isEmpty()){ + backLists.add(backList); + } + if(backLists != null && !backLists.isEmpty()){ + List> time_list_tmp = (List>)flowMaps.get(key); + for(int j = 0 ; j < backLists.size() ;j++){ + List backListTmp = backLists.get(j); + String back_tmp_fromtime = backListTmp.get(0); + String back_tmp_totime = backListTmp.get(backListTmp.size()-1); + infoMap = new HashMap<>(); + infoMap.put("requestId", requestId); + infoMap.put(newleavetype, duration); + infoMap.put("begintime", back_tmp_fromtime); + infoMap.put("endtime", back_tmp_totime); + infoMap.put("unitType", unitType); + infoMap.put("durationrule", durationrule); + if("2".equals(durationrule)){ + infoMap.put("ishalf", "true"); + } + infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType()); + infoMap.put("newleavetype", newleavetype); + infoMap.put("repeatType", repeatType); + infoMap.put("repeatLate", repeatLate); + infoMap.put("repeatEarly", repeatEarly); + time_list_tmp.add(infoMap); + } + if(repeatType.length() > 0) { + if (flowMaps.containsKey(keyRepeat)) { + List> time_list_tmp1 = (List>)flowMaps.get(keyRepeat); + time_list_tmp1.add(infoMap); + } + } + } + }else{ + List> time_list_tmp = (List>)flowMaps.get(key); + time_list_tmp.add(infoMap); + } + }else{ + if(leavebackrequestid.length() > 0 && leavebackrequestid.startsWith(",")){ + initArrays = kqTimesArrayComInfo.getInitArr(); + int fromTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime); + int toTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(totime); + Arrays.fill(initArrays, fromTimeIndex, toTimeIndex+1, 1); + leavebackrequestid = leavebackrequestid.substring(1); + String backSql = "select * from "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" where "+Util.getSubINClause(leavebackrequestid, "requestid", "in")+" and fromdate= '"+fromdate+"'"; + rs1.executeQuery(backSql); + + while (rs1.next()){ + String back_fromtime = rs1.getString("fromtime"); + String back_totime = rs1.getString("totime"); + if(repeatType.length() > 0){ + //如果是哺乳假似的重复校验,不需要考虑时间 + back_fromtime = fromtime; + back_totime = totime; + } + if(back_fromtime.equalsIgnoreCase(fromtime)){ + Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime), kqTimesArrayComInfo.getArrayindexByTimes(back_totime)+1, -1); + }else{ + if(back_fromtime.compareTo(back_totime) < 0){ + Arrays.fill(initArrays, kqTimesArrayComInfo.getArrayindexByTimes(back_fromtime)+1, kqTimesArrayComInfo.getArrayindexByTimes(back_totime)+1, -1); + } + } + } + List> backLists = new ArrayList<>(); + List backList = new ArrayList<>(); + for(int i = fromTimeIndex ; i <= toTimeIndex ; i ++){ + if(initArrays[i] == 1){ + backList.add(kqTimesArrayComInfo.getTimesByArrayindex(i)); + }else{ + if(!backList.isEmpty()){ + backLists.add(backList); + backList = new ArrayList<>(); + }else{ + continue; + } + } + } + if(!backList.isEmpty()){ + backLists.add(backList); + } + if(backLists != null && !backLists.isEmpty()){ + List> time_list = new ArrayList<>(); + for(int j = 0 ; j < backLists.size() ;j++){ + List backListTmp = backLists.get(j); + String back_tmp_fromtime = backListTmp.get(0); + String back_tmp_totime = backListTmp.get(backListTmp.size()-1); + infoMap = new HashMap<>(); + infoMap.put("requestId", requestId); + infoMap.put(newleavetype, duration); + infoMap.put("begintime", back_tmp_fromtime); + infoMap.put("endtime", back_tmp_totime); + infoMap.put("unitType", unitType); + infoMap.put("durationrule", durationrule); + if("2".equals(durationrule)){ + infoMap.put("ishalf", "true"); + } + infoMap.put("flowtype", FlowReportTypeEnum.LEAVE.getFlowType()); + infoMap.put("newleavetype", newleavetype); + infoMap.put("repeatType", repeatType); + infoMap.put("repeatLate", repeatLate); + infoMap.put("repeatEarly", repeatEarly); + time_list.add(infoMap); + } + flowMaps.put(key, time_list); + if(repeatType.length() > 0){ + //单独存一份哺乳假的重复校验 + flowMaps.put(keyRepeat, time_list); + } + } + }else{ + List> time_list = new ArrayList<>(); + time_list.add(infoMap); + flowMaps.put(key, time_list); + if(repeatType.length() > 0){ + //单独存一份哺乳假的重复校验 + flowMaps.put(keyRepeat, time_list); + } + } + } + } + + } + return splitBeans; + } + + /** + * 获取出差相关的数据 + */ + public List getEvectionData(Map flowMaps, + Map flowDeductCard){ + + RecordSet rs = new RecordSet(); + String tablename = "select a.* from "+KqSplitFlowTypeEnum.EVECTION.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 "; + String sqlWhere = sqlParamWhere(); + if(sqlWhere.length() > 0){ + tablename += sqlWhere; + } + String leaveSql = "select * from ("+tablename+") t where 1=1 and (status is null or status <> '1') "; + + if(sqlWhere.length() > 0){ + leaveSql += sqlWhere; + } + + List splitBeans = new ArrayList<>(); + rs.execute(leaveSql); + while(rs.next()){ + SplitBean splitBean = new SplitBean(); + String requestId= rs.getString("requestId"); + String resourceid= rs.getString("resourceid"); + String fromdate= rs.getString("fromdate"); + String belongdate= rs.getString("belongdate"); + String fromtime= rs.getString("fromtime"); + String todate= rs.getString("todate"); + String totime= rs.getString("totime"); + String newleavetype= rs.getString("newleavetype"); + String duration= rs.getString("duration"); + String durationrule= rs.getString("durationrule"); + + splitBean.setRequestId(requestId); + splitBean.setResourceId(resourceid); + splitBean.setFromDate(fromdate); + splitBean.setFromTime(fromtime); + splitBean.setToDate(todate); + splitBean.setToTime(totime); + splitBean.setNewLeaveType(newleavetype); + splitBean.setDuration(duration); + splitBean.setDurationrule(durationrule); + splitBeans.add(splitBean); + + if(Util.getDoubleValue(duration) <= 0){ +// continue; + } + //计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假 + String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2"; + String card_key = requestId+"_"+resourceid+"_"+KqSplitFlowTypeEnum.EVECTION.getFlowtype(); + String serial_signtype = ""; + String serial = ""; + String signtype = ""; + if(!flowDeductCard.isEmpty() && flowDeductCard.containsKey(card_key)){ + serial_signtype = Util.null2String(flowDeductCard.get(card_key)); + if(serial_signtype.split("_") != null && serial_signtype.split("_").length == 2){ + serial = serial_signtype.split("_")[0]; + signtype = serial_signtype.split("_")[1]; + } + } + + Map infoMap = new HashMap<>(); + infoMap.put(FlowReportTypeEnum.businessLeave.getFlowType(), duration); + infoMap.put("requestId", requestId); + infoMap.put("begintime", fromtime); + infoMap.put("endtime", totime); + infoMap.put("unitType", unitType); + infoMap.put("durationrule", durationrule); + if("2".equals(durationrule) && Util.getDoubleValue(duration)<1){ + infoMap.put("ishalf", "true"); + }else{ + infoMap.put("ishalf", "false"); + } + infoMap.put("duration", duration); + infoMap.put("flowtype", FlowReportTypeEnum.EVECTION.getFlowType()); + infoMap.put("signtype", signtype); + infoMap.put("serial", serial); + + String key = resourceid+"|"+belongdate; + if(flowMaps != null){ + if(flowMaps.get(key) != null){ + List> time_list_tmp = (List>)flowMaps.get(key); + time_list_tmp.add(infoMap); + }else{ + List> time_list = new ArrayList<>(); + time_list.add(infoMap); + flowMaps.put(key, time_list); + } + } + + } + return splitBeans; + } + + /** + * 获取公出相关的数据 + */ + public List getOutData(Map flowMaps, + Map flowDeductCard){ + + RecordSet rs = new RecordSet(); + String tablename = "select a.* from "+KqSplitFlowTypeEnum.OUT.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 "; + String sqlWhere = sqlParamWhere(); + if(sqlWhere.length() > 0){ + tablename += sqlWhere; + } + String leaveSql = "select * from ("+tablename+") t where 1=1 and (status is null or status <> '1') "; + + if(sqlWhere.length() > 0){ + leaveSql += sqlWhere; + } + List splitBeans = new ArrayList<>(); + rs.execute(leaveSql); + while(rs.next()){ + SplitBean splitBean = new SplitBean(); + String requestId= rs.getString("requestId"); + String resourceid= rs.getString("resourceid"); + String fromdate= rs.getString("fromdate"); + String belongdate= rs.getString("belongdate"); + String fromtime= rs.getString("fromtime"); + String todate= rs.getString("todate"); + String totime= rs.getString("totime"); + String newleavetype= rs.getString("newleavetype"); + String duration= rs.getString("duration"); + String durationrule= rs.getString("durationrule"); + + splitBean.setRequestId(requestId); + splitBean.setResourceId(resourceid); + splitBean.setFromDate(fromdate); + splitBean.setFromTime(fromtime); + splitBean.setToDate(todate); + splitBean.setToTime(totime); + splitBean.setNewLeaveType(newleavetype); + splitBean.setDuration(duration); + splitBean.setDurationrule(durationrule); + splitBeans.add(splitBean); + + if(Util.getDoubleValue(duration) <= 0){ +// continue; + } + //计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假 + String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2"; + String card_key = requestId+"_"+resourceid+"_"+KqSplitFlowTypeEnum.OUT.getFlowtype(); + String serial_signtype = ""; + String serial = ""; + String signtype = ""; + if(!flowDeductCard.isEmpty() && flowDeductCard.containsKey(card_key)){ + serial_signtype = Util.null2String(flowDeductCard.get(card_key)); + if(serial_signtype.split("_") != null && serial_signtype.split("_").length == 2){ + serial = serial_signtype.split("_")[0]; + signtype = serial_signtype.split("_")[1]; + } + } + + Map infoMap = new HashMap<>(); + infoMap.put(FlowReportTypeEnum.officialBusiness.getFlowType(), duration); + infoMap.put("requestId", requestId); + infoMap.put("begintime", fromtime); + infoMap.put("endtime", totime); + infoMap.put("unitType", unitType); + infoMap.put("durationrule", durationrule); + if("2".equals(durationrule) && Util.getDoubleValue(duration)<1){ + infoMap.put("ishalf", "true"); + }else{ + infoMap.put("ishalf", "false"); + } + infoMap.put("duration", duration); + infoMap.put("flowtype", FlowReportTypeEnum.OUT.getFlowType()); + infoMap.put("signtype", signtype); + infoMap.put("serial", serial); + + String key = resourceid+"|"+belongdate; + if(flowMaps != null){ + if(flowMaps.get(key) != null){ + List> time_list_tmp = (List>)flowMaps.get(key); + time_list_tmp.add(infoMap); + }else{ + List> time_list = new ArrayList<>(); + time_list.add(infoMap); + flowMaps.put(key, time_list); + } + } + + } + return splitBeans; + } + + /** + * 获取加班相关的数据 + */ + public List getOverTimeData(Map flowMaps){ + + RecordSet rs = new RecordSet(); + String tablename = "select a.* from "+KqSplitFlowTypeEnum.OVERTIME.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 "; + String sqlWhere = sqlParamWhere(); + if(sqlWhere.length() > 0){ + tablename += sqlWhere; + } + String leaveSql = "select * from ("+tablename+") t where 1=1 "; + + if(sqlWhere.length() > 0){ + leaveSql += sqlWhere; + } + List splitBeans = new ArrayList<>(); + if(orderby_sql.length() > 0){ + leaveSql = leaveSql+orderby_sql; + } + rs.execute(leaveSql); + while(rs.next()){ + SplitBean splitBean = new SplitBean(); + String dataid= rs.getString("dataid"); + String detailid= rs.getString("detailid"); + String requestId= rs.getString("requestId"); + String resourceid= rs.getString("resourceid"); + String fromdate= rs.getString("fromdate"); + String belongdate= rs.getString("belongdate"); + String fromtime= rs.getString("fromtime"); + String todate= rs.getString("todate"); + String totime= rs.getString("totime"); + String newleavetype= rs.getString("newleavetype"); + String duration= rs.getString("duration"); + String durationrule= rs.getString("durationrule"); + String changetype= rs.getString("changetype"); + String d_mins= rs.getString("d_mins"); + String overtime_type= rs.getString("overtime_type"); + + String fromdatedb= rs.getString("fromdatedb"); + String fromtimedb= rs.getString("fromtimedb"); + String todatedb= rs.getString("todatedb"); + String totimedb= rs.getString("totimedb"); + + splitBean.setDataId(dataid); + splitBean.setDetailId(detailid); + splitBean.setRequestId(requestId); + splitBean.setResourceId(resourceid); + splitBean.setFromDate(fromdate); + splitBean.setFromTime(fromtime); + splitBean.setToDate(todate); + splitBean.setToTime(totime); + splitBean.setNewLeaveType(newleavetype); + splitBean.setDuration(duration); + splitBean.setDurationrule(durationrule); + splitBean.setChangeType(Util.getIntValue(changetype)); + splitBean.setD_Mins(Util.getDoubleValue(d_mins)); + splitBean.setOvertime_type(overtime_type); + splitBean.setFromdatedb(fromdatedb); + splitBean.setFromtimedb(fromtimedb); + splitBean.setTodatedb(todatedb); + splitBean.setTotimedb(totimedb); + splitBeans.add(splitBean); + + //计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假 + String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2"; + unitType = "2".equalsIgnoreCase(durationrule)?"1":"2"; + + Map infoMap = new HashMap<>(); + infoMap.put(FlowReportTypeEnum.businessLeave.getFlowType(), duration); + infoMap.put("begintime", fromtime); + infoMap.put("endtime", totime); + infoMap.put("unitType", unitType); + infoMap.put("duration", duration); + infoMap.put("flowtype", FlowReportTypeEnum.OVERTIME.getFlowType()); + + String key = resourceid+"|"+belongdate; + if(flowMaps != null){ + if(flowMaps.get(key) != null){ + List> time_list_tmp = (List>)flowMaps.get(key); + time_list_tmp.add(infoMap); + }else{ + List> time_list = new ArrayList<>(); + time_list.add(infoMap); + flowMaps.put(key, time_list); + } + } + } + return splitBeans; + } + + /** + * 获取异常流程的数据 + */ + public List getOtherData(Map flowMaps){ + + RecordSet rs = new RecordSet(); + String tablename = "select a.* from "+KqSplitFlowTypeEnum.OTHER.getTablename()+" a left join workflow_requestbase b on a.requestid = b.requestid where b.requestid > 0 "; + String sqlWhere = sqlParamWhere(); + if(sqlWhere.length() > 0){ + tablename += sqlWhere; + } + String leaveSql = "select * from ("+tablename+") t where 1=1 "; + + if(sqlWhere.length() > 0){ + leaveSql += sqlWhere; + } + List splitBeans = new ArrayList<>(); + rs.execute(leaveSql); + while(rs.next()){ + SplitBean splitBean = new SplitBean(); + String requestId= rs.getString("requestId"); + String resourceid= rs.getString("resourceid"); + String fromdate= rs.getString("fromdate"); + String belongdate= rs.getString("belongdate"); + String fromtime= rs.getString("fromtime"); + String todate= rs.getString("todate"); + String totime= rs.getString("totime"); + String newleavetype= rs.getString("newleavetype"); + String duration= rs.getString("duration"); + String durationrule= rs.getString("durationrule"); + + splitBean.setRequestId(requestId); + splitBean.setResourceId(resourceid); + splitBean.setFromDate(fromdate); + splitBean.setFromTime(fromtime); + splitBean.setToDate(todate); + splitBean.setToTime(totime); + splitBean.setNewLeaveType(newleavetype); + splitBean.setDuration(duration); + splitBean.setDurationrule(durationrule); + splitBeans.add(splitBean); + + //计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假 + String unitType = "4".equalsIgnoreCase(durationrule)?"1":"2"; + + Map infoMap = new HashMap<>(); + infoMap.put(FlowReportTypeEnum.businessLeave.getFlowType(), duration); + infoMap.put("begintime", fromtime); + infoMap.put("endtime", totime); + infoMap.put("unitType", unitType); + + String key = resourceid+"|"+belongdate; + if(flowMaps != null){ + if(flowMaps.get(key) != null){ + List> time_list_tmp = (List>)flowMaps.get(key); + time_list_tmp.add(infoMap); + }else{ + List> time_list = new ArrayList<>(); + time_list.add(infoMap); + flowMaps.put(key, time_list); + } + } + } + return splitBeans; + } + + /** + * 根据请假类型判断是否被流程引用 + * @param ruleid + * @return true表示被引用 + */ + public static boolean leaveTypeUsed(String ruleid){ + KQFlowDataBiz kqFlowDataBiz = new KQFlowDataBiz.FlowDataParamBuilder().newLeaveTypeParam(ruleid).build(); + List splitBeans = kqFlowDataBiz.getLeaveData(null, new HashMap<>()); + if(!splitBeans.isEmpty()){ + return true; + }else{ + return false; + } + } + + /** + * 生成相应的查询条件 + * @return + */ + private String sqlParamWhere() { + String sqlWhere = ""; + if(resourceid.length() > 0){ + sqlWhere += " and resourceid in ( "+resourceid+" )"; + } + if(fromDate.length() > 0 && toDate.length() > 0){ + sqlWhere += " and ( fromdate between '"+fromDate+"' and '"+toDate+"' or todate between '"+fromDate+"' and '"+toDate+"' )"; + }else{ + if(fromDate.length() > 0){ + sqlWhere += " and fromdate between '"+fromDate+"' and '"+fromDate+"' "; + } + if(toDate.length() > 0){ + sqlWhere += " and todate between '"+toDate+"' and '"+toDate+"' "; + } + } + if(belongDate.length() > 0){ + sqlWhere += " and belongdate = '"+belongDate+"' "; + } + if(fromTime.length() > 0){ + sqlWhere += " and fromtime >= '"+fromTime+"' "; + } + if(toTime.length() > 0){ + sqlWhere += " and totime <= '"+toTime+"' "; + } + if(newLeaveType.length() > 0){ + sqlWhere += " and newleavetype in ( "+newLeaveType+" )"; + } + return sqlWhere; + } + + private String sqlFlowCardParamWhere() { + String sqlWhere = ""; + if(resourceid.length() > 0){ + sqlWhere += " and resourceid in ( "+resourceid+" )"; + } + if(fromDate.length() > 0 && toDate.length() > 0){ + sqlWhere += " and ( fromdate between '"+fromDate+"' and '"+toDate+"' or todate between '"+fromDate+"' and '"+toDate+"' )"; + }else{ + if(fromDate.length() > 0){ + sqlWhere += " and fromdate between '"+fromDate+"' and '"+fromDate+"' "; + } + if(toDate.length() > 0){ + sqlWhere += " and todate between '"+toDate+"' and '"+toDate+"' "; + } + } + if(belongDate.length() > 0){ + sqlWhere += " and belongdate = '"+belongDate+"' "; + } + if(fromTime.length() > 0){ + sqlWhere += " and fromtime >= '"+fromTime+"' "; + } + if(toTime.length() > 0){ + sqlWhere += " and totime <= '"+toTime+"' "; + } + return sqlWhere; + } + + /** + * 针对可能存在的多种参数类型 创建参数静态内部类Builder + */ + public static class FlowDataParamBuilder { + + private String resourceid = ""; + private String fromDate = ""; + private String toDate = ""; + private String fromTime = ""; + private String toTime = ""; + private String belongDate = ""; + /** + * 请假用的请假类型 + */ + private String newLeaveType = ""; + private String orderby_sql = ""; + + public FlowDataParamBuilder() { + this.resourceid = ""; + //初始化的时候需要把其他参数先清空下 + this.fromDate = ""; + this.toDate = ""; + this.fromTime = ""; + this.toTime = ""; + this.newLeaveType = ""; + this.belongDate = ""; + this.orderby_sql = ""; + } + + //成员方法返回其自身,所以可以链式调用 + public KQFlowDataBiz.FlowDataParamBuilder resourceidParam(final String resourceid) { + this.resourceid = resourceid; + return this; + } + + public KQFlowDataBiz.FlowDataParamBuilder fromDateParam(final String fromDate) { + this.fromDate = fromDate; + return this; + } + + public KQFlowDataBiz.FlowDataParamBuilder toDateParam(final String toDate) { + this.toDate = toDate; + return this; + } + + public KQFlowDataBiz.FlowDataParamBuilder fromTimeParam(final String fromTime) { + this.fromTime = fromTime; + return this; + } + + public KQFlowDataBiz.FlowDataParamBuilder toTimeParam(final String toTime) { + this.toTime = toTime; + return this; + } + + public KQFlowDataBiz.FlowDataParamBuilder newLeaveTypeParam(final String newLeaveType) { + this.newLeaveType = newLeaveType; + return this; + } + + public KQFlowDataBiz.FlowDataParamBuilder belongDateParam(final String belongDate) { + this.belongDate = belongDate; + return this; + } + + public KQFlowDataBiz.FlowDataParamBuilder orderby_sqlParam(final String orderby_sql) { + this.orderby_sql = orderby_sql; + return this; + } + + //Builder的build方法,返回外部类的实例 + public KQFlowDataBiz build() { + return new KQFlowDataBiz(this); + } + } +} diff --git a/src/com/engine/kq/biz/KQFormat4ReportJob.java b/src/com/engine/kq/biz/KQFormat4ReportJob.java new file mode 100644 index 0000000..3644055 --- /dev/null +++ b/src/com/engine/kq/biz/KQFormat4ReportJob.java @@ -0,0 +1,20 @@ +package com.engine.kq.biz; + +import weaver.common.DateUtil; +import weaver.general.BaseBean; +import weaver.interfaces.schedule.BaseCronJob; + +public class KQFormat4ReportJob extends BaseCronJob{ + public void execute() { + BaseBean bb = new BaseBean(); + try{ + bb.writeLog("begin do KQFormat4ReportJob invoke ..."); + String date = DateUtil.getCurrentDate(); + //初始化今天数据 + new KQFormatBiz().formatDateByKQDate(date); + bb.writeLog("end do KQFormat4ReportJob invoke ..."); + }catch (Exception e) { + bb.writeLog(e); + } + } +} diff --git a/src/com/engine/kq/biz/KQFormatBiz.java b/src/com/engine/kq/biz/KQFormatBiz.java new file mode 100644 index 0000000..00785f3 --- /dev/null +++ b/src/com/engine/kq/biz/KQFormatBiz.java @@ -0,0 +1,371 @@ +package com.engine.kq.biz; + +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import weaver.common.DateUtil; +import weaver.conn.BatchRecordSet; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 考勤数据格式化 + */ +public class KQFormatBiz extends BaseBean { + private String today = DateUtil.getCurrentDate(); + protected KQLog kqLog = new KQLog(); + + /** + * 考勤报表格式化-带批次 + * + * @param lsFormatParams + */ + public void formatWithBatchId(List> lsFormatParams) { + BatchRecordSet bRs = new BatchRecordSet(); + String sql = ""; + List params = null; + try { + if (KQSettingsBiz.getKqformatthread()) { + sql = " insert into kq_format_pool (resourceid, kqdate,batchid) values (?,?,?)"; + if (KQSettingsBiz.getKqformatAccurate()){ + sql = " insert into kq_format_pool (resourceid, kqdate, exectime,batchid) values (?,?,?,?)"; + lsFormatParams = processFormatParams(lsFormatParams); + } + bRs.executeBatchSql(sql, lsFormatParams); + } else { + String resourceid = ""; + String kqdate = ""; + for (int i = 0; lsFormatParams != null && i < lsFormatParams.size(); i++) { + params = lsFormatParams.get(i); + resourceid = Util.null2String(params.get(0)); + kqdate = Util.null2String(params.get(1)); + new KQFormatData().formatKqDate(resourceid, kqdate); + } + } + } catch (Exception e) { + writeLog(" KQFormatData.formatKqDate lsFormatParams >>>>>>>>>" + e); + } + } + + /** + * 考勤报表格式化 + * + * @param lsFormatParams + */ + public void format(List> lsFormatParams) { + format(lsFormatParams, -1); + } + + /** + * 考勤报表格式化 + * @param lsFormatParams + * @param formatType -1: 其他; 11:右键重新计算考勤数据; 12: 考勤自动和手动同步;13:钉钉同步或者导入; 14:云桥考勤同步 15: 考勤导入;16:排班更新 + */ + public void format(List> lsFormatParams, int formatType) { + BatchRecordSet bRs = new BatchRecordSet(); + String sql = ""; + List params = null; + try { + for(List list : lsFormatParams) { + list.add(formatType); + } + if (KQSettingsBiz.getKqformatthread()) { + sql = " insert into kq_format_pool (resourceid, kqdate, formattype) values (?,?,?)"; + if (KQSettingsBiz.getKqformatAccurate()){ + sql = " insert into kq_format_pool (resourceid, kqdate, exectime,formattype) values (?,?,?,?)"; + lsFormatParams = processFormatParams(lsFormatParams); + } + bRs.executeBatchSqlNew(sql, lsFormatParams); + } else { + String resourceid = ""; + String kqdate = ""; + for (int i = 0; lsFormatParams != null && i < lsFormatParams.size(); i++) { + params = lsFormatParams.get(i); + resourceid = Util.null2String(params.get(0)); + kqdate = Util.null2String(params.get(1)); + new KQFormatData().formatKqDateByLock(resourceid, kqdate,formatType); + } + } + } catch (Exception e) { + writeLog(" KQFormatData.formatKqDate lsFormatParams >>>>>>>>>" + e); + } + } + + public void formatDateByKQDate(String kqdate) { + String sql = ""; + RecordSet rs = new RecordSet(); + List> lsFormatParams = new ArrayList<>(); + List formatParams = null; + try { + if (DateUtil.timeInterval(kqdate, today) < 0) { + kqLog.info("今天之后的无需处理的数据:kqdate==" + kqdate + "today==" + today); + return;//今天之后的无需处理 + } + + sql = " SELECT distinct resourceid FROM ( " + + new KQGroupBiz().getGroupMemberSql() + ") t "; + rs.executeQuery(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + if(Util.null2String(kqdate).length()!=10)return; + formatParams = new ArrayList<>(); + formatParams.add(resourceid); + formatParams.add(kqdate); + lsFormatParams.add(formatParams); + } + this.format(lsFormatParams); + } catch (Exception e) { + writeLog(e); + kqLog.info(e); + } + } + + public void formatDateByGroupId(String groupid, String kqdate) { + String sql = ""; + RecordSet rs = new RecordSet(); + List> lsFormatParams = new ArrayList<>(); + List formatParams = null; + try { + if (DateUtil.timeInterval(kqdate, today) < 0) { + kqLog.info("今天之后的无需处理的数据:groupid==" + groupid + "kqdate==" + kqdate + "today==" + today); + return;//今天之后的无需处理 + } + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + String kqtype = kqGroupComInfo.getKqtype(groupid); + if (kqtype.equals("2")) {//排班 + sql = "select resourceid, kqdate from kq_shiftschedule where groupid=" + groupid + " and kqdate='" + kqdate + "' and (isdelete is null or isdelete <> '1') "; + } else { + sql = "select resourceid,'" + kqdate + "' from (" + kqGroupBiz.getGroupMemberSql(groupid) + ") t "; + } + rs.executeQuery(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + if(Util.null2String(kqdate).length()!=10)return; + formatParams = new ArrayList<>(); + formatParams.add(resourceid); + formatParams.add(kqdate); + lsFormatParams.add(formatParams); + } + this.format(lsFormatParams); + } catch (Exception e) { + writeLog(e); + kqLog.info(e); + } + } + + public void formatDate(String resourceid, String kqdate) { + List> lsFormatParams = new ArrayList<>(); + List formatParams = null; + try { + if (DateUtil.timeInterval(kqdate, today) < 0) { + kqLog.info("今天之后的无需处理的数据:resourceid==" + resourceid + "kqdate==" + kqdate + "today==" + today); + return;//今天之后的无需处理 + } + if(Util.null2String(kqdate).length()!=10)return; + formatParams = new ArrayList<>(); + formatParams.add(resourceid); + formatParams.add(kqdate); + lsFormatParams.add(formatParams); + this.format(lsFormatParams); + } catch (Exception e) { + writeLog(e); + kqLog.info(e); + } + } + + public void delFormatData(String resourceid, String kqdate) { + RecordSet rs = new RecordSet(); + String sql = ""; + try { + sql = " delete from kq_format_detail where resourceid =? and kqdate = ? ";//删除非工作日数据 + rs.executeUpdate(sql, resourceid, kqdate); + + sql = " delete from kq_format_total where resourceid =? and kqdate = ? ";//删除非工作日数据 + rs.executeUpdate(sql, resourceid, kqdate); + } catch (Exception e) { + writeLog(e); + kqLog.info(e); + } + } + + public void clearFormatPool() { + RecordSet rs = new RecordSet(); + String sql = ""; + try { + //删除三天前的数据格式化数据 + if (rs.getDBType().equals("sqlserver")) { + sql = " delete from kq_format_pool where status = 1 and datediff(day,created,getdate()) > 1"; + } else if (rs.getDBType().equals("mysql")) { + sql = " delete from kq_format_pool where status = 1 and datediff(now(),created) > 1"; + } + else if (rs.getDBType().equals("postgresql")) { + sql = " delete from kq_format_pool where status = 1 and datediff(now(),created) > 1"; + } + else if (rs.getOrgindbtype().equals("st")) { + sql = " delete from kq_format_pool where status = 1 and to_number(trunc(sysdate) - trunc(created)) > 1"; + } else { + sql = " delete from kq_format_pool where status = 1 and trunc(sysdate) - trunc(created) > 1"; + } + rs.executeUpdate(sql); + } catch (Exception e) { + writeLog(e); + } + } + + public Map getDefinedField(){ + Map retMap = new HashMap<>(); + String definedField = ""; + String definedFieldSum = ""; + String definedParam = ""; + String definedParamSum = ""; + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()) { + if (!Util.null2String(kqReportFieldComInfo.getIsenable()).equals("1")) continue; + if (Util.null2String(kqReportFieldComInfo.getIsSystem()).equals("1")) continue; + if(KQReportFieldComInfo.cascadekey2fieldname.keySet().contains(kqReportFieldComInfo.getFieldname()))continue; + + if(definedField.length()>0)definedField+=","; + definedField+=kqReportFieldComInfo.getFieldname(); + + if(definedFieldSum.length()>0)definedFieldSum+=","; + definedFieldSum+="sum("+kqReportFieldComInfo.getFieldname()+") as "+kqReportFieldComInfo.getFieldname(); + + if(definedParam.length()>0)definedParam+=","; + definedParam+="?"; + + if(definedParamSum.length()>0)definedParamSum+=","; + definedParamSum+="sum("+kqReportFieldComInfo.getFieldname()+")"; + + String[] cascadekeys = Util.splitString(Util.null2String(kqReportFieldComInfo.getCascadekey()),","); + for(int i=0;cascadekeys!=null&&i0)definedField+=","; + definedField+=fieldname; + + if(definedFieldSum.length()>0)definedFieldSum+=","; + definedFieldSum+="sum("+fieldname+") as "+fieldname; + + if(definedParam.length()>0)definedParam+=","; + definedParam+="?"; + + if(definedParamSum.length()>0)definedParamSum+=","; + definedParamSum+="sum("+fieldname+")"; + } + } + retMap.put("definedField",definedField); + retMap.put("definedFieldSum",definedFieldSum); + retMap.put("definedParam",definedParam); + retMap.put("definedParamSum",definedParamSum); + return retMap; + } + + public boolean needCal(String workDate, String workTime){ + boolean needCalForgotCheckMins = true; + if (KQSettingsBiz.getKqformatAccurate()) { + workTime = new KQTimesArrayComInfo().turn48to24Time(workTime); + if (workDate.length() > 0 && workTime.length() > 0) { + String currentFullTime = DateUtil.getFullDate(); + String endTime = workDate + " " + workTime; + if (DateUtil.timeInterval(currentFullTime, endTime) > 0) { + //当前时间之后的状态无效计算 + needCalForgotCheckMins = false; + } + kqLog.writeLog("currentFullTime:"+currentFullTime+"wroktime:"+endTime+"needCalForgotCheckMins:"+needCalForgotCheckMins); + } + } + return needCalForgotCheckMins; + } + + public boolean needCal(String workDate, String workTime,String isneedcal){ + boolean needCalForgotCheckMins = true; + boolean isneedformat = "1".equals(isneedcal); + if (isneedformat) { + workTime = new KQTimesArrayComInfo().turn48to24Time(workTime); + if (workDate.length() > 0 && workTime.length() > 0) { + String currentFullTime = DateUtil.getFullDate(); + String endTime = workDate + " " + workTime; + if (DateUtil.timeInterval(currentFullTime, endTime) > 0) { + //当前时间之后的状态无效计算 + needCalForgotCheckMins = false; + } + } + } + return needCalForgotCheckMins; + } + + private List> processFormatParams(List> lsFormatParams) { + List> lsFormatParamsTmp = new ArrayList<>(); + try { + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + KQWorkTime kqWorkTime = new KQWorkTime(); + List formatParams = null; + for(int i=0;i 2) { + formattype = Util.null2String(formatParams.get(2)); + } + + formatParams = new ArrayList<>(); + formatParams.add(resourceId); + formatParams.add(kqDate); + formatParams.add(new java.sql.Timestamp(DateUtil.getCalendar(DateUtil.getFullDate()).getTimeInMillis())); + formatParams.add(formattype); + lsFormatParamsTmp.add(formatParams); + + String nextDate = DateUtil.addDate(kqDate, 1);//下一天日期 + WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceId, kqDate); + List lsWorkTime = new ArrayList<>(); + if (workTime != null) { + lsWorkTime = workTime.getWorkTime();//工作时间 + for (int j = 0; lsWorkTime != null && j < lsWorkTime.size(); j++) { + TimeScopeEntity workTimeScope = lsWorkTime.get(j); + String workBeginDateTime = workTimeScope.getBeginTimeAcross() ? nextDate : kqDate; + workBeginDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(workTimeScope.getBeginTime())+":00:00"; + String workEndDateTime = workTimeScope.getEndTimeAcross() ? nextDate : kqDate; + workEndDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(workTimeScope.getEndTime())+":00:00"; + + formatParams = new ArrayList<>(); + formatParams.add(resourceId); + formatParams.add(kqDate); + formatParams.add(new java.sql.Timestamp(DateUtil.getCalendar(workBeginDateTime).getTimeInMillis())); + formatParams.add(formattype); + lsFormatParamsTmp.add(formatParams); + + formatParams = new ArrayList<>(); + formatParams.add(resourceId); + formatParams.add(kqDate); + formatParams.add(new java.sql.Timestamp(DateUtil.getCalendar(workEndDateTime).getTimeInMillis())); + formatParams.add(formattype); + lsFormatParamsTmp.add(formatParams); + } + }else{ + formatParams = new ArrayList<>(); + formatParams.add(resourceId); + formatParams.add(kqDate); + formatParams.add(formattype); + lsFormatParamsTmp.add(formatParams); + } + } + + }catch (Exception e) { + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + return lsFormatParamsTmp; + } +} diff --git a/src/com/engine/kq/biz/KQFormatData.java b/src/com/engine/kq/biz/KQFormatData.java new file mode 100644 index 0000000..57e6b62 --- /dev/null +++ b/src/com/engine/kq/biz/KQFormatData.java @@ -0,0 +1,1735 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.bean.KQRepeatBean; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.entity.KQShiftRuleEntity; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.jucailin.genid.IdGenerator; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQLockAttendaUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.googlecode.aviator.AviatorEvaluator; +import com.googlecode.aviator.Expression; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.sql.Timestamp; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.BatchRecordSet; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.BaseBean; +import weaver.general.InitServer; +import weaver.general.Util; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 考勤数据格式化 + */ +public class KQFormatData extends BaseBean { + private String today = DateUtil.getCurrentDate(); + private KQLog kqLog = new KQLog(); + private boolean writeLog = false; + private LinkedHashMap logInfo = new LinkedHashMap<>(); + + private static final String LOCK_DEGREE = Util.null2String(Prop.getPropValue("kqLockAttenda", "LOCK_DEGREE")); + + public Map formatKqDateByLock(String userId, String kqDate, int formatType) { + Map resultMap = new HashMap<>(); + + //-1: 其他; 11:右键重新计算考勤数据; 12: 考勤自动和手动同步;13:钉钉同步或者导入; 14:云桥考勤同步 15: 考勤导入;16:排班更新 + //17:考勤流程;18testkq.jsp直接触发的;19:考勤设置升级;20:计划任务执行。 + //①在途的考勤流程可以正常提交归档报表能统计,管理员干预归档的流程报表能统计。 + //②关账不影响考勤导入打卡数据,正常的打卡数据进入报表,导入、同步。 + //③其他操作报表更新控制不生效,比如重新计算考勤,自动计算考勤。 + +// if (LOCK_DEGREE.equals("0")&&new KQLockAttendaUtil().checkLockStatus(userId, kqDate)) { +// kqLog.info("锁定程度强控:人员考勤数据已被锁定,"+"userId:"+userId+":kqDate:"+kqDate+";formatType="+formatType); +// if(formatType==12||formatType==13||formatType==14||formatType==15||formatType==17){ +// return formatKqDate(userId, kqDate); +// } +// return resultMap; +// } + //最新确认逻辑:弱控只控制流程在锁定范围内不能提交,其他都可以重新计算考勤报表。 + return formatKqDate(userId, kqDate); + } + + /*** + * 该方法不允许直接调用 + * @param userId + * @param kqDate + * @return + */ + public Map formatKqDate(String userId, String kqDate) { + //考勤报表增加锁定功能:弱控 + //1、考勤流程控制,请假、出差、公出、补卡、加班、销假、考勤变更新建的流程不能提交,在途的流程可以正常提交归档报表能统计,管理员干预归档的流程报表能统计。 + //2、关账不影响考勤导入打卡数据,正常的打卡数据进入报表。 + //3、强控就是前2点锁定日期后也不能进入报表了 + List> lsParam = new ArrayList<>(); + boolean isKqReportHalfOpen = "1".equals(new KQSettingsComInfo().getMain_val("kq_report_half")); + //非工作日处理 + List nonlsParam = null; + Map resultMap = new HashMap<>(); + BatchRecordSet bRs = new BatchRecordSet(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + kqLog.info("formatKqDate in userId=" + userId + "kqDate==" + kqDate); + if (DateUtil.timeInterval(kqDate, today) < 0) {//今天之后的无需处理 + kqLog.info("今天之后的无需处理的数据:resourceid=="+userId+"kqdate=="+kqDate+"today=="+today); + return resultMap; + } + // 强控 + if (LOCK_DEGREE.equals("1")&&new KQLockAttendaUtil().checkLockStatus(userId, kqDate)) { + kqLog.info("锁定程度强控:人员考勤数据已被锁定,"+"userId:"+userId+":kqDate:"+kqDate); + return resultMap; + } + String uuid = UUID.randomUUID().toString(); + KQFormatFreeData kqFormatFreeData = new KQFormatFreeData(); + KQWorkTime kqWorkTime = new KQWorkTime(); + kqWorkTime.setIsFormat(true); + String kqDateNext = DateUtil.addDate(kqDate, 1); + + KQFlowDataBiz kqFlowDataBiz = new KQFlowDataBiz.FlowDataParamBuilder().resourceidParam(userId).fromDateParam(kqDate).toDateParam(kqDateNext).build(); + Map workFlowInfo = new HashMap<>();//userid|date--工作流程 + kqFlowDataBiz.getAllFlowData(workFlowInfo,false); + WorkTimeEntity workTime = kqWorkTime.getWorkTime(userId, kqDate); + kqLog.info("userId:"+userId+":kqDate:"+kqDate+":formatKqDate workTime=" + JSONObject.toJSONString(workTime)+"::uuid::"+uuid); + kqLog.info("userId:"+userId+":kqDate:"+kqDate+":formatKqDate workFlowInfo=" + JSONObject.toJSONString(workFlowInfo)+"::uuid::"+uuid); + + if(this.writeLog) { + logInfo.put("userId",userId); + logInfo.put("kqDate",kqDate); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(16253,weaver.general.ThreadVarLanguage.getLang())+"",workTime); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(126871,weaver.general.ThreadVarLanguage.getLang())+"",workFlowInfo); + } + + new KQFormatBiz().delFormatData(userId, kqDate); + + String excludecount = Util.null2String(kqGroupComInfo.getExcludecount(workTime.getGroupId()));//是否参与考勤报表统计 + if (workTime.getIsExclude()) {//无需考勤人员没有异常状态 + if(!excludecount.equals("1")){ + kqLog.info("无需考勤人员没有异常状态 workTime.getIsExclude()="+workTime.getIsExclude()+"excludecount=="+excludecount); + return resultMap; + } + } + if( Util.null2String(workTime.getGroupId()).length()==0){ + //没有考勤组不需格式化 + return resultMap; + } + if (workTime == null || (workTime != null && workTime.getWorkMins() == 0 && workTime.getNonWorkShift() != 1)) { + kqLog.info("workTime == null || workTime.getWorkMins() == 0 插入空记录"); + nonlsParam = new ArrayList<>(); + formatNonWork(userId, kqDate,nonlsParam,workTime, workFlowInfo); + + if(!nonlsParam.isEmpty()){ + sql = " insert into kq_format_detail(resourceid,kqdate,groupid,serialnumber,signindate,signintime,signinid,signoutdate,signouttime,signoutid,leaveMins,leaveinfo,evectionMins,outMins,day_type,create_time,update_time,id,flowinfo)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + rs.executeUpdate(sql, nonlsParam); + + Long id = IdGenerator.generate(); + String baseField = ""; + if ("mysql".equalsIgnoreCase(rs.getDBType())){ + baseField = "sysdate(),sysdate(),"+id; + }else if ("oracle".equalsIgnoreCase(rs.getDBType())){ + baseField = "SYSDATE,SYSDATE,"+id; + }else if ("postgresql".equalsIgnoreCase(rs.getDBType())){ + baseField = "now(),now(),"+id; + }else{ + baseField = "GETDATE(),GETDATE(),"+id; + } + sql = " insert into kq_format_total(resourceid,kqdate,subcompanyid,departmentid,jobtitle,groupid,serialid,workdays," + + " workmins,attendancedays,attendancemins,signdays,signmins,belate,belatemins,gravebelate,gravebelatemins,leaveeearly,leaveearlymins," + + " graveleaveearly,graveleaveearlymins,absenteeism,absenteeismmins,forgotcheck, forgotcheckMins,leaveMins,evectionMins,outMins,create_time,update_time,id)" + + " select a.resourceid,kqdate,b.subcompanyid1,b.departmentid,b.jobtitle,groupid,serialid," + + " case when sum(workmins)>0 then 1 end as workdays, sum(workmins) as workmins," + + " 0 as attendancedays, sum(attendanceMins) as attendanceMins," + + " 0 as signdays, sum(signmins) as signmins," + + " sum(case when belatemins> 0 then 1 else 0 end) as belate,sum(belatemins) as belatemins," + + " sum(case when graveBeLateMins> 0 then 1 else 0 end) as graveBeLate,sum(graveBeLateMins) as graveBeLateMins," + + " sum(case when leaveearlymins> 0 then 1 else 0 end) as leaveearly,sum(leaveearlymins) as leaveearlymins," + + " sum(case when graveLeaveEarlyMins> 0 then 1 else 0 end) as graveLeaveEarly,sum(graveLeaveEarlyMins) as graveLeaveEarlyMins,"; +// if(isKqReportHalfOpen) { +// sql+=" sum((on_absenteeismmins+off_absenteeismmins)) as absenteeism,sum(absenteeismmins) as absenteeismmins,"; +// } else { + sql+=" sum(case when absenteeismmins> 0 then 1 else 0 end) as absenteeism,sum(absenteeismmins) as absenteeismmins,"; +// } + sql+=" sum(case when forgotcheckmins> 0 then 1 else 0 end) as forgotcheck,sum(forgotcheckmins) as forgotcheckmins, " + + " sum(leaveMins) as leaveMins, sum(evectionMins) as evectionMins, sum(outMins) as outMins," +baseField+ + " from kq_format_detail a, hrmresource b" + + " where a.resourceid = b.id and resourceid =? and kqdate=?" + + " group by resourceid,kqdate,b.subcompanyid1,b.departmentid,b.jobtitle,groupid,serialid,workmins"; + rs.executeUpdate(sql, userId, kqDate); + } + }else{ + Map definedFieldInfo = new KQFormatBiz().getDefinedField(); + String definedField = ""; + String definedParam = ""; + String definedParamSum = ""; + String convertAttendDay = workTime != null ? Util.null2s(workTime.getConvertAttendDay(),"1.0") : "1.0"; + if (workTime.getKQType().equals("3")) {//自由工时 + lsParam.addAll(kqFormatFreeData.format(userId, kqDate, workFlowInfo)); + } else { + definedField = Util.null2String(definedFieldInfo.get("definedField")); + definedParam = Util.null2String(definedFieldInfo.get("definedParam")); + definedParamSum = Util.null2String(definedFieldInfo.get("definedParamSum")); + lsParam.addAll(format(userId, kqDate, workTime, workFlowInfo,uuid)); + } + + if (lsParam.size() > 0) { + if (rs.getDBType().equals("postgresql")) { + sql = " insert into kq_format_detail( " + + " resourceid,kqdate,groupid,serialid,serialnumber,workbegindate,workbegintime,workenddate,workendtime,workmins," + + " signindate,signintime,signinid,signoutdate,signouttime,signoutid,signMins," + + " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins," + + " leaveMins,leaveinfo,evectionMins,outMins,forgotbeginworkcheckmins,otherinfo"+(definedField.length()>0?","+definedField+"":"")+",day_type,create_time,update_time,id,flowinfo,on_absenteeismmins,off_absenteeismmins) " + + " values(?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?"+(definedField.length()>0?","+definedParam+"":"")+",?,?::timestamp,?::timestamp,?,?,?,?)"; + + }else{ + sql = " insert into kq_format_detail( " + + " resourceid,kqdate,groupid,serialid,serialnumber,workbegindate,workbegintime,workenddate,workendtime,workmins," + + " signindate,signintime,signinid,signoutdate,signouttime,signoutid,signMins," + + " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins," + + " leaveMins,leaveinfo,evectionMins,outMins,forgotbeginworkcheckmins,otherinfo"+(definedField.length()>0?","+definedField+"":"")+",day_type,create_time,update_time,id,flowinfo,on_absenteeismmins,off_absenteeismmins) " + + " values(?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?"+(definedField.length()>0?","+definedParam+"":"")+",?,?,?,?,?,?,?)"; + } + for (int i = 0; i < lsParam.size(); i++) { + List param = lsParam.get(i); + boolean isok = rs.executeUpdate(sql, param); + kqLog.info("插入记录:userId:"+userId+":kqDate:"+kqDate+":param:"+JSON.toJSONString(param)+":isok:"+isok+"::uuid::"+uuid); + } + String attendancedaysF = " (cast(sum(attendanceMins)AS decimal(10, 2))*"+Util.getDoubleValue(convertAttendDay)+")/sum(workmins) as attendancedays, sum(attendanceMins) as attendanceMins, "; + String workF = " case when sum(workmins)>0 then "+convertAttendDay+" end as workdays, sum(workmins) as workmins,"; + String belateminsF = " sum(case when belatemins> 0 then 1 else 0 end) as belate,sum(belatemins) as belatemins,"; + String graveBeLateMinsF = " sum(case when graveBeLateMins> 0 then 1 else 0 end) as graveBeLate,sum(graveBeLateMins) as graveBeLateMins,"; + String leaveearlyminsF = " sum(case when leaveearlymins> 0 then 1 else 0 end) as leaveearly,sum(leaveearlymins) as leaveearlymins,"; + String graveLeaveEarlyMinsF = " sum(case when graveLeaveEarlyMins> 0 then 1 else 0 end) as graveLeaveEarly,sum(graveLeaveEarlyMins) as graveLeaveEarlyMins, "; + String absenteeismminsF = " sum(case when absenteeismmins> 0 then 1 else 0 end) as absenteeism,sum(absenteeismmins) as absenteeismmins, "; + String forgotcheckminsF = " sum(case when forgotcheckmins> 0 then 1 else 0 end) as forgotcheck,sum(forgotcheckmins) as forgotcheckmins,"; + String forgotbeginworkcheckminsF = " sum(case when forgotbeginworkcheckmins> 0 then 1 else 0 end) as forgotbeginworkcheck,sum(forgotbeginworkcheckmins) as forgotbeginworkcheckmins "; + String signF = " cast(sum(signmins)AS decimal(10, 2))/sum(workmins) as signdays, sum(signmins) as signmins,"; + String onoffAbsenteeismminsF= " sum(case when on_absenteeismmins> 0 then 1 else 0 end) as on_absenteeismmins,sum(case when off_absenteeismmins> 0 then 1 else 0 end) as off_absenteeismmins "; + if(1 == workTime.getNonWorkShift()){ + attendancedaysF = " 0 as attendancedays, 0 as attendanceMins, "; + workF = " 0 as workdays, 0 as workmins,"; + belateminsF = " 0 as belate,0 as belatemins,"; + graveBeLateMinsF = " 0 as graveBeLate,0 as graveBeLateMins,"; + leaveearlyminsF = " 0 as leaveearly,0 as leaveearlymins,"; + graveLeaveEarlyMinsF = " 0 as graveLeaveEarly,0 as graveLeaveEarlyMins, "; + absenteeismminsF = " 0 as absenteeism,0 as absenteeismmins,"; + forgotcheckminsF = " 0 as forgotcheck,0 as forgotcheckmins,"; + forgotbeginworkcheckminsF = " 0 as forgotbeginworkcheck,0 as forgotbeginworkcheckmins "; + signF = " 0 as signdays, 0 as signmins,"; + onoffAbsenteeismminsF = " 0 as on_absenteeismmins, 0 as off_absenteeismmins "; + } + + Long id = IdGenerator.generate(); + String baseField = ""; + if ("mysql".equalsIgnoreCase(rs.getDBType())){ + baseField = " now(),now(),"+id; + }else if ("oracle".equalsIgnoreCase(rs.getDBType())){ + baseField = " sysdate,sysdate,"+id; + }else if ("postgresql".equalsIgnoreCase(rs.getDBType())){ + baseField = " now(),now(),"+id; + }else{ + baseField = " getdate(),getdate(),"+id; + } + + sql = " insert into kq_format_total(resourceid,kqdate,subcompanyid,departmentid,jobtitle,groupid,serialid,workdays,workmins," + + " attendancedays,attendancemins,signdays,signmins,belate,belatemins,gravebelate,gravebelatemins,leaveeearly,leaveearlymins,graveleaveearly," + + " graveleaveearlymins,absenteeism,absenteeismmins,forgotcheck,forgotcheckmins," + + " leaveMins,evectionMins,outMins,forgotbeginworkcheck,forgotbeginworkcheckmins"+(definedField.length()>0?","+definedField+"":"")+",create_time,update_time,id,on_absenteeismmins,off_absenteeismmins) " + + " select a.resourceid,kqdate,b.subcompanyid1,b.departmentid,b.jobtitle,groupid,serialid," + + workF + + attendancedaysF + + signF + + belateminsF + + graveBeLateMinsF + + leaveearlyminsF + + graveLeaveEarlyMinsF + + absenteeismminsF + + forgotcheckminsF+ + " sum(leaveMins) as leaveMins," + + " sum(evectionMins) as evectionMins,sum(outMins) as outMins, " + + forgotbeginworkcheckminsF + + (definedField.length()>0?","+definedParamSum+"":"")+","+baseField+","+onoffAbsenteeismminsF+ + " from kq_format_detail a, hrmresource b" + + " where a.resourceid = b.id and resourceid = ? and kqdate=?" + + " group by resourceid,kqdate,b.subcompanyid1,b.departmentid,b.jobtitle,groupid,serialid"; + rs.executeUpdate(sql, userId, kqDate); + } + } + }catch (Exception e) { + kqLog.info("考勤重算报错:KQFormatData.Exception:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + return resultMap; + } + + public List> format(String userId, String kqDate, WorkTimeEntity workTime, + Map workFlowInfo, String uuid) { + List> lsParam = new ArrayList<>(); + List params = null; + HashMap middleMap = new HashMap<>(); + try { + KQRepeatLengthContext.clear(); + KQRepeatLengthContext.removeRepeatBeanLink(); + KQRepeatLengthContext.removeRepeatBeanLinkRange(); + Timestamp date = new Timestamp(System.currentTimeMillis()); + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String nosign_is_absent = Util.null2String(kqSettingsComInfo.getMain_val("nosign_is_absent"),"1"); + //默认不开启半天的特殊规则,如果开启,那么只要是半天的单位,并且申请考勤流程半天,那么实际出勤就是0.5天,不考虑迟到和早退。当天旷工的情况需要考虑,即如果另外半天是旷工,那么实际出勤自然也是0 + String is_half = Util.null2String(kqSettingsComInfo.getMain_val("is_half"),"0"); + String early_one_mins = Util.null2String(kqSettingsComInfo.getMain_val("early_one_mins"),"0"); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + KQFormatShiftRule kqFormatShiftRule = new KQFormatShiftRule(); + String preDate = DateUtil.addDate(kqDate, -1);//上一天日期 + String nextDate = DateUtil.addDate(kqDate, 1);//下一天日期 + String dateKey = userId + "|" + kqDate; + String nextDateKey = userId + "|" + nextDate; + ArrayList hostIps = InitServer.getRealIp(); + boolean oneSign = false; + List lsSignTime = new ArrayList<>(); + List lsWorkTime = new ArrayList<>(); + List lsRestTime = new ArrayList<>(); + List workFlow = null; + int restShift = 0; + int signoutOnlyoff = 0; + if (workTime != null) { + lsSignTime = workTime.getSignTime();//允许打卡时间 + lsWorkTime = workTime.getWorkTime();//工作时间 + lsRestTime = workTime.getRestTime();//休息时段时间 + oneSign = lsWorkTime!=null&&lsWorkTime.size()==1; + restShift = workTime.getNonWorkShift(); + signoutOnlyoff = workTime.getSignoutOnlyoff(); + } + kqLog.info("format in >>>>>userId" + userId + "kqDate==" + kqDate+":restShift:"+restShift+":signoutOnlyoff:"+signoutOnlyoff+":hostIps:"+hostIps+":uuid::"+uuid); + + if(this.writeLog) { + logInfo.put("signoutOnlyoff",signoutOnlyoff); + } + //哺乳假 请假时长 + int repeatLeaveMins = 0; + //所有的请假时长 + int allLeaveMins = 0; + String repeatKey = userId+"_"+kqDate; + String keyRepeat = userId + "|" + kqDate+"|repeat"; + if (workFlowInfo.get(keyRepeat) != null) { + List workFlowRepeat = (List) workFlowInfo.get(keyRepeat); + repeatLeaveMins = handleRepeatWorkFlowInfo(workFlowRepeat,repeatKey); + } + + int[] dayMins = new int[2880];//一天所有分钟数 + Arrays.fill(dayMins, -1); + + //处理半天班次冲销问题 + int[] dayMinsNew = new int[2880];//一天所有分钟数 + Arrays.fill(dayMinsNew, -1); + int workMins4leave = 0; + int middleMins = 0;//班次的半天时长 + int middleMins_final = 0;//班次的半天时长 + int shiftNums = lsWorkTime == null ? 0 : lsWorkTime.size(); + + // 一天4次打卡单独做判断,如果是上午下班打卡和下午上班打卡时间重叠,那么上午的下班卡取最早的,下午的上班卡取最晚的。用shiftCount是否等于-1判断,-1就走标准不重叠。2就表示重叠走新的逻辑 + int shiftCount = lsWorkTime == null ? 0 : lsWorkTime.size(); + int shiftI = 0; + String signEndDateTimeZero = ""; + for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) { + shiftI = i; + TimeScopeEntity signTimeScope = lsSignTime.get(i); + TimeScopeEntity workTimeScope = lsWorkTime.get(i); + String signBeginDateTime = signTimeScope.getBeginTimeAcross() ? nextDate : kqDate; + if(signTimeScope.isBeginTimePreAcross()){ + signBeginDateTime = preDate; + } + signBeginDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(signTimeScope.getBeginTime())+":00"; + String signEndDateTime = signTimeScope.getEndTimeAcross() ? nextDate : kqDate; + signEndDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(signTimeScope.getEndTime())+":59"; + if (shiftCount == 2 && shiftI == 0) { + signEndDateTimeZero = signEndDateTime; + } + if (shiftCount == 2 && shiftI == 1) { + shiftCount = signBeginDateTime.compareTo(signEndDateTimeZero) <= 0 ? shiftCount : -1; + } + + String workBeginTime = Util.null2String(workTimeScope.getBeginTime()); + String ori_workBeginTime = workBeginTime; + int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime); + boolean workBenginTimeAcross = workTimeScope.getBeginTimeAcross(); + String workEndTime = Util.null2String(workTimeScope.getEndTime()); + String ori_workEndTime = workEndTime; + int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + boolean workEndTimeAcross = workTimeScope.getEndTimeAcross(); + int workMins = workTimeScope.getWorkMins(); + + String workBeginDate = workBenginTimeAcross ? nextDate : kqDate; + String workEndDate = workEndTimeAcross ? nextDate : kqDate; + if(lsRestTime != null && !lsRestTime.isEmpty()){ + for(int k = 0 ; k < lsRestTime.size(); k++){ + TimeScopeEntity restTimeScope = lsRestTime.get(k); + if (restTimeScope!=null) { + String restBeginTime = Util.null2String(restTimeScope.getBeginTime()); + String restEndTime = Util.null2String(restTimeScope.getEndTime()); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(restBeginTime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(restEndTime); + if (endIdx > beginIdx) { + Arrays.fill(dayMinsNew, beginIdx, endIdx, -11);//休息时间 + } + } + } + int all_rest_cnt = kqTimesArrayComInfo.getCnt(dayMinsNew, workBeginIdx, workEndIdx, -11); + if(all_rest_cnt >= 0){ + workMins = workMins-(all_rest_cnt); + } + } + workMins4leave += workMins; + } + middleMins = workMins4leave>0?workMins4leave/2:0; + middleMins_final = middleMins; + int split_time_index = middleMins_final; // 半天时间index,用于考勤汇总报表区分上下午 + if(oneSign) { + List halfWorkIndex = workTime.getHalfWorkIndex(); + if(halfWorkIndex != null && !halfWorkIndex.isEmpty()) { + int[] halfWorkIndexs = halfWorkIndex.get(0); + split_time_index = halfWorkIndexs[1];//半天的时间 + } + } + + for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) { + shiftI = i; + params = new ArrayList<>(); + TimeScopeEntity signTimeScope = lsSignTime.get(i); + TimeScopeEntity workTimeScope = lsWorkTime.get(i); + //TimeScopeEntity restTimeScope = lsRestTime.isEmpty()?null:lsRestTime.get(i); + String workBeginTime = Util.null2String(workTimeScope.getBeginTime()); + String ori_workBeginTime = workBeginTime; + int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime); + boolean workBenginTimeAcross = workTimeScope.getBeginTimeAcross(); + String workEndTime = Util.null2String(workTimeScope.getEndTime()); + String ori_workEndTime = workEndTime; + int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + boolean workEndTimeAcross = workTimeScope.getEndTimeAcross(); + int workMins = workTimeScope.getWorkMins(); + + String workBeginDate = workBenginTimeAcross ? nextDate : kqDate; + String workEndDate = workEndTimeAcross ? nextDate : kqDate; + + Arrays.fill(dayMins, workBeginIdx, workEndIdx, 1);//工作时段标识 1 + + int beginIdx = 0; + int endIdx = 0; + int checkIn = 0; + int checkOut = 0; + String signInId = ""; + String signInDate = ""; + String signInTime = ""; + String signOutId = ""; + String signOutDate = ""; + String signOutTime = ""; + int earlyInMins = 0;//早到分钟数 + int lateOutMins = 0;//晚走分钟数 + int signMins = 0;//签到签退时长 + int tmpAttendanceMins = 0;//出勤分钟数(流程抵扣来的) + int attendanceMins = 0; + int beLateMins = 0; + int graveBeLateMins = 0; + int leaveEarlyMins = 0; + int graveLeaveEarlyMins = 0; + int absenteeismMins = 0; + int on_absenteeismMins = 0; + int off_absenteeismMins = 0; + int leaveMins = 0;//请假时长 + Map leaveInfo = new HashMap<>();//请假信息 + Map otherinfo = new HashMap<>();//存一些用得到的信息 + Map flowinfo = new HashMap<>();//流程信息 + int evectionMins = 0;//出差时长 + int outMins = 0;//公出时长 + int otherMins = 0;//异常流程时长 + int forgotCheckMins = 0; + int forgotBeginWorkCheckMins = 0;//上班漏签 + int signInTimeIndx = -1; + int flowSignInTimeIndx = -1; + int signInTimeOutdx = -1; + //用来计算实际打卡时长用的 + int signInTimeIndx4Sign = -1; + int signInTimeOutdx4Sign = -1; + + String signBeginDateTime = signTimeScope.getBeginTimeAcross() ? nextDate : kqDate; + if(signTimeScope.isBeginTimePreAcross()){ + signBeginDateTime = preDate; + } + signBeginDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(signTimeScope.getBeginTime())+":00"; + String signEndDateTime = signTimeScope.getEndTimeAcross() ? nextDate : kqDate; + signEndDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(signTimeScope.getEndTime())+":59"; + String workBeginDateTime = workTimeScope.getBeginTimeAcross() ? nextDate : kqDate; + workBeginDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(workTimeScope.getBeginTime())+":00"; + String workEndDateTime = workTimeScope.getEndTimeAcross() ? nextDate : kqDate; + workEndDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(workTimeScope.getEndTime())+":00"; + + kqLog.info("signBeginDateTime" + signBeginDateTime+"::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + kqLog.info("signEndDateTime" + signEndDateTime+"::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + kqLog.info("workBeginDateTime" + workBeginDateTime+"::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + kqLog.info("workEndDateTime" + workEndDateTime+"::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + + Map shifRuleMap = Maps.newHashMap(); + if (1 != restShift) { + if(oneSign){ + //个性化设置只支持一天一次上下班 + ShiftInfoBean shiftInfoBean = new ShiftInfoBean(); + shiftInfoBean.setSplitDate(kqDate); + shiftInfoBean.setShiftRuleMap(workTime.getShiftRuleInfo()); + shiftInfoBean.setSignTime(lsSignTime); + shiftInfoBean.setWorkTime(lsWorkTime); + shiftInfoBean.setSignoutOnlyoff(signoutOnlyoff); + List logList = Lists.newArrayList(); + KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, userId, shifRuleMap,logList); + if(!shifRuleMap.isEmpty()){ + if(!logList.isEmpty()){ + otherinfo.put("logList", logList); + } + + otherinfo.put("shiftRule", shifRuleMap); + if(shifRuleMap.containsKey("shift_beginworktime")){ + String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime")); + if(shift_beginworktime.length() > 0){ + workBeginTime = Util.null2String(shift_beginworktime); + workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime); + workTimeScope.setBeginTime(workBeginTime); + workTimeScope.setBeginTimeAcross(workBeginIdx>=1440?true:false); + } + } + if(this.writeLog) { + logInfo.put("before.workEndIdx",workEndIdx); + } + if(shifRuleMap.containsKey("shift_endworktime")){ + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if(shift_endworktime.length() > 0){ + workEndTime = Util.null2String(shift_endworktime); + workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + workTimeScope.setEndTime(workEndTime); + workTimeScope.setEndTimeAcross(workEndIdx>=1440?true:false); + } + } + } + kqLog.info("个性化之后 signBeginDateTime" + signBeginDateTime); + kqLog.info("个性化之后 signEndDateTime" + signEndDateTime); + kqLog.info("个性化之后 workBeginDateTime" + workBeginDateTime); + kqLog.info("个性化之后 workEndDateTime" + workEndDateTime); + } + } + if(this.writeLog) { + logInfo.put("after.workEndIdx",workEndIdx); + } + + List lsCheckInfo = new KQFormatSignData().getSignInfo(userId,signTimeScope,workTimeScope,kqDate,preDate,nextDate,kqTimesArrayComInfo,hostIps,uuid,shiftCount,shiftI,signoutOnlyoff); + kqLog.info("lsCheckInfo" + JSONObject.toJSONString(lsCheckInfo)+"::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + if(this.writeLog) { + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005297,weaver.general.ThreadVarLanguage.getLang())+"",signBeginDateTime); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005298,weaver.general.ThreadVarLanguage.getLang())+"",signEndDateTime); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(1940,weaver.general.ThreadVarLanguage.getLang())+"",workBeginDateTime); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005299,weaver.general.ThreadVarLanguage.getLang())+"",workEndDateTime); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005300,weaver.general.ThreadVarLanguage.getLang())+"",lsCheckInfo); + } + for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) { + Map checkInfo = (Map) lsCheckInfo.get(j); + String signStatus = Util.null2String(checkInfo.get("signStatus")); + String signId = Util.null2String(checkInfo.get("signId")); + String signDate = Util.null2String(checkInfo.get("signDate")); + String signTime = Util.null2String(checkInfo.get("signTime")); + String deduct_signintime = Util.null2String(checkInfo.get("deduct_signintime")); + String deduct_signofftime = Util.null2String(checkInfo.get("deduct_signofftime")); + String flow_signInTime = ""; + String flow_signOutTime = ""; + if(kqDate.compareTo(signDate) < 0)endIdx+=1440; + if (signTime.length() > 8) { + signTime = signTime.substring(0, 8); + } + if (checkInfo.get("signType").equals("1")) {//签到 + checkIn++; + //如果流程抵扣存在,打卡时长也存在,那么相互比较得到出勤时长和打卡时长 暂不这样处理,还是按照漏签的逻辑来处理 + if(signTime.length() > 0){ + signInTimeIndx4Sign = kqTimesArrayComInfo.getArrayindexByTimes(signTime); + } + signInId = signId; + signInDate = signDate; + signInTime = signTime; + signInTimeIndx = kqTimesArrayComInfo.getArrayindexByTimes(signInTime); + if(this.writeLog) { + logInfo.put(j+">>>signInTime",signInTime); + logInfo.put(j+">>>signInTimeIndx",signInTimeIndx); + logInfo.put(j+">>>kqDate",kqDate+"|"+signDate); + } + if(deduct_signintime.length() > 0){ + if(signTime.length() > 0){ + if(deduct_signintime.compareTo(signTime) < 0){ + flow_signInTime = deduct_signintime; + } + }else{ + flow_signInTime = deduct_signintime; + } + } + if(flow_signInTime.length() > 0){ + flowSignInTimeIndx = kqTimesArrayComInfo.getArrayindexByTimes(flow_signInTime); + } + if(kqDate.compareTo(signDate) < 0) { + signInTimeIndx += 1440; + flowSignInTimeIndx += 1440; + }else if(kqDate.compareTo(signDate) > 0){ + signInTimeIndx -= 1440; + signInTimeIndx = signInTimeIndx < 0 ? 0 : signInTimeIndx; + flowSignInTimeIndx -= 1440; + flowSignInTimeIndx = flowSignInTimeIndx < 0 ? 0 : flowSignInTimeIndx; + } + } else if (checkInfo.get("signType").equals("2")) {//签退 + checkOut++; + //如果流程抵扣存在,打卡时长也存在,那么相互比较得到出勤时长和打卡时长 暂不这样处理,还是按照漏签的逻辑来处理 + if(signTime.length() > 0){ + signInTimeOutdx4Sign = kqTimesArrayComInfo.getArrayindexByTimes(signTime); + } + signOutId = signId; + signOutDate = signDate; + signOutTime = signTime; + signInTimeOutdx = kqTimesArrayComInfo.getArrayindexByTimes(signOutTime); + if(deduct_signofftime.length() > 0){ + if(signTime.length() > 0){ + if(deduct_signofftime.compareTo(signTime) > 0){ + flow_signOutTime = deduct_signofftime; + } + }else{ + flow_signOutTime = deduct_signofftime; + } + } + if(flow_signOutTime.length() > 0){ + signInTimeOutdx = kqTimesArrayComInfo.getArrayindexByTimes(flow_signOutTime); + } + if(kqDate.compareTo(signDate) < 0){ + signInTimeOutdx+=1440; + }else if(kqDate.compareTo(signDate) > 0){ + signInTimeOutdx -= 1440; + signInTimeOutdx = signInTimeOutdx < 0 ? 0 : signInTimeOutdx; + } + if(oneSign){ + if(signInTimeOutdx>workEndIdx) { + lateOutMins = signInTimeOutdx-workEndIdx; + } + } + } + if (checkInfo.get("signType").equals("1")) {//签到 + if(signTime.length() > 0){ + String signMinTime = signTime.substring(0,5)+":00"; + endIdx = kqTimesArrayComInfo.getArrayindexByTimes(signTime); + if(signTime.compareTo(signMinTime) > 0){ + //如果签到时间是带秒的且是迟到,那么签到时间多一秒和多一分钟是一样的 + endIdx += 1; + signInTimeIndx = signInTimeIndx + 1;//如果是带秒的打卡数据不应该影响流程抵扣的数据的下标 + } + if(kqDate.compareTo(signDate) < 0){ + endIdx+=1440; + }else if(kqDate.compareTo(signDate) > 0){ + endIdx -= 1440; + endIdx = endIdx < 0 ? 0 : endIdx; + } + if (endIdx > workBeginIdx) { + if(flow_signInTime.length() > 0){ + if(flowSignInTimeIndx > workBeginIdx){ + //增加一个判断,流程抵扣打卡如果开启了并且有抵扣上班打卡,那么也就不是迟到了 + Arrays.fill(dayMins, workBeginIdx, endIdx, 2);//迟到时段标识 2 + } + }else{ + Arrays.fill(dayMins, workBeginIdx, endIdx, 2);//迟到时段标识 2 + } + } + } + } else if (checkInfo.get("signType").equals("2")) {//签退 + if(signTime.length() > 0){ + beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(signTime); + if(this.writeLog) { + logInfo.put(j+".signTime",signDate+"|"+signTime); + logInfo.put(j+".beginIdx",beginIdx); + logInfo.put(j+".workEndIdx",workEndIdx); + } + if(StringUtils.isNotBlank(signDate) && signDate.compareTo(kqDate) > 0){ + beginIdx+=1440; + }else if(kqDate.compareTo(signDate) > 0){ + beginIdx -= 1440; + beginIdx = beginIdx < 0 ? 0 : beginIdx; + } + if (workEndIdx > beginIdx) { + if(flow_signOutTime.length() > 0){ + if (workEndIdx > signInTimeOutdx) { + //增加一个判断,流程抵扣打卡如果开启了并且有抵扣下班打卡,那么也就不是早退了 + Arrays.fill(dayMins, beginIdx, workEndIdx, 3);//早退时段标识 3 + } + }else{ + + Arrays.fill(dayMins, beginIdx, workEndIdx, 3);//早退时段标识 3 + } + } + } + } + } + + //打卡时长=签退时间-签到时间(有签到签退才计算) + if(checkIn==1&&checkOut==1){ + if(signInTimeIndx4Sign > -1 && signInTimeOutdx4Sign > -1){ + if(DateUtil.dayDiff(signInDate,signOutDate)==0){//同一天签到和签退 + signMins=signInTimeOutdx4Sign - signInTimeIndx4Sign; + }else if(DateUtil.dayDiff(signInDate,signOutDate)==1) {//第一天签到,第二天签退 + if(signInTimeOutdx4Sign workBeginIdx) { + Arrays.fill(dayMins, workBeginIdx, workEndIdx, 4);//旷工时段标识 4 + } + } + + if (checkOut == 0 && checkIn > 0) {//漏签(有签到无签退) + if(signInTimeIndx > -1){ + if (workEndIdx > signInTimeIndx) { + //漏签就是从本次时段内的打卡到下班点 + //上班漏签应该是从签到到签到结束时间,不过这里可以不用管,只是一个次数 + Arrays.fill(dayMins, signInTimeIndx, workEndIdx, 6);//上班漏签时段标识 6 + } else { + //签到晚于本次时段结束时间,也算漏签 + forgotCheckMins++; + } + }else if(flowSignInTimeIndx > -1){ + if (workEndIdx > flowSignInTimeIndx) { + //漏签就是从本次时段内的打卡到下班点 + //上班漏签应该是从签到到签到结束时间,不过这里可以不用管,只是一个次数 + Arrays.fill(dayMins, flowSignInTimeIndx, workEndIdx, 6);//上班漏签时段标识 6 + } else { + //签到晚于本次时段结束时间,也算漏签 + forgotCheckMins++; + } + } + } + + if (checkIn == 0 && checkOut > 0) {//漏签(有签退无签到) + if(signInTimeOutdx > 0){ + if(workBeginIdx < signInTimeOutdx) { + //下班漏签应该是从签退到签退开始时间,不过这里可以不用管,只是一个次数 + Arrays.fill(dayMins, workBeginIdx, signInTimeOutdx, 66);//下班漏签时段标识 66,66呼应前面的漏签的6 + }else{ + //这种数据理论上不会存在,也记下吧 + forgotBeginWorkCheckMins++; + } + } + } + + if (workFlowInfo.get(dateKey) != null) { + workFlow = (List) workFlowInfo.get(dateKey); + } + + boolean isHandle1 = false; + boolean isHandle2 = false; + List flowList = Lists.newArrayList(); + for (int j = 0; workFlow != null && j < workFlow.size(); j++) { + Map data = (Map) workFlow.get(j); + String flowType = Util.null2String(data.get("flowtype")); + String newLeaveType = Util.null2String(data.get("newleavetype")); + String signtype = Util.null2String(data.get("signtype")); + String durationrule = Util.null2String(data.get("durationrule")); + String ishalf = Util.null2String(data.get("ishalf")); + double duration = Util.getDoubleValue(Util.null2String(data.get("duration"))); + if(flowType.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())){ + duration = Util.getDoubleValue(Util.null2String(data.get(newLeaveType))); + } + String serial = Util.null2String(data.get("serial")); + String requestId = Util.null2String(data.get("requestId")); + String begintime = Util.null2String(data.get("begintime")); + String endtime = Util.null2String(data.get("endtime")); + beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + String leavetypeKey = repeatKey+"_"+newLeaveType; + List kqRepeatBeans = KQRepeatLengthContext.getKQRepeatBean(leavetypeKey); + if(CollectionUtils.isNotEmpty(kqRepeatBeans)){ + Long allCnt = 0L; + for (int k = 0; k < kqRepeatBeans.size(); k++) { + KQRepeatBean kqRepeatBean = kqRepeatBeans.get(k); + Long repeatLate = kqRepeatBean.getRepeatLate(); + Long repeatEarly = kqRepeatBean.getRepeatEarly(); + allCnt += ((repeatLate != null && repeatLate > 0) ? repeatLate : 0L)+ ((repeatEarly != null && repeatEarly > 0) ? repeatEarly : 0L); + } + if(leaveInfo.get(newLeaveType)==null){ + leaveInfo.put(newLeaveType,allCnt.intValue()); + }else{ + Integer val = (Integer) leaveInfo.get(newLeaveType); + leaveInfo.put(newLeaveType,val+allCnt); + } + continue; + } + if (beginIdx >= endIdx) { + continue; + } + + Map flowMap = Maps.newHashMap(); + flowMap.put("newLeaveType", newLeaveType); + flowMap.put("begintime", begintime); + flowMap.put("endtime", endtime); + List> flowMapList = Lists.newArrayList(); + if(flowinfo.containsKey(flowType)){ + List> tmpFlowMapList = (List>) flowinfo.get(flowType); + tmpFlowMapList.add(flowMap); + }else{ + flowMapList.add(flowMap); + flowinfo.put(flowType, flowMapList); + } + int middleIdx = (workBeginIdx+workEndIdx)/2;//工作时段标识 1 + + if(flowType.equals(FlowReportTypeEnum.EVECTION.getFlowType())){ + if("2".equals(durationrule) && "true".equals(ishalf)){ + isHandle2 = true; + } + Arrays.fill(dayMins, beginIdx, endIdx, 7);//出差抵扣时段标识 7 + }else if(flowType.equals(FlowReportTypeEnum.OUT.getFlowType())){ + if("2".equals(durationrule) && "true".equals(ishalf)){ + isHandle2 = true; + } + Arrays.fill(dayMins, beginIdx, endIdx, 8);//公出抵扣时段标识 8 + }else if(flowType.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())){ + if("2".equals(durationrule) && "true".equals(ishalf)){ + isHandle1 = true; + } + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 5);//流程抵扣时段标识 5 + int tmpBeginIdx = beginIdx; + int tmpEndIdx = endIdx; + Integer val = 0; + + if(beginIdx>=workEndIdx){ + continue; + } + if(endIdx<=workBeginIdx){ + continue; + } + + if(leaveInfo.get(newLeaveType)==null){ + leaveInfo.put(newLeaveType,val); + }else{ + val = (Integer) leaveInfo.get(newLeaveType); + } + + if(beginIdxworkEndIdx)tmpEndIdx=endIdx; + if(tmpEndIdx>tmpBeginIdx){ + leaveInfo.put(newLeaveType,val+(tmpEndIdx-tmpBeginIdx)); + } + } + }else{ + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 99);//异常流程抵扣时段标识99 + } + } + } + + + if(lsRestTime != null && !lsRestTime.isEmpty()){ + for(int k = 0 ; k < lsRestTime.size(); k++){ + TimeScopeEntity restTimeScope = lsRestTime.get(k); + if (restTimeScope!=null) { + String restBeginTime = Util.null2String(restTimeScope.getBeginTime()); + String restEndTime = Util.null2String(restTimeScope.getEndTime()); + beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(restBeginTime); + endIdx = kqTimesArrayComInfo.getArrayindexByTimes(restEndTime); + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, -11);//休息时间 + } + } + } + int all_rest_cnt = kqTimesArrayComInfo.getCnt(dayMins, workBeginIdx, workEndIdx, -11); + if(all_rest_cnt >= 0){ + workMins = workMins-(all_rest_cnt); + } + } + + for (int j = workBeginIdx; j < workEndIdx; j++) { + switch (dayMins[j]) { + case 1: + tmpAttendanceMins++; + break; + case 2: + beLateMins++; + break; + case 3: + leaveEarlyMins++; + break; + case 4: + if(j attendRepeatBeans = KQRepeatLengthContext.getKQRepeatBean(repeatKey); + + if(beLateMins > 0){ + beLateMins = (int) handleRepeatLength(attendRepeatBeans, beLateMins, "late"); + } + if(leaveEarlyMins > 0){ + leaveEarlyMins = (int) handleRepeatLength(attendRepeatBeans, leaveEarlyMins, "early"); + } + + boolean isAmAbsent = false; + boolean isPmAbsent = false; + if(on_absenteeismMins > 0){ + //如果没有个性化的旷工,那就是全天旷工 + isAmAbsent = true; + } + if(off_absenteeismMins > 0) { + isPmAbsent = true; + } + + KQShiftRuleEntity kqShiftRuleEntity = new KQShiftRuleEntity(); + kqShiftRuleEntity.setUserId(userId); + kqShiftRuleEntity.setKqDate(kqDate); + kqShiftRuleEntity.setBelatemins(beLateMins); + kqShiftRuleEntity.setLeaveearlymins(leaveEarlyMins); + kqShiftRuleEntity.setAbsenteeismmins(absenteeismMins); + kqShiftRuleEntity.setForgotcheckmins(forgotCheckMins); + kqShiftRuleEntity.setForgotBeginWorkCheckMins(forgotBeginWorkCheckMins); + kqShiftRuleEntity.setEarlyInMins(earlyInMins); + kqShiftRuleEntity.setLateOutMins(lateOutMins); + kqShiftRuleEntity.setAMAbsent(isAmAbsent); + kqShiftRuleEntity.setPMAbsent(isPmAbsent); + kqShiftRuleEntity.setNosign_is_absent(nosign_is_absent); + kqShiftRuleEntity.setSignInTime(signInTime); + kqShiftRuleEntity.setSignOutTime(signOutTime); + kqShiftRuleEntity.setEarly_one_mins(early_one_mins); + kqLog.info("人性化规则处理前数据" + JSONObject.toJSONString(kqShiftRuleEntity)); + if(this.writeLog) { + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005301,weaver.general.ThreadVarLanguage.getLang())+"",kqShiftRuleEntity); + } + //人性化规则 + kqShiftRuleEntity = kqFormatShiftRule.doShiftRule(workTime,kqShiftRuleEntity); + kqLog.info("人性化规则处理后数据" + JSONObject.toJSONString(kqShiftRuleEntity)); + if(this.writeLog) { + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005302,weaver.general.ThreadVarLanguage.getLang())+"",kqShiftRuleEntity); + } + beLateMins = kqShiftRuleEntity.getBelatemins(); + graveBeLateMins = kqShiftRuleEntity.getGravebelatemins(); + leaveEarlyMins = kqShiftRuleEntity.getLeaveearlymins(); + graveLeaveEarlyMins = kqShiftRuleEntity.getGraveleaveearlymins(); + absenteeismMins = kqShiftRuleEntity.getAbsenteeismmins(); + forgotCheckMins = kqShiftRuleEntity.getForgotcheckmins(); + forgotBeginWorkCheckMins = kqShiftRuleEntity.getForgotBeginWorkCheckMins(); + int shiftOn_absenteeismMins = Util.getIntValue(kqShiftRuleEntity.getOn_absenteeismMins()); + if(shiftOn_absenteeismMins > 0) { + on_absenteeismMins = shiftOn_absenteeismMins; + } + int shiftOff_absenteeismMins = Util.getIntValue(kqShiftRuleEntity.getOff_absenteeismMins()); + if(shiftOff_absenteeismMins > 0) { + off_absenteeismMins = shiftOff_absenteeismMins; + } + + boolean isondutyfreecheck =false; + boolean isoffdutyfreecheck =false; + Map model_ShiftRule = kqFormatShiftRule.getModel_ShiftRule(i, workTime.getSerialId()); + Iterator iter = model_ShiftRule.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + String key = Util.null2String(entry.getKey()); + String value = Util.null2String(entry.getValue()); + if(key.equals("start")&&value.equals("1")){ + isondutyfreecheck = true; + } + if(key.equals("end")&&value.equals("1")){ + isoffdutyfreecheck = true; + } + } + boolean beforeBegin = !new KQFormatBiz().needCal(workBeginDate,workBeginTime); + if(beforeBegin) {//还未到上班时间,不用计算任何状态 + kqLog.writeLog("还未到上班时间,不用计算任何状态"); + beLateMins = 0; + graveBeLateMins = 0; + leaveEarlyMins = 0; + graveLeaveEarlyMins = 0; + absenteeismMins = 0; + forgotCheckMins = 0; + forgotBeginWorkCheckMins = 0; + isAmAbsent = false; + isPmAbsent = false; + on_absenteeismMins = 0; + off_absenteeismMins = 0; + }else if(!new KQFormatBiz().needCal(workEndDate,workEndTime)) {//还未到下班时间 + kqLog.writeLog("还未到上班时间"); + leaveEarlyMins = 0; + graveLeaveEarlyMins = 0; + forgotCheckMins = 0; + isPmAbsent = false; + off_absenteeismMins = 0; + } + + if (1 == restShift || workTime.getIsExclude()) {//休息日班次或者无需考勤人员没有异常状态 + beLateMins = 0; + graveBeLateMins = 0; + leaveEarlyMins = 0; + graveLeaveEarlyMins = 0; + absenteeismMins = 0; + forgotCheckMins = 0; + forgotBeginWorkCheckMins = 0; + isAmAbsent = false; + isPmAbsent = false; + on_absenteeismMins = 0; + off_absenteeismMins = 0; + } + if (1 == restShift) {//非工作日班次連打卡時長和出勤时长也不給了 + workMins = 0; + signMins = 0; + isAmAbsent = false; + isPmAbsent = false; + on_absenteeismMins = 0; + off_absenteeismMins = 0; + } + //允许下班不打卡 ,如果上班也没有打卡,那么算上班旷工0.5天 + if (isoffdutyfreecheck) { + if (checkIn == 0) {//(无签到),就会有上班漏签,如果有下班卡,那么上班漏签 + if(forgotBeginWorkCheckMins==0&&absenteeismMins>0){ + forgotBeginWorkCheckMins= absenteeismMins ; + } + } + absenteeismMins = 0; + forgotCheckMins = 0; + off_absenteeismMins = 0; + } + //允许上班不打卡,如果下班也没有打卡,那么算漏签 + if(isondutyfreecheck){ + if (checkOut == 0) {//(无签退) + if(forgotCheckMins==0&&absenteeismMins>0){ + forgotCheckMins= absenteeismMins ; + } + } + absenteeismMins = 0; + forgotBeginWorkCheckMins = 0; + on_absenteeismMins = 0; + } + if(isondutyfreecheck&&isoffdutyfreecheck){ + absenteeismMins = 0; + forgotCheckMins = 0; + forgotBeginWorkCheckMins = 0; + on_absenteeismMins = 0; + off_absenteeismMins = 0; + } + int repeatLeaveTime = (int) getRepeatLeaveTime(); + if(repeatLeaveTime > 0){ + leaveMins = leaveMins+repeatLeaveTime; + } + //计算实际出勤时间(出差公出算出勤)=应出勤-旷工-请假-迟到-早退 + attendanceMins = workMins - absenteeismMins-leaveMins-beLateMins-graveBeLateMins-leaveEarlyMins-graveLeaveEarlyMins; + + if(this.writeLog) { + logInfo.put("is_half",is_half); + logInfo.put("shiftNums",shiftNums); + logInfo.put("isHandle2",isHandle2); + logInfo.put("isHandle1",isHandle1); + logInfo.put("workMins"+i,workMins); + logInfo.put("absenteeismMins"+i,absenteeismMins); + logInfo.put("middleMins"+i,middleMins); + } + //如果开启半天特殊处理的,请假是需要扣除0.5天 + //说明没有打卡的情况,因为有打卡肯定是有迟到、早退、漏签这些异常的,不考虑迟到算旷工,早退算旷工的情况 + //只处理1天1次,和1天2次的情况,因为1天3次的中间点可能在第二段,需要考虑有没有打卡,以及有打卡第三次是否需要处理等情况,和上下午半天的概念不太适用 + if("1".equals(is_half)){ + boolean absentFlag_1 = false;//请假, + boolean absentFlag_2 = false;//公出或出差 + if(isHandle1 || isHandle2){ + if(absenteeismMins>0 && !(beLateMins >0||graveBeLateMins > 0||leaveEarlyMins > 0||graveLeaveEarlyMins > 0||forgotCheckMins > 0||forgotBeginWorkCheckMins >0)){ + if(isHandle1){ + absentFlag_1 = true;//可以理解为是1天3次和1天1次的情况,因为1天2次的情况,如果有旷工,那么另外半天才是有请假, + } + if(isHandle2){ + absentFlag_2 = true;//可以理解为是1天3次和1天1次的情况,因为1天2次的情况,如果有旷工,那么另外半天才是有公出或者出差 + } + } + } + if(this.writeLog) { + logInfo.put("tmp_absenteeismMins"+i,absenteeismMins); + logInfo.put("absentFlag_1"+i,absentFlag_1); + logInfo.put("absentFlag_2"+i,absentFlag_2); + } + /*1次---上午3小时,下午5小时 + 上午公出,下午旷工 + 上午公出,下午打卡 + 上午旷工,下午公出 + 上午打卡,下午公出 + + 2次---上午3小时,下午5小时 + 上午公出,下午旷工--需处理实际出勤、旷工时长 + 上午公出,下午打卡--需处理实际出勤 + 上午旷工,下午公出--需处理实际出勤、旷工时长 + 上午打卡,下午公出--需处理实际出勤 + */ + if(isHandle2){ + if(shiftNums ==1){ + absenteeismMins = absentFlag_2?middleMins_final:0; + attendanceMins = workMins - absenteeismMins; + }else if(shiftNums == 2){ + if(workMins>middleMins_final && middleMins_final>0){ + absenteeismMins = (absenteeismMins > middleMins_final)?middleMins_final:((absentFlag_2||outMins>0||evectionMins>0)?Math.abs(workMins - middleMins_final):0); + absenteeismMins = (i==1 && middleMap.get("attendanceMins0")>0)?(absentFlag_2?absenteeismMins:0):absenteeismMins;//上午打卡3小时,下午公出5小时,下午的就不要显示旷工1小时了 + } + attendanceMins = workMins - absenteeismMins; + } + } + if(this.writeLog) { + logInfo.put("absenteeismMins_1"+i,absenteeismMins); + logInfo.put("attendanceMins_1"+i,attendanceMins); + } + + /*1次---上午3小时,下午5小时 + 上午请假,下午旷工 + 上午请假,下午打卡 + 上午旷工,下午请假 + 上午打卡,下午请假 + + 2次---上午3小时,下午5小时 + 上午请假,下午旷工--需处理实际出勤、旷工时长 + 上午请假,下午打卡--需处理实际出勤 + 上午旷工,下午请假--需处理实际出勤、旷工时长 + 上午打卡,下午请假--需处理实际出勤 + */ + + if(isHandle1){ + if(shiftNums == 1){ + absenteeismMins = absentFlag_1?middleMins_final:0; + attendanceMins = workMins - absenteeismMins - (leaveMins>0?middleMins_final:(absentFlag_1?(workMins - middleMins_final):0)); + }else if(shiftNums == 2){ + if(workMins>middleMins_final && middleMins_final>0){ + absenteeismMins = (absenteeismMins > middleMins_final)?middleMins_final:((absentFlag_1||leaveMins>0)?Math.abs(workMins - middleMins_final):0); + absenteeismMins = (i==1 && middleMap.get("attendanceMins0")>0)?0:absenteeismMins;//上午打卡3小时,下午请假5小时,下午的就不要显示旷工1小时了 + } + attendanceMins = workMins - absenteeismMins - (leaveMins>0?middleMins_final:(absentFlag_1?Math.abs(workMins - middleMins_final):0)); + attendanceMins = attendanceMins>middleMins_final?middleMins_final:attendanceMins;//上午请假3小时,下午打卡5小时 + }else if(shiftNums == 3){//比如一天三次上下班,那么中间点在第二次上下班区间 +// if(workMins>middleMins && middleMins>0){ +// absenteeismMins = (absenteeismMins > middleMins_final)?middleMins_final:((absentFlag_1||leaveMins>0)?(workMins - middleMins):0); +// absenteeismMins = (i>=1 && middleMap.get("attendanceMins"+(i-1))>0)?0:absenteeismMins; +// } +// attendanceMins = workMins - absenteeismMins - (leaveMins>0?middleMins_final:(absentFlag_1?Math.abs(workMins - middleMins_final):0)); +// attendanceMins = attendanceMins>middleMins_final?middleMins_final:attendanceMins;//上午请假3小时,下午打卡5小时 +// if(workMins < middleMins){//客户可能是一天2次,或者3次,那么workmins有可能是小于半天的请假时间 +// middleMins = middleMins-workMins; +// }else { +// middleMins = 0; +// } + } + if(absenteeismMins > middleMins_final){//客户可能是一天2次,或者3次 + absenteeismMins = middleMins_final; + } + } + middleMap.put("attendanceMins"+i,attendanceMins); + middleMap.put("absenteeismMins"+i,absenteeismMins); + middleMap.put("workMins"+i,workMins); + middleMap.put("leaveMins"+i,leaveMins); + middleMap.put("outMins"+i,outMins); + middleMap.put("evectionMins"+i,evectionMins); + middleMap.put("isHandle1"+i,isHandle1?1:0); + middleMap.put("isHandle2"+i,isHandle2?1:0); + middleMap.put("absentFlag_1"+i,absentFlag_1?1:0);//1表示有旷工 + middleMap.put("absentFlag_2"+i,absentFlag_2?1:0);//1表示有旷工 + } + + // 如果没有开启"漏签是否算实际出勤"开关,则漏签不算实际出勤时长 + if("0".equals(nosign_is_absent)) { + attendanceMins = attendanceMins-forgotCheckMins-forgotBeginWorkCheckMins; + } + if(beforeBegin || attendanceMins < 0) {//还未到上班时间,不用计算任何状体 + attendanceMins = 0; + } + + /** + * 汇总报表的日历显示是有旷工就不显示漏签了,如果这里还统计漏签,张总表示日历也需要修改,改不动了 + * 在处理完实际出勤之后,将漏签还原 + */ + String nosign_ishandle = Util.null2String(kqShiftRuleEntity.getNosign_ishandle()); + if("1".equals(nosign_ishandle)){ + forgotCheckMins = 0; + }else if("2".equals(nosign_ishandle)){ + forgotCheckMins = 0; + forgotBeginWorkCheckMins = 0; + } + + kqLog.info("实际出勤计算公式" + "实际出勤=应出勤- 旷工-请假-迟到-早退 userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + kqLog.info("实际出勤计算结果" + attendanceMins + "=" + workMins + "- " + absenteeismMins + "-" + leaveMins + "-" + (beLateMins + graveBeLateMins) + "-" + (leaveEarlyMins - graveLeaveEarlyMins)+ "-" + (repeatLeaveTime)+" userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + if(this.writeLog) { + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005303,weaver.general.ThreadVarLanguage.getLang())+"",""+weaver.systeminfo.SystemEnv.getHtmlLabelName(130566,weaver.general.ThreadVarLanguage.getLang())+"="+weaver.systeminfo.SystemEnv.getHtmlLabelName(132056,weaver.general.ThreadVarLanguage.getLang())+"- "+weaver.systeminfo.SystemEnv.getHtmlLabelName(20085,weaver.general.ThreadVarLanguage.getLang())+"-"+weaver.systeminfo.SystemEnv.getHtmlLabelName(670,weaver.general.ThreadVarLanguage.getLang())+"-"+weaver.systeminfo.SystemEnv.getHtmlLabelName(20081,weaver.general.ThreadVarLanguage.getLang())+"-"+weaver.systeminfo.SystemEnv.getHtmlLabelName(20082,weaver.general.ThreadVarLanguage.getLang())+""); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005304,weaver.general.ThreadVarLanguage.getLang())+"",attendanceMins+"="+workMins+"- "+absenteeismMins+"-"+leaveMins+"-"+(beLateMins+graveBeLateMins)+"-"+(leaveEarlyMins-graveLeaveEarlyMins)+"-"+(repeatLeaveTime)); + } + //判断当天考勤状态 +// if (beLateMins > 0) { +// status = ButtonStatusEnum.BELATE.getStatusCode(); +// } else if (leaveEarlyMins > 0) { +// status = ButtonStatusEnum.LEAVEERALY.getStatusCode(); +// } else if (absenteeismMins > 0) { +// status = ButtonStatusEnum.ABSENT.getStatusCode(); +// } else if (forgotCheckMins > 0) { +// status = ButtonStatusEnum.NOSIGN.getStatusCode(); +// } else { +// status = ButtonStatusEnum.NORMAL.getStatusCode(); +// } + + String groupid = Util.null2String(workTime.getGroupId()); + String serialid = Util.null2String(workTime.getSerialId()); + + params.add(userId); + params.add(kqDate); + params.add(groupid.length() == 0 ? null : groupid); + params.add(serialid.length() == 0 ? null : serialid); + params.add(i); + params.add(workBeginDate); + params.add(kqTimesArrayComInfo.turn48to24Time(ori_workBeginTime)); + params.add(workEndDate); + params.add(kqTimesArrayComInfo.turn48to24Time(ori_workEndTime)); + params.add(workMins); + params.add(signInDate); + params.add(signInTime); + params.add(signInId.length() == 0 ? null : signInId); + params.add(signOutDate); + params.add(signOutTime); + params.add(signOutId.length() == 0 ? null : signOutId); + kqLog.info("format in >>>>>userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid + +":signInDate:"+signInDate+":signInTime::"+signInTime+":signOutDate:"+signOutDate+":signOutTime::"+signOutTime); + params.add(signMins); + params.add(attendanceMins); + params.add(beLateMins); + params.add(graveBeLateMins); + params.add(leaveEarlyMins); + params.add(graveLeaveEarlyMins); + params.add(absenteeismMins); + params.add(forgotCheckMins); + params.add(leaveMins); + params.add(JSONObject.toJSONString(leaveInfo)); + params.add(evectionMins); + params.add(outMins); + params.add(forgotBeginWorkCheckMins); + params.add(JSONObject.toJSONString(otherinfo)); + + Map definedFieldInfo = new KQFormatBiz().getDefinedField(); + String[] definedFields = Util.splitString(Util.null2String(definedFieldInfo.get("definedField")),","); + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + for (int tmpIdx = 0; tmpIdx env = new HashMap<>(); + String keyname = ""; + while (matcher.find()) { + String key = matcher.group(0); + keyname = key.substring(2, key.length() - 1).trim(); + expression = matcher.replaceAll(keyname); + env.put(keyname, keyname.equals("beLateMins")?beLateMins:leaveEarlyMins); + } + Expression compiledExp = AviatorEvaluator.compile(expression,true); + String value = Util.null2String(compiledExp.execute(env)); + params.add(value); + if(value.equals("1")) { + params.add(keyname.equals("beLateMins") ? beLateMins : leaveEarlyMins); + }else{ + params.add("0"); + } + } + kqLog.info("format in >>>>>userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid + +":params:"+JSON.toJSONString(params)); + Long id = IdGenerator.generate(); + params.add(workTime.getDayType()); + params.add(date); + params.add(date); + params.add(id); + params.add(JSONObject.toJSONString(flowinfo)); +// if(isAmAbsent){ +// params.add(1); +// }else { +// params.add(0); +// } +// if(isPmAbsent){ +// params.add(1); +// }else { +// params.add(0); +// } + params.add(on_absenteeismMins); + params.add(off_absenteeismMins); + lsParam.add(params); + + resetAttendRepeatBeans(attendRepeatBeans); + //这个只是记录每个时段消耗的哺乳假,用完就清掉 + KQRepeatLengthContext.removeRepeatBeanLinkRange(); + //把每一段的请假时长记录一下 + allLeaveMins += leaveMins; + } + KQRepeatLengthContext.removeRepeatBean(); + KQRepeatLengthContext.clear(); + KQRepeatLengthContext.removeRepeatBeanLinkRange(); + + if(repeatLeaveMins > 0){ + if(allLeaveMins == 0){ + //哺乳假 有这种情况,没有迟到,也没有早退,allLeaveMins未0的情况 + if(CollectionUtils.isNotEmpty(lsParam)){ + List tmp = lsParam.get(0); + //目前请假时长是24位,以后有新增调整列一定要记得改这里的 + tmp.set(24, repeatLeaveMins); + } + } + } + } catch (Exception e) { + kqLog.info("考勤格式化生成数据报错:KQFormatData:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + return lsParam; + } + + /** + * 哺乳假被当前规则用完了之后,需要把late和early的已休时长重置一下 + * 为什么要在这里搞,因为前面迟到,严重迟到在判断的时候都需要用到原始数据,只有前面的判断都用完了,最后才能去更新 + * @param attendRepeatBeans + */ + private void resetAttendRepeatBeans(List attendRepeatBeans) { + if(CollectionUtils.isEmpty(attendRepeatBeans)){ + return ; + } + KQRepeatBean attendRepeatBeanLink = KQRepeatLengthContext.getRepeatBeanLink(); + if(attendRepeatBeanLink == null){ + return ; + } + Long repeatLateLink = attendRepeatBeanLink.getRepeatLateLink(); + Long repeatEarlyLink = attendRepeatBeanLink.getRepeatEarlyLink(); + for (int i = 0; i < attendRepeatBeans.size(); i++) { + KQRepeatBean attendRepeatBean = attendRepeatBeans.get(i); + Long repeatEarly = attendRepeatBean.getRepeatEarly(); + Long repeatLate = attendRepeatBean.getRepeatLate(); + if(repeatLateLink != null && repeatLateLink > 0 && repeatLate != null && repeatLate > 0){ + if(repeatLateLink > repeatLate){ + repeatLateLink = repeatLateLink - repeatLate; + attendRepeatBean.setRepeatLateLink(repeatLate); + }else{ + attendRepeatBean.setRepeatLateLink(repeatLateLink); + repeatLateLink= 0L; + } + } + if(repeatEarlyLink != null && repeatEarlyLink > 0 && repeatEarly != null && repeatEarly > 0){ + if(repeatEarlyLink > repeatEarly){ + repeatEarlyLink = repeatEarlyLink - repeatEarly; + attendRepeatBean.setRepeatEarlyLink(repeatEarly); + }else{ + attendRepeatBean.setRepeatEarlyLink(repeatEarlyLink); + repeatEarlyLink = 0L; + } + } + } + } + + /** + * 实际出勤里也要去除哺乳假的时长 + * @return + */ + private long getRepeatLeaveTime() { + long repeatLeaveTime = 0L; + KQRepeatBean attendRepeatBeanLink = KQRepeatLengthContext.getRepeatBeanLinkRange(); + if(attendRepeatBeanLink == null){ + return repeatLeaveTime; + } + Long repeatLateLink = attendRepeatBeanLink.getRepeatLateLink(); + Long repeatEarlyLink = attendRepeatBeanLink.getRepeatEarlyLink(); + if(repeatLateLink > 0){ + repeatLeaveTime = repeatLateLink; + } + if(repeatEarlyLink > 0){ + if(repeatLeaveTime > 0){ + repeatLeaveTime += repeatEarlyLink; + }else{ + repeatLeaveTime = repeatEarlyLink; + } + } + return repeatLeaveTime; + } + + /** + * 哺乳假针对异常时长部分的处理 + * @param attendRepeatBeans + * @param repeatLength + * @param type + * @return + */ + private long handleRepeatLength(List attendRepeatBeans, long repeatLength, String type) { + if(repeatLength <= 0){ + return repeatLength; + } + Long oriLength = repeatLength; + try{ +// 当天总消耗哺乳假 用于当天迟到早退 + KQRepeatBean attendRepeatBeanLink = KQRepeatLengthContext.getRepeatBeanLink(); +// 当前时段消耗哺乳假,用于计算缺勤 + KQRepeatBean attendRepeatBeanLinkRange = KQRepeatLengthContext.getRepeatBeanLinkRange(); + if(attendRepeatBeanLink == null){ + attendRepeatBeanLink = new KQRepeatBean(); + } + if(attendRepeatBeanLinkRange == null){ + attendRepeatBeanLinkRange = new KQRepeatBean(); + } + Long repeatLateLink = attendRepeatBeanLink.getRepeatLateLink(); + if(repeatLateLink == null){ + repeatLateLink = 0L; + } + Long repeatEarlyLink = attendRepeatBeanLink.getRepeatEarlyLink(); + if(repeatEarlyLink == null){ + repeatEarlyLink = 0L; + } + Long repeatLateLinkRange = attendRepeatBeanLinkRange.getRepeatLateLink(); + if(repeatLateLinkRange == null){ + repeatLateLinkRange = 0L; + } + Long repeatEarlyLinkRange = attendRepeatBeanLinkRange.getRepeatEarlyLink(); + if(repeatEarlyLinkRange == null){ + repeatEarlyLinkRange = 0L; + } + if(CollectionUtils.isNotEmpty(attendRepeatBeans)){ + for (int i = 0; i < attendRepeatBeans.size(); i++) { + KQRepeatBean attendRepeatBean = attendRepeatBeans.get(i); + if(oriLength <= 0){ + attendRepeatBeanLink.setRepeatLateLink(repeatLateLink); + attendRepeatBeanLink.setRepeatEarlyLink(repeatEarlyLink); + KQRepeatLengthContext.setRepeatBeanLink(attendRepeatBeanLink); + attendRepeatBeanLinkRange.setRepeatLateLink(repeatLateLinkRange); + attendRepeatBeanLinkRange.setRepeatEarlyLink(repeatEarlyLinkRange); + KQRepeatLengthContext.setRepeatBeanLinkRange(attendRepeatBeanLinkRange); + return oriLength; + } + if("late".equals(type)){ + Long repeatLate = attendRepeatBean.getRepeatLate(); + Long repeatLatTmp = attendRepeatBean.getRepeatLateLink(); + if(repeatLate != null){ + if(repeatLatTmp != null && repeatLatTmp > 0){ + repeatLate = repeatLate - repeatLatTmp; + repeatLate = repeatLate < 0 ? 0 : repeatLate; + } + oriLength = oriLength - repeatLate; + oriLength = oriLength < 0 ? 0 : oriLength; + if(oriLength == 0){ + //如果异常已经被每天重复时长完全抵扣了,那么需要更新下AttendRepeatBeanLink + repeatLateLink += repeatLength; + repeatLateLinkRange += repeatLength; + }else{ + repeatLateLink += repeatLate; + repeatLateLinkRange += repeatLate; + } + } + } + if("early".equals(type)){ + Long repeatEarly = attendRepeatBean.getRepeatEarly(); + Long repeatEarTmp = attendRepeatBean.getRepeatEarlyLink(); + if(repeatEarly != null){ + if(repeatEarTmp != null && repeatEarTmp > 0){ + repeatEarly = repeatEarly - repeatEarTmp; + repeatEarly = repeatEarly < 0 ? 0 : repeatEarly; + } + oriLength = oriLength - repeatEarly; + oriLength = oriLength < 0 ? 0 : oriLength; + if(oriLength == 0){ + //如果异常已经被每天重复时长完全抵扣了,那么需要更新下AttendRepeatBean + repeatEarlyLink += repeatLength; + repeatEarlyLinkRange += repeatLength; + }else{ + repeatEarlyLink += repeatEarly; + repeatEarlyLinkRange += repeatEarly; + } + } + } + } + } + + attendRepeatBeanLink.setRepeatLateLink(repeatLateLink); + attendRepeatBeanLink.setRepeatEarlyLink(repeatEarlyLink); + KQRepeatLengthContext.setRepeatBeanLink(attendRepeatBeanLink); + attendRepeatBeanLinkRange.setRepeatLateLink(repeatLateLinkRange); + attendRepeatBeanLinkRange.setRepeatEarlyLink(repeatEarlyLinkRange); + KQRepeatLengthContext.setRepeatBeanLinkRange(attendRepeatBeanLinkRange); + }catch (Exception e){ + kqLog.error("handleRepeatLength",e); + } + return oriLength; + } + + public int handleRepeatWorkFlowInfo(List workFlowRepeat, String repeatKey) { + int repeatLeaveMins = 0; + for (int j = 0; workFlowRepeat != null && j < workFlowRepeat.size(); j++) { + Map data = (Map) workFlowRepeat.get(j); + String repeatType = Util.null2String(data.get("repeatType")); + String repeatLate = Util.null2String(data.get("repeatLate")); + String repeatEarly = Util.null2String(data.get("repeatEarly")); + String newleavetype = Util.null2String(data.get("newleavetype")); + String leavetypeKey = repeatKey+"_"+newleavetype; + KQRepeatBean repeatBean = new KQRepeatBean(); + repeatBean.setRepeatType(repeatType); + if("0".equals(repeatType)){ + if(repeatLate.length() > 0){ + repeatBean.setRepeatLate(new Double(Double.valueOf(repeatLate)).longValue()); + repeatLeaveMins += new Double(Double.valueOf(repeatLate)).longValue(); + } + } + if("1".equals(repeatType)){ + if(repeatEarly.length() > 0){ + repeatBean.setRepeatEarly(new Double(Double.valueOf(repeatEarly)).longValue()); + repeatLeaveMins += new Double(Double.valueOf(repeatEarly)).longValue(); + } + } + if("2".equals(repeatType)){ + if(repeatLate.length() > 0){ + repeatBean.setRepeatLate(new Double(Double.valueOf(repeatLate)).longValue()); + repeatLeaveMins += new Double(Double.valueOf(repeatLate)).longValue(); + } + if(repeatEarly.length() > 0){ + repeatBean.setRepeatEarly(new Double(Double.valueOf(repeatEarly)).longValue()); + repeatLeaveMins += new Double(Double.valueOf(repeatEarly)).longValue(); + } + } + KQRepeatLengthContext.setKQRepeatBean(repeatKey,repeatBean); + KQRepeatLengthContext.setKQRepeatBean(leavetypeKey,repeatBean); + } + return repeatLeaveMins; + } + + public void setWriteLog(boolean writeLog) { + this.writeLog = writeLog; + } + + public Map getLogInfo() { + return logInfo; + } + + public void formatDateByKQDate(String kqdate) { + KQFormatBiz kqFormatBiz = new KQFormatBiz(); + kqFormatBiz.formatDateByKQDate(kqdate); + } + + public void formatDateByGroupId(String groupid, String kqdate) { + KQFormatBiz kqFormatBiz = new KQFormatBiz(); + kqFormatBiz.formatDateByGroupId(groupid, kqdate); + } + + public void formatDate(String resourceid, String kqdate) { + KQFormatBiz kqFormatBiz = new KQFormatBiz(); + kqFormatBiz.formatDate(resourceid, kqdate); + } + + public void delFormatData(String resourceid, String kqdate) { + KQFormatBiz kqFormatBiz = new KQFormatBiz(); + kqFormatBiz.delFormatData(resourceid, kqdate); + } + + /** + * 非工作日格式化考勤报表 + * @param userId + * @param kqDate + * @param nonlsParam + * @param workTime + * @param workFlowInfo + */ + public void formatNonWork(String userId, String kqDate, List nonlsParam, WorkTimeEntity workTime, Map workFlowInfo) { + String signInId = ""; + String signInDate = ""; + String signInTime = ""; + String signOutId = ""; + String signOutDate = ""; + String signOutTime = ""; + int beginIdx = 0; + int endIdx = 0; + int leaveMins = 0;//请假时长 + Map flowinfo = new HashMap<>();//流程信息 + Map leaveInfo = new HashMap<>();//请假信息 + int evectionMins = 0;//出差时长 + int outMins = 0;//公出时长 + int otherMins = 0;//异常流程时长 + int[] dayMins = new int[2880];//一天所有分钟数 + List workFlow = null; + String dateKey = userId + "|" + kqDate; + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + + String preDate = DateUtil.addDate(kqDate, -1);//上一天日期 + String nextDate = DateUtil.addDate(kqDate, 1);//下一天日期 + WorkTimeEntity pre_workTime = new KQWorkTime().getWorkTime(userId, preDate); + List pre_lsSignTime = new ArrayList<>(); + + if (pre_workTime != null) { + pre_lsSignTime = pre_workTime.getSignTime();//允许打卡时间 + pre_lsSignTime = pre_lsSignTime != null ? pre_lsSignTime : new ArrayList<>(); + } + WorkTimeEntity next_workTime = new KQWorkTime().getWorkTime(userId, nextDate); + List next_lsSignTime = new ArrayList<>(); + + if (next_workTime != null) { + next_lsSignTime = next_workTime.getSignTime();//允许打卡时间 + next_lsSignTime = next_lsSignTime != null ? next_lsSignTime : new ArrayList<>(); + } + + List lsCheckInfo = new KQFormatSignData().getNonWorkSignInfo(userId,preDate,kqDate,pre_lsSignTime,next_lsSignTime); + + for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) { + Map checkInfo = (Map) lsCheckInfo.get(j); + String signStatus = Util.null2String(checkInfo.get("signStatus")); + String signId = Util.null2String(checkInfo.get("signId")); + String signDate = Util.null2String(checkInfo.get("signDate")); + String signTime = Util.null2String(checkInfo.get("signTime")); + if (checkInfo.get("signType").equals("1")) {//签到 + signInId = signId; + signInDate = signDate; + signInTime = signTime; + } else if (checkInfo.get("signType").equals("2")) {//签退 + signOutId = signId; + signOutDate = signDate; + signOutTime = signTime; + } + } + + if (workFlowInfo.get(dateKey) != null) { + workFlow = (List) workFlowInfo.get(dateKey); + } + + for (int j = 0; workFlow != null && j < workFlow.size(); j++) { + Map data = (Map) workFlow.get(j); + String flowType = Util.null2String(data.get("flowtype")); + String newLeaveType = Util.null2String(data.get("newleavetype")); + String begintime = Util.null2String(data.get("begintime")); + String endtime = Util.null2String(data.get("endtime")); + beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + + if (beginIdx > endIdx) { + continue; + } + Map flowMap = Maps.newHashMap(); + flowMap.put("newLeaveType", newLeaveType); + flowMap.put("begintime", begintime); + flowMap.put("endtime", endtime); + List> flowMapList = Lists.newArrayList(); + if(flowinfo.containsKey(flowType)){ + List> tmpFlowMapList = (List>) flowinfo.get(flowType); + tmpFlowMapList.add(flowMap); + }else{ + flowMapList.add(flowMap); + flowinfo.put(flowType, flowMapList); + } + if(flowType.equals(FlowReportTypeEnum.EVECTION.getFlowType())){ + Arrays.fill(dayMins, beginIdx, endIdx, 7);//出差抵扣时段标识 7 + }else if(flowType.equals(FlowReportTypeEnum.OUT.getFlowType())){ + Arrays.fill(dayMins, beginIdx, endIdx, 8);//公出抵扣时段标识 8 + }else if(flowType.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())){ + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 5);//流程抵扣时段标识 5 + int tmpBeginIdx = beginIdx; + int tmpEndIdx = endIdx; + Integer val = 0; + if(leaveInfo.get(newLeaveType)==null){ + leaveInfo.put(newLeaveType,val); + }else{ + val = (Integer) leaveInfo.get(newLeaveType); + } + if(tmpEndIdx>tmpBeginIdx){ + leaveInfo.put(newLeaveType,val+(tmpEndIdx-tmpBeginIdx)); + } + } + }else{ + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 99);//异常流程抵扣时段标识99 + } + } + } + + for (int j = 0; j < 2880; j++) { + switch (dayMins[j]) { + case 5: + leaveMins++; + break; + case 7: + evectionMins++; + break; + case 8: + outMins++; + break; + case 99: + otherMins++; + break; + default: + break; + } + } + + nonlsParam.add(userId); + nonlsParam.add(kqDate); + nonlsParam.add(workTime.getGroupId()); + nonlsParam.add(0); + nonlsParam.add(signInDate); + nonlsParam.add(signInTime); + nonlsParam.add(signInId.length() == 0 ? null : signInId); + nonlsParam.add(signOutDate); + nonlsParam.add(signOutTime); + nonlsParam.add(signOutId.length() == 0 ? null : signOutId); + nonlsParam.add(leaveMins); + nonlsParam.add(JSONObject.toJSONString(leaveInfo)); + nonlsParam.add(evectionMins); + nonlsParam.add(outMins); + nonlsParam.add(workTime.getDayType()); + Timestamp date = new Timestamp(System.currentTimeMillis()); + Long id = IdGenerator.generate(); + nonlsParam.add(date); + nonlsParam.add(date); + nonlsParam.add(id); + nonlsParam.add(JSONObject.toJSONString(flowinfo)); + } +} diff --git a/src/com/engine/kq/biz/KQFormatDateChangeJob.java b/src/com/engine/kq/biz/KQFormatDateChangeJob.java new file mode 100644 index 0000000..a5b182a --- /dev/null +++ b/src/com/engine/kq/biz/KQFormatDateChangeJob.java @@ -0,0 +1,48 @@ +package com.engine.kq.biz; + +import com.engine.kq.log.KQLog; +import java.util.List; +import org.apache.commons.compress.utils.Lists; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.tools.HrmDateCheck; +import weaver.interfaces.schedule.BaseCronJob; + +/** + * 格式化入职日期、离职日期发生变化的考勤数据 + */ +public class KQFormatDateChangeJob extends BaseCronJob{ + private KQLog kqLog = new KQLog(); + + + @Override + public void execute() { + RecordSet rs = new RecordSet(); + try{ + kqLog.info("begin do KQFormatDateChangeJob invoke ..."); + + List upSqls = Lists.newArrayList(); + RecordSet rs1 = new RecordSet(); + String sql = "select * from kq_date_change_log where status ='0'"; + kqLog.info("begin do KQFormatDateChangeJob invoke ...sql::"+sql); + rs1.execute(sql); + while (rs1.next()){ + String id = Util.null2String(rs1.getString("id")); + String resourceid = Util.null2String(rs1.getString("resourceid")); + String changefromdate = Util.null2String(rs1.getString("changefromdate")); + String changetodate = Util.null2String(rs1.getString("changetodate")); + kqLog.info("KQScheduleFormatJob:id:"+id+":resourceid:"+resourceid+":changefromdate:"+changefromdate+":changetodate:"+changetodate); + new HrmDateCheck().calKqData(changefromdate,changetodate,resourceid); + String upsql = "update kq_date_change_log set status='1' where id = "+id; + upSqls.add(upsql); + } + + for (String upsql :upSqls) { + rs1.executeUpdate(upsql); + } + kqLog.info("end do KQFormatDateChangeJob invoke ..."); + }catch (Exception e) { + kqLog.info(e) ; + } + } +} diff --git a/src/com/engine/kq/biz/KQFormatFreeData.java b/src/com/engine/kq/biz/KQFormatFreeData.java new file mode 100644 index 0000000..079d27b --- /dev/null +++ b/src/com/engine/kq/biz/KQFormatFreeData.java @@ -0,0 +1,358 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.jucailin.genid.IdGenerator; +import com.google.common.collect.Lists; +import java.sql.Date; +import java.sql.Timestamp; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.log.KQLog; +import com.google.common.collect.Maps; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; + +/** + * 格式化自由工时数据 + */ +public class KQFormatFreeData extends BaseBean{ + private static DecimalFormat df = new DecimalFormat("0.00"); + protected KQLog kqLog = new KQLog(); + + /** + * + * @param userId + * @param kqDate + * @param workFlowInfo + * @return + */ + public List> format(String userId, String kqDate, Map workFlowInfo){ + List> lsParam = new ArrayList<>(); + List params = new ArrayList<>(); + try{ + Timestamp date = new Timestamp(System.currentTimeMillis()); + int workMins = 0; + String signInId = ""; + String signInDate = ""; + String signInTime = ""; + String signOutId = ""; + String signOutDate = ""; + String signOutTime = ""; + + String temp_signInDate = ""; + String temp_signInTime = ""; + String temp_signOutDate = ""; + String temp_signOutTime = ""; + + String cal_signInId = ""; + String cal_signInDate = ""; + String cal_signInTime = ""; + String cal_signOutId = ""; + String cal_signOutDate = ""; + String cal_signOutTime = ""; + + int signMins = 0; + int attendanceMins=0; + String serialid = ""; + String groupid = ""; + int beLateMins = 0; + int graveBeLateMins = 0; + int leaveEarlyMins =0; + int graveLeaveEarlyMins =0; + int absenteeismMins =0; + int leaveMins = 0;//请假时长 + int evectionMins = 0;//出差时长 + int outMins = 0;//公出时长 + Map leaveInfo = new HashMap<>();//请假信息 + Map otherinfo = new HashMap<>();//存一些用得到的信息 + Map flowinfo = new HashMap<>();//流程信息 + + KQWorkTime kqWorkTime = new KQWorkTime(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + + int workBeginIdx = 0; + int beginIdx = 0; + int endIdx = 0; + String dateKey = userId +"|"+ kqDate; + String nextDate = DateUtil.addDate(kqDate, 1); + + List workFlow = null; + WorkTimeEntity workTime = kqWorkTime.getWorkTime(userId,kqDate); + String signstart = ""; + String calmethod = "2"; + if(workTime!=null) { + groupid = Util.null2String(workTime.getGroupId()); + signstart = Util.null2String(workTime.getSignStart());//签到开始时间 + workMins = Util.getIntValue(Util.null2String(workTime.getWorkMins()));//工作时长 + workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(signstart); + calmethod = Util.null2s(workTime.getCalmethod(),"1");//自由班制计算方式 + } +// 弹性工作制是否可以跨天 + boolean isFreezeAcross = KQSettingsBiz.is_freeAcross(); + + int kqSize = 1440; + if(isFreezeAcross){ + kqSize = kqTimesArrayComInfo.getIndexSize(); + } + int[] dayMins = new int[kqSize];//一天所有分钟数 + + if(workFlowInfo.get(dateKey)!=null){ + workFlow = (List)workFlowInfo.get(dateKey); + } + + for(int j=0;workFlow!=null&&j data = (Map) workFlow.get(j); + String flowType = Util.null2String(data.get("flowtype")); + String newLeaveType = Util.null2String(data.get("newleavetype")); + String begintime = Util.null2String(data.get("begintime")); + String endtime = Util.null2String(data.get("endtime")); + beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + + Map flowMap = Maps.newHashMap(); + flowMap.put("newLeaveType", newLeaveType); + flowMap.put("begintime", begintime); + flowMap.put("endtime", endtime); + List> flowMapList = Lists.newArrayList(); + if(flowinfo.containsKey(flowType)){ + List> tmpFlowMapList = (List>) flowinfo.get(flowType); + tmpFlowMapList.add(flowMap); + }else{ + flowMapList.add(flowMap); + flowinfo.put(flowType, flowMapList); + } + if(flowType.equals(FlowReportTypeEnum.EVECTION.getFlowType())){ + Arrays.fill(dayMins, beginIdx, endIdx, 7);//出差抵扣时段标识 7 + }else if(flowType.equals(FlowReportTypeEnum.OUT.getFlowType())){ + Arrays.fill(dayMins, beginIdx, endIdx, 8);//公出抵扣时段标识 8 + }else{ + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 5);//流程抵扣时段标识 5 + if(flowType.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())){ + int tmpBeginIdx = beginIdx; + int tmpEndIdx = endIdx; + int val = 0; + if(leaveInfo.get(newLeaveType)==null){ + leaveInfo.put(newLeaveType,val); + }else{ + val = leaveInfo.get(newLeaveType); + } + if(beginIdxtmpBeginIdx){ + leaveInfo.put(newLeaveType,val+(tmpEndIdx-tmpBeginIdx)); + } + } + } + } + } + + String signBeginDateTime = kqDate + " "+ signstart+":00"; + String signEndDateTime = kqDate + " 23:59:59"; + if(isFreezeAcross){ + signEndDateTime = nextDate + " "+ signstart+":00"; + } + String workBeginDateTime = ""; + String workEndDateTime = ""; + List lsCheckInfo = new KQFormatSignData().getSignInfoForAll(userId,signBeginDateTime,signEndDateTime,workBeginDateTime,workEndDateTime); + + if("2".equalsIgnoreCase(calmethod)){ + //成对出现 + if(!lsCheckInfo.isEmpty()) { + if(lsCheckInfo.size()%2==1 && lsCheckInfo.size() > 1){ + lsCheckInfo.remove(lsCheckInfo.size()-1); + } + } + }else{ + if(!lsCheckInfo.isEmpty()) { + List tmplsCheckInfo = Lists.newArrayList(); + tmplsCheckInfo.add(lsCheckInfo.get(0)); + if(lsCheckInfo.size()>1) { + tmplsCheckInfo.add(lsCheckInfo.get(lsCheckInfo.size() - 1)); + } + lsCheckInfo.clear(); + lsCheckInfo.addAll(tmplsCheckInfo); + } + } + + for (int i = 0; i checkInfo = (Map) lsCheckInfo.get(i); + String signId = Util.null2String(checkInfo.get("signId")); + String signDate = Util.null2String(checkInfo.get("signDate")); + String signTime = Util.null2String(checkInfo.get("signTime")); + if (signTime.length() > 8) { + signTime = signTime.substring(0, 8); + } + + //用于计算打卡时长 + if (checkInfo.get("signType").equals("1")) {//签到 + temp_signInDate = signDate; + if(temp_signInDate.compareTo(kqDate) > 0){ + temp_signInTime = kqTimesArrayComInfo.turn24to48Time(signTime); + }else{ + temp_signInTime = signTime; + } + } else if (checkInfo.get("signType").equals("2")) {//签退 + temp_signOutDate = signDate; + if(temp_signOutDate.compareTo(kqDate) > 0){ + temp_signOutTime = kqTimesArrayComInfo.turn24to48Time(signTime); + }else{ + temp_signOutTime = signTime; + } + } + + if (i==0 && checkInfo.get("signType").equals("1")) {//签到 + signInId = signId; + signInDate = signDate; + signInTime = signTime; + if(temp_signInDate.compareTo(kqDate) > 0){ + temp_signInTime = kqTimesArrayComInfo.turn24to48Time(signTime); + }else{ + temp_signInTime = signTime; + } + } else if (i==lsCheckInfo.size()-1&&checkInfo.get("signType").equals("2")) {//签退 + signOutId = signId; + signOutDate = signDate; + signOutTime = signTime; + } + + if("2".equalsIgnoreCase(calmethod)){ + if(i%2==1){ + beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(temp_signInTime); + endIdx = kqTimesArrayComInfo.getArrayindexByTimes(temp_signOutTime); + if(endIdx>beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 1);//工作时段标识 1 + } + } + }else{ + if(i == 0){ + cal_signInId = signId; + cal_signInDate = signDate; + cal_signInTime = signTime; + }else { + cal_signOutId = signId; + cal_signOutDate = signDate; + cal_signOutTime = signTime; + } + } + } + + if("1".equalsIgnoreCase(calmethod)){ + beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(cal_signInTime); + endIdx = kqTimesArrayComInfo.getArrayindexByTimes(cal_signOutTime); + if(cal_signInDate.compareTo(kqDate) > 0){ + beginIdx = kqTimesArrayComInfo.turn24to48TimeIndex(beginIdx); + } + if(cal_signOutDate.compareTo(kqDate) > 0){ + endIdx = kqTimesArrayComInfo.turn24to48TimeIndex(endIdx); + } + if(endIdx>beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 1);//工作时段标识 1 + } + signInId = cal_signInId; + signInDate = cal_signInDate; + signInTime = cal_signInTime; + signOutId = cal_signOutId; + signOutDate = cal_signOutDate; + signOutTime = cal_signOutTime; + } + + int workFlowMins = 0; + for(int i=workBeginIdx;iworkMins)attendanceMins=workMins; + + absenteeismMins = workMins - attendanceMins-leaveMins; + if(absenteeismMins<0){ + absenteeismMins=0; + } + + if (workTime.getIsExclude()) {//无需考勤人员没有异常状态 + attendanceMins = workMins; + beLateMins = 0; + graveBeLateMins = 0; + leaveEarlyMins = 0; + graveLeaveEarlyMins = 0; + absenteeismMins = 0; + } + + params.add(userId); + params.add(kqDate); + params.add(groupid.length() == 0 ? null : groupid); + params.add(serialid.length() == 0 ? null : serialid); + params.add(0); + params.add(null); + params.add(null); + params.add(null); + params.add(null); + params.add(workMins); + params.add(signInDate); + params.add(signInTime); + params.add(signInId.length() == 0 ? null : signInId); + params.add(signOutDate); + params.add(signOutTime); + params.add(signOutId.length() == 0 ? null : signOutId); + params.add(signMins); + params.add(attendanceMins); + params.add(beLateMins); + params.add(graveBeLateMins); + params.add(leaveEarlyMins); + params.add(graveLeaveEarlyMins); + params.add(absenteeismMins); + params.add(null); + params.add(leaveMins); + params.add(JSONObject.toJSONString(leaveInfo)); + params.add(evectionMins); + params.add(outMins); + params.add(null); + params.add(JSONObject.toJSONString(otherinfo)); + Long id = IdGenerator.generate(); + params.add(workTime.getDayType()); + params.add(date); + params.add(date); + params.add(id); + params.add(JSONObject.toJSONString(flowinfo)); + if(absenteeismMins<=0) { + params.add(0); + params.add(0); + } else { + params.add(attendanceMins/2); + params.add(attendanceMins/2); + } + lsParam.add(params); + }catch (Exception e){ + writeLog(e); + kqLog.info(e); + } + return lsParam; + } +} diff --git a/src/com/engine/kq/biz/KQFormatJob.java b/src/com/engine/kq/biz/KQFormatJob.java new file mode 100644 index 0000000..b14fb50 --- /dev/null +++ b/src/com/engine/kq/biz/KQFormatJob.java @@ -0,0 +1,87 @@ +package com.engine.kq.biz; + +import com.engine.kq.log.KQLog; +import com.weaver.util.threadPool.ThreadPoolUtil; +import com.weaver.util.threadPool.constant.ModulePoolEnum; +import weaver.common.DateUtil; +import weaver.conn.ConnStatement; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.general.WArrayList; + +import java.util.TimerTask; + +/** + * 考勤数据格式化定时任务 + */ +public class KQFormatJob extends TimerTask { + private static KQFormatJob instance = new KQFormatJob(); + public static WArrayList kqformatIds = new WArrayList(); + private static boolean flag = false; + private KQLog kqLog = new KQLog(); + + public static KQFormatJob getInstance(){ + return instance; + } + + public void run() { + KQFormatThread kqFormatThread = null; + ConnStatement cs = new ConnStatement(); + String sql = ""; + try{ + if(flag) return; + flag = true; + if(kqformatIds.size()>0){ + flag = false; + return; + } + sql = " select id, kqdate, resourceid,formattype from kq_format_pool where status = 0 order by kqdate, resourceid asc"; + boolean kqformatAccurate = KQSettingsBiz.getKqformatAccurate(); + if (kqformatAccurate){ + String currentFullTime = DateUtil.getFullDate(); + RecordSet rs = new RecordSet(); + if(rs.getDBType().equals("oracle")){ + sql = " select id, kqdate, resourceid,exectime,formattype from kq_format_pool where status = 0 and exectime is not null and exectime < to_date('"+currentFullTime+"','yyyy-mm-dd hh24:mi:ss') order by kqdate, resourceid, exectime asc"; + } + else if(rs.getDBType().equals("postgresql")){ + sql = " select id, kqdate, resourceid,exectime,formattype from kq_format_pool where status = 0 and exectime is not null and exectime < TO_TIMESTAMP('"+currentFullTime+"','yyyy-mm-dd hh24:mi:ss') order by kqdate, resourceid, exectime asc"; + } + else if (rs.getDBType().equals("mysql")) { + sql = " select id, kqdate, resourceid,exectime,formattype from kq_format_pool where status = 0 and exectime is not null and exectime>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + cs.getString("id") + "==" + cs.getString("kqdate") + "==" + cs.getString("resourceid") + "==" + cs.getString("exectime")); + }else{ + kqLog.info(Thread.currentThread().getId() + "===KQFormatJob in>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + cs.getString("id") + "==" + cs.getString("kqdate") + "==" + cs.getString("resourceid")); + } + ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.HRM, "KQFormatJob", kqFormatThread); + } + + flag = false; + }catch (Exception e){ + flag = false; + new BaseBean().writeLog(e); + kqLog.info("考勤数据格式化定时任务错误:",e); + }finally { + try { + cs.close(); + }catch(Exception ex) {new BaseBean().writeLog("关闭考勤数据格式化定时任务数据库链接错误");} + } + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQFormatShiftRule.java b/src/com/engine/kq/biz/KQFormatShiftRule.java new file mode 100644 index 0000000..c592a00 --- /dev/null +++ b/src/com/engine/kq/biz/KQFormatShiftRule.java @@ -0,0 +1,561 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum; +import com.engine.kq.entity.KQShiftRuleEntity; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.TimeSignScopeEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; + +import java.util.*; + +/** + * 格式化数据 人性化规则 + */ +public class KQFormatShiftRule extends BaseBean { + private KQLog kqLog = new KQLog(); + + public KQShiftRuleEntity doShiftRule(WorkTimeEntity workTime, KQShiftRuleEntity kqShiftRuleEntity) { + Map shiftRuleInfo = workTime.getShiftRuleInfo(); + //人性化处理 + if (shiftRuleInfo != null && shiftRuleInfo.size() > 0) { + Map ruleDetail = (Map) shiftRuleInfo.get("ruleDetail"); + //允许迟到分钟数 + boolean usepermitlateminutes = Util.null2String(shiftRuleInfo.get("permitlatestatus")).equals("1"); + int permitlateminutes = Util.getIntValue(Util.null2String(shiftRuleInfo.get("permitlateminutes")), 0); + boolean enableexcludelate = Util.null2String(shiftRuleInfo.get("enableexcludelate")).equals("1"); + //允许早退分钟数 + boolean usepermitleaveearlyminutes = Util.null2String(shiftRuleInfo.get("permitleaveearlystatus")).equals("1"); + int permitleaveearlyminutes = Util.getIntValue(Util.null2String(shiftRuleInfo.get("permitleaveearlyminutes")), 0); + boolean enableexcludeleaveearly = Util.null2String(shiftRuleInfo.get("enableexcludeleaveearly")).equals("1"); + + //严重迟到分钟数 + boolean useseriouslateminutes = Util.null2String(shiftRuleInfo.get("seriouslatestatus")).equals("1"); + int seriouslateminutes = Util.getIntValue(Util.null2String(shiftRuleInfo.get("seriouslateminutes")), 0); + //严重早退分钟数 + boolean useseriousleaveearlyminutes = Util.null2String(shiftRuleInfo.get("seriousleaveearlystatus")).equals("1"); + int seriousleaveearlyminutes = Util.getIntValue(Util.null2String(shiftRuleInfo.get("seriousleaveearlyminutes")), 0); + //迟到多少钟数算旷工 + boolean uselateabsentminutes = Util.null2String(shiftRuleInfo.get("lateabsentstatus")).equals("1"); + int lateabsentminutes = Util.getIntValue(Util.null2String(shiftRuleInfo.get("lateabsentminutes")), 0); + //早退多少钟数算旷工 + boolean useleaveearlyabsentminutes = Util.null2String(shiftRuleInfo.get("leaveearlyabsentstatus")).equals("1"); + int leaveearlyabsentminutes = Util.getIntValue(Util.null2String(shiftRuleInfo.get("leaveearlyabsentminutes")), 0); + //允许下班不打卡 + boolean isoffdutyfreecheck = Util.null2String(shiftRuleInfo.get("isoffdutyfreecheck")).equals("1"); + + String userId = kqShiftRuleEntity.getUserId(); + String kqDate = kqShiftRuleEntity.getKqDate(); + int beLateMins = kqShiftRuleEntity.getBelatemins(); + int graveBeLateMins = 0; + int leaveEarlyMins = kqShiftRuleEntity.getLeaveearlymins(); + int graveLeaveEarlyMins = 0; + int absenteeismMins = kqShiftRuleEntity.getAbsenteeismmins(); + int forgotcheckMins = kqShiftRuleEntity.getForgotcheckmins(); + int forgotBeginWorkCheckMins = kqShiftRuleEntity.getForgotBeginWorkCheckMins(); + int earlyInMins = kqShiftRuleEntity.getEarlyInMins(); + int lateOutMins = kqShiftRuleEntity.getLateOutMins(); + String nosign_is_absent = kqShiftRuleEntity.getNosign_is_absent(); + String early_one_mins = kqShiftRuleEntity.getEarly_one_mins(); + String signInTime = kqShiftRuleEntity.getSignInTime(); + String signOutTime = kqShiftRuleEntity.getSignOutTime(); + + + + List earlyinearlyout = null;//早到早走规则 + List lateinlateout = null;//晚到晚走规则 + List lateoutlatein = null;//晚走晚到规则 + + //这里个性化没法处理流程数据,逻辑改为在前面直接虚拟改掉了上下班时间 + if (ruleDetail != null && ruleDetail.size() > 0 && false) {//处理人性化设置其他规则 + earlyinearlyout = (List) ruleDetail.get("earlyinearlyout"); + lateinlateout = (List) ruleDetail.get("lateinlateout"); + lateoutlatein = (List) ruleDetail.get("lateoutlatein"); + + if (earlyinearlyout != null && earlyinearlyout.size() > 0 && leaveEarlyMins > 0) { + for (int i = 0; earlyInMins > 0 && i < earlyinearlyout.size(); i++) { + Map rule = (Map) earlyinearlyout.get(i); + if (Util.null2String(rule.get("enable")).equals("1")) { + int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//早到时间 + int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//允许早走时间 + if (Util.null2String(rule.get("enablesame")).equals("1")) { + if (earlyInMins > postponetime) { + leaveEarlyMins -= postponetime; + if (leaveEarlyMins < 0) leaveEarlyMins = 0; + } else { + leaveEarlyMins -= earlyInMins; + if (leaveEarlyMins < 0) leaveEarlyMins = 0; + } + break; + } else { + if (earlyInMins >= advancetime) { + leaveEarlyMins -= postponetime; + if (leaveEarlyMins < 0) leaveEarlyMins = 0; + break; + } + } + } + } + } + + if (lateinlateout != null && lateinlateout.size() > 0 && beLateMins > 0) { + for (int i = 0; lateOutMins > 0 && i < lateinlateout.size(); i++) { + Map rule = (Map) lateinlateout.get(i); + if (Util.null2String(rule.get("enable")).equals("1")) { + int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//晚到时间 + int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//需要晚走时间 + if (Util.null2String(rule.get("enablesame")).equals("1")) { + if (lateOutMins > postponetime) { + beLateMins -= postponetime; + if (beLateMins < 0) beLateMins = 0; + } else { + beLateMins -= lateOutMins; + if (beLateMins < 0) beLateMins = 0; + } + break; + } else { + if (lateOutMins >= postponetime) { + beLateMins -= advancetime; + if (beLateMins < 0) beLateMins = 0; + break; + } + } + } + } + } + + if (lateoutlatein != null && lateoutlatein.size() > 0 && beLateMins > 0) { + int preDayLateOutMins = getPreDayLateOutMins(userId, kqDate); + for (int i = 0; preDayLateOutMins > 0 && i < lateoutlatein.size(); i++) { + Map rule = (Map) lateoutlatein.get(i); + if (Util.null2String(rule.get("enable")).equals("1")) { + int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//晚走时间 + int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//允许晚到时间 + + if (Util.null2String(rule.get("enablesame")).equals("1")) { + if (preDayLateOutMins > postponetime) { + beLateMins -= postponetime; + if (beLateMins < 0) beLateMins = 0; + } else { + beLateMins -= preDayLateOutMins; + if (beLateMins < 0) beLateMins = 0; + } + break; + } else { + if (preDayLateOutMins >= advancetime) { + beLateMins -= postponetime; + if (beLateMins < 0) beLateMins = 0; + break; + } + } + } + } + } + } + + if (beLateMins > 0) {//迟到人性化设置 + if (usepermitlateminutes) {//允许迟到分钟数 + if (permitlateminutes >= beLateMins) { + beLateMins = 0; + } else if (enableexcludelate) { + beLateMins = beLateMins - permitlateminutes; + } + } + + if (uselateabsentminutes && beLateMins >= lateabsentminutes) {//旷工 + absenteeismMins += beLateMins; + beLateMins = 0; + kqShiftRuleEntity.setOn_absenteeismMins(absenteeismMins); + kqShiftRuleEntity.setAMAbsent(true); + //leaveEarlyMins = 0; + if ("1".equals(nosign_is_absent)) { + /** + * 在漏签算实际出勤的情况,才需要清空漏签时长(forgotcheckMins),原由如下:比如09:00--18:00,这是11:00打上班卡,下班卡没有打卡 + * 情况1:没有开启迟到或者早退算旷工的情况,正常应该显示:【迟到120分钟 漏签】,这时候实际出勤应该是0 + * 情况2:开启了迟到60分钟算旷工之后,应该显示【旷工120分钟 漏签】,这时候实际出勤应该是0。而如果清空漏签时长(forgotcheckMins) ,那么就有实际出勤时长了,因为实际出勤=应出勤-迟到-早退-旷工-请假-漏签时长 + * 所以:在漏签算实际出勤的时候才需要清空,也就原标准逻辑,反之不需要清空 + * , + */ + forgotcheckMins = 0; + } else { + kqShiftRuleEntity.setNosign_ishandle("1"); + } + } else if (useseriouslateminutes && beLateMins >= seriouslateminutes) {//严重迟到 + graveBeLateMins += beLateMins; + //TODO 这有个问题,严重迟到了,还要不要算迟到?这两个是同时存在的吗? + beLateMins = 0; + } + } + + if (leaveEarlyMins > 0) {//早退人性化设置 + if (usepermitleaveearlyminutes) {//允许早退分钟数 + if (permitleaveearlyminutes >= leaveEarlyMins) { + leaveEarlyMins = 0; + } else if (enableexcludeleaveearly) { + leaveEarlyMins = leaveEarlyMins - permitleaveearlyminutes; + } + } + if (useleaveearlyabsentminutes && leaveEarlyMins >= leaveearlyabsentminutes) {//旷工 + absenteeismMins += leaveEarlyMins; + //beLateMins = 0; + leaveEarlyMins = 0; + kqShiftRuleEntity.setOff_absenteeismMins(absenteeismMins); + kqShiftRuleEntity.setPMAbsent(true); + if ("1".equals(nosign_is_absent)) { + /** + * 在漏签算实际出勤的情况,才需要清空漏签时长(forgotcheckMins),原由如下:比如09:00--18:00,这是11:00打上班卡,下班卡没有打卡 + * 情况1:没有开启迟到或者早退算旷工的情况,正常应该显示:【迟到120分钟 漏签】,这时候实际出勤应该是0 + * 情况2:开启了迟到60分钟算旷工之后,应该显示【旷工120分钟 漏签】,这时候实际出勤应该是0。而如果清空漏签时长(forgotcheckMins) ,那么就有实际出勤时长了,因为实际出勤=应出勤-迟到-早退-旷工-请假-漏签时长 + * 所以:在漏签算实际出勤的时候才需要清空,也就原标准逻辑,反之不需要清空 + * , + */ + forgotcheckMins = 0; + forgotBeginWorkCheckMins = 0; + } else { + kqShiftRuleEntity.setNosign_ishandle("2"); + } + + } else if (useseriousleaveearlyminutes && leaveEarlyMins >= seriousleaveearlyminutes) {//严重早退 + graveLeaveEarlyMins += leaveEarlyMins; + //TODO 这有个问题,严重早退了,还要不要算早退?这两个是同时存在的吗? + leaveEarlyMins = 0; + } + } + //允许下班不打卡 + if (isoffdutyfreecheck) { + forgotcheckMins = 0; + } + + /** + * 含泪加上 + * 晚到晚走导致的早退1分钟特殊处理下, + * 2024-02-28 上班时间是:2024-02-28 08:30:00,签到时间是:2024-02-28 08:34:26,晚到5分钟, 开启了晚到晚走,相对时间 + * 所以2024-02-28的上班时间和下班时间变化了,上班时间变成了:2024-02-28 08:35,下班时间变成了:2024-02-28 17:35 + * 现在签到是08:34:26,签退是17:34:48,导致早退1分钟 + */ + if("1".equals(early_one_mins)){ + if (ruleDetail != null && ruleDetail.size() > 0) {//处理人性化设置其他规则 + earlyinearlyout = (List) ruleDetail.get("earlyinearlyout"); + lateinlateout = (List) ruleDetail.get("lateinlateout"); + } + + String signInTime_Sec = (signInTime != null && signInTime.length() == 8) ? signInTime.substring(6, 8) : ""; + String signOutTime_Sec = (signOutTime != null && signOutTime.length() == 8) ? signOutTime.substring(6, 8) : ""; + writeLog("signInTime="+signInTime+",signInTime_Sec="+signInTime_Sec+",signOutTime="+signOutTime+",signOutTime_Sec="+signOutTime_Sec+",leaveEarlyMins="+leaveEarlyMins); +// writeLog("leaveEarlyMins="+leaveEarlyMins+",lateinlateout="+JSONObject.toJSONString(lateinlateout)); + if (((lateinlateout != null && lateinlateout.size() > 0)||(earlyinearlyout != null && earlyinearlyout.size() > 0)) + && leaveEarlyMins == 1) { + if (signInTime_Sec.compareTo(signOutTime_Sec) <= 0) { + leaveEarlyMins = 0; + } + } + } +// writeLog("leaveEarlyMins="+leaveEarlyMins+",early_one_mins="+early_one_mins); + + kqShiftRuleEntity.setBelatemins(beLateMins); + kqShiftRuleEntity.setGravebelatemins(graveBeLateMins); + kqShiftRuleEntity.setLeaveearlymins(leaveEarlyMins); + kqShiftRuleEntity.setGraveleaveearlymins(graveLeaveEarlyMins); + kqShiftRuleEntity.setAbsenteeismmins(absenteeismMins); + kqShiftRuleEntity.setForgotcheckmins(forgotcheckMins); + kqShiftRuleEntity.setForgotBeginWorkCheckMins(forgotBeginWorkCheckMins); + } + return kqShiftRuleEntity; + } + public int getEarlyInMins(String userId, String kqDate) { + return getEarlyInMins(userId,kqDate,0); + } + + public int getEarlyInMins(String userId, String kqDate,int signoutOnlyoff) { + int earlyInMins = 0; + boolean oneSign = false; + String preDate = DateUtil.addDate(kqDate, -1);//上一天日期 + String nextDate = DateUtil.addDate(kqDate, 1);//下一天日期 + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTime = kqWorkTime.getWorkTime(userId, kqDate); + List lsSignTime = new ArrayList<>(); + List lsWorkTime = new ArrayList<>(); + if (workTime != null) { + lsSignTime = workTime.getSignTime();//允许打卡时间 + lsWorkTime = workTime.getWorkTime();//工作时间 + oneSign = lsWorkTime != null && lsWorkTime.size() == 1; + } + + if (oneSign) { + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + TimeScopeEntity signTimeScope = lsSignTime.get(0); + TimeScopeEntity workTimeScope = lsWorkTime.get(0); + int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workTimeScope.getBeginTime()); + + List lsCheckInfo = new KQFormatSignData().getSignInfo(userId, signTimeScope, workTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo + ,Lists.newArrayList(), "",0,0,signoutOnlyoff); + for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) { + Map checkInfo = (Map) lsCheckInfo.get(j); + String signDate = Util.null2String(checkInfo.get("signDate")); + String signTime = Util.null2String(checkInfo.get("signTime")); + String deduct_signintime = Util.null2String(checkInfo.get("deduct_signintime")); + if (checkInfo.get("signType").equals("1")) {//签到 + //有签到但是没有signTime是因为开启了流程抵扣打卡 + if (null == signTime || signTime.length() < 5) { + continue; + } else { + writeLog("signDate:" + signDate + ",signTime=" + signTime + ",checkInfo=" + checkInfo.toString()); + } + String signMinTime = signTime.substring(0, 5) + ":00"; + boolean signInWorkBeginTime = false; + if (signTime.compareTo(signMinTime) > 0) { + //如果签到时间是带秒的且是迟到,那么签到时间多一秒和多一分钟是一样的 + signInWorkBeginTime = true; + } + String signInTime = signTime; + int signInTimeIndx = kqTimesArrayComInfo.getArrayindexByTimes(signInTime); + String flow_signInTime = ""; + if (deduct_signintime.length() > 0) { + if (signTime.length() > 0) { + if (deduct_signintime.compareTo(signTime) < 0) { + flow_signInTime = deduct_signintime; + } + } else { + flow_signInTime = deduct_signintime; + } + } + if (flow_signInTime.length() > 0) { + signInTimeIndx = kqTimesArrayComInfo.getArrayindexByTimes(flow_signInTime); + } + if (kqDate.compareTo(signDate) < 0) signInTimeIndx += 1440; + if (signInWorkBeginTime) { + signInTimeIndx = signInTimeIndx + 1; + } + if (workBeginIdx > signInTimeIndx) { + earlyInMins = workBeginIdx - signInTimeIndx; + } + } + } + } + return earlyInMins; + } + + public int getLateOutMins(String userId, String kqDate) { + return getLateOutMins(userId,kqDate,0); + } + + public int getLateOutMins(String userId, String kqDate,int signoutOnlyoff) { + int lateOutMins = 0; + boolean oneSign = false; + String preDate = DateUtil.addDate(kqDate, -1);//上一天日期 + String nextDate = DateUtil.addDate(kqDate, 1);//下一天日期 + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTime = kqWorkTime.getWorkTime(userId, kqDate); + List lsSignTime = new ArrayList<>(); + List lsWorkTime = new ArrayList<>(); + if (workTime != null) { + lsSignTime = workTime.getSignTime();//允许打卡时间 + lsWorkTime = workTime.getWorkTime();//工作时间 + oneSign = lsWorkTime != null && lsWorkTime.size() == 1; + } + + if (oneSign) { + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + TimeScopeEntity signTimeScope = lsSignTime.get(0); + TimeScopeEntity workTimeScope = lsWorkTime.get(0); + int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workTimeScope.getEndTime()); + + List lsCheckInfo = new KQFormatSignData().getSignInfo(userId, signTimeScope, workTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo + ,Lists.newArrayList(), "",0,0,signoutOnlyoff); + for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) { + Map checkInfo = (Map) lsCheckInfo.get(j); + String signDate = Util.null2String(checkInfo.get("signDate")); + String signTime = Util.null2String(checkInfo.get("signTime")); + String deduct_signofftime = Util.null2String(checkInfo.get("deduct_signofftime")); + if (checkInfo.get("signType").equals("2")) {//签退 + String signOutTime = signTime; + int signInTimeOutdx = kqTimesArrayComInfo.getArrayindexByTimes(signOutTime); + String flow_signOutTime = signOutTime; + if (deduct_signofftime.length() > 0) { + if (signTime.length() > 0) { + if (deduct_signofftime.compareTo(signTime) > 0) { + flow_signOutTime = deduct_signofftime; + } + } else { + flow_signOutTime = deduct_signofftime; + } + } + if (flow_signOutTime.length() > 0) { + signInTimeOutdx = kqTimesArrayComInfo.getArrayindexByTimes(flow_signOutTime); + } + if (kqDate.compareTo(signDate) < 0) signInTimeOutdx += 1440; + if (signInTimeOutdx > workEndIdx) { + lateOutMins = signInTimeOutdx - workEndIdx; + } + } + } + } + return lateOutMins; + } + + public int getPreDayLateOutMins(String userId, String kqDate) { + return getPreDayLateOutMins(userId, kqDate, Lists.newArrayList()); + } + public int getPreDayLateOutMins(String userId, String kqDate, List logList) { + return getPreDayLateOutMins(userId, kqDate,logList,0); + } + + /** + * 前一天晚走分钟数 + */ + public int getPreDayLateOutMins(String userId, String kqDate, List logList,int signoutOnlyoff) { + int preDayLateOutMins = 0; + + boolean oneSign = false; + KQWorkTime kqWorkTime = new KQWorkTime(); + //前一天是非工作日,往前取到工作日 + String tmpKQPreDate = DateUtil.addDate(kqDate, -1); + for (int i = 0; i < 31; i++) { + WorkTimeEntity workTime = kqWorkTime.getWorkTime(userId, tmpKQPreDate); + if (workTime.getWorkMins() > 0) { + kqDate = DateUtil.addDate(tmpKQPreDate, 1); + break; + } + tmpKQPreDate = DateUtil.addDate(tmpKQPreDate, -1); + } + String kqPreDate = DateUtil.addDate(kqDate, -1); + ; + String kqPrePreDate = DateUtil.addDate(kqDate, -2); + WorkTimeEntity workTime = kqWorkTime.getWorkTime(userId, kqPreDate); + List lsSignTime = new ArrayList<>(); + List lsWorkTime = new ArrayList<>(); + if (workTime != null) { + lsSignTime = workTime.getSignTime();//允许打卡时间 + lsWorkTime = workTime.getWorkTime();//工作时间 + oneSign = lsWorkTime != null && lsWorkTime.size() == 1; + } + + if (oneSign) { + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + TimeScopeEntity signTimeScope = lsSignTime.get(0); + TimeScopeEntity workTimeScope = lsWorkTime.get(0); + String signBeginDateTime = signTimeScope.getBeginTimeAcross() ? kqPrePreDate : kqPreDate; + signBeginDateTime += " " + kqTimesArrayComInfo.turn48to24Time(signTimeScope.getBeginTime()) + ":00"; + String signEndDateTime = signTimeScope.getEndTimeAcross() ? kqDate : kqPreDate; + signEndDateTime += " " + kqTimesArrayComInfo.turn48to24Time(signTimeScope.getEndTime()) + ":00"; + String workBeginDateTime = workTimeScope.getBeginTimeAcross() ? kqPrePreDate : kqPreDate; + workBeginDateTime += " " + kqTimesArrayComInfo.turn48to24Time(workTimeScope.getBeginTime()) + ":00"; + String workEndDateTime = workTimeScope.getEndTimeAcross() ? kqDate : kqPreDate; + workEndDateTime += " " + kqTimesArrayComInfo.turn48to24Time(workTimeScope.getEndTime()) + ":00"; + + Map shifRuleMap = Maps.newHashMap(); + String shif_workEndTime = ""; + getPre_ShiftRuleInfo(kqPreDate, workTime, lsSignTime, lsWorkTime, userId, shifRuleMap, logList); + if (!shifRuleMap.isEmpty()) { + if (shifRuleMap.containsKey("shift_endworktime")) { + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if (shift_endworktime.length() > 0) { + shif_workEndTime = Util.null2String(shift_endworktime); + } + } + } + + List lsCheckInfo = new KQFormatSignData().getSignInfo(userId, signTimeScope, workTimeScope, kqPreDate, kqPrePreDate, kqDate, kqTimesArrayComInfo + ,Lists.newArrayList(), "",0,0,signoutOnlyoff); + Map checkInfo = null; + if (lsCheckInfo.size() == 2) { + for (int i = 0; i < lsCheckInfo.size(); i++) { + checkInfo = (Map) lsCheckInfo.get(i); + String signType = Util.null2String(checkInfo.get("signType")); + if ("2".equalsIgnoreCase(signType)) { + break; + } + } + String signDate = Util.null2String(checkInfo.get("signDate")); + String signTime = Util.null2String(checkInfo.get("signTime")); + String workEndTime = Util.null2String(workTimeScope.getEndTime()); + int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + if (shif_workEndTime.length() > 0) { + workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(shif_workEndTime); + } + if (!kqPreDate.equals(signDate)) { //跨天 + signTime = kqTimesArrayComInfo.turn24to48Time(signTime); + } + int signOutTimeIdx = kqTimesArrayComInfo.getArrayindexByTimes(signTime); + if (signOutTimeIdx > workEndIdx) { + preDayLateOutMins = signOutTimeIdx - workEndIdx; + logList.add("签退时间是:" + (signDate + " " + kqTimesArrayComInfo.turn48to24Time(signTime)) + ",晚走了" + preDayLateOutMins + "分钟"); + } + } else if (!lsCheckInfo.isEmpty()) { + for (int i = 0; i < lsCheckInfo.size(); i++) { + Map checkInfoMap = (Map) lsCheckInfo.get(i); + String signType = Util.null2String(checkInfoMap.get("signType")); + if ("2".equalsIgnoreCase(signType)) { + String signDate = Util.null2String(checkInfoMap.get("signDate")); + String signTime = Util.null2String(checkInfoMap.get("signTime")); + String workEndTime = Util.null2String(workTimeScope.getEndTime()); + int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + if (shif_workEndTime.length() > 0) { + workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(shif_workEndTime); + } + if (!kqPreDate.equals(signDate)) { //跨天 + signTime = kqTimesArrayComInfo.turn24to48Time(signTime); + } + int signOutTimeIdx = kqTimesArrayComInfo.getArrayindexByTimes(signTime); + if (signOutTimeIdx > workEndIdx) { + preDayLateOutMins = signOutTimeIdx - workEndIdx; + logList.add(",签退时间是:" + (signDate + " " + signTime) + ",晚走了" + preDayLateOutMins + "分钟"); + } + } + } + } + } + return preDayLateOutMins; + } + + /** + * 获取前一天的弹性时间 + * + * @param kqPreDate + * @param workTime + * @param lsSignTime + * @param lsWorkTime + * @param userId + * @param logList + */ + public void getPre_ShiftRuleInfo(String kqPreDate, WorkTimeEntity workTime, + List lsSignTime, List lsWorkTime, String userId, + Map shifRuleMap, List logList) { + ShiftInfoBean shiftInfoBean = new ShiftInfoBean(); + shiftInfoBean.setSplitDate(kqPreDate); + shiftInfoBean.setShiftRuleMap(workTime.getShiftRuleInfo()); + shiftInfoBean.setSignTime(lsSignTime); + shiftInfoBean.setWorkTime(lsWorkTime); + KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, userId, shifRuleMap, false, logList); + } + + /** + * 获取班次设置里面的上下班不打卡数据 + * + * @param i + * @param serialId + */ + public Map getModel_ShiftRule(int i, String serialId) { + RecordSet rs = new RecordSet(); + HashMap sectionMap = new HashMap<>(); + String getStartWorkSections = "select * from kq_ShiftOnOffWorkSections where SERIALID=? and record=? "; + rs.executeQuery(getStartWorkSections, serialId, i); + while (rs.next()) { + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + String clockinnot = Util.null2s(Util.null2String(rs.getString("clockinnot")), "0"); + sectionMap.put(onoffworktype, clockinnot); + } + return sectionMap; + } + +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQFormatSignData.java b/src/com/engine/kq/biz/KQFormatSignData.java new file mode 100644 index 0000000..c416925 --- /dev/null +++ b/src/com/engine/kq/biz/KQFormatSignData.java @@ -0,0 +1,758 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.TimeSignScopeEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.UtilKQ; +import com.engine.kq.wfset.util.KQSignUtil; +import com.google.common.collect.Lists; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; + +import java.util.*; + +/** + * 获取班次打卡数据 + */ +public class KQFormatSignData extends BaseBean { + private KQLog kqLog = new KQLog(); + + public List getSignInfo(String userId, TimeScopeEntity signTimeScope, + TimeScopeEntity workTimeScope, String kqDate, String preDate, + String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo) { + return getSignInfo(userId, signTimeScope, workTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo, + Lists.newArrayList(), ""); + } + + public List getSignInfo(String userId, TimeScopeEntity signTimeScope, + TimeScopeEntity workTimeScope, String kqDate, String preDate, + String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo, ArrayList hostIps, String uuid) { + return getSignInfo(userId, signTimeScope, workTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo, hostIps, uuid, 0, 0); + } + + public List getSignInfo(String userId, TimeScopeEntity signTimeScope, + TimeScopeEntity workTimeScope, String kqDate, String preDate, + String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo, ArrayList hostIps, String uuid, int shiftCount, int shiftI) { + return getSignInfo(userId, signTimeScope, workTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo, hostIps, uuid, shiftCount, shiftI, 0); + } + + /*** + * 获取班次打卡数据 + * @param userId + * @param signTimeScope + * @param workTimeScope + * @param kqDate + * @param preDate + * @param nextDate + * @param kqTimesArrayComInfo + * @return + */ + public List getSignInfo(String userId, TimeScopeEntity signTimeScope, + TimeScopeEntity workTimeScope, String kqDate, String preDate, + String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo, ArrayList hostIps, String uuid, int shiftCount, int shiftI, int signoutOnlyoff) { + kqLog.info("in getSignInfo ::userId" + userId + "kqDate==" + kqDate + ":hostIps:" + hostIps + ":uuid::" + uuid + " in "); + List lsCheckInfo = new ArrayList<>(); + String count4NoonStartDateTime = ""; + String count4NoonEndDateTime = ""; + try { + Map checkInfo = null; + String base_sql = ""; + RecordSet rs = new RecordSet(); + String dbtype = rs.getDBType(); + + //获取工作上下班时间 + String workBeginDateTime = workTimeScope.getBeginTimeAcross() ? nextDate : kqDate; + workBeginDateTime += " " + kqTimesArrayComInfo.turn48to24Time(workTimeScope.getBeginTime()) + ":00"; + kqLog.info("in getSignInfo ::userId" + userId + "kqDate==" + kqDate + ":hostIps:" + hostIps + ":uuid::" + uuid + "::workBeginDateTime::" + workBeginDateTime); + + //获取工作上下班时间 + String workEndDateTime = workTimeScope.getEndTimeAcross() ? nextDate : kqDate; + workEndDateTime += " " + kqTimesArrayComInfo.turn48to24Time(workTimeScope.getEndTime()) + ":00"; + kqLog.info("in getSignInfo ::userId" + userId + "kqDate==" + kqDate + ":hostIps:" + hostIps + ":uuid::" + uuid + "::workEndDateTime::" + workEndDateTime); + + Map flow_deduct_card_map = getflowDeductCardSql(userId, kqDate, workTimeScope.getBeginTime(), workTimeScope.getEndTime()); + + kqLog.info("in getSignInfo ::userId" + userId + "kqDate==" + kqDate + ":hostIps:" + hostIps + ":uuid::" + uuid + "::flow_deduct_card_map::" + flow_deduct_card_map); + kqLog.info("in getSignInfo ::userId" + userId + "kqDate==" + kqDate + ":hostIps:" + hostIps + ":uuid::" + uuid + "::signTimeScope::" + JSON.toJSONString(signTimeScope)); + + List> sqlConditions = getCanSignInfo(signTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo, workTimeScope, shiftCount, shiftI, signoutOnlyoff); + base_sql = signSignSql(rs); + new KQLog().info("sqlConditions:(userId:" + userId + ":base_sql" + base_sql + ":::userId" + userId + "kqDate==" + kqDate + ":hostIps:" + hostIps + ":uuid::" + uuid + "::flow_deduct_card_map::" + flow_deduct_card_map + "::sqlConditions::" + JSONObject.toJSONString(sqlConditions)); + if (sqlConditions != null && !sqlConditions.isEmpty()) { + if (shiftCount == 2) { + String fieldName = ""; + if (shiftI == 0) { + fieldName = "signEndDateTime"; + } else if (shiftI == 1) { + fieldName = "signBeginDateTime"; + } + Map sqlMap = sqlConditions.get(0); + count4NoonStartDateTime = Util.null2String(sqlMap.get(fieldName)); + if (count4NoonStartDateTime.length() == 19) { + count4NoonStartDateTime = count4NoonStartDateTime.substring(0, 17) + "00"; + } + sqlMap = sqlConditions.get(0); + count4NoonEndDateTime = Util.null2String(sqlMap.get(fieldName)); + if (sqlConditions.size() >= 2) { + sqlMap = sqlConditions.get(1); + count4NoonEndDateTime = Util.null2String(sqlMap.get(fieldName)); + } + } + + boolean hasSignIn = false; + for (Map sqlMap : sqlConditions) { + String sql = ""; + String orderSql = ""; + int idx = 0; + String signBeginDateTime = Util.null2String(sqlMap.get("signBeginDateTime")); + String signEndDateTime = Util.null2String(sqlMap.get("signEndDateTime")); + String type = Util.null2String(sqlMap.get("type")); + String signoutOnlyoff_flag = Util.null2String(sqlMap.get("signoutOnlyoff")); + if (type.length() > 0) { + if ("signoff".equalsIgnoreCase(type)) { + orderSql = " order by signdate desc, signtime desc "; + } else if ("signin".equalsIgnoreCase(type)) { + orderSql = " order by signdate asc, signtime asc "; + } + if ("oracle".equalsIgnoreCase(dbtype)) { + sql = "select * from (" + base_sql + " " + orderSql + ") a where rownum=1"; + } else if ("mysql".equalsIgnoreCase(dbtype)) { + sql = "select * from (" + base_sql + " " + orderSql + ") a limit 0,1"; + } else if ("postgresql".equalsIgnoreCase(dbtype)) { + sql = "select * from (" + base_sql + " " + orderSql + ") a limit 1 offset 0"; + } else if ("sqlserver".equalsIgnoreCase(dbtype)) { + sql = "select top 1 * from (" + base_sql + ") a " + " " + orderSql; + } else { + sql = "select * from (" + base_sql + " " + orderSql + ") a where rownum=1"; + } + } else { + orderSql = " order by signdate asc, signtime asc "; + sql = base_sql + " " + orderSql; + } + rs.executeQuery(sql, userId, signBeginDateTime, signEndDateTime); + new KQLog().info("getSignInfo:(userId:" + userId + ":signBeginDateTime:" + + signBeginDateTime + ":signEndDateTime:" + signEndDateTime + "):sql" + sql + ":counts:" + rs.getCounts() + ":::userId" + userId + "kqDate==" + kqDate + ":hostIps:" + hostIps + ":uuid::" + uuid + "::flow_deduct_card_map::" + flow_deduct_card_map); + while (rs.next()) { + String signId = Util.null2String(rs.getString("id")); + String signdate = Util.null2String(rs.getString("signdate")); + String signtime = Util.null2String(rs.getString("signtime")); + + checkInfo = new HashMap<>(); + checkInfo.put("signId", signId);//签到签退标识 + checkInfo.put("signDate", signdate);//签到签退日期 + checkInfo.put("signTime", signtime);//签到签退时间 + String signDateTime = signdate + " " + signtime; + idx++; + if (type.length() > 0) { + if ("signin".equalsIgnoreCase(type)) { + checkInfo.put("signType", "1"); + if (workBeginDateTime.length() > 0) { + checkInfo.put("signStatus", UtilKQ.getSignStatus("1", signDateTime, workBeginDateTime)); + } + if (!Util.null2String(checkInfo.get("signStatus")).equalsIgnoreCase(ButtonStatusEnum.NORMAL.getStatusCode())) { + if (flow_deduct_card_map.containsKey("signin")) { + String deduct_signintime = Util.null2String(flow_deduct_card_map.get("signin")); + if (deduct_signintime.length() > 0) { + signDateTime = signdate + " " + deduct_signintime; + checkInfo.put("deduct_signintime", deduct_signintime);//流程抵扣作为打卡时间 + checkInfo.put("signStatus", UtilKQ.getSignStatus("1", signDateTime, workBeginDateTime)); + } + } + } + lsCheckInfo.add(checkInfo); + } else { + checkInfo.put("signType", "2"); + if (workEndDateTime.length() > 0) { + checkInfo.put("signStatus", UtilKQ.getSignStatus("2", signDateTime, workEndDateTime)); + } + if (!Util.null2String(checkInfo.get("signStatus")).equalsIgnoreCase(ButtonStatusEnum.NORMAL.getStatusCode())) { + if (flow_deduct_card_map.containsKey("signoff")) { + String deduct_signofftime = Util.null2String(flow_deduct_card_map.get("signoff")); + if (deduct_signofftime.length() > 0) { + signDateTime = signdate + " " + deduct_signofftime; + checkInfo.put("deduct_signofftime", deduct_signofftime);//流程抵扣作为打卡时间 + checkInfo.put("signStatus", UtilKQ.getSignStatus("2", signDateTime, workEndDateTime)); + } + } + } + lsCheckInfo.add(checkInfo); + } + } else { + if (signoutOnlyoff_flag.length()>0) { + if("signin".equals(signoutOnlyoff_flag) && idx == 1){ + checkInfo.put("signType", "1"); + if (workBeginDateTime.length() > 0) { + checkInfo.put("signStatus", UtilKQ.getSignStatus("1", signDateTime, workBeginDateTime)); + } + if (!Util.null2String(checkInfo.get("signStatus")).equalsIgnoreCase(ButtonStatusEnum.NORMAL.getStatusCode())) { + if (flow_deduct_card_map.containsKey("signin")) { + String deduct_signintime = Util.null2String(flow_deduct_card_map.get("signin")); + if (deduct_signintime.length() > 0) { + signDateTime = signdate + " " + deduct_signintime; + checkInfo.put("deduct_signintime", deduct_signintime);//流程抵扣作为打卡时间 + checkInfo.put("signStatus", UtilKQ.getSignStatus("1", signDateTime, workBeginDateTime)); + } + } + } + lsCheckInfo.add(checkInfo); + hasSignIn = true; + } + if("signoff".equals(signoutOnlyoff_flag)){ + if ((hasSignIn && idx == rs.getCounts() && idx > 1) || (!hasSignIn && idx == rs.getCounts())) {//第一条可能是签到卡需要处理下,否则可能会导致一条上班卡同时识别为上班卡和下班卡 + checkInfo.put("signType", "2"); + if (workEndDateTime.length() > 0) { + checkInfo.put("signStatus", UtilKQ.getSignStatus("2", signDateTime, workEndDateTime)); + } + if (!Util.null2String(checkInfo.get("signStatus")).equalsIgnoreCase(ButtonStatusEnum.NORMAL.getStatusCode())) { + if (flow_deduct_card_map.containsKey("signoff")) { + String deduct_signofftime = Util.null2String(flow_deduct_card_map.get("signoff")); + if (deduct_signofftime.length() > 0) { + signDateTime = signdate + " " + deduct_signofftime; + checkInfo.put("deduct_signofftime", deduct_signofftime);//流程抵扣作为打卡时间 + checkInfo.put("signStatus", UtilKQ.getSignStatus("2", signDateTime, workEndDateTime)); + } + } + } + lsCheckInfo.add(checkInfo); + } + } + } else { + if (idx == 1) {//第一条算签到 + checkInfo.put("signType", "1"); + if (workBeginDateTime.length() > 0) { + checkInfo.put("signStatus", UtilKQ.getSignStatus("1", signDateTime, workBeginDateTime)); + } + if (!Util.null2String(checkInfo.get("signStatus")).equalsIgnoreCase(ButtonStatusEnum.NORMAL.getStatusCode())) { + if (flow_deduct_card_map.containsKey("signin")) { + String deduct_signintime = Util.null2String(flow_deduct_card_map.get("signin")); + if (deduct_signintime.length() > 0) { + signDateTime = signdate + " " + deduct_signintime; + checkInfo.put("deduct_signintime", deduct_signintime);//流程抵扣作为打卡时间 + checkInfo.put("signStatus", UtilKQ.getSignStatus("1", signDateTime, workBeginDateTime)); + } + } + } + lsCheckInfo.add(checkInfo); + hasSignIn = true; + } else if (idx == rs.getCounts()) {//最后一条算签退 + checkInfo.put("signType", "2"); + if (workEndDateTime.length() > 0) { + checkInfo.put("signStatus", UtilKQ.getSignStatus("2", signDateTime, workEndDateTime)); + } + if (!Util.null2String(checkInfo.get("signStatus")).equalsIgnoreCase(ButtonStatusEnum.NORMAL.getStatusCode())) { + if (flow_deduct_card_map.containsKey("signoff")) { + String deduct_signofftime = Util.null2String(flow_deduct_card_map.get("signoff")); + if (deduct_signofftime.length() > 0) { + signDateTime = signdate + " " + deduct_signofftime; + checkInfo.put("deduct_signofftime", deduct_signofftime);//流程抵扣作为打卡时间 + checkInfo.put("signStatus", UtilKQ.getSignStatus("2", signDateTime, workEndDateTime)); + } + } + } + lsCheckInfo.add(checkInfo); + } + } + } + } + } + } + //如果签到,签退不成对,流程抵扣异常存在,那么需要判断下是不是可以补足 + if (lsCheckInfo.size() < 2 && !flow_deduct_card_map.isEmpty()) { + if (lsCheckInfo.isEmpty()) { + if (flow_deduct_card_map.containsKey("signin")) { + String deduct_signintime = Util.null2String(flow_deduct_card_map.get("signin")); + if (deduct_signintime.length() > 0) { + checkInfo = new HashMap<>(); + String[] workBeginDateTimes = workBeginDateTime.split(" "); + String tmp_workBeginDate = workBeginDateTimes[0]; + String tmp_workBeginTime = workBeginDateTimes[1]; + checkInfo.put("signType", "1"); + checkInfo.put("signDate", tmp_workBeginDate);//签到签退日期 + checkInfo.put("signTime", "");//签到签退时间 + checkInfo.put("deduct_signintime", tmp_workBeginTime);//流程抵扣作为打卡时间 + checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); + lsCheckInfo.add(checkInfo); + } + } + if (flow_deduct_card_map.containsKey("signoff")) { + String deduct_signofftime = Util.null2String(flow_deduct_card_map.get("signoff")); + if (deduct_signofftime.length() > 0) { + checkInfo = new HashMap<>(); + String[] workEndDateTimes = workEndDateTime.split(" "); + String tmp_workEndDate = workEndDateTimes[0]; + String tmp_workEndTime = workEndDateTimes[1]; + checkInfo.put("signType", "2"); + checkInfo.put("signDate", tmp_workEndDate);//签到签退日期 + checkInfo.put("signTime", "");//签到签退时间 + checkInfo.put("deduct_signofftime", tmp_workEndTime);//流程抵扣作为打卡时间 + checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); + lsCheckInfo.add(checkInfo); + } + } + } else { + Map checkCardMap = (Map) lsCheckInfo.get(0); + if (!checkCardMap.isEmpty()) { + String signType = Util.null2String(checkCardMap.get("signType")); + if ("1".equalsIgnoreCase(signType)) { + //如果签到数据有了,检测下是不是有签退的流程抵扣打卡 + if (flow_deduct_card_map.containsKey("signoff")) { + String deduct_signofftime = Util.null2String(flow_deduct_card_map.get("signoff")); + if (deduct_signofftime.length() > 0) { + checkInfo = new HashMap<>(); + String[] workEndDateTimes = workEndDateTime.split(" "); + String tmp_workEndDate = workEndDateTimes[0]; + String tmp_workEndTime = workEndDateTimes[1]; + checkInfo.put("signType", "2"); + checkInfo.put("signDate", tmp_workEndDate);//签到签退日期 + checkInfo.put("signTime", "");//签到签退时间 + checkInfo.put("deduct_signofftime", tmp_workEndTime);//流程抵扣作为打卡时间 + checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); + lsCheckInfo.add(checkInfo); + } + } + } else { + if (flow_deduct_card_map.containsKey("signin")) { + String deduct_signintime = Util.null2String(flow_deduct_card_map.get("signin")); + if (deduct_signintime.length() > 0) { + checkInfo = new HashMap<>(); + String[] workBeginDateTimes = workBeginDateTime.split(" "); + String tmp_workBeginDate = workBeginDateTimes[0]; + String tmp_workBeginTime = workBeginDateTimes[1]; + checkInfo.put("signType", "1"); + checkInfo.put("signDate", tmp_workBeginDate);//签到签退日期 + checkInfo.put("signTime", "");//签到签退时间 + checkInfo.put("deduct_signintime", tmp_workBeginTime);//流程抵扣作为打卡时间 + checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); + lsCheckInfo.add(checkInfo); + } + } + } + } + } + } + // 上午的签退取中间时段的第一次打卡 + if (shiftCount == 2 && shiftI == 0) { + String noonSignTimeSql = KQSignUtil.buildSignSql(count4NoonStartDateTime, count4NoonEndDateTime); + String baseSql = "select * from hrmschedulesign where 1=1 and isInCom='1' and userid=" + userId + " "; + String sql = baseSql; + sql += " and " + noonSignTimeSql + " order by signdate, signtime"; + rs.executeQuery(sql); + if (rs.next()) { + String signId = Util.null2String(rs.getString("id")); + String signDate = Util.null2String(rs.getString("signdate")); + String signTime = Util.null2String(rs.getString("signtime")); + String signDateTime = signDate + " " + signTime; + for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) { + Map checkInfoInner = (Map) lsCheckInfo.get(j); + if (checkInfoInner.get("signType").equals("2")) {//签退 + String signDateInner = Util.null2String(checkInfoInner.get("signDate")); + String signTimeInner = Util.null2String(checkInfoInner.get("signTime")); + String deduct_signofftime = Util.null2String(checkInfoInner.get("deduct_signofftime")); + if (!"".equals(signTimeInner)) { + String signDateTimeInner = signDateInner + " " + signTimeInner; + if (signDateTime.compareTo(signDateTimeInner) < 0) { + checkInfoInner.put("signId", signId);//签到签退标识 + checkInfoInner.put("signType", "2"); + checkInfoInner.put("signDate", signDateInner);//签到签退日期 + checkInfoInner.put("signTime", signTime);//签到签退时间 + checkInfoInner.put("deduct_signofftime", deduct_signofftime);//流程抵扣作为打卡时间 + checkInfoInner.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); + } + } + } + } + } + } else if (shiftCount == 2 && shiftI == 1) { // 下午的签到取中间时段的第二次打卡 + String noonSignTimeSql = KQSignUtil.buildSignSql(count4NoonStartDateTime, count4NoonEndDateTime); + String baseSql = "select * from hrmschedulesign where 1=1 and isInCom='1' and userid=" + userId + " "; + String sql = baseSql; + sql += " and " + noonSignTimeSql + " order by signdate, signtime"; + rs.executeQuery(sql); + int count = 0; + int counts = rs.getCounts(); + if (counts == 1) { + lsCheckInfo.clear(); + } + while (rs.next()) { + if (count == 0) { + count++; + continue; + } + String signId = Util.null2String(rs.getString("id")); + String signTime = Util.null2String(rs.getString("signtime")); + for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) { + Map checkInfoInner = (Map) lsCheckInfo.get(j); + if (checkInfoInner.get("signType").equals("1")) {//签退 + String signDateInner = Util.null2String(checkInfoInner.get("signDate")); + String signTimeInner = Util.null2String(checkInfoInner.get("signTime")); + String deduct_signofftime = Util.null2String(checkInfoInner.get("deduct_signofftime")); + checkInfoInner.put("signId", signId);//签到签退标识 + checkInfoInner.put("signType", "1"); + checkInfoInner.put("signDate", signDateInner);//签到签退日期 + checkInfoInner.put("signTime", signTime);//签到签退时间 + checkInfoInner.put("deduct_signofftime", deduct_signofftime);//流程抵扣作为打卡时间 + checkInfoInner.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); + } + } + break; + } + } + } catch (Exception e) { + + kqLog.info("报表错:getSignInfo:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + + //writeLog(sql,userId +"=="+ signBeginDateTime+"=="+signEndDateTime); + return lsCheckInfo; + } + + /** + * 根据上下班时间获取到是否有流程抵扣打卡的数据 + * + * @param userId + * @param kqDate + * @param workBeginDateTime + * @param workEndDateTime + */ + public Map getflowDeductCardSql(String userId, String kqDate, String workBeginDateTime, String workEndDateTime) { + Map flow_deduct_card_map = new HashMap<>(); + RecordSet rs = new RecordSet(); + String flow_deduct_card_sql = "select * from kq_flow_deduct_card where 1=1 and (isclear is null or isclear<>1) "; + if (userId.length() > 0) { + flow_deduct_card_sql += " and resourceid=" + userId; + } + if (kqDate.length() > 0) { + flow_deduct_card_sql += " and belongDate='" + kqDate + "'"; + } + if (workBeginDateTime.length() > 0) { + flow_deduct_card_sql += " and workBeginTime='" + workBeginDateTime + "'"; + } + if (workEndDateTime.length() > 0) { + flow_deduct_card_sql += " and workEndTime='" + workEndDateTime + "'"; + } + rs.executeQuery(flow_deduct_card_sql); + while (rs.next()) { + String signtype = rs.getString("signtype"); + if ("1".equalsIgnoreCase(signtype)) { + flow_deduct_card_map.put("signin", workBeginDateTime); + } + if ("2".equalsIgnoreCase(signtype)) { + flow_deduct_card_map.put("signoff", workEndDateTime); + } + } + return flow_deduct_card_map; + } + + /** + * 根据打卡的范围生成上班,下班数据获取的sql + * + * @param signTimeScope + * @param kqDate + * @param preDate + * @param nextDate + * @param kqTimesArrayComInfo + * @return + */ + public List> getCanSignInfo(TimeScopeEntity signTimeScope, String kqDate, String preDate, String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo) { + return getCanSignInfo(signTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo, null); + } + + public List> getCanSignInfo(TimeScopeEntity signTimeScope, String kqDate, String preDate, String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo,TimeScopeEntity workTimeScope,int signoutOnlyoff) { + return getCanSignInfo(signTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo, workTimeScope, 0, 0, signoutOnlyoff); + } + + public List> getCanSignInfo(TimeScopeEntity signTimeScope, String kqDate, String preDate, String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo, TimeScopeEntity workTimeScope) { + return getCanSignInfo(signTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo, workTimeScope, 0, 0); + } + + public List> getCanSignInfo(TimeScopeEntity signTimeScope, String kqDate, String preDate, String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo, TimeScopeEntity workTimeScope, int shiftCount, int shiftI) { + return getCanSignInfo(signTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo, workTimeScope, shiftCount, shiftI, 0); + } + + public List> getCanSignInfo(TimeScopeEntity signTimeScope, String kqDate, String preDate, String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo, TimeScopeEntity workTimeScope, int shiftCount, int shiftI, int signoutOnlyoff) { + + List> sqlConditions = new ArrayList<>(); + Map conditionMap = new HashMap<>(); + + TimeSignScopeEntity timeSignScopeEntity = signTimeScope.getTimeSignScopeEntity(); + + String signBeginDateTime = ""; + String signEndDateTime = ""; + signBeginDateTime = signTimeScope.getBeginTimeAcross() ? nextDate : kqDate; + if (signTimeScope.isBeginTimePreAcross()) { + signBeginDateTime = preDate; + } + signBeginDateTime += " " + kqTimesArrayComInfo.turn48to24Time(signTimeScope.getBeginTime()) + ":00"; + + signEndDateTime = signTimeScope.getEndTimeAcross() ? nextDate : kqDate; + +// if (workTimeScope != null && workTimeScope.getEndTimeAcross() && signTimeScope.getEndTimeAcross() ) { +// if(workTimeScope.getEndTime().compareTo(signTimeScope.getEndTime())>=0){ +// signEndDateTime = DateUtil.addDate(kqDate, 2);//下下一天日期; +// } +// } + signEndDateTime += " " + kqTimesArrayComInfo.turn48to24Time(signTimeScope.getEndTime()) + ":59"; + + + if (timeSignScopeEntity == null) { + //没有设置 签到最晚时间和签退最早时间,比如是09:00-18:00,打卡范围是【08:00---19:00】 + if (signoutOnlyoff == 1 && workTimeScope != null) {//开启了下班后只能签退的按钮,那么考勤格式化的打卡数据查询范围也搞一下 + String signBeginDateEndTime = ""; + String signEndDateStartTime = ""; + String workEndTime = workTimeScope.getEndTime(); + boolean workEndTimeAcross = workTimeScope.getEndTimeAcross(); + + String workEndTimeNew = kqTimesArrayComInfo.getTimesByArrayindex(kqTimesArrayComInfo.getArrayindexByTimes(workEndTime) - 1);//17:59 + signBeginDateEndTime = workEndTimeAcross ? nextDate : kqDate; + signBeginDateEndTime += " " + kqTimesArrayComInfo.turn48to24Time(workEndTimeNew) + ":59";//17:59:59 + + conditionMap = new HashMap<>(); + conditionMap.put("signBeginDateTime", signBeginDateTime);//08:00:00 + conditionMap.put("signEndDateTime", signBeginDateEndTime);//17:59:59 +// conditionMap.put("type", "signin"); + conditionMap.put("signoutOnlyoff", "signin"); + sqlConditions.add(conditionMap); + + conditionMap = new HashMap<>(); + conditionMap.put("signBeginDateTime", signBeginDateTime);//08:00:00,这里为什么从上班开始打卡时间起算,因为存在上班有打卡,连续打卡的情况,那么需要将除上班卡之后的打卡都识别为下班卡 + conditionMap.put("signEndDateTime", signEndDateTime);//19:00:59 + //这里不能传type=signoff,否则上班打卡可能会同时识别为上班卡和下班卡 + conditionMap.put("signoutOnlyoff", "signoff"); + sqlConditions.add(conditionMap); + + } else {//走标准原逻辑 + conditionMap = new HashMap<>(); + conditionMap.put("signBeginDateTime", signBeginDateTime); + conditionMap.put("signEndDateTime", signEndDateTime); + sqlConditions.add(conditionMap); + } + + } else { + String beginTimeEnd = timeSignScopeEntity.getBeginTimeEnd(); + boolean beginTimeEndAcross = timeSignScopeEntity.isBeginTimeEndAcross(); + + String endTimeStart = timeSignScopeEntity.getEndTimeStart(); + boolean endTimeStartAcross = timeSignScopeEntity.isEndTimeStartAcross(); + + if (beginTimeEnd.length() > 0) { + //如果设置了 上班结束时间 + if (endTimeStart.length() > 0) { + //设置了下班开始时间 + String signBeginDateEndTime = ""; + String signEndDateStartTime = ""; + signBeginDateEndTime = beginTimeEndAcross ? nextDate : kqDate; + signBeginDateEndTime += " " + kqTimesArrayComInfo.turn48to24Time(beginTimeEnd) + ":59"; + + //张总表示设了打卡归属,以设置的为准,这个开关相当于不起作用,代码含泪注释 +// if(signoutOnlyoff == 1 && workTimeScope != null){//开启了下班后只能签退的按钮,那么考勤格式化的打卡数据查询范围也搞一下 +// String workEndTime = workTimeScope.getEndTime(); +// boolean workEndTimeAcross = workTimeScope.getEndTimeAcross(); +// signBeginDateEndTime = workEndTimeAcross ? nextDate : kqDate; +// signBeginDateEndTime+=" "+kqTimesArrayComInfo.turn48to24Time(workEndTime)+":59"; +// conditionMap = new HashMap<>(); +// conditionMap.put("signBeginDateTime", signBeginDateTime); +// conditionMap.put("signEndDateTime", signBeginDateEndTime); +// conditionMap.put("type", "signin"); +// sqlConditions.add(conditionMap); +// +// conditionMap = new HashMap<>(); +// conditionMap.put("signBeginDateTime", signBeginDateEndTime); +// conditionMap.put("signEndDateTime", signEndDateTime); +// conditionMap.put("type", "signoff"); +// sqlConditions.add(conditionMap); +// +// }else{ + conditionMap = new HashMap<>(); + conditionMap.put("signBeginDateTime", signBeginDateTime); + conditionMap.put("signEndDateTime", signBeginDateEndTime); + conditionMap.put("type", "signin"); + sqlConditions.add(conditionMap); + + signEndDateStartTime = endTimeStartAcross ? nextDate : kqDate; + signEndDateStartTime += " " + kqTimesArrayComInfo.turn48to24Time(endTimeStart) + ":00"; + + conditionMap = new HashMap<>(); + conditionMap.put("signBeginDateTime", signEndDateStartTime); + conditionMap.put("signEndDateTime", signEndDateTime); + conditionMap.put("type", "signoff"); + sqlConditions.add(conditionMap); +// } + } else { + //没有设置下班开始时间 + String signBeginDateEndTime = ""; + String signEndDateStartTime = ""; + signBeginDateEndTime = beginTimeEndAcross ? nextDate : kqDate; + signBeginDateEndTime += " " + kqTimesArrayComInfo.turn48to24Time(beginTimeEnd) + ":59"; + + conditionMap = new HashMap<>(); + conditionMap.put("signBeginDateTime", signBeginDateTime); + conditionMap.put("signEndDateTime", signBeginDateEndTime); + conditionMap.put("type", "signin"); + sqlConditions.add(conditionMap); + + //如果设置了上班结束时间,相当于下班开始时间也被限定了 + String endTimeByBeginTime = kqTimesArrayComInfo.getTimesByArrayindex(kqTimesArrayComInfo.getArrayindexByTimes(beginTimeEnd) + 1); + signEndDateStartTime = beginTimeEndAcross ? nextDate : kqDate; + signEndDateStartTime += " " + kqTimesArrayComInfo.turn48to24Time(endTimeByBeginTime) + ":00"; + + conditionMap = new HashMap<>(); + conditionMap.put("signBeginDateTime", signEndDateStartTime); + conditionMap.put("signEndDateTime", signEndDateTime); + conditionMap.put("type", "signoff"); + sqlConditions.add(conditionMap); + } + } else if (endTimeStart.length() > 0) { + //如果没有设置上班结束时间,设置了下班开始时间 + String signBeginDateEndTime = ""; + String signEndDateStartTime = ""; + + //如果设置了下班开始时间,相当于上班结束时间也被限定了 + String BeginTimeByendTime = kqTimesArrayComInfo.getTimesByArrayindex(kqTimesArrayComInfo.getArrayindexByTimes(endTimeStart) - 1); + signBeginDateEndTime = endTimeStartAcross ? nextDate : kqDate; + signBeginDateEndTime += " " + kqTimesArrayComInfo.turn48to24Time(BeginTimeByendTime) + ":59"; + + conditionMap = new HashMap<>(); + conditionMap.put("signBeginDateTime", signBeginDateTime); + conditionMap.put("signEndDateTime", signBeginDateEndTime); + conditionMap.put("type", "signin"); + sqlConditions.add(conditionMap); + + signEndDateStartTime = endTimeStartAcross ? nextDate : kqDate; + signEndDateStartTime += " " + kqTimesArrayComInfo.turn48to24Time(endTimeStart) + ":00"; + + conditionMap = new HashMap<>(); + conditionMap.put("signBeginDateTime", signEndDateStartTime); + conditionMap.put("signEndDateTime", signEndDateTime); + conditionMap.put("type", "signoff"); + sqlConditions.add(conditionMap); + } + } + return sqlConditions; + } + + public String signSignSql(RecordSet rs) { + String sql = ""; + if (rs.getDBType().equals("oracle")) { + sql = " select id,signdate,signtime from hrmschedulesign where isincom=1 and userid = ? and signdate||' '||signtime >= ? and signdate||' '||signtime <= ? " + + " "; + } else if ("sqlserver".equals(rs.getDBType())) { + sql = " select id,signdate,signtime from hrmschedulesign where isincom=1 and userid = ? and signdate + ' ' + signtime >= ? and signdate + ' ' + signtime <= ? " + + " "; + } else { + sql = " select id,signdate,signtime from hrmschedulesign where isincom=1 and userid = ? and concat(signdate,' ',signtime) >= ? and concat(signdate,' ',signtime) <= ? " + + " "; + } + return sql; + } + + public List getSignInfoForAll(String userId, String signBeginDateTime, String signEndDateTime, String workBeginDateTime, String workEndDateTime) { + List lsCheckInfo = new ArrayList<>(); + Map checkInfo = null; + String sql = ""; + RecordSet rs = new RecordSet(); + + int idx = 0; + if (rs.getDBType().equals("oracle")) { + sql = " select id,signdate,signtime from hrmschedulesign where isincom=1 and userid = ? and signdate||' '||signtime >= ? and signdate||' '||signtime <= ? " + + " order by signdate asc, signtime asc "; + } else if ("sqlserver".equals(rs.getDBType())) { + sql = " select id,signdate,signtime from hrmschedulesign where isincom=1 and userid = ? and signdate + ' ' + signtime >= ? and signdate + ' ' + signtime <= ? " + + " order by signdate asc, signtime asc "; + } else { + sql = " select id,signdate,signtime from hrmschedulesign where isincom=1 and userid = ? and concat(signdate,' ',signtime) >= ? and concat(signdate,' ',signtime) <= ? " + + " order by signdate asc, signtime asc "; + } + rs.executeQuery(sql, userId, signBeginDateTime, signEndDateTime); + //writeLog(sql,userId +"=="+ signBeginDateTime+"=="+signEndDateTime); + while (rs.next()) { + String signId = Util.null2String(rs.getString("id")); + String signdate = Util.null2String(rs.getString("signdate")); + String signtime = Util.null2String(rs.getString("signtime")); + + checkInfo = new HashMap<>(); + checkInfo.put("signId", signId);//签到签退标识 + checkInfo.put("signDate", signdate);//签到签退日期 + checkInfo.put("signTime", signtime);//签到签退时间 + String signDateTime = signdate + " " + signtime; + + idx++; + if (idx % 2 == 1) { + checkInfo.put("signType", "1"); + } else { + checkInfo.put("signType", "2"); + } + lsCheckInfo.add(checkInfo); + } + return lsCheckInfo; + } + + public List getNonWorkSignInfo(String userId, String preDate, String kqDate, + List pre_lsSignTime, + List next_lsSignTime) { + List lsCheckInfo = new ArrayList<>(); + Map checkInfo = null; + RecordSet rs = new RecordSet(); + String pre_Worktime4Today = ""; + if (!pre_lsSignTime.isEmpty()) { + TimeScopeEntity pre_signTimeScope = pre_lsSignTime.get(pre_lsSignTime.size() - 1); + if (pre_signTimeScope.getEndTimeAcross()) { + pre_Worktime4Today = pre_signTimeScope.getEndTime(); + } + } + String next_Worktime4Today = ""; + if (!next_lsSignTime.isEmpty()) { + TimeScopeEntity next_signTimeScope = next_lsSignTime.get(next_lsSignTime.size() - 1); + if (next_signTimeScope.isBeginTimePreAcross()) { + next_Worktime4Today = next_signTimeScope.getBeginTime(); + } + } + String sql = "select * from hrmschedulesign where userid=" + userId + " and signdate = '" + kqDate + "' "; + if (pre_Worktime4Today.length() > 0) { + if (pre_Worktime4Today.length() == 5) { + pre_Worktime4Today += ":59"; + } + sql += " and signtime > '" + pre_Worktime4Today + "'"; + } + if (next_Worktime4Today.length() > 0) { + if (next_Worktime4Today.length() == 5) { + next_Worktime4Today += ":00"; + } + sql += " and signtime < '" + next_Worktime4Today + "'"; + } + sql += " order by signdate asc,signtime asc "; + rs.executeQuery(sql); + int idx = 0; + while (rs.next()) { + String signId = Util.null2String(rs.getString("id")); + String signdate = Util.null2String(rs.getString("signdate")); + String signtime = Util.null2String(rs.getString("signtime")); + + checkInfo = new HashMap<>(); + checkInfo.put("signId", signId);//签到签退标识 + checkInfo.put("signDate", signdate);//签到签退日期 + checkInfo.put("signTime", signtime);//签到签退时间 + idx++; + if (idx == 1) {//第一条算签到 + checkInfo.put("signType", "1"); + lsCheckInfo.add(checkInfo); + } else if (idx == rs.getCounts()) {//最后一条算签退 + checkInfo.put("signType", "2"); + lsCheckInfo.add(checkInfo); + } + } + return lsCheckInfo; + } + +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQFormatThread.java b/src/com/engine/kq/biz/KQFormatThread.java new file mode 100644 index 0000000..bcf61cc --- /dev/null +++ b/src/com/engine/kq/biz/KQFormatThread.java @@ -0,0 +1,67 @@ +package com.engine.kq.biz; + +import com.engine.kq.log.KQLog; +import weaver.conn.RecordSet; + +public class KQFormatThread extends com.weaver.util.threadPool.entity.LocalRunnable { + private String id; + private String resourceid; + private String kqdate; + + private int formatType; + private KQLog kqLog = new KQLog(); + + @Override + public void execute() { + RecordSet rs = new RecordSet(); + //更新已处理的记录 + String key = this.kqdate+ "|"+ this.resourceid; + try { + kqLog.info("执行KQFormatThread this.resourceid=="+this.resourceid+"this.kqdate=="+this.kqdate); + KQFormatData kqFormatData = new KQFormatData(); + //-1: 其他; 11:右键重新计算考勤数据; 12: 考勤自动和手动同步;13:钉钉同步或者导入; 14:云桥考勤同步 15: 考勤导入;16:排班更新 + //打卡数据这些要更新,11和16不能更新, + kqFormatData.formatKqDateByLock(this.resourceid, this.kqdate,this.formatType); + + boolean isremove = KQFormatJob.kqformatIds.remove(key); + if(isremove){ + rs.executeUpdate("update kq_format_pool set status=1 where id=?",this.id); + } + } catch (Exception e) { + KQFormatJob.kqformatIds.remove(key); + kqLog.info(e); + writeLog(e); + } + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getResourceid() { + return resourceid; + } + + public void setResourceid(String resourceid) { + this.resourceid = resourceid; + } + public int getFormatType() { + return formatType; + } + + public void setFormatType(int formatType) { + this.formatType = formatType; + } + + public String getKqdate() { + return kqdate; + } + + public void setKqdate(String kqdate) { + this.kqdate = kqdate; + } +} diff --git a/src/com/engine/kq/biz/KQFormatThreadManagerExceptionHandler.java b/src/com/engine/kq/biz/KQFormatThreadManagerExceptionHandler.java new file mode 100644 index 0000000..868f42d --- /dev/null +++ b/src/com/engine/kq/biz/KQFormatThreadManagerExceptionHandler.java @@ -0,0 +1,49 @@ +/* + * + * Copyright (c) 2001-2016 泛微软件. + * 泛微协同商务系统,版权所有. + * + */ +package com.engine.kq.biz; +import com.engine.kq.log.KQLog; +import weaver.system.ThreadWork; +import weaver.system.ThreadWorkTimer; + +import java.lang.Thread.UncaughtExceptionHandler; + +/** + * @version 1.0 + * @author + * [优化]考勤格式化线程偶发失效的问题(自动扫描失效后会自动启一个新的线程) + */ +public class KQFormatThreadManagerExceptionHandler implements UncaughtExceptionHandler { + + protected KQLog kqLog = new KQLog(); + + /** + * 线程异常后,重启线程 + * @param t 异常线程对象 + * @param e 异常对象 + * @return + */ + public void uncaughtException(Thread t, Throwable e) + { + +// kqLog.writeLog("考勤格式化线程异常,重新启动..."); +// kqLog.writeLog("An exception has been capturedn"); +// kqLog.writeLog("Thread: " +t.getId()); +// kqLog.writeLog("Exception: "+ e.getClass().getName()); +// kqLog.writeLog(" "+ e.getMessage()); +// kqLog.writeLog("Stack Trace: n"); +// kqLog.writeLog("Thread status:"+t.getState()); +// +// int hrmInterval = 30; //30秒检查一次 +// //ThreadWork KQFormatJob = new KQFormatJob(); +// +// ThreadWorkTimer hrmThreadWorkTimer = new ThreadWorkTimer(hrmInterval, KQFormatJob,"KQFormatJob"); +// +// hrmThreadWorkTimer.start(); + } + + +} diff --git a/src/com/engine/kq/biz/KQFormatTimer.java b/src/com/engine/kq/biz/KQFormatTimer.java new file mode 100644 index 0000000..6c20dd6 --- /dev/null +++ b/src/com/engine/kq/biz/KQFormatTimer.java @@ -0,0 +1,24 @@ +package com.engine.kq.biz; + +import weaver.general.StaticObj; + +import java.util.Timer; + +public class KQFormatTimer { + private static KQFormatTimer instance = new KQFormatTimer(); + + private KQFormatTimer(){ + init(); + } + public static KQFormatTimer getInstance(){ + return instance; + } + + private void init() { + Timer timer = new Timer(); + timer.schedule(KQFormatJob.getInstance(), 2000, 5*1000);//频率5秒钟 + + Timer cardFlowFlushTimer = new Timer(); + cardFlowFlushTimer.schedule(KQCardFlowFlushJob.getInstance(), 2000, 5*1000);//频率5秒钟 + } +} diff --git a/src/com/engine/kq/biz/KQGroupBiz.java b/src/com/engine/kq/biz/KQGroupBiz.java new file mode 100644 index 0000000..e7475bb --- /dev/null +++ b/src/com/engine/kq/biz/KQGroupBiz.java @@ -0,0 +1,714 @@ +package com.engine.kq.biz; + +import com.engine.kq.entity.KQGroupEntity; +import com.engine.kq.log.KQLog; +import com.google.common.collect.Lists; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.IpUtils; +import weaver.general.Util; +import weaver.hrm.common.database.dialect.DbDialectFactory; +import weaver.hrm.common.database.dialect.IDbDialectSql; + +import java.util.*; + +public class KQGroupBiz extends BaseBean { + + private static final double EARTH_RADIUS = 6378137;// 地球半径 + public static final String GROUPMEMBER_VALIDATE_FROMDATE="2000-01-01"; + public static final String GROUPMEMBER_VALIDATE_TODATE="2999-12-31"; + + public String getGroupMemberSql() { + return getGroupMemberSql(""); + } + + public String getGroupMemberSql(String groupId) { + Map params = new HashMap<>(); + params.put("groupId",groupId); + return this.getGroupMemberSql(params); + } + + public String getGroupMemberSql(Map params) { + String sql = ""; + try { + String groupId = Util.null2String(params.get("groupId")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + if(Util.null2String(groupId).length()>0){ + sql = " SELECT distinct resourceid, groupid FROM ( " + + " SELECT a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b " + + " WHERE a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') " + + " UNION ALL " + + " SELECT a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b " + + " WHERE a.subcompanyid1 = b.typevalue AND b.type=2 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') " + + " UNION ALL " + + " SELECT a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b " + + " WHERE a.departmentid = b.typevalue AND b.type=3 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') " + + " UNION ALL " + + " SELECT a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b " + + " WHERE a.jobtitle = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=5 " + + " AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))) " + + " and (b.isdelete is null or b.isdelete <> '1') " + + " UNION ALL " + + " SELECT a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b " + + " WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') ) t" + + " where 1=1 "; + if(!Util.null2String(isNoAccount).equals("1")){ + sql += " and t.status in (0,1,2,3) "; + } + sql += " and t.groupid = "+groupId; + }else{ + sql = " SELECT distinct resourceid, groupid FROM ( " + + " SELECT a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b,kq_group c " + + " WHERE a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') and (c.isdelete is null or c.isdelete <> '1') and c.id=b.groupid " + + " UNION ALL " + + " SELECT a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b,kq_group c " + + " WHERE a.subcompanyid1 = b.typevalue AND b.type=2 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') and (c.isdelete is null or c.isdelete <> '1') and c.id=b.groupid " + + " UNION ALL " + + " SELECT a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b,kq_group c " + + " WHERE a.departmentid = b.typevalue AND b.type=3 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') and (c.isdelete is null or c.isdelete <> '1') and c.id=b.groupid " + + " UNION ALL " + + " SELECT a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b,kq_group c " + + " WHERE a.jobtitle = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=5 " + + " AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))) " + + " and (b.isdelete is null or b.isdelete <> '1') and (c.isdelete is null or c.isdelete <> '1') and c.id=b.groupid " + + " UNION ALL " + + " SELECT a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b,kq_group c " + + " WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') and (c.isdelete is null or c.isdelete <> '1') and c.id=b.groupid ) t" + + " where 1=1 "; + if(!Util.null2String(isNoAccount).equals("1")){ + sql += " and t.status in (0,1,2,3) "; + } + } + } catch (Exception e) { + writeLog(e); + } + + return sql; + } + + public List getGroupMembers(String groupId) { + Map params = new HashMap<>(); + params.put("groupId",groupId); + return this.getGroupMembers(params); + } + + public List getGroupMembers(Map params) { + RecordSet rs = new RecordSet(); + List members = new ArrayList<>(); + try { + String sql = this.getGroupMemberSql(params); + rs.executeQuery(sql); + while (rs.next()) { + members.add(rs.getString("resourceid")); + } + } catch (Exception e) { + writeLog(e); + } + + return members; + } + + //根据传入的班次id,然后判断是否有考勤组引用这个班次 + public boolean serialIdIsUesed(String serialid) { + boolean serialIdUesed = false; + RecordSet rs = new RecordSet(); + String sql = ""; + IDbDialectSql dialectSql = DbDialectFactory.get(rs.getDBType()) ; + String isDeleteField = dialectSql.isNull("isdelete",0) ; + try { + sql = " select count(1) " + + " from (select distinct serialid from kq_fixedschedulce where serialid in ( ? ) and ("+isDeleteField+" !=1 ) "+ + " union " + + " select distinct serialid from kq_shiftschedule where serialid in ( ? ) and ("+isDeleteField+" !=1 ) ) t"; + rs.executeQuery(sql,serialid,serialid); + if (rs.next()){ + if(rs.getInt(1)>0){ + serialIdUesed = true; + } + } + + if(!serialIdUesed){ + + + if(rs.getDBType().equals("oracle")||rs.getDBType().equals("postgresql")) { + sql = " select count(1) from kq_group where ((','||serialids||',') like '%," + serialid + ",%' or (','||shiftcycleserialids||',') like '%," + serialid + ",%') and (isdelete is null or isdelete <> '1')"; + }else if(rs.getDBType().equals("mysql")){ + String serialidsConcatContion = dialectSql.concatStr("','","serialids","','") ; + String shiftcycleSerialidsConcatConditon = dialectSql.concatStr("','","shiftcycleserialids","','") ; + String groupIsDeleteCondition = dialectSql.isNull("isdelete",0) ; + String likeValue = "%,"+serialid+",%" ; + + sql = String.format(" select count(1) from kq_group where ((%s) like '%s' or (%s) like '%s') and (%s!=1)", + serialidsConcatContion,likeValue, + shiftcycleSerialidsConcatConditon,likeValue, + groupIsDeleteCondition) ; + }else{ + sql = " select count(1) from kq_group where (','+serialids+',' like '%," + serialid + ",%' or ','+shiftcycleserialids+',' like '%," + serialid + ",%') and (isdelete is null or isdelete <> '1')"; + } + + + + rs.executeQuery(sql); + if (rs.next()){ + if(rs.getInt(1)>0){ + serialIdUesed = true; + } + } + } + } catch (Exception e) { + writeLog(e); + } + return serialIdUesed; + } + + /** + * 根据传入的班次id,引用此班次的考勤组 + * @param serialid + * @return + */ + public List getGroupIdByUesedSerialId(String serialid) { + RecordSet rs = new RecordSet(); + List groupList = Lists.newArrayList(); + String sql = ""; + IDbDialectSql dialectSql = DbDialectFactory.get(rs.getDBType()) ; + String isDeleteField = dialectSql.isNull("isdelete",0) ; + try { + sql = " select serialid,groupid " + + " from (select distinct serialid,groupid from kq_fixedschedulce where serialid in ( ? ) and ("+isDeleteField+" !=1 ) "+ + " union " + + " select distinct serialid,groupid from kq_shiftschedule where serialid in ( ? ) and ("+isDeleteField+" !=1 ) ) t"; + rs.executeQuery(sql,serialid,serialid); + while (rs.next()){ + String tmp_groupId = rs.getString("groupid"); + if(!groupList.contains(tmp_groupId)){ + groupList.add(tmp_groupId); + } + } + + if(rs.getDBType().equals("oracle")||rs.getDBType().equals("postgresql")) { + sql = " select id from kq_group where ((','||serialids||',') like '%," + serialid + ",%' or (','||shiftcycleserialids||',') like '%," + serialid + ",%') and (isdelete is null or isdelete <> '1')"; + }else if(rs.getDBType().equals("mysql")){ + String serialidsConcatContion = dialectSql.concatStr("','","serialids","','") ; + String shiftcycleSerialidsConcatConditon = dialectSql.concatStr("','","shiftcycleserialids","','") ; + String groupIsDeleteCondition = dialectSql.isNull("isdelete",0) ; + String likeValue = "%,"+serialid+",%" ; + + sql = String.format(" select id from kq_group where ((%s) like '%s' or (%s) like '%s') and (%s!=1)", + serialidsConcatContion,likeValue, + shiftcycleSerialidsConcatConditon,likeValue, + groupIsDeleteCondition) ; + }else{ + sql = " select id from kq_group where (','+serialids+',' like '%," + serialid + ",%' or ','+shiftcycleserialids+',' like '%," + serialid + ",%') and (isdelete is null or isdelete <> '1')"; + } + + rs.executeQuery(sql); + while (rs.next()){ + String tmp_groupId = rs.getString("id"); + if(!groupList.contains(tmp_groupId)){ + groupList.add(tmp_groupId); + } + } + } catch (Exception e) { + writeLog(e); + } + return groupList; + } + + public Map getLocationWifiInfo(String userid,String showWifiList) { + Map result = new HashMap<>(); + Map locationInfo = new HashMap<>(); + Map wifiInfo = new HashMap<>(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQLoactionComInfo kqLoactionComInfo = new KQLoactionComInfo(); + String groupid = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid)); + List datas = null; + Map data = null; + + if(groupid.length()>0){ + datas = new ArrayList(); + while(kqLoactionComInfo.next()){ + if(!kqLoactionComInfo.getGroupid().equals(groupid))continue; + data = new HashMap<>(); + data.put("id",kqLoactionComInfo.getId()); + data.put("locationname",Util.null2String(kqLoactionComInfo.getLocationname())); + data.put("longitude",Util.null2String(kqLoactionComInfo.getLongitude())); + data.put("latitude",Util.null2String(kqLoactionComInfo.getLatitude())); + data.put("address",Util.null2String(kqLoactionComInfo.getAddress())); + data.put("checkscope",Util.null2String(kqLoactionComInfo.getCheckscope())); + data.put("groupid",Util.null2String(kqLoactionComInfo.getGroupid())); + datas.add(data); + } + locationInfo.put("locationcheck",Util.null2String(kqGroupComInfo.getLocationcheck(groupid)).equals("1")); + locationInfo.put("locationcheckscope",Util.null2String(kqGroupComInfo.getLocationcheckscope(groupid))); + locationInfo.put("locations",datas); + + datas = new ArrayList(); + if("1".equalsIgnoreCase(showWifiList)){ + KQWifiComInfo kqWifiComInfo = new KQWifiComInfo(); + while(kqWifiComInfo.next()){ + if(!kqWifiComInfo.getGroupid().equals(groupid))continue; + data = new HashMap<>(); + data.put("id",kqWifiComInfo.getId()); + data.put("wifiname",Util.null2String(kqWifiComInfo.getWifiname())); + data.put("mac",Util.null2String(kqWifiComInfo.getMac())); + data.put("groupid",Util.null2String(kqWifiComInfo.getGroupid())); + datas.add(data); + } + } + wifiInfo.put("wificheck",Util.null2String(kqGroupComInfo.getWificheck(groupid)).equals("1")); + wifiInfo.put("wifis",datas); + + result.put("locationInfo",locationInfo); + result.put("wifiInfo",wifiInfo); + result.put("status","1"); + + String show_position = "show_position"; + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String positioncheck = Util.null2String(kqSettingsComInfo.getMain_val(show_position),"0"); + result.put("positioncheck",positioncheck); + } + return result; + } + /** + * 用户考勤地点 WIFI限制信息 + * @param userid + * @return + */ + public Map getLocationWifiInfo(String userid) { + return getLocationWifiInfo(userid,"1"); + } + + /** + *判断办公地点范围 + * @return + */ + public Map checkLocationScope(String userId, String longitude, String latitude){ + Map retmap = new HashMap<>(); + Map loactionInfo = null; + try { + boolean inScope = false; + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(userId); + KQLoactionComInfo kqLoactionComInfo = new KQLoactionComInfo(); + Map locationTrueInfo = new HashMap<>(); + double distance = EARTH_RADIUS; + if (kqGroupEntity != null && kqGroupEntity.getLocationcheck().equals("1")) { + while (kqLoactionComInfo.next()) { + if (Util.null2String(kqLoactionComInfo.getGroupid()).equals(kqGroupEntity.getId())) { + double lng1 = Util.getDoubleValue(longitude);//经度 + double lat1 = Util.getDoubleValue(latitude);//纬度 + double lng2 = Util.getDoubleValue(kqLoactionComInfo.getLongitude());//经度 + double lat2 = Util.getDoubleValue(kqLoactionComInfo.getLatitude());//纬度 + int checkscope = Util.getIntValue(kqLoactionComInfo.getCheckscope());//有效范围 + double geo_distance = geo_distance(lng1, lat1, lng2, lat2); + if (distance > geo_distance) { + distance = geo_distance; + locationTrueInfo.put("lng2", lng2); + locationTrueInfo.put("lat2", lat2); + locationTrueInfo.put("checkscope", checkscope); + locationTrueInfo.put("geo_distance", geo_distance); +// locationTrueInfo = lng2 + "#" + lat2 + "#" + checkscope + "#" + geo_distance; + } + if (geo_distance < checkscope) { + inScope = true; + loactionInfo = new HashMap<>(); + loactionInfo.put("locationname", kqLoactionComInfo.getLocationname()); + loactionInfo.put("longitude", kqLoactionComInfo.getLongitude()); + loactionInfo.put("latitude", kqLoactionComInfo.getLatitude()); + loactionInfo.put("address", kqLoactionComInfo.getAddress()); + loactionInfo.put("id", kqLoactionComInfo.getId()); + loactionInfo.put("longitudefromoa", lng2); + loactionInfo.put("latitudefromoa", lat2); + loactionInfo.put("lengthfromoa", checkscope); + loactionInfo.put("lengthfromem", geo_distance); + break; + } + } + } + } else {//未开启开关 + inScope = true; + } + retmap.put("needCheck", kqGroupEntity != null ? Util.null2String(kqGroupEntity.getLocationcheck()) : "0");//是否开启办公地点验证 + retmap.put("inScope", inScope);//是否在考勤范围内 + retmap.put("locationshowaddress", kqGroupEntity != null ? Util.null2String(kqGroupEntity.getLocationshowaddress()) : "0");//有效识别半径内显示同一地址 + if (!inScope && locationTrueInfo != null && !locationTrueInfo.isEmpty()) { + if(loactionInfo == null) { + loactionInfo = new HashMap<>(); + } + loactionInfo.put("longitudefromoa", Util.null2String(locationTrueInfo.get("lng2"))); + loactionInfo.put("latitudefromoa", Util.null2String(locationTrueInfo.get("lat2"))); + loactionInfo.put("lengthfromoa", Util.null2String(locationTrueInfo.get("checkscope"))); + loactionInfo.put("lengthfromem", Util.null2String(locationTrueInfo.get("geo_distance"))); + } + }catch (Exception e) { + writeLog(e); + } + retmap.put("loactionInfo", loactionInfo);//考勤范围相关信息 + return retmap; + } + + /** + * 计算两个经度纬度(WGS-84)之间的距离 + * @param lng1 坐标1经度 + * @param lat1 坐标1纬度EARTH_RADIUS + * @param lng2 坐标2经度 + * @param lat2 坐标2纬度 + * @return 2个坐标之间距离,单位:米 + */ + private double geo_distance(double lng1, double lat1, double lng2, double lat2) { + double radLat1 = Math.toRadians(lat1); + double radLat2 = Math.toRadians(lat2); + double a = Math.abs(radLat1 - radLat2); + double b = Math.abs(Math.toRadians(lng1) - Math.toRadians(lng2)); + double distance = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); + distance = distance * EARTH_RADIUS; + distance = Math.round(distance * 10000) / 10000; + return distance; + } + + /** + *判断Wifi范围 + * @return + */ + public Map checkWifiScope(String userId, String wifiName, String mac){ + Map retmap = new HashMap<>(); + Map wifiInfo = null; + boolean inScope = false; + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(userId); + KQWifiComInfo kqWifiComInfo = new KQWifiComInfo(); + + if(kqGroupEntity.getWificheck().equals("1")){ + try{ + List lst = new ArrayList<>(Arrays.asList(mac.split(":"))); + for(int i = 0; i < lst.size(); i++){ + String s = lst.get(i); + if(s.length() == 1) + lst.set(i, "0" + s); + } + mac = String.join(":", lst); + }catch (Exception ex){ + ex.printStackTrace(); + } + while(kqWifiComInfo.next()){ + if(Util.null2String(kqWifiComInfo.getGroupid()).equals(kqGroupEntity.getId())){ + if(Util.null2String(kqWifiComInfo.getWifiname().toLowerCase()).equals(wifiName.toLowerCase())){ + String wifi_cominfo_mac = Util.null2String(kqWifiComInfo.getMac().toLowerCase()); + String param_mac = mac.toLowerCase(); + int last_wifi_mac_index = wifi_cominfo_mac.lastIndexOf(":"); + int param_mac_index = param_mac.lastIndexOf(":"); + if(last_wifi_mac_index > 0 && param_mac_index > 0){ + wifi_cominfo_mac = wifi_cominfo_mac.substring(0,last_wifi_mac_index); + param_mac = param_mac.substring(0,param_mac_index); + } + if(wifi_cominfo_mac.equals(param_mac)){ + inScope = true; + wifiInfo = new HashMap<>(); + wifiInfo.put("wifiname",kqWifiComInfo.getWifiname()); + wifiInfo.put("mac",kqWifiComInfo.getMac()); + break; + } + } + } + } + }else{//未开启开关 + inScope = true; + } + retmap.put("needCheck",Util.null2String(kqGroupEntity.getWificheck()));//是否开启wifi验证 + retmap.put("inScope",inScope);//是否在考勤范围内 + retmap.put("wifiInfo",wifiInfo);//考勤范围相关信息 + return retmap; + } + + /** + * 校验ipv4和v6范围 + * @param userId + * @param clientAddress + * @param ismobile + * @return + */ + public boolean getIsInScopeV4V6(String userId, String clientAddress,String ismobile) { + boolean isInScope = false; + clientAddress = Util.null2String(clientAddress).trim(); + if (clientAddress.length() == 0) { + return isInScope; + } + + RecordSet rs = new RecordSet(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupid = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userId)); + String signIpScope = Util.null2String(kqGroupComInfo.getIpscope(groupid)).trim();//格式:10.*.*.*;10.16.0.12;10.16.0.13-10.16.0.18 + String signIpscope_v4_em = Util.null2String(kqGroupComInfo.getIpscope_v4_em(groupid)).trim(); + String signIpscope_v4_pc = Util.null2String(kqGroupComInfo.getIpscope_v4_pc(groupid)).trim(); + String signIpscope_v6_em = Util.null2String(kqGroupComInfo.getIpscope_v6_em(groupid)).trim(); + String signIpscope_v6_pc = Util.null2String(kqGroupComInfo.getIpscope_v6_pc(groupid)).trim(); + if (signIpscope_v4_em.length() == 0 && signIpscope_v4_pc.length() == 0 + && signIpscope_v6_em.length() == 0 && signIpscope_v6_pc.length() == 0) { + return true; + } + + new KQLog().info("getIsInScopeV4V6:ismobile:"+ismobile+":signIpscope_v4_em:"+signIpscope_v4_em+":signIpscope_v6_em:"+signIpscope_v6_em + +":signIpscope_v4_pc:"+signIpscope_v4_pc+":signIpscope_v6_pc:"+signIpscope_v6_pc); + if("1".equalsIgnoreCase(ismobile)){ + if(signIpscope_v4_em.length() > 0){ + return checkIps(signIpscope_v4_em,clientAddress,"IPv4"); + }else if(signIpscope_v6_em.length() > 0){ + return checkIps(signIpscope_v6_em,clientAddress,"IPv6"); + }else{ + return true; + } + }else{ + if(signIpscope_v4_pc.length() > 0){ + return checkIps(signIpscope_v4_pc,clientAddress,"IPv4"); + }else if(signIpscope_v6_pc.length() > 0){ + return checkIps(signIpscope_v6_pc,clientAddress,"IPv6"); + }else{ + return true; + } + } + } + + + private boolean checkIps(String signIpScope, String clientAddress,String ipType) { + boolean isInScope = false; + List signIpScopeList = Util.TokenizerString(signIpScope, ";"); + String signIpScopeSingle = ""; + for (int i = 0; i < signIpScopeList.size(); i++) { + signIpScopeSingle = Util.null2String((String) signIpScopeList.get(i)); + signIpScopeSingle = signIpScopeSingle.trim(); + if("IPv4".equalsIgnoreCase(ipType)){ + isInScope = checkIpV4(signIpScopeSingle,clientAddress); + if(isInScope){ + break; + } + }else if("IPv6".equalsIgnoreCase(ipType)){ + isInScope = checkIpV6(signIpScopeSingle,clientAddress); + if(isInScope){ + break; + } + } + } + return isInScope; + } + + private boolean checkIpV6(String signIpScopeSingle, String clientAddress) { + + boolean isInScope = false; + if (signIpScopeSingle.indexOf("-") > -1) { + String signIpFrom = signIpScopeSingle.substring(0, signIpScopeSingle.indexOf("-")); + signIpFrom = Util.null2String(signIpFrom).trim(); + String signIpTo = ""; + if (!signIpScopeSingle.endsWith("-")) { + signIpTo = signIpScopeSingle.substring(signIpScopeSingle.indexOf("-") + 1); + } + signIpTo = Util.null2String(signIpTo).trim(); + String tempClientAddress = IpUtils.parseAbbreviationToFullIPv6(clientAddress); + signIpFrom = addToThreeFigure(signIpFrom, "signIpFrom"); + signIpTo = addToThreeFigure(signIpTo, "signIpTo"); + + signIpFrom = IpUtils.parseAbbreviationToFullIPv6(signIpFrom); + signIpTo = IpUtils.parseAbbreviationToFullIPv6(signIpTo); + + if (signIpFrom.equals("") && signIpTo.equals("")) { + isInScope = true; + } + if (signIpFrom.equals("") && !signIpTo.equals("")) { + if (tempClientAddress.compareTo(signIpTo) <= 0) { + isInScope = true; + } + } + + if (!signIpFrom.equals("") && signIpTo.equals("")) { + if (tempClientAddress.compareTo(signIpFrom) >= 0) { + isInScope = true; + } + } + if (!signIpFrom.equals("") && !signIpTo.equals("")) { + if (tempClientAddress.compareTo(signIpFrom) >= 0 && tempClientAddress.compareTo(signIpTo) <= 0) { + isInScope = true; + } + } + } else { + String tempClientAddress = IpUtils.parseAbbreviationToFullIPv6(clientAddress); + if (tempClientAddress.equals(signIpScopeSingle)) { + isInScope = true; + } + } + return isInScope; + } + + public boolean checkIpV4(String signIpScopeSingle,String clientAddress) { + + boolean isInScope = false; + if (signIpScopeSingle.indexOf("*") > -1) {//如果单个ip范围的格式为10.*.*.* + List signIpScopeSingleList = Util.TokenizerString(signIpScopeSingle, "."); + List clientAddressList = Util.TokenizerString(clientAddress, "."); + if (signIpScopeSingleList.size() == 4 + && clientAddressList.size() == 4 + && ("*".equals((String) signIpScopeSingleList.get(0)) + || Util.null2String((String) clientAddressList.get(0)).equals((String) signIpScopeSingleList.get(0))) + && ("*".equals((String) signIpScopeSingleList.get(1)) + || Util.null2String((String) clientAddressList.get(1)).equals((String) signIpScopeSingleList.get(1))) + && ("*".equals((String) signIpScopeSingleList.get(2)) + || Util.null2String((String) clientAddressList.get(2)).equals((String) signIpScopeSingleList.get(2))) + && ("*".equals((String) signIpScopeSingleList.get(3)) + || Util.null2String((String) clientAddressList.get(3)).equals((String) signIpScopeSingleList.get(2))) + ) { + isInScope = true; + } + } else if (signIpScopeSingle.indexOf("-") > -1) {//如果单个ip范围的格式为10.16.0.13-10.16.0.18 + String signIpFrom = signIpScopeSingle.substring(0, signIpScopeSingle.indexOf("-")); + signIpFrom = Util.null2String(signIpFrom).trim(); + String signIpTo = ""; + if (!signIpScopeSingle.endsWith("-")) { + signIpTo = signIpScopeSingle.substring(signIpScopeSingle.indexOf("-") + 1); + } + signIpTo = Util.null2String(signIpTo).trim(); + String tempClientAddress = addToThreeFigure(clientAddress, "clientAddress"); + signIpFrom = addToThreeFigure(signIpFrom, "signIpFrom"); + signIpTo = addToThreeFigure(signIpTo, "signIpTo"); + + if (signIpFrom.equals("") && signIpTo.equals("")) { + isInScope = true; + } + if (signIpFrom.equals("") && !signIpTo.equals("")) { + if (tempClientAddress.compareTo(signIpTo) <= 0) { + isInScope = true; + } + } + + if (!signIpFrom.equals("") && signIpTo.equals("")) { + if (tempClientAddress.compareTo(signIpFrom) >= 0) { + isInScope = true; + } + } + if (!signIpFrom.equals("") && !signIpTo.equals("")) { + if (tempClientAddress.compareTo(signIpFrom) >= 0 && tempClientAddress.compareTo(signIpTo) <= 0) { + isInScope = true; + } + } + } else {//否则单个ip范围的格式为10.16.0.12 + if (clientAddress.equals(signIpScopeSingle)) { + isInScope = true; + } + } + return isInScope; + } + + + /** + * 校验ip范围 + * @param clientAddress + * @return + */ + public boolean getIsInScope(String userId, String clientAddress) { + boolean isInScope = false; + clientAddress = Util.null2String(clientAddress).trim(); + if (clientAddress.length() == 0) { + return isInScope; + } + + RecordSet rs = new RecordSet(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupid = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userId)); + String signIpScope = Util.null2String(kqGroupComInfo.getIpscope(groupid)).trim();//格式:10.*.*.*;10.16.0.12;10.16.0.13-10.16.0.18 + if (signIpScope.length() == 0) { + return true; + } + + List signIpScopeList = Util.TokenizerString(signIpScope, ";"); + String signIpScopeSingle = ""; + for (int i = 0; i < signIpScopeList.size(); i++) { + signIpScopeSingle = Util.null2String((String) signIpScopeList.get(i)); + signIpScopeSingle = signIpScopeSingle.trim(); + if (signIpScopeSingle.indexOf("*") > -1) {//如果单个ip范围的格式为10.*.*.* + List signIpScopeSingleList = Util.TokenizerString(signIpScopeSingle, "."); + List clientAddressList = Util.TokenizerString(clientAddress, "."); + if (signIpScopeSingleList.size() == 4 + && clientAddressList.size() == 4 + && ("*".equals((String) signIpScopeSingleList.get(0)) + || Util.null2String((String) clientAddressList.get(0)).equals((String) signIpScopeSingleList.get(0))) + && ("*".equals((String) signIpScopeSingleList.get(1)) + || Util.null2String((String) clientAddressList.get(1)).equals((String) signIpScopeSingleList.get(1))) + && ("*".equals((String) signIpScopeSingleList.get(2)) + || Util.null2String((String) clientAddressList.get(2)).equals((String) signIpScopeSingleList.get(2))) + && ("*".equals((String) signIpScopeSingleList.get(3)) + || Util.null2String((String) clientAddressList.get(3)).equals((String) signIpScopeSingleList.get(2))) + ) { + isInScope = true; + break; + } + + } else if (signIpScopeSingle.indexOf("-") > -1) {//如果单个ip范围的格式为10.16.0.13-10.16.0.18 + String signIpFrom = signIpScopeSingle.substring(0, signIpScopeSingle.indexOf("-")); + signIpFrom = Util.null2String(signIpFrom).trim(); + String signIpTo = ""; + if (!signIpScopeSingle.endsWith("-")) { + signIpTo = signIpScopeSingle.substring(signIpScopeSingle.indexOf("-") + 1); + } + signIpTo = Util.null2String(signIpTo).trim(); + String tempClientAddress = addToThreeFigure(clientAddress, "clientAddress"); + signIpFrom = addToThreeFigure(signIpFrom, "signIpFrom"); + signIpTo = addToThreeFigure(signIpTo, "signIpTo"); + + if (signIpFrom.equals("") && signIpTo.equals("")) { + isInScope = true; + break; + } + if (signIpFrom.equals("") && !signIpTo.equals("")) { + if (tempClientAddress.compareTo(signIpTo) <= 0) { + isInScope = true; + break; + } + } + + if (!signIpFrom.equals("") && signIpTo.equals("")) { + if (tempClientAddress.compareTo(signIpFrom) >= 0) { + isInScope = true; + break; + } + } + if (!signIpFrom.equals("") && !signIpTo.equals("")) { + if (tempClientAddress.compareTo(signIpFrom) >= 0 && tempClientAddress.compareTo(signIpTo) <= 0) { + isInScope = true; + break; + } + } + } else {//否则单个ip范围的格式为10.16.0.12 + if (clientAddress.equals(signIpScopeSingle)) { + isInScope = true; + break; + } + } + } + return isInScope; + } + /** + * 将IP地址填充为3位数 + * 如 "192.168.0.25"填充为3位数后为"192.168.000.025" + * @return String 填充为3位数后的IP地址 + */ + private String addToThreeFigure(String IPAddress, String IPType) { + if (IPAddress == null || IPAddress.trim().equals("") || IPType == null || IPType.trim().equals("")) { + return ""; + } + String returnString = ""; + List IPAddressList = Util.TokenizerString(IPAddress, "."); + String IPAddressPart = ""; + for (int i = 0; i < IPAddressList.size(); i++) { + IPAddressPart = Util.null2String(IPAddressList.get(i)); + if (IPType.equals("signIpTo")) { + returnString += "." + Util.add0(Util.getIntValue(IPAddressPart, 255), 3); + } else { + returnString += "." + Util.add0(Util.getIntValue(IPAddressPart, 0), 3); + } + } + if (!returnString.equals("")) { + returnString = returnString.substring(1); + } + return returnString; + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQGroupComInfo.java b/src/com/engine/kq/biz/KQGroupComInfo.java new file mode 100644 index 0000000..e2868af --- /dev/null +++ b/src/com/engine/kq/biz/KQGroupComInfo.java @@ -0,0 +1,466 @@ +package com.engine.kq.biz; + +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; + +public class KQGroupComInfo extends CacheBase{ + protected static String TABLE_NAME = "kq_group"; + /** sql中的where信息,不要以where开始 */ + protected static String TABLE_WHERE = null; + /** sql中的order by信息,不要以order by开始 */ + protected static String TABLE_ORDER = "id"; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + @CacheColumn(name = "groupname") + protected static int groupname; + + @CacheColumn(name = "excludeid") + protected static int excludeid; + + @CacheColumn(name = "excludecount") + protected static int excludecount; + + @CacheColumn(name = "subcompanyid") + protected static int subcompanyid; + + @CacheColumn(name = "kqtype") + protected static int kqtype; + + @CacheColumn(name = "serialids") + protected static int serialids; + + @CacheColumn(name = "weekday") + protected static int weekday; + + @CacheColumn(name = "signstart") + protected static int signstart; + + @CacheColumn(name = "workhour") + protected static int workhour; + + @CacheColumn(name = "isdelete") + protected static int isdelete; + + @CacheColumn(name = "signintype") + protected static int signintype; + + @CacheColumn(name = "ipscope") + protected static int ipscope; + + @CacheColumn(name = "locationcheck") + protected static int locationcheck; + + @CacheColumn(name = "locationcheckscope") + protected static int locationcheckscope; + + @CacheColumn(name = "wificheck") + protected static int wificheck; + + @CacheColumn(name = "outsidesign") + protected static int outsidesign; + + @CacheColumn(name = "outsignapprove") + protected static int outsignapprove; + + @CacheColumn(name = "validity") + protected static int validity; + + @CacheColumn(name = "validityfromdate") + protected static int validityfromdate; + + @CacheColumn(name = "validityenddate") + protected static int validityenddate; + + @CacheColumn(name = "locationfacecheck") + protected static int locationfacecheck; + + @CacheColumn(name = "locationfacechecktype") + protected static int locationfacechecktype; + + @CacheColumn(name = "locationshowaddress") + protected static int locationshowaddress; + + @CacheColumn(name = "wififacecheck") + protected static int wififacecheck; + + @CacheColumn(name = "wififacechecktype") + protected static int wififacechecktype; + + @CacheColumn(name = "ipscope_v4_pc") + protected static int ipscope_v4_pc; + + @CacheColumn(name = "ipscope_v4_em") + protected static int ipscope_v4_em; + + @CacheColumn(name = "ipscope_v6_pc") + protected static int ipscope_v6_pc; + + @CacheColumn(name = "ipscope_v6_em") + protected static int ipscope_v6_em; + + @CacheColumn(name = "auto_checkin") + protected static int auto_checkin; + + @CacheColumn(name = "auto_checkin_before") + protected static int auto_checkin_before; + + @CacheColumn(name = "auto_checkin_after") + protected static int auto_checkin_after; + + @CacheColumn(name = "auto_checkout") + protected static int auto_checkout; + + @CacheColumn(name = "auto_checkout_before") + protected static int auto_checkout_before; + + @CacheColumn(name = "auto_checkout_after") + protected static int auto_checkout_after; + + @CacheColumn(name = "calmethod") + protected static int calmethod; + + @CacheColumn(name = "isPhotoPunchEnabled") + protected static int isPhotoPunchEnabled; + + /** + * 启用员工自我排班 + */ + @CacheColumn(name = "self_shift") + protected static int self_shift; + /** + * 0表示默认统一设置,1表示按照班次设置 + */ + @CacheColumn(name = "overtime_type") + protected static int overtime_type; + + + @CacheColumn(name = "abnormalremind") + protected static int abnormalremind; + + public String getId() { + return (String) getRowValue(PK_INDEX); + } + + public String getGroupname() { + return (String) getRowValue(groupname); + } + + public String getGroupname(String key) { + return (String) getValue(groupname, key); + } + + public String getExcludeid() { + return (String) getRowValue(excludeid); + } + + public String getExcludeid(String key) { + return (String) getValue(excludeid, key); + } + + public String getExcludecount() { + return (String) getRowValue(excludecount); + } + + public String getExcludecount(String key) { + return (String) getValue(excludecount, key); + } + + public String getSubcompanyid() { + return (String) getRowValue(subcompanyid); + } + + public String getSubcompanyid(String key) { + return (String) getValue(subcompanyid, key); + } + + public String getKqtype() { + return (String) getRowValue(kqtype); + } + + public String getKqtype(String key) { + return (String) getValue(kqtype, key); + } + + public String getSerialids() { + return (String) getRowValue(serialids); + } + + public String getSerialids(String key) { + return (String) getValue(serialids, key); + } + + public String getWeekday() { + return (String) getRowValue(weekday); + } + + public String getWeekday(String key) { + return (String) getValue(weekday, key); + } + + public String getSignstart() { + return (String) getRowValue(signstart); + } + + public String getSignstart(String key) { + return (String) getValue(signstart, key); + } + + public String getWorkhour() { + return (String) getRowValue(workhour); + } + + public String getWorkhour(String key) { + return (String) getValue(workhour, key); + } + + public String getIsdelete() { + return (String) getRowValue(isdelete); + } + + public String getIsdelete(String key) { + return (String) getValue(isdelete, key); + } + + public String getSignintype() { + return (String) getRowValue(signintype); + } + + public String getSignintype(String key) { + return (String) getValue(signintype, key); + } + + public String getIpscope() { + return (String) getRowValue(ipscope); + } + + public String getIpscope(String key) { + return (String) getValue(ipscope, key); + } + + public String getLocationcheck() { + return (String) getRowValue(locationcheck); + } + + public String getLocationcheck(String key) { + return (String) getValue(locationcheck, key); + } + + public String getLocationcheckscope() { + return (String) getRowValue(locationcheckscope); + } + + public String getLocationcheckscope(String key) { + return (String) getValue(locationcheckscope, key); + } + + public String getWificheck() { + return (String) getRowValue(wificheck); + } + + public String getWificheck(String key) { + return (String) getValue(wificheck, key); + } + + public String getOutsidesign() { + return (String) getRowValue(outsidesign); + } + + public String getOutsidesign(String key) { + return (String) getValue(outsidesign, key); + } + + public String getOutsignApprove() { + return (String) getRowValue(outsignapprove); + } + + public String getOutsignApprove(String key) { + return (String) getValue(outsignapprove, key); + } + + public String getValidity() { + return (String) getRowValue(validity); + } + + public String getValidity(String key) { + return (String) getValue(validity, key); + } + + public String getValidityfromdate() { + return (String) getRowValue(validityfromdate); + } + + public String getValidityfromdate(String key) { + return (String) getValue(validityfromdate, key); + } + + public String getValidityenddate() { + return (String) getRowValue(validityenddate); + } + + public String getValidityenddate(String key) { + return (String) getValue(validityenddate, key); + } + + public String getLocationfacecheck() { + return (String) getRowValue(locationfacecheck); + } + + public String getLocationfacecheck(String key) { + return (String) getValue(locationfacecheck, key); + } + + public String getLocationfacechecktype() { + return (String) getRowValue(locationfacechecktype); + } + + public String getLocationfacechecktype(String key) { + return (String) getValue(locationfacechecktype, key); + } + + public String getLocationshowaddress() { + return (String) getRowValue(locationshowaddress); + } + + public String getLocationshowaddress(String key) { + return (String) getValue(locationshowaddress, key); + } + + public String getWififacecheck() { + return (String) getRowValue(wififacecheck); + } + + public String getWififacecheck(String key) { + return (String) getValue(wififacecheck, key); + } + + public String getWififacechecktype() { + return (String) getRowValue(wififacechecktype); + } + + public String getWififacechecktype(String key) { + return (String) getValue(wififacechecktype, key); + } + + public String getIpscope_v4_pc() { + return (String) getRowValue(ipscope_v4_pc); + } + + public String getIpscope_v4_pc(String key) { + return (String) getValue(ipscope_v4_pc, key); + } + + public String getIpscope_v4_em() { + return (String) getRowValue(ipscope_v4_em); + } + + public String getIpscope_v4_em(String key) { + return (String) getValue(ipscope_v4_em, key); + } + + public String getIpscope_v6_pc() { + return (String) getRowValue(ipscope_v6_pc); + } + + public String getIpscope_v6_pc(String key) { + return (String) getValue(ipscope_v6_pc, key); + } + + public String getIpscope_v6_em() { + return (String) getRowValue(ipscope_v6_em); + } + + public String getIpscope_v6_em(String key) { + return (String) getValue(ipscope_v6_em, key); + } + + public String getAuto_checkin() { + return (String) getRowValue(auto_checkin); + } + + public String getAuto_checkin(String key) { + return (String) getValue(auto_checkin, key); + } + + public String getAuto_checkin_before() { + return (String) getRowValue(auto_checkin_before); + } + + public String getAuto_checkin_before(String key) { + return (String) getValue(auto_checkin_before, key); + } + + public String getAuto_checkin_after() { + return (String) getRowValue(auto_checkin_after); + } + + public String getAuto_checkin_after(String key) { + return (String) getValue(auto_checkin_after, key); + } + + public String getAuto_checkout() { + return (String) getRowValue(auto_checkout); + } + + public String getAuto_checkout(String key) { + return (String) getValue(auto_checkout, key); + } + + public String getAuto_checkout_before() { + return (String) getRowValue(auto_checkout_before); + } + + public String getAuto_checkout_before(String key) { + return (String) getValue(auto_checkout_before, key); + } + + public String getAuto_checkout_after() { + return (String) getRowValue(auto_checkout_after); + } + + public String getAuto_checkout_after(String key) { + return (String) getValue(auto_checkout_after, key); + } + + public String getOvertime_type() { + return (String) getRowValue(overtime_type); + } + + public String getOvertime_type(String key) { + return (String) getValue(overtime_type, key); + } + + public String getCalmethod() { + return (String) getRowValue(calmethod); + } + + public String getCalmethod(String key) { + return (String) getValue(calmethod, key); + } + + public String getSelf_shift() { + return (String) getRowValue(self_shift); + } + + public String getSelf_shift(String key) { + return (String) getValue(self_shift, key); + } + + public String getIsPhotoPunchEnabled() { + return (String) getRowValue(isPhotoPunchEnabled); + } + + public String getIsPhotoPunchEnabled(String key) { + return (String) getValue(isPhotoPunchEnabled, key); + } + public String getAbnormalremind() { + return (String)getRowValue(abnormalremind); + } + + public String getAbnormalremind(String key) { + return (String)getValue(abnormalremind,key); + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQGroupInit.java b/src/com/engine/kq/biz/KQGroupInit.java new file mode 100644 index 0000000..52a553b --- /dev/null +++ b/src/com/engine/kq/biz/KQGroupInit.java @@ -0,0 +1,147 @@ +package com.engine.kq.biz; + +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class KQGroupInit extends BaseBean { + + /** + * 初始化考勤组基本信息 + * @return + */ + public boolean initGroupBase(){ + boolean flag = false; + String sql = ""; + RecordSet rs = new RecordSet(); + try{ + int groupId = 0; + int serialId = 0; + sql = " select groupid,serialid from kq_inithistory"; + rs.executeQuery(sql); + if(rs.next()){ + groupId = rs.getInt("groupid"); + serialId = rs.getInt("serialid"); + } + + if(serialId>0){ + List lsParams = new ArrayList<>(); + boolean isdelete = new KQGroupComInfo().getIsdelete(""+groupId).equals("1"); + if(groupId<=0||isdelete){ + sql = " insert into kq_group (groupname,kqtype,signintype,locationcheckscope) values(?,?,?,?) "; + lsParams.add(""+ SystemEnv.getHtmlLabelName(10005305,weaver.general.ThreadVarLanguage.getLang())+""); + lsParams.add(1); + lsParams.add(1); + lsParams.add(300); + rs.executeUpdate(sql,lsParams); + + rs.executeQuery("select max(id) from kq_group") ; + if(rs.next()){ + groupId = rs.getInt(1); + } + + sql = "update kq_inithistory set groupid = ?"; + rs.executeUpdate(sql,groupId); + } + flag = true; + } + }catch (Exception e){ + writeLog(e); + } + return flag; + } + + /** + * 初始化考勤组班次信息 + * @return + */ + public boolean initGroupSerial(String workDate){ + boolean flag = false; + String sql = ""; + RecordSet rs = new RecordSet(); + try{ + int groupId = 0; + int serialId = 0; + sql = " select groupid,serialid from kq_inithistory"; + rs.executeQuery(sql); + if(rs.next()){ + groupId = rs.getInt("groupid"); + serialId = rs.getInt("serialid"); + } + + if(serialId>0&&groupId>0){ + for(int i=0;i<7;i++){ + int weekday = i;//星期几 + int id = 0; + int serialIdTemp = serialId; + if (("," + workDate + ",").indexOf("," + i + ",") == -1) { + serialIdTemp = -1;//周末为休息 + } + sql = " select id from kq_fixedschedulce where weekday = ? and groupid = ? "; + rs.executeQuery(sql, weekday, groupId); + if (rs.next()) { + id = rs.getInt("id"); + } + + if(id>0){ + sql = "update kq_fixedschedulce set serialid =? where id=? "; + rs.executeUpdate(sql,serialIdTemp==0?null:serialIdTemp,id); + }else{ + sql = "insert into kq_fixedschedulce(weekday,serialid,groupid) values(?,?,?)"; + rs.executeUpdate(sql,weekday,serialIdTemp==0?null:serialIdTemp,groupId); + } + } + flag = true; + } + }catch (Exception e){ + writeLog(e); + } + return flag; + } + + /** + * 初始化考勤组成员信息 + * @return + */ + public boolean initGroupMembers(){ + boolean flag = false; + String sql = ""; + RecordSet rs = new RecordSet(); + try{ + int groupId = 0; + int serialId = 0; + sql = " select groupid,serialid from kq_inithistory"; + rs.executeQuery(sql); + if(rs.next()){ + groupId = rs.getInt("groupid"); + serialId = rs.getInt("serialid"); + } + + if(groupId>0&&serialId>0) { + //考勤组成员重复判断,单条判断下 + boolean isExists = false; + sql = " select count(id) from kq_groupmember where type = 6 and (isdelete is null or isdelete <> '1') and groupid= ? "; + rs.executeQuery(sql, groupId); + if (rs.next()) { + if (rs.getInt(1) > 0) { + isExists = true; + } + } + if (!isExists) {//初始化所有人 安全级别255 + sql = " INSERT INTO kq_groupmember ( groupid, typevalue, type, seclevel, seclevelto,validatefrom,validateto) VALUES (?,?,?,?,?,?,?)"; + rs.executeUpdate(sql, groupId, 0, 6, 0, 255, KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE, KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE); + } + flag = true; + } + }catch (Exception e){ + writeLog(e); + } + return flag; + } +} diff --git a/src/com/engine/kq/biz/KQGroupMemberComInfo.java b/src/com/engine/kq/biz/KQGroupMemberComInfo.java new file mode 100644 index 0000000..6ce6b1e --- /dev/null +++ b/src/com/engine/kq/biz/KQGroupMemberComInfo.java @@ -0,0 +1,1000 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.entity.KQGroupEntity; +import com.engine.kq.log.KQLog; +import weaver.cache.*; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.StaticObj; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import java.io.PrintWriter; +import java.io.Serializable; +import java.io.StringWriter; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +public class KQGroupMemberComInfo extends CacheBase implements Serializable { + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化, 这个字段可以不定义 + */ + protected static String TABLE_NAME = ""; + + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化,或者不需要指定固定的条件, 这个字段可以不定义 + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = null; + + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化,或者不需要指定顺序, 这个字段可以不定义 sql中的order + * by信息,不要以order by开始 + * + */ + protected static String TABLE_ORDER = null; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + @CacheColumn + protected static int group; + + private KQLog kqLog = new KQLog(); + + private boolean isFormat = false; + + @Override + protected boolean autoInitIfNotFound() { + return false; + } + + private StaticObj staticobj = null; + + @Override + public CacheItem initCache(String key) { + + if (key == null || "".equals(key.trim())) { + return null; + } + + RecordSet rs = new RecordSet(); + String sql = ""; + kqLog = new KQLog(); + ConcurrentHashMap resourceKQGroups = new ConcurrentHashMap<>(); + //考勤组优先级 + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + + String subcompanyid = Util.null2String(resourceComInfo.getSubCompanyID(key));//分部 + String departmentid = Util.null2String(resourceComInfo.getDepartmentID(key));//部门 + String jobtitle = Util.null2String(resourceComInfo.getJobTitle(key));//岗位 + + //人员 + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.id=b.typevalue and b.type =1 and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1')" + + " and a.id = "+key+ + " order by b.groupid desc "; + rs.executeQuery(sql); + while (rs.next()) { + setMemberGroup(resourceKQGroups, rs.getString("resourceid"), rs.getString("groupid")); + } + + //部门 + if(departmentid.length()>0) { + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b , kq_group c" + + " WHERE a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + " and a.departmentid = " + departmentid + + " and a.id="+key+ + " order by b.groupid desc"; + rs.executeQuery(sql); + while (rs.next()) { + setMemberGroup(resourceKQGroups, rs.getString("resourceid"), rs.getString("groupid")); + } + } + + //分部 + if(subcompanyid.length()>0) { + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + " and a.subcompanyid1 = " + subcompanyid + + " and a.id="+key+ + " order by b.groupid desc "; + rs.executeQuery(sql); + while (rs.next()) { + setMemberGroup(resourceKQGroups, rs.getString("resourceid"), rs.getString("groupid")); + } + } + + //岗位 + if(jobtitle.length()>0) { + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.jobtitle = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=5 " + + " AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))) " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + " and a.jobtitle = " + jobtitle + + " and a.id="+key+ + " order by b.groupid desc "; + rs.executeQuery(sql); + while (rs.next()) { + setMemberGroup(resourceKQGroups, rs.getString("resourceid"), rs.getString("groupid")); + } + } + + //所有人 + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE (b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto) and b.groupid=c.id " + + " and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + " and a.id = "+key+ + " order by b.groupid desc "; + rs.executeQuery(sql); + while (rs.next()) { + setMemberGroup(resourceKQGroups, rs.getString("resourceid"), rs.getString("groupid")); + } + + if(resourceKQGroups.size()>0){ + CacheItem cacheItem = createCacheItem(); + Iterator> iterator = resourceKQGroups.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + String id = entry.getKey(); + List value = entry.getValue(); + cacheItem.set(PK_INDEX, id); + cacheItem.set(group, value); + modifyCacheItem(key, cacheItem); + } + return cacheItem; + } + } catch (Exception e) { + kqLog.info(e); + } + return null; + } + + private void getHasValidateGroupInfo() { + RecordSet rs = new RecordSet(); + String backFields = " b.groupid, b.typevalue, b.validatefrom as validatefrom, b.validateto as validateto,b.seclevel as groupseclevel,b.seclevelto as groupseclevelto, b.jobtitlelevel as jobtitlelevel, b.jobtitlelevelvalue as jobtitlelevelvalue "; + String sqlWhere = " and ((validatefrom <>'"+KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE+"') or (validateto <>'"+KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE+"'))"; + //人员 + String sql = " SELECT "+backFields+" FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.id=b.typevalue and b.type =1 and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1')" + + sqlWhere + " order by b.groupid desc "; + rs.executeQuery(sql); +// rs.writeLog("sql:::::::::"+sql); + List userGroupList = null; + while (rs.next()) { + String param = "type#1#"+rs.getString("typevalue"); + String groupId = rs.getString("groupid"); + String validatefrom = Util.null2String(rs.getString("validatefrom"), KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE); + String validateto = Util.null2String(rs.getString("validateto"), KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE); + String valueParam = groupId+"#"+validatefrom+"#"+validateto; + if(staticobj.getObject("User&GroupMember") == null) { + userGroupList = new ArrayList<>(); + } else { + userGroupList = (List)staticobj.getRecordFromObj("User&GroupMember",param); + if(userGroupList == null) { + userGroupList = new ArrayList<>(); + } + } + if(!userGroupList.contains(valueParam)) { + userGroupList.add(valueParam); + staticobj.putRecordToObj("User&GroupMember",param,userGroupList); + } +// rs.writeLog("userGroupList:::::::::"+JSON.toJSONString(userGroupList)); + } + //部门 + sql = " SELECT "+backFields+" FROM HrmResource a, kq_groupmember b , kq_group c" + + " WHERE a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + sqlWhere + + " order by b.groupid desc"; + rs.executeQuery(sql); + List departGroupList = null; + while (rs.next()) { + String param = "type#3#"+rs.getString("typevalue"); + String groupId = rs.getString("groupid"); + String validatefrom = Util.null2String(rs.getString("validatefrom"), KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE); + String validateto = Util.null2String(rs.getString("validateto"), KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE); + String groupseclevel = Util.null2String(rs.getString("groupseclevel")); + String groupseclevelto = Util.null2String(rs.getString("groupseclevelto")); + String valueParam = groupId+"#"+validatefrom+"#"+validateto+"#"+groupseclevel+"#"+groupseclevelto; + if(staticobj.getObject("Department&GroupMember") == null) { + departGroupList = new ArrayList<>(); + } else { + departGroupList = (List)staticobj.getRecordFromObj("Department&GroupMember",param); + if(departGroupList == null) { + departGroupList = new ArrayList<>(); + } + } + if(!departGroupList.contains(valueParam)) { + departGroupList.add(valueParam); + staticobj.putRecordToObj("Department&GroupMember",param,departGroupList); + } + } + //分部 + sql = " SELECT "+backFields+" FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + sqlWhere + + " order by b.groupid desc "; + rs.executeQuery(sql); + List subCompanyGroupList = null; + while (rs.next()) { + String param = "type#2#"+rs.getString("typevalue"); + String groupId = rs.getString("groupid"); + String validatefrom = Util.null2String(rs.getString("validatefrom"), KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE); + String validateto = Util.null2String(rs.getString("validateto"), KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE); + String groupseclevel = Util.null2String(rs.getString("groupseclevel")); + String groupseclevelto = Util.null2String(rs.getString("groupseclevelto")); + String valueParam = groupId+"#"+validatefrom+"#"+validateto+"#"+groupseclevel+"#"+groupseclevelto; + if(staticobj.getObject("SubCompany&GroupMember") == null) { + subCompanyGroupList = new ArrayList<>(); + } else { + subCompanyGroupList = (List)staticobj.getRecordFromObj("SubCompany&GroupMember",param); + if(subCompanyGroupList == null) { + subCompanyGroupList = new ArrayList<>(); + } + } + if(!subCompanyGroupList.contains(valueParam)) { + subCompanyGroupList.add(valueParam); + staticobj.putRecordToObj("SubCompany&GroupMember",param,subCompanyGroupList); + } + } + //岗位 + sql = " SELECT "+backFields+" FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.jobtitle = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=5 " + + " AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))) " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + sqlWhere + + " order by b.groupid desc "; + rs.executeQuery(sql); + List jobtitleGroupList = null; + while (rs.next()) { + String param = "type#5#"+rs.getString("typevalue"); + String groupId = rs.getString("groupid"); + String validatefrom = Util.null2String(rs.getString("validatefrom"), KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE); + String validateto = Util.null2String(rs.getString("validateto"), KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE); + String groupseclevel = Util.null2String(rs.getString("groupseclevel")); + String groupseclevelto = Util.null2String(rs.getString("groupseclevelto")); + String jobtitlelevel = Util.null2String(rs.getString("jobtitlelevel")); + jobtitlelevel = "".equals(jobtitlelevel) ? "-1" : jobtitlelevel; + String jobtitlelevelvalue = Util.null2String(rs.getString("jobtitlelevelvalue")); + jobtitlelevelvalue = "".equals(jobtitlelevelvalue) ? "-1" : ","+jobtitlelevelvalue+","; + String valueParam = groupId+"#"+validatefrom+"#"+validateto+"#"+groupseclevel+"#"+groupseclevelto+"#"+jobtitlelevel+"#"+jobtitlelevelvalue; + if(staticobj.getObject("Jobtitle&GroupMember") == null) { + jobtitleGroupList = new ArrayList<>(); + } else { + jobtitleGroupList = (List)staticobj.getRecordFromObj("Jobtitle&GroupMember",param); + if(jobtitleGroupList == null) { + jobtitleGroupList = new ArrayList<>(); + } + } + if(!jobtitleGroupList.contains(valueParam)) { + jobtitleGroupList.add(valueParam); + staticobj.putRecordToObj("Jobtitle&GroupMember",param,jobtitleGroupList); + } + } + //所有人 + sql = " SELECT "+backFields+" FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE (b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto) and b.groupid=c.id " + + " and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + sqlWhere + + " order by b.groupid desc "; + rs.executeQuery(sql); + rs.executeQuery(sql); + List allGroupList = null; + while (rs.next()) { + String param = "type#6#"+rs.getString("typevalue"); + String groupId = rs.getString("groupid"); + String validatefrom = Util.null2String(rs.getString("validatefrom"), KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE); + String validateto = Util.null2String(rs.getString("validateto"), KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE); + String groupseclevel = Util.null2String(rs.getString("groupseclevel")); + String groupseclevelto = Util.null2String(rs.getString("groupseclevelto")); + String valueParam = groupId+"#"+validatefrom+"#"+validateto+"#"+groupseclevel+"#"+groupseclevelto; + if(staticobj.getObject("All&GroupMember") == null) { + allGroupList = new ArrayList<>(); + } else { + allGroupList = (List)staticobj.getRecordFromObj("All&GroupMember",param); + if(allGroupList == null) { + allGroupList = new ArrayList<>(); + } + } + if(!allGroupList.contains(valueParam)) { + allGroupList.add(valueParam); + staticobj.putRecordToObj("All&GroupMember",param,allGroupList); + } + } + } + + @Override + public CacheMap initCache() { +// writeLog("KQGroupMemberComInfo::::::in:::::::2222::::::"); + staticobj = StaticObj.getInstance(); + staticobj.removeObject("User&GroupMember"); + staticobj.removeObject("Department&GroupMember"); + staticobj.removeObject("SubCompany&GroupMember"); + staticobj.removeObject("Jobtitle&GroupMember"); + staticobj.removeObject("All&GroupMember"); + getHasValidateGroupInfo(); + + CacheMap localData = createCacheMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + kqLog = new KQLog(); + ConcurrentHashMap resourceKQGroups = new ConcurrentHashMap<>(); + //考勤组优先级 + try { + //人员 + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.id=b.typevalue and b.type =1 and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') order by b.groupid desc "; + rs.executeQuery(sql); + while (rs.next()) { + setMemberGroup(resourceKQGroups, rs.getString("resourceid"), rs.getString("groupid")); + } + + //部门 + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b , kq_group c" + + " WHERE a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') order by b.groupid desc"; + rs.executeQuery(sql); + while (rs.next()) { + setMemberGroup(resourceKQGroups, rs.getString("resourceid"), rs.getString("groupid")); + } + + //分部 + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') order by b.groupid desc "; + rs.executeQuery(sql); + while (rs.next()) { + setMemberGroup(resourceKQGroups, rs.getString("resourceid"), rs.getString("groupid")); + } + + //岗位 + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.jobtitle = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=5 " + + " AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))) " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') order by b.groupid desc "; + rs.executeQuery(sql); + while (rs.next()) { + setMemberGroup(resourceKQGroups, rs.getString("resourceid"), rs.getString("groupid")); + } + + //所有人 + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE (b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto) and b.groupid=c.id " + + " and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') order by b.groupid desc "; + rs.executeQuery(sql); + while (rs.next()) { + setMemberGroup(resourceKQGroups, rs.getString("resourceid"), rs.getString("groupid")); + } + + if(resourceKQGroups.size()>0) { + Iterator> iterator = resourceKQGroups.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + String id = entry.getKey(); + List value = entry.getValue(); + CacheItem cacheItem = createCacheItem(); + cacheItem.set(PK_INDEX, id); + cacheItem.set(group, value); + modifyCacheItem(id, cacheItem); + localData.put(id, cacheItem); + } + } + } catch (Exception e) { + kqLog.writeLog(e); + } + return localData; + } + + private void setMemberGroup(ConcurrentHashMap resourceKQGroups, String resourceid, String groupid) { + try { + List kqGroups = null; + if (resourceKQGroups.get(resourceid) == null) { + kqGroups = new ArrayList<>(); + } else { + kqGroups = (List) resourceKQGroups.get(resourceid); + } + kqGroups.add(groupid); + resourceKQGroups.put(resourceid, kqGroups); + } catch (Exception e) { + kqLog.info(e); + } + } + + public String getKQGroupId(String userId) { + String workDate = DateUtil.getCurrentDate(); + return getKQGroupId(userId, workDate); + } + + /** + * 根据user获取考勤组id + * + * @param userId + * @return + */ + public String getKQGroupId(String userId, String workDate) { + return getKQGroupId(userId, workDate, true); + } + + /** + * 是否在考勤组的有效期范围内 + * @param tmpGroupId + * @param workDate + * @return + */ + private boolean isInKqGroupValidate(String tmpGroupId, String workDate) { + boolean flag = true; + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + String kqtype = kqGroupComInfo.getKqtype(tmpGroupId); + String validity = kqGroupComInfo.getValidity(tmpGroupId); + String validityfromdate = kqGroupComInfo.getValidityfromdate(tmpGroupId); + String validityenddate = kqGroupComInfo.getValidityenddate(tmpGroupId); + if (validity.equals("1")) { + if (!DateUtil.isInDateRange(workDate, validityfromdate, validityenddate)) { + flag = false; + } + } + return flag; + } + /*** + * 根据user获取考勤组id + * @param userId + * @param workDate + * @param containFixed 取不到排班取固定班 + * @return + */ + public String getKQGroupId(String userId, String workDate, boolean containFixed) { + String groupId = ""; + Map> allKqGroupsExceptSql = new HashMap<>(); + List kqGroups = getGroupBefore(userId, workDate, allKqGroupsExceptSql); + if(kqGroups.size() > 0) { + String tmpGroupId = kqGroups.get(0); + if(isInKqGroupValidate(tmpGroupId, workDate)) { + return tmpGroupId; + } + } + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + List lsGroupIds = this.getKQGroups(userId, workDate); + lsGroupIds.removeIf(allKqGroupsExceptSql::containsKey); + for (int i = 0; i < lsGroupIds.size(); i++) { + String tmpGroupId = Util.null2String((String) lsGroupIds.get(i)); + if(isInKqGroupValidate(tmpGroupId, workDate)) { + groupId = tmpGroupId; + } else { + continue; + } + String kqtype = kqGroupComInfo.getKqtype(tmpGroupId); +// String validity = kqGroupComInfo.getValidity(tmpGroupId); +// String validityfromdate = kqGroupComInfo.getValidityfromdate(tmpGroupId); +// String validityenddate = kqGroupComInfo.getValidityenddate(tmpGroupId); +// if (validity.equals("1")) { +// if (DateUtil.isInDateRange(workDate, validityfromdate, validityenddate)) { +// groupId = tmpGroupId; +// }else{ +// //超过有效期 +// continue; +// } +// } else { +// groupId = tmpGroupId; +// } + + //考勤组如果排班为空,取下一个考勤组 + if (groupId.length() > 0) { + if (containFixed && kqtype.equals("2")) { + KQShiftScheduleComInfo kqShiftScheduleComInfo = new KQShiftScheduleComInfo(); + kqShiftScheduleComInfo.setShiftGroupId(Util.getIntValue(groupId)); + if (Util.null2String(kqShiftScheduleComInfo.getSerialId(userId, workDate)).length() > 0 && + Util.null2String(kqShiftScheduleComInfo.getGroupId(userId, workDate)).equals(groupId)) { + break; + } + } else { + break; + } + } + } + return groupId; + } + + public List getKQGroups(String userId, String kqDate) { +// if(!this.isFormat){ +// return (List) getObjValue(group, userId); +// } + RecordSet rs = new RecordSet(); + String sql = ""; + kqLog = new KQLog(); + List kqGroups = new ArrayList<>(); +// Map> allKqGroupsExceptSql = new HashMap<>(); + //考勤组优先级 + try { +// Map> sqlWhereMap = sqlWhereMap(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); +// kqGroups = getGroupBefore(userId, kqDate, allKqGroupsExceptSql); +// if(kqGroups.size() > 0) { +// return kqGroups; +// } + String subcompanyid = Util.null2String(resourceComInfo.getSubCompanyID(userId));//分部 + String departmentid = Util.null2String(resourceComInfo.getDepartmentID(userId));//部门 + String jobtitle = Util.null2String(resourceComInfo.getJobTitle(userId));//岗位 + String sqlWhere = " and ('"+kqDate+"' between b.validatefrom and b.validateto) "; +// if(rs.getDBType().equalsIgnoreCase("oracle")) { +// sqlWhere = " and ('"+kqDate+"' between nvl(b.validatefrom,'2000-01-01') and nvl(b.validateto,'2999-12-31')) "; +// }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ +// sqlWhere = " and ('"+kqDate+"' between ifnull(b.validatefrom,'2000-01-01') and ifnull(b.validateto,'2999-12-31')) "; +// }else { +// sqlWhere = " and ('"+kqDate+"' between isnull(b.validatefrom,'2000-01-01') and isnull(b.validateto,'2999-12-31')) "; +// } + + //人员 + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.id=b.typevalue and b.type =1 and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1')" + + " and a.id = ?"+sqlWhere+ + " order by b.groupid desc "; + rs.executeQuery(sql,userId); + while (rs.next()) { + kqGroups.add(rs.getString("groupid")); + } + + //部门 + if(departmentid.length()>0) { + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b , kq_group c" + + " WHERE a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + " and a.departmentid = ? "+ + " and a.id= ? "+sqlWhere+ + " order by b.groupid desc"; + rs.executeQuery(sql,departmentid,userId); + while (rs.next()) { + kqGroups.add(rs.getString("groupid")); + } + } + + //分部 + if(subcompanyid.length()>0) { + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + " and a.subcompanyid1 = ? " + + " and a.id= ? "+sqlWhere+ + " order by b.groupid desc "; + rs.executeQuery(sql,subcompanyid,userId); + while (rs.next()) { + kqGroups.add(rs.getString("groupid")); + } + } + + //岗位 + if(jobtitle.length()>0) { + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.jobtitle = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=5 " + + " AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))) " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + " and a.jobtitle = ? " + + " and a.id= ? "+sqlWhere+ + " order by b.groupid desc "; + rs.executeQuery(sql,jobtitle,userId); + while (rs.next()) { + kqGroups.add(rs.getString("groupid")); + } + } + + //所有人 + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE (b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto) and b.groupid=c.id " + + " and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + " and a.id = ? "+sqlWhere+ + " order by b.groupid desc "; + rs.executeQuery(sql,userId); + while (rs.next()) { + kqGroups.add(rs.getString("groupid")); + } + } catch (Exception e) { + kqLog.info(e); + } +// kqGroups.removeIf(allKqGroupsExceptSql::containsKey); + return kqGroups; + } + + /** + * 如果设置了有效期,且查询在有效期范围内的,直接用 + * @return + */ + private List getGroupBefore(String userId, String kqDate, Map> allKqGroupsExceptSql) { + StaticObj groupMemberStaticObj = StaticObj.getInstance(); + RecordSet rs = new RecordSet(); + List kqGroups = new ArrayList<>(); + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String subcompanyid = Util.null2String(resourceComInfo.getSubCompanyID(userId));//分部 + String departmentid = Util.null2String(resourceComInfo.getDepartmentID(userId));//部门 + String jobtitle = Util.null2String(resourceComInfo.getJobTitle(userId));//岗位 + // 人员 + String param = "type#1#"+userId; + if(groupMemberStaticObj.getObject("User&GroupMember") != null) { + List userGroupList = (List)groupMemberStaticObj.getRecordFromObj("User&GroupMember",param); +// writeLog("userGroupList::::"+ JSON.toJSONString(userGroupList)); + if(userGroupList != null) { + for (String userGourp : userGroupList) { + String groupId = userGourp.split("#")[0]; + handle(allKqGroupsExceptSql, groupId, userId, "resourceId"); + String validateFrom = userGourp.split("#")[1]; + String validateTo = userGourp.split("#")[2]; + if (kqDate.compareTo(validateFrom) >= 0 && kqDate.compareTo(validateTo) <= 0) { + kqGroups.add(groupId); + } + } + if (kqGroups.size() > 0) { + return kqGroups; + } + } + } + //部门 + if (departmentid.length() > 0) { + param = "type#3#" + departmentid; + if (groupMemberStaticObj.getObject("Department&GroupMember") != null) { + List departGroupList = (List) groupMemberStaticObj.getRecordFromObj("Department&GroupMember", param); +// writeLog("departGroupList::::" + JSON.toJSONString(departGroupList)); + if (departGroupList != null) { + for (String departGroup : departGroupList) { + String groupId = departGroup.split("#")[0]; + String validateFrom = departGroup.split("#")[1]; + String validateTo = departGroup.split("#")[2]; + String groupseclevel = departGroup.split("#")[3]; + String groupseclevelto = departGroup.split("#")[4]; + int userSeclevel = Util.getIntValue(resourceComInfo.getSeclevel(userId)); + if (kqDate.compareTo(validateFrom) >= 0 && kqDate.compareTo(validateTo) <= 0 && userSeclevel>=Util.getIntValue(groupseclevel) + && userSeclevel<=Util.getIntValue(groupseclevelto)) { + if (allKqGroupsExceptSql.containsKey(groupId)) { + continue; + } + handle(allKqGroupsExceptSql, groupId, departmentid, "departmentId"); + kqGroups.add(groupId); + } + } + } + if (kqGroups.size() > 0) { + return kqGroups; + } + } + } + + //分部 + if (subcompanyid.length() > 0) { + param = "type#2#" + subcompanyid; + if (groupMemberStaticObj.getObject("SubCompany&GroupMember") != null) { + List subCompanyGroupList = (List) groupMemberStaticObj.getRecordFromObj("SubCompany&GroupMember", param); +// writeLog("subCompanyGroupList::::" + JSON.toJSONString(subCompanyGroupList)); + if (subCompanyGroupList != null) { + for (String subCompanyGroup : subCompanyGroupList) { + String groupId = subCompanyGroup.split("#")[0]; + String validateFrom = subCompanyGroup.split("#")[1]; + String validateTo = subCompanyGroup.split("#")[2]; + String groupseclevel = subCompanyGroup.split("#")[3]; + String groupseclevelto = subCompanyGroup.split("#")[4]; + int userSeclevel = Util.getIntValue(resourceComInfo.getSeclevel(userId)); + if (kqDate.compareTo(validateFrom) >= 0 && kqDate.compareTo(validateTo) <= 0 && userSeclevel>=Util.getIntValue(groupseclevel) + && userSeclevel<=Util.getIntValue(groupseclevelto)) { + if (allKqGroupsExceptSql.containsKey(groupId)) { + continue; + } + handle(allKqGroupsExceptSql, groupId, subcompanyid, "subcompanyId"); + kqGroups.add(groupId); + } + } + } + if (kqGroups.size() > 0) { + return kqGroups; + } + } + } + + //岗位 + if (jobtitle.length() > 0) { + param = "type#5#" + jobtitle; + if (groupMemberStaticObj.getObject("Jobtitle&GroupMember") != null) { + List jobtitleGroupList = (List) groupMemberStaticObj.getRecordFromObj("Jobtitle&GroupMember", param); +// writeLog("jobtitleGroupList::::" + JSON.toJSONString(jobtitleGroupList)); + if (jobtitleGroupList != null) { + for (String jobtitleGroup : jobtitleGroupList) { + String groupId = jobtitleGroup.split("#")[0]; + String validateFrom = jobtitleGroup.split("#")[1]; + String validateTo = jobtitleGroup.split("#")[2]; + String groupseclevel = jobtitleGroup.split("#")[3]; + String groupseclevelto = jobtitleGroup.split("#")[4]; + String jobtitlelevel = jobtitleGroup.split("#")[5]; + String jobtitlelevelvalue = jobtitleGroup.split("#")[6]; + int userSeclevel = Util.getIntValue(resourceComInfo.getSeclevel(userId)); + if("2".equals(jobtitlelevel)) { // 分部 + String subcompanyId = ","+resourceComInfo.getSubCompanyID(userId)+","; + if(!jobtitlelevelvalue.contains(subcompanyId)) { + continue; + } + } else if("3".equals(jobtitlelevel)) { // 部门 + String departmentId = ","+resourceComInfo.getDepartmentID(userId)+","; + if(!jobtitlelevelvalue.contains(departmentId)) { + continue; + } + } + if (kqDate.compareTo(validateFrom) >= 0 && kqDate.compareTo(validateTo) <= 0 && userSeclevel>=Util.getIntValue(groupseclevel) + && userSeclevel<=Util.getIntValue(groupseclevelto)) { + if (allKqGroupsExceptSql.containsKey(groupId)) { + continue; + } + handle(allKqGroupsExceptSql, groupId, jobtitle, "jobtitleId"); + kqGroups.add(groupId); + } + } + } + if (kqGroups.size() > 0) { + return kqGroups; + } + } + } + + //所有人 + param = "type#6#0"; + if (groupMemberStaticObj.getObject("All&GroupMember") != null) { + List allGroupList = (List) groupMemberStaticObj.getRecordFromObj("All&GroupMember", param); +// writeLog("allGroupList::::" + JSON.toJSONString(allGroupList)); + if (allGroupList != null) { + for (String allGroup : allGroupList) { + String groupId = allGroup.split("#")[0]; + String validateFrom = allGroup.split("#")[1]; + String validateTo = allGroup.split("#")[2]; + String groupseclevel = allGroup.split("#")[3]; + String groupseclevelto = allGroup.split("#")[4]; + int userSeclevel = Util.getIntValue(resourceComInfo.getSeclevel(userId)); + if (kqDate.compareTo(validateFrom) >= 0 && kqDate.compareTo(validateTo) <= 0 && userSeclevel>=Util.getIntValue(groupseclevel) + && userSeclevel<=Util.getIntValue(groupseclevelto)) { + if (allKqGroupsExceptSql.containsKey(groupId)) { + continue; + } + handle(allKqGroupsExceptSql, groupId, "0", "all"); + kqGroups.add(groupId); + } + } + if (kqGroups.size() > 0) { + return kqGroups; + } + } + } + }catch (Exception e) { + writeLog(e); + } + return kqGroups; + } + + private Map> sqlWhereMap() { + // 先把所有的groupid找到 + RecordSet rs = new RecordSet(); + Map> allKqGroupsExceptSql = new HashMap<>(); + String sql = "select * from kq_groupmember where (isDelete is null or isDelete<>1)"; + rs.executeQuery(sql); + while (rs.next()) { + String groupId = rs.getString("id"); + int groupType = rs.getInt("type"); + String groupTypeValue = rs.getString("typevalue"); + + switch (groupType) { + case 1: + handle(allKqGroupsExceptSql, groupId, groupTypeValue, "resourceId"); + break; + case 2: + handle(allKqGroupsExceptSql, groupId, groupTypeValue, "subcompanyId"); + break; + case 3: + handle(allKqGroupsExceptSql, groupId, groupTypeValue, "departmentId"); + break; + case 5: + handle(allKqGroupsExceptSql, groupId, groupTypeValue, "jobTitleId"); + break; + case 6: + handle(allKqGroupsExceptSql, groupId, groupTypeValue, "all"); + break; + default: + break; + } + + } + return allKqGroupsExceptSql; + } + + private void handle(Map> allKqGroupsExceptSql, String groupId, String groupTypeValue, String key) { + Map sqlWhereMap = null; + String sqlWhereValue = groupTypeValue; + if(allKqGroupsExceptSql.containsKey(groupId)) { + sqlWhereMap = allKqGroupsExceptSql.get(groupId); + if (sqlWhereMap.containsKey(key)) { + sqlWhereValue = sqlWhereMap.get(key) + "," + groupTypeValue; + } + } else { + sqlWhereMap = new HashMap<>(); + } + sqlWhereMap.put(key, sqlWhereValue); + allKqGroupsExceptSql.put(groupId, sqlWhereMap); + } + /** + * 根据user获取所有考勤组 + * + * @param userId + * @return + */ + private List getKQGroups(String userId) { + if(!this.isFormat){ + return (List) getObjValue(group, userId); + } + RecordSet rs = new RecordSet(); + String sql = ""; + kqLog = new KQLog(); + List kqGroups = new ArrayList<>(); + //考勤组优先级 + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + + String subcompanyid = Util.null2String(resourceComInfo.getSubCompanyID(userId));//分部 + String departmentid = Util.null2String(resourceComInfo.getDepartmentID(userId));//部门 + String jobtitle = Util.null2String(resourceComInfo.getJobTitle(userId));//岗位 + + //人员 + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.id=b.typevalue and b.type =1 and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1')" + + " and a.id = ?"+ + " order by b.groupid desc "; + rs.executeQuery(sql,userId); + while (rs.next()) { + kqGroups.add(rs.getString("groupid")); + } + + //部门 + if(departmentid.length()>0) { + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b , kq_group c" + + " WHERE a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + " and a.departmentid = ? "+ + " and a.id= ? "+ + " order by b.groupid desc"; + rs.executeQuery(sql,departmentid,userId); + while (rs.next()) { + kqGroups.add(rs.getString("groupid")); + } + } + + //分部 + if(subcompanyid.length()>0) { + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + " and a.subcompanyid1 = ? " + + " and a.id= ? "+ + " order by b.groupid desc "; + rs.executeQuery(sql,subcompanyid,userId); + while (rs.next()) { + kqGroups.add(rs.getString("groupid")); + } + } + + //岗位 + if(jobtitle.length()>0) { + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE a.jobtitle = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=5 " + + " AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))) " + + " and b.groupid=c.id and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + " and a.jobtitle = ? " + + " and a.id= ? "+ + " order by b.groupid desc "; + rs.executeQuery(sql,jobtitle,userId); + while (rs.next()) { + kqGroups.add(rs.getString("groupid")); + } + } + + //所有人 + sql = " SELECT distinct a.id AS resourceid, b.groupid, a.status FROM HrmResource a, kq_groupmember b, kq_group c " + + " WHERE (b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto) and b.groupid=c.id " + + " and (c.isdelete is null or c.isdelete <> '1') and (b.isdelete is null or b.isdelete <> '1') " + + " and a.id = ? "+ + " order by b.groupid desc "; + rs.executeQuery(sql,userId); + while (rs.next()) { + kqGroups.add(rs.getString("groupid")); + } + } catch (Exception e) { + kqLog.info(e); + } + return kqGroups; + } + + /** + * 根据user获取所有考勤组id + * + * @param userId + * @return + */ + public String getKQGroupIds(String userId) { + String groupId = ""; + String kqDate = DateUtil.getCurrentDate(); + List lsGroupIds = this.getKQGroups(userId, kqDate); + if (lsGroupIds != null) { + groupId = String.join(",", lsGroupIds); + } + return groupId; + } + + public String getKQGroupIds(String userId, String kqDate) { + String groupId = ""; + List lsGroupIds = this.getKQGroups(userId, kqDate); + if (lsGroupIds != null) { + groupId = String.join(",", lsGroupIds); + } + return groupId; + } + + + public KQGroupEntity getUserKQGroupInfo(String userId) { + String workDate = DateUtil.getCurrentDate(); + return getUserKQGroupInfo(userId, workDate); + } + + /** + * 获取考勤组相关信息 + * + * @param userId + * @return + */ + public KQGroupEntity getUserKQGroupInfo(String userId, String workDate) { + return getUserKQGroupInfo(userId, workDate, true); + } + + /*** + * 获取考勤组相关信息 + * @param userId + * @param workDate + * @param containFixed 取不到排班取固定班 + * @return + */ + public KQGroupEntity getUserKQGroupInfo(String userId, String workDate, boolean containFixed) { + KQGroupEntity kqGroupEntity = null; + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + try { + String groupid = Util.null2String(this.getKQGroupId(userId, workDate, containFixed)); + if (groupid.length() > 0) { + kqGroupEntity = new KQGroupEntity(); + kqGroupEntity.setId(groupid); + kqGroupEntity.setGroupname(kqGroupComInfo.getGroupname(groupid)); + kqGroupEntity.setExcludeid(kqGroupComInfo.getExcludeid(groupid)); + kqGroupEntity.setSubcompanyid(kqGroupComInfo.getSubcompanyid(groupid)); + kqGroupEntity.setKqtype(kqGroupComInfo.getKqtype(groupid)); + kqGroupEntity.setSerialids(kqGroupComInfo.getSerialids(groupid)); + kqGroupEntity.setWeekday(kqGroupComInfo.getWeekday(groupid)); + kqGroupEntity.setSignstart(kqGroupComInfo.getSignstart(groupid)); + kqGroupEntity.setWorkhour(kqGroupComInfo.getWorkhour(groupid)); + kqGroupEntity.setIsdelete(kqGroupComInfo.getIsdelete(groupid)); + kqGroupEntity.setSignintype(kqGroupComInfo.getSignintype(groupid)); + kqGroupEntity.setIpscope(kqGroupComInfo.getIpscope(groupid)); + kqGroupEntity.setLocationcheck(kqGroupComInfo.getLocationcheck(groupid)); + kqGroupEntity.setLocationcheckscope(kqGroupComInfo.getLocationcheckscope(groupid)); + kqGroupEntity.setWificheck(kqGroupComInfo.getWificheck(groupid)); + kqGroupEntity.setOutsidesign(kqGroupComInfo.getOutsidesign(groupid)); + kqGroupEntity.setOutsignapprove(kqGroupComInfo.getOutsignApprove(groupid)); + kqGroupEntity.setCalmethod(kqGroupComInfo.getCalmethod(groupid)); + kqGroupEntity.setLocationshowaddress(kqGroupComInfo.getLocationshowaddress(groupid)); + kqGroupEntity.setAbnormalremind(kqGroupComInfo.getAbnormalremind(groupid)); + } + } catch (Exception e) { + kqLog.info(e); + } + return kqGroupEntity; + } + + public void removeCache() { + super.removeCache(); + + } + + public void setIsFormat(boolean isFormat){ + this.isFormat = isFormat; + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQHolidaySetBiz.java b/src/com/engine/kq/biz/KQHolidaySetBiz.java new file mode 100644 index 0000000..f3560aa --- /dev/null +++ b/src/com/engine/kq/biz/KQHolidaySetBiz.java @@ -0,0 +1,499 @@ +package com.engine.kq.biz; + +import com.engine.integration.util.MyX509TrustManager; +import com.engine.kq.log.KQLog; +import net.sf.json.JSONObject; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.*; + +/** + * 节假日设置相关接口数据 + */ +public class KQHolidaySetBiz { + + private static KQLog logger = new KQLog(); + + /** + * 获取指定考勤组ID获取节假日设置数据 + * + * @param resourceId 指定人员的ID + * @param year 指定年份 + * @param month 指定月份 指定月份为空时查询指定年份一整年的数据 + * @return + */ + public static List getGroupHolidaySetList(String groupId, String year, String month) { + List> valueList = new ArrayList>(); + Map valueMap = new HashMap(); + /*指定年月*/ + String startDate = year; + String endDate = month; + if (month.length() == 0) { + startDate = year + "-01" + "-01"; + endDate = year + "-12" + "-31"; + } else if (month.length() == 1) { + startDate = year + "-0" + month + "-01"; + endDate = year + "-0" + month + "-31"; + } else if (month.length() == 2) { + startDate = year + "-" + month + "-01"; + endDate = year + "-" + month + "-31"; + } + RecordSet recordSet = new RecordSet(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQHolidaySetComInfo holidaySetComInfo = new KQHolidaySetComInfo(); + boolean isEnd = false; + for (String date = startDate; !isEnd; ) { + if (date.compareTo(endDate) >= 0) { + isEnd = true; + } + + String changeType = holidaySetComInfo.getChangeType(groupId, date); + String holidayDesc = holidaySetComInfo.getHolidayDesc(groupId, date); + if (!changeType.equals("")) { + valueMap = new HashMap(); + valueMap.put("date", date); + valueMap.put("name", holidayDesc); + valueMap.put("type", changeType); + valueList.add(valueMap); + } + date = DateUtil.getDate(date, 1); + } + return valueList; + } + + /** + * 获取指定考勤组ID获取节假日设置数据 + * + * @param resourceId 指定人员的ID + * @param year 指定年份 + * @param month 指定月份 指定月份为空时查询指定年份一整年的数据 + * @return + */ + public static List getKQHolidaySetList(String resourceId, String year, String month) { + + List> valueList = new ArrayList>(); + + /*指定年月*/ + String startDate = year; + String endDate = month; + if (month.length() == 0) { + startDate = year + "-01" + "-01"; + endDate = year + "-12" + "-31"; + } else if (month.length() == 1) { + startDate = year + "-0" + month + "-01"; + endDate = year + "-0" + month + "-31"; + } else if (month.length() == 2) { + startDate = year + "-" + month + "-01"; + endDate = year + "-" + month + "-31"; + } + valueList = getHolidaySetListByScope(resourceId, startDate, endDate); + return valueList; + } + + /** + * 根据日期范围获取节假日数据 + * + * @param resourceId 指定人员的ID + * @param startDate 指定日期范围的起点 + * @param endDate 指定日期范围的终点 + * @return + */ + public static List getHolidaySetListByScope(String resourceId, String startDate, String endDate) { + Map valueMap = new HashMap(); + List> valueList = new ArrayList>(); + + + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQHolidaySetComInfo holidaySetComInfo = new KQHolidaySetComInfo(); + + boolean isEnd = false; + for (String date = startDate; !isEnd; ) { + if (date.compareTo(endDate) >= 0) { + isEnd = true; + } + + /*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/ + String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date); + + String changeType = holidaySetComInfo.getChangeType(groupId, date); + String holidayDesc = holidaySetComInfo.getHolidayDesc(groupId, date); + if (!changeType.equals("")&&!getWorkDay(resourceId, date)) { + valueMap = new HashMap(); + valueMap.put("date", date); + valueMap.put("name", holidayDesc); + valueMap.put("type", changeType); + valueList.add(valueMap); + } + date = DateUtil.getDate(date, 1); + } + return valueList; + } + + + /** + * 判断某天是否是节假日(公众假日+调配休息日) + * + * @param resourceId 指定人员ID + * @param date 指定日期 + * @return true-节假日、false、不是节假日 + */ + public static boolean isHoliday(String resourceId, String date) { + return isHoliday(resourceId, date, false); + } + + /** + * 判断某天是否是节假日(公众假日+调配休息日+周末) + * + * @param resourceId 指定人员ID + * @param date 指定日期 + * @param containWeekend 是否包含周末 为true包含周末、false不包含 + * @return true-节假日、false、不是节假日 + */ + public static boolean isHoliday(String resourceId, String date, boolean containWeekend) { + boolean flag = false; + if(getWorkDay(resourceId, date)){ + return flag; + } + /*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/ + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date); + + int changeType = getChangeType(groupId, date); + /*如果需要包含周末,判断传入的日期是不是周末*/ + if (containWeekend && changeType != 2 && (DateUtil.getWeek(date) == 6 || DateUtil.getWeek(date) == 7)) { + flag = true; + } + if (changeType == 1 || changeType == 3) { + flag = true; + } + return flag; + } + + /** + * 判断某天是否是节假日(公众假日+调配休息日+周末) + * + * @param resourceId 指定人员ID + * @param date 指定日期 + * @return true-节假日、false、不是节假日 + */ + public static boolean isDouble(String resourceId, String date) { + boolean flag = false; + /*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/ + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date); + + int changeType = getChangeType(groupId, date); + if (changeType == 1 || changeType == 3) { + flag = true; + } + return flag; + } + + /** + * 获取人员指定日期是否有排班的考勤排班:(当考勤组属于排班制时) + * + * @param resourceId 指定人员的ID + * @param date 指定日期 + * @return + */ + public static boolean getWorkDay(String resourceId, String date) { + boolean flag = false; + /*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/ + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date); + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String holiday_is_priority = Util.null2String(kqSettingsComInfo.getMain_val("holiday_is_priority"),"0"); + if("0".equals(holiday_is_priority)) { + return flag; + } + /*排班制不支持调配节假日数据*/ + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + String KQType = kqGroupComInfo.getKqtype(groupId);//考勤类型:1-固定班制、2-排班制、3-自由班制 + if (KQType.equals("2")) { + flag = true; + } + return flag; + } + /** + * 获取当前日期是何种类型(这里只考虑节假日设置) + * + * @param groupId 考勤组ID + * @param date 指定日期 + * @return 1-节假日、2-工作日、3-休息日、-1-没有设置过数据 + */ + public static int getChangeType(String groupId, String date) { + int changeType = -1;//默认没有设置过节假日(节假日设置的类型:1-公众假日、2-调配工作日、3-调配休息日) + KQHolidaySetComInfo kqHolidaySetComInfo = new KQHolidaySetComInfo(); + String tmpChangetype = kqHolidaySetComInfo.getChangeType(groupId, date); + if(null != tmpChangetype){ + changeType = Util.getIntValue(tmpChangetype, -1); + } + + return changeType; + } + + /** + * 获取调配工作日时的指定工作日(当考勤组不属于排班制时) + * + * @param resourceId 指定人员的ID + * @param date 指定日期 + * @return + */ + public static int getRelatedDay(String resourceId, String date) { + int relatedDay = -1; + + /*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/ + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date); + + /*排班制不支持调配节假日数据*/ + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + String KQType = kqGroupComInfo.getKqtype(groupId);//考勤类型:1-固定班制、2-排班制、3-自由班制 + if (KQType.equals("2")) { + return relatedDay; + } + + /*只有当调配工作日时才有对应工作日*/ + KQHolidaySetComInfo kqHolidaySetComInfo = new KQHolidaySetComInfo(); + int changeType = Util.getIntValue(kqHolidaySetComInfo.getChangeType(groupId, date), -1); + if (changeType == 2) { + relatedDay = Util.getIntValue(kqHolidaySetComInfo.getRelatedDay(groupId, date), 0); + } + + return relatedDay; + } + + /** + * 指定的考勤组初始化节假日设置数据(只初始化固定班制和自由班制) + * + * @param groupIds 指定考勤组ID(多个ID之间用,分隔) + * @param year 指定年份 + * @return + */ + public static Map initHolidaySet(String groupIds, String year, User user) { + Map resultMap = new HashMap(); + List errInfoList = new ArrayList();//错误信息集合 + /** + * 调用网上的节假日API,数据格式如下(不是JSON字符串):(此后如果原来的节假日API不能用了,只要调整将新的API接口调整成如下格式即可) + * status:1-成功、0-失败 + * sketch:'简要描述错误原因' + * holidayList:[{holidayDate:'',changeType:'',holidayDesc:''},……,{holidayDate:'',changeType:'',holidayDesc:''}] + */ + String url = Prop.getInstance().getPropValue("kq_settings", "KQHolidaySetUrl"); + Map tempMap = httpRequest(url +"?year="+year+"&key="+Util.getEncrypt(Util.getRandom()), user); + if ("0".equals((String) tempMap.get("status"))) { + resultMap.put("status", "0"); + resultMap.put("sketch", (String) tempMap.get("sketch")); + return resultMap; + } + List holidayDateList = new ArrayList(); + try { + List groupIdList = Util.TokenizerString(groupIds, ",");//考勤组ID集合 + for (int i = 0; i < groupIdList.size(); i++) { + String groupId = groupIdList.get(i); + /** + * 预先加载此考勤组已经调整了哪些日期了,如果某日期在初始化之前已经调整过了,删除掉原来的数据,插入新的数据 + */ + List dateList = new ArrayList(); + KQHolidaySetComInfo kqHolidaySetComInfo = new KQHolidaySetComInfo(); + kqHolidaySetComInfo.setTofirstRow(); + while (kqHolidaySetComInfo.next()) { + if (kqHolidaySetComInfo.getGroupId().equals(groupId)) { + dateList.add(kqHolidaySetComInfo.getHolidayDate()); + } + } + + /** + * 预先加载固定班制周一~周日这一周中一天开始上班的是周几 + */ + int relatedDay = 0; + for (int x = 0; x < 7; x++) { + KQFixedSchedulceComInfo kqFixedSchedulceComInfo = new KQFixedSchedulceComInfo(); + String serialId = Util.null2String(kqFixedSchedulceComInfo.getSerialid(groupId, x)); + if (!serialId.equals("")) { + relatedDay = x; + break; + } + } + + /** + * 初始化改考勤组的节假日数据(只初始化) + */ + boolean flag = true; + RecordSet recordSet = new RecordSet(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + + List> holidayList = (List>) tempMap.get("holidayList"); + Map holidayMap = new HashMap(); + + if(holidayList.size()>0){ + String tmpsql = "delete from kq_HolidaySet where groupId='"+groupId+"' and holidayDate>='"+year+"-01-01' and holidayDate<='"+year+"-12-31' "; + recordSet.executeUpdate(tmpsql); + } + + for (int j = 0; j < holidayList.size(); j++) { + holidayMap = holidayList.get(j); + + String holidayDate = year + "-" + (String) holidayMap.get("holidayDate"); + if (!holidayDateList.contains(holidayDate)) { + holidayDateList.add(holidayDate); + } + int changeType = (int) holidayMap.get("changeType"); + if (kqGroupComInfo.getKqtype(groupId).equals("2")&&changeType == 2 ) { + //排班制的考勤组不能初始化调配工作日 + continue; + } + String holidayDesc = (String) holidayMap.get("holidayDesc"); + if (dateList.contains(holidayDate)) { + String deleteSql = "delete from kq_HolidaySet where groupId=? and holidayDate=?"; + recordSet.executeUpdate(deleteSql, groupId, holidayDate); + } + + String sql = "insert into kq_HolidaySet(groupId,holidayDate,changeType,holidayDesc,relatedDay) values(?,?,?,?,?)"; + flag = recordSet.executeUpdate(sql, groupId, holidayDate, changeType, holidayDesc, relatedDay); + if (!flag) { + errInfoList.add(SystemEnv.getHtmlLabelName(5056701, user.getLanguage()).replace("$groupName$", kqGroupComInfo.getGroupname(groupId)).replace("$holidayDate$", holidayDate)); + } + } + } + + /** + * 如果没有错误信息则代表初始化成功 + */ + if (errInfoList.size() > 0) { + resultMap.put("status", "0"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(125960, user.getLanguage())); + resultMap.put("description", errInfoList); + } else { + resultMap.put("status", "1"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(20196, user.getLanguage())); + } + } catch (Exception e) { + resultMap.put("status", "0"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + resultMap.put("desscription", errInfoList); + } finally { + /*刷新缓存*/ + KQHolidaySetComInfo kqHolidaySetComInfo = new KQHolidaySetComInfo(); + kqHolidaySetComInfo.removeCache(); + + /*刷新考勤报表*/ + logger.info("初始化节假日数据,格式化考勤报表。groupIdList=" + com.alibaba.fastjson.JSONObject.toJSONString(groupIds) + + "。holidayDateList=" + com.alibaba.fastjson.JSONObject.toJSONString(holidayDateList)); + List groupIdList = Util.TokenizerString(groupIds, ",");//考勤组ID集合 + new KQHolidaySetThread(groupIdList,holidayDateList).start(); + } + return resultMap; + } + + /** + * 请求网络上的节假日API接口,获取节假日设置数据 + * + * @param requestUrl + * @return + */ + private static Map httpRequest(String requestUrl, User user) { + Map resultMap = new HashMap(); + //buffer用于接受返回的字符 + StringBuffer buffer = new StringBuffer(); + try { + TrustManager[] tm = {new MyX509TrustManager()}; + SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE"); + sslContext.init(null, tm, new java.security.SecureRandom()); + SSLSocketFactory ssf = sslContext.getSocketFactory(); + + URL url= new URL(null, requestUrl, new sun.net.www.protocol.https.Handler()); + HttpsURLConnection httpUrlConn = (HttpsURLConnection) url.openConnection(); + httpUrlConn.setSSLSocketFactory(ssf); + + httpUrlConn.setDoOutput(true); + httpUrlConn.setDoInput(true); + httpUrlConn.setUseCaches(false); + httpUrlConn.setRequestMethod("GET"); + httpUrlConn.connect(); + + //获得输入 + InputStream inputStream = httpUrlConn.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8"); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + + //将bufferReader的值给放到buffer里 + String str = null; + while ((str = bufferedReader.readLine()) != null) { + buffer.append(str); + } + //关闭bufferReader和输入流 + bufferedReader.close(); + inputStreamReader.close(); + inputStream.close(); + inputStream = null; + //断开连接 + httpUrlConn.disconnect(); + + /** + * 解析JSON字符串 + */ + String jsonStr = buffer.toString(); + JSONObject jsonObject = JSONObject.fromObject(jsonStr).getJSONObject("data"); + int code = jsonObject.optInt("code");//0服务正常。-1服务出错 + if (code != 0) { + //初始化节假日失败,获取网络服务出错 + resultMap.put("status", "0"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(520011, user.getLanguage())); + return resultMap; + } + JSONObject holiday = jsonObject.getJSONObject("holiday"); + if (holiday.size() == 0) { + //初始化节假日失败,暂未获取到所选年份的节假日数据 + resultMap.put("status", "0"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(505673, user.getLanguage())); + return resultMap; + } + Map holidayMap = new HashMap(); + List> holidayList = new ArrayList>(); + Iterator iterator = holiday.keys(); + while (iterator.hasNext()) { + holidayMap = new HashMap(); + + String holidayDate = (String) iterator.next(); + holidayMap.put("holidayDate", holidayDate);//日期 + JSONObject detailInfo = holiday.getJSONObject(holidayDate); + int wage = detailInfo.optInt("wage"); + if (wage == 1) { + holidayMap.put("changeType", 2);//调配工作日 + } else if (wage == 2) { + holidayMap.put("changeType", 3);//调配休息日 + } else if (wage == 3) { + holidayMap.put("changeType", 1);//公众假日 + } + String holidayDesc = detailInfo.getString("name"); + holidayMap.put("holidayDesc", holidayDesc);//说明 + + holidayList.add(holidayMap); + } + resultMap.put("status", "1"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(505674, user.getLanguage())); + resultMap.put("holidayList", holidayList); + } catch (Exception e) { + e.printStackTrace(); + resultMap.put("status", "0"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(520011, user.getLanguage())); + return resultMap; + } + return resultMap; + } + +} diff --git a/src/com/engine/kq/biz/KQHolidaySetComInfo.java b/src/com/engine/kq/biz/KQHolidaySetComInfo.java new file mode 100644 index 0000000..9dd623b --- /dev/null +++ b/src/com/engine/kq/biz/KQHolidaySetComInfo.java @@ -0,0 +1,197 @@ +package com.engine.kq.biz; + +import weaver.cache.*; +import weaver.conn.RecordSet; + +/** + * 节假日设置缓存类 + */ +public class KQHolidaySetComInfo extends CacheBase { + + /** + * 数据来源 + */ + protected static String TABLE_NAME = "kq_holidaySet"; + /** + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = null; + /** + * sql中的order by信息,不要以order by开始 + */ + protected static String TABLE_ORDER = "id"; + + /** + * 主键 + */ + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + /** + * ID + */ + @CacheColumn(name = "id") + protected static int id; + + /** + * 考勤组ID + */ + @CacheColumn(name = "groupId") + protected static int groupId; + + /** + * 日期 + */ + @CacheColumn(name = "holidayDate") + protected static int holidayDate; + + /** + * 说明 + */ + @CacheColumn(name = "holidayDesc") + protected static int holidayDesc; + + /** + * 类型 + * 1-公众假日、2-调配工作日、3-调配休息日 + */ + @CacheColumn(name = "changeType") + protected static int changeType; + + /** + * 对应工作日 + * 1-星期日、2-星期一、3-星期二、4-星期三、5-星期四、6-星期五、7-星期六 + * 当考勤组的考勤类型为固定班制和自由班制的时启用 + */ + @CacheColumn(name = "relatedDay") + protected static int relatedDay; + + @Override + protected boolean autoInitIfNotFound() { + return false; + } + + @Override + protected CacheMap initCache() throws Exception { + CacheMap localData = super.createCacheMap(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_HolidaySet order by id "; + rs.executeQuery(sql); + while (rs.next()) { + String groupId = rs.getString("groupId"); + String holidayDate = rs.getString("holidayDate"); + String PK = groupId + "|" + holidayDate; + + CacheItem row = createCacheItem(); + parseResultSetToCacheItem(rs, row); + //这里需要记得调用这个转化方法,否则这些自己加载的数据就不能正确转化,当然你也可以直接在转化逻辑写在这里,不过这样先让代码重复了 + modifyCacheItem(PK, row); + localData.put(PK, row); + } + return localData; + } + + @Override + protected CacheItem initCache(String key) { + if (key == null || "".equals(key.trim())) { + return null; + } + + String groupId = "";//考勤组的ID + String holidayDate = "";//日期 + + String[] keyArr = key.split("\\|"); + if (keyArr.length == 2) { + groupId = keyArr[0]; + holidayDate = keyArr[1]; + + String sql = "select * from kq_HolidaySet where groupId=? and holidayDate=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, groupId, holidayDate); + if (recordSet.next()) { + CacheItem cacheItem = createCacheItem(); + parseResultSetToCacheItem(recordSet, cacheItem); + modifyCacheItem(key, cacheItem); + return cacheItem; + } + return null; + } else { + return null; + } + } + + private String getId(String key) { + return (String) getValue(id, key); + } + + public String getId(String groupId, String holidayDate) { + String PK = groupId + "|" + holidayDate; + String id = getId(PK); + return id; + } + + public String getGroupId() { + return (String) getRowValue(groupId); + } + + private String getGroupId(String key) { + return (String) getValue(groupId, key); + } + + public String getGroupId(String groupId, String holidayDate) { + String PK = groupId + "|" + holidayDate; + return getGroupId(PK); + } + + public String getHolidayDate() { + return (String) getRowValue(holidayDate); + } + + private String getHolidayDate(String key) { + return (String) getValue(holidayDate, key); + } + + public String getHolidayDate(String groupId, String holidayDate) { + String PK = groupId + "|" + holidayDate; + return getHolidayDate(PK); + } + + public String getHolidayDesc() { + return (String) getRowValue(holidayDesc); + } + + private String getHolidayDesc(String key) { + return (String) getValue(holidayDesc, key); + } + + public String getHolidayDesc(String groupId, String holidayDate) { + String PK = groupId + "|" + holidayDate; + return getHolidayDesc(PK); + } + + public String getChangeType() { + return (String) getRowValue(changeType); + } + + private String getChangeType(String key) { + return (String) getValue(changeType, key); + } + + public String getChangeType(String groupId, String holidayDate) { + String PK = groupId + "|" + holidayDate; + return getChangeType(PK); + } + + public String getRelatedDay() { + return (String) getRowValue(relatedDay); + } + + private String getRelatedDay(String key) { + return (String) getValue(relatedDay, key); + } + + public String getRelatedDay(String groupId, String holidayDate) { + String PK = groupId + "|" + holidayDate; + return getRelatedDay(PK); + } +} diff --git a/src/com/engine/kq/biz/KQHolidaySetThread.java b/src/com/engine/kq/biz/KQHolidaySetThread.java new file mode 100644 index 0000000..b14a0a0 --- /dev/null +++ b/src/com/engine/kq/biz/KQHolidaySetThread.java @@ -0,0 +1,37 @@ +package com.engine.kq.biz; + +import weaver.general.BaseBean; + +import java.util.ArrayList; +import java.util.List; + +/** + * 由于节假日设置的变更会影响到考勤汇总报表,所以在节假日发生变更后需要格式化考勤 + * 由于格式化考勤比较耗时,所以如果节假日设置完后可能会因需要格式化考勤等到很长一段时间,所以改为线程去调用格式化考勤的方法 + */ +public class KQHolidaySetThread extends Thread { + + private List groupIdList; + + private List holidayDateList; + + public KQHolidaySetThread(List groupIdList, List holidayDateList) { + this.groupIdList = groupIdList; + this.holidayDateList = holidayDateList; + if (this.groupIdList == null) { + this.groupIdList = new ArrayList(); + } + if (this.holidayDateList == null) { + this.holidayDateList = new ArrayList(); + } + } + + @Override + public void run() { + for (String groupId : this.groupIdList) { + for (String holidayDate : this.holidayDateList) { + new KQFormatBiz().formatDateByGroupId(groupId, holidayDate);//刷新考勤报表 + } + } + } +} diff --git a/src/com/engine/kq/biz/KQInitializationBiz.java b/src/com/engine/kq/biz/KQInitializationBiz.java new file mode 100644 index 0000000..0776072 --- /dev/null +++ b/src/com/engine/kq/biz/KQInitializationBiz.java @@ -0,0 +1,673 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.cmd.shiftmanagement.SaveShiftManagementBaseFormCmd; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.auto.AutoInitWFSet; +import com.weaver.general.Util; + +import java.util.*; + +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 初始化考勤的相关接口 + */ +public class KQInitializationBiz { + + /** + * 初始化班次 + * workTime:上班时间 + * restTime:下班时间 + * excludeRestTime:排除休息时间:0-不勾选、1-勾选 + * restTime_start:休息时间段的开始时间 + * restTime_end:休息时间段的结束时间 + * workDate:工作日期:6-星期日、0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六 + * + * @return + */ + public static Map initShift(Map params, User user) { + Map resultMap = new HashMap(); + + try { + RecordSet rs = new RecordSet(); + String sql = "select * from kq_initHistory where id=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + recordSet.next(); + int serialidDB = Util.getIntValue(recordSet.getString("serialid"), 0); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + int[] initArrays = kqTimesArrayComInfo.getInitArr(); + String workTime = weaver.general.Util.null2String(params.get("workTime")); + String restTime = weaver.general.Util.null2String(params.get("restTime")); + boolean isRest = false; + String excludeRestTime = weaver.general.Util.null2String(params.get("excludeRestTime")); + String restTime_start = weaver.general.Util.null2String(params.get("restTime_start")); + String restTime_end = weaver.general.Util.null2String(params.get("restTime_end")); + + String serail = workTime + "-" + restTime; + int workTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(workTime); + int restTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(restTime); + Arrays.fill(initArrays, workTimeIndex, restTimeIndex, 1); + if ("1".equalsIgnoreCase(excludeRestTime)) { + isRest = true; + int restTime_startIndex = kqTimesArrayComInfo.getArrayindexByTimes(restTime_start); + int restTime_endIndex = kqTimesArrayComInfo.getArrayindexByTimes(restTime_end); + Arrays.fill(initArrays, restTime_startIndex, restTime_endIndex, -1); + } + int worktime = kqTimesArrayComInfo.getCnt(initArrays, 0, 1440, 1); + + Map retmap = new HashMap(); + JSONArray workArray = new JSONArray(); + JSONObject workObjects = new JSONObject(); + JSONObject workObject = new JSONObject(); + + JSONArray restArray = new JSONArray(); + JSONObject restObjects = new JSONObject(); + + JSONObject jsonObj = new JSONObject(); + jsonObj.put("subcompanyid", ""); + jsonObj.put("serial", serail); + jsonObj.put("shiftonoffworkcount", "1"); + jsonObj.put("punchsettings", "0"); + jsonObj.put("isoffdutyfreecheck", "0"); + jsonObj.put("isresttimeopen", isRest ? "1" : "0"); + jsonObj.put("worktime", worktime + ""); + //初始化工作时段 + workObject = new JSONObject(); + workObject.put("across", "0"); + workObject.put("times", workTime); + workObject.put("mins", "60"); + workObjects.put("start", workObject); + + workObject = new JSONObject(); + workObject.put("across", "0"); + workObject.put("times", restTime); + workObject.put("mins", "60"); + workObjects.put("end", workObject); + + workObjects.put("record", 0); + workArray.add(workObjects); + jsonObj.put("workSections", workArray); + //初始化休息时段 + jsonObj.put("restTimeSections", restArray); + JSONObject _jsonObj = null; + if (isRest) { + _jsonObj = new JSONObject(); + restObjects = new JSONObject(); + restObjects.put("record", UUID.randomUUID()); + _jsonObj.put("time", restTime_start); + _jsonObj.put("accross", "0"); + restObjects.put("start", _jsonObj); + _jsonObj = new JSONObject(); + _jsonObj.put("time", restTime_end); + _jsonObj.put("accross", "0"); + restObjects.put("end", _jsonObj); + restArray.add(restObjects); + +// restObjects = new JSONObject(); +// restObjects.put("resttype", "end"); +// restObjects.put("time", restTime_end); +// restArray.add(restObjects); + } + + SaveShiftManagementBaseFormCmd baseFormCmd = new SaveShiftManagementBaseFormCmd(null, user); + if (serialidDB <= 0) { + baseFormCmd.add(retmap, jsonObj); + String status = weaver.general.Util.null2String(retmap.get("status")); + String serialid = weaver.general.Util.null2String(retmap.get("id")); + if ("1".equals(status) && serialid.length() > 0) { + resultMap.put("status", "1"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(505652, user.getLanguage()));//班次初始化成功 + List descList = new ArrayList(); + resultMap.put("description", descList); + String updateHistory = "update kq_initHistory set serialid = ? "; + rs.executeUpdate(updateHistory, serialid); + } else { + resultMap.put("status", "0"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(125960, user.getLanguage())); + List descList = new ArrayList(); + resultMap.put("description", descList); + } + } else { + jsonObj.put("id", serialidDB); + baseFormCmd.edit(retmap, jsonObj); + resultMap.put("status", "1"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(505652, user.getLanguage()));//班次初始化成功 + } + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + kqShiftManagementComInfo.removeShiftManagementCache(); + resultMap.put("url", "/spa/hrm/staticAttendance4engine/engine.html#/attendance/shift"); + return resultMap; + } catch (Exception e) { + e.printStackTrace(); + resultMap.put("status", "0"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(125960, user.getLanguage())); + List descList = new ArrayList(); + resultMap.put("description", descList); + return resultMap; + + } + } + + /** + * 初始化考勤组 + * workTime:上班时间 + * restTime:下班时间 + * excludeRestTime:排除休息时间:0-不勾选、1-勾选 + * restTime_start:休息时间段的开始时间 + * restTime_end:休息时间段的结束时间 + * workDate:工作日期:6-星期日、0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六 + * + * @return + */ + public static Map initGroup(Map params, User user) { + Map resultMap = new HashMap(); + resultMap.put("status", "1"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(10000750,weaver.general.Util.getIntValue(user.getLanguage())));//考勤组初始化 + + List descList = new ArrayList(); + KQGroupInit kqGroupInit = new KQGroupInit(); + boolean initGroupBase = kqGroupInit.initGroupBase(); + boolean initGroupMembers = kqGroupInit.initGroupMembers(); + + String workDate = Util.null2String((String)params.get("workDate"));//工作日期 + boolean initGroupSerial = kqGroupInit.initGroupSerial(workDate); + + //考勤组基本信息 + descList.add(initGroupBase ? SystemEnv.getHtmlLabelName(10000751,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000752,weaver.general.Util.getIntValue(user.getLanguage()))); + //固定班次 + descList.add(initGroupSerial ? SystemEnv.getHtmlLabelName(10000753,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000754,weaver.general.Util.getIntValue(user.getLanguage()))); + //考勤组成员 + descList.add(initGroupMembers ? SystemEnv.getHtmlLabelName(10000755,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000756,weaver.general.Util.getIntValue(user.getLanguage()))); + + if (initGroupBase && initGroupSerial && initGroupMembers) { + new KQReportFieldComInfo().removeCache(); + new KQGroupComInfo().removeCache(); + new KQGroupMemberComInfo().removeCache(); + new KQShiftScheduleComInfo().removeCache(); + new KQFixedSchedulceComInfo().removeCache(); + resultMap.put("status", "1"); + } else { + resultMap.put("status", "0"); + } + resultMap.put("description", descList); + resultMap.put("url", "/spa/hrm/staticAttendance4engine/engine.html#/attendance/groupSetting"); + return resultMap; + } + + /** + * 初始化考勤流程 + * workTime:上班时间 + * restTime:下班时间 + * excludeRestTime:排除休息时间:0-不勾选、1-勾选 + * restTime_start:休息时间段的开始时间 + * restTime_end:休息时间段的结束时间 + * workDate:工作日期:6-星期日、0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六 + * + * @return + */ + public static Map initWorkflow(Map params, User user) { + RecordSet rs = new RecordSet(); + Map resultMap = new HashMap(); + String sql = "select * from kq_initHistory where id=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + recordSet.next(); + + int leavewf = Util.getIntValue(recordSet.getString("leavewf"), 0); + int travelwf = Util.getIntValue(recordSet.getString("travelwf"), 0); + int exitwf = Util.getIntValue(recordSet.getString("exitwf"), 0); + int overtimewf = Util.getIntValue(recordSet.getString("overtimewf"), 0); + int changeserialwf = Util.getIntValue(recordSet.getString("changeserialwf"), 0); + int punchcardwf = Util.getIntValue(recordSet.getString("punchcardwf"), 0); + int sellingoffwf = Util.getIntValue(recordSet.getString("sellingoffwf"), 0); + int processchangewf = Util.getIntValue(recordSet.getString("processchangewf"), 0); + + resultMap.put("status", "1"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(505655,weaver.general.Util.getIntValue(user.getLanguage()))); + AutoInitWFSet autoInitWFSet = new AutoInitWFSet(); + autoInitWFSet.setUser(user); + autoInitWFSet.setLog(true); + + boolean isLeaveOk = false; + boolean isEvectionOk = false; + boolean isOutOk = false; + boolean isOvertimeOk = false; + boolean isShiftOk = false; + boolean isCardOk = false; + boolean isLeaveBackOk = false; + boolean isProcessChangeOk = false; + + String curdatetime = DateUtil.getFullDate(); + if (leavewf == 1) { + isLeaveOk = true; + } else { + //请假流程 + isLeaveOk = autoInitWFSet.initWfForKQ(KqSplitFlowTypeEnum.LEAVE.getFlowtype(), SystemEnv.getHtmlLabelName(83393, user.getLanguage()) + curdatetime, "0"); + } + + if (travelwf == 1) { + isEvectionOk = true; + } else { + //出差流程 + isEvectionOk = autoInitWFSet.initWfForKQ(KqSplitFlowTypeEnum.EVECTION.getFlowtype(), SystemEnv.getHtmlLabelName(83394, user.getLanguage()) + curdatetime, "0"); + } + + if (exitwf == 1) { + isOutOk = true; + } else { + //公出流程 + isOutOk = autoInitWFSet.initWfForKQ(KqSplitFlowTypeEnum.OUT.getFlowtype(), SystemEnv.getHtmlLabelName(83395, user.getLanguage()) + curdatetime, "0"); + } + + if (overtimewf == 1) { + isOvertimeOk = true; + } else { + //加班流程 + isOvertimeOk = autoInitWFSet.initWfForKQ(KqSplitFlowTypeEnum.OVERTIME.getFlowtype(), SystemEnv.getHtmlLabelName(83396, user.getLanguage()) + curdatetime, "0"); + } + + if (changeserialwf == 1) { + isShiftOk = true; + } else { + //排班流程 + autoInitWFSet.setIsdetail(true); + isShiftOk = autoInitWFSet.initWfForKQ(KqSplitFlowTypeEnum.SHIFT.getFlowtype(), SystemEnv.getHtmlLabelName(390737, user.getLanguage()) + curdatetime, "1"); + } + + if (punchcardwf == 1) { + isCardOk = true; + } else { + //补卡流程 + autoInitWFSet.setIsdetail(true); + isCardOk = autoInitWFSet.initWfForKQ(KqSplitFlowTypeEnum.CARD.getFlowtype(), SystemEnv.getHtmlLabelName(390274, user.getLanguage()) + curdatetime, "1"); + } + + if (sellingoffwf == 1) { + isLeaveBackOk = true; + } else { + //销假流程 + autoInitWFSet.setIsdetail(true); + isLeaveBackOk = autoInitWFSet.initWfForKQ(KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype(), SystemEnv.getHtmlLabelName(389117, user.getLanguage()) + curdatetime, "1"); + } + if (processchangewf == 1) { + isProcessChangeOk = true; + } else { + //变更流程 + autoInitWFSet.setIsdetail(true); + isProcessChangeOk = autoInitWFSet.initWfForKQ(KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype(), SystemEnv.getHtmlLabelName(513400, user.getLanguage()) + curdatetime, "1"); + } + + List descList = new ArrayList(); + if (isLeaveOk) { + String updateHistory = "update kq_initHistory set leavewf = ? "; + rs.executeUpdate(updateHistory, "1"); + descList.add(SystemEnv.getHtmlLabelName(10000757,weaver.general.Util.getIntValue(user.getLanguage())) + "," + SystemEnv.getHtmlLabelName(505658, user.getLanguage())); + } else { + autoInitWFSet.cleanAutoInit("0"); + descList.add(SystemEnv.getHtmlLabelName(505685,weaver.general.Util.getIntValue(user.getLanguage()))); + } + if (isEvectionOk) { + String updateHistory = "update kq_initHistory set travelwf = ? "; + rs.executeUpdate(updateHistory, "1"); + descList.add(SystemEnv.getHtmlLabelName(10000758,weaver.general.Util.getIntValue(user.getLanguage())) + "," + SystemEnv.getHtmlLabelName(505658, user.getLanguage())); + } else { + autoInitWFSet.cleanAutoInit("1"); + descList.add(SystemEnv.getHtmlLabelName(505687,weaver.general.Util.getIntValue(user.getLanguage()))); + } + if (isOutOk) { + String updateHistory = "update kq_initHistory set exitwf = ? "; + rs.executeUpdate(updateHistory, "1"); + descList.add(SystemEnv.getHtmlLabelName(10000759,weaver.general.Util.getIntValue(user.getLanguage())) + "," + SystemEnv.getHtmlLabelName(505658, user.getLanguage())); + } else { + autoInitWFSet.cleanAutoInit("2"); + descList.add(SystemEnv.getHtmlLabelName(505689,weaver.general.Util.getIntValue(user.getLanguage()))); + } + if (isOvertimeOk) { + String updateHistory = "update kq_initHistory set overtimewf = ? "; + rs.executeUpdate(updateHistory, "1"); + descList.add(SystemEnv.getHtmlLabelName(10000760,weaver.general.Util.getIntValue(user.getLanguage())) + "," + SystemEnv.getHtmlLabelName(505658, user.getLanguage())); + } else { + autoInitWFSet.cleanAutoInit("3"); + descList.add(SystemEnv.getHtmlLabelName(505691,weaver.general.Util.getIntValue(user.getLanguage()))); + } + if (isShiftOk) { + String updateHistory = "update kq_initHistory set changeserialwf = ? "; + rs.executeUpdate(updateHistory, "1"); + descList.add(SystemEnv.getHtmlLabelName(10000761,weaver.general.Util.getIntValue(user.getLanguage())) + "," + SystemEnv.getHtmlLabelName(505658, user.getLanguage())); + } else { + autoInitWFSet.cleanAutoInit("5"); + descList.add(SystemEnv.getHtmlLabelName(505693,weaver.general.Util.getIntValue(user.getLanguage()))); + } + if (isCardOk) { + String updateHistory = "update kq_initHistory set punchcardwf = ? "; + rs.executeUpdate(updateHistory, "1"); + descList.add(SystemEnv.getHtmlLabelName(10000762,weaver.general.Util.getIntValue(user.getLanguage())) + "," + SystemEnv.getHtmlLabelName(505658, user.getLanguage())); + } else { + autoInitWFSet.cleanAutoInit("7"); + descList.add(SystemEnv.getHtmlLabelName(505695,weaver.general.Util.getIntValue(user.getLanguage()))); + } + if (isLeaveBackOk) { + String updateHistory = "update kq_initHistory set sellingoffwf = ? "; + rs.executeUpdate(updateHistory, "1"); + descList.add(SystemEnv.getHtmlLabelName(10000763,weaver.general.Util.getIntValue(user.getLanguage())) + "," + SystemEnv.getHtmlLabelName(505658, user.getLanguage())); + } else { + autoInitWFSet.cleanAutoInit("6"); + descList.add(SystemEnv.getHtmlLabelName(505697,weaver.general.Util.getIntValue(user.getLanguage()))); + } + if (isProcessChangeOk) { + String updateHistory = "update kq_initHistory set processchangewf = ? "; + rs.executeUpdate(updateHistory, "1"); + descList.add(SystemEnv.getHtmlLabelName(10000764,weaver.general.Util.getIntValue(user.getLanguage())) + "," + SystemEnv.getHtmlLabelName(505658, user.getLanguage())); + } else { + autoInitWFSet.cleanAutoInit("8"); + descList.add(SystemEnv.getHtmlLabelName(505697,weaver.general.Util.getIntValue(user.getLanguage()))); + } + if (isLeaveOk && isEvectionOk && isOutOk && isOvertimeOk && isShiftOk && isCardOk && isLeaveBackOk && isProcessChangeOk) { + resultMap.put("status", "1"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(20196,weaver.general.Util.getIntValue(user.getLanguage())) + "," + SystemEnv.getHtmlLabelName(505658, user.getLanguage())); + } else { + resultMap.put("status", "0"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(125960, user.getLanguage())); + } + + resultMap.put("description", descList); + resultMap.put("url", "/spa/hrm/staticAttendance4engine/engine.html#/attendance/wfn/statesShedule"); + return resultMap; + } + + /** + * 初始化节假日 + * workTime:上班时间 + * restTime:下班时间 + * excludeRestTime:排除休息时间:0-不勾选、1-勾选 + * restTime_start:休息时间段的开始时间 + * restTime_end:休息时间段的结束时间 + * workDate:工作日期:6-星期日、0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六 + * + * @return + */ + public static Map initHolidaySet(Map params,User user) { + Map resultMap = new HashMap(); + + Calendar today = Calendar.getInstance(); + String currentYear = Util.add0(today.get(Calendar.YEAR), 4); + + String sql = "select * from kq_initHistory where id=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + recordSet.next(); + int groupId = Util.getIntValue(recordSet.getString("groupId"), 0); + + /*如果初始化历史记录表中没有记录考勤组ID,则初始化失败*/ + if (groupId == 0) { + resultMap.put("status", "0"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(505660, user.getLanguage())); + resultMap.put("url", "/spa/hrm/staticAttendance4engine/engine.html#/attendance/holidaySetting"); + return resultMap; + } + resultMap = KQHolidaySetBiz.initHolidaySet("" + groupId, currentYear,user); + resultMap.put("url", "/spa/hrm/staticAttendance4engine/engine.html#/attendance/holidaySetting/" + groupId); + return resultMap; + } + + /*** + * 初始化加班规则 + * workTime:上班时间 + * restTime:下班时间 + * excludeRestTime:排除休息时间:0-不勾选、1-勾选 + * restTime_start:休息时间段的开始时间 + * restTime_end:休息时间段的结束时间 + * workDate:工作日期:6-星期日、0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六 + * @return + */ + public static Map initOvertimeRules(Map params,User user) { + Map resultMap = new HashMap(); + resultMap.put("url", "/spa/hrm/staticAttendance4engine/engine.html#/attendance/overtimeRule"); + + int excludeRestTime = Util.getIntValue((String) params.get("excludeRestTime"), 0); + String restTime_start = Util.null2String((String) params.get("restTime_start")); + String restTime_end = Util.null2String((String) params.get("restTime_end")); + + String sql = "select * from kq_initHistory where id=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + recordSet.next(); + int groupId = Util.getIntValue(recordSet.getString("groupId"), 0); + int overtimeRuleId = Util.getIntValue(recordSet.getString("overtimeRuleId"), 0); + + /*如果初始化历史记录表中没有记录考勤组ID,则初始化失败*/ + if (groupId == 0) { + resultMap.put("status", "0"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(505659, user.getLanguage())); + return resultMap; + } + + /*判断加班规则是否初始化过*/ + boolean initialized = false; + sql = "select * from kq_overtimeRules where (isDelete is null or isDelete <>1 ) and id=" + overtimeRuleId; + recordSet.executeQuery(sql); + initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + if (initialized) { + sql = "update kq_overtimeRules set name='默认加班规则',groupIds=?,isDelete=0 where id=?"; + recordSet.executeUpdate(sql, groupId, overtimeRuleId); + } else { + sql = "insert into kq_OvertimeRules(name,groupIds,isDelete) values(?,?,0)"; + recordSet.executeUpdate(sql, "默认加班规则", groupId); + + String maxIdSql = "select max(id) from kq_OvertimeRules where (isDelete is null or isDelete <>1)"; + recordSet.executeQuery(maxIdSql); + if (recordSet.next()) { + overtimeRuleId = Util.getIntValue(recordSet.getString(1), 0); + } + } + + if (overtimeRuleId == 0) { + resultMap.put("status", "1"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(10000765,weaver.general.Util.getIntValue(user.getLanguage()))); + return resultMap; + } + + sql = "delete from kq_OvertimeRulesDetail where ruleId=?"; + boolean isok = recordSet.executeUpdate(sql, overtimeRuleId); + new KQLog().info("kq_OvertimeRulesDetail:"+sql+":overtimeRuleId:"+overtimeRuleId+":isok:"+isok); + sql = "insert into kq_OvertimeRulesDetail(ruleId,dayType,overtimeEnable,computingMode,startTime,minimumLen,paidLeaveEnable,lenOfOvertime,lenOfLeave,hasRestTime) " + + "values(?,?,?,?,?,?,?,?,?,?)"; + boolean flag2 = recordSet.executeUpdate(sql, overtimeRuleId, 2, 1, 1, 30, 30, 1, 1, 1, 0); + boolean flag3 = recordSet.executeUpdate(sql, overtimeRuleId, 3, 1, 1, 0, 30, 1, 1, 1, excludeRestTime); + if (flag3 && excludeRestTime == 1) { + String restTimeSql = "delete from kq_OvertimeRestTime where ruleId=? and dayType=?"; + recordSet.executeUpdate(restTimeSql, overtimeRuleId, 3); + + restTimeSql = "insert into kq_OvertimeRestTime(ruleId,dayType,startType,startTime,endType,endTime) values(?,?,?,?,?,?)"; + recordSet.executeUpdate(restTimeSql, overtimeRuleId, 3, 0, restTime_start, 0, restTime_end); + } + boolean flag1 = recordSet.executeUpdate(sql, overtimeRuleId, 1, 1, 1, 0, 30, 1, 1, 1, excludeRestTime); + if (flag1 && excludeRestTime == 1) { + String restTimeSql = "delete from kq_OvertimeRestTime where ruleId=? and dayType=?"; + recordSet.executeUpdate(restTimeSql, overtimeRuleId, 1); + + restTimeSql = "insert into kq_OvertimeRestTime(ruleId,dayType,startType,startTime,endType,endTime) values(?,?,?,?,?,?)"; + recordSet.executeUpdate(restTimeSql, overtimeRuleId, 1, 0, restTime_start, 0, restTime_end); + } + + if (flag1 && flag2 && flag3) { + resultMap.put("status", "1"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(10000766,weaver.general.Util.getIntValue(user.getLanguage()))); + resultMap.put("description", new String[]{SystemEnv.getHtmlLabelName(10000767,weaver.general.Util.getIntValue(user.getLanguage())), SystemEnv.getHtmlLabelName(10000768,weaver.general.Util.getIntValue(user.getLanguage())), SystemEnv.getHtmlLabelName(10000769,weaver.general.Util.getIntValue(user.getLanguage()))}); + } + + /*在初始化历史记录表中记录下加班规则的ID*/ + sql = "update kq_initHistory set overtimeRuleId=" + overtimeRuleId; + recordSet.executeUpdate(sql); + + return resultMap; + } + + /*** + * 初始化出差公出规则 + * workTime:上班时间 + * restTime:下班时间 + * excludeRestTime:排除休息时间:0-不勾选、1-勾选 + * restTime_start:休息时间段的开始时间 + * restTime_end:休息时间段的结束时间 + * workDate:工作日期:6-星期日、0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六 + * @return + */ + public static Map initTravelRules(Map params,User user) { + Map resultMap = new HashMap(); + resultMap.put("url", "/spa/hrm/staticAttendance4engine/engine.html#/attendance/travelRule"); + String sql = "update kq_travelRules set minimumUnit=1,proportion=8,computingMode=2,hoursToDay=8 where id=1"; + RecordSet recordSet = new RecordSet(); + boolean isTravelRuleOK = recordSet.executeUpdate(sql);//出差规则是否执行成功 + + sql = "update kq_exitRules set minimumUnit=1,proportion=8,computingMode=2,hoursToDay=8 where id=1"; + boolean isExitRuleOk = recordSet.executeUpdate(sql);//公出规则是否执行成功 + + if (isTravelRuleOK && isExitRuleOk) { + resultMap.put("status", "1"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(10000770,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("status", "0"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(10000771,weaver.general.Util.getIntValue(user.getLanguage()))); + } + + /** + * 刷新缓存 + */ + KQTravelRulesComInfo travelRulesComInfo = new KQTravelRulesComInfo();//出差规则缓存类 + KQExitRulesComInfo exitRulesComInfo = new KQExitRulesComInfo();//公出规则缓存类 + travelRulesComInfo.removeCache(); + exitRulesComInfo.removeCache(); + return resultMap; + } + + /** + * 初始化假期规则 + * workTime:上班时间 + * restTime:下班时间 + * excludeRestTime:排除休息时间:0-不勾选、1-勾选 + * restTime_start:休息时间段的开始时间 + * restTime_end:休息时间段的结束时间 + * workDate:工作日期:6-星期日、0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六 + * + * @return + */ + public static Map initLeaveRules(Map params,User user) { + Map resultMap = new HashMap(); + resultMap.put("url", "/spa/hrm/staticAttendance4engine/engine.html#/attendance/holidayRule"); + /** + * 根据考勤一键初始化记录表判断哪些假期规则已经初始化过了 + */ + String sql = "select * from kq_initHistory where id=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + recordSet.next(); + int annualLeave = Util.getIntValue(recordSet.getString("annualLeave"), 0); + int paidCompassionateLeave = Util.getIntValue(recordSet.getString("paidCompassionateLeave"), 0); + int paidSickLeave = Util.getIntValue(recordSet.getString("paidSickLeave"), 0); + int vacationLeave = Util.getIntValue(recordSet.getString("vacationLeave"), 0); + int compassionateLeave = Util.getIntValue(recordSet.getString("compassionateLeave"), 0); + int sickLeave = Util.getIntValue(recordSet.getString("sickLeave"), 0); + int maternityLeave = Util.getIntValue(recordSet.getString("maternityLeave"), 0); + int paternityLeave = Util.getIntValue(recordSet.getString("paternityLeave"), 0); + int marriageLeave = Util.getIntValue(recordSet.getString("marriageLeave"), 0); + int funeralLeave = Util.getIntValue(recordSet.getString("funeralLeave"), 0); + int breastfeedingLeave = Util.getIntValue(recordSet.getString("breastfeedingLeave"), 0); + + boolean isAnnualLeaveOK = KQLeaveRulesBiz.initAnnualLeave(annualLeave); + boolean isPaidCompassionateLeaveOK = KQLeaveRulesBiz.initPaidCompassionateLeave(paidCompassionateLeave); + boolean isPaidSickLeaveOK = KQLeaveRulesBiz.initPaidSickLeave(paidSickLeave); + boolean isVacationLeaveOK = KQLeaveRulesBiz.initVacationLeave(vacationLeave); + boolean isCompassionateLeaveOK = KQLeaveRulesBiz.initCompassionateLeave(compassionateLeave); + boolean isSickLeaveOK = KQLeaveRulesBiz.initSickLeave(sickLeave); + boolean isMaternityLeaveOK = KQLeaveRulesBiz.initMaternityLeave(maternityLeave); + boolean isPaternityLeaveOK = KQLeaveRulesBiz.initPaternityLeave(paternityLeave); + boolean isMarriageLeaveOK = KQLeaveRulesBiz.initMarriageLeave(marriageLeave); + boolean isFuneralLeaveOK = KQLeaveRulesBiz.initFuneralLeave(funeralLeave); + boolean isBreastfeedingLeaveOK = KQLeaveRulesBiz.initBreastfeedingLeave(breastfeedingLeave); + + List descList = new ArrayList();//详细描述 + descList.add(isAnnualLeaveOK ? SystemEnv.getHtmlLabelName(10000772,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000773,weaver.general.Util.getIntValue(user.getLanguage()))); + descList.add(isPaidCompassionateLeaveOK ? SystemEnv.getHtmlLabelName(10000774,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000775,weaver.general.Util.getIntValue(user.getLanguage()))); + descList.add(isPaidSickLeaveOK ? SystemEnv.getHtmlLabelName(10000776,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000777,weaver.general.Util.getIntValue(user.getLanguage()))); + descList.add(isVacationLeaveOK ? SystemEnv.getHtmlLabelName(10000778,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000779,weaver.general.Util.getIntValue(user.getLanguage()))); + descList.add(isCompassionateLeaveOK ? SystemEnv.getHtmlLabelName(10000780,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000781,weaver.general.Util.getIntValue(user.getLanguage()))); + descList.add(isSickLeaveOK ? SystemEnv.getHtmlLabelName(10000782,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000783,weaver.general.Util.getIntValue(user.getLanguage()))); + descList.add(isMaternityLeaveOK ? SystemEnv.getHtmlLabelName(10000784,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000785,weaver.general.Util.getIntValue(user.getLanguage()))); + descList.add(isPaternityLeaveOK ? SystemEnv.getHtmlLabelName(10000786,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000787,weaver.general.Util.getIntValue(user.getLanguage()))); + descList.add(isMarriageLeaveOK ? SystemEnv.getHtmlLabelName(10000788,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000789,weaver.general.Util.getIntValue(user.getLanguage()))); + descList.add(isFuneralLeaveOK ? SystemEnv.getHtmlLabelName(10000790,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000791,weaver.general.Util.getIntValue(user.getLanguage()))); + descList.add(isBreastfeedingLeaveOK ? SystemEnv.getHtmlLabelName(10000792,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000793,weaver.general.Util.getIntValue(user.getLanguage()))); + + if (isAnnualLeaveOK && isPaidCompassionateLeaveOK && isPaidSickLeaveOK && isVacationLeaveOK && isCompassionateLeaveOK + && isSickLeaveOK && isMaternityLeaveOK && isPaternityLeaveOK && isMarriageLeaveOK && isFuneralLeaveOK && isBreastfeedingLeaveOK) { + resultMap.put("status", "1"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(10000794,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("status", "0"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(10000795,weaver.general.Util.getIntValue(user.getLanguage()))); + } + resultMap.put("description", descList); + + /** + * 刷新缓存 + */ + KQLeaveRulesComInfo leaveRulesComInfo = new KQLeaveRulesComInfo(); + leaveRulesComInfo.removeCache(); + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + detailComInfo.removeCache(); + + return resultMap; + } + + /** + * 初始化假期假期余额成功 + * workTime:上班时间 + * restTime:下班时间 + * excludeRestTime:排除休息时间:0-不勾选、1-勾选 + * restTime_start:休息时间段的开始时间 + * restTime_end:休息时间段的结束时间 + * workDate:工作日期:6-星期日、0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六 + * + * @return + */ + public static Map initBalanceOfLeave(Map params,User user) { + Map resultMap = new HashMap(); + resultMap.put("url", "/spa/hrm/staticAttendance4engine/engine.html#/attendance/vacationBalance"); + /** + * 根据考勤一键初始化记录表判断哪些假期规则已经初始化过了 + */ + String sql = "select * from kq_initHistory where id=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + recordSet.next(); + int annualLeave = Util.getIntValue(recordSet.getString("annualLeave"), 0); + + String date = DateUtil.getCurrentDate(); + + boolean isAnnualLeaveOK = annualLeave == 0 ? false : KQBalanceOfLeaveBiz.createData("" + annualLeave, date.substring(0, 4), 0, "", "" + user.getUID()); + + List descList = new ArrayList();//详细描述 + descList.add(isAnnualLeaveOK ? SystemEnv.getHtmlLabelName(10000796,weaver.general.Util.getIntValue(user.getLanguage())) : SystemEnv.getHtmlLabelName(10000796,weaver.general.Util.getIntValue(user.getLanguage()))); + + if (isAnnualLeaveOK) { + resultMap.put("status", "1"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(10000797,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("status", "0"); + resultMap.put("sketch", SystemEnv.getHtmlLabelName(10000798,weaver.general.Util.getIntValue(user.getLanguage()))); + } + resultMap.put("description", descList); + return resultMap; + } +} diff --git a/src/com/engine/kq/biz/KQLeaveCarryOverJob.java b/src/com/engine/kq/biz/KQLeaveCarryOverJob.java new file mode 100644 index 0000000..6d34991 --- /dev/null +++ b/src/com/engine/kq/biz/KQLeaveCarryOverJob.java @@ -0,0 +1,225 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.entity.KQUsageHistoryEntity; +import com.engine.kq.jucailin.util.KQDateUtil; +import com.engine.kq.log.KQLog; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.schedule.BaseCronJob; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; + +/** + * 每年1月1日结转去年的年假 + */ +public class KQLeaveCarryOverJob extends BaseCronJob { + private KQLog kqLog = new KQLog(); + + public void execute() { + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + String currentYear = Util.add0(today.get(Calendar.YEAR), 4); + today.add(Calendar.YEAR, -1); + String lastYear = Util.add0(today.get(Calendar.YEAR), 4); + kqLog.info("begin do KQLeaveCarryOverJob invoke ..."); + List lsCheckInfo = new ArrayList<>(); + Map checkInfo = null; + RecordSet rs = new RecordSet(); + RecordSet recordSet = new RecordSet(); + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and carryOver=1 "; + rs.executeQuery(sql); + while (rs.next()) { + String ruledetailId = rs.getString("id"); + String ruleId = rs.getString("ruleid"); + String carryOverDays = Util.null2s(rs.getString("carryOverDays"), "0"); + checkInfo = new HashMap<>(); + checkInfo.put("leaveid", ruleId); + checkInfo.put("ruledetailId", ruledetailId); + checkInfo.put("carryOverDays", carryOverDays); + + lsCheckInfo.add(checkInfo); + } + boolean f = false; + new BaseBean().writeLog(JSON.toJSONString(lsCheckInfo)); + //假期规则缓存类(每个假期类型下可能存在多个假期规则) + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) { + Map leaveInfo = (Map) lsCheckInfo.get(j); + String leaveid = Util.null2String(leaveInfo.get("leaveid")); + String carryOverDays = Util.null2String(leaveInfo.get("carryOverDays")); + String ruledetailId = Util.null2String(leaveInfo.get("ruledetailId")); + + + int minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(leaveid), -1); + KQUsageHistoryEntity usageHistoryEntity = new KQUsageHistoryEntity(); + List usageHistoryEntityList = new ArrayList(); + + List updateList = new ArrayList(); + sql = "select * from kq_balanceOfLeave where belongyear=? and leaverulesid=?"; + rs.executeQuery(sql, lastYear, leaveid); + while (rs.next()) { + String id = rs.getString("id"); + String resourceId = rs.getString("resourceid"); + if (resourceId.equals("22")) { + f = true; + } + //分部ID + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + //余额发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按入职时长+工龄自动发放 + int distributionMode = Util.getIntValue(detailComInfo.getDistributionMode(leaveid, subcompanyId, departmentId, resourceId)); + String carryOver = detailComInfo.getCarryOver(leaveid, subcompanyId, departmentId, resourceId); + String rulesDetailId = detailComInfo.getId(leaveid, subcompanyId, departmentId, resourceId); + if (!rulesDetailId.equals(ruledetailId) || !carryOver.equals("1")) { + continue; + } + + BigDecimal baseAmount = new BigDecimal(Util.null2s(rs.getString("baseAmount"), "0"));//假期余额基数 + BigDecimal usedAmount = new BigDecimal(Util.null2s(rs.getString("usedAmount"), "0"));//已休的假期时长 + BigDecimal extraAmount = new BigDecimal(Util.null2s(rs.getString("extraAmount"), "0"));//额外的假期时长 + + + //员工假期余额使用记录 + usageHistoryEntity = new KQUsageHistoryEntity(); + usageHistoryEntity.setLeaveRulesId(leaveid); + usageHistoryEntity.setRelatedId(resourceId); + usageHistoryEntity.setWfRequestId(""); + usageHistoryEntity.setOperator(resourceId); + usageHistoryEntity.setOperateDate(currentDate); + usageHistoryEntity.setOperateTime(currentTime); + usageHistoryEntity.setOperateType("9"); + usageHistoryEntity.setInsertOrUpdate("update"); + usageHistoryEntity.setBelongYear(lastYear); + + usageHistoryEntity.setOldMinimumUnit("" + minimumUnit); + usageHistoryEntity.setNewMinimumUnit("" + minimumUnit); + + if (distributionMode == 6) { + + //扣减优先级:1-法定年假、2-福利年假 + int priority = Util.getIntValue(detailComInfo.getPriority(leaveid, subcompanyId, departmentId, resourceId), 1); + //福利年假的基数 + BigDecimal baseAmount2 = new BigDecimal(Util.null2s(rs.getString("baseAmount2"), "0")); + //福利年假的额外 + BigDecimal usedAmount2 = new BigDecimal(Util.null2s(rs.getString("usedAmount2"), "0")); + //福利年假的已休 + BigDecimal extraAmount2 = new BigDecimal(Util.null2s(rs.getString("extraAmount2"), "0")); + //剩余=已释放+额外-已休 + BigDecimal restAmount1 = baseAmount.add(extraAmount).subtract(usedAmount); + BigDecimal restAmount2 = baseAmount2.add(extraAmount2).subtract(usedAmount2); + BigDecimal restAmount = restAmount1.add(restAmount2); + if (restAmount.compareTo(new BigDecimal(carryOverDays)) > 0) { + BigDecimal _duration = restAmount.subtract(new BigDecimal(carryOverDays)); + + if (priority == 1) {//扣减优先级:先扣减法定年假、再扣减福利年假 + BigDecimal temp = baseAmount.add(extraAmount).subtract(usedAmount).subtract(_duration); + if (temp.doubleValue() >= 0) { + String newUsedAmount = usedAmount.add(_duration).setScale(2, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setOldUsedAmount(usedAmount.setScale(2, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + + } else { + String newUsedAmount = baseAmount.add(extraAmount).setScale(2, RoundingMode.HALF_UP).toPlainString(); + String newUsedAmount2 = _duration.subtract(baseAmount.add(extraAmount).subtract(usedAmount)).add(usedAmount2).setScale(2, RoundingMode.HALF_UP).toString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + ",usedAmount2=" + (newUsedAmount2) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setOldUsedAmount(usedAmount.setScale(2, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setOldUsedAmount2(usedAmount2.setScale(2, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + + } + } else {//扣减优先级:先扣减福利年假、再扣减法定年假 + BigDecimal temp = baseAmount2.add(extraAmount2).subtract(usedAmount2).subtract(_duration); + if (temp.doubleValue() >= 0) { + String newUsedAmount2 = usedAmount2.add(_duration).setScale(2, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount2=" + (newUsedAmount2) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setOldUsedAmount2(usedAmount2.setScale(2, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + + } else { + String newUsedAmount2 = baseAmount2.add(extraAmount2).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String newUsedAmount = _duration.subtract(baseAmount2.add(extraAmount2).subtract(usedAmount2)).add(usedAmount).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount2=" + (newUsedAmount2) + ",usedAmount=" + (newUsedAmount) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setOldUsedAmount(usedAmount.setScale(2, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setOldUsedAmount2(usedAmount2.setScale(2, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + + + } + } + } + } else { + //剩余=已释放+额外-已休 + BigDecimal restAmount = baseAmount.add(extraAmount).subtract(usedAmount); + if (restAmount.compareTo(new BigDecimal(carryOverDays)) > 0) { + String newUsedAmount = baseAmount.add(extraAmount).subtract(new BigDecimal(carryOverDays)).setScale(2, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + ", update_time=? where id=" + id; + updateList.add(updateSql); + + usageHistoryEntity.setOldUsedAmount(usedAmount.setScale(2, RoundingMode.HALF_UP).toPlainString()); + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setBalanceOfLeaveId(id); + usageHistoryEntityList.add(usageHistoryEntity); + } + } + } + + boolean flag = false; + java.sql.Timestamp updateDate = KQDateUtil.getUpdateTimeStamp(); + for (int i = 0; i < updateList.size(); i++) { + flag = recordSet.executeUpdate(updateList.get(i), updateDate); + if (!flag) { + kqLog.writeLog("结转SQL执行失败。" + "updateListsql=" + updateList.get(i)); + break; + } + } + + /*记录假期使用记录*/ + if (flag && usageHistoryEntityList.size() > 0) { + KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz(); + flag = usageHistoryBiz.save(usageHistoryEntityList); + if (!flag) { + kqLog.writeLog("结转SQL日志执行失败。" + "updateListsql=" + JSON.toJSONString(usageHistoryEntityList)); + break; + } + } + } + kqLog.info("end do KQLeaveCarryOverJob invoke ..."); + } catch (Exception e) { + new BaseBean().writeLog(e.getMessage()); + new BaseBean().writeLog(e); + } + } + +} diff --git a/src/com/engine/kq/biz/KQLeaveRulesBiz.java b/src/com/engine/kq/biz/KQLeaveRulesBiz.java new file mode 100644 index 0000000..b0c4b4c --- /dev/null +++ b/src/com/engine/kq/biz/KQLeaveRulesBiz.java @@ -0,0 +1,1307 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSONObject; +import com.api.hrm.util.ServiceUtil; +import com.engine.kq.entity.KQBalanceOfLeaveEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQTransMethod; +import com.weaver.general.TimeUtil; +import org.apache.commons.lang.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.StringUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.common.Tools; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class KQLeaveRulesBiz { + + public static final ThreadLocal THREAD_LOCAL = new ThreadLocal<>(); + + + /** + * 记录日志 + */ + private static KQLog logger = new KQLog(); + + /** + * 根据假期规则ID获取假期规则名称 + * + * @param ruleId 假期规则的ID + * @return + */ + public static String getLeaveName(String ruleId) { + String leaveName = ""; + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + leaveName = kqLeaveRulesComInfo.getLeaveName(ruleId); + return leaveName; + } + + /** + * 判断是否具有假期余额 + * + * @param ruleId + * @return + */ + public static boolean getBalanceEnable(String ruleId) { + int balanceEnable = 0; + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + balanceEnable = Util.getIntValue(kqLeaveRulesComInfo.getBalanceEnable(ruleId), 0); + if (balanceEnable == 1) { + return true; + } else { + return false; + } + } + /** + * 判断优先假期类型id字符串 + * + * @param ruleId + * @return + */ + public static String getLeaveids(String ruleId) { + int schevacationON = 0; + String schevacation = "-1"; + + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + schevacationON = Util.getIntValue(kqLeaveRulesComInfo.getSchevacationON(ruleId), 0); + if (schevacationON == 1) { + schevacation=Util.null2s(kqLeaveRulesComInfo.getSchevacation(ruleId), "-1"); + } + return schevacation; + + } + + /** + * 判断人员的假期类型id字符串 + * + * @param scheLeaveids + * @param resourceId + * @return + */ + public static String getusedLeaveids(String scheLeaveids, String resourceId) { + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + + List scheLeaveidsList = Util.splitString2List(scheLeaveids, ","); + + /** + * 加载应用范围为总部的以及应用范围为分部(但是范围中包含了所属分部ID)的假期规则 + */ + RecordSet recordSet = new RecordSet(); + String sql = "select * from kq_LeaveRules "; + String sqlWhere = " where (isDelete is null or isDelete <>1) and isEnable=1 and balanceEnable=1 "; + /*如果找不到人员所在分部,则只返回应用范围为总部的假期规则*/ + if (!resourceId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere += " and ( (scopeType=3 and ','+scopeValue+',' like '%," + resourceId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere += " and ( (scopeType=3 and concat(',',scopeValue,',') like '%," + resourceId + ",%') "; + } else { + sqlWhere += " and ( (scopeType=3 and ','||scopeValue||',' like '%," + resourceId + ",%') "; + } + } + if (!departmentId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere += " or (scopeType=2 and ','+scopeValue+',' like '%," + departmentId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere += " or (scopeType=2 and concat(',',scopeValue,',') like '%," + departmentId + ",%') "; + } else { + sqlWhere += " or (scopeType=2 and ','||scopeValue||',' like '%," + departmentId + ",%') "; + } + } + if (!subcompanyId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere += " or (scopeType=1 and ','+scopeValue+',' like '%," + subcompanyId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere += " or (scopeType=1 and concat(',',scopeValue,',') like '%," + subcompanyId + ",%') "; + } else { + sqlWhere += " or (scopeType=1 and ','||scopeValue||',' like '%," + subcompanyId + ",%') "; + } + } + + sqlWhere += " or scopeType=0 )"; + sql = sql + sqlWhere + " order by showOrder,id "; + scheLeaveids = ""; + List remleaveidsList = new ArrayList<>(); + recordSet.executeQuery(sql); + /*如果指定人员所在分部下面单独设置过假期规则,则取分部下面的假期规则*/ + while (recordSet.next()) { + String leaveid = recordSet.getString("id");//假期类型id + remleaveidsList.add(leaveid); + } + + for (String id : scheLeaveidsList) { + if (remleaveidsList.contains(id)) { + if (scheLeaveids.equals("")) { + scheLeaveids = id; + } else { + scheLeaveids += "," + id; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return scheLeaveids; + + } + /** + * 获取最小请假单位 + * 1-按天请假 + * 2-按半天请假 + * 3-按小时请假 + * 4-按整天请假 + * 其他:无效数据 + * + * @param ruleId 指定的假期规则ID + * @return + */ + public static int getMinimumUnit(String ruleId) { + int minimumUnit = -1;//最小请假单位 + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + minimumUnit = Util.getIntValue(kqLeaveRulesComInfo.getMinimumUnit(ruleId), -1); + return minimumUnit; + } + + /** + * 获取请假时长计算方式 + * 1-按照工作日计算请假时长 + * 2-按照自然日计算请假时长 + * 其他:无效数据 + * + * @param ruleId 指定的假期规则ID + * @return + */ + public static int getComputingMode(String ruleId) { + int computingMode = -1;//计算请假时长方式 + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + computingMode = Util.getIntValue(kqLeaveRulesComInfo.getComputingMode(ruleId), -1); + return computingMode; + } + + /** + * 按照自然日计算请假时长排除节假日、休息日 + * 0-不排除 + * 1-排除节假日 + * 2-排除休息日 + * 1,2-排除节假日和休息日 + * + * @param ruleId 指定的假期规则ID + * @return + */ + public static String getFilterHolidays(String ruleId) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String filterHolidays = Util.null2s(kqLeaveRulesComInfo.getFilterHolidays(ruleId), "0"); + return filterHolidays; + } + + /** + * 获取日折算时长(多少小时算一天) + * + * @param ruleId 指定的假期规则ID + * @return + */ + public static String getHoursToDay(String ruleId) { + double hoursToDay = -1;//日折算时长 + int computingMode = -1;//计算请假时长方式 + int minimumUnit = -1;//最小请假单位 + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + hoursToDay = Util.getDoubleValue(kqLeaveRulesComInfo.getHoursToDay(ruleId), -1); + computingMode = Util.getIntValue(kqLeaveRulesComInfo.getComputingMode(ruleId), -1); + minimumUnit = Util.getIntValue(kqLeaveRulesComInfo.getMinimumUnit(ruleId), -1); + if (computingMode != 2) { + hoursToDay = -1; + } + return String.format("%.2f", hoursToDay); + } + + /** + * 1-按天请假 + * 2-按半天请假 + * 3-按小时请假 + * 4-按整天请假 + * + * @param minimumUnit + * @param lan + * @return + */ + public static String getMinimumUnitName(String minimumUnit, int lan) { + String minimumUnitName = ""; + switch (minimumUnit) { + case "1": + minimumUnitName = SystemEnv.getHtmlLabelName(1925, lan); + break; + case "2": + minimumUnitName = SystemEnv.getHtmlLabelName(1925, lan); + break; + case "3": + case "5": + case "6": + minimumUnitName = SystemEnv.getHtmlLabelName(391, lan); + break; + case "4": + minimumUnitName = SystemEnv.getHtmlLabelName(1925, lan); + break; + default: + break; + } + return minimumUnitName; + } + + /** + * 获取所有的假期规则 + * unitType:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假、-1:数据异常,无效数据 + * + * @return + */ + public static List> getAllLeaveRules() { + Map ruleMap = new HashMap(); + List> ruleList = new ArrayList>(); + + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + kqLeaveRulesComInfo.setTofirstRow(); + while (kqLeaveRulesComInfo.next()) { + if (kqLeaveRulesComInfo.getIsEnable().equals("1")) { + ruleMap = new HashMap(); + ruleMap.put("id", kqLeaveRulesComInfo.getId()); + ruleMap.put("name", kqLeaveRulesComInfo.getLeaveName()); + ruleMap.put("unitType", kqLeaveRulesComInfo.getMinimumUnit()); + ruleMap.put("proportion", kqLeaveRulesComInfo.getProportion()); + ruleMap.put("scopeType",kqLeaveRulesComInfo.getScopeType()); + ruleMap.put("scopeValue",kqLeaveRulesComInfo.getScopeValue()); + ruleList.add(ruleMap); + } + } + return ruleList; + } + + /** + * 根据人员ID获取其可见的所有假期类型 + * + * @param resourceId 指定人员ID + * @return + */ + public static String getAllLeaveRulesByUserId(String resourceId, String languageId) { + String resultStr = ""; + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String subcomId = resourceComInfo.getSubCompanyID(resourceId); + String deptId = resourceComInfo.getDepartmentID(resourceId); + + List tempList = new ArrayList(); + + Map itemMap = new HashMap(); + List itemList = new ArrayList(); + + String sql = "select * from kq_leaveRules where 1=1 and (isDelete is null or isDelete <>1) and isEnable=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String scopeType = recordSet.getString("scopeType"); + String scopeValue = recordSet.getString("scopeValue"); + String leaveName = recordSet.getString("leaveName"); + String id = recordSet.getString("id"); + + if (scopeType.equals("1")) { + tempList = Util.TokenizerString(scopeValue, ","); + if (!tempList.contains(subcomId)) { + continue; + } + } + + itemMap = new HashMap(); + itemMap.put("name", Util.formatMultiLang(leaveName, languageId)); + itemMap.put("id", id); + itemList.add(itemMap); + } + resultStr = JSONObject.toJSONString(itemList); + } catch (Exception e) { + e.printStackTrace(); + } + return resultStr; + } + public static boolean filterSubLeaveRule(KQLeaveRulesComInfo kqLeaveRulesComInfo, User user, String leaveId) { + return filterSubLeaveRule(Util.null2String(user.getUID()), kqLeaveRulesComInfo.getScopeType(leaveId), kqLeaveRulesComInfo.getScopeValue(leaveId), Util.null2String(user.getUserSubCompany1()),Util.null2String(user.getUserDepartment())); + } + public static boolean filterSubLeaveRule(String userId, String scopeType, String scopeValue, String subCompany, String deptId) { + boolean isAdmin = ServiceUtil.isAdmin(userId); + if (isAdmin) { + return false; + } + if ("1".equals(scopeType)) { + if (scopeValue.indexOf(",") > 0) { + String[] split = scopeValue.split(","); + for (String v : split) { + if (!StringUtil.isEmpty(v) && v.equals(subCompany)) { + return false; + } + } + return true; + } else { + return !scopeValue.equals(subCompany); + } + }else if("2".equals(scopeType)){ + if (scopeValue.indexOf(",") > 0) { + String[] split = scopeValue.split(","); + for (String v : split) { + if (!StringUtil.isEmpty(v) && v.equals(deptId)) { + return false; + } + } + return true; + } else { + return !scopeValue.equals(deptId); + } + }else if("3".equals(scopeType)){ + if (scopeValue.indexOf(",") > 0) { + String[] split = scopeValue.split(","); + for (String v : split) { + if (!StringUtil.isEmpty(v) && v.equals(userId)) { + return false; + } + } + return true; + } else { + return !scopeValue.equals(userId); + } + } + return false; + } + /** + * 初始化年假 + * + * @param ruleId + * @return + */ + public static boolean initAnnualLeave(int ruleId) { + boolean isInitSuccess = false; + try { + /*判断年假是否初始化过*/ + RecordSet recordSet = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='年假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=1," + + "isDelete=0,isEnable=1,leaveCode='annualLeave' where id=" + ruleId; + isInitSuccess = recordSet.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + + String deleteDetailSql = "delete from kq_LeaveRulesDetail where scopeType=0 and ruleId=" + ruleId; + recordSet.executeUpdate(deleteDetailSql); + + String insertDetailSql = "insert into kq_LeaveRulesDetail(ruleName,ruleId,scopeType,scopeValue,distributionMode,annualAmount,priority,validityRule,expirationMonth,expirationDay,extensionEnable,extendedDays,releaseRule,calcMethod)" + + "values('年假-总部规则'," + ruleId + ",0,'',3,0,1,0,'','',0,0,0,0)"; + isInitSuccess = recordSet.executeUpdate(insertDetailSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'年假-初始化',0,'',1,8,1,1,0,1,'annualLeave')"; + isInitSuccess = recordSet.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String insertDetailSql = "insert into kq_LeaveRulesDetail(ruleName,ruleId,scopeType,scopeValue,distributionMode,annualAmount,priority,validityRule,expirationMonth,expirationDay,extensionEnable,extendedDays,releaseRule,calcMethod)" + + "values('年假-总部规则'," + nextId + ",0,'',3,0,1,0,'','',0,0,0,0)"; + isInitSuccess = recordSet.executeUpdate(insertDetailSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set annualLeave=" + nextId + " where id=1"; + isInitSuccess = recordSet.executeUpdate(historySql); + + ruleId = nextId; + } + + String detailId = ""; + sql = "select * from kq_LeaveRulesDetail where scopeType=0 and ruleId=" + ruleId; + recordSet.executeQuery(sql); + if (recordSet.next()) { + detailId = recordSet.getString("id"); + } + if (detailId.equals("")) { + return false; + } + + /*先删除原来的明细记录,在插入新的明细记录*/ + String detailSql = "delete from kq_WorkingAgeToLeave where leaveRulesId=" + detailId; + isInitSuccess = recordSet.executeUpdate(detailSql); + if (!isInitSuccess) { + sql = "delete from kq_LeaveRules where leaveRulesId=" + detailId; + recordSet.executeUpdate(sql); + return false; + } + + /*插入明细记录*/ + detailSql = "insert into kq_WorkingAgeToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)"; + isInitSuccess = recordSet.executeUpdate(detailSql, detailId, 0, 1, 0); + isInitSuccess = recordSet.executeUpdate(detailSql, detailId, 1, 10, 5); + isInitSuccess = recordSet.executeUpdate(detailSql, detailId, 10, 20, 10); + isInitSuccess = recordSet.executeUpdate(detailSql, detailId, 20, 9999, 15); + } catch (Exception e) { + logger.info(e.getMessage()); + } + return isInitSuccess; + } + + /** + * 初始化带薪事假 + * + * @param ruleId + * @return + */ + public static boolean initPaidCompassionateLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='带薪事假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='paidCompassionateLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'带薪事假-初始化',0,'',1,8,1,0,0,1,'paidCompassionateLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set paidCompassionateLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化带薪病假 + * + * @param ruleId + * @return + */ + public static boolean initPaidSickLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='带薪病假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='paidSickLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'带薪病假-初始化',0,'',1,8,1,0,0,1,'paidSickLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set paidSickLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化调休 + * + * @param ruleId + * @return + */ + public static boolean initVacationLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='调休-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=1," + + "isDelete=0,isEnable=1,leaveCode='vacationLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + + String deleteDetailSql = "delete from kq_LeaveRulesDetail where scopeType=0 and ruleId=" + ruleId; + rs.executeUpdate(deleteDetailSql); + + String insertDetailSql = "insert into kq_LeaveRulesDetail(ruleName,ruleId,scopeType,scopeValue,distributionMode,annualAmount,priority,validityRule,expirationMonth,expirationDay,extensionEnable,extendedDays,releaseRule,calcMethod)" + + "values('调休-总部规则'," + ruleId + ",0,'',5,0,1,0,'','',0,0,0,0)"; + isInitSuccess = rs.executeUpdate(insertDetailSql); + if (!isInitSuccess) { + return false; + } + } else { + /*判断系统中是否已经存在调休了,如果已存在,则不允许新建新的调休假期*/ + sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id in (select ruleId from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=5)"; + rs.executeQuery(sql); + if (rs.getCounts() > 0) { + return false; + } + + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'调休-初始化',0,'',1,8,1,1,0,1,'vacationLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String insertDetailSql = "insert into kq_LeaveRulesDetail(ruleName,ruleId,scopeType,scopeValue,distributionMode,annualAmount,priority,validityRule,expirationMonth,expirationDay,extensionEnable,extendedDays,releaseRule,calcMethod)" + + "values('调休-总部规则'," + nextId + ",0,'',5,0,1,0,'','',0,0,0,0)"; + isInitSuccess = rs.executeUpdate(insertDetailSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set vacationLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化事假 + * + * @param ruleId + * @return + */ + public static boolean initCompassionateLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='事假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='compassionateLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'事假-初始化',0,'',1,8,1,0,0,1,'compassionateLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set compassionateLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化病假 + * + * @param ruleId + * @return + */ + public static boolean initSickLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='病假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='sickLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'病假-初始化',0,'',1,8,1,0,0,1,'sickLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set sickLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化产假 + * + * @param ruleId + * @return + */ + public static boolean initMaternityLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='产假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=2,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='maternityLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'产假-初始化',0,'',1,8,2,0,0,1,'maternityLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set maternityLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化陪产假 + * + * @param ruleId + * @return + */ + public static boolean initPaternityLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (recordSet.next()) { + String updateSql = "update kq_LeaveRules set leaveName='陪产假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=2,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='paternityLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'陪产假-初始化',0,'',1,8,2,0,0,1,'paternityLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set paternityLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化婚假 + * + * @param ruleId + * @return + */ + public static boolean initMarriageLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='婚假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=2,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='marriageLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'婚假-初始化',0,'',1,8,2,0,0,1,'marriageLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set marriageLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化丧假 + * + * @param ruleId + * @return + */ + public static boolean initFuneralLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='丧假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='funeralLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'丧假-初始化',0,'',1,8,1,0,0,1,'funeralLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set funeralLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化哺乳假 + * + * @param ruleId + * @return + */ + public static boolean initBreastfeedingLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='哺乳假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='breastfeedingLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'哺乳假-初始化',0,'',1,8,1,0,0,1,'breastfeedingLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set breastfeedingLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 根据人员ID以及名称获取对应的假期规则ID(主要对于对接小E) + * + * @param resourceId 人员ID + * @param leaveName 假期规则名称 + * @return + */ + public static List getLeaveRuleIdByName(String resourceId, String leaveName) { + List dataList = new ArrayList(); + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String subcomId = resourceComInfo.getSubCompanyID(resourceId); + + Map dataMap = new HashMap(); + + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete <>1) and isEnable=1 and leaveName like '%" + leaveName + "%'"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + int scopeType = Util.getIntValue(recordSet.getString("scopeType"), 0); + String scopeValue = Util.null2String(recordSet.getString("scopeValue")); + + if (scopeType == 1) { + List tempList = Util.TokenizerString(scopeValue, ","); + if (!tempList.contains(subcomId)) { + continue; + } + } + + dataMap = new HashMap(); + dataMap.put("ruleId", recordSet.getString("id")); + dataMap.put("name", Util.formatMultiLang(recordSet.getString("leaveName"), "7")); + dataList.add(dataMap); + } + } catch (Exception e) { + e.printStackTrace(); + } + return dataList; + } + + /** + * 判断此请假类型是否是由 法定年假+福利年假 组合而成的混合模式 + * + * @param ruleId 指定的请假类型的id(对应于kq_LeaveRules表的主键ID) + * @return true--是混合模式、false--不是 + */ + public static boolean isMixMode(String ruleId) { + boolean flag = false; + try { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=6 and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + flag = true; + } + } catch (Exception e) { + logger.info(e.getMessage()); + } + return flag; + } + + /** + * 获取请假类型的颜色(随机生成) + * + * @return + */ + public static String getColor() { + String color = ""; + try { + StringBuffer result = new StringBuffer(); + for (int i = 0; i < 6; i++) { + //随机生成0-15的数值并转换成16进制 + result.append(Integer.toHexString(new Random().nextInt(16))); + } + color = "#" + result.toString().toUpperCase(); + } catch (Exception e) { + System.out.println("获取16进制字符串异常,返回默认..."); + color = "#00CCCC"; + } + return color; + } + + public static String getChildName(String balanceofleaveid){ + String name = ""; + try { + String sql = "select childId from kq_balanceOfLeave where id=?"; + RecordSet recordSet = new RecordSet(); + KQChildrenComInfo kqChildrenComInfo = new KQChildrenComInfo(); + recordSet.executeQuery(sql, balanceofleaveid); + if (recordSet.next()) { + String chlid = Util.null2s(recordSet.getString("childId"), ""); + if(StringUtils.isNotBlank(chlid)){ + name= kqChildrenComInfo.getChildrenName(chlid); + } + } + } catch (Exception e) { + logger.info(e.getMessage()); + } + return name; + } + /** + * 是否是调休 + * @param ruleId + * @return + */ + public static boolean isTiaoXiu(String ruleId){ + boolean flag = false; + try { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=5 and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + flag = true; + } + } catch (Exception e) { + logger.info(e.getMessage()); + } + return flag; + } + + public static boolean isTiaoXiu(String ruleId, String subCompanyId, String departmentId, String resourceId) { + boolean flag = false; + RecordSet recordSet = new RecordSet(); + try { + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + recordSet.writeLog("isTiaoXiu>>1=" +ruleId+";2="+ subCompanyId+";3="+ departmentId+";4="+ resourceId ); + int distributionMode = Util.getIntValue(detailComInfo.getDistributionMode(ruleId, subCompanyId, departmentId, resourceId), 1); + if (distributionMode == 5) { + flag = true; + } + recordSet.writeLog("isTiaoXiu>>distributionMode=" +distributionMode); +// if (!flag) { + if (true) { + + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) " + + "and distributionMode=5 and ruleId=? "; + String sqlWhere = ""; + if (!resourceId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere = " and (scopeType=3 and ','+scopeValue+',' like '%," + resourceId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere = " and (scopeType=3 and concat(',',scopeValue,',') like '%," + resourceId + ",%') "; + } else { + sqlWhere = " and (scopeType=3 and ','||scopeValue||',' like '%," + resourceId + ",%') "; + } + recordSet.writeLog("isTiaoXiu>>sql1=" + sql + sqlWhere); + recordSet.executeQuery(sql + sqlWhere, ruleId); + if (recordSet.next()) { + return true; + } + } else if (!departmentId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere = " and (scopeType=2 and ','+scopeValue+',' like '%," + departmentId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere = " and (scopeType=2 and concat(',',scopeValue,',') like '%," + departmentId + ",%') "; + } else { + sqlWhere = " and (scopeType=2 and ','||scopeValue||',' like '%," + departmentId + ",%') "; + } + recordSet.writeLog("isTiaoXiu>>sql2=" + sql + sqlWhere); + recordSet.executeQuery(sql + sqlWhere, ruleId); + if (recordSet.next()) { + return true; + } + } else if (!subCompanyId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere = " and (scopeType=1 and ','+scopeValue+',' like '%," + subCompanyId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere = " and (scopeType=1 and concat(',',scopeValue,',') like '%," + subCompanyId + ",%') "; + } else { + sqlWhere = " and (scopeType=1 and ','||scopeValue||',' like '%," + subCompanyId + ",%') "; + } + recordSet.writeLog("isTiaoXiu>>sql3=" + sql + sqlWhere); + recordSet.executeQuery(sql + sqlWhere, ruleId); + if (recordSet.next()) { + return true; + } + } else { + sqlWhere = " and scopeType=0 "; + recordSet.writeLog("isTiaoXiu>>sql4=" + sql + sqlWhere); + recordSet.executeQuery(sql + sqlWhere, ruleId); + if (recordSet.next()) { + return true; + } + } + } + + recordSet.writeLog("isTiaoXiu>>flag=" + flag); + } catch (Exception e) { + recordSet.writeLog(e.getMessage()); + recordSet.writeLog(e); + } + return flag; + } + + public static int getTiaoXiu(String subCompanyId, String departmentId, String resourceId) { + int ruleid = 0; + RecordSet recordSet = new RecordSet(); + try { + + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) " + + "and distributionMode=5 "; + String sqlWhere = ""; + if (!resourceId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere = " and (scopeType=3 and ','+scopeValue+',' like '%," + resourceId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere = " and (scopeType=3 and concat(',',scopeValue,',') like '%," + resourceId + ",%') "; + } else { + sqlWhere = " and (scopeType=3 and ','||scopeValue||',' like '%," + resourceId + ",%') "; + } + + recordSet.executeQuery(sql + sqlWhere); + while (recordSet.next()) { + ruleid = recordSet.getInt("ruleId"); + return ruleid; + } + } + if (!departmentId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere = " and (scopeType=2 and ','+scopeValue+',' like '%," + departmentId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere = " and (scopeType=2 and concat(',',scopeValue,',') like '%," + departmentId + ",%') "; + } else { + sqlWhere = " and (scopeType=2 and ','||scopeValue||',' like '%," + departmentId + ",%') "; + } + + recordSet.executeQuery(sql + sqlWhere); + while (recordSet.next()) { + ruleid = recordSet.getInt("ruleId"); + return ruleid; + } + } + if (!subCompanyId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere = " and (scopeType=1 and ','+scopeValue+',' like '%," + subCompanyId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere = " and (scopeType=1 and concat(',',scopeValue,',') like '%," + subCompanyId + ",%') "; + } else { + sqlWhere = " and (scopeType=1 and ','||scopeValue||',' like '%," + subCompanyId + ",%') "; + } + + recordSet.executeQuery(sql + sqlWhere); + while (recordSet.next()) { + ruleid = recordSet.getInt("ruleId"); + return ruleid; + } + } + + sqlWhere = " and scopeType=0 "; + + recordSet.executeQuery(sql + sqlWhere); + while (recordSet.next()) { + ruleid = recordSet.getInt("ruleId"); + return ruleid; + } + + } catch (Exception e) { + recordSet.writeLog(e.getMessage()); + recordSet.writeLog(e); + } + return ruleid; + } + + public static Map isRepeat(String ruleid,int scopeType,String scopeValue,User user,String ruleDetailId){ + Map result = new HashMap<>(); + result.put("flag","0");//0=未重复,1=重复了不让保存 +// String sql = "select id,ruleid,scopetype,scopevalue,distributionmode from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=5 "; + String sql = "select id,ruleid,scopetype,scopevalue,distributionmode from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) "; + RecordSet recordSet = new RecordSet(); + recordSet.writeLog("ruleid="+ruleid+",scopeType="+scopeType+",scopeValue="+scopeValue); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String tmp_id = Util.null2String(recordSet.getString("id")); + String tmp_ruleid = Util.null2String(recordSet.getString("ruleid")); + String tmp_scopetype = Util.null2String(recordSet.getString("scopetype")); + String tmp_scopevalue = Util.null2String(recordSet.getString("scopevalue")); + String tmp_distributionmode = Util.null2String(recordSet.getString("distributionmode")); + recordSet.writeLog("tmp_id="+tmp_id+",tmp_ruleid="+tmp_ruleid+",tmp_scopetype="+tmp_scopetype+",tmp_scopevalue="+tmp_scopevalue); + if(tmp_ruleid.equals(ruleid) && ("".equals(ruleDetailId) || !tmp_id.equals(ruleDetailId))){ + //同一个假期类型,不能同时设置为【加班自动计入调休】和其他的规则,比如按工龄自动发放 + if(!tmp_distributionmode.equals("5")){ + result.put("flag","1"); + result.put("msg", SystemEnv.getHtmlLabelName(546798, user.getLanguage())); + return result; + } + } + + if(tmp_distributionmode.equals("5") && tmp_scopetype.equals(Util.null2String(scopeType)) && ("".equals(ruleDetailId) || !tmp_id.equals(ruleDetailId))){ + //总部级别的范围单独处理下,因为存在之前是分部级别,维护了分部id,这个时候即便是scopytype=0,但是scopevalue依然有值了,所以总部级别不用进行scopevalue的比对 + if("0".equals(tmp_scopetype)){ + result.put("flag","1"); + result.put("msg", SystemEnv.getHtmlLabelName(546797, user.getLanguage())); + return result; + } + if(null != scopeValue && scopeValue.indexOf(",")>-1){ + String[] values = scopeValue.split(","); + for (String value : values) { + if((","+tmp_scopevalue+",").indexOf(","+value+",")>-1){ + result.put("flag","1"); + result.put("msg", SystemEnv.getHtmlLabelName(546797, user.getLanguage())); + return result; + } + } + }else { + if((","+tmp_scopevalue+",").indexOf(","+scopeValue+",")>-1){ + result.put("flag","1"); + result.put("msg", SystemEnv.getHtmlLabelName(546797, user.getLanguage())); + return result; + } + } + } + } + + return result; + } + + /** + * 是否是育儿假,且不开启叠加 + * @param ruleId + * @return + */ + public static boolean isLeaveOfParental(String ruleId){ + boolean flag = false; + try { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=8 and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + String severalChildren = Util.null2s(recordSet.getString("severalChildren"), "0"); + if(severalChildren.equals("0")){ + flag = true; + } + } + } catch (Exception e) { + logger.info(e.getMessage()); + } + return flag; + } + /** + * 是否是育儿假且开启了叠加 + * @param ruleId + * @return + */ + public static boolean isLeaveOfParentalNum(String ruleId){ + boolean flag = false; + try { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=8 and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + String severalChildren = Util.null2s(recordSet.getString("severalChildren"), "0"); + if(severalChildren.equals("1")){ + flag = true; + } + } + } catch (Exception e) { + logger.info(e.getMessage()); + } + return flag; + } + + /** + * 半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + * @param ruleId + * @return + */ + public static int getTimeselection(String ruleId) { + int timeselection = 1;//最小请假单位 + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + timeselection = Util.getIntValue(kqLeaveRulesComInfo.getTimeSelection(ruleId), 1); + return timeselection; + } + + public void updateChildLeaveDate(int scopeType,String scopeValue,int validityRule,String ruleId){ + RecordSet rs = new RecordSet(); + try { + // 查询当年育儿假数据 + String sql = "select * from kq_balanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId = "+ruleId ; + + if (scopeType == 1 ) { + sql += " and resourceid in (select id from hrmresource where subCompanyId1 in (" + scopeValue + ") )"; + }else if (scopeType == 2 ) { + sql += " and resourceid in (select id from hrmresource where departmentId in (" + scopeValue + ") )"; + }else if (scopeType == 3) { + sql += " and (" + Tools.getOracleSQLIn(scopeValue, "resourceid") + ") "; + } + KQBalanceOfLeaveEntity balanceEntity = null; + ArrayList balanceEntities = new ArrayList<>(); + rs.executeQuery(sql); + while (rs.next()) { + int id = rs.getInt("id"); + String childId = Util.null2s(rs.getString("childId"), ""); + if(StringUtils.isNotBlank(childId)){ + String expirationDate = Util.null2s(rs.getString("expirationDate"), ""); + String effectiveDate = Util.null2s(rs.getString("effectiveDate"), ""); + balanceEntity = new KQBalanceOfLeaveEntity(); + balanceEntity.setId(id); + balanceEntity.setExpirationDate(expirationDate); + balanceEntity.setEffectiveDate(effectiveDate); + balanceEntities.add(balanceEntity); + } + } + sql = " update kq_balanceOfLeave set expirationDate =? where id= ? "; + for (int i = 0; balanceEntities != null && i < balanceEntities.size(); i++) { + KQBalanceOfLeaveEntity balance = balanceEntities.get(i); + String uid = Util.null2String(balance.getId()); + String effectiveDate = Util.null2String(balance.getEffectiveDate()); + String expirationDate = "2222-12-31"; + if (validityRule != 0) { + expirationDate = TimeUtil.dateAdd(TimeUtil.yearAdd(effectiveDate, 1), -1); + } + rs.executeUpdate(sql, expirationDate,uid); + } + + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + } + } +} diff --git a/src/com/engine/kq/biz/KQLeaveRulesComInfo.java b/src/com/engine/kq/biz/KQLeaveRulesComInfo.java new file mode 100644 index 0000000..3790b34 --- /dev/null +++ b/src/com/engine/kq/biz/KQLeaveRulesComInfo.java @@ -0,0 +1,319 @@ +package com.engine.kq.biz; + +import com.engine.kq.wfset.util.KQAttFlowCheckUtil; +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +/** + * 假期规则缓存类 + */ +public class KQLeaveRulesComInfo extends CacheBase { + + /** + * 数据来源 + */ + protected static String TABLE_NAME = "kq_leaveRules"; + /** + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = " (isDelete is null or isDelete !=1) "; + /** + * sql中的order by信息,不要以order by开始 + */ + protected static String TABLE_ORDER = " showOrder,id "; + + /** + * 主键 + */ + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + /** + * 假期规则名称 + */ + @CacheColumn(name = "leaveName") + protected static int leaveName; + + @CacheColumn(name = "SchevacationON") + protected static int SchevacationON; + + @CacheColumn(name = "Schevacation") + protected static int Schevacation; + + /** + * 是否禁用:0-未禁用、1-已禁用 + */ + @CacheColumn(name = "isEnable") + protected static int isEnable; + + /** + * 应用范围:0-总部、1-分部 + */ + @CacheColumn(name = "scopeType") + protected static int scopeType; + + /** + * 分部ID(当应用范围为分部时选择的分部ID) + */ + @CacheColumn(name = "scopeValue") + protected static int scopeValue; + + /** + * 最小请假单位 + * 1-按天请假 + * 2-按半天请假 + * 3-按小时请假 + * 4-按整天请假 + * 其他:无效数据 + */ + @CacheColumn(name = "minimumUnit") + protected static int minimumUnit; + + /** + * 余额单位变更时的换算比例 + * XX小时=1天 + */ + @CacheColumn(name = "proportion") + protected static int proportion; + + /** + * 日折算时长(1天=XX小时) + */ + @CacheColumn(name = "hoursToDay") + protected static int hoursToDay; + + /** + * 按自然日计算请假时长,0-不排除,1-排除节假日,2-排除休息日,3-排除节假日和休息日 + */ + @CacheColumn(name = "filterHolidays") + protected static int filterHolidays; + + /** + * 计算请假时长方式: + * 1-按工作日计算请假时长 + * 2-按自然日计算请假时长 + */ + @CacheColumn(name = "computingMode") + protected static int computingMode; + + /** + * 启用假期余额: + * 0-不启用 + * 1-启用 + */ + @CacheColumn(name = "balanceEnable") + protected static int balanceEnable; + + /** + * 假期类型标识 + */ + @CacheColumn(name = "leaveCode") + protected static int leaveCode; + + /** + * 半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + */ + @CacheColumn(name = "timeselection") + protected static int timeselection; + + /** + * 折算方式 1是四舍五入 2是向上取整 3是向下取整 + */ + @CacheColumn(name = "conversion") + protected static int conversion; + + /** + * 流程重复时段 1是重复 0是不重复,默认不重复 + */ + @CacheColumn(name = "repeat_time") + protected static int repeatTime; + + public String getId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getLeaveName() { + return (String)getRowValue(leaveName); + } + + public String getLeaveName(String key){ + return (String) getValue(leaveName,key); + } + + public String getSchevacationON() { + return (String)getRowValue(SchevacationON); + } + + public String getSchevacationON(String key){ + return (String) getValue(SchevacationON,key); + } + + public String getSchevacation() { + return (String)getRowValue(Schevacation); + } + + public String getSchevacation(String key){ + return (String) getValue(Schevacation,key); + } + + public String getIsEnable() { + return (String)getRowValue(isEnable); + } + + public String getIsEnable(String key){ + return (String) getValue(isEnable,key); + } + + public String getScopeType() { + return (String)getRowValue(scopeType); + } + + public String getScopeType(String key){ + return (String) getValue(scopeType,key); + } + + public String getScopeValue() { + return (String)getRowValue(scopeValue); + } + + public String getScopeValue(String key){ + return (String) getValue(scopeValue,key); + } + + public String getMinimumUnit() { + return (String)getRowValue(minimumUnit); + } + + public String getMinimumUnit(String key){ + return (String)getValue(minimumUnit,key); + } + + public String getProportion() { + return (String)getRowValue(proportion); + } + + public String getProportion(String key){ + return (String)getValue(proportion,key); + } + + public String getHoursToDay() { + return (String)getRowValue(hoursToDay); + } + + public String getHoursToDay(String key){ + return (String)getValue(hoursToDay,key); + } + public String getFilterHolidays() { + return (String)getRowValue(filterHolidays); + } + + public String getFilterHolidays(String key){ + return (String)getValue(filterHolidays,key); + } + + public String getComputingMode() { + return (String)getRowValue(computingMode); + } + + public String getComputingMode(String key){ + return (String)getValue(computingMode,key); + } + + public String getBalanceEnable() { + return (String)getRowValue(balanceEnable); + } + + public String getBalanceEnable(String key){ + return (String)getValue(balanceEnable,key); + } + + public String getLeaveCode() { + return (String)getRowValue(leaveCode); + } + + public String getLeaveCode(String key){ + return (String)getValue(leaveCode,key); + } + + public String getTimeSelection() { + String value = (String) getRowValue(timeselection); + if (value == null || value.equals("")) { + value = "1"; + } + return value; + } + + public String getTimeSelection(String key) { + String value = (String) getValue(timeselection, key); + if (value == null || value.equals("")) { + value = "1"; + } + return value; + } + + public String getConversion() { + return (String)getRowValue(conversion); + } + + public String getConversion(String key){ + return (String)getValue(conversion,key); + } + + public String getRepeatTime() { + return (String)getRowValue(repeatTime); + } + + public String getRepeatTime(String key){ + return (String)getValue(repeatTime,key); + } + + public String getUnitName(int language){ + String unitName = "";//单位名称,天/小时 + int minimumUnit = Util.getIntValue(getMinimumUnit(),1); + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) { + unitName = SystemEnv.getHtmlLabelName(389325, language);//(天) + } else { + unitName = SystemEnv.getHtmlLabelName(389326, language);//(小时) + } + return unitName; + } + + public String getUnitName(String key,int language){ + String unitName = "";//单位名称,天/小时 + int minimumUnit = Util.getIntValue(getMinimumUnit(key),1); + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) { + unitName = SystemEnv.getHtmlLabelName(389325, language);//(天) + } else { + unitName = SystemEnv.getHtmlLabelName(389326, language);//(小时) + } + +// KQTransMethod method = new KQTransMethod(); +// unitName = "("+method.getMinimumUnitName4Browser(""+minimumUnit, ""+language)+")"; + return unitName; + } + + public String getUnitNameNew(String key,int language){ + String unitName = "";//单位名称,天/小时 + int minimumUnit = Util.getIntValue(getMinimumUnit(key),1); + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) { + unitName = SystemEnv.getHtmlLabelName(389325, language);//(天) + } else { + unitName = SystemEnv.getHtmlLabelName(389326, language);//(小时) + } + return unitName; + } + + + + @Override + public void removeCache() { + super.removeCache(); + KQAttFlowCheckUtil kqAttFlowCheckUtil = new KQAttFlowCheckUtil(); + kqAttFlowCheckUtil.initLeaveUnit(); + } + +} diff --git a/src/com/engine/kq/biz/KQLeaveRulesDetailComInfo.java b/src/com/engine/kq/biz/KQLeaveRulesDetailComInfo.java new file mode 100644 index 0000000..b7398ec --- /dev/null +++ b/src/com/engine/kq/biz/KQLeaveRulesDetailComInfo.java @@ -0,0 +1,1329 @@ +package com.engine.kq.biz; + +import weaver.cache.*; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; + +/** + * @Auther: Administrator + * @Date: 2019-03-08 16:23 + * @Description: + */ +public class KQLeaveRulesDetailComInfo extends CacheBase { + + /** + * 数据来源 + */ + protected static String TABLE_NAME = "kq_leaveRulesDetail"; + /** + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = " (isDelete is null or isDelete !=1) "; + /** + * sql中的order by信息,不要以order by开始 + */ + protected static String TABLE_ORDER = "id"; + + /** + * 主键 + */ + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + /** + * 假期规则的ID + */ + @CacheColumn(name = "id") + protected static int id; + + /** + * 假期类型的ID + */ + @CacheColumn(name = "ruleId") + protected static int ruleId; + + /** + * 假期规则名称 + */ + @CacheColumn(name = "ruleName") + protected static int ruleName; + + /** + * 应用范围:0-总部、1-分部 + */ + @CacheColumn(name = "scopeType") + protected static int scopeType; + + /** + * 分部ID(当应用范围为分部时选择的分部ID) + */ + @CacheColumn(name = "scopeValue") + protected static int scopeValue; + + /** + * 余额发放方式: + * 1-手动发放 + * 2-按司龄自动发放 + * 3-按工龄自动发放 + * 4-每年自动发放固定天数 + * 5-加班时长自动计入余额 + * 6-按司龄+工龄自动发放 + */ + @CacheColumn(name = "distributionMode") + protected static int distributionMode; + + /** + * 每人发放小时(天)数 + * 注:当余额发放方式为"4-每年自动发放固定天数"时有效 + */ + @CacheColumn(name = "annualAmount") + protected static int annualAmount; + + /** + * 法定年假的规则:(当【余额发放方式】选择【6-按司龄+工龄自动发放】才有效) + * 0-工龄(默认) + * 1-司龄 + * 2-司龄+工龄 + */ + @CacheColumn(name = "legalKey") + protected static int legalKey; + + /** + * 福利年假的规则:(当【余额发放方式】选择【6-按司龄+工龄自动发放】才有效) + * 0-工龄 + * 1-司龄(默认) + * 2-司龄+工龄 + */ + @CacheColumn(name = "welfareKey") + protected static int welfareKey; + + /** + * 扣减优先级:(当【余额发放方式】选择【6-按司龄+工龄自动发放】才有效) + * 1-法定年假 + * 2-福利年假 + */ + @CacheColumn(name = "priority") + protected static int priority; + + /** + * 计算方式 + */ + @CacheColumn(name = "calcMethod") + protected static int calcMethod; + + /** + * //假期基数的发放日期 + * //1--每年的1月1号 + * //2--入职日期 + * //3--参加工作日期 + */ + @CacheColumn(name = "baseAmountReleaseDate") + protected static int baseAmountReleaseDate; + + /** + * //假期基数的变动日期 + * //1--每年的1月1号 + * //2--入职日期 + * //3--参加工作日期 + */ + @CacheColumn(name = "baseAmountChangeDate") + protected static int baseAmountChangeDate; + + /** + * 假期基数折算方式 + * 0--不折算 + * 1--四舍五入 + * 2--向上取整 + * 3--向下取整 + * 4--向上取0.5的倍数 + * 5--向下取0.5的倍数 + */ + @CacheColumn(name = "convertMode") + protected static int convertMode; + + /** + * 折算后保留的小数点位数 + */ + @CacheColumn(name = "decimalDigit") + protected static int decimalDigit; + + /** + * 有效期规则 + * 0-永久有效 + * 1-按自然年(1月1日-12月31日) + * 2-按入职日期起12个月 + * 3-自定义次年失效日期 + * 4-按天数失效 + * 5-按季度失效 + * 6-按月数失效 + */ + @CacheColumn(name = "validityRule") + protected static int validityRule; + + /** + * 失效日期-月 + */ + @CacheColumn(name = "expirationMonth") + protected static int expirationMonth; + + /** + * 失效日期-日 + */ + @CacheColumn(name = "expirationDay") + protected static int expirationDay; + + /** + * 有效天数 + */ + @CacheColumn(name = "effectiveDays") + protected static int effectiveDays; + + /** + * 有效月数 + */ + @CacheColumn(name = "effectiveMonths") + protected static int effectiveMonths; + + /** + * 是否允许延长有效期 + * 0-不允许 + * 1-允许 + */ + @CacheColumn(name = "extensionEnable") + protected static int extensionEnable; + + /** + * 允许延长的有效期天数 + */ + @CacheColumn(name = "extendedDays") + protected static int extendedDays; + + /** + * 释放规则 + * 0-不限制 + * 1-按天释放 + * 2-按月释放 + */ + @CacheColumn(name = "releaseRule") + protected static int releaseRule; + + /** + * 假期类型 + */ + @CacheColumn(name = "leaveCode") + protected static int leaveCode; + + /** + * 是否需要排除次账号 + * 0--不排除,即次账号正常享受年假 + * 1--排除,即次账号不能享受年假 + */ + @CacheColumn(name = "excludeSubAccount") + protected static int excludeSubAccount; + + /** + * 转正之前是否允许发放假期余额 + * 0--不允许 + * 1--允许 + */ + @CacheColumn(name = "beforeFormal") + protected static int beforeFormal; + + /** + * 多孩叠加开关 + * 0--不 + * 1--开 + */ + @CacheColumn(name = "severalChildren") + protected static int severalChildren; + + /** + * 孩子多少周岁前发放。 + */ + @CacheColumn(name = "yearsOld") + protected static int yearsOld; + + /** + *是否按照省份发放育儿假。1否,2是 + */ + @CacheColumn(name = "isprovince") + protected static int isprovince; + + /** + *是否按照省份发放育儿假。1否,2是 + */ + @CacheColumn(name = "carryOver") + protected static int carryOver; + + private static final String[] SCOPE_TYPES = {"3", "2", "1"}; + @Override + public CacheMap initCache() throws Exception { + CacheMap localData = super.createCacheMap(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_leaveRulesDetail where (isDelete is null or isDelete<>1) order by id"; + rs.executeQuery(sql); + while (rs.next()) { + String _id = rs.getString("id"); + String _ruleId = rs.getString("ruleId");//假期类型的ID + String _ruleName = rs.getString("ruleName");//假期类型的ID + String _scopeType = rs.getString("scopeType");//假期类型的流程可见范围 + String _scopeValue = rs.getString("scopeValue");//流程可见范围为分部时勾选的分部ID + String _distributionMode = rs.getString("distributionMode"); + String _annualAmount = rs.getString("annualAmount"); + String _legalKey = rs.getString("legalKey"); + String _welfareKey = rs.getString("welfareKey"); + String _priority = rs.getString("priority"); + String _calcMethod = rs.getString("calcMethod"); + String _baseAmountReleaseDate = rs.getString("baseAmountReleaseDate"); + String _baseAmountChangeDate = rs.getString("baseAmountChangeDate"); + String _convertMode = rs.getString("convertMode"); + String _decimalDigit = rs.getString("decimalDigit"); + String _validityRule = rs.getString("validityRule"); + String _expirationMonth = rs.getString("expirationMonth"); + String _expirationDay = rs.getString("expirationDay"); + String _effectiveDays = rs.getString("effectiveDays"); + String _effectiveMonths = rs.getString("effectiveMonths"); + String _extensionEnable = rs.getString("extensionEnable"); + String _extendedDays = rs.getString("extendedDays"); + String _releaseRule = rs.getString("releaseRule"); + String _leaveCode = rs.getString("leaveCode"); + String _excludeSubAccount = rs.getString("excludeSubAccount"); + String _beforeFormal = rs.getString("beforeFormal"); + String _severalChildren = rs.getString("severalChildren"); + String _yearsOld = rs.getString("yearsOld"); + String _isprovince = rs.getString("isprovince"); + String _carryOver = rs.getString("carryOver"); + if (_scopeType.equals("1") || _scopeType.equals("2") || _scopeType.equals("3")) { + String[] scopeValueArr = _scopeValue.split(","); + for (int i = 0; i < scopeValueArr.length; i++) { + String PK = _ruleId + "|" + _scopeType + "|" + scopeValueArr[i]; + + + CacheItem row = createCacheItem(); + row.set(PK_INDEX, PK); + row.set(id, _id); + row.set(ruleId, _ruleId); + row.set(ruleName, _ruleName); + row.set(scopeType, _scopeType); + row.set(scopeValue, _scopeValue); + row.set(distributionMode, _distributionMode); + row.set(annualAmount, _annualAmount); + row.set(legalKey, _legalKey); + row.set(welfareKey, _welfareKey); + row.set(priority, _priority); + row.set(calcMethod, _calcMethod); + row.set(baseAmountReleaseDate, _baseAmountReleaseDate); + row.set(baseAmountChangeDate, _baseAmountChangeDate); + row.set(convertMode, _convertMode); + row.set(decimalDigit, _decimalDigit); + row.set(validityRule, _validityRule); + row.set(expirationMonth, _expirationMonth); + row.set(expirationDay, _expirationDay); + row.set(effectiveDays, _effectiveDays); + row.set(effectiveMonths, _effectiveMonths); + row.set(extensionEnable, _extensionEnable); + row.set(extendedDays, _extendedDays); + row.set(releaseRule, _releaseRule); + row.set(leaveCode, _leaveCode); + row.set(excludeSubAccount, _excludeSubAccount); + row.set(beforeFormal, _beforeFormal); + row.set(severalChildren, _severalChildren); + row.set(yearsOld, _yearsOld); + row.set(isprovince, _isprovince); + row.set(carryOver, _carryOver); + modifyCacheItem(PK, row); + localData.put(PK, row); + } + } else { + String PK = ruleId + "|" + scopeType; + + CacheItem row = createCacheItem(); + row.set(PK_INDEX, PK); + row.set(id, _id); + row.set(ruleId, _ruleId); + row.set(ruleName, _ruleName); + row.set(scopeType, _scopeType); + row.set(scopeValue, _scopeValue); + row.set(distributionMode, _distributionMode); + row.set(annualAmount, _annualAmount); + row.set(legalKey, _legalKey); + row.set(welfareKey, _welfareKey); + row.set(priority, _priority); + row.set(calcMethod, _calcMethod); + row.set(baseAmountReleaseDate, _baseAmountReleaseDate); + row.set(baseAmountChangeDate, _baseAmountChangeDate); + row.set(convertMode, _convertMode); + row.set(decimalDigit, _decimalDigit); + row.set(validityRule, _validityRule); + row.set(expirationMonth, _expirationMonth); + row.set(expirationDay, _expirationDay); + row.set(effectiveDays, _effectiveDays); + row.set(effectiveMonths, _effectiveMonths); + row.set(extensionEnable, _extensionEnable); + row.set(extendedDays, _extendedDays); + row.set(releaseRule, _releaseRule); + row.set(leaveCode, _leaveCode); + row.set(excludeSubAccount, _excludeSubAccount); + row.set(beforeFormal, _beforeFormal); + row.set(severalChildren, _severalChildren); + row.set(yearsOld, _yearsOld); + row.set(isprovince, _isprovince); + row.set(carryOver, _carryOver); + modifyCacheItem(PK, row); + localData.put(PK, row); + } + } + return localData; + } + + @Override + public CacheItem initCache(String key) { + if (key == null || "".equals(key.trim())) { + return null; + } + + String ruleIdTemp = "";//假期类型的ID + String scopeTypeTemp = "";//假期类型的流程可见范围 + String scopeValueTemp = "";//流程可见范围为分部时勾选的分部ID + String PK = ""; + + String[] keyArr = key.split("\\|"); + String sql = ""; + RecordSet rs = new RecordSet(); + if (keyArr.length == 2) { + ruleIdTemp = keyArr[0]; + scopeTypeTemp = keyArr[1]; + PK = ruleIdTemp + "|0"; + + sql = "select * from kq_leaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=" + ruleIdTemp + " and scopeType=" + scopeTypeTemp + " order by id"; + } + if (keyArr.length == 3) { + ruleIdTemp = keyArr[0]; + scopeTypeTemp = keyArr[1]; + scopeValueTemp = keyArr[2]; + PK = ruleIdTemp + "|1|" + scopeValueTemp; + + sql = "select * from kq_leaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=" + ruleIdTemp + " and scopeType=" + scopeTypeTemp; + if (rs.getDBType().equalsIgnoreCase("sqlserver")) { + sql += " and ','+scopeValue+',' like '%," + scopeValueTemp + ",%'"; + } else if (rs.getDBType().equalsIgnoreCase("mysql")) { + sql += " and concat(',',scopeValue,',') like '%," + scopeValueTemp + ",%'"; + } else { + sql += " and ','||scopeValue||',' like '%," + scopeValueTemp + ",%'"; + } + sql += " order by id "; + } + rs.executeQuery(sql); + if (rs.next()) { + String _id = rs.getString("id"); + String _ruleId = rs.getString("ruleId");//假期类型的ID + String _ruleName = rs.getString("ruleName");//假期类型的ID + String _scopeType = rs.getString("scopeType");//假期类型的流程可见范围 + String _scopeValue = rs.getString("scopeValue");//流程可见范围为分部时勾选的分部ID + String _distributionMode = rs.getString("distributionMode"); + String _annualAmount = rs.getString("annualAmount"); + String _legalKey = rs.getString("legalKey"); + String _welfareKey = rs.getString("welfareKey"); + String _priority = rs.getString("priority"); + String _calcMethod = rs.getString("calcMethod"); + String _baseAmountReleaseDate = rs.getString("baseAmountReleaseDate"); + String _baseAmountChangeDate = rs.getString("baseAmountChangeDate"); + String _convertMode = rs.getString("convertMode"); + String _decimalDigit = rs.getString("decimalDigit"); + String _validityRule = rs.getString("validityRule"); + String _expirationMonth = rs.getString("expirationMonth"); + String _expirationDay = rs.getString("expirationDay"); + String _effectiveDays = rs.getString("effectiveDays"); + String _effectiveMonths = rs.getString("effectiveMonths"); + String _extensionEnable = rs.getString("extensionEnable"); + String _extendedDays = rs.getString("extendedDays"); + String _releaseRule = rs.getString("releaseRule"); + String _leaveCode = rs.getString("leaveCode"); + String _excludeSubAccount = rs.getString("excludeSubAccount"); + String _beforeFormal = rs.getString("beforeFormal"); + String _severalChildren = rs.getString("severalChildren"); + String _yearsOld = rs.getString("yearsOld"); + String _isprovince = rs.getString("isprovince"); + String _carryOver = rs.getString("carryOver"); + + CacheItem row = createCacheItem(); + row.set(PK_INDEX, PK); + row.set(id, _id); + row.set(ruleId, _ruleId); + row.set(ruleName, _ruleName); + row.set(scopeType, _scopeType); + row.set(scopeValue, _scopeValue); + row.set(distributionMode, _distributionMode); + row.set(annualAmount, _annualAmount); + row.set(legalKey, _legalKey); + row.set(welfareKey, _welfareKey); + row.set(priority, _priority); + row.set(calcMethod, _calcMethod); + row.set(baseAmountReleaseDate, _baseAmountReleaseDate); + row.set(baseAmountChangeDate, _baseAmountChangeDate); + row.set(convertMode, _convertMode); + row.set(decimalDigit, _decimalDigit); + row.set(validityRule, _validityRule); + row.set(expirationMonth, _expirationMonth); + row.set(expirationDay, _expirationDay); + row.set(effectiveDays, _effectiveDays); + row.set(effectiveMonths, _effectiveMonths); + row.set(extensionEnable, _extensionEnable); + row.set(extendedDays, _extendedDays); + row.set(releaseRule, _releaseRule); + row.set(leaveCode, _leaveCode); + row.set(excludeSubAccount, _excludeSubAccount); + row.set(beforeFormal, _beforeFormal); + row.set(severalChildren, _severalChildren); + row.set(yearsOld, _yearsOld); + row.set(isprovince, _isprovince); + row.set(carryOver, _carryOver); + modifyCacheItem(key, row); + return row; + } else { + CacheItem row = createCacheItem(); + modifyCacheItem(key, row); + return row; + } + } + + private String getId(String key) { + return (String) getValue(id, key); + } + +// public String getId(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String id = getId(PK); +// if (id == null || id == "") { +// PK = ruleId + "|0"; +// id = getId(PK); +// } +// return id; +// } + + private String getRuleId(String key) { + return (String) getValue(ruleId, key); + } + + private String getRuleName(String key) { + return (String) getValue(ruleName, key); + } + +// public String getRuleName(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String ruleName = getRuleName(PK); +// if (ruleName == null || ruleName == "") { +// PK = ruleId + "|0"; +// ruleName = getRuleName(PK); +// } +// return ruleName; +// } + + private String getScopeType(String key) { + return (String) getValue(scopeType, key); + } + +// public String getScopeType(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String scopeType = getScopeType(PK); +// if (scopeType == null || scopeType == "") { +// PK = ruleId + "|0"; +// scopeType = getScopeType(PK); +// } +// return scopeType; +// } + + private String getScopeValue(String key) { + return (String) getValue(scopeValue, key); + } + +// public String getScopeValue(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String scopeValue = getScopeValue(PK); +// if (scopeValue == null || scopeValue == "") { +// PK = ruleId + "|0"; +// scopeValue = getScopeValue(PK); +// } +// return scopeValue; +// } + + private String getDistributionMode(String key) { + return (String) getValue(distributionMode, key); + } + +// public String getDistributionMode(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String distributionMode = getDistributionMode(PK); +// if (distributionMode == null || distributionMode == "") { +// PK = ruleId + "|0"; +// distributionMode = getDistributionMode(PK); +// } +// return distributionMode; +// } + + private String getAnnualAmount(String key) { + return (String) getValue(annualAmount, key); + } + +// public String getAnnualAmount(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String annualAmount = getAnnualAmount(PK); +// if (annualAmount == null || annualAmount == "") { +// PK = ruleId + "|0"; +// annualAmount = getAnnualAmount(PK); +// } +// return annualAmount; +// } + + private String getLegalKey(String key) { + return (String) getValue(legalKey, key); + } + +// public String getLegalKey(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String legalKey = getLegalKey(PK); +// if (legalKey == null || legalKey == "") { +// PK = ruleId + "|0"; +// legalKey = getLegalKey(PK); +// } +// return legalKey; +// } + + private String getWelfareKey(String key) { + return (String) getValue(welfareKey, key); + } + +// public String getWelfareKey(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String welfareKey = getWelfareKey(PK); +// if (welfareKey == null || welfareKey == "") { +// PK = ruleId + "|0"; +// welfareKey = getWelfareKey(PK); +// } +// return welfareKey; +// } + + private String getPriority(String key) { + return (String) getValue(priority, key); + } + +// public String getPriority(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String priority = getPriority(PK); +// if (priority == null || priority == "") { +// PK = ruleId + "|0"; +// priority = getPriority(PK); +// } +// return priority; +// } + + private String getValidityRule(String key) { + return (String) getValue(validityRule, key); + } + +// public String getValidityRule(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String validityRule = getValidityRule(PK); +// if (validityRule == null || validityRule == "") { +// PK = ruleId + "|0"; +// validityRule = getValidityRule(PK); +// } +// return validityRule; +// } + + private String getExpirationMonth(String key) { + return (String) getValue(expirationMonth, key); + } + +// public String getExpirationMonth(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String expirationMonth = getExpirationMonth(PK); +// if (expirationMonth == null || expirationMonth == "") { +// PK = ruleId + "|0"; +// expirationMonth = getExpirationMonth(PK); +// } +// if (expirationMonth.length() == 1) { +// expirationMonth = "0" + expirationMonth; +// } +// return expirationMonth; +// } + + private String getExpirationDay(String key) { + return (String) getValue(expirationDay, key); + } + +// public String getExpirationDay(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String expirationDay = getExpirationDay(PK); +// if (expirationDay == null || expirationDay == "") { +// PK = ruleId + "|0"; +// expirationDay = getExpirationDay(PK); +// } +// if (expirationDay.length() == 1) { +// expirationDay = "0" + expirationDay; +// } +// return expirationDay; +// } + + private String getEffectiveDays(String key) { + return (String) getValue(effectiveDays, key); + } + +// public String getEffectiveDays(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String effectiveDays = getEffectiveDays(PK); +// if (effectiveDays == null || effectiveDays == "") { +// PK = ruleId + "|0"; +// effectiveDays = getEffectiveDays(PK); +// } +// if (Util.getIntValue(effectiveDays, 0) < 1) { +// effectiveDays = "1"; +// } +// return effectiveDays; +// } + + private String getEffectiveMonths(String key) { + return (String) getValue(effectiveMonths, key); + } + +// public String getEffectiveMonths(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String effectiveMonths = getEffectiveMonths(PK); +// if (effectiveMonths == null || effectiveMonths == "") { +// PK = ruleId + "|0"; +// effectiveMonths = getEffectiveMonths(PK); +// } +// if (Util.getIntValue(effectiveMonths, 0) < 1) { +// effectiveMonths = "1"; +// } +// return effectiveMonths; +// } + + private String getExtensionEnable(String key) { + return (String) getValue(extensionEnable, key); + } + +// public String getExtensionEnable(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String extensionEnable = getExtensionEnable(PK); +// if (extensionEnable == null || extensionEnable == "") { +// PK = ruleId + "|0"; +// extensionEnable = getExtensionEnable(PK); +// } +// return extensionEnable; +// } + + private String getExtendedDays(String key) { + return (String) getValue(extendedDays, key); + } + +// public String getExtendedDays(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String extendedDays = getExtendedDays(PK); +// if (extendedDays == null || extendedDays == "") { +// PK = ruleId + "|0"; +// extendedDays = getExtendedDays(PK); +// } +// return extendedDays; +// } + + private String getReleaseRule(String key) { + return (String) getValue(releaseRule, key); + } + +// public String getReleaseRule(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String releaseRule = getReleaseRule(PK); +// if (releaseRule == null || releaseRule == "") { +// PK = ruleId + "|0"; +// releaseRule = getReleaseRule(PK); +// } +// return releaseRule; +// } + + private String getLeaveCode(String key) { + return (String) getValue(leaveCode, key); + } + +// public String getLeaveCode(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String leaveCode = getLeaveCode(PK); +// if (leaveCode == null || leaveCode == "") { +// PK = ruleId + "|0"; +// leaveCode = getLeaveCode(PK); +// } +// return leaveCode; +// } + + private String getCalcMethod(String key) { + return (String) getValue(calcMethod, key); + } + +// public String getCalcMethod(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String calcMethod = getCalcMethod(PK); +// if (calcMethod == null || calcMethod == "") { +// PK = ruleId + "|0"; +// calcMethod = getCalcMethod(PK); +// } +// return calcMethod; +// } + + private String getBaseAmountReleaseDate(String key) { + return (String) getValue(baseAmountReleaseDate, key); + } + +// public String getBaseAmountReleaseDate(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String baseAmountReleaseDate = getBaseAmountReleaseDate(PK); +// if (baseAmountReleaseDate == null || baseAmountReleaseDate == "") { +// PK = ruleId + "|0"; +// baseAmountReleaseDate = getBaseAmountReleaseDate(PK); +// } +// return baseAmountReleaseDate; +// } + + private String getBaseAmountChangeDate(String key) { + return (String) getValue(baseAmountChangeDate, key); + } + +// public String getBaseAmountChangeDate(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String baseAmountChangeDate = getBaseAmountChangeDate(PK); +// if (baseAmountChangeDate == null || baseAmountChangeDate == "") { +// PK = ruleId + "|0"; +// baseAmountChangeDate = getBaseAmountChangeDate(PK); +// } +// return baseAmountChangeDate; +// } + + private String getConvertMode(String key) { + return (String) getValue(convertMode, key); + } + +// public String getConvertMode(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String convertMode = getConvertMode(PK); +// if (convertMode == null || convertMode == "") { +// PK = ruleId + "|0"; +// convertMode = getConvertMode(PK); +// } +// if (convertMode == null || convertMode.equals("")) { +// convertMode = "1"; +// } +// return convertMode; +// } + + private String getDecimalDigit(String key) { + return (String) getValue(decimalDigit, key); + } + +// public String getDecimalDigit(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String decimalDigit = getDecimalDigit(PK); +// if (decimalDigit == null || decimalDigit == "") { +// PK = ruleId + "|0"; +// decimalDigit = getDecimalDigit(PK); +// } +// if (decimalDigit == null || decimalDigit == "" || Util.getIntValue(decimalDigit, 0) < 2) { +// decimalDigit = "2"; +// } +// return decimalDigit; +// } + + private String getExcludeSubAccount(String key) { + return (String) getValue(excludeSubAccount, key); + } + +// public String getExcludeSubAccount(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String excludeSubAccount = getExcludeSubAccount(PK); +// if (excludeSubAccount == null || excludeSubAccount == "") { +// PK = ruleId + "|0"; +// excludeSubAccount = getExcludeSubAccount(PK); +// } +// return excludeSubAccount; +// } + + private String getBeforeFormal(String key) { + return (String) getValue(beforeFormal, key); + } + +// public String getBeforeFormal(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String beforeFormal = getBeforeFormal(PK); +// if (beforeFormal == null || beforeFormal == "") { +// PK = ruleId + "|0"; +// beforeFormal = getBeforeFormal(PK); +// } +// return beforeFormal; +// } + private String getSeveralChildren(String key) { + return (String) getValue(severalChildren, key); + } + +// public String getSeveralChildren(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String severalChildren = getSeveralChildren(PK); +// if (severalChildren == null || severalChildren == "") { +// PK = ruleId + "|0"; +// severalChildren = getSeveralChildren(PK); +// } +// return severalChildren; +// } + + private String getYearsOld(String key) { + return (String) getValue(yearsOld, key); + } + +// public String getYearsOld(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String yearsOld = getYearsOld(PK); +// if (yearsOld == null || yearsOld == "") { +// PK = ruleId + "|0"; +// yearsOld = getYearsOld(PK); +// } +// return yearsOld; +// } + private String getIsProvince(String key) { + return (String) getValue(isprovince, key); + } + + private String getCarryOver(String key) { + return (String) getValue(carryOver, key); + } + +// public String getIsProvince(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String isprovince = getIsProvince(PK); +// if (isprovince == null || isprovince == "") { +// PK = ruleId + "|0"; +// isprovince = getIsProvince(PK); +// } +// return isprovince; +// } + + + + public String getId(String ruleId, String subcompanyId, String departmentId, String resourceId) { + String value = ""; + String[] scopeValue = {resourceId, departmentId, subcompanyId}; + for(int i=0; i tableMap = new HashMap<>(); + rs.executeQuery(sql); + while(rs.next()){ + String setid = rs.getString("id"); + String formid = rs.getString("field002"); + String tablename = workflowBillComInfo.getTablename(formid); + String fieldnameSql = " select * from hrm_att_proc_relation where field002 in(select id from hrm_att_proc_fields where field001 = 180 and field002='newLeaveType') and field001 = "+setid; + String fieldname = ""; + rs1.executeQuery(fieldnameSql); + if(rs1.next()){ + fieldname = rs1.getString("field004"); + } + if(tablename.length() > 0 && fieldname.length() > 0){ + tableMap.put(tablename, fieldname); + } + } + List updateSqls = new ArrayList<>(); + String leavetypeSql = "select * from hrm_to_kq_LeaveRules "; + rs2.executeQuery(leavetypeSql); + while(rs2.next()){ + String hrmleaveid = rs2.getString("hrmleaveid"); + String kqleaveid = rs2.getString("kqleaveid"); + for(Map.Entry me: tableMap.entrySet()){ + String upSql = "update "+me.getKey()+" set "+me.getValue()+" = " +kqleaveid+ " where "+me.getValue()+"="+hrmleaveid; + updateSqls.add(upSql); + } + } + for(String upSql : updateSqls){ + rs.executeUpdate(upSql); + } + + } + + /** + * 在流程數據拆分前,需要初始化出差规则、公出规则和加班规则 + * @return + */ + public boolean upFLowRule() { + boolean isDone = false; + isDone = upEvectionRule(); + if(!isDone){ + return isDone; + } + isDone = upOutRule(); + if(!isDone){ + return isDone; + } + isDone = upOvertimeRuleUnit(); + if(!isDone){ + return isDone; + } + isDone = upOvertimeRule("",null,""); + if(!isDone){ + return isDone; + } + return isDone; + } + + /** + * 初始化加班规则单位 + * @return + */ + public boolean upOvertimeRuleUnit() { + + int id = 1;////暂为备用字段,加班单位ID,固定为1 + int organizationType = 0;//暂为备用字段,所属机构类型:0-总部、1-分部、2-部门 + int organizationId = -1;//暂为备用字段,所属机构的ID(机构类型为分部时为分部ID) + int minimumUnit = 1;//最小加班单位:1-按天加班、2-按半天加班、3-按小时加班、4-按整天加班 + double hoursToday = 8.00;//日折算时长 + + boolean flag = true; + String sql = "update kq_OvertimeUnit set minimumUnit=?,hoursToday=? where id=?"; + RecordSet recordSet = new RecordSet(); + flag = recordSet.executeUpdate(sql, minimumUnit, hoursToday, id); + return flag; + } + + /** + * 升级初始化加班规则 + */ + public boolean upOvertimeRule(String groupids, User user,String rulefrom) { + RecordSet rs = new RecordSet(); + if(groupids.length() > 0){ + groupids = groupids.substring(1); + Map params = new HashMap<>(); + if("scheduleset".equalsIgnoreCase(rulefrom)){ + params.put("name", "一般工作时间升级加班规则"); + }else{ + params.put("name", "排班升级加班规则"); + } + params.put("groupIds", groupids); + params.put("minimumLen2", "1"); + params.put("startTime2", "0"); + params.put("minimumLen3", "1"); + params.put("minimumLen1", "1"); + + params.put("paidLeaveEnableType2", "2"); + params.put("paidLeaveEnableType3", "2"); + params.put("paidLeaveEnableType1", "2"); + params.put("paidLeaveEnableFlowType2", "1"); + params.put("paidLeaveEnableFlowType3", "1"); + params.put("paidLeaveEnableFlowType1", "1"); + int ruleId = KQOvertimeRulesBiz.addOvertimeRules(params, user); + if(ruleId > 0){ + String overRuleSql = "insert into hrm_to_kq_OverRules(kqid,rulefrom) values(?,?)"; + return rs.executeUpdate(overRuleSql, ruleId,rulefrom); + }else{ + kqLog.info("upOvertimeRule 生成加班规则失败 :"+params); + return false; + } + }else{ + kqLog.info("upOvertimeRule 生成加班规则失败 :groupids为空"); + return false; + } + } + + /** + * 升级初始化公出规则 + */ + public boolean upOutRule() { + RecordSet recordSet = new RecordSet(); + String exit_ruleId = "1";//暂为备用字段,规则ID,固定为1 + String exit_name = "出差";//暂为备用字段,规则名称,目前固定为出差 + int exit_organizationType = 0;//暂为备用字段,所属机构类型:0-总部、1-分部、2-部门 + int exit_organizationId = 0;//暂为备用字段,所属机构的ID(机构类型为分部时为分部ID) + int exit_minimumUnit = 1;//最小公出单位:1-按天公出、2-按半天公出、3-按小时公出、4-按整天公出 + double exit_proportion = 8.00;//换算比例(当单位由天、半天、整天切换成小时或者由小时切换成天、半天、整天时,历史数据的转换比例) + int exit_computingMode = 1;//计算公出时长方式:1-按工作日计算公出时长、2-按自然日计算公出时长 + double exit_hoursToDay = 8.00;//日折算时长(当按天公出、按半天公出且按自然日计算公出时长时有效) + + String sql = "update kq_exitRules set minimumUnit=?,proportion=?,computingMode=?,hoursToDay=? where id=?"; + boolean flag = recordSet.executeUpdate(sql, exit_minimumUnit, exit_proportion, exit_computingMode, exit_hoursToDay, exit_ruleId); + + return flag; + } + + /** + * 升级初始化出差规则 + */ + public boolean upEvectionRule() { + String ruleId = "1";//暂为备用字段,规则ID,固定为1 + String name = "出差";//暂为备用字段,规则名称,目前固定为出差 + int organizationType = 0;//暂为备用字段,所属机构类型:0-总部、1-分部、2-部门 + int organizationId = 0;//暂为备用字段,所属机构的ID(机构类型为分部时为分部ID) + int minimumUnit = 1;//最小出差单位:1-按天出差、2-按半天出差、3-按小时出差、4-按整天出差 + double proportion = 8.00;//换算比例(当单位由天、半天、整天切换成小时或者由小时切换成天、半天、整天时,历史数据的转换比例) + int computingMode = 1;//计算公出时长方式:1-按工作日计算出差时长、2-按自然日计算出差时长 + double hoursToDay = 8.00;//折算时长(当按天出差、按半天出差且按自然日计算出差时长时有效) + + boolean flag = true; + String sql = "update kq_travelRules set minimumUnit=?,proportion=?,computingMode=?,hoursToDay=? where id=?"; + RecordSet recordSet = new RecordSet(); + flag = recordSet.executeUpdate(sql, minimumUnit, proportion, computingMode, hoursToDay, ruleId); + + return flag; + } + + /** + * 所有相關的緩存需要刷新下 + */ + public void refreshCominfo() { + + try{ + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + subCompanyComInfo.removeCompanyCache(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + departmentComInfo.removeCompanyCache(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + resourceComInfo.removeResourceCache(); + }catch (Exception e){ + } + KQAttFlowSetComInfo kqAttFlowSetComInfo = new KQAttFlowSetComInfo(); + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + KQShiftOnOffWorkSectionComInfo onOffWorkSectionComInfo = new KQShiftOnOffWorkSectionComInfo(); + KQShiftRestTimeSectionComInfo restTimeSectionComInfo = new KQShiftRestTimeSectionComInfo(); + KQGroupMemberComInfo groupMemberComInfo = new KQGroupMemberComInfo(); + KQFixedSchedulceComInfo kqFixedSchedulceComInfo = new KQFixedSchedulceComInfo(); + KQShiftScheduleComInfo kqShiftScheduleComInfo = new KQShiftScheduleComInfo(); + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + KQHolidaySetComInfo holidaySetComInfo = new KQHolidaySetComInfo(); + KQTravelRulesComInfo travelRulesComInfo = new KQTravelRulesComInfo(); + KQExitRulesComInfo exitRulesComInfo = new KQExitRulesComInfo(); + KQLeaveRulesDetailComInfo rulesDetailComInfo = new KQLeaveRulesDetailComInfo(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + + kqShiftManagementComInfo.removeShiftManagementCache(); + onOffWorkSectionComInfo.removeShiftWorkSectionCache(); + restTimeSectionComInfo.removeShiftRestTimeSectionCache(); + groupMemberComInfo.removeCache(); + kqFixedSchedulceComInfo.removeCache(); + kqShiftScheduleComInfo.removeCache(); + kqLeaveRulesComInfo.removeCache(); + holidaySetComInfo.removeCache(); + travelRulesComInfo.removeCache(); + exitRulesComInfo.removeCache(); + kqAttFlowSetComInfo.removeKQAttFlowSetComInfoCache(); + kqLeaveRulesComInfo.removeCache(); + rulesDetailComInfo.removeCache(); + kqGroupComInfo.removeCache(); + } + + public void upReportData(String startdate,String enddate) { + KQFormatData kqFormatData = new KQFormatData(); + LocalDate localFromDate = LocalDate.parse(startdate); + LocalDate localToDate = LocalDate.parse(enddate); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + long betweenDays = localToDate.toEpochDay() - localFromDate.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + LocalDate curLocalDate = localFromDate.plusDays(i); + String kqDate = curLocalDate.format(dateFormatter); + new KQFormatBiz().formatDateByKQDate(kqDate); + } + } + + /** + * 升級流程數據 對流程數據進行拆分 + * @param startdate + * @param enddate + * @return + */ + public void upFlowData(String startdate,String enddate) { + + try{ + RecordSet rs = new RecordSet(); + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + + String sql1 = " select * from kq_ATT_PROC_SET where id in(select kqid from hrm_to_attSet) "; + rs.executeQuery(sql1); + while(rs.next()){ + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + + String workflowid = rs.getString("field001"); + + int kqtype = Util.getIntValue(rs.getString("field006")); + String valueWhere = " and ( fromDate between '"+startdate+"' and '"+enddate+"' or toDate between '"+startdate+"' and '"+enddate+"' " + + " or '"+startdate+"' between fromDate and toDate or '"+enddate+"' between fromDate and toDate) "; + + Map map = new HashMap(); + if(kqtype != 5 && kqtype != 6 && kqtype != 7){ + map.put("fromDate", valueWhere); + map.put("currentNodeType", " and currentNodeType = '3' "); + } + + Map result = kqFlowActiontBiz.handleKQFlowAction(proc_set_id, usedetails, 0, kqtype, Util.getIntValue(workflowid), false,true,map); + + if(!result.isEmpty()){ + String error = Util.null2String(result.get("message")); + kqLog.info("升级考勤流程拆分:"+error); + continue; + } + + } + + }catch (Exception e){ + e.printStackTrace(); + } + + } + + /** + * 生成处理的sql + * @param proc_set_id + * @param usedetails + * @param kqtype + * @return + */ + public Map handleSql(String proc_set_id,String usedetails,int kqtype) { + + HrmAttProcSetManager hrmAttProcSetManager= new HrmAttProcSetManager(); + Map map = new HashMap(); + Map sqlMap = new HashMap<>(); + sqlMap = hrmAttProcSetManager.getSQLByField006Map(kqtype, map, true, true, proc_set_id,usedetails); + + return sqlMap; + } + + /** + * 升级考勤流程设置 + */ + public boolean upAttSet() { + + boolean isDone = false; + try{ + + //1、考勤流程基本信息 + upAttProcSet(); + //2、新/老 考勤流程字段生成映射 + upAttProcField(); + //3、新考勤流程字段對應 + isDone = upKQAttProcField(); + //4、考勤流程動作設置 + isDone = upAttProcAction(); + }catch (Exception e){ + isDone = false; + e.printStackTrace(); + } + + return isDone; + } + + /** + * 考勤流程動作設置對應 + */ + public boolean upAttProcAction() throws Exception{ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + RecordSet rs3 = new RecordSet(); + boolean isDone = false; + + //请假加班的先做一下 + String sql4 = "select a.*,b.field001 as workflowid,b.field006 as kqtype from hrm_ATT_PROC_ACTION a left join HRM_ATT_PROC_SET b on a.FIELD001=b.id where a.FIELD001 >0 and b.FIELD006 in (0,3) "; + rs.executeQuery(sql4); + while(rs.next()){ + String att_proc_action_id = rs.getString("id"); + String field001 = rs.getString("field001"); + String field002 = rs.getString("field002"); + String field003 = rs.getString("field003"); + String field004 = rs.getString("field004"); + String field005 = rs.getString("field005"); + String field006 = rs.getString("field006"); + String field007 = rs.getString("field007"); + String field008 = rs.getString("field008"); + String kqtype = rs.getString("kqtype"); + String workflowid = rs.getString("workflowid"); + long mfid = UUID.randomUUID().getMostSignificantBits(); + + String att_proc_set_id = ""; + String attsetIdSql = "select * from hrm_to_attSet where hrmid="+field001; + rs2.executeQuery(attsetIdSql); + if(rs2.next()){ + att_proc_set_id = Util.null2String(rs2.getString("kqid")); + } + if(att_proc_set_id.length() == 0){ + continue; + } + String actionname = ""; + switch (field002){ + case "deduction": + actionname ="KqDeductionVacationAction"; + break; + case "freeze": + actionname ="KqFreezeVacationAction"; + break; + case "release": + actionname ="KqReleaseVacationAction"; + break; + case "HrmScheduleShift": + actionname ="KqSplitShiftAction"; + break; + case "HrmPaidLeaveAction": + actionname ="KqPaidLeaveAction"; + break; + default: + break; + } + + if(actionname.length() > 0){ + String updateSql = "update kq_ATT_PROC_ACTION set field003=?,field004=?,field005=?,field006=?,field007=?,field008=? where field001=? and field002= ? "; + isDone = rs1.executeUpdate(updateSql,field003,field004,field005,field006,field007,field008,att_proc_set_id,actionname); + if(!isDone){ + break; + } + rs2.executeSql("delete from workflowactionset where workflowid = "+workflowid+" and interfaceid in ('"+actionname+"')"); + + int preoperator = 0; + if(StringUtil.parseToInt(field005) == 2){ + preoperator = 1; + } + String field003Name = SystemEnv.getHtmlLabelNames(field003,7); + WorkflowActionManager workflowActionManager = new WorkflowActionManager(); + workflowActionManager.setActionid(0); + workflowActionManager.setActionname(field003Name); + workflowActionManager.setWorkflowid(StringUtil.parseToInt(workflowid)); + workflowActionManager.setNodeid(StringUtil.parseToInt(field006)); + workflowActionManager.setNodelinkid(0); + workflowActionManager.setIspreoperator(preoperator); + workflowActionManager.setActionorder(1); + workflowActionManager.setInterfaceid(actionname); + workflowActionManager.setInterfacetype(3); + workflowActionManager.setIsused(1); + if(field007.equalsIgnoreCase("1")){ + workflowActionManager.setDrawbackflag(1); + } + workflowActionManager.doSaveWsAction(); + } + if(workflowid.length() > 0){ + String nodeid = ""; + String getNodeSql = "select * from workflow_flownode where workflowid = ? and nodetype=3 "; + rs3.executeQuery(getNodeSql, workflowid); + if(rs3.next()){ + nodeid = rs3.getString("nodeid"); + String updateSql = "update kq_ATT_PROC_ACTION set field005=?,field006=?,field007=?,field008=? where field001=? and field002= ? "; + isDone = rs1.executeUpdate(updateSql,"2",nodeid,"1","1",att_proc_set_id,"KqSplitAction"); + + int preoperator = 0; + if(StringUtil.parseToInt(field005) == 2){ + preoperator = 1; + } + rs2.executeSql("delete from workflowactionset where workflowid = "+workflowid+" and interfaceid in ('KqSplitAction')"); + + String field003Name = SystemEnv.getHtmlLabelName(81543, Util.getIntValue(7)); + WorkflowActionManager workflowActionManager = new WorkflowActionManager(); + workflowActionManager.setActionid(0); + workflowActionManager.setActionname(field003Name); + workflowActionManager.setWorkflowid(StringUtil.parseToInt(workflowid)); + workflowActionManager.setNodeid(StringUtil.parseToInt(nodeid)); + workflowActionManager.setNodelinkid(0); + workflowActionManager.setIspreoperator(preoperator); + workflowActionManager.setActionorder(1); + workflowActionManager.setInterfaceid("KqSplitAction"); + workflowActionManager.setInterfacetype(3); + workflowActionManager.setIsused(1); + workflowActionManager.doSaveWsAction(); + } + } + } + //再处理下出差,公出和异常流程的 + String sql_5 = "select * from HRM_ATT_PROC_SET where FIELD006 in (1,2,4) "; + rs.executeQuery(sql_5); + while(rs.next()){ + String workflowid = rs.getString("field001"); + String attid = rs.getString("id"); + String att_proc_set_id = ""; + String attsetIdSql = "select * from hrm_to_attSet where hrmid="+attid; + rs2.executeQuery(attsetIdSql); + if(rs2.next()){ + att_proc_set_id = Util.null2String(rs2.getString("kqid")); + } + if(att_proc_set_id.length() == 0){ + continue; + } + if(workflowid.length() > 0){ + String nodeid = ""; + String getNodeSql = "select * from workflow_flownode where workflowid = ? and nodetype=3 "; + rs3.executeQuery(getNodeSql, workflowid); + if(rs3.next()){ + nodeid = rs3.getString("nodeid"); + } + String updateSql = "update kq_ATT_PROC_ACTION set field005=?,field006=?,field007=?,field008=? where field001=? and field002= ? "; + isDone = rs1.executeUpdate(updateSql,"2",nodeid,"1","1",att_proc_set_id,"KqSplitAction"); + + rs2.executeSql("delete from workflowactionset where workflowid = "+workflowid+" and interfaceid in ('KqSplitAction')"); + + String field003Name = SystemEnv.getHtmlLabelName(81543, Util.getIntValue(7)); + WorkflowActionManager workflowActionManager = new WorkflowActionManager(); + workflowActionManager.setActionid(0); + workflowActionManager.setActionname(field003Name); + workflowActionManager.setWorkflowid(StringUtil.parseToInt(workflowid)); + workflowActionManager.setNodeid(StringUtil.parseToInt(nodeid)); + workflowActionManager.setNodelinkid(0); + workflowActionManager.setIspreoperator(1); + workflowActionManager.setActionorder(1); + workflowActionManager.setInterfaceid("KqSplitAction"); + workflowActionManager.setInterfacetype(3); + workflowActionManager.setIsused(1); + workflowActionManager.doSaveWsAction(); + } + + } + + return isDone; + } + + /** + * 新考勤流程字段對應 + */ + public boolean upKQAttProcField() throws Exception{ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + boolean isDone = false; + + String sql3 = "select * from hrm_ATT_PROC_RELATION "; + rs.executeQuery(sql3); + while(rs.next()){ + String att_proc_relation_id = rs.getString("id"); + String field001 = rs.getString("field001"); + String field002 = rs.getString("field002"); + String field003 = rs.getString("field003"); + String field004 = rs.getString("field004"); + long mfid = UUID.randomUUID().getMostSignificantBits(); + String att_proc_set_id = ""; + String attsetIdSql = "select * from hrm_to_attSet where hrmid="+field001; + rs2.executeQuery(attsetIdSql); + if(rs2.next()){ + att_proc_set_id = Util.null2String(rs2.getString("kqid")); + } + String att_proc_field_id = ""; + String attfieldIdSql = "select * from hrm_to_attfield where hrmid="+field002; + rs2.executeQuery(attfieldIdSql); + if(rs2.next()){ + att_proc_field_id = Util.null2String(rs2.getString("kqid")); + } + + if(att_proc_set_id.length() == 0 || att_proc_field_id.length() == 0){ + continue; + } + + String insertSql = "insert into kq_ATT_PROC_RELATION(mfid,field001,field002,field003,field004) " + + " values(?,?,?,?,?) "; + isDone = rs1.executeUpdate(insertSql,mfid,att_proc_set_id,att_proc_field_id,field003,field004); + if(!isDone){ + break; + } + } + return isDone; + } + + /** + * 新/老 考勤流程字段生成映射 + */ + public void upAttProcField() throws Exception{ + Map fieldMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + + String sql2 = "select * from HRM_ATT_PROC_FIELDS "; + rs.executeQuery(sql2); + while(rs.next()){ + String att_proc_field_id = rs.getString("id"); + String field001 = rs.getString("field001"); + String field002 = rs.getString("field002"); + if("leaveDays".equalsIgnoreCase(field002)){ + field002 = "duration"; + } + if("tilldate".equalsIgnoreCase(field002)){ + field002 = "toDate"; + } + if("tilltime".equalsIgnoreCase(field002)){ + field002 = "toTime"; + } + if("overtimeDays".equalsIgnoreCase(field002)){ + field002 = "duration"; + } + if("otype".equalsIgnoreCase(field002)){ + field002 = "overtime_type"; + } + field001 = field001.toLowerCase(); + field002 = field002.toLowerCase(); + String key = field001+"_"+field002; + fieldMap.put(key, att_proc_field_id); + } + + sql2 = "select * from kq_ATT_PROC_FIELDS "; + rs.executeQuery(sql2); + while(rs.next()){ + String att_proc_field_kqid = rs.getString("id"); + String field001 = rs.getString("field001"); + String field002 = rs.getString("field002"); + field001 = field001.toLowerCase(); + field002 = field002.toLowerCase(); + String key = field001+"_"+field002; + if(fieldMap.get(key) != null){ + String att_proc_field_id = fieldMap.get(key); + String bindSql = "insert into hrm_to_attfield(hrmid,kqid) values("+att_proc_field_id+","+att_proc_field_kqid+") "; + boolean isBinded = rs1.executeUpdate(bindSql); + } + } + } + + /** + * 考勤流程設置基本信息 + */ + public void upAttProcSet() throws Exception{ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + RecordSet rs3 = new RecordSet(); + RecordSet rs4 = new RecordSet(); + + Map tableMap = new HashMap<>(); + + String tablenameSql = "select * from workflow_bill where id in(select field002 from hrm_att_proc_set)"; + rs4.execute(tablenameSql); + while(rs4.next()){ + String formid = rs4.getString("id"); + String tablename = rs4.getString("tablename"); + tableMap.put(formid, tablename); + } + + String sql1 = "select * from hrm_att_proc_set "; + rs.executeQuery(sql1); + while(rs.next()){ + String att_proc_set_id = rs.getString("id"); + String field001 = rs.getString("field001"); + String field002 = rs.getString("field002"); + String field003 = rs.getString("field003"); + String field004 = rs.getString("field004"); + String field005 = rs.getString("field005"); + String field006 = rs.getString("field006"); + String field007 = rs.getString("field007"); + String field008 = rs.getString("field008"); + String field009 = rs.getString("field009"); + String field010 = rs.getString("field010"); + String field011 = rs.getString("field011"); + String field012 = rs.getString("field012"); + String field013 = rs.getString("field013"); + String field014 = rs.getString("field014"); + String field015 = rs.getString("field015"); + long mfid = UUID.randomUUID().getLeastSignificantBits(); + int ishalfday = Util.getIntValue(rs.getString("ishalfday"),-1); + + String tablename = Util.null2String(tableMap.get(field002)); + + String usedetail = "0"; + String custompage = ""; + String custompage4Emoble = ""; + String templetroute = ""; + switch (field006){ + case "0" : + custompage = KqTempletEnum.LEAVE.getTempletfile(); + custompage4Emoble = KqTempletEnum.LEAVE.getTempletmobilefile(); + templetroute = KqTempletEnum.LEAVE.getTempletroute(); + break; + case "1" : + custompage = KqTempletEnum.EVECTION.getTempletfile(); + custompage4Emoble = KqTempletEnum.EVECTION.getTempletmobilefile(); + templetroute = KqTempletEnum.EVECTION.getTempletroute(); + break; + case "2" : + custompage = KqTempletEnum.OUT.getTempletfile(); + custompage4Emoble = KqTempletEnum.OUT.getTempletmobilefile(); + templetroute = KqTempletEnum.OUT.getTempletroute(); + break; + case "3" : + custompage = KqTempletEnum.OVERTIME.getTempletfile(); + custompage4Emoble = KqTempletEnum.OVERTIME.getTempletmobilefile(); + templetroute = KqTempletEnum.OVERTIME.getTempletroute(); + break; + case "4" : + custompage = KqTempletEnum.OTHER.getTempletfile(); + custompage4Emoble = KqTempletEnum.OTHER.getTempletmobilefile(); + templetroute = KqTempletEnum.OTHER.getTempletroute(); + break; + case "5" : + custompage = KqTempletEnum.SHIFT.getTempletfile(); + custompage4Emoble = KqTempletEnum.SHIFT.getTempletmobilefile(); + templetroute = KqTempletEnum.SHIFT.getTempletroute(); + break; + case "6" : + custompage = KqTempletEnum.LEAVEBACK.getTempletfile(); + custompage4Emoble = KqTempletEnum.LEAVEBACK.getTempletmobilefile(); + templetroute = KqTempletEnum.LEAVEBACK.getTempletroute(); + break; + default: + break; + } + + String insertSql = "insert into kq_ATT_PROC_SET(field001,field002,field003,field004,field005," + + "field006,field007,field008,field009,field010,field011,field012,field013,field014,field015," + + "mfid,ishalfday,usedetail,templetroute,templetmobilefile,templetfile,tablename) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + boolean isUpdated = rs1.executeUpdate(insertSql,field001,field002,field003,field004,field005, + field006,field007,field008,field009,field010,field011,field012, + field013,field014,field015,mfid,ishalfday,usedetail,templetroute, + custompage4Emoble,custompage,tablename); + + if(isUpdated){ + rs2.executeQuery("select max(id) from kq_ATT_PROC_SET "); + if(rs2.next()){ + String kq_att_set_id = rs2.getString(1); + String actionSql = ""; + String actionSql1 = ""; + String actionSql2 = ""; + String actionSql3 = ""; + switch (field006){ + case "0" : + actionSql = "insert into kq_ATT_PROC_ACTION(mfid,field001,field002,field003,field004,field005,field006,field007,field008) values(-1,"+kq_att_set_id+",'KqSplitAction','81543',0,-1,-1,1,4)"; + actionSql1 = "insert into kq_ATT_PROC_ACTION(mfid,field001,field002,field003,field004,field005,field006,field007,field008) values(-1,"+kq_att_set_id+",'KqDeductionVacationAction','82823,25842',0,-1,-1,1,1)"; + actionSql2 = "insert into kq_ATT_PROC_ACTION(mfid,field001,field002,field003,field004,field005,field006,field007,field008) values(-1,"+kq_att_set_id+",'KqFreezeVacationAction','1232,25842',0,-1,-1,1,2)"; + actionSql3 = "insert into kq_ATT_PROC_ACTION(mfid,field001,field002,field003,field004,field005,field006,field007,field008) values(-1,"+kq_att_set_id+",'KqReleaseVacationAction','82824,25842',0,-1,-1,1,3)"; + break; + case "1" : + actionSql = "insert into kq_ATT_PROC_ACTION(mfid,field001,field002,field003,field004,field005,field006,field007,field008) values(-1,"+kq_att_set_id+",'KqSplitAction','81543',0,-1,-1,1,1)"; + break; + case "2" : + actionSql = "insert into kq_ATT_PROC_ACTION(mfid,field001,field002,field003,field004,field005,field006,field007,field008) values(-1,"+kq_att_set_id+",'KqSplitAction','81543',0,-1,-1,1,1)"; + break; + case "3" : + actionSql = "insert into kq_ATT_PROC_ACTION(mfid,field001,field002,field003,field004,field005,field006,field007,field008) values(-1,"+kq_att_set_id+",'KqSplitAction','81543',0,-1,-1,1,2)"; + actionSql1 = "insert into kq_ATT_PROC_ACTION(mfid,field001,field002,field003,field004,field005,field006,field007,field008) values(-1,"+kq_att_set_id+",'KqPaidLeaveAction','126739',0,-1,-1,1,1)"; + break; + case "4" : + actionSql = "insert into kq_ATT_PROC_ACTION(mfid,field001,field002,field003,field004,field005,field006,field007,field008) values(-1,"+kq_att_set_id+",'KqSplitAction','81543',0,-1,-1,1,1)"; + break; + case "5" : + actionSql = "insert into kq_ATT_PROC_ACTION(mfid,field001,field002,field003,field004,field005,field006,field007,field008) values(-1,"+kq_att_set_id+",'KqSplitAction','390737',0,-1,-1,1,1)"; + break; + case "6" : + actionSql = "insert into kq_ATT_PROC_ACTION(mfid,field001,field002,field003,field004,field005,field006,field007,field008) values(-1,"+kq_att_set_id+",'KqSplitAction','81543',0,-1,-1,1,1)"; + break; + default: + break; + } + if(actionSql.length() > 0){ + rs3.execute(actionSql); + } + if(actionSql1.length() > 0){ + rs3.execute(actionSql1); + } + if(actionSql2.length() > 0){ + rs3.execute(actionSql2); + } + if(actionSql3.length() > 0){ + rs3.execute(actionSql3); + } + HrmAttProcSetManager attProcSetManager = new HrmAttProcSetManager(); + attProcSetManager.welcomeToSet(Util.getIntValue(field001), Util.getIntValue(field006),custompage,custompage4Emoble,templetroute); + String bindSql = "insert into hrm_to_attSet(hrmid,kqid) values("+att_proc_set_id+","+kq_att_set_id+") "; + boolean isBinded = rs4.executeUpdate(bindSql); + } + } + + } + } + + /** + * 请假类型数据迁移 + * @param year + */ + public boolean upLeave(String year) { + + boolean isLeaveDone = true; + try { + Map leaveMap = new HashMap<>(); + upLeaveRule(); + //TODO 正式系统的历史数据excel导入,这里不做处理 + if(!leaveMap.isEmpty() && false){ + isLeaveDone = upLeaveData(leaveMap,year); + } + }catch (Exception e){ + isLeaveDone = false; + e.printStackTrace(); + } + return isLeaveDone; + } + + /** + * 根据假期规则生成相应的假期数据 + * @param leaveMap + * @param year + */ + public boolean upLeaveData(Map leaveMap,String year) throws Exception{ + boolean isLeaveDataDone = true; + for(Map.Entry me : leaveMap.entrySet()){ + String leaveid = me.getKey(); + String leavecode = me.getValue(); + switch (leavecode){ + case "annualLeave": + upAnnual(); + break; + case "vacationLeave": + upOvertimePiad(); + break; + default: + upPaid(); + break; + } + } + + return isLeaveDataDone; + } + + /** + * 迁移带薪数据 + */ + public void upPaid() { + RecordSet rs = new RecordSet(); + String insertSql = "insert into kq_BalanceOfLeave(leaverulesid,resourceid,belongyear,extraAmount,status) select leavetype,resourceid,pslyear,psldays,0 from hrmpslmanagement where status = 1 and pslyear is not null or pslyear !='' "; + rs.executeUpdate(insertSql); + } + + /** + * 迁移调休数据 + */ + public void upOvertimePiad() { + RecordSet rs = new RecordSet(); + String curYear = DateUtil.getYear(DateUtil.getCalendar()); + String firstdate = DateUtil.getFirstDayOfYear(DateUtil.getCurrentDate()); + String enddate = DateUtil.getLastDayOfYear(DateUtil.getCurrentDate()); + String insertSql = "insert into kq_BalanceOfLeave(leaverulesid,resourceid,belongyear,extraAmount,status) values(?,?,?,?,?)"; + List params = new ArrayList(); + HrmPaidLeaveTimeManager paidLeaveTimeManager = new HrmPaidLeaveTimeManager(); + Map otherparams = new HashMap<>(); + otherparams.put("fromdate", firstdate); + otherparams.put("enddate", enddate); + otherparams.put("sql_field001", " and field001 >0 "); + Map paramMap = new HashMap(); + Iterator it = otherparams.entrySet().iterator(); + while(it.hasNext()){ + Map.Entry entry = (Map.Entry) it.next(); + paramMap.put((String)entry.getKey(), (String)entry.getValue()); + } + List tList = paidLeaveTimeManager.find(paramMap); + for(HrmPaidLeaveTime paidLeaveTime : tList){ + Long resourceid = paidLeaveTime.getId(); + String extraVal = String.valueOf(paidLeaveTime.getField004()); + List beanParams = new ArrayList(); + beanParams.add("-13"); + beanParams.add(resourceid); + beanParams.add(curYear); + beanParams.add(extraVal); + beanParams.add("0"); + params.add(beanParams); + } + boolean isOk = rs.executeBatchSql(insertSql, params); + } + + /** + * 迁移年假数据 + */ + public void upAnnual() { + RecordSet rs = new RecordSet(); + String insertSql = "insert into kq_BalanceOfLeave(leaverulesid,resourceid,belongyear,extraAmount,status) select -6,resourceid,annualyear,annualdays,0 from HrmAnnualManagement where status = 1 and resourceid is not null "; + rs.executeUpdate(insertSql); + } + + /** + * 升级假期规则 + * @return + * @throws Exception + */ + public void upLeaveRule() throws Exception{ + RecordSet rs = new RecordSet(); + RecordSet recordSet = new RecordSet(); + + //请假类型 数据迁移 + String leaveSql = " select * from hrmleavetypecolor order by field006 "; + rs.execute(leaveSql); + while (rs.next()) { + String leaveid = rs.getString("id"); + String leaveName = ""+Util.formatMultiLang(rs.getString("field001"),"7")+""; + String isuse = rs.getString("field002"); + String leavecode = rs.getString("field004"); + String iscalworkday = rs.getString("iscalworkday"); + //自然日调配按照周几计算时长无法迁移,这个地方定死一个值吧 hoursToDay + int relateweekday = Util.getIntValue(rs.getString("relateweekday")); + String ispaidleave = rs.getString("ispaidleave"); + String leavecodeRule = ""; + int scopeType = 0; + String scopeValue = ""; + int minimumUnit = 1; + int hoursToDay = 8; + int computingMode = 1; + int isEnable = 1; + int balanceEnable = 0; + + int distributionMode = 1; + int annualAmount = 0; + int priority = 1; + int validityRule = 0;//不限制 + String expirationMonth = ""; + String expirationDay = ""; + int extensionEnable = 0; + int extendedDays = 0; + int releaseRule = 0; + if (!"1".equalsIgnoreCase(isuse)) { + isEnable = 0; + } + if ("0".equalsIgnoreCase(iscalworkday)) { + computingMode = 2; + } + if ("1".equalsIgnoreCase(ispaidleave)) { + balanceEnable = 1; + } + if ("-6".equalsIgnoreCase(leavecode)) { + balanceEnable = 1; + leavecodeRule = "annualLeave"; + } + if ("-12".equalsIgnoreCase(leavecode)) { + leavecodeRule = "paidSickLeave"; + balanceEnable = 1; + } + if ("-13".equalsIgnoreCase(leavecode)) { + balanceEnable = 1; + leavecodeRule = "vacationLeave"; + distributionMode = 5; + minimumUnit = 3; + } + + boolean flag = false;//数据是否插入成功 + + String sql = "insert into kq_LeaveRules(Id,leaveName,scopeType,scopeValue,minimumUnit,computingMode,hoursToDay,balanceEnable,isEnable,isDelete,leavecode) values(?,?,?,?,?,?,?,?,?,?,?)"; + flag = recordSet.executeUpdate(sql, leavecode, leaveName, scopeType, scopeValue, minimumUnit, computingMode, hoursToDay, balanceEnable, isEnable, 0,leavecodeRule); + + if (!flag) { + kqLog.info("升级假期规则 upLeaveRule 失败 :hrmleavetypecolor:field004: "+leavecode); + break; + } + String bindSql = "insert into hrm_to_kq_LeaveRules(hrmid,kqid) values(?,?) "; + boolean isBind = recordSet.executeUpdate(bindSql,leaveid,leavecode); + if(isBind && balanceEnable == 1){ + //带薪假和系统假期都需要处理下请假类型明细设置 + sql = "insert into kq_LeaveRulesDetail(ruleId,ruleName,scopeType,scopeValue," + + "distributionMode,annualAmount,priority,validityRule,expirationMonth,expirationDay,extensionEnable,extendedDays,releaseRule,calcMethod,isDelete) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,0)"; + flag = recordSet.executeUpdate(sql, leavecode, leaveName+"规则", scopeType, scopeValue, + distributionMode, annualAmount, priority, validityRule, expirationMonth, expirationDay, extensionEnable, extendedDays, releaseRule, 0); + } + } + refreshCominfo(); + } + + + /** + * 如果升级错了,或者需要重新升级需要先删除数据 + * @return + */ + public boolean refreshData(){ + try{ + List delSql = new ArrayList<>(); + delSql.add("delete from kq_group "); + delSql.add("delete from kq_fixedschedulce "); + delSql.add("delete from kq_groupmember "); + delSql.add("delete from kq_ShiftManagement "); + delSql.add("delete from kq_ShiftRestTimeSections "); + delSql.add("delete from kq_ShiftOnOffWorkSections "); + + delSql.add("delete from kq_shiftschedule "); + + delSql.add("delete from kq_LeaveRules "); + delSql.add("delete from kq_balanceOfLeave "); + delSql.add("delete from KQ_HOLIDAYSET "); + delSql.add("delete from kq_OvertimeRules "); + delSql.add("delete from kq_OvertimeRulesDetail "); + + delSql.add("delete from kq_att_proc_set "); + delSql.add("delete from kq_ATT_PROC_RELATION "); + delSql.add("delete from kq_ATT_PROC_ACTION where field001 <>'-1' "); + + delSql.add("delete from kq_flow_split_leave "); + delSql.add("delete from kq_flow_split_evection "); + delSql.add("delete from kq_flow_split_out "); + delSql.add("delete from kq_flow_split_overtime "); + RecordSet rs = new RecordSet(); + for(String del : delSql){ + rs.executeUpdate(del); + } + return true; + }catch (Exception e){ + e.printStackTrace(); + return false; + } + } + + /** + * 排班人员升级 + * 升级 考勤组+班次 + * @return + */ + public void upScheduleGroupData() throws Exception{ + RecordSet rs0 = new RecordSet(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + RecordSet rs3 = new RecordSet(); + RecordSet rs4 = new RecordSet(); + RecordSet rs5 = new RecordSet(); + RecordSet rs6 = new RecordSet(); + RecordSet rs7 = new RecordSet(); + RecordSet rs8 = new RecordSet(); + RecordSet rs9 = new RecordSet(); + + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + String hrmdftsubcomid = manageDetachComInfo.getHrmdftsubcomid();//分权默认分部 + String shiftsetSql = "select * from hrm_schedule_shifts_set where delflag=0 "; + rs0.executeQuery(shiftsetSql); + while (rs0.next()) { + String shifts_set_id = rs0.getString("id"); + String groupname = "排班("+Util.formatMultiLang(rs0.getString("field001"),"7")+")"; + int subcompanyid = Util.getIntValue(rs0.getString("field002"), 0); + if(hrmdetachable){ + subcompanyid = Util.getIntValue(hrmdftsubcomid); + } + boolean is4worklen = false; + String shiftOnOffWorkCount = "1"; + String isresttimeopen = "0"; + String[] worktimeids = null; + String getworkTimeSql = "select * from hrm_schedule_shifts_detail where field001='" + shifts_set_id + + "' and delflag=0 "; + rs1.executeQuery(getworkTimeSql); + kqLog.info("upScheduleGroupData getworkTimeSql:"+getworkTimeSql); + if (rs1.next()) { + String worktimeid = rs1.getString("field002"); + worktimeids = worktimeid.split(";"); + if (worktimeids.length == 1) { + shiftOnOffWorkCount = "1"; + }else if(worktimeids.length == 2){ + shiftOnOffWorkCount = "2"; + }else if(worktimeids.length == 3){ + shiftOnOffWorkCount = "3"; + }else{ + is4worklen = true; + } + } + if(is4worklen){ + continue; + } + String worktimes = ""; + if(worktimeids != null){ + for(String workid : worktimeids){ + worktimes += ","+workid; + } + } + if(worktimes.length() > 0){ + worktimes = worktimes.substring(1); + } + + if(worktimes.length() > 0){ + List timesList = new ArrayList<>(); + String uuid = UUID.randomUUID().toString(); + int worktime = 0; + String serials = "排班"; + String serialname= ""; + String serialcontent= ""; + String punchsettings= "1"; + String isoffdutyfreecheck= "0"; + String worktimeSql = "select * from hrm_schedule_worktime where delflag=0 and id in ("+worktimes+") order by field002"; + rs.execute(worktimeSql); + while(rs.next()) { + String worktimename = Util.null2s(rs.getString("field001"),""); + String starttime = Util.null2s(rs.getString("field002"),""); + String endtime = Util.null2s(rs.getString("field003"),""); + String starttime_min = Util.null2s(rs.getString("field004"),""); + String endtime_min = Util.null2s(rs.getString("field005"),""); + String workhour = Util.null2s(rs.getString("field007"),""); + worktime += Util.getDoubleValue(workhour)*60; + if(serialname.length() > 0){ + serialname += ";"+worktimename; + serialcontent += ";"+(starttime+"-"+endtime); + }else { + serialname += worktimename; + serialcontent += (starttime+"-"+endtime); + } + Map timeMap = new HashMap<>(); + timeMap.put("starttime", starttime); + timeMap.put("endtime", endtime); + timeMap.put("starttime_min", starttime_min); + timeMap.put("endtime_min", endtime_min); + timesList.add(timeMap); + } + if(serialname.length() > 0){ + serials += "("+Util.formatMultiLang(serialname,"7")+")"; + } + + String serialSql = "insert into kq_ShiftManagement(serial,subcompanyid,shiftonoffworkcount,punchsettings,isoffdutyfreecheck,isresttimeopen,worktime,uuid,color)" + + " values('"+serials+"',"+subcompanyid+","+shiftOnOffWorkCount+","+punchsettings+","+isoffdutyfreecheck+","+isresttimeopen+","+worktime+",'"+uuid+"',null)"; + boolean isSerial = rs2.executeUpdate(serialSql); + kqLog.info("upScheduleGroupData serialSql:"+serialSql+":isSerial:"+isSerial); + if(isSerial) { + int serialid = 0; + String getSerialIdSql = "select max(id) from kq_ShiftManagement "; + rs4.execute(getSerialIdSql); + if(rs4.next()) { + serialid = Util.getIntValue(rs4.getString(1)); + if(serialid > 0){ + String bindSql = + "insert into hrm_to_kq_serial(hrmid,kqid,serial,serialfrom) values(" + shifts_set_id + + "," + serialid + ",'"+serialcontent+"','shiftset') "; + boolean isBinded = rs3.executeUpdate(bindSql); + kqLog.info("upScheduleGroupData bindSql:"+bindSql+":isBinded:"+isBinded); + + for(int i = 0 ; i < timesList.size() ; i++){ + Map tmpTimeMap = (Map) timesList.get(i); + String starttime = Util.null2s(tmpTimeMap.get("starttime"),""); + String endtime = Util.null2s(tmpTimeMap.get("endtime"),""); + String starttime_min = Util.null2s(tmpTimeMap.get("starttime_min"),"30"); + String endtime_min = Util.null2s(tmpTimeMap.get("endtime_min"),"30"); + String across = "0"; + String workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,clockinnot) " + + "values("+serialid+","+across+","+starttime_min+",'"+starttime+"','start',"+i+",0)"; + boolean isSection = rs3.executeUpdate(workSql); + kqLog.info("upScheduleGroupData workSql:"+workSql+":isSection:"+isSection); + if(starttime.compareTo(endtime) > 0){ + across = "1"; + } + workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,clockinnot) " + + "values("+serialid+","+across+","+endtime_min+",'"+endtime+"','end',"+i+",0)"; + isSection = rs3.executeUpdate(workSql); + kqLog.info("upScheduleGroupData workSql:"+workSql+":isSection:"+isSection); + } + + String groupSql = " insert into kq_group (" + + " groupname,subcompanyid,excludeid,kqtype,shiftcyclename,shiftcycleday,shiftcycleserialids,serialids," + + " weekday,signstart,workhour,signintype,validity,validityfromdate,validityenddate,locationcheckscope) " + + " values('"+groupname+"',"+subcompanyid+",null,2,null,null,null,'"+serialid+"',null,null,null,1,0,null,null,300)"; + boolean isOk = rs5.executeUpdate(groupSql); + kqLog.info("groupSql:"+groupSql); + if(isOk){ + int groupid = 0; + String getGroupIdSql = "select max(id) from kq_group "; + rs6.execute(getGroupIdSql); + if(rs6.next()){ + groupid = Util.getIntValue(rs6.getString(1)); + } + if(groupid > 0) { + bindSql ="insert into hrm_to_kq_group(hrmid,kqid,groupfrom) values(" + + shifts_set_id + "," + groupid + ",'shiftset') "; + isBinded = rs6.executeUpdate(bindSql); + if (isBinded) { + String memSql = " INSERT INTO kq_groupmember ( groupid ,typevalue ,type ,alllevel ," + + " seclevel ,seclevelto ,jobtitlelevelvalue ,jobtitlelevel,validatefrom,validateto) " + + " VALUES (? ,? ,? ,?,? ,? ,? ,?, ?, ?)"; + List params = new ArrayList(); + List resourceids = new ArrayList<>(); + String shiftDetail =" select * from hrm_schedule_set_detail where delflag=0 and field001 = '" + shifts_set_id + "'";; + rs7.executeQuery(shiftDetail); + kqLog.info("shiftDetail:"+shiftDetail); + while (rs7.next()) { + String resourceid = rs7.getString("field002"); + if (!resourceids.contains(resourceid)) { + List beanParams = new ArrayList(); + beanParams.add(groupid); + beanParams.add(resourceid); + beanParams.add(1); + beanParams.add(null); + beanParams.add(0); + beanParams.add(100); + beanParams.add(null); + beanParams.add(null); + beanParams.add(KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE); + beanParams.add(KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE); + params.add(beanParams); + resourceids.add(resourceid); + } + } + kqLog.info("params:"+params); + boolean isMemDone = rs8.executeBatchSql(memSql, params); + if (isMemDone) { + String detailsql = ""; + if(rs.getDBType().equals("oracle")){ + detailsql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid) " + + "select field003,(case when nvl(FIELD005,'-1')='-1' then '-1' when nvl(FIELD005,'')='' then '-1' else '"+serialid+"' end ),field002," + groupid + + " from hrm_schedule_set_detail where delflag=0 and field001 = '" + shifts_set_id + "'"; + + }else if(rs.getDBType().equals("mysql")){ + detailsql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid) " + + "select field003,(case when ifnull(FIELD005,'-1')='-1' then '-1' when ifnull(FIELD005,'')='' then '-1' else '"+serialid+"' end ),field002," + groupid + + " from hrm_schedule_set_detail where delflag=0 and field001 = '" + shifts_set_id + "'"; + + }else{ + detailsql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid) " + + "select field003,(case when isnull(FIELD005,'-1')='-1' then '-1' when isnull(FIELD005,'')='' then '-1' else '"+serialid+"' end ),field002," + groupid + + " from hrm_schedule_set_detail where delflag=0 and field001 = '" + shifts_set_id + "'"; + + } + + kqLog.info("detailsql:"+detailsql); + boolean isDetailDone = rs8.executeUpdate(detailsql); + } + } + } + + } + } + } + } + } + } + + refreshCominfo(); + } + + /** + * 排班人员 更新考勤组成员和具体设置排班数据 + * @param groupidMap + * @param year + */ + public boolean upScheduleGroupMem(Map groupidMap,Map groupSerialMap,String year) { + RecordSet rs_shiftdetail = new RecordSet(); + RecordSet rs_groupmem = new RecordSet(); + RecordSet rs_scheduledetail = new RecordSet(); + + String firstdate = DateUtil.getFirstDayOfYear(year + "-01-01"); + String enddate = DateUtil.getLastDayOfYear(year + "-01-01"); + boolean isDetailDone = true; + //3、考勤组成员搞一波 + for (Map.Entry groupdetail : groupidMap.entrySet()) { + List params = new ArrayList(); + List resourceids = new ArrayList<>(); + String groupid = groupdetail.getKey(); + String shifts_set_id = groupdetail.getValue(); + String shiftDetail = + " select * from hrm_schedule_set_detail where delflag=0 and field003 between '" + + firstdate + "' and '" + enddate + "'"; + if (shifts_set_id.length() == 0) { + continue; + } + String serialid = Util.null2String(groupSerialMap.get(groupid), "-1"); + shiftDetail += " and field001 = '" + shifts_set_id + "'"; + rs_shiftdetail.executeQuery(shiftDetail); + while (rs_shiftdetail.next()) { + String resourceid = rs_shiftdetail.getString("field002"); + if (!resourceids.contains(resourceid)) { + List beanParams = new ArrayList(); + beanParams.add(groupid); + beanParams.add(resourceid); + beanParams.add(1); + beanParams.add(null); + beanParams.add(0); + beanParams.add(100); + beanParams.add(null); + beanParams.add(null); + beanParams.add(KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE); + beanParams.add(KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE); + params.add(beanParams); + resourceids.add(resourceid); + } + } + String memSql = " INSERT INTO kq_groupmember ( groupid ,typevalue ,type ,alllevel ," + + " seclevel ,seclevelto ,jobtitlelevelvalue ,jobtitlelevel,validatefrom,validateto) " + + " VALUES (? ,? ,? ,?,? ,? ,? ,?,?,?)"; + if (!params.isEmpty()) { + boolean isMemDone = rs_groupmem.executeBatchSql(memSql, params); + if (isMemDone) { + String detailsql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid) " + + "select field003," + serialid + ",field002," + groupid + + " from hrm_schedule_set_detail where delflag=0 and field003 between '" + + firstdate + "' and '" + enddate + "' and field001 = '" + shifts_set_id + "'"; + isDetailDone = rs_scheduledetail.executeUpdate(detailsql); + if (!isDetailDone) { + break; + } + } + } + } + return isDetailDone; + } + + /** + * 排班人员 考勤组里设置下班次 + * @param groupSerialMap + * @return + */ + public boolean upScheduleGroupSerial(Map groupSerialMap) { + RecordSet rs_groupschedule = new RecordSet(); + boolean isUpGroupDone = true; + for (Map.Entry me : groupSerialMap.entrySet()) { + String groupid = me.getKey(); + String serialid = me.getValue(); + + String updteGroupSrial = "update kq_group set serialids = ? where id= ? "; + isUpGroupDone = rs_groupschedule.executeUpdate(updteGroupSrial, serialid, groupid); + if (!isUpGroupDone) { + break; + } + } + return isUpGroupDone; + } + + /** + * 升级排班人员 班次数据 + * @param groupidMap + * @param groupidShiftMap + * @param groupSerialMap + * @param worktimeSerialMap + * @param year + * @param upSignSql + */ + public void upScheduleSerial(Map groupidMap,Map groupidShiftMap, + Map groupSerialMap, Map worktimeSerialMap, + String year,List upSignSql) { + + String worktimeSep = ";"; + RecordSet rs = new RecordSet(); + RecordSet rs_shift = new RecordSet(); + RecordSet rs_shift1 = new RecordSet(); + RecordSet rs_shift2 = new RecordSet(); + RecordSet rs_shift3 = new RecordSet(); + + String mainSql = + "insert into kq_ShiftManagement(serial,subcompanyid,shiftonoffworkcount,punchsettings,isoffdutyfreecheck,isresttimeopen,worktime,uuid,color)" + + " values(?,?,?,?,?,?,?,?,?)"; + + String shiftOnOffWorkCount = "1"; + + //针对考勤组 然后对应班次 + for (Map.Entry me : groupidShiftMap.entrySet()) { + String groupid = me.getKey(); + String worktimeid = me.getValue(); + String shifts_set_id = groupidMap.get(groupid); + String[] worktimeids = worktimeid.split(worktimeSep); + String shiftworktimeSql = "select * from hrm_schedule_worktime where delflag=0 "; + if (worktimeids.length == 3) { + String worktimeid1 = worktimeids[0]; + String worktimeid2 = worktimeids[1]; + String worktimeid3 = worktimeids[2]; + shiftworktimeSql += + " and id in (" + worktimeid1 + "," + worktimeid2 + "," + worktimeid3 + ") "; + shiftOnOffWorkCount = "3"; + } else if (worktimeids.length == 2) { + String worktimeid1 = worktimeids[0]; + String worktimeid2 = worktimeids[1]; + shiftworktimeSql += " and id in (" + worktimeid1 + "," + worktimeid2 + ") "; + shiftOnOffWorkCount = "2"; + } else if (worktimeids.length == 1) { + String worktimeid1 = worktimeids[0]; + shiftworktimeSql += " and id in (" + worktimeid1 + ") "; + shiftOnOffWorkCount = "1"; + } else { + //当前E9就支持最多三个班次 + rs.writeLog("班次创建失败,当前E9就支持最多三个班次"); + } + shiftworktimeSql += " order by field002 "; + + List> workserctionList = new ArrayList<>(); + + String serailname = ""; + int workminTotal = 0; + + rs.executeQuery(shiftworktimeSql); + while (rs.next()) { + Map workserctionMap = new HashMap<>(); + String serial = rs.getString("field001"); + serailname += "," + serial; + String starttime = rs.getString("field002"); + String endtime = rs.getString("field003"); + String starttime_min = rs.getString("field004"); + String endtime_min = rs.getString("field005"); + String workhour = rs.getString("field007"); + workminTotal += (Util.getDoubleValue(workhour, 0.0) * 60.0); + String startacross = "0"; + String endacross = "0"; + if (starttime.compareTo(endtime) > 0) { + endacross = "1"; + } + + workserctionMap.put("starttime", starttime); + workserctionMap.put("endtime", endtime); + workserctionMap.put("starttime_min", starttime_min); + workserctionMap.put("endtime_min", endtime_min); + workserctionMap.put("startacross", startacross); + workserctionMap.put("endacross", endacross); + + workserctionList.add(workserctionMap); + } + + //获取更新签到签退的sql + upScheduleSignSql(workserctionList,year,upSignSql,shifts_set_id); + + if (serailname.length() > 0) { + serailname = serailname.substring(1); + } + String subcompanyid = null; + String punchSettings = null; + String isOffDutyFreeCheck = null; + String isRestTimeOpen = null; + String uuid = UUID.randomUUID().toString(); + String color = null; + String worktime = workminTotal + ""; + + boolean isUpdated = rs_shift + .executeUpdate(mainSql, serailname, subcompanyid, shiftOnOffWorkCount, punchSettings, + isOffDutyFreeCheck, isRestTimeOpen, worktime, uuid, color); + if (isUpdated) { + int serialid = 0; + String idSql = "select id from kq_ShiftManagement where uuid=? "; + rs_shift1.executeQuery(idSql, uuid); + if (rs_shift1.next()) { + serialid = rs_shift1.getInt("id"); + } + if (serialid > 0) { + String workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,clockinnot) values(?,?,?,?,?,?,?)"; + int record = 0; + for (Map workMap : workserctionList) { + String starttime = workMap.get("starttime"); + String endtime = workMap.get("endtime"); + String starttime_min = workMap.get("starttime_min"); + String endtime_min = workMap.get("endtime_min"); + String startacross = workMap.get("startacross"); + String endacross = workMap.get("endacross"); + + boolean issectionOK = rs_shift3 + .executeUpdate(workSql, serialid, startacross, starttime_min, starttime, + "start", record + "",0); + if (issectionOK) { + issectionOK = rs_shift3 + .executeUpdate(workSql, serialid, endacross, endtime_min, endtime, "end", + record + "",0); + } + record++; + } + groupSerialMap.put(groupid, serialid + ""); + worktimeSerialMap.put(worktimeid, serialid + ""); + } + } + + } + + } + + /** + * 更新排班人员的签到签退数据 + * @param workserctionList + * @param year + * @param upSignSql + * @param shifts_set_id + */ + public void upScheduleSignSql(List> workserctionList, String year, + List upSignSql, String shifts_set_id) { + String firstdate = DateUtil.getFirstDayOfYear(year + "-01-01"); + String enddate = DateUtil.getLastDayOfYear(year + "-01-01"); + int cnt = workserctionList.size(); + for(int i = 0 ; i < cnt ;i++){ + Map workserctionMap = workserctionList.get(i); + String starttime = workserctionMap.get("starttime"); + String endtime = workserctionMap.get("endtime"); + int starttime_min = Util.getIntValue(workserctionMap.get("starttime_min"),0); + int endtime_min = Util.getIntValue(workserctionMap.get("endtime_min"),0); + String startacross = workserctionMap.get("startacross"); + String endacross = workserctionMap.get("endacross"); + if("1".equalsIgnoreCase(endacross)){ + new BaseBean().writeLog("排班数据存在跨天,不处理跨天的签到签退数据!"); + } + if(endtime.length() == 0){ + return ; + } + String worksection = starttime + "-" + endtime; + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + LocalTime canStartTime = LocalTime.parse(starttime+":00",dateTimeFormatter).minusMinutes(starttime_min); + LocalTime canEndTime = LocalTime.parse(endtime+":00",dateTimeFormatter).plusMinutes(endtime_min); + String canSignInTime = canStartTime.format(dateTimeFormatter); + String canSignOutTime = canEndTime.format(dateTimeFormatter); + String signWhere = " and userid in (select field002 from hrm_schedule_set_detail where delflag=0 and field001 in(select id from hrm_schedule_shifts_set where delflag=0 and id='"+shifts_set_id+"') and field003 between '"+firstdate+"' and '"+enddate+"') and signdate between '"+firstdate+"' and '"+enddate+"'"; + + String signSql1 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection+"' , belongtime='"+starttime+"' where signtype=1 and signtime >= '"+canSignInTime+"' and signtime <= '"+canSignOutTime+"' "+signWhere; + upSignSql.add(signSql1); + String signSql2 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection+"' , belongtime='"+endtime+"' where signtype=2 and signtime >= '"+canSignInTime+"' and signtime <= '"+canSignOutTime+"' "+signWhere; + upSignSql.add(signSql2); + } + + } + + /** + * 一般工作时间 + * 升级三类数据 考勤组 + 班次 + * @return + */ + public void upCommonGroupData() throws Exception{ + + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + RecordSet rs4 = new RecordSet(); + RecordSet rs5 = new RecordSet(); + + SubCompanyComInfo sci = new SubCompanyComInfo(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + String hrmdftsubcomid = manageDetachComInfo.getHrmdftsubcomid();//分权默认分部 + + String scheduleSql = "select * from hrmschedule where scheduletype >= 3 ORDER BY scheduletype "; + rs.execute(scheduleSql); + while(rs.next()) { + String id = rs.getString("id"); + String scheduletype = rs.getString("scheduletype"); + String relatedid = Util.null2String(rs.getString("relatedid"), "0"); + String validedatefrom = rs.getString("validedatefrom"); + String validedateto = rs.getString("validedateto"); + String needsign = rs.getString("needsign"); + String onlyworkday = rs.getString("onlyworkday"); + String signtimescope = rs.getString("signtimescope"); + String signipscope = rs.getString("signipscope"); + String sign_type = rs.getString("sign_type"); + String sign_start_time = rs.getString("sign_start_time"); + String subcompanyid = "0"; + if(hrmdetachable){ + subcompanyid = hrmdftsubcomid; + } + +// 0周一 1周二 2周三 3周四 4周五 5周六 6周日 + String monstarttime1 = rs.getString("monstarttime1"); + String monendtime1 = rs.getString("monendtime1"); + String monstarttime2 = rs.getString("monstarttime2"); + String monendtime2 = rs.getString("monendtime2"); + + if(monstarttime1.length() > 0 && monendtime1.length() > 0 && + monstarttime2.length() > 0 && monendtime2.length() > 0){ + setSerial(monstarttime1, monendtime1, monstarttime2, monendtime2, subcompanyid, sign_type, id, "0",sign_start_time); + } + + String tuestarttime1 = rs.getString("tuestarttime1"); + String tueendtime1 = rs.getString("tueendtime1"); + String tuestarttime2 = rs.getString("tuestarttime2"); + String tueendtime2 = rs.getString("tueendtime2"); + + if(tuestarttime1.length() > 0 && tueendtime1.length() > 0 && + tuestarttime2.length() > 0 && tueendtime2.length() > 0){ + setSerial(tuestarttime1, tueendtime1, tuestarttime2, tueendtime2, subcompanyid, sign_type, id, "1",sign_start_time); + } + + String wedstarttime1 = rs.getString("wedstarttime1"); + String wedendtime1 = rs.getString("wedendtime1"); + String wedstarttime2 = rs.getString("wedstarttime2"); + String wedendtime2 = rs.getString("wedendtime2"); + + if(wedstarttime1.length() > 0 && wedendtime1.length() > 0 && + wedstarttime2.length() > 0 && wedendtime2.length() > 0){ + setSerial(wedstarttime1, wedendtime1, wedstarttime2, wedendtime2, subcompanyid, sign_type, id, "2",sign_start_time); + } + + String thustarttime1 = rs.getString("thustarttime1"); + String thuendtime1 = rs.getString("thuendtime1"); + String thustarttime2 = rs.getString("thustarttime2"); + String thuendtime2 = rs.getString("thuendtime2"); + + if(thustarttime1.length() > 0 && thuendtime1.length() > 0 && + thustarttime2.length() > 0 && thuendtime2.length() > 0){ + setSerial(thustarttime1, thuendtime1, thustarttime2, thuendtime2, subcompanyid, sign_type, id, "3",sign_start_time); + } + + String fristarttime1 = rs.getString("fristarttime1"); + String friendtime1 = rs.getString("friendtime1"); + String fristarttime2 = rs.getString("fristarttime2"); + String friendtime2 = rs.getString("friendtime2"); + + if(fristarttime1.length() > 0 && friendtime1.length() > 0 && + fristarttime2.length() > 0 && friendtime2.length() > 0){ + setSerial(fristarttime1, friendtime1, fristarttime2, friendtime2, subcompanyid, sign_type, id, "4",sign_start_time); + } + + String satstarttime1 = rs.getString("satstarttime1"); + String satendtime1 = rs.getString("satendtime1"); + String satstarttime2 = rs.getString("satstarttime2"); + String satendtime2 = rs.getString("satendtime2"); + + if(satstarttime1.length() > 0 && satendtime1.length() > 0 && + satstarttime2.length() > 0 && satendtime2.length() > 0){ + setSerial(satstarttime1, satendtime1, satstarttime2, satendtime2, subcompanyid, sign_type, id, "5",sign_start_time); + } + + String sunstarttime1 = rs.getString("sunstarttime1"); + String sunendtime1 = rs.getString("sunendtime1"); + String sunstarttime2 = rs.getString("sunstarttime2"); + String sunendtime2 = rs.getString("sunendtime2"); + + if(sunstarttime1.length() > 0 && sunendtime1.length() > 0 && + sunstarttime2.length() > 0 && sunendtime2.length() > 0){ + setSerial(sunstarttime1, sunendtime1, sunstarttime2, sunendtime2, subcompanyid, sign_type, id, "6",sign_start_time); + } + + String groupname = ""; + if ("3".equalsIgnoreCase(scheduletype)) { + groupname += "一般工作时间:总部" + "(" + validedatefrom + "到" + validedateto + ")"; + } else { + groupname += "一般工作时间:分部" + "(" + Util.formatMultiLang(sci.getSubcompanyname(relatedid),"7") + ")" + "(" + + validedatefrom + "到" + validedateto + ")"; + } + + String groupSql = " insert into kq_group (" + + " groupname,subcompanyid,excludeid,kqtype,shiftcyclename,shiftcycleday,shiftcycleserialids,serialids," + + " weekday,signstart,workhour,signintype,validity,validityfromdate,validityenddate,locationcheckscope) " + + " values('"+groupname+"',"+subcompanyid+",null,1,null,null,null,null,null,null,null,1,1,'"+validedatefrom+"','"+validedateto+"',300)"; + + boolean isOk = rs1.executeUpdate(groupSql); + if(isOk){ + int groupid = 0; + String getGroupIdSql = "select max(id) from kq_group "; + rs1.execute(getGroupIdSql); + if(rs1.next()){ + groupid = Util.getIntValue(rs1.getString(1)); + } + if(groupid > 0){ + String bindSql = "insert into hrm_to_kq_group(hrmid,kqid,groupfrom) values("+id+","+groupid+",'scheduleset') "; + boolean isBinded = rs2.executeUpdate(bindSql); + if(isBinded){ + String kq_signintype = "1".equalsIgnoreCase(needsign)?"1":"4"; + String updateGroupInfo = " update kq_group set signintype="+kq_signintype+", ipscope='"+signipscope+"',locationcheck=null,locationcheckscope=300,wificheck=null,outsidesign=null where id= "+groupid; + boolean isUpdated = rs2.executeUpdate(updateGroupInfo); + if(isUpdated){ + String weekSql = "select * from hrm_to_kq_group_weekday where hrmid = "+id+" order by weekday "; + rs4.executeQuery(weekSql); + while (rs4.next()){ + String weekday = Util.null2s(rs4.getString("weekday"),""); + String serialid = Util.null2s(rs4.getString("serialid"),""); + String connectSql = "insert into kq_fixedschedulce(weekday,serialid,groupid) values("+weekday+","+serialid+","+groupid+")"; + rs5.executeUpdate(connectSql); + } + + String type = ""; + if("3".equalsIgnoreCase(scheduletype)){ + //所有人 + type = "6"; + }else if("4".equalsIgnoreCase(scheduletype)){ + //分部 + type = "2"; + } + String memSql = " INSERT INTO kq_groupmember ( groupid ,typevalue ,type ,alllevel ," + + " seclevel ,seclevelto ,jobtitlelevelvalue ,jobtitlelevel,validatefrom,validateto) " + + " VALUES ("+groupid+" ,"+relatedid+" ,"+type+" ,null,0 ,100 ,null ,null,'"+KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE+"','"+KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE+"')"; + rs4.executeUpdate(memSql); + } + } + + + } + + } + } + + refreshCominfo(); + } + + /** + * 升级班次数据 + * @param starttime1 + * @param endtime1 + * @param starttime2 + * @param endtime2 + * @param subcompanyid + * @param sign_type + * @param id + * @param weekday + * @param sign_start_time 打二次打卡时间 + * @throws Exception + */ + public void setSerial(String starttime1,String endtime1,String starttime2,String endtime2,String subcompanyid,String sign_type,String id,String weekday,String sign_start_time) throws Exception{ + try{ + DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + LocalTime localTime_0 = LocalTime.parse("00:00", timeFormatter); + LocalTime localTime_24 = LocalTime.parse("23:59", timeFormatter); + LocalTime localTime_sign_start = null; + if(sign_start_time.length() > 0){ + localTime_sign_start = LocalTime.parse(sign_start_time, timeFormatter); + } + boolean isBinded = false; + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + RecordSet rs3 = new RecordSet(); + RecordSet rs4 = new RecordSet(); + RecordSet rs5 = new RecordSet(); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HH:mm"); + + Duration duration1 = Duration.between( + LocalTime.parse(starttime1, dtf), LocalTime.parse(endtime1, dtf)); + Duration duration2 = Duration.between(LocalTime.parse(starttime2, dtf), LocalTime.parse(endtime2, dtf)); + String worktime = ""+(duration1.toMinutes()+duration2.toMinutes()); + + String shiftOnOffWorkCount = "1"; + String isresttimeopen = "1"; + if("2".equalsIgnoreCase(sign_type)){ + shiftOnOffWorkCount = "2"; + isresttimeopen = "0"; + } + String uuid = UUID.randomUUID().toString(); + String serial = starttime1+"-"+endtime1+" "+starttime2+"-"+endtime2; + String serialContent = serial+"_"+shiftOnOffWorkCount; + + String checkSerial = "select * from hrm_to_kq_serial where serial='"+serialContent+"' and serialfrom ='scheduleset' "; + rs4.executeQuery(checkSerial); + if(rs4.next()){ + String serialid = rs4.getString("kqid"); + if(Util.getIntValue(serialid) > 0){ + String bindSql = + "insert into hrm_to_kq_group_weekday(hrmid,weekday,serialid) values(" + id + + ",'"+weekday+"',"+serialid+") "; + isBinded = rs2.executeUpdate(bindSql); + } + }else{ + String serialname = "一般工作时间("+Util.formatMultiLang(serial,"7")+")"; + String serialSql = "insert into kq_ShiftManagement(serial,subcompanyid,shiftonoffworkcount,punchsettings,isoffdutyfreecheck,isresttimeopen,worktime,uuid,color)" + + " values('"+serialname+"',"+subcompanyid+","+shiftOnOffWorkCount+",0,0,"+isresttimeopen+","+worktime+",'"+uuid+"',null)"; + boolean isSerial = rs3.executeUpdate(serialSql); + if(isSerial){ + int serialid = 0; + String getSerialIdSql = "select max(id) from kq_ShiftManagement "; + rs1.execute(getSerialIdSql); + if(rs1.next()){ + serialid = Util.getIntValue(rs1.getString(1)); + if(serialid > 0) { + int mins = 30; + String bindSql = + "insert into hrm_to_kq_serial(hrmid,kqid,serial,serialfrom) values(" + id + + "," + serialid + ",'"+serialContent+"','scheduleset') "; + isBinded = rs2.executeUpdate(bindSql); + if(isBinded){ + bindSql = + "insert into hrm_to_kq_group_weekday(hrmid,weekday,serialid) values(" + id + + ",'"+weekday+"',"+serialid+") "; + isBinded = rs2.executeUpdate(bindSql); + if(isBinded){ + if(!"2".equalsIgnoreCase(sign_type)){ + LocalTime localTime = LocalTime.parse(starttime1, timeFormatter); + long start_mins = Duration.between(localTime_0, localTime).toMinutes(); + String workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,clockinnot) " + + "values("+serialid+",0,"+start_mins+",'"+starttime1+"','start',0,0)"; + boolean isSection = rs5.executeUpdate(workSql); + if(isSection){ + LocalTime localTime2 = LocalTime.parse(endtime2, timeFormatter); + long end_mins = Duration.between(localTime2, localTime_24).toMinutes(); + workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,clockinnot) " + + "values("+serialid+",0,"+end_mins+",'"+endtime2+"','end',0,0)"; + rs5.executeUpdate(workSql); + } + }else{ + LocalTime localTime = LocalTime.parse(starttime1, timeFormatter); + long start_mins1 = Duration.between(localTime_0, localTime).toMinutes(); + String workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,clockinnot) " + + "values("+serialid+",0,"+start_mins1+",'"+starttime1+"','start',0,0)"; + boolean isSection = rs5.executeUpdate(workSql); + if(isSection){ + LocalTime localTime2 = LocalTime.parse(endtime1, timeFormatter); + long end_mins1 = Duration.between(localTime2, localTime_sign_start).toMinutes(); + workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,clockinnot) " + + "values("+serialid+",0,"+end_mins1+",'"+endtime1+"','end',0,0)"; + isSection = rs5.executeUpdate(workSql); + if(isSection){ + LocalTime localTime3 = LocalTime.parse(starttime2, timeFormatter); + long start_mins2 = Duration.between(localTime_sign_start, localTime3).toMinutes(); + workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,clockinnot) " + + "values("+serialid+",0,"+start_mins2+",'"+starttime2+"','start',1,0)"; + isSection = rs5.executeUpdate(workSql); + if(isSection){ + LocalTime localTime4 = LocalTime.parse(endtime2, timeFormatter); + long end_mins2 = Duration.between(localTime4, localTime_24).toMinutes(); + workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,clockinnot) " + + "values("+serialid+",0,"+end_mins2+",'"+endtime2+"','end',1,0)"; + isSection = rs5.executeUpdate(workSql); + } + } + } + + } + if(!"2".equalsIgnoreCase(sign_type)){ + String restSql = "insert into kq_ShiftRestTimeSections(serialid,resttype,time,across) values("+serialid+",'start','"+endtime1+"',0)"; + rs5.executeUpdate(restSql); + restSql = "insert into kq_ShiftRestTimeSections(serialid,resttype,time,across) values("+serialid+",'end','"+starttime2+"',0)"; + rs5.executeUpdate(restSql); + } + } + } + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + } + } + + /** + * 工作日期调整迁移 + * @return + */ + public void upPub() { + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + RecordSet rs3 = new RecordSet(); + RecordSet rs4 = new RecordSet(); + + String pubSql = "select * from hrmpubholiday"; + String groupSql = " select * from hrm_to_kq_group where groupfrom = 'scheduleset' and hrmid in( select id from hrmschedule) "; + rs.executeQuery(groupSql); + while (rs.next()){ + String groupid = Util.null2s(rs.getString("kqid"),""); + if(groupid.length() >0){ + rs1.executeQuery(pubSql); + while (rs1.next()){ + String id = Util.null2s(rs1.getString("id"),""); + String holidaydate = Util.null2s(rs1.getString("holidaydate"),""); + String holidayname = Util.null2s(rs1.getString("holidayname"),""); + String changetype = Util.null2s(rs1.getString("changetype"),""); + int relateweekday = Util.getIntValue(Util.null2s(rs1.getString("relateweekday"),"0"),0); + String insertSql = "insert into KQ_HOLIDAYSET(holidaydate,holidaydesc,changetype,relatedday,groupid) " + + " values('"+holidaydate+"','"+Util.formatMultiLang(holidayname,"7")+"','"+changetype+"','"+relateweekday+"','"+groupid+"')"; + boolean isOk = rs2.executeUpdate(insertSql); + if(isOk){ + int pubid = 0; + String getPubIdSql = "select max(id) from KQ_HOLIDAYSET "; + rs3.execute(getPubIdSql); + if(rs3.next()){ + pubid = Util.getIntValue(rs3.getString(1)); + } + if(pubid > 0){ + String bindSql = "insert into hrm_to_kq_pub(hrmid,kqid) values("+id+","+pubid+")"; + rs4.executeUpdate(bindSql); + } + } + } + } + } + + refreshCominfo(); + } + + /** + * 一般工作时间 更新签到签退数据 + * @param upSignSql + */ + public void updateSign(List upSignSql) throws Exception{ + RecordSet rs1 = new RecordSet(); + for(int i = 0 ; i < upSignSql.size() ; i++){ + String signSql = upSignSql.get(i); + rs1.executeUpdate(signSql); + } + + } + + /** + * 按照E9新考勤规则 更新签到签退数据 + * @param relatedid + * @param signFromDate + * @param signtoDate + * @param sign_start_time + * @param scheduletype + * @param sign_type + * @param worktime1s + * @param upSignSql + */ + public void upSignSql(String relatedid, String signFromDate,String signtoDate,String sign_start_time, String scheduletype, String sign_type, String[] worktime1s, List upSignSql) { + if("2".equalsIgnoreCase(sign_type)){ + if(worktime1s.length == 5){ + String worksection1 = worktime1s[0]+"-"+worktime1s[1]; + String worksection2 = worktime1s[2]+"-"+worktime1s[3]; + if("3".equalsIgnoreCase(scheduletype)){ + String signSql1 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection1+"' , belongtime='"+worktime1s[0]+"' where signtype=1 and signtime <= '"+sign_start_time+"' and signdate between '"+signFromDate+"' and '"+signtoDate+"'"; + upSignSql.add(signSql1); + String signSql2 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection1+"' , belongtime='"+worktime1s[1]+"' where signtype=2 and signtime <= '"+sign_start_time+"' and signdate between '"+signFromDate+"' and '"+signtoDate+"'"; + upSignSql.add(signSql2); + + String signSql3 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection2+"' , belongtime='"+worktime1s[2]+"' where signtype=1 and signtime >= '"+sign_start_time+"' and signdate between '"+signFromDate+"' and '"+signtoDate+"'"; + upSignSql.add(signSql3); + String signSql4 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection2+"' , belongtime='"+worktime1s[3]+"' where signtype=2 and signtime >= '"+sign_start_time+"' and signdate between '"+signFromDate+"' and '"+signtoDate+"'"; + upSignSql.add(signSql4); + }else if("4".equalsIgnoreCase(scheduletype)){ + String signSql1 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection1+"' , belongtime='"+worktime1s[0]+"' where signtype=1 and signtime <= '"+sign_start_time+"' and userid in (select id from hrmresource where subcompanyid1 in ("+relatedid+")) and signdate between '"+signFromDate+"' and '"+signtoDate+"'"; + upSignSql.add(signSql1); + String signSql2 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection1+"' , belongtime='"+worktime1s[1]+"' where signtype=2 and signtime <= '"+sign_start_time+"' and userid in (select id from hrmresource where subcompanyid1 in ("+relatedid+")) and signdate between '"+signFromDate+"' and '"+signtoDate+"'"; + upSignSql.add(signSql2); + + String signSql3 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection2+"' , belongtime='"+worktime1s[2]+"' where signtype=1 and signtime >= '"+sign_start_time+"' and userid in (select id from hrmresource where subcompanyid1 in ("+relatedid+")) and signdate between '"+signFromDate+"' and '"+signtoDate+"'"; + upSignSql.add(signSql3); + String signSql4 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection2+"' , belongtime='"+worktime1s[3]+"' where signtype=2 and signtime >= '"+sign_start_time+"' and userid in (select id from hrmresource where subcompanyid1 in ("+relatedid+")) and signdate between '"+signFromDate+"' and '"+signtoDate+"'"; + upSignSql.add(signSql4); + } + } + }else{ + if(worktime1s.length == 5) { + String worksection = worktime1s[0] + "-" + worktime1s[3]; + if("3".equalsIgnoreCase(scheduletype)){ + String signSql1 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection+"' , belongtime='"+worktime1s[0]+"' where signtype=1 and signdate between '"+signFromDate+"' and '"+signtoDate+"'"; + upSignSql.add(signSql1); + String signSql2 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection+"' , belongtime='"+worktime1s[3]+"' where signtype=2 and signdate between '"+signFromDate+"' and '"+signtoDate+"'"; + upSignSql.add(signSql2); + }else if("4".equalsIgnoreCase(scheduletype)){ + String signSql1 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection+"' , belongtime='"+worktime1s[0]+"' where signtype=1 and userid in (select id from hrmresource where subcompanyid1 in ("+relatedid+")) and signdate between '"+signFromDate+"' and '"+signtoDate+"'"; + upSignSql.add(signSql1); + String signSql2 = "update hrmschedulesign set belongdate=signdate,worksection='"+worksection+"' , belongtime='"+worktime1s[3]+"' where signtype=2 and userid in (select id from hrmresource where subcompanyid1 in ("+relatedid+")) and signdate between '"+signFromDate+"' and '"+signtoDate+"'"; + upSignSql.add(signSql2); + } + } + } + } + + + /** + * 升级关联考勤组成员 + * @param memMap + * @throws Exception + */ + public void upGroupMem(Map memMap) throws Exception{ + RecordSet rs_groupmem = new RecordSet(); + + for(Map.Entry me : memMap.entrySet()){ + String groupid = me.getKey(); + String mems = me.getValue(); + String[] memsArr = mems.split(separator); + if(memsArr.length == 2){ + String scheduletype = memsArr[0]; + String type = ""; + if("3".equalsIgnoreCase(scheduletype)){ + //所有人 + type = "6"; + }else if("4".equalsIgnoreCase(scheduletype)){ + //分部 + type = "2"; + } + String relatedid = memsArr[1]; + String memSql = " INSERT INTO kq_groupmember ( groupid ,typevalue ,type ,alllevel ," + + " seclevel ,seclevelto ,jobtitlelevelvalue ,jobtitlelevel,validatefrom,validateto) " + + " VALUES (? ,? ,? ,?,? ,? ,? ,?, ?,?)"; + rs_groupmem.executeUpdate(memSql,groupid,relatedid,type,null,0,100,null,null,KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE, KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE); + } + } + } + + /** + * 班次生成完成,绑定考勤组和班次 + * @param weekMap + * @param serialMap + */ + public void upGroupSerial(Map weekMap, Map serialMap) throws Exception{ + RecordSet rs_groupfixed = new RecordSet(); + for(Map.Entry me : weekMap.entrySet()){ + String groupid = me.getKey(); + List fixedList = (List) me.getValue(); + if(fixedList != null && !fixedList.isEmpty()){ + for(int i = 0 ; i < fixedList.size() ; i++){ + String worktimeKey = fixedList.get(i); + String weekday = ""+i;//星期几 + String serialid = ""; + if(serialMap.get(worktimeKey) != null){ + serialid = serialMap.get(worktimeKey); + } + String connectSql = "insert into kq_fixedschedulce(weekday,serialid,groupid) values(?,?,?)"; + rs_groupfixed.executeUpdate(connectSql,weekday,serialid.length()==0?null:serialid,groupid); + } + } + } + } + + /** + * 生成班次数据 + * @param serialMap + * @param worktimeLists + */ + public void upSerial(Map serialMap, List worktimeLists) throws Exception{ + RecordSet rs_shift = new RecordSet(); + RecordSet rs_shift1 = new RecordSet(); + RecordSet rs_shift2 = new RecordSet(); + RecordSet rs_shift3 = new RecordSet(); + + for(int i = 0 ; i < worktimeLists.size() ; i++){ + String mainSql = "insert into kq_ShiftManagement(serial,subcompanyid,shiftonoffworkcount,punchsettings,isoffdutyfreecheck,isresttimeopen,worktime,uuid,color)" + + " values(?,?,?,?,?,?,?,?,?)"; + String times = worktimeLists.get(i); + String[] timeArr = times.split(separator); + if(timeArr.length == 5){ + List list_work = new ArrayList<>(); + List list_rest = new ArrayList<>(); + String serial = "历史考勤数据:"; + String worktime = ""; + String subcompanyid = null; + String shiftOnOffWorkCount = "1"; + String punchSettings = null; + String isOffDutyFreeCheck = null; + String isRestTimeOpen = "1"; + String uuid = UUID.randomUUID().toString(); + String color = null; + + String work1 = timeArr[0]; + String work2 = timeArr[1]; + String work3 = timeArr[2]; + String work4 = timeArr[3]; + String sign_type = timeArr[4]; + if(work1.length() == 0 || work2.length() == 0 && work3.length() == 0 && work4.length() == 0){ + continue; + } + + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HH:mm"); + + if("2".equalsIgnoreCase(sign_type)){ + list_work.add(work1+separator+work2); + list_work.add(work3+separator+work4); + isRestTimeOpen = "0"; + serial += work1+"-"+work2+" "+work3+"-"+work4; + //二次考勤 + shiftOnOffWorkCount = "2"; + }else{ + list_work.add(work1+separator+work4); + list_rest.add(work2+separator+work3); + serial += work1+"-"+work4; + } + if(work1.length() > 0 && work2.length() > 0 && + work3.length() > 0 && work4.length() > 0){ + Duration duration1 = Duration.between(LocalTime.parse(work1, dtf), LocalTime.parse(work2, dtf)); + Duration duration2 = Duration.between(LocalTime.parse(work3, dtf), LocalTime.parse(work4, dtf)); + worktime = ""+(duration1.toMinutes()+duration2.toMinutes()); + } + + boolean isUpdated = rs_shift.executeUpdate(mainSql, serial,subcompanyid,shiftOnOffWorkCount,punchSettings,isOffDutyFreeCheck,isRestTimeOpen,worktime,uuid,color); + if(isUpdated){ + int serialid = 0; + String idSql = "select id from kq_ShiftManagement where uuid=? "; + rs_shift1.executeQuery(idSql,uuid); + if(rs_shift1.next()) { + serialid = rs_shift1.getInt("id"); + } + if(serialid > 0){ + if("1".equalsIgnoreCase(isRestTimeOpen)){ + String restSql = "insert into kq_ShiftRestTimeSections(serialid,resttype,time) values(?,?,?)"; + for(String rest : list_rest){ + String[] rests = rest.split(separator); + if(rests.length == 2){ + rs_shift2.executeUpdate(restSql, serialid,"start",rests[0]); + rs_shift2.executeUpdate(restSql, serialid,"end",rests[1]); + } + } + } + String workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,clockinnot) values(?,?,?,?,?,?,?)"; + int record = 0; + for(String work : list_work){ + String[] works = work.split(separator); + if(works.length == 2){ + rs_shift3.executeUpdate(workSql, serialid,"0","",works[0],"start",record+"",0); + rs_shift3.executeUpdate(workSql, serialid,"0","",works[1],"end",record+"",0); + } + record++; + } + } + serialMap.put(times, serialid+""); + } + } + } + } + + /** + * 可以重复升级数据 那就是需要升级之前先清空数据 + * 清空一般工作时间里的升级数据 + */ + public void clearCommonGroupData() { + RecordSet rs = new RecordSet(); + String sql_1 = " delete from kq_shiftmanagement where id in(select kqid from hrm_to_kq_serial where serialfrom ='scheduleset')"; + rs.executeUpdate(sql_1); + String sql_2 = "delete from kq_ShiftOnOffWorkSections where serialid in(select kqid from hrm_to_kq_serial where serialfrom ='scheduleset')"; + rs.executeUpdate(sql_2); + String sql_3 = "delete from kq_ShiftRestTimeSections where serialid in(select kqid from hrm_to_kq_serial where serialfrom ='scheduleset')" ; + rs.executeUpdate(sql_3); + + String sql_5 = "delete from hrm_to_kq_group_weekday where serialid in(select kqid from hrm_to_kq_serial where serialfrom ='scheduleset') "; + rs.executeUpdate(sql_5); + String sql_6 ="delete from kq_group where id in( select kqid from hrm_to_kq_group where groupfrom = 'scheduleset')"; + rs.executeUpdate(sql_6); + String sql_7 ="delete from kq_fixedschedulce where groupid in(select kqid from hrm_to_kq_group where groupfrom = 'scheduleset')"; + rs.executeUpdate(sql_7); + String sql_8 = "delete from kq_shiftschedule where groupid in(select kqid from hrm_to_kq_group where groupfrom = 'scheduleset')"; + rs.executeUpdate(sql_8); + String sql_9 = "delete from kq_groupmember where groupid in(select kqid from hrm_to_kq_group where groupfrom = 'scheduleset')"; + rs.executeUpdate(sql_9); + String sql_10 ="delete from hrm_to_kq_group where groupfrom = 'scheduleset'"; + rs.executeUpdate(sql_10); + + String sql_4 = "delete from hrm_to_kq_serial where serialfrom ='scheduleset' "; + rs.executeUpdate(sql_4); + + String sql_11 = "delete from kq_OvertimeRulesDetail where ruleId in(select kqid from hrm_to_kq_OverRules where rulefrom ='scheduleset') "; + rs.executeUpdate(sql_11); + + String sql_12 = "delete from kq_OvertimeRules where id in( select kqid from hrm_to_kq_OverRules where rulefrom ='scheduleset' )"; + rs.executeUpdate(sql_12); + + String sql_13 = "delete from hrm_to_kq_OverRules where rulefrom ='scheduleset' "; + rs.executeUpdate(sql_13); + + } + + /** + * 可以重复升级数据 那就是需要升级之前先清空数据 + * 清空排班时间里的升级数据 + */ + public void clearScheduleGroupData() { + RecordSet rs = new RecordSet(); + String sql_1 = " delete from kq_shiftmanagement where id in(select kqid from hrm_to_kq_serial where serialfrom ='shiftset')"; + rs.executeUpdate(sql_1); + String sql_2 = "delete from kq_ShiftOnOffWorkSections where serialid in(select kqid from hrm_to_kq_serial where serialfrom ='shiftset')"; + rs.executeUpdate(sql_2); + String sql_3 = "delete from kq_ShiftRestTimeSections where serialid in(select kqid from hrm_to_kq_serial where serialfrom ='shiftset')" ; + rs.executeUpdate(sql_3); + + String sql_5 = "delete from hrm_to_kq_group_weekday where serialid in(select kqid from hrm_to_kq_serial where serialfrom ='shiftset') "; + rs.executeUpdate(sql_5); + String sql_6 ="delete from kq_group where id in( select kqid from hrm_to_kq_group where groupfrom = 'shiftset')"; + rs.executeUpdate(sql_6); + String sql_7 ="delete from kq_fixedschedulce where groupid in(select kqid from hrm_to_kq_group where groupfrom = 'shiftset')"; + rs.executeUpdate(sql_7); + String sql_8 = "delete from kq_shiftschedule where groupid in(select kqid from hrm_to_kq_group where groupfrom = 'shiftset')"; + rs.executeUpdate(sql_8); + String sql_9 = "delete from kq_groupmember where groupid in(select kqid from hrm_to_kq_group where groupfrom = 'shiftset')"; + rs.executeUpdate(sql_9); + String sql_10 ="delete from hrm_to_kq_group where groupfrom = 'shiftset'"; + rs.executeUpdate(sql_10); + + String sql_4 = "delete from hrm_to_kq_serial where serialfrom ='shiftset'"; + rs.executeUpdate(sql_4); + + String sql_11 = "delete from kq_OvertimeRulesDetail where ruleId in(select kqid from hrm_to_kq_OverRules where rulefrom ='shiftset') "; + rs.executeUpdate(sql_11); + + String sql_12 = "delete from kq_OvertimeRules where id in( select kqid from hrm_to_kq_OverRules where rulefrom ='shiftset' )"; + rs.executeUpdate(sql_12); + + String sql_13 = "delete from hrm_to_kq_OverRules where rulefrom ='shiftset' "; + rs.executeUpdate(sql_13); + + } + + /** + * 清空加班规则 + */ + public void clearPaidRule() { + RecordSet rs = new RecordSet(); + String sql_1 = " delete from kq_OvertimeRules where id in(select kqid from hrm_to_kq_serial where serialfrom ='shiftset')"; + rs.executeUpdate(sql_1); + String sql_2 = "delete from kq_ShiftOnOffWorkSections where serialid in(select kqid from hrm_to_kq_serial where serialfrom ='shiftset')"; + rs.executeUpdate(sql_2); + String sql_3 = "delete from kq_ShiftRestTimeSections where serialid in(select kqid from hrm_to_kq_serial where serialfrom ='shiftset')" ; + rs.executeUpdate(sql_3); + + String sql_5 = "delete from hrm_to_kq_group_weekday where serialid in(select kqid from hrm_to_kq_serial where serialfrom ='shiftset') "; + rs.executeUpdate(sql_5); + String sql_6 ="delete from kq_group where id in( select kqid from hrm_to_kq_group where groupfrom = 'shiftset')"; + rs.executeUpdate(sql_6); + String sql_7 ="delete from kq_fixedschedulce where groupid in(select kqid from hrm_to_kq_group where groupfrom = 'shiftset')"; + rs.executeUpdate(sql_7); + String sql_8 = "delete from kq_shiftschedule where groupid in(select kqid from hrm_to_kq_group where groupfrom = 'shiftset')"; + rs.executeUpdate(sql_8); + String sql_9 = "delete from kq_groupmember where groupid in(select kqid from hrm_to_kq_group where groupfrom = 'shiftset')"; + rs.executeUpdate(sql_9); + String sql_10 ="delete from hrm_to_kq_group where groupfrom = 'shiftset'"; + rs.executeUpdate(sql_10); + + String sql_4 = "delete from hrm_to_kq_serial where serialfrom ='shiftset'"; + rs.executeUpdate(sql_4); + } + + /** + * 可以重复升级数据 那就是需要升级之前先清空数据 + * 清空请假类型的升级数据 + */ + public void clearLeaveRule() { + RecordSet rs = new RecordSet(); + String sql_1 = " delete from kq_LeaveRules where id in(select kqid from hrm_to_kq_LeaveRules)"; + rs.executeUpdate(sql_1); + String sql_2 = " delete from kq_LeaveRulesDetail where ruleid in(select kqid from hrm_to_kq_LeaveRules)"; + rs.executeUpdate(sql_2); + String sql_3 = " delete from hrm_to_kq_LeaveRules"; + rs.executeUpdate(sql_3); + } + + /** + * 可以重复升级数据 那就是需要升级之前先清空数据 + * 清空工作日期调整的升级数据 + */ + public void clearPub() { + RecordSet rs = new RecordSet(); + String sql_1 = " delete from KQ_HOLIDAYSET where id in(select kqid from hrm_to_kq_pub)"; + rs.executeUpdate(sql_1); + String sql_2 = " delete from hrm_to_kq_pub"; + rs.executeUpdate(sql_2); + + } + + /** + * 可以重复升级数据 那就是需要升级之前先清空数据 + * 清空假期余额的升级数据 + */ + public void clearBalance(String rulesql) { + RecordSet rs = new RecordSet(); + String sql_1 = "delete from kq_BalanceOfLeave where leaverulesid in ("+rulesql+")"; + rs.executeUpdate(sql_1); + } + + /** + * 可以重复升级数据 那就是需要升级之前先清空数据 + * 清空考勤流程设置的升级数据 + */ + public void clearAttSet() { + RecordSet rs = new RecordSet(); + String sql_1 = "delete from kq_ATT_PROC_SET where id in(select kqid from hrm_to_attSet) "; + rs.executeUpdate(sql_1); + String sql_2 = "delete from kq_ATT_PROC_RELATION where field001 in(select kqid from hrm_to_attSet) "; + rs.executeUpdate(sql_2); + String sql_3 = "delete from kq_ATT_PROC_ACTION where field001 in(select kqid from hrm_to_attSet) "; + rs.executeUpdate(sql_3); + String sql_4 = "delete from hrm_to_attfield "; + rs.executeUpdate(sql_4); + String sql_5 = "delete from hrm_to_attSet "; + rs.executeUpdate(sql_5); + + } + + /** + * 可以重复升级数据 那就是需要升级之前先清空数据 + * 清空考勤流程的升级数据 + */ + public void clearFlowData(String startdate, String enddate) { + RecordSet rs = new RecordSet(); + String sql_11 = "delete from hrm_to_flow_split where splitid in (select requestid from kq_flow_split_overtime where fromdate >='"+startdate+"' and todate <='"+enddate+"')"; + rs.executeUpdate(sql_11); + String sql_12 = "delete from hrm_to_flow_split where splitid in (select requestid from kq_flow_split_out where fromdate >='"+startdate+"' and todate <='"+enddate+"')"; + rs.executeUpdate(sql_12); + String sql_13 = "delete from hrm_to_flow_split where splitid in (select requestid from kq_flow_split_evection where fromdate >='"+startdate+"' and todate <='"+enddate+"')"; + rs.executeUpdate(sql_13); + String sql_14 = "delete from hrm_to_flow_split where splitid in (select requestid from kq_flow_split_leave where fromdate >='"+startdate+"' and todate <='"+enddate+"')"; + rs.executeUpdate(sql_14); + String sql_15 = "delete from hrm_to_flow_split where splitid in (select requestid from kq_flow_split_other where fromdate >='"+startdate+"' and todate <='"+enddate+"')"; + rs.executeUpdate(sql_15); + + String sql_1 = "delete from kq_flow_split_overtime where fromdate >='"+startdate+"' and todate <='"+enddate+"' "; + rs.executeUpdate(sql_1); + String sql_111 = "delete from kq_flow_overtime where belongdate >='"+startdate+"' and belongdate <='"+enddate+"' "; + rs.executeUpdate(sql_111); + String sql_2 = "delete from kq_flow_split_out where fromdate >='"+startdate+"' and todate <='"+enddate+"' "; + rs.executeUpdate(sql_2); + String sql_3 = "delete from kq_flow_split_evection where fromdate >='"+startdate+"' and todate <='"+enddate+"' "; + rs.executeUpdate(sql_3); + String sql_4 = "delete from kq_flow_split_leave where fromdate >='"+startdate+"' and todate <='"+enddate+"' "; + rs.executeUpdate(sql_4); + String sql_5 = "delete from kq_flow_split_other where fromdate >='"+startdate+"' and todate <='"+enddate+"' "; + rs.executeUpdate(sql_5); + } + + /** + * 可以重复升级数据 那就是需要升级之前先清空数据 + * 清空考勤报表的升级数据 + */ + public void clearReportData(String startdate, String enddate) { + RecordSet rs = new RecordSet(); + String sql_1 = "delete from kq_format_pool where kqdate between '"+startdate+"' and '"+enddate+"'"; + rs.executeUpdate(sql_1); + String sql_2 = "delete from kq_format_detail where kqdate between '"+startdate+"' and '"+enddate+"'"; + rs.executeUpdate(sql_2); + String sql_3 = "delete from kq_format_total where kqdate between '"+startdate+"' and '"+enddate+"'"; + rs.executeUpdate(sql_3); + } +} diff --git a/src/com/engine/kq/biz/KQOverTimeFlowBiz.java b/src/com/engine/kq/biz/KQOverTimeFlowBiz.java new file mode 100644 index 0000000..110f02d --- /dev/null +++ b/src/com/engine/kq/biz/KQOverTimeFlowBiz.java @@ -0,0 +1,774 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.entity.KQOvertimeRulesDetailEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.bean.OvertimeBalanceTimeBean; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.KQFlowUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import org.springframework.beans.BeanUtils; +import weaver.common.StringUtil; +import weaver.general.Util; + +/** + * 加班流程 非工作时长计算 重新搞一把 + * 现在是根据归属来拆分流程 + */ +public class KQOverTimeFlowBiz { + private KQLog kqLog = new KQLog(); + + /** + * 之前的加班拆分是根据每一天进行拆分的,但是我们是有个默认归属的,就是上班前是属于前一天的,再加上这次标准改造,加了临界点, + * 加班的拆分改造一下,改成和请假拆分一样,根据归属区间来拆分 + * 未设置加班归属的逻辑是 + * 工作日A-工作日B ,从工作日A的上班时间往后加24小时,都算工作日A的加班区间 + * 工作日A-非工作日,从工作日A的上班时间往后加24小时,都算工作日A的加班区间 + * 非工作日-工作日A,从非工作日的0点到工作日A的上班前,都属于非工作日的区间 + * + * 计算加班逻辑很特殊, + * 需要知道昨日,今日和明日的类型,是工作日还是非工作日 + * @param splitBean + * @param splitBeans + */ + public void getSplitDurationBean_new(SplitBean splitBean,List splitBeans) { + try{ + double oneDayHour = KQFlowUtil.getOneDayHour(splitBean.getDurationTypeEnum(),""); + int workmins = (int)(oneDayHour * 60); + String resourceid = splitBean.getResourceId(); + String fromDate = splitBean.getFromdatedb(); + String toDate = splitBean.getTodatedb(); + + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate localToDate = LocalDate.parse(toDate); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate preFromDate = localFromDate.minusDays(1); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String overtimePoint = Util.null2String(kqSettingsComInfo.getMain_val("overtime_point"),"0"); + KQOverTimeRuleCalBiz kqOverTimeRuleCalBiz = new KQOverTimeRuleCalBiz(); + Map changeTypeMap = Maps.newHashMap(); + Map overRulesDetailMap = Maps.newHashMap(); + Map> restTimeMap = Maps.newHashMap(); + Map computingModeMap = Maps.newHashMap(); + kqOverTimeRuleCalBiz.getOverTimeDataMap(resourceid, fromDate, toDate, dateFormatter,changeTypeMap,overRulesDetailMap,restTimeMap,computingModeMap); + +// kqLog.info("getSplitDurationBean_new:overRulesDetailMap:"+ JSON.toJSONString(overRulesDetailMap)); +// kqLog.info("getSplitDurationBean_new:computingModeMap:"+ JSON.toJSONString(computingModeMap)); + if(overRulesDetailMap.isEmpty()){ + return; + } + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + String fromTime = splitBean.getFromtimedb(); + String toTime = splitBean.getTotimedb(); + long betweenDays = localToDate.toEpochDay() - preFromDate.toEpochDay(); + //默认是从加班开始日期的前一天开始计算 需要特殊处理的就三个情况,i=0的时候,i=1的时候就是加班流程开始日期那一天,i=最后一天就是加班流程结束日期那一天 + for (int i = 0; i <= betweenDays; i++) { + SplitBean overSplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + BeanUtils.copyProperties(splitBean, overSplitBean); + + //从加班流程开始的前一天开始算归属 + LocalDate curLocalDate = preFromDate.plusDays(i); + String splitDate = curLocalDate.format(dateFormatter); + String preSplitDate = LocalDate.parse(splitDate).minusDays(1).format(dateFormatter); + LocalDate nextLocalDate = curLocalDate.plusDays(1); + String nextSplitDate = nextLocalDate.format(dateFormatter); + String change_key = splitDate+"_"+resourceid; + String pre_change_key = preSplitDate+"_"+resourceid; + String next_change_key = nextSplitDate+"_"+resourceid; + int changeType = Util.getIntValue(""+changeTypeMap.get(change_key),-1); + int preChangeType = Util.getIntValue(""+changeTypeMap.get(pre_change_key),-1); + int next_changeType = Util.getIntValue(""+changeTypeMap.get(next_change_key),-1); + + boolean shouldAcross = false; + String changeType_key = splitDate+"_"+changeType; + String preChangeType_key = preSplitDate+"_"+preChangeType; + String nextChangeType_key = nextSplitDate+"_"+next_changeType; + if(!computingModeMap.containsKey(changeType_key)){ + continue; + } + int computingMode = computingModeMap.get(changeType_key); + if(computingMode == 3){ + //如果是纯打卡为主的不生成加班 + continue; + } + + int[] initArrays = kqTimesArrayComInfo.getInitArr(); + //当前日期的加班分割点 分割点都是次日的 + String overtime_cut_point = ""; + int before_startTime = 0; + int startTime = 0; + int curMins = 0 ; + //排除休息类型 + int restTimeType = -1; + //需要知道明日的类型:如果今天是工作日的话,那么今天的加班临界点可能和明日的上班时间冲突,需要知道明日的上班时间进行比较, + String next_beginwork_time = getNextBeginworkTime(resourceid,nextSplitDate,next_changeType,splitBean,is_flow_humanized,kqTimesArrayComInfo); + // 如果今天是休息日,那么明天如果是工作日的话,默认规则下,明天的上班前都是属于今天的加班区间 + String cur_beginwork_time = getCurBeginworkTime(resourceid,splitDate,changeType,splitBean,is_flow_humanized,kqTimesArrayComInfo); + String serialid = ""; + List overtimeBalanceTimeBeans = Lists.newArrayList(); + KQOvertimeRulesDetailEntity curKqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key); +// kqLog.info("getSplitDurationBean_new:splitDate:"+ splitDate +// +"::i::"+i+"::changeType_key::"+changeType_key +// +"::next_beginwork_time::"+next_beginwork_time+"::cur_beginwork_time::"+cur_beginwork_time +// +"::curKqOvertimeRulesDetailEntity::"+curKqOvertimeRulesDetailEntity); + if(curKqOvertimeRulesDetailEntity != null){ + int has_cut_point = curKqOvertimeRulesDetailEntity.getHas_cut_point(); + before_startTime = curKqOvertimeRulesDetailEntity.getBefore_startTime(); + int overtimeEnable = curKqOvertimeRulesDetailEntity.getOvertimeEnable(); + if(overtimeEnable != 1){ + continue; + } + if(has_cut_point != 1){ + before_startTime = -1; + } + startTime = curKqOvertimeRulesDetailEntity.getStartTime(); + restTimeType = curKqOvertimeRulesDetailEntity.getRestTimeType(); + if(has_cut_point == 0){ + if(changeType == 2){ + overtime_cut_point = cur_beginwork_time; + if(next_beginwork_time.length() > 0){ + if(next_beginwork_time.compareTo(cur_beginwork_time) < 0){ + overtime_cut_point = next_beginwork_time; + } + } + }else { + if(next_beginwork_time.length() > 0){ + overtime_cut_point = next_beginwork_time; + } + } + }else{ + overtime_cut_point = curKqOvertimeRulesDetailEntity.getCut_point(); + if(next_beginwork_time.length() > 0){ + int next_beginwork_time_index = kqTimesArrayComInfo.getArrayindexByTimes(next_beginwork_time); + int overtime_cut_point_index = kqTimesArrayComInfo.getArrayindexByTimes(overtime_cut_point); + if(overtime_cut_point_index > next_beginwork_time_index){ + overtime_cut_point = next_beginwork_time; + } + } + } + if(overtime_cut_point.length() == 0){ + overtime_cut_point = "00:00"; + } + }else{ + continue; + } + int fromTime_index = 0; + int toTime_index = 0; + if(i == 0){ + //i=0就是加班开始日期的前一天,只有当加班临界点超过了加班流程开始时间的话,i=0才会有可能计算出时长 +// kqLog.info("getSplitDurationBean_new:splitDate:"+ splitDate +// +"::i::"+i+"::overtime_cut_point::"+overtime_cut_point+"::fromTime::"+fromTime); + if(overtime_cut_point.compareTo(fromTime) > 0){ + fromTime_index = kqTimesArrayComInfo.getArrayindexByTimes(kqTimesArrayComInfo.turn24to48Time(fromTime)); + toTime_index = kqTimesArrayComInfo.getArrayindexByTimes(kqTimesArrayComInfo.turn24to48Time(overtime_cut_point)); + if(fromDate.equalsIgnoreCase(toDate)){ + //如果开始日期和结束日期是同一天,还需要比较流程的结束时间和归属点的大小 + int oriTotime_index = kqTimesArrayComInfo.getArrayindexByTimes(kqTimesArrayComInfo.turn24to48Time(toTime)); + if(toTime_index > oriTotime_index){ + toTime_index = oriTotime_index; + } + } + Arrays.fill(initArrays, fromTime_index, toTime_index, 0); + //处理下昨日的工作日,可能跨天到今日的情况 + if(preChangeType == 2){ + boolean isok = handlePrechangeType2(initArrays, resourceid, preSplitDate, preChangeType_key,overRulesDetailMap,kqTimesArrayComInfo,splitBean,is_flow_humanized); + } +// 1-节假日、2-工作日、3-休息日 + if(changeType == 1){ + handle_changeType_1(initArrays,overRulesDetailMap,nextChangeType_key,next_changeType,next_beginwork_time); + }else if(changeType == 2){ + boolean isok = handle_changeType_2(initArrays, resourceid, splitDate, before_startTime, startTime, fromTime_index,kqTimesArrayComInfo,splitBean, + toTime_index,is_flow_humanized,curKqOvertimeRulesDetailEntity); + serialid = splitBean.getSerialid(); +// kqLog.info("getSplitDurationBean_new:splitDate:"+ splitDate +// +"::i::"+i+"::isok::"+isok); + if(!isok){ + continue; + } + }else if(changeType == 3){ + handle_changeType_3(initArrays,overRulesDetailMap,nextChangeType_key,next_changeType,next_beginwork_time); + } + if(restTimeType == 1){ + //如果排除设置的休息时间 + handle_resttime(restTimeMap,changeType_key,kqTimesArrayComInfo,shouldAcross,initArrays); + } +// kqLog.info("getSplitDurationBean_new:splitDate:"+ splitDate+"::fromTime_index::"+fromTime_index+"::toTime_index::"+toTime_index); + curMins = kqTimesArrayComInfo.getCnt(initArrays, fromTime_index,toTime_index,0); +// kqLog.info("getSplitDurationBean_new:splitDate:"+ splitDate+"::curMins::"+curMins); + if(restTimeType == 2){ + //如果排除休息时间是扣除时长 + curMins = handle_restlength(curMins,restTimeMap,changeType_key); + } +// kqLog.info("getSplitDurationBean_new:handle_restlength:splitDate:"+ splitDate+"::curMins::"+curMins); + }else{ + continue; + } + }else{ + //除了i=0的情况,其他的每一天都是要获取一下昨日的临界点的 + String pre_overtime_cut_point = get_pre_overtime_cut_point(overRulesDetailMap,preChangeType_key,resourceid,preSplitDate,splitDate,preChangeType,kqTimesArrayComInfo,splitBean,changeType,is_flow_humanized); +// kqLog.info("getSplitDurationBean_new:splitDate:"+ splitDate +// +"::i::"+i+"::pre_overtime_cut_point::"+pre_overtime_cut_point+"::fromTime::"+fromTime); + //计算区间加班开始日期和加班结束日期这两天都是要特殊处理的 + fromTime_index = kqTimesArrayComInfo.getArrayindexByTimes(pre_overtime_cut_point); + if(i == 1){ + if(fromTime.compareTo(pre_overtime_cut_point) > 0){ + fromTime_index = kqTimesArrayComInfo.getArrayindexByTimes(fromTime); + } + } + if(i == betweenDays){ + toTime_index = kqTimesArrayComInfo.getArrayindexByTimes(toTime); + }else{ +// kqLog.info("getSplitDurationBean_new:splitDate:"+ splitDate +// +"::i::"+i+"::overtime_cut_point::"+overtime_cut_point +// +"::next_beginwork_time::"+next_beginwork_time +// +"::betweenDays::"+betweenDays); + toTime_index = kqTimesArrayComInfo.turn24to48TimeIndex(kqTimesArrayComInfo.getArrayindexByTimes(overtime_cut_point)); + if(next_beginwork_time.length() > 0){ + int overtime_cut_point_index = kqTimesArrayComInfo.getArrayindexByTimes(overtime_cut_point); + int next_beginwork_time_index = kqTimesArrayComInfo.getArrayindexByTimes(next_beginwork_time); + //如果临界点都已经超过第二天上班的开始时间了,要相应的缩短成第二天上班时间 + if(overtime_cut_point_index > next_beginwork_time_index){ + toTime_index = kqTimesArrayComInfo.turn24to48TimeIndex(next_beginwork_time_index); + } + } + if(i == betweenDays-1){ + int ori_totime_index = kqTimesArrayComInfo.turn48to24TimeIndex(toTime_index); + int last_toTime_index = kqTimesArrayComInfo.getArrayindexByTimes(toTime); + if(ori_totime_index > last_toTime_index){ + toTime_index = kqTimesArrayComInfo.turn24to48TimeIndex(last_toTime_index); + } + } + } + +// kqLog.info("getSplitDurationBean_new:splitDate:"+ splitDate +// +"::i::"+i+"::fromTime_index::"+fromTime_index+"::toTime_index::"+toTime_index); + if(fromTime_index > toTime_index){ + continue; + } +// kqLog.info("getSplitDurationBean_new:splitDate:"+ splitDate+"::fromTime_index::"+fromTime_index+"::toTime_index::"+toTime_index); + Arrays.fill(initArrays, fromTime_index, toTime_index, 0); +// kqLog.info("getSplitDurationBean_new:splitDate:"+ splitDate+"::getCnt:1:"+kqTimesArrayComInfo.getCnt(initArrays, fromTime_index,toTime_index,0)); + + //处理下昨日的工作日,可能跨天到今日的情况 + if(preChangeType == 2){ + boolean isok = handlePrechangeType2(initArrays, resourceid, preSplitDate, preChangeType_key,overRulesDetailMap,kqTimesArrayComInfo,splitBean,is_flow_humanized); + } +// kqLog.info("getSplitDurationBean_new:splitDate:"+ splitDate+"::getCnt:2:"+kqTimesArrayComInfo.getCnt(initArrays, fromTime_index,toTime_index,0)); + if(changeType == 1){ + handle_changeType_1(initArrays, overRulesDetailMap, nextChangeType_key, next_changeType, + next_beginwork_time); + }else if(changeType == 2){ + serialid = splitBean.getSerialid(); + boolean isok = handle_changeType_2(initArrays, resourceid, splitDate, before_startTime, startTime, fromTime_index, + kqTimesArrayComInfo, splitBean, toTime_index,is_flow_humanized, + curKqOvertimeRulesDetailEntity); + if(!isok){ + continue; + } + }else if(changeType == 3){ + handle_changeType_3(initArrays, overRulesDetailMap, nextChangeType_key, next_changeType, + overtime_cut_point); + } + if(restTimeType == 1) { + //如果排除设置的休息时间 + handle_resttime(restTimeMap, changeType_key, kqTimesArrayComInfo, shouldAcross,initArrays); + } + curMins = kqTimesArrayComInfo.getCnt(initArrays, fromTime_index,toTime_index,0); +// kqLog.info("getSplitDurationBean_new:splitDate:"+ splitDate+"::getCnt:3:"+kqTimesArrayComInfo.getCnt(initArrays, fromTime_index,toTime_index,0)); + + if(restTimeType == 2){ + //如果排除休息时间是扣除时长 + curMins = handle_restlength(curMins,restTimeMap,changeType_key); + } +// kqLog.info("getSplitDurationBean_new:splitDate:"+ splitDate+"::getCnt:4:"+kqTimesArrayComInfo.getCnt(initArrays, fromTime_index,toTime_index,0)); + } + int minimumUnit = curKqOvertimeRulesDetailEntity.getMinimumLen(); + if(curMins < minimumUnit){ + continue; + } + + int maxmumUnit = curKqOvertimeRulesDetailEntity.getMaxmumLen(); + if(curMins > maxmumUnit){ + curMins = maxmumUnit; + } + + curMins = (int) kqOverTimeRuleCalBiz.getD_MinsByUnit(curMins); + overSplitBean.setChangeType(changeType); + overSplitBean.setPreChangeType(preChangeType); + overSplitBean.setOneDayHour(oneDayHour); + overSplitBean.setWorkmins(workmins); + overSplitBean.setComputingMode(computingMode+""); + overSplitBean.setChangeType(changeType); + overSplitBean.setFromDate(splitDate); + overSplitBean.setFromTime(kqTimesArrayComInfo.getTimesByArrayindex(fromTime_index)); + overSplitBean.setToDate(splitDate); + overSplitBean.setToTime(kqTimesArrayComInfo.getTimesByArrayindex(toTime_index)); + overSplitBean.setBelongDate(splitDate); + overSplitBean.setD_Mins(curMins); + overSplitBean.setOvertimeBalanceTimeBeans(overtimeBalanceTimeBeans); + overSplitBean.setSerialid(serialid); + getDurationByRule(overSplitBean); + splitBeans.add(overSplitBean); + } + +// kqLog.info("getSplitDurationBean_new:splitBeans:"+ JSON.toJSONString(splitBeans)); + }catch (Exception e){ + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + } + + private boolean handlePrechangeType2(int[] initArrays, String resourceid, String preSplitDate, String preChangeTypeKey, Map overRulesDetailMap, + KQTimesArrayComInfo kqTimesArrayComInfo, SplitBean splitBean, boolean is_flow_humanized) { + KQOvertimeRulesDetailEntity preOverRulesDetail = overRulesDetailMap.get(preChangeTypeKey); + int startTime = 0; + if(preOverRulesDetail != null){ + startTime = preOverRulesDetail.getStartTime(); + } + ShiftInfoBean pre_shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, preSplitDate, false); + if(pre_shiftInfoBean != null){ + int restShift = pre_shiftInfoBean.getRestShift(); + if(1 != restShift){ + List workLongTimeIndex = pre_shiftInfoBean.getWorkLongTimeIndex(); + List real_workLongTimeIndex = Lists.newArrayList(); + get_real_workLongTimeIndex(workLongTimeIndex,real_workLongTimeIndex,pre_shiftInfoBean,kqTimesArrayComInfo,splitBean,is_flow_humanized); + + if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){ + int all_firstworktime = -1; + int all_lastworktime = -1; + boolean need_middle_time = false; + + int isovertimecal = 0; + //午休加班 + if(preOverRulesDetail != null){ + isovertimecal = preOverRulesDetail.getIsOvertimeCal(); + if(isovertimecal==1){ + need_middle_time = true; + }//----午休加班 + } + for(int k = 0 ; k < real_workLongTimeIndex.size() ; k++){ + int workLongTimeStartIndex = real_workLongTimeIndex.get(k)[0]; + int workLongTimeEndIndex = real_workLongTimeIndex.get(k)[1]; + workLongTimeStartIndex = workLongTimeStartIndex - 1440; + workLongTimeEndIndex = workLongTimeEndIndex - 1440; + if(workLongTimeStartIndex < 0){ + workLongTimeStartIndex = 0; + } + if(workLongTimeEndIndex < 0){ + workLongTimeEndIndex = 0; + } + if(workLongTimeStartIndex >= workLongTimeEndIndex){ + continue; + } + if(all_firstworktime > -1){ + //最早开始时间已经赋值了就不处理了 + }else{ + all_firstworktime = workLongTimeStartIndex; + } + if(k == real_workLongTimeIndex.size()-1){ + if(startTime > -1){ + int after_workLongTimeEndIndex = workLongTimeEndIndex+startTime; + if(workLongTimeEndIndex < after_workLongTimeEndIndex){ + Arrays.fill(initArrays, workLongTimeEndIndex,after_workLongTimeEndIndex,-1); + } + } + all_lastworktime = workLongTimeEndIndex; + } + if(!need_middle_time){ + //目前标准加班,一天多次打卡的话是不算中间时间的,只算上班前和下班后的加班 + }else{ + //这个里面是可以算一天多次打卡的话是中间时间的 + Arrays.fill(initArrays, workLongTimeStartIndex,workLongTimeEndIndex,1); + } + } + if(!need_middle_time){ + if(all_lastworktime > all_firstworktime){ + Arrays.fill(initArrays, all_firstworktime,all_lastworktime,1); + } + } + List restLongTimeIndex = pre_shiftInfoBean.getRestLongTimeIndex(); + if(restLongTimeIndex != null && !restLongTimeIndex.isEmpty()){ + for (int k = 0; k < restLongTimeIndex.size(); k++) { + int restLongTimeStartIndex = restLongTimeIndex.get(k)[0]; + int restLongTimeEndIndex = restLongTimeIndex.get(k)[1]; + restLongTimeStartIndex = restLongTimeStartIndex - 1440; + restLongTimeEndIndex = restLongTimeEndIndex - 1440; + if(restLongTimeStartIndex < 0){ + restLongTimeStartIndex = 0; + } + if(restLongTimeEndIndex < 0){ + restLongTimeEndIndex = 0; + } + if(restLongTimeStartIndex >= restLongTimeEndIndex){ + continue; + } + //午休加班---- + if(isovertimecal==1){ + Arrays.fill(initArrays, restLongTimeStartIndex, restLongTimeEndIndex, 0); + }else{ + Arrays.fill(initArrays, restLongTimeStartIndex, restLongTimeEndIndex, 2); + }//---午休加班 + } + } + } + } + } + + return true; + } + + private String getCurBeginworkTime(String resourceid, String splitDate, int changeType, + SplitBean splitBean, boolean isFlowHumanized, KQTimesArrayComInfo kqTimesArrayComInfo) { + String cur_beginwork_time = ""; + ShiftInfoBean cur_shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate, false); + + if(cur_shiftInfoBean != null){ + List workLongTimeIndex = cur_shiftInfoBean.getWorkLongTimeIndex(); + List real_workLongTimeIndex = Lists.newArrayList(); + get_real_workLongTimeIndex(workLongTimeIndex,real_workLongTimeIndex,cur_shiftInfoBean,kqTimesArrayComInfo,splitBean,isFlowHumanized); + + if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){ + cur_beginwork_time = kqTimesArrayComInfo.getTimesByArrayindex(real_workLongTimeIndex.get(0)[0]); + } + } + return cur_beginwork_time; + } + + /** + * 获取第二天的上班时间 + */ + private String getNextBeginworkTime(String resourceid, String nextSplitDate, int nextChangeType, + SplitBean splitBean, boolean isFlowHumanized, KQTimesArrayComInfo kqTimesArrayComInfo) { + String next_beginwork_time = ""; + ShiftInfoBean next_shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, nextSplitDate, false); + if(next_shiftInfoBean != null){ + List workLongTimeIndex = next_shiftInfoBean.getWorkLongTimeIndex(); + List real_workLongTimeIndex = Lists.newArrayList(); + get_real_workLongTimeIndex(workLongTimeIndex,real_workLongTimeIndex,next_shiftInfoBean,kqTimesArrayComInfo,splitBean,isFlowHumanized); + + if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){ + next_beginwork_time = kqTimesArrayComInfo.getTimesByArrayindex(real_workLongTimeIndex.get(0)[0]); + } + } + return next_beginwork_time; + } + + + /** + * 被个性化设置处理下 得到实际的上下班时间 + * @param workLongTimeIndex + * @param real_workLongTimeIndex + * @param shiftInfoBean + * @param kqTimesArrayComInfo + * @param splitBean + */ + public void get_real_workLongTimeIndex(List workLongTimeIndex, + List real_workLongTimeIndex, + ShiftInfoBean shiftInfoBean, KQTimesArrayComInfo kqTimesArrayComInfo, + SplitBean splitBean) { + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + get_real_workLongTimeIndex(workLongTimeIndex,real_workLongTimeIndex,shiftInfoBean,kqTimesArrayComInfo,splitBean,is_flow_humanized); + } + + public void get_real_workLongTimeIndex(List workLongTimeIndex, + List real_workLongTimeIndex, + ShiftInfoBean shiftInfoBean, KQTimesArrayComInfo kqTimesArrayComInfo, + SplitBean splitBean,boolean is_flow_humanized) { + + //list带数组,这里要深拷贝 + for(int[] tmp : workLongTimeIndex){ + int[] real_tmp = new int[tmp.length]; + System.arraycopy(tmp, 0, real_tmp, 0, tmp.length); + real_workLongTimeIndex.add(real_tmp); + } + if(real_workLongTimeIndex.size() == 1){ + //个性化设置只支持一次打卡的 + KQShiftRuleInfoBiz kqShiftRuleInfoBiz = new KQShiftRuleInfoBiz(); +// boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + kqShiftRuleInfoBiz.rest_workLongTimeIndex(shiftInfoBean,splitBean,real_workLongTimeIndex,kqTimesArrayComInfo,null,is_flow_humanized); + } + + } + + /** + * 获取一下昨日的临界点 + * @param overRulesDetailMap + * @param preChangeType_key + * @param resourceid + * @param preSplitDate + * @param splitDate + * @param preChangeType + * @param kqTimesArrayComInfo + * @param splitBean + * @param changeType + * @return + */ + private String get_pre_overtime_cut_point( + Map overRulesDetailMap, + String preChangeType_key, String resourceid, String preSplitDate, String splitDate, + int preChangeType, KQTimesArrayComInfo kqTimesArrayComInfo, + SplitBean splitBean, int changeType) { + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + return get_pre_overtime_cut_point(overRulesDetailMap,preChangeType_key,resourceid,preSplitDate,splitDate,preChangeType,kqTimesArrayComInfo,splitBean,changeType,is_flow_humanized); + } + + private String get_pre_overtime_cut_point( + Map overRulesDetailMap, + String preChangeType_key, String resourceid, String preSplitDate, String splitDate, + int preChangeType, KQTimesArrayComInfo kqTimesArrayComInfo, + SplitBean splitBean, int changeType,boolean is_flow_humanized) { + + String pre_overtime_cut_point = ""; + KQOvertimeRulesDetailEntity preKqOvertimeRulesDetailEntity = overRulesDetailMap.get(preChangeType_key); + if(preKqOvertimeRulesDetailEntity != null){ + int has_cut_point = preKqOvertimeRulesDetailEntity.getHas_cut_point(); + if(has_cut_point == 0){ + ShiftInfoBean pre_shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, preSplitDate, false); + boolean hasNoSerial = false; + if(pre_shiftInfoBean != null){ + String serialid = Util.null2s(pre_shiftInfoBean.getSerialid(),""); + if(StringUtil.isNull(serialid)){ + hasNoSerial = true; + } + } + String next_beginwork_time = ""; + ShiftInfoBean next_shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate, false); + if(next_shiftInfoBean != null){ + List nextWorkLongTimeIndex = next_shiftInfoBean.getWorkLongTimeIndex(); + List nextRealWorkLongTimeIndex = Lists.newArrayList(); + get_real_workLongTimeIndex(nextWorkLongTimeIndex,nextRealWorkLongTimeIndex,next_shiftInfoBean,kqTimesArrayComInfo,splitBean,is_flow_humanized); + + if(nextRealWorkLongTimeIndex != null && !nextRealWorkLongTimeIndex.isEmpty()){ + next_beginwork_time = kqTimesArrayComInfo.getTimesByArrayindex(nextRealWorkLongTimeIndex.get(0)[0]); + } + } + if(preChangeType == 2 && !hasNoSerial){ + if(pre_shiftInfoBean != null){ + List workLongTimeIndex = pre_shiftInfoBean.getWorkLongTimeIndex(); + List real_workLongTimeIndex = Lists.newArrayList(); + get_real_workLongTimeIndex(workLongTimeIndex,real_workLongTimeIndex,pre_shiftInfoBean,kqTimesArrayComInfo,splitBean,is_flow_humanized); + + if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){ + pre_overtime_cut_point = kqTimesArrayComInfo.getTimesByArrayindex(real_workLongTimeIndex.get(0)[0]); + } + if(next_beginwork_time.length() > 0){ + if(pre_overtime_cut_point.compareTo(next_beginwork_time) > 0){ + //如果前一天的上班时间大于今天的上班时间,则以今天的上班时间作为前一天的归属结束时间 + pre_overtime_cut_point = next_beginwork_time; + } + } + } + }else { + if(next_beginwork_time.length() > 0){ + pre_overtime_cut_point = next_beginwork_time; + } + } + + }else{ + pre_overtime_cut_point = preKqOvertimeRulesDetailEntity.getCut_point(); + } + } + if(pre_overtime_cut_point.length() == 0){ + pre_overtime_cut_point = "00:00"; + } + return pre_overtime_cut_point; + } + + /** + * 处理节假日的加班 + * @param initArrays + * @param overRulesDetailMap + * @param nextChangeType_key + * @param next_changeType + * @param next_beginwork_time + */ + public void handle_changeType_1(int[] initArrays, + Map overRulesDetailMap, + String nextChangeType_key, int next_changeType, String next_beginwork_time){ + + } + + /** + * 排除休息时间 现在工作日,节假日和休息日都可以设置排除休息时间 + */ + public void handle_resttime(Map> restTimeMap, String changeType_key, KQTimesArrayComInfo kqTimesArrayComInfo, boolean shouldAcross, int[] initArrays) { + + if(restTimeMap.containsKey(changeType_key)){ + List restTimeList = restTimeMap.get(changeType_key); + //再把休息时间填充上去 + if(!restTimeList.isEmpty()){ + for(int k =0 ; k < restTimeList.size() ; k++){ + String[] restTimes = restTimeList.get(k); + if(restTimes.length == 2){ + int restStart = kqTimesArrayComInfo.getArrayindexByTimes(restTimes[0]); + int restEnd = kqTimesArrayComInfo.getArrayindexByTimes(restTimes[1]); +// if(shouldAcross && restEnd == 1439){ + if(restEnd == 1439){ + //针对跨天的休息时段单独处理排除掉23:59-00:00的时间 + restEnd = 1440; + } + Arrays.fill(initArrays, restStart, restEnd, 1); + } + } + } + } + } + + /** + * 排除休息时长 根据加班时长排除指定时长 + * @param curMins + * @param restTimeMap + * @param changeType_key + * @return + */ + public int handle_restlength(int curMins, Map> restTimeMap, String changeType_key) { + if(restTimeMap.containsKey(changeType_key)) { + List restTimeList = restTimeMap.get(changeType_key); + //再把休息时间填充上去 + if (!restTimeList.isEmpty()) { + for(int k = restTimeList.size()-1 ; k >= 0 ; k--) { + String[] restTimes = restTimeList.get(k); + if (restTimes.length == 2) { + //overlength 是满多少小时 cutlength是减去多少小时 + double overlength = Util.getDoubleValue(restTimes[0],-1); + double cutlength = Util.getDoubleValue(restTimes[1],-1); + if(overlength > -1 && cutlength > -1){ + double min_overlength = overlength * 60; + double min_cutlength = cutlength * 60; + if(curMins >= min_overlength){ + curMins = (int) (curMins-min_cutlength); + break; + } + } + } + } + + } + } + return curMins; + } + + /** + * 处理工作日的加班 + */ + public boolean handle_changeType_2(int[] initArrays, String resourceid, String splitDate, + int before_startTime, int startTime, int fromTime_index, + KQTimesArrayComInfo kqTimesArrayComInfo, SplitBean splitBean, int toTime_index,boolean is_flow_humanized, + KQOvertimeRulesDetailEntity curKqOvertimeRulesDetailEntity){ + + boolean isok = true; + ShiftInfoBean cur_shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate, false); + + if(cur_shiftInfoBean != null){ + splitBean.setSerialid(cur_shiftInfoBean.getSerialid()); + List workLongTimeIndex = cur_shiftInfoBean.getWorkLongTimeIndex(); + List real_workLongTimeIndex = Lists.newArrayList(); + get_real_workLongTimeIndex(workLongTimeIndex,real_workLongTimeIndex,cur_shiftInfoBean,kqTimesArrayComInfo,splitBean,is_flow_humanized); + if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){ + int all_firstworktime = 0; + int all_lastworktime = 0; + boolean need_middle_time = false; + //午休加班 + int isovertimecal = curKqOvertimeRulesDetailEntity.getIsOvertimeCal(); + if(isovertimecal==1){ + need_middle_time = true; + }//----午休加班 + for(int k = 0 ; k < real_workLongTimeIndex.size() ; k++){ + int workLongTimeStartIndex = real_workLongTimeIndex.get(k)[0]; + int workLongTimeEndIndex = real_workLongTimeIndex.get(k)[1]; + if(k == 0){ + if(before_startTime > -1){ + int before_workLongTimeStartIndex = workLongTimeStartIndex-before_startTime; + if(before_workLongTimeStartIndex > 0){ + //从前一天的加班归属点到今天的上班前开始加班点,这段时间属于两不靠。需要排除 + if(fromTime_index < before_workLongTimeStartIndex){ + Arrays.fill(initArrays, fromTime_index,before_workLongTimeStartIndex,-1); + } + } + } + all_firstworktime = workLongTimeStartIndex; + } + if(k == real_workLongTimeIndex.size()-1){ + if(startTime > -1){ + int after_workLongTimeEndIndex = workLongTimeEndIndex+startTime; + if(workLongTimeEndIndex < after_workLongTimeEndIndex){ + Arrays.fill(initArrays, workLongTimeEndIndex,after_workLongTimeEndIndex,-1); + } + } + all_lastworktime = workLongTimeEndIndex; + } + if(!need_middle_time){ + //目前标准加班,一天多次打卡的话是不算中间时间的,只算上班前和下班后的加班 + }else{ + //这个里面是可以算一天多次打卡的话是中间时间的 + Arrays.fill(initArrays, workLongTimeStartIndex,workLongTimeEndIndex,1); + } + } + if(!need_middle_time){ + Arrays.fill(initArrays, all_firstworktime,all_lastworktime,1); + } + List restLongTimeIndex = cur_shiftInfoBean.getRestLongTimeIndex(); + if(restLongTimeIndex != null && !restLongTimeIndex.isEmpty()){ + for (int k = 0; k < restLongTimeIndex.size(); k++) { + //午休加班---- + if(isovertimecal==1){ + Arrays.fill(initArrays, restLongTimeIndex.get(k)[0], restLongTimeIndex.get(k)[1], 0); + }else{ + Arrays.fill(initArrays, restLongTimeIndex.get(k)[0], restLongTimeIndex.get(k)[1], 2); + }//---午休加班 + } + } + }else { + kqLog.info("error"); + isok = false; + } + }else { + kqLog.info("error"); + isok = false; + } + + return isok; + } + /** + * 处理休息日的加班 + * @param restTimeMap + * @param initArrays + * @param overRulesDetailMap + * @param nextChangeType_key + * @param next_changeType + * @param next_beginwork_time + */ + public void handle_changeType_3(int[] initArrays, + Map overRulesDetailMap, + String nextChangeType_key, int next_changeType, String next_beginwork_time) { + + } + + public void getDurationByRule(SplitBean splitBean) { + double D_Mins = splitBean.getD_Mins(); + int workmins = splitBean.getWorkmins(); + String durationrule = splitBean.getDurationrule(); + if("3".equalsIgnoreCase(durationrule) || "5".equalsIgnoreCase(durationrule) + || "6".equalsIgnoreCase(durationrule)){ + double d_hour = D_Mins/60.0; + splitBean.setDuration(KQDurationCalculatorUtil.getDurationRound5(""+d_hour)); + }else if("1".equalsIgnoreCase(durationrule)){ + double d_day = D_Mins/workmins; + splitBean.setDuration(KQDurationCalculatorUtil.getDurationRound5(""+d_day)); + } + } +} diff --git a/src/com/engine/kq/biz/KQOverTimeRuleCalBiz.java b/src/com/engine/kq/biz/KQOverTimeRuleCalBiz.java new file mode 100644 index 0000000..053a547 --- /dev/null +++ b/src/com/engine/kq/biz/KQOverTimeRuleCalBiz.java @@ -0,0 +1,3094 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.entity.KQOvertimeRulesDetailEntity; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.jucailin.util.KQDateUtil; +import com.engine.kq.log.KQLog; +import com.engine.kq.timer.KQOvertimeCardBean; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.util.KQLockAttendaUtil; +import com.engine.kq.wfset.bean.OvertimeBalanceTimeBean; +import com.engine.kq.wfset.bean.SplitBean; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +/** + * 根据加班规则计算加班和调休数据 + * 主要是针对 流程+打卡 打卡 这几种方式 + */ +public class KQOverTimeRuleCalBiz { + private KQLog kqLog = new KQLog(); + + private static final String LOCK_DEGREE = Util.null2String(Prop.getPropValue("kqLockAttenda", "LOCK_DEGREE")); + + /** + * 生成加班数据 + * + * @param resourceid + * @param fromDate + * @param toDate + * @param eventtype + */ + public void buildOvertime(String resourceid, String fromDate, String toDate, String eventtype) { + + try { + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + Map changeTypeMap = Maps.newHashMap(); + Map overRulesDetailMap = Maps.newHashMap(); + Map> restTimeMap = Maps.newHashMap(); + Map computingModeMap = Maps.newHashMap(); + //先获取一些前提数据,加班規則和假期規則 + getOverTimeDataMap(resourceid, fromDate, toDate, dateFormatter, changeTypeMap, overRulesDetailMap, restTimeMap, computingModeMap); + Map eventLogMap = Maps.newHashMap(); + eventLogMap.put("fromDate", fromDate); + eventLogMap.put("toDate", toDate); + eventLogMap.put("eventtype", eventtype); + KQOvertimeLogBiz kqEventLogBiz = new KQOvertimeLogBiz(); + String logKey = "|key|" + resourceid + "_" + fromDate + "_" + toDate; + String main_uuid = kqEventLogBiz.logEvent(resourceid, eventLogMap, "buildOvertime|生成加班调休" + logKey); + + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate localToDate = LocalDate.parse(toDate); + LocalDate preFromDate = localFromDate.minusDays(1); + LocalDate nextToDate = localToDate.plusDays(1); + //之前是考虑外部考勤数据导入跨天打卡,判断归属的问题,向前算一天,现在不管了,都是默认只处理当天的 + if (eventtype.indexOf("#flow,") > -1 || eventtype.indexOf("punchcard") > -1 || true) { + //如果是正常走的加班流程,就是流程开始日期和结束日期,只有补卡,打卡,同步的时候才需要处理一下前一天和后一天的数据 + preFromDate = localFromDate; + nextToDate = localToDate; + } + long betweenDays = nextToDate.toEpochDay() - preFromDate.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + LocalDate curLocalDate = preFromDate.plusDays(i); + String splitDate = curLocalDate.format(dateFormatter); + String key = resourceid + "_" + splitDate; + // 强控 + if (LOCK_DEGREE.equals("1")&&new KQLockAttendaUtil().checkLockStatus(resourceid, splitDate)) { + kqLog.info("锁定程度强控:人员考勤数据已被锁定,"+"userId:"+resourceid+":kqDate:"+splitDate); + continue; + } + + + String nextDate = DateUtil.addDate(splitDate, 1); + Map overtimeLogMap = Maps.newLinkedHashMap(); + Map eventMap = Maps.newLinkedHashMap(); + //加班日志记录类 + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(resourceid, splitDate); + Map workTimeEntityLogMap = Maps.newHashMap(); + workTimeEntityLogMap.put("resourceid", resourceid); + workTimeEntityLogMap.put("splitDate", splitDate); + workTimeEntityLogMap.put("workTimeEntity", workTimeEntity); + String uuid = kqEventLogBiz.logDetailWorkTimeEntity(resourceid, workTimeEntityLogMap, main_uuid, "doComputingMode|加班打卡|key|" + key); + + try { + Map lsCheckInfoMaps = Maps.newLinkedHashMap(); + //获取加班打卡数据 + + getOverTimeCardDataMap(resourceid, splitDate, splitDate, dateFormatter, kqTimesArrayComInfo, overRulesDetailMap, changeTypeMap, lsCheckInfoMaps, eventMap); + Map nextLsCheckInfoMaps = Maps.newLinkedHashMap(); + Map nextEventMap = Maps.newLinkedHashMap(); + getOverTimeCardDataMap(resourceid, nextDate, nextDate, dateFormatter, kqTimesArrayComInfo, overRulesDetailMap, changeTypeMap, nextLsCheckInfoMaps, nextEventMap); + eventMap.put("nextEventMap", JSON.toJSONString(nextEventMap)); + if (MapUtils.isNotEmpty(nextLsCheckInfoMaps)) { + for (Map.Entry nextBean : nextLsCheckInfoMaps.entrySet()) { + String nextInTodayKey = nextBean.getKey(); + String[] mapKeys = nextInTodayKey.split("_"); + if (mapKeys.length == 3) { + eventMap.put("nextInBefore", JSON.toJSONString(nextBean)); + lsCheckInfoMaps.put(nextInTodayKey, nextBean.getValue()); + } + } + } + + Iterator> iterator = lsCheckInfoMaps.entrySet().iterator(); + while (iterator.hasNext()) { + Entry next = iterator.next(); + String mapKey = next.getKey(); + KQOvertimeCardBean kqOvertimeCardBean = next.getValue(); + String[] mapKeys = mapKey.split("_"); + if (mapKeys.length < 2) { + continue; + } + String realSplitDate = mapKeys[1]; + if (mapKeys.length == 3) { + splitDate = mapKeys[2]; + mapKey = resourceid + "_" + realSplitDate; + } + String change_key = realSplitDate + "_" + resourceid; + int changeType = Util.getIntValue("" + changeTypeMap.get(change_key), -1); + String changeType_key = realSplitDate + "_" + changeType; + int computingMode = Util.getIntValue("" + computingModeMap.get(changeType_key), -1); + + boolean isOk = true; +//把原来下面一个方法里的内容要抽出来,是因为存在如下的问题,如果我是跨天打卡,次日3点,加班归属点设置的是次日2点,2-3这部分的是属于第二天的,需要判断下第二天的加班方式是不是doComputingMode2,如果不是就需要去走对应的doComputingMode方法 + if (2 == computingMode) { + isOk = doComputingMode2WithCard(kqOvertimeCardBean, mapKey, resourceid, changeTypeMap, + dateFormatter, overtimeLogMap, splitDate, overRulesDetailMap, eventMap, kqTimesArrayComInfo, + restTimeMap, kqEventLogBiz, uuid, realSplitDate); + } else if (3 == computingMode) { + isOk = doComputingMode3WithCard(kqOvertimeCardBean, mapKey, resourceid, changeTypeMap, + dateFormatter, overtimeLogMap, splitDate, overRulesDetailMap, eventMap, kqTimesArrayComInfo, + restTimeMap, kqEventLogBiz, uuid, realSplitDate); + } else if (4 == computingMode) { + isOk = doComputingMode4WithCard(kqOvertimeCardBean, mapKey, resourceid, changeTypeMap, + dateFormatter, overtimeLogMap, splitDate, overRulesDetailMap, eventMap, kqTimesArrayComInfo, + restTimeMap, kqEventLogBiz, uuid, realSplitDate); + } + if (!isOk) { + continue; + } + } + } catch (Exception e) { + kqLog.info("加班生成数据报错:KQOverTimeRuleCalBiz:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } finally { + kqEventLogBiz.logDetailOvertimeMap(resourceid, overtimeLogMap, uuid); + kqEventLogBiz.logDetailEvent(resourceid, eventMap, uuid, "doComputingMode|对应的加班数据|key|" + key); + } + + } + fromDate = preFromDate.format(dateFormatter); + updateTiaoXiu(resourceid, fromDate, toDate); + } catch (Exception e) { + kqLog.info("加班生成数据报错:KQOverTimeRuleCalBiz:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + } + + + /** + * 更新调休 + * + * @param resourceid + * @param fromDate + * @param toDate + */ + public void updateTiaoXiu(String resourceid, String fromDate, String toDate) { + Timestamp updateDate = KQDateUtil.getUpdateTimeStamp(); + RecordSet recordSet = new RecordSet(); + //假期类型的缓存类 + try { + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String subCompanyId = resourceComInfo.getSubCompanyID(resourceid); + String departmentId = resourceComInfo.getDepartmentID(resourceid); + //[调休]的假期类型的ID + String leaveRulesId = ""; + //找到[调休]的假期类型ID + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + if (KQLeaveRulesBiz.isTiaoXiu(rulesComInfo.getId(), subCompanyId, departmentId, resourceid)) { + if ("1".equals(rulesComInfo.getIsEnable())) { + leaveRulesId = rulesComInfo.getId(); + break; + } + } + } + if ("".equals(leaveRulesId) || null == leaveRulesId) { + return; + } + + String sql = " select * from kq_balanceOfLeave " + + " where (isDelete is null or isDelete<>1) and resourceId=" + resourceid + + " and leaveRulesId=" + leaveRulesId + + " and effectiveDate>='" + fromDate + "' and effectiveDate<='" + toDate + "'" + + " order by belongYear asc,effectiveDate asc,id asc "; + recordSet.executeQuery(sql); + String all_tiaoxiuids = ""; + BigDecimal duration = new BigDecimal("0"); + while (recordSet.next()) { + //额外 + BigDecimal extraAmount = new BigDecimal(Util.null2s(recordSet.getString("extraAmount"), "0")); + //加班生成调休 + BigDecimal tiaoxiuAmount = new BigDecimal(Util.null2s(recordSet.getString("tiaoxiuamount"), "0")); + //已休 + BigDecimal usedAmount = new BigDecimal(Util.null2s(recordSet.getString("usedAmount"), "0")); + + if (extraAmount.add(tiaoxiuAmount).subtract(usedAmount).doubleValue() >= 0) { + continue; + } + String id = recordSet.getString("id"); + if (id.length() > 0 && Util.getIntValue(id) > 0) { + all_tiaoxiuids += "," + id; + duration = duration.add(extraAmount).add(tiaoxiuAmount).subtract(usedAmount); + } + } + duration = duration.abs(); + List updateList = new ArrayList(); + sql = " select * from kq_balanceOfLeave " + + " where (isDelete is null or isDelete<>1) and resourceId=" + resourceid + + " and leaveRulesId=" + leaveRulesId + + " and effectiveDate>='" + fromDate + "'" + + " order by belongYear asc,effectiveDate asc,id asc "; + recordSet.executeQuery(sql); + int total = recordSet.getCounts(); + int index = 0; + while (recordSet.next()) { + index++; + String id = recordSet.getString("id"); + //额外 + BigDecimal extraAmount = new BigDecimal(Util.null2s(recordSet.getString("extraAmount"), "0")); + //加班生成调休 + BigDecimal tiaoxiuAmount = new BigDecimal(Util.null2s(recordSet.getString("tiaoxiuamount"), "0")); + //已休 + BigDecimal usedAmount = new BigDecimal(Util.null2s(recordSet.getString("usedAmount"), "0")); + + if (extraAmount.add(tiaoxiuAmount).subtract(usedAmount).doubleValue() <= 0) { + continue; + } + BigDecimal temp = extraAmount.add(tiaoxiuAmount).subtract(usedAmount).subtract(duration); + /*该假期剩余假期余额不足以扣减,记录错误日志,退出方法*/ + if (index == total && temp.doubleValue() < 0) { + kqLog.info("该人员的该假期所有的剩余假期余额都不足以扣减。" + + "resourceId=" + resourceid + ",date=" + fromDate + ",ruleId=" + leaveRulesId + ",duration=" + duration + ",extraAmount=" + extraAmount.doubleValue() + ",usedAmount=" + usedAmount.doubleValue()); + String newUsedAmount = usedAmount.add(duration).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + ", update_time=? where id=" + id; + updateList.add(updateSql); + break; + } + if (temp.doubleValue() >= 0) { + String newUsedAmount = usedAmount.add(duration).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + ", update_time=? where id=" + id; + updateList.add(updateSql); + break; + } else { + duration = duration.add(usedAmount).subtract(extraAmount).subtract(tiaoxiuAmount); + String newUsedAmount = extraAmount.add(tiaoxiuAmount).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + ", update_time=? where id=" + id; + updateList.add(updateSql); + continue; + } + } + if (all_tiaoxiuids.length() > 0) { + all_tiaoxiuids = all_tiaoxiuids.substring(1); + updateList.add("update kq_balanceOfLeave set isDelete=1, update_time=? where id in (" + all_tiaoxiuids + ")"); + } + kqLog.info("updateList:" + updateList); + /*SQL操作批处理*/ + for (int i = 0; i < updateList.size(); i++) { + boolean flag = recordSet.executeUpdate(updateList.get(i), updateDate); + if (!flag) { + kqLog.info("刷新加班流程数据失败:数据库更新失败"); + return; + } + } + } catch (Exception e) { + recordSet.writeLog(e); + } + } + + /** + * 需审批,以打卡为准,取流程和打卡的交集 + */ + private void doComputingMode4(String resourceid, String splitDate, + DateTimeFormatter dateFormatter, Map changeTypeMap, + Map overRulesDetailMap, + Map> restTimeMap, Map computingModeMap, + KQTimesArrayComInfo kqTimesArrayComInfo, String main_uuid, + Map lsCheckInfoMaps) throws Exception { + String key = resourceid + "_" + splitDate; + //加班日志记录类 + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(resourceid, splitDate); + Map workTimeEntityLogMap = Maps.newHashMap(); + workTimeEntityLogMap.put("resourceid", resourceid); + workTimeEntityLogMap.put("splitDate", splitDate); + workTimeEntityLogMap.put("workTimeEntity", workTimeEntity); + KQOvertimeLogBiz kqEventLogBiz = new KQOvertimeLogBiz(); + String uuid = kqEventLogBiz.logDetailWorkTimeEntity(resourceid, workTimeEntityLogMap, main_uuid, "doComputingMode4|加班计算,需审批,以打卡为准,取流程和打卡的交集|key|" + key); + Map overtimeLogMap = Maps.newLinkedHashMap(); + + Map eventMap = Maps.newLinkedHashMap(); + + Iterator> iterator = lsCheckInfoMaps.entrySet().iterator(); + while (iterator.hasNext()) { + Entry next = iterator.next(); + String mapKey = next.getKey(); + KQOvertimeCardBean kqOvertimeCardBean = next.getValue(); + String[] mapKeys = mapKey.split("_"); + if (mapKeys.length != 2) { + continue; + } + String realSplitDate = mapKeys[1]; + String change_key = realSplitDate + "_" + resourceid; + int changeType = Util.getIntValue("" + changeTypeMap.get(change_key), -1); + String changeType_key = realSplitDate + "_" + changeType; + int computingMode = Util.getIntValue("" + computingModeMap.get(changeType_key), -1); + + boolean isOk = true; +//把原来下面一个方法里的内容要抽出来,是因为存在如下的问题,如果我是跨天打卡,次日3点,加班归属点设置的是次日2点,2-3这部分的是属于第二天的,需要判断下第二天的加班方式是不是doComputingMode2,如果不是就需要去走对应的doComputingMode方法 + if (2 == computingMode) { + isOk = doComputingMode2WithCard(kqOvertimeCardBean, mapKey, resourceid, changeTypeMap, + dateFormatter, overtimeLogMap, splitDate, overRulesDetailMap, eventMap, kqTimesArrayComInfo, + restTimeMap, kqEventLogBiz, uuid, realSplitDate); + } else if (3 == computingMode) { + isOk = doComputingMode3WithCard(kqOvertimeCardBean, mapKey, resourceid, changeTypeMap, + dateFormatter, overtimeLogMap, splitDate, overRulesDetailMap, eventMap, kqTimesArrayComInfo, + restTimeMap, kqEventLogBiz, uuid, realSplitDate); + } else if (4 == computingMode) { + isOk = doComputingMode4WithCard(kqOvertimeCardBean, mapKey, resourceid, changeTypeMap, + dateFormatter, overtimeLogMap, splitDate, overRulesDetailMap, eventMap, kqTimesArrayComInfo, + restTimeMap, kqEventLogBiz, uuid, realSplitDate); + } + if (!isOk) { + continue; + } + } + kqEventLogBiz.logDetailOvertimeMap(resourceid, overtimeLogMap, uuid); + kqEventLogBiz.logDetailEvent(resourceid, eventMap, uuid, "doComputingMode4|对应的加班流程数据|key|" + key); + + } + + /** + * 把获取打卡数据后处理的部分拆出来 + */ + private boolean doComputingMode4WithCard(KQOvertimeCardBean kqOvertimeCardBean, String mapKey, String resourceid, Map changeTypeMap, DateTimeFormatter dateFormatter, Map overtimeLogMap, + String splitDate, Map overRulesDetailMap, Map eventMap, KQTimesArrayComInfo kqTimesArrayComInfo, Map> restTimeMap, KQOvertimeLogBiz kqEventLogBiz, String uuid, + String realSplitDate) throws Exception { + + Map> splitBeanMaps = Maps.newHashMap(); + //获取加班流程数据 + getOverTimeFlowData(resourceid, realSplitDate, realSplitDate, splitBeanMaps, dateFormatter); + + String change_key = realSplitDate + "_" + resourceid; + int changeType = Util.getIntValue("" + changeTypeMap.get(change_key), -1); + String changeType_key = realSplitDate + "_" + changeType; + LocalDate localbelongDate = LocalDate.parse(realSplitDate); + LocalDate preLocalDate = localbelongDate.minusDays(1); + String preSplitDate = preLocalDate.format(dateFormatter); + String preChange_key = preSplitDate + "_" + resourceid; + int preChangeType = Util.getIntValue("" + changeTypeMap.get(preChange_key), -1); + String preChangeType_key = preSplitDate + "_" + preChangeType; + LocalDate nextLocalDate = localbelongDate.plusDays(1); + String nextSplitDate = nextLocalDate.format(dateFormatter); + String nextChange_key = nextSplitDate + "_" + resourceid; + int nextChangeType = Util.getIntValue("" + changeTypeMap.get(nextChange_key), -1); + String nextChangeType_key = nextSplitDate + "_" + nextChangeType; + + String changetypeName = 1 == changeType ? "节假日" : (2 == changeType ? "工作日" : (3 == changeType ? "休息日" : "异常")); + String changetypeLogInfo = change_key + "|changeType|" + changeType + "|" + changetypeName; + logOvertimeMap(overtimeLogMap, changetypeLogInfo, mapKey + "|" + "加班日期属性|changetypeLogInfo"); + + clearOvertimeTX(resourceid, realSplitDate, overtimeLogMap, splitDate); + logOvertimeMap(overtimeLogMap, kqOvertimeCardBean, mapKey + "|" + "打卡和上下班数据|KQOvertimeCardBean"); + + KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key); + if (kqOvertimeRulesDetailEntity == null) { + String overRuleInfo = "changeType_key:" + changeType_key + ":kqOvertimeRulesDetailEntity:" + kqOvertimeRulesDetailEntity; + logOvertimeMap(overtimeLogMap, overRuleInfo, mapKey + "|" + "加班规则为null|kqOvertimeRulesDetailEntity"); + return false; + } + int overtimeEnable = kqOvertimeRulesDetailEntity.getOvertimeEnable(); + if (overtimeEnable != 1) { + String overtimeEnableInfo = "overtimeEnable:" + overtimeEnable; + logOvertimeMap(overtimeLogMap, overtimeEnableInfo, mapKey + "|" + "未开启加班规则|overtimeEnable"); + return false; + } + + if (kqOvertimeCardBean != null) { + + int[] initArrays = kqTimesArrayComInfo.getInitArr(); + List> hasOverTime4SignList = Lists.newArrayList(); + getHasOverTimeData(resourceid, realSplitDate, hasOverTime4SignList); + Map signinoffMap = buildOvertimeCard(kqOvertimeCardBean, resourceid, realSplitDate, kqTimesArrayComInfo, restTimeMap, changeType_key, initArrays, hasOverTime4SignList, + overRulesDetailMap, true, overtimeLogMap, preChangeType_key, nextChangeType_key); + logOvertimeMap(overtimeLogMap, signinoffMap, mapKey + "|" + "获取上下班打卡数据|signinoffMap"); + + String signinTime = Util.null2String(signinoffMap.get("signinTime")); + String signoutTime = Util.null2String(signinoffMap.get("signoutTime")); + String signinDate = Util.null2String(signinoffMap.get("signinDate")); + String signoutDate = Util.null2String(signinoffMap.get("signoutDate")); + int signinTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signinTime); + int signoutTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signoutTime); + + if (signinTimeIndex < signoutTimeIndex) { + //先覆盖打卡 打卡区间都是1 + int over_count = kqTimesArrayComInfo.getCnt(initArrays, signinTimeIndex, signoutTimeIndex, 1); + String overCountLogInfo = "signinTimeIndex:" + signinTimeIndex + ":signoutTimeIndex:" + signoutTimeIndex + ":over_count:" + over_count; + logOvertimeMap(overtimeLogMap, overCountLogInfo, mapKey + "|" + "打卡区间,得到打卡时长|over_count"); + if (over_count > 0) { + int restTimeType = 1; + String kqOvertimeRulesDetailEntityLogInfo = kqOvertimeRulesDetailEntity == null ? "" : JSON.toJSONString(kqOvertimeRulesDetailEntity); + logOvertimeMap(overtimeLogMap, kqOvertimeRulesDetailEntityLogInfo, mapKey + "|具体这个人这一天对应的加班规则|KQOvertimeRulesDetailEntity"); + int minimumLen = -1; + if (kqOvertimeRulesDetailEntity != null) { + minimumLen = kqOvertimeRulesDetailEntity.getMinimumLen(); + if (over_count < minimumLen) { + String minInfo = "over_count:" + over_count + ":minimumLen:" + minimumLen; + logOvertimeMap(overtimeLogMap, minInfo, mapKey + "|打卡时长小于最小加班时长|over_count splitBeans = splitBeanMaps.get(mapKey); + String flowinfo = ""; + if (splitBeans != null && !splitBeans.isEmpty()) { + flowinfo = JSON.toJSONString(splitBeans, SerializerFeature.DisableCheckSpecialChar, SerializerFeature.DisableCircularReferenceDetect); + } + eventMap.put(mapKey + "|" + "加班流程数据|flowinfo", flowinfo); + + if (splitBeans == null || splitBeans.isEmpty()) { + return false; + } + + for (int m = 0; m < splitBeans.size(); m++) { + SplitBean splitBean = splitBeans.get(m); + String dataid = splitBean.getDataId(); + String detailid = splitBean.getDetailId(); + String flow_fromdate = splitBean.getFromDate(); + String flow_fromtime = splitBean.getFromTime(); + String flow_todate = splitBean.getToDate(); + String flow_totime = splitBean.getToTime(); + String fromdatedb = splitBean.getFromdatedb(); + String fromtimedb = splitBean.getFromtimedb(); + String todatedb = splitBean.getTodatedb(); + String totimedb = splitBean.getTotimedb(); + String requestid = splitBean.getRequestId(); + double d_mins = splitBean.getD_Mins(); + if (d_mins <= 0) { + continue; + } + String flow_key = mapKey + "|" + "flow_fromdate|" + flow_fromdate + "|flow_todate|" + flow_todate + + "|flow_fromtime|" + flow_fromtime + "|flow_totime|" + flow_totime; + //如果打卡数据有了,再拿流程数据去覆盖,得到有效的打卡区间,这个区间肯定已经是去除了上下班时间和休息时间还有重复打卡的部分 + List cross_time_list = Lists.newArrayList(); +// cross_time_list里存的是排除了工作时间的打卡段,找到1表示找到打卡开始的点了,找到-2表示找到打卡结束的点了 + get_cross_time_list(cross_time_list, initArrays, signinTimeIndex, signoutTimeIndex, 1, -2); + logOvertimeMap(overtimeLogMap, cross_time_list, flow_key + "|cross_time_list"); + int[] initArrays_flow = Arrays.copyOfRange(initArrays, 0, initArrays.length); + if (flow_fromdate.compareTo(realSplitDate) > 0) { + flow_fromtime = kqTimesArrayComInfo.turn24to48Time(flow_fromtime); + } + if (flow_todate.compareTo(realSplitDate) > 0) { + flow_totime = kqTimesArrayComInfo.turn24to48Time(flow_totime); + } + int flow_fromIndex = kqTimesArrayComInfo.getArrayindexByTimes(flow_fromtime); + int flow_toIndex = kqTimesArrayComInfo.getArrayindexByTimes(flow_totime); + //在已经打卡的区间1上覆盖2,那么在有效打卡范围内是2的就是交集的部分 + Arrays.fill(initArrays_flow, flow_fromIndex, flow_toIndex, 2); + + int across_mins = 0; + for (int i = 0; i < cross_time_list.size(); ) { + int cross_fromtime_index = cross_time_list.get(i); + int cross_totime_index = cross_time_list.get(i + 1); + //前面打卡区间段已经都被流程给覆盖了,所以取获取打卡区间段内有多少流程的标识2,就是交叉部分了 + int flow_count = kqTimesArrayComInfo.getCnt(initArrays_flow, cross_fromtime_index, cross_totime_index, 2); + logOvertimeMap(overtimeLogMap, flow_count, flow_key + "|取打卡和流程相交的时长|flow_count"); + + if (flow_count > 0) { + List flow_cross_time_list = Lists.newArrayList(); + // 找到2表示找到流程开始的点了,找到1表示找到流程结束的点了 + get_cross_time_list(flow_cross_time_list, initArrays_flow, cross_fromtime_index, cross_totime_index, 2, 1); + + logOvertimeMap(overtimeLogMap, flow_cross_time_list, flow_key + "|取打卡和流程相交的区间|flow_cross_time_list"); + for (int j = 0; j < flow_cross_time_list.size(); ) { + int flow_cross_fromtime_index = flow_cross_time_list.get(j); + int flow_cross_totime_index = flow_cross_time_list.get(j + 1); + + int mins = flow_cross_totime_index - flow_cross_fromtime_index; + if (mins <= 0) { + String crossInfo = "flow_cross_fromtime_index:" + flow_cross_fromtime_index + ":flow_cross_totime_index:" + flow_cross_totime_index + ":mins:" + mins; + logOvertimeMap(overtimeLogMap, crossInfo, flow_key + "|打卡时长小于最小加班时长|crossInfo"); + continue; + } + across_mins += mins; + + String flow_cross_key = "加班计算区间|" + kqTimesArrayComInfo.getTimesByArrayindex(flow_cross_fromtime_index) + "-" + kqTimesArrayComInfo.getTimesByArrayindex(flow_cross_totime_index); + logOvertimeMap(overtimeLogMap, mins, flow_cross_key + "|原始加班区间生成的加班时长|mins"); + + j = j + 2; + } + } else { + + } + i = i + 2; + } + + if (kqOvertimeRulesDetailEntity != null) { + //我这个方法是针对每次生成的加班数据做排除休息时长的处理 + restTimeType = kqOvertimeRulesDetailEntity.getRestTimeType(); + if (restTimeType == 2) { + across_mins = new KQOverTimeFlowBiz().handle_restlength(across_mins, restTimeMap, changeType_key); + } + } + int card_mins = over_count; + int maxMumLen = kqOvertimeRulesDetailEntity.getMaxmumLen(); + if (across_mins > maxMumLen) { + across_mins = maxMumLen; + } + double double_mins = getD_MinsByUnit((1.0 * across_mins)); + across_mins = (int) double_mins; + if (across_mins <= 0) { + logOvertimeMap(overtimeLogMap, across_mins, flow_key + "|经过单位换算之后时长为0|across_mins"); + continue; + } + if (across_mins < minimumLen) { + String minInfo = "across_mins:" + across_mins + ":minimumLen:" + minimumLen; + logOvertimeMap(overtimeLogMap, minInfo, flow_key + "|打卡时长小于最小加班时长|over_count otherParam = Maps.newHashMap(); + otherParam.put("overtime_type", overtime_type); + otherParam.put("changeType", String.valueOf(changeType)); + int paidLeaveEnableType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableType(); + if (2 == paidLeaveEnableType) { + logOvertimeMap(overtimeLogMap, overtime_type, flow_key + "|关联调休与否来自于流程选择,加班类型下拉框值|overtime_type"); + } + + int paidLeaveEnable = getPaidLeaveEnable(kqOvertimeRulesDetailEntity, overtime_type); + + otherParam.put("overtimeLogMap", overtimeLogMap); + logOvertimeMap(overtimeLogMap, across_mins, flow_key + "|最终生成的加班分钟数|overtime_mins"); + tiaoxiuId = KQBalanceOfLeaveBiz.addExtraAmountByDis5(resourceid, realSplitDate, across_mins + "", "0", workingHours, requestid, "1", realSplitDate, otherParam); + if (Util.getIntValue(tiaoxiuId) > 0) { + kqLog.info("doComputingMode4 生成调休成功,调休id:" + tiaoxiuId + ":resourceid:" + resourceid + ":realSplitDate:" + realSplitDate); + } else { + kqLog.info("doComputingMode4 生成调休失败,调休id:" + tiaoxiuId + ":resourceid:" + resourceid + ":realSplitDate:" + realSplitDate); + } + logOvertimeMap(overtimeLogMap, tiaoxiuId, flow_key + "|最终生成的调休id|tiaoxiuId"); + + String flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate," + + "workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid,fromdatedb,fromtimedb,todatedb,totimedb,flow_mins,card_mins,ori_belongdate,flow_dataid,create_time,update_time,creator)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + if (rs.getDBType().equals("postgresql")) { + flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate," + + "workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid,fromdatedb,fromtimedb,todatedb,totimedb,flow_mins,card_mins,ori_belongdate,flow_dataid,create_time,update_time,creator)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?::timestamp,?::timestamp,?) "; + } + signinTime = kqTimesArrayComInfo.turn48to24Time(signinTime); + signoutTime = kqTimesArrayComInfo.turn48to24Time(signoutTime); + if (signinTime.length() == 5) { + signinTime = signinTime + ":00"; + } + if (signoutTime.length() == 5) { + signoutTime = signoutTime + ":00"; + } + Long cur = System.currentTimeMillis(); + Timestamp date = new Timestamp(cur); + boolean isUp = rs.executeUpdate(flow_overtime_sql, requestid, resourceid, signinDate, signinTime, signoutDate, signoutTime, across_mins, "", realSplitDate, + "", unit, changeType, paidLeaveEnable, computingMode, tiaoxiuId, overtime_uuid, fromdatedb, fromtimedb, todatedb, totimedb, d_mins, card_mins, splitDate, flow_dataid, date, date, Util.getIntValue(resourceid)); + + String overtimeid = get_overtime_uuid(overtime_uuid); + kqEventLogBiz.updateOvertimeId(uuid, overtimeid); + } + } else { + //有打卡没有流程 + logOvertimeMap(overtimeLogMap, mapKey, mapKey + "|" + "加班流程为空"); + } + } else { + logOvertimeMap(overtimeLogMap, overCountLogInfo, mapKey + "|" + "打卡数据时长为0"); + } + } else { + String overCountLogInfo = "signinTimeIndex:" + signinTimeIndex + ":signoutTimeIndex:" + signoutTimeIndex; + logOvertimeMap(overtimeLogMap, overCountLogInfo, mapKey + "|" + "打卡数据异常"); + } + } else { + logOvertimeMap(overtimeLogMap, "打卡数据KQOvertimeCardBean为null", mapKey + "|" + "打卡和上下班数据|KQOvertimeCardBean"); + } + return true; + } + + /** + * 得到有效的打卡区间,这个区间肯定已经是去除了上下班时间和休息时间还有重复打卡的部分 + * + * @param cross_time_list + * @param initArrays + * @param fromIndex + * @param toIndex + * @param cross_from_index + * @param cross_to_index + */ + public void get_cross_time_list(List cross_time_list, int[] initArrays, + int fromIndex, int toIndex, int cross_from_index, int cross_to_index) { + for (int i = fromIndex; i < toIndex + 1; i++) { + if (cross_time_list.isEmpty()) { + if (initArrays[i] == cross_from_index) { + cross_time_list.add(i); + } + } else { + if (cross_time_list.size() % 2 != 0) { + if (initArrays[i] == cross_to_index) { + cross_time_list.add(i); + } + } else { + if (initArrays[i] == cross_from_index) { + cross_time_list.add(i); + } + } + } + } + if (cross_time_list.size() % 2 != 0) { + cross_time_list.add(toIndex); + } + } + + /** + * 处理加班方式是 无需审批,根据打卡时间计算加班时长 + */ + private void doComputingMode3(String resourceid, String splitDate, + DateTimeFormatter dateFormatter, Map changeTypeMap, + Map overRulesDetailMap, + Map> restTimeMap, Map computingModeMap, + KQTimesArrayComInfo kqTimesArrayComInfo, String main_uuid, + Map lsCheckInfoMaps) throws Exception { + String key = resourceid + "_" + splitDate; + //加班日志记录类 + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(resourceid, splitDate); + Map workTimeEntityLogMap = Maps.newHashMap(); + workTimeEntityLogMap.put("resourceid", resourceid); + workTimeEntityLogMap.put("splitDate", splitDate); + workTimeEntityLogMap.put("workTimeEntity", workTimeEntity); + KQOvertimeLogBiz kqEventLogBiz = new KQOvertimeLogBiz(); + String uuid = kqEventLogBiz.logDetailWorkTimeEntity(resourceid, workTimeEntityLogMap, main_uuid, "doComputingMode3|加班计算,无需审批,根据打卡时间计算加班时长|key|" + key); + Map overtimeLogMap = Maps.newLinkedHashMap(); + + Map eventMap = Maps.newHashMap(); + kqEventLogBiz.logDetailEvent(resourceid, eventMap, uuid, "doComputingMode3|对应的打卡数据|key|" + key); + + Iterator> iterator = lsCheckInfoMaps.entrySet().iterator(); + while (iterator.hasNext()) { + Entry next = iterator.next(); + String mapKey = next.getKey(); + KQOvertimeCardBean kqOvertimeCardBean = next.getValue(); + String[] mapKeys = mapKey.split("_"); + if (mapKeys.length != 2) { + continue; + } + String realSplitDate = mapKeys[1]; + String change_key = realSplitDate + "_" + resourceid; + int changeType = Util.getIntValue("" + changeTypeMap.get(change_key), -1); + String changeType_key = realSplitDate + "_" + changeType; + int computingMode = Util.getIntValue("" + computingModeMap.get(changeType_key), -1); + + boolean isOk = true; +//把原来下面一个方法里的内容要抽出来,是因为存在如下的问题,如果我是跨天打卡,次日3点,加班归属点设置的是次日2点,2-3这部分的是属于第二天的,需要判断下第二天的加班方式是不是doComputingMode2,如果不是就需要去走对应的doComputingMode方法 + if (2 == computingMode) { + isOk = doComputingMode2WithCard(kqOvertimeCardBean, mapKey, resourceid, changeTypeMap, + dateFormatter, overtimeLogMap, splitDate, overRulesDetailMap, eventMap, kqTimesArrayComInfo, + restTimeMap, kqEventLogBiz, uuid, realSplitDate); + } else if (3 == computingMode) { + isOk = doComputingMode3WithCard(kqOvertimeCardBean, mapKey, resourceid, changeTypeMap, + dateFormatter, overtimeLogMap, splitDate, overRulesDetailMap, eventMap, kqTimesArrayComInfo, + restTimeMap, kqEventLogBiz, uuid, realSplitDate); + } else if (4 == computingMode) { + isOk = doComputingMode4WithCard(kqOvertimeCardBean, mapKey, resourceid, changeTypeMap, + dateFormatter, overtimeLogMap, splitDate, overRulesDetailMap, eventMap, kqTimesArrayComInfo, + restTimeMap, kqEventLogBiz, uuid, realSplitDate); + } + if (!isOk) { + continue; + } + } + kqEventLogBiz.logDetailOvertimeMap(resourceid, overtimeLogMap, uuid); + kqEventLogBiz.logDetailEvent(resourceid, eventMap, uuid, "doComputingMode3|对应的加班流程数据|key|" + key); + + + } + + /** + * 把获取打卡数据后处理的部分拆出来 + */ + private boolean doComputingMode3WithCard(KQOvertimeCardBean kqOvertimeCardBean, String mapKey, String resourceid, Map changeTypeMap, DateTimeFormatter dateFormatter, Map overtimeLogMap, + String splitDate, Map overRulesDetailMap, Map eventMap, KQTimesArrayComInfo kqTimesArrayComInfo, Map> restTimeMap, KQOvertimeLogBiz kqEventLogBiz, String uuid, + String realSplitDate) throws Exception { + String change_key = realSplitDate + "_" + resourceid; + int changeType = Util.getIntValue("" + changeTypeMap.get(change_key), -1); + String changeType_key = realSplitDate + "_" + changeType; + LocalDate localbelongDate = LocalDate.parse(realSplitDate); + LocalDate preLocalDate = localbelongDate.minusDays(1); + String preSplitDate = preLocalDate.format(dateFormatter); + String preChange_key = preSplitDate + "_" + resourceid; + int preChangeType = Util.getIntValue("" + changeTypeMap.get(preChange_key), -1); + String preChangeType_key = preSplitDate + "_" + preChangeType; + LocalDate nextLocalDate = localbelongDate.plusDays(1); + String nextSplitDate = nextLocalDate.format(dateFormatter); + String nextChange_key = nextSplitDate + "_" + resourceid; + int nextChangeType = Util.getIntValue("" + changeTypeMap.get(nextChange_key), -1); + String nextChangeType_key = nextSplitDate + "_" + nextChangeType; + + String changetypeName = 1 == changeType ? "节假日" : (2 == changeType ? "工作日" : (3 == changeType ? "休息日" : "异常")); + String changetypeLogInfo = change_key + "|changeType|" + changeType + "|" + changetypeName; + logOvertimeMap(overtimeLogMap, changetypeLogInfo, "加班日期属性|changetypeLogInfo"); + + clearOvertimeTX(resourceid, realSplitDate, overtimeLogMap, splitDate); + + logOvertimeMap(overtimeLogMap, kqOvertimeCardBean, "打卡和上下班数据|KQOvertimeCardBean"); + + KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key); + if (kqOvertimeRulesDetailEntity == null) { + String overRuleInfo = "changeType_key:" + changeType_key + ":kqOvertimeRulesDetailEntity:" + kqOvertimeRulesDetailEntity; + logOvertimeMap(overtimeLogMap, overRuleInfo, mapKey + "|" + "加班规则为null|kqOvertimeRulesDetailEntity"); + return false; + } + int overtimeEnable = kqOvertimeRulesDetailEntity.getOvertimeEnable(); + if (overtimeEnable != 1) { + String overtimeEnableInfo = "overtimeEnable:" + overtimeEnable; + logOvertimeMap(overtimeLogMap, overtimeEnableInfo, mapKey + "|" + "未开启加班规则|overtimeEnable"); + return false; + } + if (kqOvertimeCardBean != null) { + + int[] initArrays = kqTimesArrayComInfo.getInitArr(); + Map signinoffMap = buildOvertimeCard(kqOvertimeCardBean, resourceid, realSplitDate, kqTimesArrayComInfo, restTimeMap, changeType_key, initArrays, Lists.newArrayList(), overRulesDetailMap, + true, overtimeLogMap, preChangeType_key, nextChangeType_key); + logOvertimeMap(overtimeLogMap, signinoffMap, "获取上下班打卡数据|signinoffMap"); + + String signinTime = Util.null2String(signinoffMap.get("signinTime")); + String signoutTime = Util.null2String(signinoffMap.get("signoutTime")); + String signinDate = Util.null2String(signinoffMap.get("signinDate")); + String signoutDate = Util.null2String(signinoffMap.get("signoutDate")); + int signinTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signinTime); + int signoutTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signoutTime); + String flow_cross_key = mapKey + "|" + "加班计算区间|" + signinTime + "-" + signoutTime; + + if (signinTimeIndex < signoutTimeIndex) { + int over_count = kqTimesArrayComInfo.getCnt(initArrays, signinTimeIndex, signoutTimeIndex, 1); + String countLogInfo = "signinTimeIndex:" + signinTimeIndex + ":signoutTimeIndex:" + signoutTimeIndex + ":over_count:" + over_count; + logOvertimeMap(overtimeLogMap, countLogInfo, mapKey + "|" + "打卡区间,得到打卡时长|over_count"); + if (over_count > 0) { + //表示加班打卡是存在的 + int restTimeType = 1; + if (kqOvertimeRulesDetailEntity != null) { + int minimumLen = kqOvertimeRulesDetailEntity.getMinimumLen(); + if (over_count < minimumLen) { + return false; + } + logOvertimeMap(overtimeLogMap, JSON.toJSONString(kqOvertimeRulesDetailEntity), mapKey + "|" + "加班规则|KQOvertimeRulesDetailEntity"); + //我这个方法是针对每次生成的加班数据做排除休息时长的处理 + restTimeType = kqOvertimeRulesDetailEntity.getRestTimeType(); + if (restTimeType == 2) { + over_count = new KQOverTimeFlowBiz().handle_restlength(over_count, restTimeMap, changeType_key); + } + } + if (over_count <= 0) { + logOvertimeMap(overtimeLogMap, "没有打卡数据", mapKey + "|" + "打卡时长|over_count"); + return false; + } + logOvertimeMap(overtimeLogMap, over_count, mapKey + "|" + "经历过休息时间之后的加班时长|over_rest_count"); + + int mins = over_count; + int maxMumLen = kqOvertimeRulesDetailEntity.getMaxmumLen(); + if (mins > maxMumLen) { + mins = maxMumLen; + } + double double_mins = getD_MinsByUnit((1.0 * mins)); + mins = (int) double_mins; + + RecordSet rs = new RecordSet(); + String overtime_uuid = UUID.randomUUID().toString(); + String tiaoxiuId = ""; + String workingHours = ""; + int computingMode = 3; + + Map otherParam = Maps.newHashMap(); + otherParam.put("changeType", String.valueOf(changeType)); + int unit = KQOvertimeRulesBiz.getMinimumUnit(); + + int paidLeaveEnable = kqOvertimeRulesDetailEntity.getPaidLeaveEnable(); + int paidLeaveEnableType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableType(); + + logOvertimeMap(overtimeLogMap, mins, flow_cross_key + "|最终生成的加班分钟数|overtime_mins"); + tiaoxiuId = KQBalanceOfLeaveBiz.addExtraAmountByDis5(resourceid, realSplitDate, mins + "", "0", workingHours, "", "", realSplitDate, otherParam); + if (Util.getIntValue(tiaoxiuId) > 0) { + kqLog.info("doComputingMode3 生成调休成功,调休id:" + tiaoxiuId + ":resourceid:" + resourceid + ":realSplitDate:" + realSplitDate); + } else { + kqLog.info("doComputingMode3 生成调休失败,调休id:" + tiaoxiuId + ":resourceid:" + resourceid + ":realSplitDate:" + realSplitDate); + } + Long cur = System.currentTimeMillis(); + Timestamp date = new Timestamp(cur); + + String flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate," + + "workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid,fromdatedb,fromtimedb,todatedb,totimedb,flow_mins,ori_belongdate,create_time,update_time,creator)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + if (rs.getDBType().equals("postgresql")) { + flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate," + + "workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid,fromdatedb,fromtimedb,todatedb,totimedb,flow_mins,ori_belongdate,create_time,update_time,creator)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?::timestamp,?::timestamp,?) "; + } + signinTime = kqTimesArrayComInfo.turn48to24Time(signinTime); + signoutTime = kqTimesArrayComInfo.turn48to24Time(signoutTime); + boolean isUp = rs.executeUpdate(flow_overtime_sql, "", resourceid, signinDate, signinTime, signoutDate, signoutTime, mins, "", realSplitDate, + "", unit, changeType, paidLeaveEnable, computingMode, tiaoxiuId, overtime_uuid, "", "", "", "", 0, splitDate, date, date, Util.getIntValue(resourceid)); + + String overtimeid = get_overtime_uuid(overtime_uuid); + kqEventLogBiz.updateOvertimeId(uuid, overtimeid); + } + } else { + logOvertimeMap(overtimeLogMap, "打卡区间不正确|" + flow_cross_key, mapKey + "|" + "打卡区间,得到打卡时长|over_count"); + } + } else { + logOvertimeMap(overtimeLogMap, "打卡数据KQOvertimeCardBean为null", mapKey + "|" + "打卡和上下班数据|KQOvertimeCardBean"); + } + return true; + } + + /** + * 获取生成的加班id + * + * @param overtime_uuid + * @return + */ + public String get_overtime_uuid(String overtime_uuid) { + RecordSet rs = new RecordSet(); + String sql = "select * from kq_flow_overtime where uuid='" + overtime_uuid + "' "; + rs.executeQuery(sql); + if (rs.next()) { + return rs.getString("id"); + } + return ""; + } + + /** + * 按加班的时间段设置转调休时长 + * + * @param kqOvertimeRulesDetailEntity + * @return + */ + public List get_timepointList(KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity) { + List timepointList = Lists.newArrayList(); + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + int ruleDetailid = kqOvertimeRulesDetailEntity.getId(); + int paidLeaveEnableType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableType(); + if (1 == paidLeaveEnableType) { + int paidLeaveEnableDefaultType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableDefaultType(); + + if (paidLeaveEnableDefaultType == 3) { + Map> balanceTimethDetailMap = kqOvertimeRulesBiz.getBalanceTimeDetailMap(ruleDetailid); + if (balanceTimethDetailMap != null && !balanceTimethDetailMap.isEmpty()) { + timepointList = balanceTimethDetailMap.get("timepointList"); + } + } + } else if (2 == paidLeaveEnableType) { + int paidLeaveEnableFlowType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableFlowType(); + + if (paidLeaveEnableFlowType == 3) { + Map> balanceTimethDetailMap = kqOvertimeRulesBiz.getBalanceTimeDetailMap(ruleDetailid); + if (balanceTimethDetailMap != null && !balanceTimethDetailMap.isEmpty()) { + timepointList = balanceTimethDetailMap.get("timepointList"); + } + } + } + return timepointList; + } + + /** + * 加班补偿规则里,按照加班时段补偿方式需要获取每一个时间区间内的加班时长 + * + * @param timepointList + * @param overtimeBalanceTimeBeans + * @param kqTimesArrayComInfo + * @param initArrays + * @param toTime_index + * @param fromTime_index + * @param arrayIndexValue + */ + public void get_overtimeBalanceTimeBeans(List timepointList, + List overtimeBalanceTimeBeans, + KQTimesArrayComInfo kqTimesArrayComInfo, int[] initArrays, + int toTime_index, int fromTime_index, int arrayIndexValue) { + //如果 [按加班的时间段设置转调休时长] 是这种方式,还需要根据时间点来判断时间区间内的加班时长,艹 + for (int k = 0; k < timepointList.size(); k++) { + OvertimeBalanceTimeBean overtimeBalanceTimeBean = new OvertimeBalanceTimeBean(); + String start_pointtime = timepointList.get(k); + int start_pointtime_index = kqTimesArrayComInfo.getArrayindexByTimes(start_pointtime); + if (k == 0) { + if (start_pointtime_index > fromTime_index) { + int timepoint_curMins = kqTimesArrayComInfo.getCnt(initArrays, fromTime_index, start_pointtime_index, arrayIndexValue); + OvertimeBalanceTimeBean ori_overtimeBalanceTimeBean = new OvertimeBalanceTimeBean(); + ori_overtimeBalanceTimeBean.setTimepoint(kqTimesArrayComInfo.getTimesByArrayindex(start_pointtime_index)); + ori_overtimeBalanceTimeBean.setTimepoint_start(kqTimesArrayComInfo.getTimesByArrayindex(fromTime_index)); + ori_overtimeBalanceTimeBean.setTimepoint_end(kqTimesArrayComInfo.getTimesByArrayindex(start_pointtime_index)); + ori_overtimeBalanceTimeBean.setTimepoint_mins(timepoint_curMins); + ori_overtimeBalanceTimeBean.setNeedTX(false); + overtimeBalanceTimeBeans.add(ori_overtimeBalanceTimeBean); + } + } + if (start_pointtime_index > toTime_index) { + continue; + } + overtimeBalanceTimeBean.setList_index(k); + int start_index = -1; + int end_index = -1; + if (k == timepointList.size() - 1) { + start_index = start_pointtime_index; + end_index = toTime_index; + } else { + if (k + 1 < timepointList.size()) { + String end_pointtime = timepointList.get(k + 1); + start_index = start_pointtime_index; + end_index = kqTimesArrayComInfo.getArrayindexByTimes(end_pointtime); + } + } + if (start_index < end_index) { + int timepoint_curMins = kqTimesArrayComInfo.getCnt(initArrays, start_index, end_index, arrayIndexValue); + overtimeBalanceTimeBean.setTimepoint(kqTimesArrayComInfo.getTimesByArrayindex(start_index)); + overtimeBalanceTimeBean.setTimepoint_start(kqTimesArrayComInfo.getTimesByArrayindex(start_index)); + overtimeBalanceTimeBean.setTimepoint_end(kqTimesArrayComInfo.getTimesByArrayindex(end_index)); + overtimeBalanceTimeBean.setTimepoint_mins(timepoint_curMins); + overtimeBalanceTimeBean.setNeedTX(true); + overtimeBalanceTimeBeans.add(overtimeBalanceTimeBean); + } + } + } + + /** + * 处理加班方式是 需审批,以打卡为准,但是不能超过审批时长的加班时长 + */ + private void doComputingMode2(String resourceid, String splitDate, + DateTimeFormatter dateFormatter, Map changeTypeMap, + Map overRulesDetailMap, + Map> restTimeMap, Map computingModeMap, + KQTimesArrayComInfo kqTimesArrayComInfo, String main_uuid, + Map lsCheckInfoMaps) throws Exception { + String key = resourceid + "_" + splitDate; + //加班日志记录类 + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(resourceid, splitDate); + Map workTimeEntityLogMap = Maps.newHashMap(); + workTimeEntityLogMap.put("resourceid", resourceid); + workTimeEntityLogMap.put("splitDate", splitDate); + workTimeEntityLogMap.put("workTimeEntity", workTimeEntity); + KQOvertimeLogBiz kqEventLogBiz = new KQOvertimeLogBiz(); + String uuid = kqEventLogBiz.logDetailWorkTimeEntity(resourceid, workTimeEntityLogMap, main_uuid, "doComputingMode2|加班计算,需审批,以打卡为准,但是不能超过审批时长的加班时长|key|" + key); + Map overtimeLogMap = Maps.newLinkedHashMap(); + + Map eventMap = Maps.newHashMap(); + + Iterator> iterator = lsCheckInfoMaps.entrySet().iterator(); + while (iterator.hasNext()) { + Entry next = iterator.next(); + String mapKey = next.getKey(); + KQOvertimeCardBean kqOvertimeCardBean = next.getValue(); + String[] mapKeys = mapKey.split("_"); + if (mapKeys.length != 2) { + continue; + } + String realSplitDate = mapKeys[1]; + String change_key = realSplitDate + "_" + resourceid; + int changeType = Util.getIntValue("" + changeTypeMap.get(change_key), -1); + String changeType_key = realSplitDate + "_" + changeType; + int computingMode = Util.getIntValue("" + computingModeMap.get(changeType_key), -1); + + boolean isOk = true; +//把原来下面一个方法里的内容要抽出来,是因为存在如下的问题,如果我是跨天打卡,次日3点,加班归属点设置的是次日2点,2-3这部分的是属于第二天的,需要判断下第二天的加班方式是不是doComputingMode2,如果不是就需要去走对应的doComputingMode方法 + if (2 == computingMode) { + isOk = doComputingMode2WithCard(kqOvertimeCardBean, mapKey, resourceid, changeTypeMap, + dateFormatter, overtimeLogMap, splitDate, overRulesDetailMap, eventMap, kqTimesArrayComInfo, + restTimeMap, kqEventLogBiz, uuid, realSplitDate); + } else if (3 == computingMode) { + isOk = doComputingMode3WithCard(kqOvertimeCardBean, mapKey, resourceid, changeTypeMap, + dateFormatter, overtimeLogMap, splitDate, overRulesDetailMap, eventMap, kqTimesArrayComInfo, + restTimeMap, kqEventLogBiz, uuid, realSplitDate); + } else if (4 == computingMode) { + isOk = doComputingMode4WithCard(kqOvertimeCardBean, mapKey, resourceid, changeTypeMap, + dateFormatter, overtimeLogMap, splitDate, overRulesDetailMap, eventMap, kqTimesArrayComInfo, + restTimeMap, kqEventLogBiz, uuid, realSplitDate); + } + if (!isOk) { + continue; + } + } + kqEventLogBiz.logDetailOvertimeMap(resourceid, overtimeLogMap, uuid); + kqEventLogBiz.logDetailEvent(resourceid, eventMap, uuid, "doComputingMode2|对应的加班流程数据|key|" + key); + + } + + /** + * 把获取打卡数据后处理的部分拆出来 + */ + public boolean doComputingMode2WithCard(KQOvertimeCardBean kqOvertimeCardBean, String mapKey, + String resourceid, Map changeTypeMap, DateTimeFormatter dateFormatter, + Map overtimeLogMap, String splitDate, + Map overRulesDetailMap, + Map eventMap, KQTimesArrayComInfo kqTimesArrayComInfo, + Map> restTimeMap, KQOvertimeLogBiz kqEventLogBiz, String uuid, + String realSplitDate) throws Exception { + String change_key = realSplitDate + "_" + resourceid; + int changeType = Util.getIntValue("" + changeTypeMap.get(change_key), -1); + String changeType_key = realSplitDate + "_" + changeType; + + Map> splitBeanMaps = Maps.newHashMap(); + //获取加班流程数据 + getOverTimeFlowData(resourceid, realSplitDate, realSplitDate, splitBeanMaps, dateFormatter); + LocalDate localbelongDate = LocalDate.parse(realSplitDate); + LocalDate preLocalDate = localbelongDate.minusDays(1); + String preSplitDate = preLocalDate.format(dateFormatter); + String preChange_key = preSplitDate + "_" + resourceid; + int preChangeType = Util.getIntValue("" + changeTypeMap.get(preChange_key), -1); + String preChangeType_key = preSplitDate + "_" + preChangeType; + LocalDate nextLocalDate = localbelongDate.plusDays(1); + String nextSplitDate = nextLocalDate.format(dateFormatter); + String nextChange_key = nextSplitDate + "_" + resourceid; + int nextChangeType = Util.getIntValue("" + changeTypeMap.get(nextChange_key), -1); + String nextChangeType_key = nextSplitDate + "_" + nextChangeType; + + String changetypeName = 1 == changeType ? "节假日" : (2 == changeType ? "工作日" : (3 == changeType ? "休息日" : "异常")); + String changetypeLogInfo = change_key + "|changeType|" + changeType + "|" + changetypeName; + logOvertimeMap(overtimeLogMap, changetypeLogInfo, mapKey + "|" + "加班日期属性|changetypeLogInfo"); + + clearOvertimeTX(resourceid, realSplitDate, overtimeLogMap, splitDate); + logOvertimeMap(overtimeLogMap, kqOvertimeCardBean, mapKey + "|" + "打卡和上下班数据|KQOvertimeCardBean"); + + KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key); + if (kqOvertimeRulesDetailEntity == null) { + String overRuleInfo = "changeType_key:" + changeType_key + ":kqOvertimeRulesDetailEntity:" + kqOvertimeRulesDetailEntity; + logOvertimeMap(overtimeLogMap, overRuleInfo, mapKey + "|" + "加班规则为null|kqOvertimeRulesDetailEntity"); + return false; + } + int overtimeEnable = kqOvertimeRulesDetailEntity.getOvertimeEnable(); + if (overtimeEnable != 1) { + String overtimeEnableInfo = "overtimeEnable:" + overtimeEnable; + logOvertimeMap(overtimeLogMap, overtimeEnableInfo, mapKey + "|" + "未开启加班规则|overtimeEnable"); + return false; + } + + if (kqOvertimeCardBean != null) { + if (splitBeanMaps.containsKey(mapKey)) { + List splitBeans = splitBeanMaps.get(mapKey); + String flowinfo = ""; + if (splitBeans != null && !splitBeans.isEmpty()) { + flowinfo = JSON.toJSONString(splitBeans, SerializerFeature.DisableCheckSpecialChar, SerializerFeature.DisableCircularReferenceDetect); + } else { + logOvertimeMap(overtimeLogMap, "打卡数据KQOvertimeCardBean为null", mapKey + "|" + "打卡和上下班数据|KQOvertimeCardBean"); + return false; + } + eventMap.put(mapKey + "|" + "加班流程数据|flowinfo", flowinfo); + for (int m = 0; m < splitBeans.size(); m++) { + int[] initArrays_flow = kqTimesArrayComInfo.getInitArr(); + SplitBean splitBean = splitBeans.get(m); + String dataid = splitBean.getDataId(); + String detailid = splitBean.getDetailId(); + String flow_fromdate = splitBean.getFromDate(); + String flow_fromtime = splitBean.getFromTime(); + String flow_todate = splitBean.getToDate(); + String flow_totime = splitBean.getToTime(); + String fromdatedb = splitBean.getFromdatedb(); + String fromtimedb = splitBean.getFromtimedb(); + String todatedb = splitBean.getTodatedb(); + String totimedb = splitBean.getTotimedb(); + String requestid = splitBean.getRequestId(); + double d_mins = splitBean.getD_Mins(); + if (d_mins <= 0) { + continue; + } + String flow_key = mapKey + "|" + "dataid|" + dataid + "|" + "detailid|" + detailid + "|" + "requestid|" + requestid + "|flow_fromdate|" + flow_fromdate + + "|flow_fromtime|" + flow_fromtime + "|flow_todate|" + flow_todate + "|flow_totime|" + flow_totime; + int flow_count = (int) d_mins; + String flowLogInfo = "flow_fromdate:" + flow_fromdate + ":flow_fromtime:" + flow_fromtime + + ":flow_todate:" + flow_todate + ":flow_totime:" + flow_totime + ":requestid:" + requestid + + ":d_mins:" + d_mins; + logOvertimeMap(overtimeLogMap, flowLogInfo, flow_key + "|加班流程信息|flowLogInfo"); + + List> hasOverTimeList = Lists.newArrayList(); + getHasOverTimeData(resourceid, realSplitDate, hasOverTimeList); + logOvertimeMap(overtimeLogMap, hasOverTimeList, flow_key + "|是否已经生成过加班,返回已经生成过加班的区间|hasOverTimeList"); + + if (flow_fromdate.compareTo(realSplitDate) > 0) { + flow_fromtime = kqTimesArrayComInfo.turn24to48Time(flow_fromtime); + } + if (flow_todate.compareTo(realSplitDate) > 0) { + flow_totime = kqTimesArrayComInfo.turn24to48Time(flow_totime); + } + int flow_fromIndex = kqTimesArrayComInfo.getArrayindexByTimes(flow_fromtime); + int flow_toIndex = kqTimesArrayComInfo.getArrayindexByTimes(flow_totime); + Arrays.fill(initArrays_flow, flow_fromIndex, flow_toIndex, 1); + int all_has_duration_min = 0; + //因为存在下班后的打卡和上班前的打卡。这两块的打卡需要合在一起来和合在一起的流程比较时长 + Map hasCardMap = Maps.newHashMap(); + if (hasOverTimeList != null && !hasOverTimeList.isEmpty()) { + for (int p = 0; p < hasOverTimeList.size(); p++) { + Map hasOverTimeMap = hasOverTimeList.get(p); + String duration_min = Util.null2String(hasOverTimeMap.get("duration_min")); + String flow_dataid = Util.null2String(hasOverTimeMap.get("flow_dataid")); + String ori_belongdate = Util.null2String(hasOverTimeMap.get("ori_belongdate")); + String has_requestid = Util.null2String(hasOverTimeMap.get("requestid")); + + String card_fromdate = Util.null2String(hasOverTimeMap.get("fromdate_flow")); + String card_fromtime = Util.null2String(hasOverTimeMap.get("fromtime_flow")); + String card_todate = Util.null2String(hasOverTimeMap.get("todate_flow")); + String card_totime = Util.null2String(hasOverTimeMap.get("totime_flow")); + String card_key = card_fromdate + "_" + card_fromtime + "_" + card_todate + "_" + card_totime; + + int int_duration_min = Util.getIntValue(duration_min, 0); + String has_key = has_requestid; + String cur_key = requestid; + if (flow_dataid.length() > 0) { + has_key += "_" + dataid + "_" + detailid; + cur_key += "_" + flow_dataid; + } + //为什么要加这个判断呢,因为有可能我请假3小时,打卡1小时,然后这个时候生成1小时加班,然后我后面又补卡了2小时,这时候,加班流程虽然已经 +// 生成过加班,但是其实只用了1小时,还需要拿这个加班流程来,减去已经用的1小时,d_mins就是这个加班流程实际可用的加班流程时长 + if (has_key.equalsIgnoreCase(cur_key)) { + if (int_duration_min > 0) { + d_mins = d_mins - (int_duration_min * 1.0); + } + } + all_has_duration_min += int_duration_min; + if (hasCardMap.containsKey(card_key)) { + int tmp_int_duration_min = Util.getIntValue(hasCardMap.get(card_key)); + hasCardMap.put(card_key, "" + (int_duration_min + tmp_int_duration_min)); + } else { + hasCardMap.put(card_key, int_duration_min + ""); + } + } + } + if (d_mins > 0) { + + int[] initArrays = kqTimesArrayComInfo.getInitArr(); + Map signinoffMap = buildOvertimeCard(kqOvertimeCardBean, resourceid, realSplitDate, kqTimesArrayComInfo, restTimeMap, changeType_key, initArrays, hasOverTimeList, + overRulesDetailMap, false, overtimeLogMap, preChangeType_key, nextChangeType_key); + + String signinTime = Util.null2String(signinoffMap.get("signinTime")); + String signoutTime = Util.null2String(signinoffMap.get("signoutTime")); + String signinDate = Util.null2String(signinoffMap.get("signinDate")); + String signoutDate = Util.null2String(signinoffMap.get("signoutDate")); + int signinTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signinTime); + int signoutTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signoutTime); + + if (signinTimeIndex < signoutTimeIndex) { + String nowCardKey = signinDate + "_" + kqTimesArrayComInfo.turn48to24Time(signinTime) + + "_" + signoutDate + "_" + kqTimesArrayComInfo.turn48to24Time(signoutTime); + int over_count = kqTimesArrayComInfo.getCnt(initArrays, signinTimeIndex, signoutTimeIndex, 1); + int card_mins = over_count; + logOvertimeMap(overtimeLogMap, over_count, flow_key + "|加班打卡生成的时长|over_count"); + if (over_count > 0) { + //表示加班打卡是存在的 + String flow_cross_key = flow_key + "|加班计算区间|" + signinTime + "-" + signoutTime; + + int restTimeType = 1; + if (kqOvertimeRulesDetailEntity != null) { + int minimumLen = kqOvertimeRulesDetailEntity.getMinimumLen(); + if (card_mins < minimumLen) { + continue; + } + logOvertimeMap(overtimeLogMap, JSON.toJSONString(kqOvertimeRulesDetailEntity), flow_key + "|加班规则|KQOvertimeRulesDetailEntity"); + //我这个方法是针对每次生成的加班数据做排除休息时长的处理 打卡数据也要去掉休息时长 + restTimeType = kqOvertimeRulesDetailEntity.getRestTimeType(); + if (restTimeType == 2) { + over_count = new KQOverTimeFlowBiz().handle_restlength(over_count, restTimeMap, changeType_key); + } + } + if (all_has_duration_min > 0) { + for (Entry me : hasCardMap.entrySet()) { + String cardKey = me.getKey(); + String cardValue = me.getValue(); + if (cardKey.equalsIgnoreCase(nowCardKey)) { + } else { + all_has_duration_min = all_has_duration_min - Util.getIntValue(cardValue); + } + } + over_count = over_count - all_has_duration_min; + } + if (over_count <= 0) { + continue; + } + int mins = over_count < d_mins ? over_count : (int) d_mins; + int maxMumLen = kqOvertimeRulesDetailEntity.getMaxmumLen(); + if (mins > maxMumLen) { + mins = maxMumLen; + } + double double_mins = getD_MinsByUnit((1.0 * mins)); + mins = (int) double_mins; + + RecordSet rs = new RecordSet(); + String overtime_uuid = UUID.randomUUID().toString(); + String flow_dataid = dataid + "_" + detailid; + String tiaoxiuId = ""; + int computingMode = 2; + + int unit = KQOvertimeRulesBiz.getMinimumUnit(); + String workingHours = ""; + String overtime_type = splitBean.getOvertime_type(); + Map otherParam = Maps.newHashMap(); + otherParam.put("overtime_type", overtime_type); + otherParam.put("changeType", String.valueOf(changeType)); + int paidLeaveEnableType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableType(); + if (2 == paidLeaveEnableType) { + logOvertimeMap(overtimeLogMap, overtime_type, flow_cross_key + "|关联调休与否来自于流程选择,加班类型下拉框值|overtime_type"); + } + + int paidLeaveEnable = getPaidLeaveEnable(kqOvertimeRulesDetailEntity, overtime_type); + + logOvertimeMap(overtimeLogMap, mins, flow_cross_key + "|最终生成的加班时长|mins"); + otherParam.put("overtimeLogMap", overtimeLogMap); + + tiaoxiuId = KQBalanceOfLeaveBiz.addExtraAmountByDis5(resourceid, realSplitDate, mins + "", "0", workingHours, requestid, "1", flow_fromdate, otherParam); + if (Util.getIntValue(tiaoxiuId) > 0) { + kqLog.info("doComputingMode2 生成调休成功,调休id:" + tiaoxiuId + ":resourceid:" + resourceid + ":realSplitDate:" + realSplitDate + ":requestid:" + requestid); + } else { + kqLog.info("doComputingMode2 生成调休失败,调休id:" + tiaoxiuId + ":resourceid:" + resourceid + ":realSplitDate:" + realSplitDate + ":requestid:" + requestid); + } + logOvertimeMap(overtimeLogMap, tiaoxiuId, flow_cross_key + "|最终生成的调休id|tiaoxiuId"); + + Long cur = System.currentTimeMillis(); + Timestamp date = new Timestamp(cur); + String flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate," + + "workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid,fromdatedb,fromtimedb,todatedb,totimedb,flow_mins,card_mins,ori_belongdate,flow_dataid,create_time,update_time,creator)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + if (rs.getDBType().equals("postgresql")) { + flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate," + + "workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid,fromdatedb,fromtimedb,todatedb,totimedb,flow_mins,card_mins,ori_belongdate,flow_dataid,create_time,update_time,creator)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?::timestamp,?::timestamp,?) "; + } + signinTime = kqTimesArrayComInfo.turn48to24Time(signinTime); + signoutTime = kqTimesArrayComInfo.turn48to24Time(signoutTime); + if (fromtimedb.length() == 5) { + fromtimedb = fromtimedb + ":00"; + } + if (totimedb.length() == 5) { + totimedb = totimedb + ":00"; + } + boolean isUp = rs.executeUpdate(flow_overtime_sql, requestid, resourceid, fromdatedb, fromtimedb, todatedb, totimedb, mins, "", realSplitDate, + "", unit, changeType, paidLeaveEnable, computingMode, tiaoxiuId, overtime_uuid, signinDate, signinTime, signoutDate, signoutTime, flow_count, card_mins, splitDate, flow_dataid, date, date, Util.getIntValue(resourceid)); + String overtimeid = get_overtime_uuid(overtime_uuid); + kqEventLogBiz.updateOvertimeId(uuid, overtimeid); + } + } + } else { + logOvertimeMap(overtimeLogMap, "流程时长d_mins为0,不生成加班", flow_key + "|加班流程信息|flowLogInfo"); + } + } + } + + } else { + logOvertimeMap(overtimeLogMap, "打卡数据KQOvertimeCardBean为null", "打卡和上下班数据|KQOvertimeCardBean"); + } + return true; + } + + /** + * 打卡的时长计算,流程+打卡 和纯打卡的可以拿来共用 + * needHasOverTime 是否需要按照打卡区间排除重复打卡的数据,第二种流程和打卡比较时长的不需要这个方式 + */ + public Map buildOvertimeCard(KQOvertimeCardBean kqOvertimeCardBean, + String resourceid, String splitDate, KQTimesArrayComInfo kqTimesArrayComInfo, + Map> restTimeMap, String changeType_key, int[] initArrays, + List> hasOverTimeList, + Map overRulesDetailMap, boolean needHasOverTime, + Map overtimeLogMap, String preChangeType_key, String nextChangeType_key) throws Exception { + Map signinoffMap = Maps.newHashMap(); + + String signinDate = kqOvertimeCardBean.getSigninDate(); + String signinTime = kqOvertimeCardBean.getSigninTime(); + String signoutDate = kqOvertimeCardBean.getSignoutDate(); + String signoutTime = kqOvertimeCardBean.getSignoutTime(); + + if (hasOverTimeList.isEmpty()) { + getHasOverTimeData(resourceid, splitDate, hasOverTimeList); + } + + if (signinDate.compareTo(splitDate) > 0) { + signinTime = kqTimesArrayComInfo.turn24to48Time(signinTime); + if (signinTime.length() > 0) { + signinTime = signinTime + ":00"; + } + } + if (signoutDate.compareTo(splitDate) > 0) { + signoutTime = kqTimesArrayComInfo.turn24to48Time(signoutTime); + if (signoutTime.length() > 0) { + signoutTime = signoutTime + ":00"; + } + } + if (signinTime.length() == 0 || signoutTime.length() == 0) { + return signinoffMap; + } + + int signinTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signinTime); + int signoutTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signoutTime); + + signinoffMap.put("signinTime", signinTime); + signinoffMap.put("signoutTime", signoutTime); + signinoffMap.put("signinDate", signinDate); + signinoffMap.put("signoutDate", signoutDate); + //先把打卡数据都列出来 置位1 + if (signinTimeIndex < signoutTimeIndex) { + Arrays.fill(initArrays, signinTimeIndex, signoutTimeIndex, 1); + } + KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key); + if (restTimeMap.containsKey(preChangeType_key)) { + //昨日的排除休息时间跨天的情况 + List restTimeList = restTimeMap.get(preChangeType_key); + if (CollectionUtils.isNotEmpty(restTimeList)) { + for (int k = 0; k < restTimeList.size(); k++) { + String[] restTimes = restTimeList.get(k); + if (restTimes.length == 2) { + int restStart = kqTimesArrayComInfo.getArrayindexByTimes(restTimes[0]); + int restEnd = kqTimesArrayComInfo.getArrayindexByTimes(restTimes[1]); + restStart = restStart - 1440; + restEnd = restEnd - 1440; + if (restEnd > 0) { + //休息时段跨天了 + if (restStart > 0) { + Arrays.fill(initArrays, restStart, restEnd, 1); + } else { + Arrays.fill(initArrays, 0, restEnd, 1); + } + } + } + } + } + + } + if (restTimeMap.containsKey(changeType_key)) { + List restTimeList = restTimeMap.get(changeType_key); + logOvertimeMap(overtimeLogMap, restTimeList, "非工作时间设置的排除休息时间区间|restTimeList"); + //再把休息时间填充上去 + if (!restTimeList.isEmpty()) { + int restTimeType = 1; + if (kqOvertimeRulesDetailEntity != null) { + restTimeType = kqOvertimeRulesDetailEntity.getRestTimeType(); + } + if (restTimeType == 1) { + for (int j = 0; j < restTimeList.size(); j++) { + String[] restTimes = restTimeList.get(j); + if (restTimes.length == 2) { + int restStart = kqTimesArrayComInfo.getArrayindexByTimes(restTimes[0]); + int restEnd = kqTimesArrayComInfo.getArrayindexByTimes(restTimes[1]); + if (restEnd == 1439) { + //针对跨天的休息时段单独处理排除掉23:59-00:00的时间 + restEnd = 1440; + } + if (restStart < restEnd) { + Arrays.fill(initArrays, restStart, restEnd, -2); + } + } + } + } + } + } +// handleType 是否是处理昨日的,今日的还是明日的,0是处理今日的,1是处理明日的上下班时间和休息时间都要+1440,2是处理昨日的,需要减去1440 + int handleType = 2; + KQOvertimeRulesDetailEntity preKqOvertimeRulesDetailEntity = overRulesDetailMap.get(preChangeType_key); + clearWorkAndRestTime(resourceid, DateUtil.addDate(splitDate, -1), handleType, kqTimesArrayComInfo, overtimeLogMap, preKqOvertimeRulesDetailEntity, initArrays, signinTimeIndex); + handleType = 0; + clearWorkAndRestTime(resourceid, splitDate, handleType, kqTimesArrayComInfo, overtimeLogMap, kqOvertimeRulesDetailEntity, initArrays, signinTimeIndex); + handleType = 1; + KQOvertimeRulesDetailEntity nextKqOvertimeRulesDetailEntity = overRulesDetailMap.get(nextChangeType_key); + clearWorkAndRestTime(resourceid, DateUtil.addDate(splitDate, 1), handleType, kqTimesArrayComInfo, + overtimeLogMap, nextKqOvertimeRulesDetailEntity, initArrays, signinTimeIndex); + + if (!hasOverTimeList.isEmpty() && needHasOverTime) { + if (hasOverTimeList != null && !hasOverTimeList.isEmpty()) { + for (int p = 0; p < hasOverTimeList.size(); p++) { + Map hasOverTimeMap = hasOverTimeList.get(p); + String duration_min = Util.null2String(hasOverTimeMap.get("duration_min")); + String fromdate = Util.null2String(hasOverTimeMap.get("fromdate")); + String fromtime = Util.null2String(hasOverTimeMap.get("fromtime")); + String todate = Util.null2String(hasOverTimeMap.get("todate")); + String totime = Util.null2String(hasOverTimeMap.get("totime")); + if (fromdate.compareTo(splitDate) > 0) { + fromtime = kqTimesArrayComInfo.turn24to48Time(fromtime); + } + if (todate.compareTo(splitDate) > 0) { + totime = kqTimesArrayComInfo.turn24to48Time(totime); + } + int begintimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime); + int endtimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(totime); + if (begintimeIndex < endtimeIndex) { + Arrays.fill(initArrays, begintimeIndex, endtimeIndex, -2); + } + } + } + } + return signinoffMap; + } + + /** + * 把指定的打卡区间内的上下班时间和休息时间去除 + * + * @param resourceid + * @param splitDate + * @param handleType 是否是处理昨日的,今日的还是明日的,0是处理今日的,1是处理明日的上下班时间和休息时间都要+1440,2是处理昨日的 + * @param kqTimesArrayComInfo + * @param overtimeLogMap + * @param kqOvertimeRulesDetailEntity + * @param initArrays + * @param signinTimeIndex + */ + public void clearWorkAndRestTime(String resourceid, String splitDate, int handleType, + KQTimesArrayComInfo kqTimesArrayComInfo, + Map overtimeLogMap, + KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity, int[] initArrays, + int signinTimeIndex) { + + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceid, splitDate); + if (workTime == null || (workTime != null && (workTime.getWorkMins() == 0 || workTime.getNonWorkShift() == 1))) { + } else { + if (workTime.getKQType().equals("3")) {//自由工时 + //目前自由工时不加班 + } else { + boolean oneSign = false; + List lsSignTime = new ArrayList<>(); + List lsWorkTime = new ArrayList<>(); + List lsRestTime = new ArrayList<>(); + if (workTime != null) { + lsSignTime = workTime.getSignTime();//允许打卡时间 + lsWorkTime = workTime.getWorkTime();//工作时间 + lsRestTime = workTime.getRestTime();//休息时段时间 + oneSign = lsWorkTime != null && lsWorkTime.size() == 1; + + if (lsWorkTime != null && !lsWorkTime.isEmpty()) { + + for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) { + TimeScopeEntity workTimeScope = lsWorkTime.get(i); + if (oneSign) { + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + if (is_flow_humanized) { + String workBeginTime = Util.null2String(workTimeScope.getBeginTime()); + int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime); + String workEndTime = Util.null2String(workTimeScope.getEndTime()); + int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + + Map shifRuleMap = Maps.newHashMap(); + //个性化设置只支持一天一次上下班 + ShiftInfoBean shiftInfoBean = new ShiftInfoBean(); + shiftInfoBean.setSplitDate(splitDate); + shiftInfoBean.setShiftRuleMap(workTime.getShiftRuleInfo()); + shiftInfoBean.setSignTime(lsSignTime); + shiftInfoBean.setWorkTime(lsWorkTime); + List logList = Lists.newArrayList(); + KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, resourceid, shifRuleMap, logList); + if (!shifRuleMap.isEmpty()) { + if (shifRuleMap.containsKey("shift_beginworktime")) { + String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime")); + if (shift_beginworktime.length() > 0) { + workBeginTime = Util.null2String(shift_beginworktime); + workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime); + workTimeScope.setBeginTime(workBeginTime); + workTimeScope.setBeginTimeAcross(workBeginIdx >= 1440 ? true : false); + } + } + if (shifRuleMap.containsKey("shift_endworktime")) { + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if (shift_endworktime.length() > 0) { + workEndTime = Util.null2String(shift_endworktime); + workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + workTimeScope.setEndTime(workEndTime); + workTimeScope.setEndTimeAcross(workEndIdx >= 1440 ? true : false); + } + } + } + } + } + } + + //目前只处理上班前和下班后的加班数据,上班中间的数据不处理,所以从第一次上班时间到最后下班时间都是无效的加班打卡 + TimeScopeEntity first_TimeScopeEntity = lsWorkTime.get(0); + TimeScopeEntity last_TimeScopeEntity = lsWorkTime.get(lsWorkTime.size() - 1); + + String begintime = first_TimeScopeEntity.getBeginTime(); + String endtime = last_TimeScopeEntity.getEndTime(); + int begintimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endtimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + if (1 == handleType) { + begintimeIndex = begintimeIndex + 1440; + endtimeIndex = endtimeIndex + 1440; + if (begintimeIndex >= initArrays.length) { + begintimeIndex = initArrays.length - 1; + } + if (endtimeIndex >= initArrays.length) { + endtimeIndex = initArrays.length - 1; + } + } + if (2 == handleType) { + begintimeIndex = begintimeIndex - 1440; + endtimeIndex = endtimeIndex - 1440; + } + String workTimeLogInfo = "begintime:" + begintime + ":endtime:" + endtime + ":handleType:" + handleType; + logOvertimeMap(overtimeLogMap, workTimeLogInfo, "工作日的上下班时间|workTimeLogInfo"); + if (begintimeIndex >= 0 && endtimeIndex >= 0 && begintimeIndex < endtimeIndex) { + Arrays.fill(initArrays, begintimeIndex, endtimeIndex, -2); + } + if (0 == handleType) { + if (kqOvertimeRulesDetailEntity != null) { + int startTime = kqOvertimeRulesDetailEntity.getStartTime(); + if (startTime > -1) { + int after_endtimeIndex = endtimeIndex + startTime; + if (after_endtimeIndex > 0 && after_endtimeIndex > endtimeIndex) { + if (endtimeIndex < 0) { + endtimeIndex = 0; + } + Arrays.fill(initArrays, endtimeIndex, after_endtimeIndex, -2); + } + } + int has_cut_point = kqOvertimeRulesDetailEntity.getHas_cut_point(); + if (has_cut_point == 1) { + int before_startTime = kqOvertimeRulesDetailEntity.getBefore_startTime(); + if (before_startTime > -1 && begintimeIndex > 0) { + int before_begintimeIndex = begintimeIndex - before_startTime; + if (before_begintimeIndex < 0) { + before_begintimeIndex = 0; + } + if (before_begintimeIndex > signinTimeIndex) { + Arrays.fill(initArrays, signinTimeIndex, before_begintimeIndex, -2); + } + } + } + } + } + if (2 == handleType) { + if (kqOvertimeRulesDetailEntity != null) { + int startTime = kqOvertimeRulesDetailEntity.getStartTime(); + if (startTime > -1) { + int after_endtimeIndex = endtimeIndex + startTime; + if (after_endtimeIndex > 0 && after_endtimeIndex > endtimeIndex) { + if (endtimeIndex < 0) { + endtimeIndex = 0; + } + Arrays.fill(initArrays, endtimeIndex, after_endtimeIndex, -2); + } + } + int has_cut_point = kqOvertimeRulesDetailEntity.getHas_cut_point(); + if (has_cut_point == 1) { + int before_startTime = kqOvertimeRulesDetailEntity.getBefore_startTime(); + if (before_startTime > -1) { + int before_begintimeIndex = begintimeIndex - before_startTime; + if (before_begintimeIndex < 0) { + before_begintimeIndex = 0; + } + if (before_begintimeIndex > signinTimeIndex) { + Arrays.fill(initArrays, signinTimeIndex, before_begintimeIndex, -2); + } + } + } + } + } + } + if (lsRestTime != null && !lsRestTime.isEmpty()) { + String restTimeLogInfo = JSON.toJSONString(lsRestTime); + logOvertimeMap(overtimeLogMap, restTimeLogInfo, "工作日的休息时间|restTimeLogInfo"); + for (int p = 0; p < lsRestTime.size(); p++) { + TimeScopeEntity rest_TimeScopeEntity = lsRestTime.get(p); + String begintime = rest_TimeScopeEntity.getBeginTime(); + String endtime = rest_TimeScopeEntity.getEndTime(); + int begintimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endtimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + if (1 == handleType) { + begintimeIndex = begintimeIndex + 1440; + endtimeIndex = endtimeIndex + 1440; + if (begintimeIndex >= initArrays.length) { + begintimeIndex = initArrays.length - 1; + } + if (endtimeIndex >= initArrays.length) { + endtimeIndex = initArrays.length - 1; + } + } + if (2 == handleType) { + begintimeIndex = begintimeIndex - 1440; + if (begintimeIndex < 0) { + begintimeIndex = 0; + } + endtimeIndex = endtimeIndex - 1440; + if (endtimeIndex < 0) { + endtimeIndex = 0; + } + } + if (begintimeIndex >= 0 && endtimeIndex >= 0 && begintimeIndex < endtimeIndex) { + Arrays.fill(initArrays, begintimeIndex, endtimeIndex, -2); + } + } + } + + } + } + } + } + + /** + * 根据打卡数据和加班归属 拆分出来需要计算加班的区段 + * + * @param resourceid + * @param fromDate + * @param toDate + * @param dateFormatter + * @param kqTimesArrayComInfo + * @param overRulesDetailMap + * @param changeTypeMap + * @param lsCheckInfoMaps + * @param eventMap + */ + public void getOverTimeCardDataMap(String resourceid, String fromDate, String toDate, + DateTimeFormatter dateFormatter, + KQTimesArrayComInfo kqTimesArrayComInfo, + Map overRulesDetailMap, + Map changeTypeMap, Map lsCheckInfoMaps, + Map eventMap) throws Exception { + + KQOverTimeFlowBiz kqOverTimeFlowBiz = new KQOverTimeFlowBiz(); + + List lsCheckInfos = Lists.newArrayList(); + Map result = getSignData(resourceid, fromDate, dateFormatter, eventMap, lsCheckInfos, changeTypeMap, overRulesDetailMap); + + //获取一下当天的上班时间 + String firstworkDate = Util.null2String(result.get("firstworkDate")); + String firstworkTime = Util.null2String(result.get("firstworkTime")); + int pre_has_cut_point = Util.getIntValue(Util.null2String(result.get("pre_has_cut_point"))); + String pre_cut_point = Util.null2String(result.get("pre_cut_point")); + int has_cut_point = Util.getIntValue(Util.null2String(result.get("has_cut_point"))); + String cut_point = Util.null2String(result.get("cut_point")); + int before_startTime = Util.getIntValue(Util.null2String(result.get("before_startTime"))); + int preChangeType = Util.getIntValue(Util.null2String(result.get("preChangeType"))); + int changeType = Util.getIntValue(Util.null2String(result.get("changeType"))); + + LocalDate localbelongDate = LocalDate.parse(fromDate); + String splitDate = localbelongDate.format(dateFormatter); + LocalDate preLocalDate = localbelongDate.minusDays(1); + String preSplitDate = preLocalDate.format(dateFormatter); + String nextSplitDate = localbelongDate.plusDays(1).format(dateFormatter); + + String preKey = resourceid + "_" + preSplitDate; + String key = resourceid + "_" + splitDate; + String nextkey = resourceid + "_" + nextSplitDate; + + eventMap.put("lsCheckInfos", lsCheckInfos); + if (!lsCheckInfos.isEmpty()) { + Map signMap = (Map) lsCheckInfos.get(0); + String signindate = ""; + String signintime = ""; + String signoutdate = ""; + String signouttime = ""; + + if (signMap != null && !signMap.isEmpty()) { + signindate = Util.null2String(signMap.get("signindate")); + signintime = Util.null2String(signMap.get("signintime")); + signoutdate = Util.null2String(signMap.get("signoutdate")); + signouttime = Util.null2String(signMap.get("signouttime")); + if (lsCheckInfos.size() > 1) { + Map lastSignMap = (Map) lsCheckInfos.get(lsCheckInfos.size() - 1); + signoutdate = Util.null2String(lastSignMap.get("signoutdate")); + signouttime = Util.null2String(lastSignMap.get("signouttime")); + } + } + KQOvertimeCardBean kqOvertimeBean = new KQOvertimeCardBean(); + kqOvertimeBean.setSigninDate(signindate); + kqOvertimeBean.setSigninTime(signintime); + kqOvertimeBean.setSignoutDate(signoutdate); + kqOvertimeBean.setSignoutTime(signouttime); + kqOvertimeBean.setBelongDate(splitDate); + eventMap.put("pre_has_cut_point", pre_has_cut_point); + eventMap.put("has_cut_point", has_cut_point); + if (pre_has_cut_point == 0) { + //未设置打卡归属 + if (preChangeType == 2) { + eventMap.put("preChangeType", preChangeType); + //如果前一天是工作日 + String pre_overtime_cut_point = ""; + ShiftInfoBean pre_shiftInfoBean = KQDurationCalculatorUtil + .getWorkTime(resourceid, preSplitDate, false); + if (pre_shiftInfoBean != null) { + boolean isfree = pre_shiftInfoBean.isIsfree(); + eventMap.put("isfree", isfree); + if (!isfree) { + List workLongTimeIndex = pre_shiftInfoBean.getWorkLongTimeIndex(); + List real_workLongTimeIndex = Lists.newArrayList(); + SplitBean splitBean = new SplitBean(); + splitBean.setResourceId(resourceid); + kqOverTimeFlowBiz.get_real_workLongTimeIndex(workLongTimeIndex, real_workLongTimeIndex, pre_shiftInfoBean, kqTimesArrayComInfo, splitBean); + + if (real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()) { + pre_overtime_cut_point = kqTimesArrayComInfo.getTimesByArrayindex(real_workLongTimeIndex.get(0)[0]); + } + } else { + //自由班制直接给0点 + pre_overtime_cut_point = "00:00"; + } + if (result.containsKey("beginTime")) { + String beginTime = Util.null2String(result.get("beginTime")); + if(pre_overtime_cut_point.compareTo(beginTime) > 0){ + pre_overtime_cut_point = beginTime; + } + } + eventMap.put("pre_overtime_cut_point", pre_overtime_cut_point); + if (pre_overtime_cut_point.length() >= 0) { + rePutCheckInfoMap(lsCheckInfoMaps, kqOvertimeBean, preKey, key, pre_overtime_cut_point, splitDate, eventMap, has_cut_point, result, nextkey); + } + } else { + String errorMsg = "前一天是工作日但是前一天的ShiftInfoBean班次获取不到信息"; + eventMap.put("errorMsg", errorMsg); + } + } else { + eventMap.put("changeType", changeType); + if (changeType == 2) { + eventMap.put("firstworkTime", firstworkTime); + result.put("cut_point", cut_point); + if (has_cut_point == 1 && before_startTime > 0) { + firstworkTime = kqTimesArrayComInfo.getTimesByArrayindex(kqTimesArrayComInfo.getArrayindexByTimes(firstworkTime) - before_startTime); + } + //如果前一天是非工作日,今天是工作日的话 + rePutCheckInfoMap(lsCheckInfoMaps, kqOvertimeBean, preKey, key, firstworkTime, splitDate, + eventMap, has_cut_point, result, nextkey); + } else { + if (result.containsKey("nonWorkBeginTime")) { + String nonWorkBeginTime = result.get("nonWorkBeginTime"); + eventMap.put("nonWorkBeginTime", nonWorkBeginTime); + //如果前一天是非工作日,今天是非工作日班次的话 + rePutCheckInfoMap(lsCheckInfoMaps, kqOvertimeBean, preKey, key, nonWorkBeginTime, splitDate, + eventMap, has_cut_point, result, nextkey); + } else { + //如果前一天是非工作日,今天是非工作日的话,那就是打卡获取的是啥就是啥 + lsCheckInfoMaps.put(key, kqOvertimeBean); + } + } + } + } else { + List pre_lsCheckInfos = Lists.newArrayList(); + getSignData(resourceid, preSplitDate, dateFormatter, eventMap, pre_lsCheckInfos, changeTypeMap, overRulesDetailMap); + + Map preSignMap = Maps.newHashMap(); + if (!pre_lsCheckInfos.isEmpty()) { + preSignMap = (Map) pre_lsCheckInfos.get(0); + } + eventMap.put("pre_cut_point", pre_cut_point); + //设置了打卡归属 那么一天的打卡就可能被前一天给拆成两部分和后一天的打卡归属给拆分成两部分 + rePutCheckInfoCutPointMap(lsCheckInfoMaps, kqOvertimeBean, preKey, key, pre_cut_point, splitDate, + eventMap, cut_point, nextSplitDate, nextkey, has_cut_point, result, pre_has_cut_point, preSignMap); + } + } + eventMap.put("lsCheckInfos_after", lsCheckInfoMaps); + } + + /** + * 获取打卡数据 + * + * @param resourceid + * @param belongDate + * @param dateFormatter + * @param eventMap + * @param lsCheckInfos + * @param changeTypeMap + * @param overRulesDetailMap + */ + public Map getSignData(String resourceid, String belongDate, + DateTimeFormatter dateFormatter, Map eventMap, + List lsCheckInfos, Map changeTypeMap, + Map overRulesDetailMap) throws Exception { + Map result = Maps.newHashMap(); + String firstworkDate = ""; + String firstworkTime = ""; + + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + LocalDate localbelongDate = LocalDate.parse(belongDate); + String splitDate = localbelongDate.format(dateFormatter); + LocalDate preLocalDate = localbelongDate.minusDays(1); + String preSplitDate = preLocalDate.format(dateFormatter); + String nextSplitDate = localbelongDate.plusDays(1).format(dateFormatter); + + String change_key = splitDate + "_" + resourceid; + String preChange_key = preSplitDate + "_" + resourceid; + String nextChange_key = nextSplitDate + "_" + resourceid; + int changeType = Util.getIntValue("" + changeTypeMap.get(change_key), -1); + int preChangeType = Util.getIntValue("" + changeTypeMap.get(preChange_key), -1); + int nextChangeType = Util.getIntValue("" + changeTypeMap.get(nextChange_key), -1); + String changeType_key = splitDate + "_" + changeType; + String preChangeType_key = preSplitDate + "_" + preChangeType; + + KQOvertimeRulesDetailEntity curKqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key); + KQOvertimeRulesDetailEntity preKqOvertimeRulesDetailEntity = overRulesDetailMap.get(preChangeType_key); + + int pre_has_cut_point = 0; + String pre_cut_point = ""; + if (preKqOvertimeRulesDetailEntity != null) { + pre_has_cut_point = preKqOvertimeRulesDetailEntity.getHas_cut_point(); + pre_cut_point = preKqOvertimeRulesDetailEntity.getCut_point(); + } + int has_cut_point = 0; + String cut_point = ""; + int before_startTime = -1; + if (curKqOvertimeRulesDetailEntity != null) { + has_cut_point = curKqOvertimeRulesDetailEntity.getHas_cut_point(); + cut_point = curKqOvertimeRulesDetailEntity.getCut_point(); + before_startTime = curKqOvertimeRulesDetailEntity.getBefore_startTime(); + } + + result.put("pre_has_cut_point", "" + pre_has_cut_point); + result.put("pre_cut_point", pre_cut_point); + result.put("has_cut_point", "" + has_cut_point); + result.put("cut_point", cut_point); + result.put("before_startTime", "" + before_startTime); + result.put("preChangeType", "" + preChangeType); + result.put("changeType", "" + changeType); + + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceid, splitDate); + int signoutOnlyoff = 0; + + LocalDate pre_curLocalDate = localbelongDate.minusDays(1); + String preDate = pre_curLocalDate.format(dateFormatter); + LocalDate next_curLocalDate = localbelongDate.plusDays(1); + String nextDate = next_curLocalDate.format(dateFormatter); + boolean isNonWork = false; + if (workTime == null || (workTime.getWorkMins() == 0 && workTime.getNonWorkShift() != 1)) { + isNonWork = true; + } + + if (isNonWork) { + Map signMap = getRestSignInfo(resourceid, splitDate, preDate, nextDate, curKqOvertimeRulesDetailEntity, eventMap, preKqOvertimeRulesDetailEntity); + if (signMap != null && !signMap.isEmpty()) { + lsCheckInfos.add(signMap); + } + } else { + if (workTime.getKQType().equals("3")) {//自由工时 + //目前自由工时不加班 + } else { + boolean oneSign = false; + List lsSignTime = new ArrayList<>(); + List lsWorkTime = new ArrayList<>(); + List lsRestTime = new ArrayList<>(); + oneSign = lsWorkTime != null && lsWorkTime.size() == 1; + boolean need_middle_time = false; + + if (workTime != null) { + signoutOnlyoff = workTime.getSignoutOnlyoff(); + if (workTime.getNonWorkShift() == 1) { + //非工作日班次 计算逻辑 + lsSignTime = workTime.getSignTime();//允许打卡时间 + List nonWorkTime = workTime.getWorkTime(); + TimeScopeEntity signTimeScopeStart = lsSignTime.get(0); + TimeScopeEntity signTimeScopeEnd = lsSignTime.get(lsSignTime.size() - 1); + TimeScopeEntity signTimeScope = new TimeScopeEntity(); + signTimeScope.setBeginTime(signTimeScopeStart.getBeginTime()); + signTimeScope.setBeginTimeAcross(signTimeScopeStart.getBeginTimeAcross()); + signTimeScope.setEndTime(signTimeScopeEnd.getEndTime()); + signTimeScope.setEndTimeAcross(signTimeScopeEnd.getEndTimeAcross()); + signTimeScope.setBeginTimePreAcross(signTimeScopeStart.isBeginTimePreAcross()); + + int i = 0; + result.put("lsWorkTime_size", "1"); + if (CollectionUtils.isNotEmpty(nonWorkTime)) { + TimeScopeEntity wTimeScopeEntity = nonWorkTime.get(0); + result.put("nonWorkBeginTime", wTimeScopeEntity.getBeginTime()); + } + Map signMap = getSignInfo(resourceid, signTimeScope, null, splitDate, preDate, nextDate, kqTimesArrayComInfo, eventMap, i, result,signoutOnlyoff); + if (signMap != null && !signMap.isEmpty()) { + //目前一天多次打卡的话,只获取第一次和最后一次打卡 + lsCheckInfos.add(signMap); + } + } else { + lsSignTime = workTime.getSignTime();//允许打卡时间 + lsWorkTime = workTime.getWorkTime();//工作时间 + result.put("lsWorkTime_size", "" + lsWorkTime.size()); + lsRestTime = workTime.getRestTime();//休息时段时间 + oneSign = lsWorkTime != null && lsWorkTime.size() == 1; + if (lsWorkTime != null) { + TimeScopeEntity timeScopeEntity0 = lsWorkTime.get(0); + TimeScopeEntity timeScopeEntity1 = lsWorkTime.get(lsWorkTime.size() - 1); + String beginTime = timeScopeEntity0.getBeginTime(); + String endTime = timeScopeEntity1.getEndTime(); + boolean endTimeAcross = timeScopeEntity1.getEndTimeAcross(); + result.put("beginTime", beginTime); + result.put("endTime", endTime); + result.put("endTimeAcross", endTimeAcross ? "1" : "0"); + } + for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) { + TimeScopeEntity signTimeScope = lsSignTime.get(i); + TimeScopeEntity workTimeScope = lsWorkTime.get(i); + if (i == 0) { + firstworkDate = splitDate; + firstworkTime = workTimeScope.getBeginTime(); + } + if (!oneSign) { + if (!need_middle_time) { + //多次打卡的时候,中间打卡不算加班 + if (i != 0 && i != lsWorkTime.size() - 1) { + continue; + } + } + } else { + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + if (is_flow_humanized) { + String workBeginTime = Util.null2String(workTimeScope.getBeginTime()); + String ori_workBeginTime = workBeginTime; + int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime); + boolean workBenginTimeAcross = workTimeScope.getBeginTimeAcross(); + String workEndTime = Util.null2String(workTimeScope.getEndTime()); + String ori_workEndTime = workEndTime; + int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + boolean workEndTimeAcross = workTimeScope.getEndTimeAcross(); + + Map shifRuleMap = Maps.newHashMap(); + //个性化设置只支持一天一次上下班 + ShiftInfoBean shiftInfoBean = new ShiftInfoBean(); + shiftInfoBean.setSplitDate(splitDate); + shiftInfoBean.setShiftRuleMap(workTime.getShiftRuleInfo()); + shiftInfoBean.setSignTime(lsSignTime); + shiftInfoBean.setWorkTime(lsWorkTime); + List logList = Lists.newArrayList(); + KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, resourceid, shifRuleMap, logList); + if (!shifRuleMap.isEmpty()) { + if (shifRuleMap.containsKey("shift_beginworktime")) { + String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime")); + if (shift_beginworktime.length() > 0) { + workBeginTime = Util.null2String(shift_beginworktime); + workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime); + workTimeScope.setBeginTime(workBeginTime); + workTimeScope.setBeginTimeAcross(workBeginIdx >= 1440 ? true : false); + if (i == 0) { + firstworkDate = workBeginIdx >= 1440 ? nextDate : splitDate; + firstworkTime = workBeginTime; + } + } + } + if (shifRuleMap.containsKey("shift_endworktime")) { + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if (shift_endworktime.length() > 0) { + workEndTime = Util.null2String(shift_endworktime); + workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + workTimeScope.setEndTime(workEndTime); + workTimeScope.setEndTimeAcross(workEndIdx >= 1440 ? true : false); + } + } + } + } + } + Map signMap = getSignInfo(resourceid, signTimeScope, workTimeScope, splitDate, preDate, nextDate, kqTimesArrayComInfo, eventMap, i, result,signoutOnlyoff); + if (signMap != null && !signMap.isEmpty()) { + //目前一天多次打卡的话,只获取第一次和最后一次打卡 + lsCheckInfos.add(signMap); + } + } + } + } + } + } + + if (firstworkDate.length() > 0 && firstworkTime.length() > 0) { + result.put("firstworkDate", firstworkDate); + result.put("firstworkTime", firstworkTime); + } + return result; + } + + public void rePutCheckInfoCutPointMap(Map lsCheckInfoMaps, + KQOvertimeCardBean kqOvertimeBean, String preKey, String key, String pre_cut_point, + String splitDate, Map eventMap, String cut_point, String nextDate, + String nextkey, int has_cut_point, Map result, + int pre_has_cut_point, Map preSignMap) { + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + String preDate = DateUtil.addDate(splitDate, -1); + + String pre_cut_points = pre_cut_point + ":00"; + String pre_date_cut_point = splitDate + " " + pre_cut_points; + + String cut_points = cut_point + ":00"; + String cur_date_cut_point = nextDate + " " + cut_points; + + String signindate = kqOvertimeBean.getSigninDate(); + String signoutdate = kqOvertimeBean.getSignoutDate(); + String signintime = kqOvertimeBean.getSigninTime(); + String signouttime = kqOvertimeBean.getSignoutTime(); + String signindatetime = kqOvertimeBean.getSigninDate() + " " + kqOvertimeBean.getSigninTime(); + String signoutdatetime = ""; + if (kqOvertimeBean.getSignoutDate().length() > 0 && kqOvertimeBean.getSignoutTime().length() > 0) { + //如果是休息日的话,可能存在没有上班时间的情况 + signoutdatetime = kqOvertimeBean.getSignoutDate() + " " + kqOvertimeBean.getSignoutTime(); + } + String pre_signindate = ""; + String pre_signintime = ""; + String pre_signoutdate = ""; + String pre_signouttime = ""; + if (preSignMap != null && !preSignMap.isEmpty()) { + pre_signindate = Util.null2String(preSignMap.get("signindate")); + pre_signintime = Util.null2String(preSignMap.get("signintime")); + pre_signoutdate = Util.null2String(preSignMap.get("signoutdate")); + pre_signouttime = Util.null2String(preSignMap.get("signouttime")); + } + + String timeInfo = "date_cut_point:" + pre_date_cut_point + ":signoutdatetime:" + signoutdatetime + ":signindatetime:" + signindatetime; + String timeCompare1 = "date_cut_point.compareTo(signoutdatetime):" + pre_date_cut_point.compareTo(signoutdatetime); + String timeCompare2 = "date_cut_point.compareTo(signindatetime):" + pre_date_cut_point.compareTo(signindatetime); + eventMap.put("timeInfo", timeInfo); + eventMap.put("timeCompare1", timeCompare1); + eventMap.put("timeCompare2", timeCompare2); + if (pre_date_cut_point.compareTo(signindatetime) > 0) { + //如果归属大于签到时间,小于签退时间,表示归属之前是属于前一天的,归属之后的是属于今天的 + //开启了归属之后,归属点之前的打卡就属于前一天的签退卡了,相当于是从前一天的下班时间到这个卡都算是前一天的加班卡,和不开归属的时候不一样 + KQOvertimeCardBean preKqOvertimeBean = new KQOvertimeCardBean(); + if (pre_signindate.length() > 0 && pre_signintime.length() > 0) { + preKqOvertimeBean.setSigninDate(pre_signindate); + preKqOvertimeBean.setSigninTime(pre_signintime); + preKqOvertimeBean.setSignoutDate(signindate); + preKqOvertimeBean.setSignoutTime(signintime); + preKqOvertimeBean.setBelongDate(preDate); + lsCheckInfoMaps.put(preKey, preKqOvertimeBean); + } + if (signoutdatetime.length() > 0 && signoutdatetime.compareTo(pre_date_cut_point) > 0) { + KQOvertimeCardBean curOvertimeBean = new KQOvertimeCardBean(); + curOvertimeBean.setSigninDate(splitDate); + curOvertimeBean.setSigninTime(pre_cut_points); + curOvertimeBean.setSignoutDate(signoutdate); + curOvertimeBean.setSignoutTime(signouttime); + curOvertimeBean.setBelongDate(splitDate); + lsCheckInfoMaps.put(key, curOvertimeBean); + } + + } else if (signoutdatetime.length() > 0 && pre_date_cut_point.compareTo(signoutdatetime) > 0) { + //如果归属大于签退时间 表示这个时间都是属于前一天的 + if (signindate.length() > 0 && signintime.length() > 0 && signoutdate.length() > 0 && signouttime.length() > 0) { + lsCheckInfoMaps.put(preKey, kqOvertimeBean); + } + } else { + if (signindate.length() > 0 && signintime.length() > 0 && signoutdate.length() > 0 && signouttime.length() > 0) { + lsCheckInfoMaps.put(key, kqOvertimeBean); + } + } + if (signoutdate.length() > 0) { + if (signoutdate.compareTo(splitDate) > 0) { + if (1 == has_cut_point) { + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String overtimePoint = Util.null2String(kqSettingsComInfo.getMain_val("overtime_point"), "0"); + boolean needPointCut = false; + if ("1".equals(overtimePoint)) { + needPointCut = true; + } + //如果签退大于签到 表示打卡跨天 + if (cur_date_cut_point.compareTo(signoutdatetime) < 0) { + String hasSigninDate = signindate; + String hasSigninTime = signintime; + if (lsCheckInfoMaps.containsKey(key)) { + KQOvertimeCardBean hasOvertimeBean = lsCheckInfoMaps.get(key); + hasSigninDate = hasOvertimeBean.getSigninDate(); + hasSigninTime = hasOvertimeBean.getSigninTime(); + } + KQOvertimeCardBean curOvertimeBean = new KQOvertimeCardBean(); + curOvertimeBean.setSigninDate(hasSigninDate); + curOvertimeBean.setSigninTime(hasSigninTime); + curOvertimeBean.setSignoutDate(nextDate); + curOvertimeBean.setSignoutTime(cut_points); + if (needPointCut) { + //这个是新加的开关,为了保证历史数据,只能这样加了 + if (result.containsKey("beginTime")) { + //上班前打卡和班次开始时间作为第一段加班区间 + curOvertimeBean.setSignoutDate(splitDate); + curOvertimeBean.setSignoutTime(result.get("beginTime") + ":00"); + } + } + curOvertimeBean.setBelongDate(splitDate); + lsCheckInfoMaps.put(key, curOvertimeBean); + + KQOvertimeCardBean nextOvertimeBean = new KQOvertimeCardBean(); + nextOvertimeBean.setSigninDate(nextDate); + nextOvertimeBean.setSigninTime(cut_points); + if (needPointCut) { + //这个是新加的开关,为了保证历史数据,只能这样加了 + if (result.containsKey("endTime") && result.containsKey("endTimeAcross")) { + if (result.get("endTimeAcross").equals("1")) { + String endTime = kqTimesArrayComInfo.turn48to24Time(result.get("endTime")) + ":00"; + if (cut_points.compareTo(endTime) > 0) { + //如果下班时间跨天了,但是下班时间早于临界点 + //下班时间和开启的加班归属点作为第二段加班区间 + KQOvertimeCardBean curNextOvertimeBean = new KQOvertimeCardBean(); + curNextOvertimeBean.setSigninDate(nextDate); + curNextOvertimeBean.setSigninTime(endTime); + curNextOvertimeBean.setSignoutDate(nextDate); + curNextOvertimeBean.setSignoutTime(cut_points); + curNextOvertimeBean.setBelongDate(splitDate); + if (lsCheckInfoMaps.containsKey(key)) { + KQOvertimeCardBean kqOvertimeCardBean = lsCheckInfoMaps.get(key); + curNextOvertimeBean.setSigninDate(kqOvertimeCardBean.getSigninDate()); + curNextOvertimeBean.setSigninTime(kqOvertimeCardBean.getSigninTime()); + } + lsCheckInfoMaps.put(key, curNextOvertimeBean); + } else { + nextOvertimeBean.setSigninDate(nextDate); + nextOvertimeBean.setSigninTime(endTime); + } + } else { + //下班时间和开启的加班归属点作为第二段加班区间 + String endTime = result.get("endTime") + ":00"; + KQOvertimeCardBean curNextOvertimeBean = new KQOvertimeCardBean(); + curNextOvertimeBean.setSigninDate(splitDate); + curNextOvertimeBean.setSigninTime(endTime); + curNextOvertimeBean.setSignoutDate(nextDate); + curNextOvertimeBean.setSignoutTime(cut_points); + curNextOvertimeBean.setBelongDate(splitDate); + if (lsCheckInfoMaps.containsKey(key)) { + KQOvertimeCardBean kqOvertimeCardBean = lsCheckInfoMaps.get(key); + curNextOvertimeBean.setSigninDate(kqOvertimeCardBean.getSigninDate()); + curNextOvertimeBean.setSigninTime(kqOvertimeCardBean.getSigninTime()); + } + lsCheckInfoMaps.put(key, curNextOvertimeBean); + } + } + } + nextOvertimeBean.setSignoutDate(signoutdate); + nextOvertimeBean.setSignoutTime(signouttime); + nextOvertimeBean.setBelongDate(nextDate); + //加班归属点和跨天的下班签退卡作为第三段加班区间 + lsCheckInfoMaps.put(nextkey, nextOvertimeBean); + } + } + } + } + //如果存在签到时间跨到前一天的情况 + if (signindate.length() > 0 && signindate.compareTo(splitDate) < 0) { + if (1 == pre_has_cut_point) { + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String overtimePoint = Util.null2String(kqSettingsComInfo.getMain_val("overtime_point"), "0"); + boolean needPointCut = false; + if ("1".equals(overtimePoint)) { + needPointCut = true; + } + if (needPointCut) { + if (signindatetime.compareTo(pre_date_cut_point) < 0) { + if (lsCheckInfoMaps.containsKey(preKey)) { + if (signoutdate.length() > 0 && signouttime.length() > 0) { + KQOvertimeCardBean preKqOvertimeBean = new KQOvertimeCardBean(); + preKqOvertimeBean.setSigninDate(pre_signindate); + preKqOvertimeBean.setSigninTime(pre_signintime); + preKqOvertimeBean.setSignoutDate(pre_signoutdate); + preKqOvertimeBean.setSignoutTime(pre_signouttime); + preKqOvertimeBean.setBelongDate(preDate); + lsCheckInfoMaps.put(preKey, preKqOvertimeBean); + + //这是一种特殊情况,跨天临界点是0点,然后签到时间跨到前一天去了,如果这时候还开了0点拆分,那么0点前的部分和0点后的部分都需要处理 + String[] keys = key.split("_"); + if (keys.length > 1) { + String resourceid = keys[0]; + String beforeKey = resourceid + "_" + signindate + "_" + splitDate; + KQOvertimeCardBean todayInPreOvertimeBean = new KQOvertimeCardBean(); + todayInPreOvertimeBean.setSigninDate(signindate); + todayInPreOvertimeBean.setSigninTime(signintime); + todayInPreOvertimeBean.setSignoutDate(splitDate); + todayInPreOvertimeBean.setSignoutTime(pre_cut_points); + todayInPreOvertimeBean.setBelongDate(splitDate); + lsCheckInfoMaps.put(beforeKey, todayInPreOvertimeBean); + } + } + } else { + //这是一种特殊情况,跨天临界点是0点,然后签到时间跨到前一天去了,如果这时候还开了0点拆分,那么0点前的部分和0点后的部分都需要处理 + String[] keys = key.split("_"); + if (keys.length > 1) { + String resourceid = keys[0]; + String beforeKey = resourceid + "_" + signindate + "_" + splitDate; + KQOvertimeCardBean todayInPreOvertimeBean = new KQOvertimeCardBean(); + todayInPreOvertimeBean.setSigninDate(signindate); + todayInPreOvertimeBean.setSigninTime(signintime); + todayInPreOvertimeBean.setSignoutDate(splitDate); + todayInPreOvertimeBean.setSignoutTime(pre_cut_points); + todayInPreOvertimeBean.setBelongDate(splitDate); + lsCheckInfoMaps.put(beforeKey, todayInPreOvertimeBean); + } + } + } + } + } + } + } + + + /** + * 重新把打卡数据按照归属来赋值 + */ + public void rePutCheckInfoMap(Map lsCheckInfoMaps, + KQOvertimeCardBean kqOvertimeBean, + String preKey, String key, String overtime_cut_point, String splitDate, + Map eventMap, int has_cut_point, Map result, String nextkey) { + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + + String nextDate = DateUtil.addDate(splitDate, 1); + String cut_point = Util.null2String(result.get("cut_point")); + String next_overtime_cut_points = cut_point + ":00"; + String next_date_cut_point = nextDate + " " + next_overtime_cut_points; + + String preDate = DateUtil.addDate(splitDate, -1); + String overtime_cut_points = overtime_cut_point + ":00"; + String date_cut_point = splitDate + " " + overtime_cut_points; + String signindate = kqOvertimeBean.getSigninDate(); + String signoutdate = kqOvertimeBean.getSignoutDate(); + String signintime = kqOvertimeBean.getSigninTime(); + String signouttime = kqOvertimeBean.getSignoutTime(); + String signindatetime = kqOvertimeBean.getSigninDate() + " " + kqOvertimeBean.getSigninTime(); + String signoutdatetime = ""; + if (kqOvertimeBean.getSignoutDate().length() > 0 && kqOvertimeBean.getSignoutTime().length() > 0) { + //如果是休息日的话,可能存在没有上班时间的情况 + signoutdatetime = kqOvertimeBean.getSignoutDate() + " " + kqOvertimeBean.getSignoutTime(); + } + + String timeInfo = "date_cut_point:" + date_cut_point + ":signoutdatetime:" + signoutdatetime + ":signindatetime:" + signindatetime; + String timeCompare1 = "date_cut_point.compareTo(signoutdatetime):" + date_cut_point.compareTo(signoutdatetime); + String timeCompare2 = "date_cut_point.compareTo(signindatetime):" + date_cut_point.compareTo(signindatetime); + eventMap.put("timeInfo", timeInfo); + eventMap.put("timeCompare1", timeCompare1); + eventMap.put("timeCompare2", timeCompare2); + if (date_cut_point.compareTo(signindatetime) > 0) { + //如果归属大于签到时间,小于签退时间,表示归属之前是属于前一天的,归属之后的是属于今天的 + //不开启了归属的时候,根据打卡的性质来判断,如果是签到卡,那么签到时间到前一天上班时间,这段区间内算是前一天的加班卡,和开启了归属不一样 + KQOvertimeCardBean preKqOvertimeBean = new KQOvertimeCardBean(); + preKqOvertimeBean.setSigninDate(signindate); + preKqOvertimeBean.setSigninTime(signintime); + preKqOvertimeBean.setSignoutDate(splitDate); + preKqOvertimeBean.setSignoutTime(overtime_cut_points); + preKqOvertimeBean.setBelongDate(preDate); + preKqOvertimeBean.setHas_cut_point("0"); + lsCheckInfoMaps.put(preKey, preKqOvertimeBean); + + if (signoutdatetime.length() > 0 && signoutdatetime.compareTo(date_cut_point) > 0) { + + KQOvertimeCardBean curOvertimeBean = new KQOvertimeCardBean(); + curOvertimeBean.setSigninDate(splitDate); + curOvertimeBean.setSigninTime(overtime_cut_points); + curOvertimeBean.setSignoutDate(signoutdate); + curOvertimeBean.setSignoutTime(signouttime); + curOvertimeBean.setBelongDate(splitDate); + curOvertimeBean.setHas_cut_point("0"); + lsCheckInfoMaps.put(key, curOvertimeBean); + } + } else if (signoutdatetime.length() > 0 && date_cut_point.compareTo(signoutdatetime) > 0) { + //如果归属大于签退时间 表示这个时间都是属于前一天的 + if (signindate.length() > 0 && signintime.length() > 0 && signoutdate.length() > 0 && signouttime.length() > 0) { + lsCheckInfoMaps.put(preKey, kqOvertimeBean); + } + } else { + //如果归属 小于签到时间,则都属于今天 + if (signindate.length() > 0 && signintime.length() > 0 && signoutdate.length() > 0 && signouttime.length() > 0) { + lsCheckInfoMaps.put(key, kqOvertimeBean); + } + } + + if (signoutdate.length() > 0) { + if (signoutdate.compareTo(splitDate) > 0) { + if (1 == has_cut_point) { + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String overtimePoint = Util.null2String(kqSettingsComInfo.getMain_val("overtime_point"), "0"); + boolean needPointCut = false; + if ("1".equals(overtimePoint)) { + needPointCut = true; + } + //没这个开关的话不会有下面的逻辑 + if (needPointCut) { + //如果签退大于签到 表示打卡跨天 + if (next_date_cut_point.compareTo(signoutdatetime) < 0) { + String hasSigninDate = signindate; + String hasSigninTime = signintime; + if (lsCheckInfoMaps.containsKey(key)) { + KQOvertimeCardBean hasOvertimeBean = lsCheckInfoMaps.get(key); + hasSigninDate = hasOvertimeBean.getSigninDate(); + hasSigninTime = hasOvertimeBean.getSigninTime(); + } + KQOvertimeCardBean curOvertimeBean = new KQOvertimeCardBean(); + curOvertimeBean.setSigninDate(hasSigninDate); + curOvertimeBean.setSigninTime(hasSigninTime); + curOvertimeBean.setSignoutDate(nextDate); + curOvertimeBean.setSignoutTime(next_overtime_cut_points); + //这个是新加的开关,为了保证历史数据,只能这样加了 + if (result.containsKey("beginTime")) { + //上班前打卡和班次开始时间作为第一段加班区间 + curOvertimeBean.setSignoutDate(splitDate); + curOvertimeBean.setSignoutTime(result.get("beginTime") + ":00"); + } + curOvertimeBean.setBelongDate(splitDate); + lsCheckInfoMaps.put(key, curOvertimeBean); + + KQOvertimeCardBean nextOvertimeBean = new KQOvertimeCardBean(); + nextOvertimeBean.setSigninDate(nextDate); + nextOvertimeBean.setSigninTime(next_overtime_cut_points); + //这个是新加的开关,为了保证历史数据,只能这样加了 + if (result.containsKey("endTime") && result.containsKey("endTimeAcross")) { + if (result.get("endTimeAcross").equals("1")) { + String tmp1 = nextDate + " " + kqTimesArrayComInfo.turn48to24Time(result.get("endTime")) + ":00"; + if (next_date_cut_point.compareTo(tmp1) > 0) { + //如果跨天归属点大于下班时间,需要再根据归属点分割下 + KQOvertimeCardBean curNextOvertimeBean = new KQOvertimeCardBean(); + curNextOvertimeBean.setSigninDate(nextDate); + curNextOvertimeBean.setSigninTime(kqTimesArrayComInfo.turn48to24Time(result.get("endTime")) + ":00"); + curNextOvertimeBean.setSignoutDate(nextDate); + curNextOvertimeBean.setSignoutTime(next_overtime_cut_points); + curNextOvertimeBean.setBelongDate(splitDate); + if (lsCheckInfoMaps.containsKey(key)) { + KQOvertimeCardBean kqOvertimeCardBean = lsCheckInfoMaps.get(key); + curNextOvertimeBean.setSigninDate(kqOvertimeCardBean.getSigninDate()); + curNextOvertimeBean.setSigninTime(kqOvertimeCardBean.getSigninTime()); + } + lsCheckInfoMaps.put(key, curNextOvertimeBean); + } else { + nextOvertimeBean.setSigninDate(nextDate); + nextOvertimeBean.setSigninTime(kqTimesArrayComInfo.turn48to24Time(result.get("endTime")) + ":00"); + } + } else { + //下班时间和开启的加班归属点作为第二段加班区间 + KQOvertimeCardBean curNextOvertimeBean = new KQOvertimeCardBean(); + curNextOvertimeBean.setSigninDate(splitDate); + curNextOvertimeBean.setSigninTime(result.get("endTime") + ":00"); + curNextOvertimeBean.setSignoutDate(nextDate); + curNextOvertimeBean.setSignoutTime(next_overtime_cut_points); + curNextOvertimeBean.setBelongDate(splitDate); + if (lsCheckInfoMaps.containsKey(key)) { + KQOvertimeCardBean kqOvertimeCardBean = lsCheckInfoMaps.get(key); + curNextOvertimeBean.setSigninDate(kqOvertimeCardBean.getSigninDate()); + curNextOvertimeBean.setSigninTime(kqOvertimeCardBean.getSigninTime()); + } + lsCheckInfoMaps.put(key, curNextOvertimeBean); + } + } + nextOvertimeBean.setSignoutDate(signoutdate); + nextOvertimeBean.setSignoutTime(signouttime); + nextOvertimeBean.setBelongDate(nextDate); + //加班归属点和跨天的下班签退卡作为第三段加班区间 + lsCheckInfoMaps.put(nextkey, nextOvertimeBean); + } + } + } + } + } + //如果存在签到时间跨到前一天的情况 + if (signindate.length() > 0 && signindate.compareTo(splitDate) < 0) { + if (signindatetime.compareTo(date_cut_point) < 0) { + //这是一种特殊情况,跨天临界点是0点,然后签到时间跨到前一天去了,如果这时候还开了0点拆分,那么0点前的部分和0点后的部分都需要处理 + String[] keys = key.split("_"); + if (keys.length > 1) { + String resourceid = keys[0]; + String beforeKey = resourceid + "_" + signindate + "_" + splitDate; + KQOvertimeCardBean todayInPreOvertimeBean = new KQOvertimeCardBean(); + todayInPreOvertimeBean.setSigninDate(signindate); + todayInPreOvertimeBean.setSigninTime(signintime); + todayInPreOvertimeBean.setSignoutDate(splitDate); + todayInPreOvertimeBean.setSignoutTime(overtime_cut_points); + todayInPreOvertimeBean.setBelongDate(splitDate); + lsCheckInfoMaps.put(beforeKey, todayInPreOvertimeBean); + } + } + } + } + + + /** + * 获取加班流程数据 + * + * @param resourceid + * @param fromDate + * @param toDate + * @param splitBeanMaps + * @param dateFormatter + */ + private void getOverTimeFlowData(String resourceid, String fromDate, String toDate, + Map> splitBeanMaps, + DateTimeFormatter dateFormatter) { + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate preFromDate = localFromDate.minusDays(1); + LocalDate localToDate = LocalDate.parse(toDate); + long betweenDays = localToDate.toEpochDay() - preFromDate.toEpochDay(); + for (int k = 0; k <= betweenDays; k++) { + LocalDate curLocalDate = preFromDate.plusDays(k); + String splitDate = curLocalDate.format(dateFormatter); + String key = resourceid + "_" + splitDate; + String order_sql = " order by belongdate,fromtime "; + KQFlowDataBiz kqFlowDataBiz = new KQFlowDataBiz.FlowDataParamBuilder().belongDateParam(splitDate).resourceidParam(resourceid).orderby_sqlParam(order_sql).build(); + Map flowMaps = Maps.newHashMap(); + List splitBeans = kqFlowDataBiz.getOverTimeData(flowMaps); + if (!splitBeans.isEmpty()) { + splitBeanMaps.put(key, splitBeans); + } + } + } + + /** + * 获取非工作日的打卡数据 + * + * @param resourceid + * @param splitDate + * @param preDate + * @param nextDate + * @param curKqOvertimeRulesDetailEntity + * @param eventMap + * @param preKqOvertimeRulesDetailEntity + * @return + */ + private Map getRestSignInfo(String resourceid, String splitDate, String preDate, + String nextDate, + KQOvertimeRulesDetailEntity curKqOvertimeRulesDetailEntity, + Map eventMap, + KQOvertimeRulesDetailEntity preKqOvertimeRulesDetailEntity) { + Map signMap = Maps.newHashMap(); + WorkTimeEntity pre_workTime = new KQWorkTime().getWorkTime(resourceid, preDate); + List pre_lsSignTime = new ArrayList<>(); + + if (pre_workTime != null) { + pre_lsSignTime = pre_workTime.getSignTime();//允许打卡时间 + pre_lsSignTime = pre_lsSignTime != null ? pre_lsSignTime : new ArrayList<>(); + } + WorkTimeEntity next_workTime = new KQWorkTime().getWorkTime(resourceid, nextDate); + List next_lsSignTime = new ArrayList<>(); + + if (next_workTime != null) { + next_lsSignTime = next_workTime.getSignTime();//允许打卡时间 + next_lsSignTime = next_lsSignTime != null ? next_lsSignTime : new ArrayList<>(); + } + + signMap = getNonWorkSignInfo(resourceid, nextDate, splitDate, pre_lsSignTime, next_lsSignTime, curKqOvertimeRulesDetailEntity, eventMap, preKqOvertimeRulesDetailEntity); + + return signMap; + } + + + /** + * 获取非工作日的打卡数据 封装处理下 + * + * @param resourceid + * @param nextDate + * @param kqDate + * @param pre_lsSignTime + * @param next_lsSignTime + * @param curKqOvertimeRulesDetailEntity + * @param eventMap + * @param preKqOvertimeRulesDetailEntity + * @return + */ + public Map getNonWorkSignInfo(String resourceid, String nextDate, String kqDate, + List pre_lsSignTime, + List next_lsSignTime, + KQOvertimeRulesDetailEntity curKqOvertimeRulesDetailEntity, + Map eventMap, + KQOvertimeRulesDetailEntity preKqOvertimeRulesDetailEntity) { + Map signMap = Maps.newHashMap(); + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String overtimePoint = Util.null2String(kqSettingsComInfo.getMain_val("overtime_point"), "0"); + boolean needPointCut = false; + if ("1".equals(overtimePoint)) { + needPointCut = true; + } + KQFormatSignData kqFormatSignData = new KQFormatSignData(); + List lsCheckInfo = new ArrayList<>(); + Map checkInfo = null; + RecordSet rs = new RecordSet(); + String pre_Worktime4Today = ""; + if (!pre_lsSignTime.isEmpty()) { + TimeScopeEntity pre_signTimeScope = pre_lsSignTime.get(pre_lsSignTime.size() - 1); + if (pre_signTimeScope.getEndTimeAcross()) { + pre_Worktime4Today = pre_signTimeScope.getEndTime(); + } + } + String next_Worktime4Today = ""; + if (!next_lsSignTime.isEmpty()) { + TimeScopeEntity next_signTimeScope = next_lsSignTime.get(next_lsSignTime.size() - 1); + if (next_signTimeScope.isBeginTimePreAcross()) { + next_Worktime4Today = next_signTimeScope.getBeginTime(); + } + } + String signBeginDateTime = kqDate + " 00:00:00"; + String signEndDateTime = kqDate + " 23:59:59"; + //有这么一种情况,比如前一天是工作日,最晚签退是2点,然后工作日的归属是设置的5点,那么如果4点打一个卡的话,其实是需要生成加班的,因为4带你这个卡是昨日的签退 + String ore_signBeginDateTime = signBeginDateTime; + String base_sql = kqFormatSignData.signSignSql(rs); + + int pre_has_cut_point = preKqOvertimeRulesDetailEntity != null ? preKqOvertimeRulesDetailEntity.getHas_cut_point() : 0; + + if (pre_Worktime4Today.length() > 0) { + if (!needPointCut && pre_has_cut_point == 1) { + String cut_point = Util.null2String(preKqOvertimeRulesDetailEntity.getCut_point()); + if (cut_point.length() > 0) { + if (cut_point.compareTo(pre_Worktime4Today) > 0) { + pre_Worktime4Today = cut_point; + } else { + if (pre_Worktime4Today.length() == 5) { + pre_Worktime4Today += ":00"; + } + ore_signBeginDateTime = kqDate + " " + pre_Worktime4Today; + } + /** + 打卡数据:2022/04/29 09:00:00----2022/04/29 23:59:59---2022/04/30 00:00:00----2022/04/30 02:00:00 + 加班流程:2022-04-29 20:00---2022-04-30 03:00 + 加班规则:2022-04-29周五工作日自定义跨天归属设置为00:00,取交集,然后30号的00:00-02:00两个小时加班无法生成 + 问题原因:当29的下班卡结束打卡时间在自定义跨天00:00之后,那么读卡范围是:29号结束打卡时间(pre_Worktime4Today)开始的 + */ + pre_Worktime4Today = cut_point + ":01"; + } + } + if (pre_Worktime4Today.length() == 5) { + pre_Worktime4Today += ":00"; + } + signBeginDateTime = kqDate + " " + pre_Worktime4Today; + } else { + if (!needPointCut && pre_has_cut_point == 1) { + String cut_point = Util.null2String(preKqOvertimeRulesDetailEntity.getCut_point()); + if (cut_point.length() > 0) { + String cut_point_time = kqDate + " " + cut_point + ":00"; + signBeginDateTime = cut_point_time; + } + } + } + if (next_Worktime4Today.length() > 0) { + if (next_Worktime4Today.length() == 5) { + next_Worktime4Today += ":00"; + } + signEndDateTime = kqDate + " " + next_Worktime4Today; + } else { + if (curKqOvertimeRulesDetailEntity != null) { + int cur_has_cut_point = curKqOvertimeRulesDetailEntity.getHas_cut_point(); + if (!needPointCut && cur_has_cut_point == 1) { + String cut_point = Util.null2String(curKqOvertimeRulesDetailEntity.getCut_point()); + if (cut_point.length() > 0) { + String cut_point_time = nextDate + " " + cut_point + ":00"; + signEndDateTime = cut_point_time; + } + } + } + } + String sql = "select * from (" + base_sql + ") a " + " order by signdate asc,signtime asc "; + rs.executeQuery(sql, resourceid, signBeginDateTime, signEndDateTime); + String nonwork_card_sql = "sql:" + sql + "|resourceid|" + resourceid + "|signBeginDateTime|" + signBeginDateTime + "|signEndDateTime|" + signEndDateTime; + eventMap.put("非工作日打卡sql|nonwork_card_sql", nonwork_card_sql); + eventMap.put("非工作日打卡sql结果|nonwork_card_sql_getCounts", rs.getCounts()); + int idx = 0; + while (rs.next()) { + String signId = Util.null2String(rs.getString("id")); + String signdate = Util.null2String(rs.getString("signdate")); + String signtime = Util.null2String(rs.getString("signtime")); + + checkInfo = new HashMap<>(); + checkInfo.put("signId", signId);//签到签退标识 + checkInfo.put("signDate", signdate);//签到签退日期 + checkInfo.put("signTime", signtime);//签到签退时间 + idx++; + if (idx == 1) {//第一条算签到 + checkInfo.put("signType", "1"); + lsCheckInfo.add(checkInfo); + } else if (idx == rs.getCounts()) {//最后一条算签退 + checkInfo.put("signType", "2"); + lsCheckInfo.add(checkInfo); + } + } + if (lsCheckInfo != null && !lsCheckInfo.isEmpty()) { + if (lsCheckInfo.size() == 2) { + Map begin_signMap = (Map) lsCheckInfo.get(0); + Map end_signMap = (Map) lsCheckInfo.get(lsCheckInfo.size() - 1); + signMap.put("signindate", begin_signMap.get("signDate")); + signMap.put("signintime", begin_signMap.get("signTime")); + signMap.put("signoutdate", end_signMap.get("signDate")); + signMap.put("signouttime", end_signMap.get("signTime")); + } else if (lsCheckInfo.size() == 1) { + Map begin_signMap = (Map) lsCheckInfo.get(0); + signMap.put("signindate", begin_signMap.get("signDate")); + signMap.put("signintime", begin_signMap.get("signTime")); + } + } else { + if (false) { + sql = "select * from (" + base_sql + ") a " + " order by signdate asc,signtime asc "; + rs.executeQuery(sql, resourceid, ore_signBeginDateTime, signEndDateTime); + nonwork_card_sql = "sql:" + sql + "|resourceid|" + resourceid + "|ore_signBeginDateTime|" + ore_signBeginDateTime + "|signEndDateTime|" + signEndDateTime; + eventMap.put("昨日开启了打卡归属,非工作日打卡sql|nonwork_card_sql", nonwork_card_sql); + eventMap.put("昨日开启了打卡归属,非工作日打卡sql结果|nonwork_card_sql_getCounts", rs.getCounts()); + idx = 0; + while (rs.next()) { + String signId = Util.null2String(rs.getString("id")); + String signdate = Util.null2String(rs.getString("signdate")); + String signtime = Util.null2String(rs.getString("signtime")); + + checkInfo = new HashMap<>(); + checkInfo.put("signId", signId);//签到签退标识 + checkInfo.put("signDate", signdate);//签到签退日期 + checkInfo.put("signTime", signtime);//签到签退时间 + idx++; + if (idx == 1) {//第一条算签到 + checkInfo.put("signType", "1"); + lsCheckInfo.add(checkInfo); + } else if (idx == rs.getCounts()) {//最后一条算签退 + checkInfo.put("signType", "2"); + lsCheckInfo.add(checkInfo); + } + } + if (lsCheckInfo != null && !lsCheckInfo.isEmpty()) { + //这种情况下,就只是把签到卡传回去作为前一天的签退了 + Map begin_signMap = (Map) lsCheckInfo.get(0); + signMap.put("signindate", begin_signMap.get("signDate")); + signMap.put("signintime", begin_signMap.get("signTime")); + } + } + } + return signMap; + } + + /** + * 获取工作日的打卡数据 + * + * @param userId + * @param signTimeScope + * @param workTimeScope + * @param kqDate + * @param preDate + * @param nextDate + * @param kqTimesArrayComInfo + * @param eventMap + * @param index + * @param result + * @return + */ + + public Map getSignInfo(String userId, TimeScopeEntity signTimeScope, + TimeScopeEntity workTimeScope, String kqDate, String preDate, + String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo, Map eventMap, + int index, Map result) { + return getSignInfo(userId, signTimeScope, workTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo, eventMap, index, result,0); + } + public Map getSignInfo(String userId, TimeScopeEntity signTimeScope, + TimeScopeEntity workTimeScope, String kqDate, String preDate, + String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo, Map eventMap, + int index, Map result,int signoutOnlyoff) { + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String overtimePoint = Util.null2String(kqSettingsComInfo.getMain_val("overtime_point"), "0"); + boolean needPointCut = true; + if ("1".equals(overtimePoint)) { + needPointCut = false; + } + + Map signMap = Maps.newHashMap(); + KQFormatSignData kqFormatSignData = new KQFormatSignData(); + List lsCheckInfo = new ArrayList<>(); + Map checkInfo = null; + String base_sql = ""; + RecordSet rs = new RecordSet(); + String dbtype = rs.getDBType(); + + int has_cut_point = Util.getIntValue(Util.null2String(result.get("has_cut_point"))); + String cut_point = Util.null2String(result.get("cut_point")); + + int pre_has_cut_point = Util.getIntValue(Util.null2String(result.get("pre_has_cut_point"))); + String pre_cut_point = Util.null2String(result.get("pre_cut_point")); + int lsWorkTime_size = Util.getIntValue(Util.null2String(result.get("lsWorkTime_size"))); + + List> sqlConditions = kqFormatSignData.getCanSignInfo(signTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo,workTimeScope,signoutOnlyoff); + base_sql = kqFormatSignData.signSignSql(rs); + + if (sqlConditions != null && !sqlConditions.isEmpty()) { + boolean hasSignIn = false; + for (int i = 0; i < sqlConditions.size(); i++) { + Map sqlMap = sqlConditions.get(i); + String sql = ""; + String orderSql = ""; + int idx = 0; + String signBeginDateTime = Util.null2String(sqlMap.get("signBeginDateTime")); + String signEndDateTime = Util.null2String(sqlMap.get("signEndDateTime")); + if (index == lsWorkTime_size - 1 && i == sqlConditions.size() - 1) { + //最后一次的打卡范围会被打卡临界点给修改 + if (needPointCut && has_cut_point == 1) { + String cut_point_datettime = nextDate + " " + cut_point + ":59"; + signEndDateTime = cut_point_datettime; + } + } + if (index == 0 && i == 0) { + //第一次的打卡范围会被打卡临界点给修改 + if (needPointCut && pre_has_cut_point == 1) { + String cut_point_datettime = kqDate + " " + pre_cut_point + ":00"; + signBeginDateTime = cut_point_datettime; + } + } + String type = Util.null2String(sqlMap.get("type")); + String signoutOnlyoff_flag = Util.null2String(sqlMap.get("signoutOnlyoff")); + if (type.length() > 0) { + if ("signoff".equalsIgnoreCase(type)) { + orderSql = " order by signdate desc, signtime desc "; + } else if ("signin".equalsIgnoreCase(type)) { + orderSql = " order by signdate asc, signtime asc "; + } + if ("oracle".equalsIgnoreCase(dbtype)) { + sql = "select * from (" + base_sql + " " + orderSql + ") a where rownum=1"; + } else if ("mysql".equalsIgnoreCase(dbtype)) { + sql = "select * from (" + base_sql + " " + orderSql + ") a limit 0,1"; + } else if ("postgresql".equalsIgnoreCase(dbtype)) { + sql = "select * from (" + base_sql + " " + orderSql + ") a limit 1 offset 0"; + } else if ("sqlserver".equalsIgnoreCase(dbtype)) { + sql = "select top 1 * from (" + base_sql + ") a " + " " + orderSql; + } else { + sql = "select * from (" + base_sql + " " + orderSql + ") a where rownum=1"; + } + } else { + orderSql = " order by signdate asc, signtime asc "; + sql = base_sql + " " + orderSql; + } + rs.executeQuery(sql, userId, signBeginDateTime, signEndDateTime); + String work_card_sql = "index:" + index + ":idx:" + idx + "|sql:" + sql + "|resourceid|" + userId + "|signBeginDateTime|" + signBeginDateTime + "|signEndDateTime|" + signEndDateTime; + + eventMap.put("工作日打卡sql|work_card_sql_" + index, work_card_sql); + eventMap.put("工作日打卡sql结果|work_card_sql_getCounts_" + index, rs.getCounts()); + while (rs.next()) { + String signId = Util.null2String(rs.getString("id")); + String signdate = Util.null2String(rs.getString("signdate")); + String signtime = Util.null2String(rs.getString("signtime")); + + checkInfo = new HashMap<>(); + checkInfo.put("signId", signId);//签到签退标识 + checkInfo.put("signDate", signdate);//签到签退日期 + checkInfo.put("signTime", signtime);//签到签退时间 + checkInfo.put("type", type);//是否有打卡归属,type有值就是有打卡归属 + idx++; + if (type.length() > 0) { + if ("signin".equalsIgnoreCase(type)) { + checkInfo.put("signType", "1"); + lsCheckInfo.add(checkInfo); + } else { + checkInfo.put("signType", "2"); + lsCheckInfo.add(checkInfo); + } + } else { + if (signoutOnlyoff_flag.length()>0) { + if("signin".equals(signoutOnlyoff_flag) && idx == 1){ + checkInfo.put("signType", "1"); + checkInfo.put("type", "signin"); + lsCheckInfo.add(checkInfo); + hasSignIn = true; + } + if("signoff".equals(signoutOnlyoff_flag)){ + if ((hasSignIn && idx == rs.getCounts() && idx > 1) || (!hasSignIn && idx == rs.getCounts())) {//第一条可能是签到卡需要处理下,否则可能会导致一条上班卡同时识别为上班卡和下班卡 + checkInfo.put("signType", "2"); + checkInfo.put("type", "signoff"); + lsCheckInfo.add(checkInfo); + } + } + }else{ + if (idx == 1) {//第一条算签到 + checkInfo.put("signType", "1"); + lsCheckInfo.add(checkInfo); + hasSignIn = true; + } else if (idx == rs.getCounts()) {//最后一条算签退 + checkInfo.put("signType", "2"); + lsCheckInfo.add(checkInfo); + } + } + } + } + } + } + if (lsCheckInfo != null && !lsCheckInfo.isEmpty()) { + if (lsCheckInfo.size() == 1) { + Map checkInfoMap = (Map) lsCheckInfo.get(0); + String type = Util.null2String(checkInfoMap.get("type")); + if (workTimeScope != null) { + if ("signin".equalsIgnoreCase(type)) { + signMap.put("signindate", checkInfoMap.get("signDate")); + signMap.put("signintime", checkInfoMap.get("signTime")); + signMap.put("signoutdate", workTimeScope.getBeginTimeAcross() ? nextDate : kqDate); + signMap.put("signouttime", kqTimesArrayComInfo.turn48to24Time(workTimeScope.getBeginTime()) + ":00"); + } else if ("signoff".equalsIgnoreCase(type)) { + signMap.put("signindate", workTimeScope.getEndTimeAcross() ? nextDate : kqDate); + signMap.put("signintime", kqTimesArrayComInfo.turn48to24Time(workTimeScope.getEndTime()) + ":00"); + signMap.put("signoutdate", checkInfoMap.get("signDate")); + signMap.put("signouttime", checkInfoMap.get("signTime")); + } else { + signMap.put("signindate", checkInfoMap.get("signDate")); + signMap.put("signintime", checkInfoMap.get("signTime")); + signMap.put("signoutdate", workTimeScope.getBeginTimeAcross() ? nextDate : kqDate); + signMap.put("signouttime", kqTimesArrayComInfo.turn48to24Time(workTimeScope.getBeginTime()) + ":00"); + } + } + } else { + Map begin_signMap = (Map) lsCheckInfo.get(0); + Map end_signMap = (Map) lsCheckInfo.get(lsCheckInfo.size() - 1); + signMap.put("signindate", begin_signMap.get("signDate")); + signMap.put("signintime", begin_signMap.get("signTime")); + signMap.put("signoutdate", end_signMap.get("signDate")); + signMap.put("signouttime", end_signMap.get("signTime")); + } + } + return signMap; + } + + /** + * 获取已经生成过的加班数据 + * + * @param resourceid + * @param belongdate + * @param hasOverTimeList + */ + private void getHasOverTimeData(String resourceid, String belongdate, List> hasOverTimeList) { + RecordSet rs = new RecordSet(); + + String sql = " select * from kq_flow_overtime where resourceid = ? and belongdate = ? "; + rs.executeQuery(sql, resourceid, belongdate); + while (rs.next()) { + String requestid = rs.getString("requestid"); + String fromdate = rs.getString("fromdate"); + String fromtime = rs.getString("fromtime"); + String todate = rs.getString("todate"); + String totime = rs.getString("totime"); + String duration_min = Util.null2String(rs.getString("duration_min")); + String flow_dataid = Util.null2String(rs.getString("flow_dataid")); + String ori_belongdate = Util.null2String(rs.getString("ori_belongdate")); + //流程+打卡的时候,存的对应的流程数据 + String fromdate_flow = rs.getString("fromdatedb"); + String fromtime_flow = rs.getString("fromtimedb"); + String todate_flow = rs.getString("todatedb"); + String totime_flow = rs.getString("totimedb"); + Map hasOverTimeMap = Maps.newHashMap(); + hasOverTimeMap.put("resourceid", resourceid); + hasOverTimeMap.put("belongdate", belongdate); + hasOverTimeMap.put("requestid", requestid); + hasOverTimeMap.put("fromdate", fromdate); + hasOverTimeMap.put("fromtime", fromtime); + hasOverTimeMap.put("todate", todate); + hasOverTimeMap.put("totime", totime); + hasOverTimeMap.put("fromdate_flow", fromdate_flow); + hasOverTimeMap.put("fromtime_flow", fromtime_flow); + hasOverTimeMap.put("todate_flow", todate_flow); + hasOverTimeMap.put("totime_flow", totime_flow); + hasOverTimeMap.put("duration_min", duration_min); + hasOverTimeMap.put("flow_dataid", flow_dataid); + hasOverTimeMap.put("ori_belongdate", ori_belongdate); + + hasOverTimeList.add(hasOverTimeMap); + } + } + + /** + * 根据人和日期获取加班规则里的信息 + * + * @param resourceid + * @param fromDate + * @param toDate + * @param dateFormatter + * @param changeTypeMap + * @param overRulesDetailMap + * @param restTimeMap + * @param computingModeMap + */ + public void getOverTimeDataMap(String resourceid, String fromDate, String toDate, + DateTimeFormatter dateFormatter, Map changeTypeMap, + Map overRulesDetailMap, Map> restTimeMap, Map computingModeMap) { + + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate localToDate = LocalDate.parse(toDate); + LocalDate preFromDate = localFromDate.minusDays(2); + LocalDate nextToDate = localToDate.plusDays(1); + long betweenDays = nextToDate.toEpochDay() - preFromDate.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + LocalDate curLocalDate = preFromDate.plusDays(i); + String splitDate = curLocalDate.format(dateFormatter); + KQOvertimeRulesBiz.getOverTimeData(resourceid, splitDate, changeTypeMap, overRulesDetailMap, restTimeMap, computingModeMap); + } + } + + public void logOvertimeMap(Map overtimeLogMap, Object params, String keys) { + if (overtimeLogMap != null) { + overtimeLogMap.put(keys, params); + } + } + + /** + * 判断是否开启了调休 + * + * @param kqOvertimeRulesDetailEntity + * @param overtime_type + * @return + */ + public int getPaidLeaveEnable(KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity, + String overtime_type) { + int paidLeaveEnable = -1; + if (kqOvertimeRulesDetailEntity != null) { + paidLeaveEnable = kqOvertimeRulesDetailEntity.getPaidLeaveEnable(); + paidLeaveEnable = paidLeaveEnable == 1 ? 1 : 0; + } + int paidLeaveEnableType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableType(); + if (2 == paidLeaveEnableType) { +// logOvertimeMap(overtimeLogMap, overtime_type, flow_cross_key+"|关联调休与否来自于流程选择,加班类型下拉框值|overtime_type"); + if ("0".equalsIgnoreCase(overtime_type)) { + paidLeaveEnable = 1; + } else if ("1".equalsIgnoreCase(overtime_type)) { + paidLeaveEnable = 0; + } else { + paidLeaveEnable = 0; + } + } + return paidLeaveEnable; + } + + + /** + * 清掉之前的加班和调休,重新生成 + * + * @param resourceid + * @param belongdate + * @param overtimeLogMap + * @param splitDate + */ + public void clearOvertimeTX(String resourceid, String belongdate, + Map overtimeLogMap, String splitDate) { + List all_tiaoxiuidList = Lists.newArrayList(); + String all_tiaoxiuids = ""; + RecordSet rs = new RecordSet(); + String sql = "select * from kq_flow_overtime where resourceid = ? and belongdate=? and ori_belongdate=? "; + rs.executeQuery(sql, resourceid, belongdate, splitDate); + while (rs.next()) { + String tiaoxiuid = Util.null2String(rs.getString("tiaoxiuid"), ""); + if (tiaoxiuid.length() > 0 && Util.getIntValue(tiaoxiuid) > 0) { + all_tiaoxiuids += "," + tiaoxiuid; + all_tiaoxiuidList.add(tiaoxiuid); + } + } + logOvertimeMap(overtimeLogMap, all_tiaoxiuids, "需要重新生成的调休|all_tiaoxiuids"); + if (all_tiaoxiuids.length() > 0) { + all_tiaoxiuids = all_tiaoxiuids.substring(1); + + Map tiaoxiuamountMap = Maps.newLinkedHashMap(); + String selSql = "select * from kq_balanceofleave where " + Util.getSubINClause(all_tiaoxiuids, "id", "in"); + rs.executeQuery(selSql); + while (rs.next()) { + String id = rs.getString("id"); + String tiaoxiuamount = rs.getString("tiaoxiuamount"); + tiaoxiuamountMap.put(id, tiaoxiuamount); + } + if (!tiaoxiuamountMap.isEmpty()) { + logOvertimeMap(overtimeLogMap, tiaoxiuamountMap, "先记录下之前的加班生成的调休数据|tiaoxiuamountMap"); + } + String tiaoxiuidis0 = ""; + String delSql0 = "select * from kq_balanceofleave where " + Util.getSubINClause(all_tiaoxiuids, "id", "in") + " and " + + " baseamount =0 and extraamount=0 and usedamount=0 and baseamount2=0 and extraamount2=0 and usedamount2=0 "; + if (rs.getDBType().equalsIgnoreCase("oracle")) { + delSql0 = "select * from kq_balanceofleave where " + Util.getSubINClause(all_tiaoxiuids, "id", "in") + " and " + + " nvl(baseamount,0) =0 and nvl(extraamount,0)=0 and nvl(usedamount,0)=0 and nvl(baseamount2,0)=0 " + + " and nvl(extraamount2,0)=0 and nvl(usedamount2,0)=0 "; + } else if ((rs.getDBType()).equalsIgnoreCase("mysql")) { + delSql0 = "select * from kq_balanceofleave where " + Util.getSubINClause(all_tiaoxiuids, "id", "in") + " and " + + " ifnull(baseamount,0) =0 and ifnull(extraamount,0)=0 and ifnull(usedamount,0)=0 and ifnull(baseamount2,0)=0 " + + " and ifnull(extraamount2,0)=0 and ifnull(usedamount2,0)=0 "; + } else { + delSql0 = "select * from kq_balanceofleave where " + Util.getSubINClause(all_tiaoxiuids, "id", "in") + " and " + + " isnull(baseamount,0) =0 and isnull(extraamount,0)=0 and isnull(usedamount,0)=0 and isnull(baseamount2,0)=0 " + + " and isnull(extraamount2,0)=0 and isnull(usedamount2,0)=0 "; + } + rs.executeQuery(delSql0); + while (rs.next()) { + String tiaoxiuid = Util.null2String(rs.getString("id"), ""); + if (tiaoxiuid.length() > 0 && Util.getIntValue(tiaoxiuid) > 0) { + tiaoxiuidis0 += "," + tiaoxiuid; + all_tiaoxiuidList.remove(tiaoxiuid); + } + } + String delSql = ""; + if (tiaoxiuidis0.length() > 0) { + delSql = "delete from kq_balanceofleave where " + Util.getSubINClause(tiaoxiuidis0, "id", "in"); + boolean flag = rs.executeUpdate(delSql); + if (!flag) { + kqLog.info("加班流程删除之前的调休数据失败:数据库更新失败"); + } + } + String clearSql = ""; + boolean isclearOk = false; + if (!all_tiaoxiuidList.isEmpty()) { + String clear_tiaoxiuids = all_tiaoxiuidList.stream().collect(Collectors.joining(",")); + clearSql = "update kq_balanceofleave set tiaoxiuamount=0.0, update_time=? where " + Util.getSubINClause(clear_tiaoxiuids, "id", "in"); + isclearOk = rs.executeUpdate(clearSql, KQDateUtil.getUpdateTimeStamp()); + } + + String delUsageSql = "delete from kq_usagehistory where " + Util.getSubINClause(all_tiaoxiuids, "balanceofleaveid", "in"); + boolean isdelUsageOk = rs.executeUpdate(delUsageSql); + Map logSqlMap = Maps.newLinkedHashMap(); + logSqlMap.put("tiaoxiuidis0", tiaoxiuidis0); + logSqlMap.put("all_tiaoxiuidList", all_tiaoxiuidList); + logSqlMap.put("delSql", delSql); + logSqlMap.put("clearSql", clearSql); + logSqlMap.put("isclearOk", isclearOk); + logSqlMap.put("delUsageSql", delUsageSql); + logSqlMap.put("isdelUsageOk", isdelUsageOk); + logOvertimeMap(overtimeLogMap, logSqlMap, "需要重新生成的调休对应的信息|logSqlMap"); + } + String delSql = "delete from kq_flow_overtime where resourceid = ? and belongdate=? and ori_belongdate=? "; + boolean isDelOk = rs.executeUpdate(delSql, resourceid, belongdate, splitDate); + String delSqlLog = delSql + ":resourceid:" + resourceid + ":belongdate:" + belongdate + ":splitDate:" + splitDate + ":isDelOk:" + isDelOk; + logOvertimeMap(overtimeLogMap, delSqlLog, "删除加班中间表数据|delSql"); + + } + + /** + * 加班单位 + * + * @param d_mins + * @return + */ + public double getD_MinsByUnit(double d_mins) { + Map map = KQOvertimeRulesBiz.getMinimumUnitAndConversion(); + if (!map.isEmpty()) { + double conversionMins = 0.0; + int minimumUnit = Util.getIntValue(Util.null2String(map.get("minimumUnit")), -1); + int overtimeConversion = Util.getIntValue(Util.null2String(map.get("overtimeConversion")), -1); + if (5 == minimumUnit || 6 == minimumUnit) { + int halfHourInt = 30; + int wholeHourInt = 60; + if (5 == minimumUnit) { + conversionMins = getConversionMins(halfHourInt, d_mins, overtimeConversion); + } else { + conversionMins = getConversionMins(wholeHourInt, d_mins, overtimeConversion); + } + return conversionMins; + } + } + return d_mins; + } + + /** + * 根据转换规则得到转换后的加班时长 + * + * @param halfHourInt + * @param d_mins + * @param overtimeConversion + * @return + */ + public double getConversionMins(int halfHourInt, double d_mins, int overtimeConversion) { + double conversionMins = 0.0; + int step = (int) (d_mins / halfHourInt); + double leftMins = d_mins - halfHourInt * step; + //半小时 + if (1 == overtimeConversion) { +// 四舍五入 + if (leftMins >= halfHourInt / 2) { + conversionMins = halfHourInt * step + halfHourInt; + } else { + conversionMins = halfHourInt * step; + } + } else if (2 == overtimeConversion) { +// 向上取整 + if (leftMins > 0) { + conversionMins = halfHourInt * step + halfHourInt; + } else { + conversionMins = halfHourInt * step; + } + } else if (3 == overtimeConversion) { +// 向下取整 + if (leftMins < halfHourInt) { + conversionMins = halfHourInt * step; + } else { + conversionMins = halfHourInt * step; + } + } + return conversionMins; + } +} diff --git a/src/com/engine/kq/biz/KQOvertimeLogBiz.java b/src/com/engine/kq/biz/KQOvertimeLogBiz.java new file mode 100644 index 0000000..78dca5f --- /dev/null +++ b/src/com/engine/kq/biz/KQOvertimeLogBiz.java @@ -0,0 +1,240 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.serializer.SerializerFeature; +import java.io.Writer; +import java.util.Map; +import java.util.UUID; +import weaver.conn.ConnStatement; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.common.DbFunctionUtil; + +/** + * 加班记录考勤事件日志 + * 现在先做一个加班的,把加班生成的时候流转,对应流程,班次,考勤组信息,加班规则信息 + */ +public class KQOvertimeLogBiz { + + /** + * 明细表里记录一下班次和考勤组信息 + * @param resourceid + * @param workTimeEntityLogMap + * @param main_uuid + * @param worktimeType + * @return + */ + public String logDetailWorkTimeEntity(String resourceid, Map workTimeEntityLogMap, + String main_uuid,String worktimeType) { + RecordSet rs = new RecordSet(); + + String serial_info = ""; + if(workTimeEntityLogMap != null){ + serial_info = JSON.toJSONString(workTimeEntityLogMap,SerializerFeature.DisableCheckSpecialChar,SerializerFeature.DisableCircularReferenceDetect); + } + String uuid = UUID.randomUUID().toString(); + boolean isok = false; + if(rs.getDBType().equalsIgnoreCase("oracle")&& Util.null2String(rs.getOrgindbtype()).equals("oracle")){ + String sql = "insert into kq_overtime_log_detail(resourceid,createdatetime,serial_info,overtime_info,event_info,uuid,overtimetype,main_uuid) " + + " values(?,"+ DbFunctionUtil.getCurrentFullTimeFunction(rs.getDBType())+",empty_clob(),empty_clob(),empty_clob(),?,?,?) "; + isok = rs.executeUpdate(sql,resourceid,uuid,worktimeType,main_uuid); + }else{ + String sql = "insert into kq_overtime_log_detail(resourceid,createdatetime,serial_info,uuid,overtimetype,main_uuid) " + + " values("+resourceid+","+DbFunctionUtil.getCurrentFullTimeFunction(rs.getDBType())+",?,'"+uuid+"','"+worktimeType+"','"+main_uuid+"') "; + rs.executeUpdate(sql,serial_info); + } + + if(rs.getDBType().equalsIgnoreCase("oracle")&& Util.null2String(rs.getOrgindbtype()).equals("oracle")){ + ConnStatement stat=null; + try { + stat = new ConnStatement(); + // 需要使用for update方法来进行更新, + // 但是,特别需要注意,如果原来CLOB字段有值,需要使用empty_clob()将其清空。 + // 如果原来是null,也不能更新,必须是empty_clob()返回的结果。 + stat.setStatementSql("select serial_info from kq_overtime_log_detail where uuid=? for update", false); + stat.setString(1,uuid); + stat.executeQuery(); + if (stat.next()) { + oracle.sql.CLOB clob = (oracle.sql.CLOB) stat.getClob("serial_info"); + Writer outStream = clob.getCharacterOutputStream(); + char[] c = serial_info.toCharArray(); + outStream.write(c, 0, c.length); + outStream.flush(); + outStream.close(); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (stat != null) { + stat.close(); + } + } + } + + return uuid; + } + + /** + * 在日志表里更新一下生成的加班id + * 这样可以根据加班id找到对应的日志 + * @param uuid + * @param overtimeid + * @return + */ + public void updateOvertimeId(String uuid,String overtimeid) { + RecordSet rs = new RecordSet(); + String sql = "update kq_overtime_log_detail set overtimeid="+overtimeid+" where uuid='"+uuid+"' "; + boolean isOk = rs.executeUpdate(sql); + } + /** + * 记录一下加班生成明细 + * @param resourceid + * @param overtimeLogMap + * @param uuid + */ + public void logDetailOvertimeMap(String resourceid, Map overtimeLogMap,String uuid) { + RecordSet rs = new RecordSet(); + + String overtime_info = ""; + if(overtimeLogMap != null){ + overtime_info = JSON.toJSONString(overtimeLogMap, SerializerFeature.DisableCheckSpecialChar,SerializerFeature.DisableCircularReferenceDetect); + } + if(rs.getDBType().equalsIgnoreCase("oracle")&& Util.null2String(rs.getOrgindbtype()).equals("oracle")){ + ConnStatement stat=null; + try { + stat = new ConnStatement(); + // 需要使用for update方法来进行更新, + // 但是,特别需要注意,如果原来CLOB字段有值,需要使用empty_clob()将其清空。 + // 如果原来是null,也不能更新,必须是empty_clob()返回的结果。 + stat.setStatementSql("select overtime_info from kq_overtime_log_detail where uuid=? for update", false); + stat.setString(1,uuid); + stat.executeQuery(); + if (stat.next()) { + oracle.sql.CLOB clob = (oracle.sql.CLOB) stat.getClob("overtime_info"); + Writer outStream = clob.getCharacterOutputStream(); + char[] c = overtime_info.toCharArray(); + outStream.write(c, 0, c.length); + outStream.flush(); + outStream.close(); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (stat != null) { + stat.close(); + } + } + }else{ + String sql = "update kq_overtime_log_detail set overtime_info='"+overtime_info+"' where uuid='"+uuid+"'"; + rs.executeUpdate(sql); + } + + } + + /** + * 记录一下流程开始日期结束日期的 + * @param resourceid + * @param eventLogMap + * @param overtimetype + * @return + */ + public String logEvent(String resourceid, Map eventLogMap, String overtimetype) { + RecordSet rs = new RecordSet(); + + String event_info = ""; + if(eventLogMap != null){ + event_info = JSON.toJSONString(eventLogMap,SerializerFeature.DisableCheckSpecialChar,SerializerFeature.DisableCircularReferenceDetect); + } + String uuid = UUID.randomUUID().toString(); + boolean isok = false; + if(rs.getDBType().equalsIgnoreCase("oracle")&& Util.null2String(rs.getOrgindbtype()).equals("oracle")){ + String sql = "insert into kq_overtime_log(resourceid,createdatetime,event_info,uuid,overtimetype) " + + " values("+resourceid+","+ DbFunctionUtil.getCurrentFullTimeFunction(rs.getDBType())+",empty_clob(),'"+uuid+"','"+overtimetype+"') "; + isok = rs.executeUpdate(sql); + }else{ + String sql = "insert into kq_overtime_log(resourceid,createdatetime,event_info,uuid,overtimetype) " + + " values("+resourceid+","+DbFunctionUtil.getCurrentFullTimeFunction(rs.getDBType())+",?,'"+uuid+"','"+overtimetype+"') "; + rs.executeUpdate(sql,event_info); + } + if(isok && rs.getDBType().equalsIgnoreCase("oracle")&& Util.null2String(rs.getOrgindbtype()).equals("oracle")){ + ConnStatement stat=null; + try { + stat = new ConnStatement(); + // 需要使用for update方法来进行更新, + // 但是,特别需要注意,如果原来CLOB字段有值,需要使用empty_clob()将其清空。 + // 如果原来是null,也不能更新,必须是empty_clob()返回的结果。 + stat.setStatementSql("select event_info from kq_overtime_log where uuid=? for update", false); + stat.setString(1,uuid); + stat.executeQuery(); + if (stat.next()) { + oracle.sql.CLOB clob = (oracle.sql.CLOB) stat.getClob("event_info"); + Writer outStream = clob.getCharacterOutputStream(); + char[] c = event_info.toCharArray(); + outStream.write(c, 0, c.length); + outStream.flush(); + outStream.close(); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (stat != null) { + stat.close(); + } + } + } + return uuid; + } + + /** + * 记录对应的加班生成过程中使用的表sql和表数据 + * @param resourceid + * @param eventLogMap + * @param uuid + * @param overtimetype + */ + public void logDetailEvent(String resourceid, Map eventLogMap, String uuid, String overtimetype) { + RecordSet rs = new RecordSet(); + + String event_info = ""; + if(eventLogMap != null){ + event_info = JSON.toJSONString(eventLogMap,SerializerFeature.DisableCheckSpecialChar,SerializerFeature.DisableCircularReferenceDetect); + } + + if(rs.getDBType().equalsIgnoreCase("oracle")&&rs.getOrgindbtype().equalsIgnoreCase("oracle")){ + ConnStatement stat=null; + try { + stat = new ConnStatement(); + // 需要使用for update方法来进行更新, + // 但是,特别需要注意,如果原来CLOB字段有值,需要使用empty_clob()将其清空。 + // 如果原来是null,也不能更新,必须是empty_clob()返回的结果。 + stat.setStatementSql("select event_info from kq_overtime_log_detail where uuid=? for update", false); + stat.setString(1,uuid); + stat.executeQuery(); + if (stat.next()) { + oracle.sql.CLOB clob = (oracle.sql.CLOB) stat.getClob("event_info"); + Writer outStream = clob.getCharacterOutputStream(); + char[] c = event_info.toCharArray(); + outStream.write(c, 0, c.length); + outStream.flush(); + outStream.close(); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (stat != null) { + stat.close(); + } + } + }else{ + String regexp = "\'"; + event_info =event_info.replaceAll(regexp, "\""); + String sql = "update kq_overtime_log_detail set event_info='"+event_info+"' where uuid='"+uuid+"'"; + rs.executeUpdate(sql); + } + + } +} diff --git a/src/com/engine/kq/biz/KQOvertimeRulesBiz.java b/src/com/engine/kq/biz/KQOvertimeRulesBiz.java new file mode 100644 index 0000000..0eec5c4 --- /dev/null +++ b/src/com/engine/kq/biz/KQOvertimeRulesBiz.java @@ -0,0 +1,1054 @@ +package com.engine.kq.biz; + +import com.engine.kq.entity.KQOvertimeRulesDetailEntity; +import com.engine.kq.log.KQLog; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.wechat.util.DateUtil; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; +import java.util.Map; + +/** + * 加班规则的相关接口 + */ +public class KQOvertimeRulesBiz { + + private static KQLog logger = new KQLog();//用于记录日志信息 + + private static KQOvertimeRulesDetailEntity kqOvertimeRulesDetail = new KQOvertimeRulesDetailEntity();//加班规则实体类 + + /** + * 根据指定人员ID以及指定日期判断这一天是工作日还是休息日还是节假日 + * + * @param resourceId 指定人员ID + * 根据指定人员ID获取考勤组ID,根据考勤组得到对应日期是工作日还是休息日 + * @param date 指定日期 + * 根据日期判断是工作日还是节假日还是休息日(这里综合考虑考勤组和节假日设置,节假日设置的优先级最高) + * @return 1-节假日、2-工作日、3-休息日、-1-数据异常,无效数据 + */ + public static int getChangeType(String resourceId, String date) { + int changeType = -1; + + /*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/ + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date); + + /*该人员不存在于任意一个考勤组中,请为其设置考勤组*/ + if(groupId.equals("")){ + logger.writeLog("该人员不存在于任意一个考勤组中,请为其设置考勤组。resourceId=" + resourceId + ",date=" + date); + } + + changeType = KQHolidaySetBiz.getChangeType(groupId, date); + if(KQHolidaySetBiz.getWorkDay(resourceId, date)){ + changeType = -1; + } + if (changeType != 1 && changeType != 2 && changeType != 3) { + KQWorkTime kqWorkTime = new KQWorkTime(); + changeType = kqWorkTime.isWorkDay(resourceId, date) ? 2 : 3; + } + return changeType; + } + + /** + * 判断是否允许加班 + * + * @param resourceId 指定人员 + * 根据人员ID获取人员所在的考勤组ID,找出对应的加班规则ID + * @param date 指定日期 + * 根据日期判断是工作日还是节假日还是休息日 + * @return 0-不允许加班、1-允许加班 + */ + public static int getOvertimeEnable(String resourceId, String date) { + int overtimeEnable = 0; + kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date); + overtimeEnable = kqOvertimeRulesDetail.getOvertimeEnable(); + return overtimeEnable; + } + /** + * 判断是否午休时间算加班。 + * + * @param resourceId 指定人员 + * 根据人员ID获取人员所在的考勤组ID,找出对应的加班规则ID + * @param date 指定日期 + * 根据日期判断是工作日还是节假日还是休息日 + * @return 0-不允许加班、1-允许加班 + */ + public static int isOrOvertimecal(String resourceId, String date) { + int isovertimecal = 0; + kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date); + isovertimecal = kqOvertimeRulesDetail.getIsOvertimeCal(); + return isovertimecal; + } + + /** + * 获取加班方式计算 + * 1-需审批,以审批单为准 + * 2-需审批,以打卡为准,但是不能超过审批时长 + * 3-无需审批,根据打卡时间计算加班时长 + * + * @param resourceId 指定人员 + * 根据人员ID获取人员所在的考勤组ID,找出对应的加班规则ID + * @param date 指定日期 + * 根据日期判断是工作日还是节假日还是休息日 + * @return -1:接口异常,返回的无效数据。 + */ + public static int getComputingMode(String resourceId, String date) { + int computingMode = -1; + kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date); + computingMode = kqOvertimeRulesDetail.getComputingMode(); + return computingMode; + } + + /** + * 获取加班起算时间 + * + * @param resourceId 指定人员 + * 根据人员ID获取人员所在的考勤组ID,找出对应的加班规则ID + * @param date 指定日期 + * 根据日期判断是工作日还是节假日还是休息日 + * @return -1:接口异常,返回的无效数据。 + */ + public static int getStartTime(String resourceId, String date) { + int startTime = -1; + kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date); + startTime = kqOvertimeRulesDetail.getStartTime(); + return startTime; + } + + /** + * 获取最小加班时长 + * + * @param resourceId 指定人员 + * 根据人员ID获取人员所在的考勤组ID,找出对应的加班规则ID + * @param date 指定日期 + * 根据日期判断是工作日还是节假日还是休息日 + * @return -1:接口异常,返回的无效数据。 + */ + public static int getMinimumLen(String resourceId, String date) { + int minimumUnit = -1; + kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date); + minimumUnit = kqOvertimeRulesDetail.getMinimumLen(); + return minimumUnit; + } + + /** + * 获取最大加班时长 + * + * @param resourceId 指定人员 + * 根据人员ID获取人员所在的考勤组ID,找出对应的加班规则ID + * @param date 指定日期 + * 根据日期判断是工作日还是节假日还是休息日 + * @return -1:接口异常,返回的无效数据。 + */ + public static int getMaxmumLen(String resourceId, String date) { + int maxmumUnit = -1; + kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date); + maxmumUnit = kqOvertimeRulesDetail.getMaxmumLen(); + return maxmumUnit; + } + + /** + * 是否允许加班补偿 + * 0-不允许加班转调休、1-允许加班转调休 + * + * @param resourceId 指定人员 + * 根据人员ID获取人员所在的考勤组ID,找出对应的加班规则ID + * @param date 指定日期 + * 根据日期判断是工作日还是节假日还是休息日 + * @return + */ + public static int getPaidLeaveEnable(String resourceId, String date) { + int paidLeaveEnable = 0; + kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date); + paidLeaveEnable = kqOvertimeRulesDetail.getPaidLeaveEnable(); + return paidLeaveEnable; + } + + /** + * 获取加班时长转调休时长比例中的分母 + * + * @param resourceId 指定人员 + * 根据人员ID获取人员所在的考勤组ID,找出对应的加班规则ID + * @param date 指定日期 + * 根据日期判断是工作日还是节假日还是休息日 + * @return -1:接口异常,返回的无效数据。 + */ + public static double getLenOfOvertime(String resourceId, String date) { + double lenOfOvertime = -1; + kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date); + lenOfOvertime = kqOvertimeRulesDetail.getLenOfOvertime(); + BigDecimal bigDecimal = new BigDecimal(lenOfOvertime); + lenOfOvertime = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + return lenOfOvertime; + } + + /** + * 获取加班时长转调休时长比例中的分子 + * + * @param resourceId 指定人员 + * 根据人员ID获取人员所在的考勤组ID,找出对应的加班规则ID + * @param date 指定日期 + * 根据日期判断是工作日还是节假日还是休息日 + * @return -1:接口异常,返回的无效数据。 + */ + public static double getLenOfLeave(String resourceId, String date) { + double lenOfLeave = -1; + kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date); + lenOfLeave = kqOvertimeRulesDetail.getLenOfLeave(); + BigDecimal bigDecimal = new BigDecimal(lenOfLeave); + lenOfLeave = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + return lenOfLeave; + } + + /** + * 判断是否需要排除休息时间 + * + * @param resourceId 指定人员 + * 根据人员ID获取人员所在的考勤组ID,找出对应的加班规则ID + * @param date 指定日期 + * 根据日期判断是工作日还是节假日还是休息日 + * @return 0-不需要排除休息时间、1-需要排除休息时间 + */ + public static int getHasRestTime(String resourceId, String date) { + int hasRestTime = 0; + kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date); + hasRestTime = kqOvertimeRulesDetail.getHasRestTime(); + return hasRestTime; + } + + /** + * 获取休息时段 + * startType:0-开始时间为本日、1-开始时间为次日 + * startTime:开始时间 + * endType:0-结束时间为本日、1-结束时间为次日 + * endTime:结束时间 + * + * @param resourceId 指定人员 + * 根据人员ID获取人员所在的考勤组ID,找出对应的加班规则ID + * @param date 指定日期 + * 根据日期判断是工作日还是节假日还是休息日 + * @return + */ + public static List getRestTimeList(String resourceId, String date) { + List restTimeList = new ArrayList(); + + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + /** + * 因为休息时段可以设置次日的数据,所以获取某一天的休息时段的时候,需要先考虑上一个日期所设置的次日的休息时段 + */ + String lastDay = DateUtil.addDay(date, -1, "yyyy-MM-dd"); + kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, lastDay); + int overtimeEnable = kqOvertimeRulesDetail.getOvertimeEnable(); + int hasRestTime = kqOvertimeRulesDetail.getHasRestTime(); + if (overtimeEnable == 1 && hasRestTime == 1) { + int dayType = kqOvertimeRulesDetail.getDayType(); + int ruleId = kqOvertimeRulesDetail.getRuleId(); + + String sql = "select * from kq_OvertimeRestTime where ruleId=" + ruleId + " and dayType=" + dayType; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String startType = recordSet.getString("startType"); + String startTime = recordSet.getString("startTime"); + String endType = recordSet.getString("endType"); + String endTime = recordSet.getString("endTime"); + if("1".equals(endType)){ + if(!"1".equals(startType)){ + startTime = "00:00"; + } + String[] str = new String[]{startTime, endTime}; + restTimeList.add(str); + } + } + } + + kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date); + overtimeEnable = kqOvertimeRulesDetail.getOvertimeEnable(); + hasRestTime = kqOvertimeRulesDetail.getHasRestTime(); + if (overtimeEnable == 1 && hasRestTime == 1) { + int dayType = kqOvertimeRulesDetail.getDayType(); + int ruleId = kqOvertimeRulesDetail.getRuleId(); + + String sql = "select * from kq_OvertimeRestTime where ruleId=" + ruleId + " and dayType=" + dayType; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String startType = recordSet.getString("startType"); + String startTime = recordSet.getString("startTime"); + String endType = recordSet.getString("endType"); + String endTime = recordSet.getString("endTime"); + + if("1".equals(startType)){ + startTime = kqTimesArrayComInfo.turn24to48Time(startTime); + } + if("1".equals(endType)){ + endTime = kqTimesArrayComInfo.turn24to48Time(endTime); + } + String[] str = new String[]{startTime, endTime}; + restTimeList.add(str); + + } + } + return restTimeList; + } + + /** + * 获取加班规则的明细 + * + * @param resourceId 指定人员 + * 根据人员ID获取人员所在的考勤组ID,找出对应的加班规则ID + * @param changeType 日期类型:1-节假日、2-工作日、3-休息日 + * @return + */ + private static KQOvertimeRulesDetailEntity getOvertimeRulesDetail(String resourceId, String date) { + KQOvertimeRulesDetailEntity kqOvertimeRulesDetail = new KQOvertimeRulesDetailEntity(); + try { + /*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/ + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupIds = kqGroupMemberComInfo.getKQGroupId(resourceId, date); + if (groupIds.equals("")) { + /*该人员不存在于任意一个考勤组中,请为其设置考勤组*/ + logger.writeLog("该人员不存在于任意一个考勤组中,请为其设置考勤组。resourceId=" + resourceId + ",date=" + date); + } + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + String overtimeType = kqGroupComInfo.getOvertime_type(groupIds); + + int changeType = getChangeType(resourceId, date); + /*获取当前日期的日期类型错误*/ + if (changeType != 1 && changeType != 2 && changeType != 3) { + logger.writeLog("获取当前日期的日期类型错误。resourceId=" + resourceId + ",date=" + date + ",changeType=" + changeType); + } + + int overtimeRuleId = 0;//加班规则的ID + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select id from kq_OvertimeRules where (isDelete is null or isDelete !=1) "; + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sql += " and ','+groupIds+',' like '%," + groupIds + ",%'"; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql += " and concat(',',groupIds,',') like '%," + groupIds + ",%'"; + } else { + sql += " and ','||groupIds||',' like '%," + groupIds + ",%'"; + } + if("1".equals(overtimeType)){ + //如果是按照班次的 + KQWorkTime kqWorkTime = new KQWorkTime(); + String serialId = kqWorkTime.getSerialIds(resourceId, date); + if(StringUtil.isNotNull(serialId)){ + String getShiftSql = "select * from kq_shiftmanagement where (isdelete is null or isdelete <> '1') and id="+serialId; + rs.executeQuery(getShiftSql); + if(rs.next()){ + String overtimeId = rs.getString("overtime_rule_id"); + if(StringUtil.isNotNull(overtimeId)){ + sql = "select id from kq_OvertimeRules where (isDelete is null or isDelete !=1) and id = "+overtimeId; + }else{ + logger.writeLog("该人员这一天班次的加班规则为空。resourceId=" + resourceId + ",date=" + date); + return kqOvertimeRulesDetail; + } + }else{ + logger.writeLog("该人员这一天没有查询到班次。resourceId=" + resourceId + ",date=" + date); + return kqOvertimeRulesDetail; + } + }else{ + logger.writeLog("该人员这一天没有设置班次。resourceId=" + resourceId + ",date=" + date); + return kqOvertimeRulesDetail; + } + } + recordSet.executeQuery(sql); + if (recordSet.next()) { + overtimeRuleId = recordSet.getInt("id"); + + sql = "select * from kq_OvertimeRulesDetail where ruleId=" + overtimeRuleId + " and dayType=" + changeType; + recordSet.executeQuery(sql); + if (recordSet.next()) { + int ruleId = recordSet.getInt("ruleId"); + int dayType = recordSet.getInt("dayType"); + int overtimeEnable = recordSet.getInt("overtimeEnable"); + int computingMode = recordSet.getInt("computingMode"); + int startTime = recordSet.getInt("startTime"); + int minimumLen = recordSet.getInt("minimumLen"); + int maxmumLen = Util.getIntValue(recordSet.getString("maxmumLen"), 2880); + int paidLeaveEnable = recordSet.getInt("paidLeaveEnable"); + double lenOfOvertime = Util.getDoubleValue(recordSet.getString("lenOfOvertime"), 1.00); + double lenOfLeave = Util.getDoubleValue(recordSet.getString("lenOfLeave"), 1.00); + int hasRestTime = Util.getIntValue(recordSet.getString("hasRestTime")); + int canmiddlerest = Util.getIntValue(recordSet.getString("canmiddlerest"), 0); + int hasCutPoint = Util.getIntValue(Util.null2s(recordSet.getString("has_cut_point"),"0"),0); + String cutPoint = Util.null2s(recordSet.getString("cut_point"),""); + + kqOvertimeRulesDetail.setRuleId(ruleId); + kqOvertimeRulesDetail.setDayType(dayType); + kqOvertimeRulesDetail.setOvertimeEnable(overtimeEnable); + kqOvertimeRulesDetail.setComputingMode(computingMode); + kqOvertimeRulesDetail.setStartTime(startTime); + kqOvertimeRulesDetail.setMinimumLen(minimumLen); + kqOvertimeRulesDetail.setMaxmumLen(maxmumLen); + kqOvertimeRulesDetail.setPaidLeaveEnable(paidLeaveEnable); + kqOvertimeRulesDetail.setLenOfOvertime(lenOfOvertime); + kqOvertimeRulesDetail.setLenOfLeave(lenOfLeave); + kqOvertimeRulesDetail.setHasRestTime(hasRestTime); + kqOvertimeRulesDetail.setIsOvertimeCal(canmiddlerest); + kqOvertimeRulesDetail.setHas_cut_point(hasCutPoint); + kqOvertimeRulesDetail.setCut_point(cutPoint); + } + } else { + logger.writeLog("该人员所属的考勤组没有设置过任何加班规则,请为其设置加班规则。resourceId=" + resourceId + ",date="+date+",changeType=" + changeType); + } + } catch (Exception e) { + logger.writeLog("根据人员ID获取加班规则的规则内容出错。resourceId=" + resourceId + ",date=" + date); + e.printStackTrace(); + } + return kqOvertimeRulesDetail; + } + + /** + * 新建加班规则 + * + * @param params + * @return + */ + public static int addOvertimeRules(Map params, User user) { + /*是否保存成功*/ + boolean flag = false; + + /*新插入的加班规则的ID*/ + int ruleId = -1; + try { + boolean canAdd = HrmUserVarify.checkUserRight("KQOvertimeRulesAdd:Add", user);//是否具有新建权限 + if (!canAdd) { + logger.info(user.getLastname() + "暂时没有权限!"); + return -1; + } + + /*加班规则名称*/ + String name = Util.null2String(params.get("name")); + /*考勤组的ID*/ + String groupIds = Util.null2String(params.get("groupIds")); + + /*工作日是否允许加班:0-不允许、1-允许*/ + int overtimeEnable2 = Util.getIntValue((String) params.get("overtimeEnable2"), 1); + /*工作日的加班方式:1-需审批,以审批单为准、2-需审批,以打卡为准,但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/ + int computingMode2 = Util.getIntValue((String) params.get("computingMode2"), 1); + /*工作日下班多少分钟后开始计算加班*/ + int startTime2 = Util.getIntValue((String) params.get("startTime2"), 30); + /*工作日最小加班时长*/ + int minimumLen2 = Util.getIntValue((String) params.get("minimumLen2"), 30); + /*工作日最大加班时长*/ + int maxmumLen2 = Util.getIntValue((String) params.get("maxmumLen2"), 2880); + /*工作日是否允许加班转调休*/ + int paidLeaveEnable2 = Util.getIntValue((String) params.get("paidLeaveEnable2"), 0); + /*工作日加班转调休比例中的加班时长*/ + int lenOfOvertime2 = Util.getIntValue((String) params.get("lenOfOvertime2"), 1); + /*工作日加班转调休比例中的调休时长*/ + int lenOfLeave2 = Util.getIntValue((String) params.get("lenOfLeave2"), 1); + + /*休息日是否允许加班:0-不允许、1-允许*/ + int overtimeEnable3 = Util.getIntValue((String) params.get("overtimeEnable3"), 1); + /*休息日的加班方式:1-需审批,以审批单为准、2-需审批,以打卡为准,但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/ + int computingMode3 = Util.getIntValue((String) params.get("computingMode3"), 1); + /*休息日的最小加班时长*/ + int minimumLen3 = Util.getIntValue((String) params.get("minimumLen3"), 30); + /*休息日的最大加班时长*/ + int maxmumLen3 = Util.getIntValue((String) params.get("maxmumLen3"), 2880); + /*休息日是否允许加班转调休*/ + int paidLeaveEnable3 = Util.getIntValue((String) params.get("paidLeaveEnable3"), 0); + /*休息日加班转调休比例中的加班时长*/ + int lenOfOvertime3 = Util.getIntValue((String) params.get("lenOfOvertime3"), 1); + /*休息日加班转调休比例中的调休时长*/ + int lenOfLeave3 = Util.getIntValue((String) params.get("lenOfLeave3"), 1); + /*休息日是否有休息时间*/ + int hasRestTime3 = Util.getIntValue((String) params.get("hasRestTime3"), 0); + + /*节假日是否允许加班:0-不允许、1-允许*/ + int overtimeEnable1 = Util.getIntValue((String) params.get("overtimeEnable1"), 1); + /*节假日的加班方式:1-需审批,以审批单为准、2-需审批,以打卡为准,但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/ + int computingMode1 = Util.getIntValue((String) params.get("computingMode1"), 1); + /*节假日的最小加班时长*/ + int minimumLen1 = Util.getIntValue((String) params.get("minimumLen1"), 30); + /*节假日的最大加班时长*/ + int maxmumLen1 = Util.getIntValue((String) params.get("maxmumLen1"), 2880); + /*节假日是否允许加班转调休*/ + int paidLeaveEnable1 = Util.getIntValue((String) params.get("paidLeaveEnable1"), 0); + /*节假日加班转调休比例中的加班时长*/ + int lenOfOvertime1 = Util.getIntValue((String) params.get("lenOfOvertime1"), 1); + /*节假日加班转调休比例中的调休时长*/ + int lenOfLeave1 = Util.getIntValue((String) params.get("lenOfLeave1"), 1); + /*节假日是否有休息时间*/ + int hasRestTime1 = Util.getIntValue((String) params.get("hasRestTime1"), 0); + + int paidLeaveEnableType2 = Util.getIntValue((String) params.get("paidLeaveEnableType2"), 2); + int paidLeaveEnableType3 = Util.getIntValue((String) params.get("paidLeaveEnableType3"), 2); + int paidLeaveEnableType1 = Util.getIntValue((String) params.get("paidLeaveEnableType1"), 2); + int paidLeaveEnableFlowType2 = Util.getIntValue((String) params.get("paidLeaveEnableFlowType2"), 1); + int paidLeaveEnableFlowType3 = Util.getIntValue((String) params.get("paidLeaveEnableFlowType3"), 1); + int paidLeaveEnableFlowType1 = Util.getIntValue((String) params.get("paidLeaveEnableFlowType1"), 1); + + /*获取今天的日期*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + String tomorrowDate = weaver.common.DateUtil.addDate(currentDate, 1); + + /*校验休息日排除休息时间的设置是否正确*/ + if (hasRestTime3 == 1) { + int restTimeLen3 = Util.getIntValue((String) params.get("restTimeLen3"), 0); + + List fromList = new ArrayList(); + List toList = new ArrayList(); + for (int i = 0; i < restTimeLen3; i++) { + String startType = "0"; + String startTime = Util.getIntValues((String) params.get("startTime3_" + i)); + String endType = "0"; + String endTime = Util.getIntValues((String) params.get("endTime3_" + i)); + + String fromDateTime = (startType.equals("0") ? currentDate : tomorrowDate) + " " + startTime + ":00"; + String toDateTime = (endType.equals("0") ? currentDate : tomorrowDate) + " " + endTime + ":00"; + if (fromDateTime.compareTo(toDateTime) > 0) { + logger.info("结束时间必须大于开始时间,fromDateTime=" + fromDateTime + ",toDateTime=" + toDateTime); + return -1; + } + fromList.add(fromDateTime); + toList.add(toDateTime); + } + /*利用冒泡法对日期时间进行排序*/ + for (int i = 0; i < fromList.size(); i++) { + for (int j = 0; j < fromList.size() - i - 1; j++) { + if (fromList.get(j).compareTo(fromList.get(j + 1)) > 0) { + String str = fromList.get(j); + fromList.set(j, fromList.get(j + 1)); + fromList.set(j + 1, str); + + str = toList.get(j); + toList.set(j, toList.get(j + 1)); + toList.set(j + 1, str); + } + } + } + /*根据排序后的数据判断是否时间段有重叠*/ + for (int i = 0; i < fromList.size() - 1; i++) { + if (fromList.get(i + 1).compareTo(toList.get(i)) < 0) { + logger.info("休息时段不能交叉"); + return -1; + } + } + } + + /*校验休息日排除休息时间的设置是否正确*/ + if (hasRestTime1 == 1) { + int restTimeLen1 = Util.getIntValue((String) params.get("restTimeLen1"), 0); + + List fromList = new ArrayList(); + List toList = new ArrayList(); + for (int i = 0; i < restTimeLen1; i++) { + String startType = "0"; + String startTime = Util.getIntValues((String) params.get("startTime1_" + i)); + String endType = "0"; + String endTime = Util.getIntValues((String) params.get("endTime1_" + i)); + + String fromDateTime = (startType.equals("0") ? currentDate : tomorrowDate) + " " + startTime + ":00"; + String toDateTime = (endType.equals("0") ? currentDate : tomorrowDate) + " " + endTime + ":00"; + if (fromDateTime.compareTo(toDateTime) > 0) { + logger.info("结束时间必须大于开始时间:fromDateTime=" + fromDateTime + ",toDateTime=" + toDateTime); + return -1; + } + fromList.add(fromDateTime); + toList.add(toDateTime); + } + /*利用冒泡法对日期时间进行排序*/ + for (int i = 0; i < fromList.size(); i++) { + for (int j = 0; j < fromList.size() - i - 1; j++) { + if (fromList.get(j).compareTo(fromList.get(j + 1)) > 0) { + String str = fromList.get(j); + fromList.set(j, fromList.get(j + 1)); + fromList.set(j + 1, str); + + str = toList.get(j); + toList.set(j, toList.get(j + 1)); + toList.set(j + 1, str); + } + } + } + /*根据排序后的数据判断是否时间段有重叠*/ + for (int i = 0; i < fromList.size() - 1; i++) { + if (fromList.get(i + 1).compareTo(toList.get(i)) < 0) { + logger.info("休息时段不能交叉"); + return -1; + } + } + } + + String sql = "insert into kq_OvertimeRules(name,groupIds,isDelete) values(?,?,0)"; + RecordSet recordSet = new RecordSet(); + flag = recordSet.executeUpdate(sql, name, groupIds); + if (!flag) { + logger.info("加班规则保存失败");//保存失败 + return -1; + } + + sql = "select max(id) maxId from kq_OvertimeRules"; + recordSet.executeQuery(sql); + if (recordSet.next()) { + ruleId = recordSet.getInt("maxId"); + } + + if (ruleId != 0) { + sql = "insert into kq_OvertimeRulesDetail(ruleId,dayType,overtimeEnable,computingMode,startTime,minimumLen,maxmumLen,paidLeaveEnable,lenOfOvertime,lenOfLeave,hasRestTime,paidleaveenabletype,paidleaveenableflowtype) " + + "values(?,?,?,?,?,?,?,?,?,?,?,?,?)"; + /** + * 保存工作日加班规则 + */ + flag = recordSet.executeUpdate(sql, ruleId, 2, overtimeEnable2, computingMode2, startTime2, minimumLen2, maxmumLen2, paidLeaveEnable2, lenOfOvertime2, lenOfLeave2, 0,paidLeaveEnableType2,paidLeaveEnableFlowType2); + if (!flag) { + logger.info("工作日加班规则保存失败");//保存失败 + return -1; + } + /** + * 保存休息日加班规则 + */ + flag = recordSet.executeUpdate(sql, ruleId, 3, overtimeEnable3, computingMode3, 0, minimumLen3, maxmumLen3, paidLeaveEnable3, lenOfOvertime3, lenOfLeave3, hasRestTime3,paidLeaveEnableType3,paidLeaveEnableFlowType3); + if (!flag) { + logger.info("休息日加班规则保存失败");//保存失败 + return -1; + } + + if (hasRestTime3 == 1) { + int restTimeLen3 = Util.getIntValue((String) params.get("restTimeLen3"), 0); + + for (int i = 0; i < restTimeLen3; i++) { + String startType = "0"; + String startTime = Util.getIntValues((String) params.get("startTime3_" + i)); + String endType = "0"; + String endTime = Util.getIntValues((String) params.get("endTime3_" + i)); + + String restTimeSql = "insert into kq_OvertimeRestTime(ruleId,dayType,startType,startTime,endType,endTime) values(?,?,?,?,?,?)"; + flag = recordSet.executeUpdate(restTimeSql, ruleId, 3, startType, startTime, endType, endTime); + if (!flag) { + logger.info("休息日加班规则休息时段保存失败");//保存失败 + return -1; + } + } + } + /** + * 保存节假日加班规则 + */ + flag = recordSet.executeUpdate(sql, ruleId, 1, overtimeEnable1, computingMode1, 0, minimumLen1, maxmumLen1, paidLeaveEnable1, lenOfOvertime1, lenOfLeave1, hasRestTime1,paidLeaveEnableType1,paidLeaveEnableFlowType1); + if (!flag) { + logger.info("节假日加班规则保存失败"); + return -1; + } + + if (hasRestTime1 == 1) { + int restTimeLen1 = Util.getIntValue((String) params.get("restTimeLen1"), 0); + + for (int i = 0; i < restTimeLen1; i++) { + String startType = "0"; + String startTime = Util.getIntValues((String) params.get("startTime1_" + i)); + String endType = "0"; + String endTime = Util.getIntValues((String) params.get("endTime1_" + i)); + + String restTimeSql = "insert into kq_OvertimeRestTime(ruleId,dayType,startType,startTime,endType,endTime) values(?,?,?,?,?,?)"; + flag = recordSet.executeUpdate(restTimeSql, ruleId, 1, startType, startTime, endType, endTime); + if (!flag) { + logger.info("节假日加班规则休息时段保存失败"); + return -1; + } + } + } + } + } catch (Exception e) { + ruleId = -1; + } + return ruleId; + } + + /************************************************加班单位的相关接口************************************************/ + /** + * 获取最小加班单位 + * 1-按天加班 + * 2-按半天加班 + * 3-按小时加班 + * 4-按整天加班 + * 5-按半小时加班 + * 6-按整小时加班 + * @return -1:接口异常,返回的无效数据。 + */ + public static int getMinimumUnit() { + int minimumUnit = -1; + String sql = "select * from kq_OvertimeUnit where (isDelete is null or isDelete !=1) and id=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + minimumUnit = recordSet.getInt("minimumUnit"); + } + return minimumUnit; + } + + /** + * 获取最小加班单位 + * 1-按天加班 + * 2-按半天加班 + * 3-按小时加班 + * 4-按整天加班 + * 5-按半小时加班 + * 6-按整小时加班 + * @return -1:接口异常,返回的无效数据。 + */ + public static Map getMinimumUnitAndConversion() { + Map map = Maps.newHashMap(); + int minimumUnit = -1; + int overtimeConversion = -1; + String sql = "select * from kq_OvertimeUnit where (isDelete is null or isDelete !=1) and id=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + minimumUnit = recordSet.getInt("minimumUnit"); + overtimeConversion = recordSet.getInt("overtimeConversion"); + map.put("minimumUnit", ""+minimumUnit); + map.put("overtimeConversion", ""+overtimeConversion); + } + return map; + } + + + /** + * 获取加班单位的日折算时长 + * + * @return -1:接口异常,返回的无效数据。 + */ + public static double getHoursToDay() { + double hoursToDay = -1.00; + String sql = "select * from kq_OvertimeUnit where (isDelete is null or isDelete !=1) and id=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + hoursToDay = recordSet.getDouble("hoursToDay"); + } + BigDecimal bigDecimal = new BigDecimal(hoursToDay); + return bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + /** + * 获取半天显示类型,是时间还是下拉框 + * 半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + * @return + */ + public static String getTimeselection() { + int timeselection = 1; + String sql = "select * from kq_OvertimeUnit where (isDelete is null or isDelete !=1) and id=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + timeselection = recordSet.getInt("timeselection"); + } + if(timeselection == 1 || timeselection == 2){ + return ""+timeselection; + }else{ + return "1"; + } + } + + /** + * 获取加班所有需要的数据 + * @param resourceId + * @param date + * @param changeTypeMap + * @return + */ + public static void getOverTimeData(String resourceId, String date, + Map changeTypeMap,Map overRulesDetailMap,Map> restTimeMap,Map computingModeMap) { + int changeType = -1; + + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + /*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/ + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupId = Util.null2s(kqGroupMemberComInfo.getKQGroupId(resourceId, date),""); + + /*该人员不存在于任意一个考勤组中,请为其设置考勤组*/ + if(groupId.length() == 0){ + logger.writeLog("该人员不存在于任意一个考勤组中,请为其设置考勤组。resourceId=" + resourceId + ",date=" + date); + return ; + } + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + String overtimeType = kqGroupComInfo.getOvertime_type(groupId); + + changeType = KQHolidaySetBiz.getChangeType(groupId, date); + if(KQHolidaySetBiz.getWorkDay(resourceId, date)){ + changeType = -1; + } + if (changeType != 1 && changeType != 2 && changeType != 3) { + KQWorkTime kqWorkTime = new KQWorkTime(); + changeType = kqWorkTime.isWorkDay(resourceId, date) ? 2 : 3; + } + String change_key = date+"_"+resourceId; + changeTypeMap.put(change_key, changeType); + + List restTimeList = new ArrayList(); + int overtimeRuleId = 0;//加班规则的ID + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select id from kq_OvertimeRules where (isDelete is null or isDelete !=1) "; + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sql += " and ','+groupIds+',' like '%," + groupId + ",%'"; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql += " and concat(',',groupIds,',') like '%," + groupId + ",%'"; + } else { + sql += " and ','||groupIds||',' like '%," + groupId + ",%'"; + } + if("1".equals(overtimeType)){ + //如果是按照班次的 + KQWorkTime kqWorkTime = new KQWorkTime(); + String serialId = kqWorkTime.getSerialIds(resourceId, date); + if(StringUtil.isNotNull(serialId)){ + String getShiftSql = "select * from kq_shiftmanagement where (isdelete is null or isdelete <> '1') and id="+serialId; + rs.executeQuery(getShiftSql); + if(rs.next()){ + String overtimeId = rs.getString("overtime_rule_id"); + if(StringUtil.isNotNull(overtimeId)){ + sql = "select id from kq_OvertimeRules where (isDelete is null or isDelete !=1) and id = "+overtimeId; + }else{ + logger.writeLog("该人员这一天班次的加班规则为空。resourceId=" + resourceId + ",date=" + date); + return ; + } + }else{ + logger.writeLog("该人员这一天没有查询到班次。resourceId=" + resourceId + ",date=" + date); + return ; + } + }else{ + logger.writeLog("该人员这一天没有设置班次。resourceId=" + resourceId + ",date=" + date); + return ; + } + } + recordSet.executeQuery(sql); + if (recordSet.next()) { + overtimeRuleId = recordSet.getInt("id"); + + sql = "select * from kq_OvertimeRulesDetail where ruleId=" + overtimeRuleId + " and dayType=" + changeType; + recordSet.executeQuery(sql); + if (recordSet.next()) { + int id = recordSet.getInt("id"); + int ruleId = recordSet.getInt("ruleId"); + int dayType = recordSet.getInt("dayType"); + int overtimeEnable = recordSet.getInt("overtimeEnable"); + int computingMode = recordSet.getInt("computingMode"); + int startTime = recordSet.getInt("startTime"); + int minimumLen = recordSet.getInt("minimumLen"); + int maxmumLen = Util.getIntValue(recordSet.getString("maxmumLen"), 2880); + int paidLeaveEnable = recordSet.getInt("paidLeaveEnable"); + double lenOfOvertime = Util.getDoubleValue(recordSet.getString("lenOfOvertime"), 1.00); + double lenOfLeave = Util.getDoubleValue(recordSet.getString("lenOfLeave"), 1.00); + int hasRestTime = Util.getIntValue(recordSet.getString("hasRestTime")); + int before_startTime = recordSet.getInt("before_startTime"); + int canmiddlerest = Util.getIntValue(recordSet.getString("canmiddlerest"), 0); + + int paidLeaveEnableType = recordSet.getInt("paidLeaveEnableType"); + int paidLeaveEnableDefaultType = recordSet.getInt("paidLeaveEnableDefaultType"); + int paidLeaveEnableFlowType = recordSet.getInt("paidLeaveEnableFlowType"); + int restTimeType = recordSet.getInt("restTimeType"); + int has_cut_point = Util.getIntValue(Util.null2s(recordSet.getString("has_cut_point"),"0"),0); + if(paidLeaveEnableType <= 0){ + paidLeaveEnableType = 1; + } + if(paidLeaveEnableDefaultType <= 0){ + paidLeaveEnableDefaultType = 1; + } + if(paidLeaveEnableFlowType <= 0){ + paidLeaveEnableFlowType = 1; + } + if(paidLeaveEnableType == 1 && paidLeaveEnable == 0){ + //如果就没有开启关联调休,那么默认的加班转调休方式就是第一种 + paidLeaveEnableDefaultType = 1; + } + if(restTimeType <= 0){ + restTimeType = 1; + } + String cut_point = Util.null2s(recordSet.getString("cut_point"),""); + String key = date+"_"+changeType; + + KQOvertimeRulesDetailEntity kqOvertimeRulesDetail = new KQOvertimeRulesDetailEntity(); + kqOvertimeRulesDetail.setRuleId(ruleId); + kqOvertimeRulesDetail.setDayType(dayType); + kqOvertimeRulesDetail.setOvertimeEnable(overtimeEnable); + kqOvertimeRulesDetail.setComputingMode(computingMode); + kqOvertimeRulesDetail.setStartTime(startTime); + kqOvertimeRulesDetail.setMinimumLen(minimumLen); + kqOvertimeRulesDetail.setMaxmumLen(maxmumLen); + kqOvertimeRulesDetail.setPaidLeaveEnable(paidLeaveEnable); + kqOvertimeRulesDetail.setLenOfOvertime(lenOfOvertime); + kqOvertimeRulesDetail.setLenOfLeave(lenOfLeave); + kqOvertimeRulesDetail.setHasRestTime(hasRestTime); + kqOvertimeRulesDetail.setBefore_startTime(before_startTime); + kqOvertimeRulesDetail.setCut_point(cut_point); + kqOvertimeRulesDetail.setHas_cut_point(has_cut_point); + kqOvertimeRulesDetail.setId(id); + kqOvertimeRulesDetail.setPaidLeaveEnableType(paidLeaveEnableType); + kqOvertimeRulesDetail.setPaidLeaveEnableDefaultType(paidLeaveEnableDefaultType); + kqOvertimeRulesDetail.setPaidLeaveEnableFlowType(paidLeaveEnableFlowType); + kqOvertimeRulesDetail.setRestTimeType(restTimeType); + kqOvertimeRulesDetail.setIsOvertimeCal(canmiddlerest); + overRulesDetailMap.put(key, kqOvertimeRulesDetail); + computingModeMap.put(key, computingMode); + + /** + * 因为休息时段可以设置次日的数据,所以获取某一天的休息时段的时候,需要先考虑上一个日期所设置的次日的休息时段 + */ + String lastDay = DateUtil.addDay(date, -1, "yyyy-MM-dd"); + KQOvertimeRulesDetailEntity pre_kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, lastDay); + int pre_overtimeEnable = pre_kqOvertimeRulesDetail.getOvertimeEnable(); + int pre_hasRestTime = pre_kqOvertimeRulesDetail.getHasRestTime(); + if (pre_overtimeEnable == 1 && pre_hasRestTime == 1) { + int prehas_cut_point = pre_kqOvertimeRulesDetail.getHas_cut_point(); + String precut_point = pre_kqOvertimeRulesDetail.getCut_point(); + + int pre_dayType = pre_kqOvertimeRulesDetail.getDayType(); + int pre_ruleId = pre_kqOvertimeRulesDetail.getRuleId(); + + sql = "select * from kq_OvertimeRestTime where ruleId=" + pre_ruleId + " and dayType=" + pre_dayType; + RecordSet recordSet1 = new RecordSet(); + recordSet1.executeQuery(sql); + while (recordSet1.next()) { + String startType = recordSet1.getString("startType"); + String startTime1 = recordSet1.getString("startTime"); + String endType = recordSet1.getString("endType"); + String endTime = recordSet1.getString("endTime"); + if("1".equals(endType)){ + if(!"1".equals(startType)){ + startTime1 = "00:00"; + } + if(1 == prehas_cut_point){ + //如果昨日的加班规则开启了临界点 需要判断下是否是临界点之后的排除休息时间,是临界点之后的排除休息时间才会影响到第二天的 + if(StringUtil.isNotNull(precut_point)){ + //比如排除休息时间是23-次日1,归属点2点,那么次日0到次日1这部分可以划到第二天的排除休息时间里 + //比如排除休息时间是23-次日2,归属点1点,那么次日1到次日2这部分可以不可以划到第二天了的排除休息时间里 + //比如排除休息时间是次日2-次日4,归属点1点,那么次日2到次日4这部分可以不可以划到第二天了的排除休息时间里 + if(precut_point.compareTo(startTime1) < 0){ + //如果归属点小于开始时间了,则这个排除休息时间就没效果了 + continue; + }else{ + if(precut_point.compareTo(endTime) < 0){ + //如果归属点小于结束时间,大于排除休息开始时间,则排除休息时间就直接以归属点作为结束时间 + endTime = precut_point; + } + } + } + } + String[] str = new String[]{startTime1, endTime}; + restTimeList.add(str); + } + } + } + + overtimeEnable = kqOvertimeRulesDetail.getOvertimeEnable(); + hasRestTime = kqOvertimeRulesDetail.getHasRestTime(); + restTimeType = kqOvertimeRulesDetail.getRestTimeType(); + if (overtimeEnable == 1 && hasRestTime == 1) { + if(restTimeType == 1){ + sql = "select * from kq_OvertimeRestTime where ruleId=" + ruleId + " and dayType=" + dayType; + RecordSet recordSet1 = new RecordSet(); + recordSet1.executeQuery(sql); + while (recordSet1.next()) { + String startType = recordSet1.getString("startType"); + String startTime1 = recordSet1.getString("startTime"); + String endType = recordSet1.getString("endType"); + String endTime = recordSet1.getString("endTime"); + + if("1".equals(startType)){ + startTime1 = kqTimesArrayComInfo.turn24to48Time(startTime1); + } + if("1".equals(endType)){ + endTime = kqTimesArrayComInfo.turn24to48Time(endTime); + } + String[] str = new String[]{startTime1, endTime}; + restTimeList.add(str); + } + }else{ + sql = "select * from kq_OvertimeRestlength where ruleId=" + ruleId + " and dayType=" + dayType+" order by dsporder "; + RecordSet recordSet1 = new RecordSet(); + recordSet1.executeQuery(sql); + while (recordSet1.next()) { + String overlength = Util.null2String(recordSet1.getString("overlength")); + String cutlength = Util.null2String(recordSet1.getString("cutlength")); + if(overlength.length() > 0 && cutlength.length() > 0){ + String[] str = new String[]{overlength, cutlength}; + restTimeList.add(str); + } + } + } + } + restTimeMap.put(key, restTimeList); + } + + + } else { + logger.writeLog("该人员所属的考勤组没有设置过任何加班规则,请为其设置加班规则。resourceId=" + resourceId + ",date="+date+",changeType=" + changeType); + } + + return ; + } + + /** + * 按加班时长范围设置转调休时长 + * 按照加班时长从大到小排序 取到最大的满足了,那么调休就直接按照这个来转调休了 + */ + public Map> getBalanceLengthDetailMap(int ruleDetailid){ + Map> balanceLengthDetailMap = Maps.newHashMap(); + RecordSet recordSet = new RecordSet(); + List overtimelengthList = Lists.newArrayList(); + List balancelengthList = Lists.newArrayList(); + String sql = "select * from kq_OvertimeBalanceLengthDetail where rulesdetailid= ? order by overtimelength desc "; + recordSet.executeQuery(sql, ruleDetailid); + while (recordSet.next()){ + String overtimelength = recordSet.getString("overtimelength"); + String balancelength = recordSet.getString("balancelength"); + overtimelengthList.add(overtimelength); + balancelengthList.add(balancelength); + } + if(!overtimelengthList.isEmpty() && !balancelengthList.isEmpty()){ + balanceLengthDetailMap.put("overtimelengthList", overtimelengthList); + balanceLengthDetailMap.put("balancelengthList", balancelengthList); + return balanceLengthDetailMap; + } + return balanceLengthDetailMap; + } + + /** + * 按加班的时间段设置转调休时长 + */ + public Map> getBalanceTimeDetailMap(int ruleDetailid){ + Map> balanceTimethDetailMap = Maps.newHashMap(); + RecordSet recordSet = new RecordSet(); + List idList = Lists.newArrayList(); + List timepointList = Lists.newArrayList(); + List lenOfOvertimeList = Lists.newArrayList(); + List lenOfLeaveList = Lists.newArrayList(); + String sql = "select * from kq_OvertimeBalanceTimeDetail where rulesdetailid= ? order by dsporder "; + recordSet.executeQuery(sql, ruleDetailid); + while (recordSet.next()){ + String id = recordSet.getString("id"); + String timepoint = recordSet.getString("timepoint"); + String lenOfOvertime = recordSet.getString("lenOfOvertime"); + String lenOfLeave = recordSet.getString("lenOfLeave"); + idList.add(id); + timepointList.add(timepoint); + lenOfOvertimeList.add(lenOfOvertime); + lenOfLeaveList.add(lenOfLeave); + } + if(!timepointList.isEmpty() && !lenOfOvertimeList.isEmpty() && !lenOfLeaveList.isEmpty()){ + balanceTimethDetailMap.put("idList", idList); + balanceTimethDetailMap.put("timepointList", timepointList); + balanceTimethDetailMap.put("lenOfOvertimeList", lenOfOvertimeList); + balanceTimethDetailMap.put("lenOfLeaveList", lenOfLeaveList); + return balanceTimethDetailMap; + } + return balanceTimethDetailMap; + } +} diff --git a/src/com/engine/kq/biz/KQRepeatLengthContext.java b/src/com/engine/kq/biz/KQRepeatLengthContext.java new file mode 100644 index 0000000..c17c36a --- /dev/null +++ b/src/com/engine/kq/biz/KQRepeatLengthContext.java @@ -0,0 +1,100 @@ +package com.engine.kq.biz; + +import com.engine.kq.bean.KQRepeatBean; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.lang.StringUtils; + +import java.util.List; +import java.util.Map; + +public class KQRepeatLengthContext { + + /** + * 需要进行哺乳假处理的 + */ + public static final ThreadLocal ATTEND_REPEAT_BEAN_LOCAL = new ThreadLocal<>(); + + + /** + * 哺乳假是控制每天的异常时长,需要记录每一天的KQRepeatBean + */ + public static final ThreadLocal>> ATTEND_REPEAT_LOCAL = new ThreadLocal<>(); + + /** + * 针对当天哺乳假流程抵扣异常时长的部分 + */ + public static final ThreadLocal ATTEND_REPEAT_LINK_DETAIL_LOCAL = new ThreadLocal<>(); + + /** + * 针对当天每一个时段哺乳假流程抵扣异常时长的部分 + */ + public static final ThreadLocal ATTEND_REPEAT_LINK_RANGE_LOCAL = new ThreadLocal<>(); + + public static KQRepeatBean getRepeatBean() { + return ATTEND_REPEAT_BEAN_LOCAL.get(); + } + + public static void setRepeatBean(KQRepeatBean repeatBean) { + ATTEND_REPEAT_BEAN_LOCAL.set(repeatBean); + } + + + public static void removeRepeatBean() { + ATTEND_REPEAT_BEAN_LOCAL.remove(); + } + + + public static void clear() { + ATTEND_REPEAT_LOCAL.remove(); + } + + public static List getKQRepeatBean(String key) { + Map> attendRepeatBeanMap = ATTEND_REPEAT_LOCAL.get(); + return attendRepeatBeanMap != null && StringUtils.isNotEmpty(key) ? attendRepeatBeanMap.get(key) : null; + } + + public static void setKQRepeatBean(String key,KQRepeatBean attendRepeatBean) { + Map> attendRepeatBeanMap = ATTEND_REPEAT_LOCAL.get(); + if (attendRepeatBeanMap == null) { + attendRepeatBeanMap = Maps.newHashMap(); + ATTEND_REPEAT_LOCAL.set(attendRepeatBeanMap); + } + if(attendRepeatBeanMap.containsKey(key)){ + List tmp = attendRepeatBeanMap.get(key); + tmp.add(attendRepeatBean); + }else{ + List tmp = Lists.newArrayList(); + tmp.add(attendRepeatBean); + attendRepeatBeanMap.put(key,tmp); + } + } + + public static KQRepeatBean getRepeatBeanLinkRange() { + return ATTEND_REPEAT_LINK_RANGE_LOCAL.get(); + } + + public static void setRepeatBeanLinkRange(KQRepeatBean repeatBean) { + ATTEND_REPEAT_LINK_RANGE_LOCAL.set(repeatBean); + } + + + public static void removeRepeatBeanLinkRange() { + ATTEND_REPEAT_LINK_RANGE_LOCAL.remove(); + } + + + + public static KQRepeatBean getRepeatBeanLink() { + return ATTEND_REPEAT_LINK_DETAIL_LOCAL.get(); + } + + public static void setRepeatBeanLink(KQRepeatBean repeatBean) { + ATTEND_REPEAT_LINK_DETAIL_LOCAL.set(repeatBean); + } + + + public static void removeRepeatBeanLink() { + ATTEND_REPEAT_LINK_DETAIL_LOCAL.remove(); + } +} diff --git a/src/com/engine/kq/biz/KQReportBiz.java b/src/com/engine/kq/biz/KQReportBiz.java new file mode 100644 index 0000000..ede4627 --- /dev/null +++ b/src/com/engine/kq/biz/KQReportBiz.java @@ -0,0 +1,3669 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum; +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; + +import java.text.DecimalFormatSymbols; +import java.util.Map.Entry; + +import com.engine.kq.util.KQTransMethod; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.text.DecimalFormat; +import java.util.*; + +public class KQReportBiz extends BaseBean { + + private static DecimalFormat df = new DecimalFormat("0.00"); + + private DecimalFormatSymbols symbols = new DecimalFormatSymbols(); + + + public String format(double value) { +// DecimalFormatSymbols symbols = new DecimalFormatSymbols(); + symbols.setDecimalSeparator('.'); + df.setMaximumFractionDigits(5); + df.setDecimalFormatSymbols(symbols); + return df.format(value); + } + + + private KQLog kqLog = new KQLog(); + /** + * 初始化当天考勤数据 + */ + public void initKQReportData(){ + String date = DateUtil.getCurrentDate(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + boolean hasInit = false; + sql = "select 1 from kq_report_check where check_date = ? "; + rs.executeQuery(sql,date); + if(rs.next()) { + hasInit = true; + } + + String beforeyesterday = DateUtil.addDate(date,-2); + String yesterday = DateUtil.addDate(date,-1); + if(!hasInit){ + //这里做过功能是每天都刷下考勤缓存 因为这个缓存也是异步的,一点都不稳定 + kqLog.info("begin do KQOneStopUp refreshCominfo invoke ..."); + new KQOneStopUp().refreshCominfo(); + kqLog.info("end do KQOneStopUp refreshCominfo invoke ..."); + + KQFormatBiz kqFormatBiz = new KQFormatBiz(); + kqFormatBiz.clearFormatPool(); + //格式化上上天数据 + kqFormatBiz.formatDateByKQDate(beforeyesterday); + //格式化上一天数据 + kqFormatBiz.formatDateByKQDate(yesterday); + //初始化今天数据 + kqFormatBiz.formatDateByKQDate(date); + + sql = " insert into kq_report_check(check_date) values (?)"; + rs.executeUpdate(sql,date); + + writeLog(date+"执行考勤报表数据格式化成功!"); + } + }catch (Exception e){ + writeLog(e); + } + } + + public Map getModel_ShiftRule(String i,String serialId) { + RecordSet rs = new RecordSet(); + HashMap sectionMap = new HashMap<>(); + String getStartWorkSections = "select * from kq_ShiftOnOffWorkSections where SERIALID=? and record=? "; + rs.executeQuery(getStartWorkSections,serialId,i); + while (rs.next()) { + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + String clockinnot = Util.null2s(Util.null2String(rs.getString("clockinnot")), "0"); + sectionMap.put(onoffworktype, clockinnot); + } + return sectionMap; + } + + /*** + * 获取考勤状态 + * @param resourceId + * @param fromdate + * @param todate + * @param isAll + * @return + */ + public List getKqDateInfo(String resourceId, String fromdate, String todate, boolean isAll) { + List kqdates = new ArrayList<>(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + Map kqdate = null; + List datas = null; + Map data = null; + sql = " select kqdate,serialid, workbegindate, workbegintime,workenddate, workendtime," + + " signintime,signouttime,beLateMins,graveBeLateMins,leaveEarlyMins,graveLeaveEarlyMins," + + " absenteeismMins, forgotCheckMins,forgotBeginWorkCheckMins,otherinfo,serialnumber "+ + " from kq_format_detail " + + " where resourceid=? and kqdate>=? and kqdate<=? "; + if(!isAll){ + if(rs.getDBType().equalsIgnoreCase("oracle") || Util.null2String(rs.getOrgindbtype()).equals("dm") || Util.null2String(rs.getOrgindbtype()).equals("st")) { + sql += " and nvl(beLateMins,0)+nvl(graveBeLateMins,0)+nvl(leaveEarlyMins,0)+nvl(graveLeaveEarlyMins,0)+nvl(absenteeismMins,0)+nvl(forgotCheckMins,0)+nvl(forgotBeginWorkCheckMins,0)>0 "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + sql += " and ifnull(beLateMins,0)+ifnull(graveBeLateMins,0)+ifnull(leaveEarlyMins,0)+ifnull(graveLeaveEarlyMins,0)+ifnull(absenteeismMins,0)+ifnull(forgotCheckMins,0)+ifnull(forgotBeginWorkCheckMins,0)>0 "; + }else { + sql += " and isnull(beLateMins,0)+isnull(graveBeLateMins,0)+isnull(leaveEarlyMins,0)+isnull(graveLeaveEarlyMins,0)+isnull(absenteeismMins,0)+isnull(forgotCheckMins,0)+isnull(forgotBeginWorkCheckMins,0)>0 "; + } + } + sql += " order by kqdate,serialnumber "; + + rs.executeQuery(sql,resourceId,fromdate, todate); + while(rs.next()){ + String serialnumber = Util.null2String(rs.getString("serialnumber")); + String serialid = Util.null2String(rs.getString("serialid")); + String workbegindate = Util.null2String(rs.getString("workbegindate")); + String workbegintime = Util.null2String(rs.getString("workbegintime")); + String workenddate = Util.null2String(rs.getString("workenddate")); + String workendtime = Util.null2String(rs.getString("workendtime")); + String signintime = Util.null2String(rs.getString("signintime")); + String signouttime = Util.null2String(rs.getString("signouttime")); + int beLateMins = rs.getInt("beLateMins"); + int graveBeLateMins = rs.getInt("graveBeLateMins"); + int leaveEarlyMins = rs.getInt("leaveEarlyMins"); + int graveLeaveEarlyMins = rs.getInt("graveLeaveEarlyMins"); + int absenteeismMins = rs.getInt("absenteeismMins"); + int forgotCheckMins = rs.getInt("forgotCheckMins"); + int forgotBeginWorkCheckMins = rs.getInt("forgotBeginWorkCheckMins"); + String otherinfo = Util.null2String(rs.getString("otherinfo")); + + String shift_begindate = ""; + String shift_beginworktime = ""; + String shift_enddate = ""; + String shift_endworktime = ""; + if(otherinfo.length() > 0){ + JSONObject otherinfo_object = JSONObject.parseObject(otherinfo); + if(otherinfo_object != null && !otherinfo_object.isEmpty()){ + JSONObject shiftRule = (JSONObject) otherinfo_object.get("shiftRule"); + if(shiftRule != null && !shiftRule.isEmpty()){ + shift_begindate = Util.null2String(shiftRule.get("shift_begindate")); + shift_beginworktime = Util.null2String(shiftRule.get("shift_beginworktime")); + shift_enddate = Util.null2String(shiftRule.get("shift_enddate")); + shift_endworktime = Util.null2String(shiftRule.get("shift_endworktime")); + if(shift_begindate.length() > 0){ + workbegindate = shift_begindate; + } + if(shift_beginworktime.length() > 0){ + workbegintime = shift_beginworktime; + } + if(shift_enddate.length() > 0){ + workenddate = shift_enddate; + } + if(shift_endworktime.length() > 0){ + workendtime = shift_endworktime; + } + } + } + } + + kqdate = new HashMap<>(); + datas = new ArrayList<>(); + kqdate.put("kqdate",Util.null2String(rs.getString("kqdate"))); + if(workbegindate.length()>0){ + data = new HashMap<>(); + data.put("workbegindate",workbegindate); + data.put("workbegintime",workbegintime); + data.put("signintime",signintime); + + data.put("workenddate",workenddate); + data.put("workendtime",workendtime); + data.put("signouttime",signouttime); + String status = ""; + if(beLateMins>0||graveBeLateMins>0){ + status = ButtonStatusEnum.BELATE.getStatusCode(); + } + if(forgotBeginWorkCheckMins>0){ + if(status.length()>0)status+=","; + status += ButtonStatusEnum.NOSIGN_ON.getStatusCode(); + } + if(leaveEarlyMins>0||graveLeaveEarlyMins>0){ + if(status.length()>0)status+=","; + status += ButtonStatusEnum.LEAVEERALY.getStatusCode(); + } + if(absenteeismMins>0){ + int isondutyfreecheck =0; + int isoffdutyfreecheck =0; + Map model_ShiftRule = getModel_ShiftRule(serialnumber, serialid); + Iterator iter = model_ShiftRule.entrySet().iterator(); + while (iter.hasNext()) { + Entry entry = (Entry) iter.next(); + String key = Util.null2String(entry.getKey()); + String value = Util.null2String(entry.getValue()); + if(key.equals("start")&&value.equals("1")){ + isondutyfreecheck = 1; + } + if(key.equals("end")&&value.equals("1")){ + isoffdutyfreecheck = 1; + } + } + data.put("start",isondutyfreecheck); + data.put("end",isoffdutyfreecheck); + if(status.length()>0)status+=","; + status += ButtonStatusEnum.ABSENT.getStatusCode(); + } + if(forgotCheckMins>0){ + if(status.length()>0)status+=","; + status += ButtonStatusEnum.NOSIGN.getStatusCode(); + } + data.put("status",status); + datas.add(data); + } + + kqdate.put("checkInfo",datas); + kqdates.add(kqdate); + } + } catch (Exception e) { + writeLog(e); + } + return kqdates; + } + + /** + * 获取真实的开始日期和结束日期,没有权限的人最大只能查询本季 + * @param fromDate + * @param toDate + * @param user + * @return + */ + public Map realDate(String fromDate, String toDate, User user, String reportType) { + Map dateMap = new HashMap<>(); + dateMap.put("fromDate", fromDate); + dateMap.put("toDate", toDate); + boolean hasRight = false; + if("-100".equals(reportType)) { + RecordSet rs = new RecordSet(); + String departmentId = ""; + rs.executeQuery("select subcompanyid1, departmentId from hrmresource where id = ?", user.getUID()); + if (rs.next()) { + departmentId = StringUtil.vString(rs.getString("departmentId")); + } + hasRight = HrmUserVarify.checkUserRight("MobileSignInfo:Manage", user, departmentId); + } else { + hasRight = new KQReportBiz().hasReportRight(reportType,""+user.getUID()); + } + boolean kq_personal_reportsearch = KQSettingsBiz.showLeaveTypeSet("kq_personal_reportsearch"); + if(!hasRight && kq_personal_reportsearch) { // 开启开关,且没有权限的账号,最大查询只支持到本季 + String seasonFromDate = TimeUtil.getDateByOption("4","0"); + String seasonToDate = TimeUtil.getDateByOption("4","1"); + if(toDate.compareTo(seasonFromDate) < 0 || fromDate.compareTo(seasonToDate) > 0) { + dateMap.put("fromDate", "-1"); + dateMap.put("toDate", "-1"); + return dateMap; + } else if(fromDate.compareTo(seasonFromDate) < 0) { + fromDate = seasonFromDate; + if(toDate.compareTo(seasonToDate) > 0) { + toDate = seasonToDate; + } + } else if(fromDate.compareTo(seasonFromDate) >= 0) { + if(toDate.compareTo(seasonToDate) > 0) { + toDate = seasonToDate; + } + } + } + dateMap.put("fromDate", fromDate); + dateMap.put("toDate", toDate); + return dateMap; + } + + /** + * 是否有考勤报表相关权限 + * @param reportType 1:考勤汇总报表; 2:每日统计报表; 3:原始打卡记录; 4:员工假期余额 + * @param userId + * @return + */ + public boolean hasReportRight(String reportType, String userId){ + String sql = ""; + RecordSet rs = new RecordSet(); + sql = " select sharelevel,subcomid, deptid,userid,jobtitleid,foralluser from kq_reportshare where resourceid=? "; + if(reportType.length()>0 ){ + sql += " and (reportname =0 or reportname =" + reportType+")"; + } + rs.executeQuery(sql,userId); + if(rs.next()) { + return true; + } + return false; + } + + /** + * 将操作导出四大考勤报表的日志记录到数据库中,谁操作的导出,什么时间操作的导出,导出的条件都存储下来 + * @param params + * @param user + */ + public void insertKqReportExportLog(Map params, User user) { + RecordSet rs = new RecordSet(); + String exportParams = JSON.toJSONString(params); + String sql = "insert into kq_exportreport_log(operatorid,exportparams) values(?,?)"; + rs.executeUpdate(sql, user.getUID(), exportParams); + } + + /** + * 获取报表权限 + * @param reportType 报表类型 + * @param userId 用户id + * @param tableExt 别名 + * @return + */ + public String getReportRight(String reportType, String userId, String tableExt){ + String rightSql = ""; + String sql = ""; + RecordSet rs = new RecordSet(); + try{ + List userAllUserIds = new ArrayList<>(); + List userAllDeptIds = new ArrayList<>(); + List userAllSubCompanyIds = new ArrayList<>(); + List userAllJobtitleIds = new ArrayList<>(); + boolean forAllUser = false; + sql = " select sharelevel,subcomid, deptid,userid,jobtitleid,foralluser from kq_reportshare where resourceid=? "; + if(reportType.length()>0 ){ + sql += " and (reportname =0 or reportname =" + reportType+")"; + } + rs.executeQuery(sql,userId); + while(rs.next()){ + int sharelevel = rs.getInt("sharelevel"); + if(sharelevel==0){//分部 + if(Util.null2String(rs.getString("subcomid")).length()>0){ + userAllSubCompanyIds.add(rs.getString("subcomid")); + } + }else if(sharelevel==1){//部门 + if(Util.null2String(rs.getString("deptid")).length()>0) { + userAllDeptIds.add(rs.getString("deptid")); + } + }else if(sharelevel==2){//人员 + if(Util.null2String(rs.getString("userid")).length()>0) { + userAllUserIds.add(rs.getString("userid")); + } + }else if(sharelevel==3){//岗位 + if(Util.null2String(rs.getString("jobtitleid")).length()>0) { + userAllJobtitleIds.add(rs.getString("jobtitleid")); + } + }else if(sharelevel==4){//所有人 + forAllUser = true; + userAllUserIds.clear(); + userAllDeptIds.clear(); + userAllSubCompanyIds.clear(); + userAllJobtitleIds.clear(); + break; + } + } + + if(!forAllUser) { + for (int sharelevel = 0; sharelevel < 4; sharelevel++) { + if (sharelevel == 0) {//分部 + if (userAllSubCompanyIds.size() > 0) { + if(rightSql.length()>0)rightSql+= " or "; + rightSql += tableExt+".subcompanyid1 in(" + String.join(",", userAllSubCompanyIds) + ")"; + } + } else if (sharelevel == 1) {//部门 + if (userAllDeptIds.size() > 0) { + if(rightSql.length()>0)rightSql+= " or "; + rightSql += tableExt+".departmentid in(" + String.join(",", userAllDeptIds) + ")"; + } + } else if (sharelevel == 2) {//人员 + if (userAllUserIds.size() > 0) { + if(rightSql.length()>0)rightSql+= " or "; + rightSql += tableExt+".id in(" + String.join(",", userAllUserIds) + ")"; + } + } else if (sharelevel == 3) {//岗位 + if (userAllJobtitleIds.size() > 0) { + if(rightSql.length()>0)rightSql+= " or "; + rightSql += tableExt+".jobtitle in(" + String.join(",", userAllJobtitleIds) + ")"; + } + } + } + + //可以看自己和下属的考勤 + String selfSql = " ("+tableExt+".id = "+userId+" or "+tableExt+".managerstr like '%,"+userId+",%')"; + if(rightSql.length()>0){ + rightSql = " and ((" +rightSql+") or "+selfSql+" ) "; + }else{ + rightSql = " and "+selfSql; + } + + } + }catch (Exception e){ + writeLog(e); + } + return rightSql; + } + + public static String getUnitType(KQReportFieldComInfo kqReportFieldComInfo, User user){ + String unitTypeName = ""; + String unitType = Util.null2String(kqReportFieldComInfo.getUnittype()); + String parentid = Util.null2String( kqReportFieldComInfo.getParentid()); + String fieldName = Util.null2String(kqReportFieldComInfo.getFieldname()); + if(kqReportFieldComInfo.getIsLeaveType().equals("1")){ + if(fieldName.equals("businessLeave")){ + unitType = KQTravelRulesBiz.getMinimumUnit().equals("3")?"2":"1";//单位类型 + }else if(fieldName.equals("officialBusiness")){ + unitType = KQExitRulesBiz.getMinimumUnit().equals("3")?"2":"1";//单位类型 + }else if(parentid.equals("overtime") || parentid.equals("overtime_nonleave") || parentid.equals("overtime_4leave")){ + unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";//单位类型 + } + } + if(Util.null2String(unitType).length()>0){ + 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()); + } + } + return unitTypeName; + } + + /** + * 为每日统计报表做流程数据查询 + * @param params + * @param user + * @return + */ + public Map getDailyFlowData(Map params, User user){ + Map datas = new HashMap<>();; + try{ + datas.putAll(getDailyFlowLeaveData(params,user)); + datas.putAll(getDailyFlowEvectionOutData(params,user)); + datas.putAll(getDailyFlowOverTimeData(params,user)); + datas.putAll(getDailyFlowLeaveBackData(params,user)); + + datas.putAll(getSignDetailInfoData(params,user)); + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + public Map getFlowData(Map params, User user){ + Map datas = new HashMap<>();; + try{ + datas.putAll(getFlowLeaveData(params,user)); + datas.putAll(getFlowEvectionOutData(params,user)); + datas.putAll(getFlowOverTimeDataNew(params,user)); + datas.putAll(getFlowOtherData(params,user)); + datas.putAll(getFlowLeaveBackData(params,user)); + datas.putAll(getFlowProcessChangeData(params,user)); + + datas.putAll(getCardMap(params,user)); + datas.putAll(getOverTime(params,user)); + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取出差和公出数据 + * @param params + * @param user + * @return + */ + public Map getFlowEvectionOutData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + String[] tables = new String[]{KqSplitFlowTypeEnum.EVECTION.getTablename(),//出差 + KqSplitFlowTypeEnum.OUT.getTablename()};//公出 + + String minimumUnit = "";//单位类型 + double proportion = 0.00;//换算关系 + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.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<>'' "); + } + + for(String table : tables){ + sql = " select resourceid, durationrule, sum(duration) as val from hrmresource a, "+table+" b "+ + " where a.id = b.resourceid and (b.status is null or b.status<>1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by resourceid, durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + double value = rs.getDouble("val"); + String durationrule = rs.getString("durationrule"); + + String flowType = ""; + if(KqSplitFlowTypeEnum.EVECTION.getTablename().equals(table)){ + flowType = "businessLeave"; + minimumUnit = KQTravelRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系 + + }else if(KqSplitFlowTypeEnum.OUT.getTablename().equals(table)){ + flowType = "officialBusiness"; + minimumUnit = KQExitRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系 + } + + if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+flowType; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key, format(value)); + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取每日的出差和公出数据 + * @param params + * @param user + * @return + */ + public Map getDailyFlowEvectionOutData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + String[] tables = new String[]{KqSplitFlowTypeEnum.EVECTION.getTablename(),//出差 + KqSplitFlowTypeEnum.OUT.getTablename()};//公出 + + String minimumUnit = "";//单位类型 + double proportion = 0.00;//换算关系 + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.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<>'' "); + } + + for(String table : tables){ + sql = " select resourceid, durationrule, sum(duration) as val,belongdate from hrmresource a, "+table+" b "+ + " where a.id = b.resourceid and (b.status is null or b.status<>1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by resourceid, durationrule,belongdate "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + double value = rs.getDouble("val"); + String durationrule = rs.getString("durationrule"); + + String flowType = ""; + if(KqSplitFlowTypeEnum.EVECTION.getTablename().equals(table)){ + flowType = "businessLeave"; + minimumUnit = KQTravelRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系 + }else if(KqSplitFlowTypeEnum.OUT.getTablename().equals(table)){ + flowType = "officialBusiness"; + minimumUnit = KQExitRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系 + } + + if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+belongdate+"|"+flowType; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key, format(value)); + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取请假数据 + * @param params + * @param user + * @return + */ + public Map getFlowLeaveData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.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 resourceid, newleavetype, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+ + " where a.id = b.resourceid and (b.status is null or b.status != 1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype, kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|leaveType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + + //获取打卡数据用于判断外勤,补卡等信息=============================== + public Map getCardMap(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + //rs.writeLog("getCardMap="+ JSONObject.toJSONString(params)); + try{ + String show_card_source = Util.null2String(params.get("show_card_source")); + if(!"1".equals(show_card_source)){//下面的日历都是实时拼接,这里还是控制下数据库的交互次数,虽然用起来没啥用-.- + return datas; + } + + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + KQTransMethod kqTransMethod = new KQTransMethod(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + rs.writeLog("jsonObj="+ jsonObj.toJSONString()); + 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")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id 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<>'' "); + } + //em7外勤、云桥外勤数据同步、钉钉外勤打卡、微信外勤转考勤(补卡先留一个口子,以防客户要) +// sqlWhere += " and (signfrom like 'card%' or signfrom='e9_mobile_out' or signfrom='EMSyn_out' or signfrom='DingTalk_out' or signfrom='Wechat_out') "; + + sql = " select a.id,b.signdate,b.id as signid,b.signfrom from hrmresource a, hrmschedulesign b "+ + " where a.id = b.userid and b.signdate >='"+fromDate+"' and b.signdate <='"+toDate+"' " +sqlWhere + + " order by a.id,b.signdate "; + rs.execute(sql); +// kqLog.info("card.sql="+sql); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("id")); + String signdate = Util.null2String(rs.getString("signdate")); + String signid = Util.null2String(rs.getString("signid")); + String signfrom = Util.null2String(rs.getString("signfrom")); + String signFromShow = kqTransMethod.getSignFromShow(signfrom, ""+user.getLanguage()); + String key = resourceid+"|"+signdate; + + datas.put(signid,signFromShow); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + +//获取打卡数据用于判断外勤,补卡等信息=============================== + + /** + * 获取销假数据 + * @param params + * @param user + * @return + */ + public Map getFlowLeaveBackData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.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 resourceid, newleavetype, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|leavebackType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取考勤变更流程数据 + * @param params + * @param user + * @return + */ + public Map getFlowProcessChangeData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + String minimumUnit = "";//单位类型 + double proportion = 0.00;//换算关系 + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.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 resourceid, durationrule, changetype,sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.PROCESSCHANGE.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by resourceid, durationrule,changetype "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + int changetype = Util.getIntValue(rs.getString("changetype")); + + String flowType = ""; + if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == changetype){ + flowType = "businessLeave_back"; + proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系 + minimumUnit = KQTravelRulesBiz.getMinimumUnit(); + }else if(KqSplitFlowTypeEnum.OUT.getFlowtype() == changetype){ + flowType = "officialBusiness_back"; + minimumUnit = KQExitRulesBiz.getMinimumUnit(); + proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系 + } + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + String durationrule = rs.getString("durationrule"); + + if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+flowType; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key, format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取每日请假数据 + * @param params + * @param user + * @return + */ + public Map getDailyFlowLeaveData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.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 resourceid, newleavetype, durationrule, sum(duration) as val,belongdate from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule,belongdate "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+belongdate+"|leaveType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + + public Map getSignDetailInfoData(Map params, User user){ + Map data = new HashMap<>(); + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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 isneedcal = Util.null2String(params.get("isneedcal")); + if("".equals(isneedcal)){ + isneedcal = KQSettingsBiz.getKqformatAccurate()?"1":"0"; + } + 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")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.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<>'' "); + } + + //================================= +// Map data = new HashMap<>(); + Map signStatusInfo = null; + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + sql = " select kqdate,resourceid,day_type,serialid,serialnumber,workbegindate,workbegintime, " + + " workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" + + " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," + + " leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid,flowinfo,on_absenteeismmins,off_absenteeismmins \n" + + " from hrmresource a,kq_format_detail b \n" + + " where a.id = b.resourceid " +sqlWhere+ + " and b.kqdate >='" + fromDate + "' and b.kqdate<='"+toDate+"' \n" + + " order by b.serialnumber \n"; + rs.execute(sql); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("resourceid")); + String kqdate = Util.null2String(rs.getString("kqdate")); + String serialid = Util.null2String(rs.getString("serialid")); + String day_type = Util.null2s(rs.getString("day_type"),""); + int workMins = rs.getInt("workMins"); + boolean isNonWork = false; + if(day_type.length() > 0){ + if("holiday".equals(day_type) || "playday".equals(day_type)){ + isNonWork = true; + } + if(serialid.length() == 0){ + //弹性班制,会存在dayType是work但是没有班次的情况 + isNonWork = true; + } + }else{ + if(workMins<=0){ + isNonWork = true; + }else{ + if(serialid.length() > 0){ + String isRest = Util.null2s(kqShiftManagementComInfo.getIsRest(serialid),""); + if("1".equals(isRest)){ + isNonWork = true; + } + } + } + } + int serialnumber = rs.getInt("serialnumber")+1; + String workbegindate = Util.null2String(rs.getString("workbegindate")).trim(); + String workbegintime = Util.null2String(rs.getString("workbegintime")).trim(); + String workenddate = Util.null2String(rs.getString("workenddate")).trim(); + String workendtime = Util.null2String(rs.getString("workendtime")).trim(); + String signintime = Util.null2String(rs.getString("signintime")).trim(); + String signouttime = Util.null2String(rs.getString("signouttime")).trim(); + int attendanceMins = rs.getInt("attendanceMins"); + String beLateMins = Util.null2String(rs.getString("beLateMins")).trim(); + String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")).trim(); + String leaveEarlyMins= Util.null2String(rs.getString("leaveEarlyMins")).trim(); + String graveLeaveEarlyMins= Util.null2String(rs.getString("graveLeaveEarlyMins")).trim(); + String absenteeismMins= Util.null2String(rs.getString("absenteeismMins")).trim(); + String forgotCheckMins = Util.null2String(rs.getString("forgotcheckMins")).trim(); + String forgotBeginWorkCheckMins = Util.null2String(rs.getString("forgotBeginWorkCheckMins")).trim(); + String signinid = Util.null2String(rs.getString("signinid")).trim(); + String signoutid = Util.null2String(rs.getString("signoutid")).trim(); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = Util.null2String(rs.getString("leaveInfo")); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + String flowinfo = Util.null2String(rs.getString("flowinfo")); + String on_absenteeismmins = Util.null2String(rs.getString("on_absenteeismmins")); + String off_absenteeismmins = Util.null2String(rs.getString("off_absenteeismmins")); + + String tmpkey = resourceid+"|"+kqdate+"|"; + + + if(!isNonWork){ + if (workbegintime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("workdate",workbegindate); + signStatusInfo.put("worktime",workbegintime); + signStatusInfo.put("beLateMins",beLateMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("graveBeLateMins",graveBeLateMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + signStatusInfo.put("isneedcal",isneedcal); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("on_absenteeismmins",on_absenteeismmins); + signStatusInfo.put("off_absenteeismmins",off_absenteeismmins); + + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); + + data.put(tmpkey+"signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put(tmpkey+"signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + } + + if (workendtime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("workdate",workenddate); + signStatusInfo.put("worktime",kqTimesArrayComInfo.turn48to24Time(workendtime)); + signStatusInfo.put("leaveEarlyMins",leaveEarlyMins); + signStatusInfo.put("graveLeaveEarlyMins",graveLeaveEarlyMins); + signStatusInfo.put("forgotCheckMins",forgotCheckMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + signStatusInfo.put("isneedcal",isneedcal); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("on_absenteeismmins",on_absenteeismmins); + signStatusInfo.put("off_absenteeismmins",off_absenteeismmins); + + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); + + data.put(tmpkey+"signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put(tmpkey+"signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else{ + if(workMins>0){ + //弹性工时打卡时间取自签到签退数据 + } + signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + signStatusInfo.put("isneedcal",isneedcal); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("on_absenteeismmins",on_absenteeismmins); + signStatusInfo.put("off_absenteeismmins",off_absenteeismmins); + + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); + + if(signinid.length() > 0){ + data.put(tmpkey+"signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put(tmpkey+"signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + if(signoutid.length() > 0){ + data.put(tmpkey+"signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put(tmpkey+"signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else if(signoutid.length() > 0){ + data.put(tmpkey+"signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put(tmpkey+"signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + }else{ + data.put(tmpkey+"signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + data.put(tmpkey+"signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + } + } + }catch (Exception e){ + writeLog(e); + } + return data; + } + + /** + * 获取每日销假数据 + * @param params + * @param user + * @return + */ + public Map getDailyFlowLeaveBackData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.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 resourceid, newleavetype, durationrule, sum(duration) as val,belongdate from hrmresource a, "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule,belongdate "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+belongdate+"|leavebackType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取实际加班数据,包括流程,打卡生成的 + * @return + */ + public Map getFlowOverTimeDataNew(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id 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<>'' "); + } + + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + + String valueField = ""; + + sql = " select resourceid,changeType, sum(cast(duration_min as decimal(18,4))) as val,paidLeaveEnable "+ + " from hrmresource a, kq_flow_overtime b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " group by resourceid,changeType,paidLeaveEnable "; + rs.execute(sql); + kqLog.info("getFlowOverTimeDataNew:sql:"+sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String paidLeaveEnable = rs.getString("paidLeaveEnable"); + int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日 + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0)+"")); + }else{//按天计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0*hoursToDay)+"")); + } + String flowType = ""; + if(changeType==1){ + flowType = "holidayOvertime"; + }else if(changeType==2){ + flowType = "workingDayOvertime"; + }else if(changeType==3){ + flowType = "restDayOvertime"; + } + if("1".equalsIgnoreCase(paidLeaveEnable)){ + //1表示关联调休 + flowType += "_4leave"; + }else{ + //0表示不关联调休 + flowType += "_nonleave"; + } + String key = resourceid+"|"+flowType; + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + if(datas.containsKey(key)){ + double tmpVal = Util.getDoubleValue(Util.null2String(datas.get(key)),0.0); + tmpVal += value; + datas.put(key,format(tmpVal)); + }else{ + datas.put(key,format(value)); + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + + /** + * 获取加班数据 + * @return + */ + public Map getFlowOverTimeData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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")); + 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<>'' "); + } + + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + + String valueField = ""; + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + valueField = "sum( case when durationrule='3' then duration else duration*"+hoursToDay+" end) as val"; + }else{//按天计算 + valueField = "sum( case when durationrule='3' then duration/"+hoursToDay+" else duration end) as val"; + } + + sql = " select resourceid,changeType, " +valueField+ + " from hrmresource a, "+KqSplitFlowTypeEnum.OVERTIME.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " group by resourceid,changeType,durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日 + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + String flowType = ""; + if(changeType==1){ + flowType = "holidayOvertime"; + }else if(changeType==2){ + flowType = "workingDayOvertime"; + }else if(changeType==3){ + flowType = "restDayOvertime"; + } + String key = resourceid+"|"+flowType; + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + if(datas.containsKey(key)){ + double tmpVal = Util.getDoubleValue(Util.null2String(datas.get(key)),0.0); + tmpVal += value; + datas.put(key,format(tmpVal)); + }else{ + datas.put(key,format(value)); + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取每日加班数据 + * @return + */ + public Map getDailyFlowOverTimeData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id 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<>'' "); + } + + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + + String valueField = ""; + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + valueField = "sum( case when durationrule='3' then duration else duration*"+hoursToDay+" end) as val"; + }else{//按天计算 + valueField = "sum( case when durationrule='3' then duration/"+hoursToDay+" else duration end) as val"; + } + + sql = " select resourceid,changeType,belongdate,paidLeaveEnable, sum(cast(duration_min as decimal(18,4))) as val "+ + " from hrmresource a, kq_flow_overtime b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " group by resourceid,changeType,paidLeaveEnable,belongdate "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String paidLeaveEnable = rs.getString("paidLeaveEnable"); + int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日 + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0)+"")); + }else{//按天计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0*hoursToDay)+"")); + } + String flowType = ""; + if(changeType==1){ + flowType = "holidayOvertime"; + }else if(changeType==2){ + flowType = "workingDayOvertime"; + }else if(changeType==3){ + flowType = "restDayOvertime"; + } + if("1".equalsIgnoreCase(paidLeaveEnable)){ + //1表示关联调休 + flowType += "_4leave"; + }else{ + //0表示不关联调休 + flowType += "_nonleave"; + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(resourceid+"|"+belongdate+"|"+flowType,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 异常冲抵 + * @return + */ + public Map getFlowOtherData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + String minimumUnit = "";//单位类型 + double proportion = 0.00;//换算关系 + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.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 resourceid, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.OTHER.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by resourceid, durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + String durationrule = rs.getString("durationrule"); + + if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|leaveDeduction"; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key, format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + *日报表数据 + * @param resourceId + * @param fromDate + * @param toDate + * @return + */ + public Map getDetialDatas(String resourceId,String fromDate, String toDate, User user){ + return getDetialDatas(resourceId,fromDate,toDate,user,new HashMap(),false,0,"0"); + } + + /** + * 考勤汇总报表上下午显示开关不开启 + * @param resourceId + * @param fromDate + * @param toDate + * @param user + * @param flowData + * @param isWrap + * @param uintType + * @param show_card_source + * @return + */ + public Map getDetialDatasHalfNotOpen(String resourceId,String fromDate, String toDate, User user, + Map flowData,boolean isWrap,int uintType,String show_card_source){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + Map datas = new HashMap<>(); + Map data = null; + Map tmpdatas = new HashMap<>(); + Map tmpdatass = new HashMap<>(); + Map tmpdata = null; + Map tmpmap = null; + + Map tmpstatusdata = new HashMap<>(); + Map tmpstatus = null; + RecordSet rs = new RecordSet(); + String sql = ""; + + //add + String unit = "小时"; + if(uintType==1 || uintType== 2 || uintType== 4){//按天计算 + unit = "天"; + } + //kqLog.info("detail.flowdata="+JSONObject.toJSONString(flowData)); + + try { + sql = " select resourceid,day_type,serialid, kqdate, workMins,attendanceMins,signindate,signintime,signoutdate,signouttime,signinid,signoutid, belatemins, graveBeLateMins, leaveearlymins, graveLeaveEarlyMins, absenteeismmins, forgotcheckMins, forgotBeginWorkCheckMins, "+ + " leaveMins,leaveInfo,evectionMins,outMins " + + " from kq_format_detail " + + " where resourceid = ? and kqdate>=? and kqdate<=? "+ + " order by resourceid, kqdate, serialnumber "; + rs.executeQuery(sql,resourceId, fromDate,toDate); + while (rs.next()) { + String key = rs.getString("resourceid") + "|" + rs.getString("kqdate"); + int workMins = rs.getInt("workMins"); + + boolean isNonWork = false; + String serialid = Util.null2s(rs.getString("serialid"),""); + String dayType = Util.null2s(rs.getString("day_type"),""); + if(dayType.length() > 0){ + if("holiday".equals(dayType) || "playday".equals(dayType)){ + isNonWork = true; + } + }else{ + if(workMins<=0){ + isNonWork = true; + }else{ + if(serialid.length() > 0){ + String isRest = Util.null2s(kqShiftManagementComInfo.getIsRest(serialid),""); + if("1".equals(isRest)){ + isNonWork = true; + } + } + } + } + String attendanceMins = rs.getString("attendanceMins"); +// String chuqin = "出勤:"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(attendanceMins) / 60.0)))+"小时"; + String overtimekey = key+"|overtime"; + String overtime = Util.null2String(flowData.get(overtimekey)); + boolean hasovertime = Util.getDoubleValue(overtime)>0; + overtime = hasovertime?(SystemEnv.getHtmlLabelName(6151, user.getLanguage())+":"+overtime+unit):"";//显示加班 + + String signinid = ""; + String signoutid = ""; + String signintime = ""; + String signouttime = ""; + if("1".equals(show_card_source)){ + String nosign = SystemEnv.getHtmlLabelName(25994, user.getLanguage());//未打卡 + signinid = Util.null2String(rs.getString("signinid")).trim(); + signintime = Util.null2String(rs.getString("signintime")).trim(); + String tmpin = SystemEnv.getHtmlLabelName(21974, user.getLanguage())+":"; + if(signinid.length()>0){ + String signinfrom = Util.null2String(flowData.get(signinid)); + signintime = tmpin+signintime+" "+signinfrom; + }else{ + signintime = tmpin+nosign; + } +// signintime = isWrap?"\r\n"+signintime:"
"+signintime; + + signoutid = Util.null2String(rs.getString("signoutid")).trim(); + signouttime = Util.null2String(rs.getString("signouttime")).trim(); + String tmpout = SystemEnv.getHtmlLabelName(21975, user.getLanguage())+":"; + if(signoutid.length()>0){ + String signoutfrom = Util.null2String(flowData.get(signoutid)); + signouttime = tmpout+signouttime+" "+signoutfrom; + }else{ + signouttime = tmpout+nosign; + } + signouttime = isWrap?"\r\n"+signouttime:"
"+signouttime; + } + + int beLateMins = rs.getInt("beLateMins"); + int leaveEarlyMins = rs.getInt("leaveEarlyMins"); + int graveBeLateMins = rs.getInt("graveBeLateMins"); + int absenteeismMins = rs.getInt("absenteeismMins"); + int graveLeaveEarlyMins = rs.getInt("graveLeaveEarlyMins"); + int forgotCheckMins = rs.getInt("forgotCheckMins"); + int forgotBeginWorkCheckMins = rs.getInt("forgotBeginWorkCheckMins"); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = rs.getString("leaveInfo"); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + String text = ""; + String tmptext =""; + String flag ="true"; + if(datas.get(key)==null){ + data = new HashMap<>(); + }else{ + data = (Map)datas.get(key); + tmptext = Util.null2String(data.get("text")); + } + tmpdata = new HashMap<>(); + if(tmpdatas.get(key)!=null){ + tmpmap = (Map)tmpdatas.get(key); + flag = Util.null2String(tmpmap.get("text")); + } + + String yichang =""; + if(tmpstatusdata.get(key)!=null){ + yichang = Util.null2String(tmpstatusdata.get(key)); + } + String sign =""; + String signkey = key+"|text"; + if(tmpstatusdata.get(signkey)!=null){ + sign = Util.null2String(tmpstatusdata.get(signkey)); + } + + if (isNonWork) { + if(text.length()>0) text +=" "; + if(sign.indexOf(SystemEnv.getHtmlLabelName(26593, user.getLanguage()))==-1){ + if(text.length()>0) { + text+= isWrap?"\r\n":"
"; + } + text += SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + } + //休息日处理 + if(signinid.length()>0){ + text += (isWrap?"\r\n":"
")+signintime; + } + if(signoutid.length()>0){ + text += signouttime; + } + sign += text; + } else { + //处理打卡数据================== + if(text.length()>0) text+= isWrap?"\r\n":"
"; + text += signintime; + text += signouttime; + if(sign.length()>0) sign+= isWrap?"\r\n":"
"; + sign += text; + //处理打卡数据================== + + if (absenteeismMins > 0) {//旷工 + if(text.length()>0) text+=" "; + text += SystemEnv.getHtmlLabelName(20085, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+absenteeismMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20085, user.getLanguage()))==-1){ + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + }else { + if (beLateMins > 0) {//迟到 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20081, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+beLateMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20081, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20081, user.getLanguage()); + } + } + if (graveBeLateMins > 0) {//严重迟到 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(500546, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+graveBeLateMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(500546, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(500546, user.getLanguage()); + } + } + if (leaveEarlyMins > 0) {//早退 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20082, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+leaveEarlyMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20082, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20082, user.getLanguage()); + } + } + if (graveLeaveEarlyMins > 0) {//严重早退 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(500547, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+graveLeaveEarlyMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(500547, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(500547, user.getLanguage()); + } + } + if (forgotCheckMins > 0) {//漏签 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20086, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + if (forgotBeginWorkCheckMins > 0) {//漏签 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20086, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + } + } + if (leaveMins > 0) {//请假 + Map jsonObject = null; + if(leaveInfo.length()>0){ + jsonObject = JSON.parseObject(leaveInfo); + for (Entry entry : jsonObject.entrySet()) { + String newLeaveType = entry.getKey(); + String tmpLeaveMins = Util.null2String(entry.getValue()); + if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){ + if (text.length() > 0) text += " "; + //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + text += Util.formatMultiLang( kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+leaveMins) / 60.0)))+"小时"; + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += Util.formatMultiLang( kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); + } + } + }else{ + if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } + } + } + if (evectionMins > 0) {//出差 + if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+evectionMins) / 60.0)))+"小时"; + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } + } + if (outMins > 0) {//公出 + if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+outMins) / 60.0)))+"小时"; + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + } + + if(text.length()==0) { + text = "√"; + }else{ + flag = "false";//有其他的异常状态,则表示为false,不需要处理直接全部显示即可 + } + text += overtime; + + + //需要处理下打卡时间和异常状态显示的顺序--start + tmpstatusdata.put(key, yichang); + tmpstatusdata.put(signkey, sign); + boolean hasyichang = tmpstatusdata.get(key).length()>0; + if(tmptext.length()>0){ +// text = tmpstatusdata.get(signkey)+(isWrap?"\r\n":"
")+tmpstatusdata.get(key)+(isWrap?"\r\n":"
"+overtime); + text = tmpstatusdata.get(signkey); + if(hasyichang){ + if(text.length()>0){ + text += (isWrap?"\r\n":"
")+tmpstatusdata.get(key); + }else{ + text += tmpstatusdata.get(key); + } + } + if(hasovertime){ + text += (isWrap?"\r\n":"
")+overtime; + } + }else{ + text = tmpstatusdata.get(signkey); + if(hasyichang){ + if(text.length()>0){ + text += (isWrap?"\r\n":"
")+tmpstatusdata.get(key); + }else{ + text += tmpstatusdata.get(key); + } + } + if(hasovertime){ + text += (isWrap?"\r\n":"
")+overtime; + } + } + //需要处理下打卡时间和异常状态显示的顺序--end + tmpdatass.put(key, (isWrap?"\r\n":"
")+overtime); +// text = tmptext.length()>0?tmptext+" "+text:text;//显示所有的状态 + data.put("text", text); + datas.put(key, data); + + //add + tmpdata.put("text", flag); + tmpdatas.put(key, tmpdata); + //end + } + //全部搞一遍 + if(tmpdatas != null){ +// writeLog(n+">>>tmpdatas="+JSONObject.toJSONString(tmpdatas)); + Map data1 = null; + for(Entry entry : tmpdatas.entrySet()){ + String mapKey = Util.null2String(entry.getKey()); + Map mapValue = (Map)entry.getValue(); + String flag = Util.null2String(mapValue.get("text")); + if("true".equals(flag)){//需要加工的数据 + String overtime = String.valueOf(tmpdatass.get(mapKey)); + data1 = new HashMap<>(); + data1.put("text", "√"+overtime); + datas.put(mapKey, data1); + } + } +// writeLog("datas="+JSONObject.toJSONString(datas)); + } + }catch (Exception e){ + writeLog(e); + } + // 最后针对数据再处理一遍,不然出现2023-01-02: "休息" 形式的错误,导致页面记载报错,应该是2023-01-01: {text: "休息"}格式 + boolean isEnd = false; + for(String currentDate = fromDate; !isEnd;) { + if (currentDate.equals(toDate)) isEnd = true; + String dailyValue = Util.null2String(datas.get(currentDate)); + if(!"".equals(dailyValue) && !dailyValue.contains("text")) { + Map innerMap2 = new HashMap<>(); + innerMap2.put("text", dailyValue); + datas.put(currentDate, innerMap2); + } + currentDate = DateUtil.addDate(currentDate, 1); + } + return datas; + } + + /** + * 考勤汇总报表上下午显示开关开启 + * @param resourceId + * @param fromDate + * @param toDate + * @param user + * @param flowData + * @param isWrap + * @param uintType + * @param show_card_source + * @return + */ + public Map getDetialDatasHalfOpen(String resourceId,String fromDate, String toDate, User user, + Map flowData,boolean isWrap,int uintType,String show_card_source){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + int split_time_index = kqTimesArrayComInfo.getArrayindexByTimes("13:00"); + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + Map datas = new HashMap<>(); + Map data = null; + Map tmpdatas = new HashMap<>(); + Map tmpdatass = new HashMap<>(); + Map tmpdata = null; + Map tmpmap = null; + + Map tmpstatusdata = new HashMap<>(); + Map tmpstatus = null; + RecordSet rs = new RecordSet(); + String sql = ""; + + //add + String unit = "小时"; + if(uintType==1 || uintType== 2 || uintType== 4){//按天计算 + unit = "天"; + } + //kqLog.info("detail.flowdata="+JSONObject.toJSONString(flowData)); + + try { + sql = " select resourceid,day_type,serialid, kqdate, workMins, workbegintime, workendtime,attendanceMins,signindate,signintime,signoutdate,signouttime,signinid,signoutid, belatemins, graveBeLateMins, leaveearlymins, graveLeaveEarlyMins, absenteeismmins, forgotcheckMins, forgotBeginWorkCheckMins, "+ + " leaveMins,leaveInfo,evectionMins,outMins,flowinfo,on_absenteeismmins,off_absenteeismmins " + + " from kq_format_detail " + + " where resourceid = ? and kqdate>=? and kqdate<=? "+ + " order by resourceid, kqdate, serialnumber "; + rs.executeQuery(sql,resourceId, fromDate,toDate); + while (rs.next()) { + String kqDate = rs.getString("kqdate"); + String key = rs.getString("resourceid") + "|" + kqDate; + int workMins = rs.getInt("workMins"); + + String signinid = ""; + String signoutid = ""; + String signintime = ""; + String signouttime = ""; + if("1".equals(show_card_source)){ + String nosign = SystemEnv.getHtmlLabelName(25994, user.getLanguage());//未打卡 + signinid = Util.null2String(rs.getString("signinid")).trim(); + signintime = Util.null2String(rs.getString("signintime")).trim(); + String tmpin = SystemEnv.getHtmlLabelName(21974, user.getLanguage())+":"; + if(signinid.length()>0){ + String signinfrom = Util.null2String(flowData.get(signinid)); + signintime = tmpin+signintime+" "+signinfrom; + }else{ + signintime = tmpin+nosign; + } + signintime = isWrap?"\r\n"+signintime:"
"+signintime; +// signintime = isWrap?"\r\n"+signintime:"
"+signintime; + + signoutid = Util.null2String(rs.getString("signoutid")).trim(); + signouttime = Util.null2String(rs.getString("signouttime")).trim(); + String tmpout = SystemEnv.getHtmlLabelName(21975, user.getLanguage())+":"; + if(signoutid.length()>0){ + String signoutfrom = Util.null2String(flowData.get(signoutid)); + signouttime = tmpout+signouttime+" "+signoutfrom; + }else{ + signouttime = tmpout+nosign; + } + signouttime = isWrap?"\r\n"+signouttime:"
"+signouttime; + } + + String overtimekey = key+"|overtime"; + String overtime = Util.null2String(flowData.get(overtimekey)); + boolean hasovertime = Util.getDoubleValue(overtime)>0; + overtime = hasovertime? ((isWrap?"\r\n":"
")+(SystemEnv.getHtmlLabelName(6151, user.getLanguage())+":"+overtime+unit)):"";//显示加班 + + + String flowinfo = Util.null2String(rs.getString("flowinfo")); + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceId, kqDate, false); + boolean isNonWork = false; + String serialid = Util.null2s(rs.getString("serialid"),""); + String dayType = Util.null2s(rs.getString("day_type"),""); + if(dayType.length() > 0){ + if("holiday".equals(dayType) || "playday".equals(dayType)){ + isNonWork = true; + } + }else{ + if(workMins<=0){ + isNonWork = true; + }else{ + if(serialid.length() > 0){ + String isRest = Util.null2s(kqShiftManagementComInfo.getIsRest(serialid),""); + if("1".equals(isRest)){ + isNonWork = true; + } + } + } + } + if(shiftInfoBean == null || isNonWork) { + String textAM = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + String textPM = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + if(datas.get(key)==null){ + data = new HashMap<>(); + }else{ + data = (Map)datas.get(key); + } + if(shiftInfoBean != null) { + List halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + if (halfWorkIndex != null && !halfWorkIndex.isEmpty()) { + int[] halfWorkIndexs = halfWorkIndex.get(0); + split_time_index = halfWorkIndexs[1];//半天的时间 + } + } + if(flowinfo.length() > 0) { + Map jsonObject = JSON.parseObject(flowinfo); + for (Entry entry : jsonObject.entrySet()) { + String jsonKey = entry.getKey(); + String jsonValue = ""; + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } else if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.EVECTION.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } else if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.OUT.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + JSONArray jsonArray = JSONArray.parseArray(Util.null2String(entry.getValue())); + if (jsonArray != null && !jsonArray.isEmpty()) { + //客户不存在多个重复流程的情况,只是显示第一个就行 + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject1 = (JSONObject) jsonArray.getJSONObject(i); + if (jsonObject1 != null && !jsonObject1.isEmpty()) { + String newLeaveType = Util.null2s(Util.null2String(jsonObject1.get("newLeaveType")), ""); + String begintime = Util.null2s(Util.null2String(jsonObject1.get("begintime")), ""); + String endtime = Util.null2s(Util.null2String(jsonObject1.get("endtime")), ""); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + if (newLeaveType.length() > 0) { + jsonValue = kqLeaveRulesComInfo.getLeaveName(newLeaveType); + } + } + if (beginIdx <= split_time_index && endIdx <= split_time_index) { + //上午 + textAM = jsonValue; + } else if (beginIdx >= split_time_index && endIdx >= split_time_index) { + //下午 + textPM = jsonValue; + } else { + //全天 + textAM = jsonValue; + textPM = jsonValue; + } + } + } + } + } + } + if(!"".equals(signintime)) { + textAM+=signintime; + } + if(!"".equals(signouttime)) { + textPM+=signouttime; + } + if(!"".equals(overtime)) { + textPM+=overtime; + } + data.put("text", textAM+""+textPM); + data.put("textAM", textAM); + data.put("textPM", textPM); + datas.put(key, data); + continue; + } + String attendanceMins = rs.getString("attendanceMins"); +// String chuqin = "出勤:"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(attendanceMins) / 60.0)))+"小时"; + + + int beLateMins = rs.getInt("beLateMins"); + int leaveEarlyMins = rs.getInt("leaveEarlyMins"); + int graveBeLateMins = rs.getInt("graveBeLateMins"); + int absenteeismMins = rs.getInt("absenteeismMins"); + int graveLeaveEarlyMins = rs.getInt("graveLeaveEarlyMins"); + int forgotCheckMins = rs.getInt("forgotCheckMins"); + int forgotBeginWorkCheckMins = rs.getInt("forgotBeginWorkCheckMins"); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = rs.getString("leaveInfo"); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + + String workbeigintime = rs.getString("workbegintime"); + String workendtime = rs.getString("workendtime"); + + String halfPoint = shiftInfoBean.getHalfcalpoint(); //1440 + List halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + if (halfWorkIndex != null && !halfWorkIndex.isEmpty()) { + int[] halfWorkIndexs = halfWorkIndex.get(0); + split_time_index = halfWorkIndexs[1];//半天的时间 + } +// int halfPointIndex = split_time_index; //kqTimesArrayComInfo.getArrayindexByTimes(halfPoint); + + int on_absenteeismmins = Util.getIntValue(Util.null2String(rs.getString("on_absenteeismmins"))); + int off_absenteeismmins = Util.getIntValue(Util.null2String(rs.getString("off_absenteeismmins"))); + + String textAM = ""; + String textPM = ""; + if (workMins<=0) { + if("".equals(flowinfo)) { + textAM = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + textPM = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + } else { + Map jsonObject = JSON.parseObject(flowinfo); + for (Entry entry : jsonObject.entrySet()) { + String jsonKey = entry.getKey(); + String jsonValue = ""; + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } else if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.EVECTION.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } else if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.OUT.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + JSONArray jsonArray = JSONArray.parseArray(Util.null2String(entry.getValue())); + if (jsonArray != null && !jsonArray.isEmpty()) { + //客户不存在多个重复流程的情况,只是显示第一个就行 + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject1 = (JSONObject) jsonArray.getJSONObject(i); + if (jsonObject1 != null && !jsonObject1.isEmpty()) { + String newLeaveType = Util.null2s(Util.null2String(jsonObject1.get("newLeaveType")), ""); + String begintime = Util.null2s(Util.null2String(jsonObject1.get("begintime")), ""); + String endtime = Util.null2s(Util.null2String(jsonObject1.get("endtime")), ""); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + if (newLeaveType.length() > 0) { + jsonValue = kqLeaveRulesComInfo.getLeaveName(newLeaveType); + } + } + if (beginIdx <= split_time_index && endIdx <= split_time_index) { + //上午 + textAM = jsonValue; + } else if (beginIdx >= split_time_index && endIdx >= split_time_index) { + //下午 + textPM = jsonValue; + } else { + //全天 + textAM = jsonValue; + textPM = jsonValue; + } + } + } + } + } + } + }else{ + textAM = "√"; + textPM = "√"; + if(on_absenteeismmins > 0) { + textAM = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + if(beLateMins > 0) { + //迟到 + textAM = SystemEnv.getHtmlLabelName(20081, user.getLanguage()); + } + if(graveBeLateMins > 0) { + //严重迟到 + textAM = SystemEnv.getHtmlLabelName(500546, user.getLanguage()); + } + if(forgotBeginWorkCheckMins > 0) { + // 漏签 + textAM = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + if(off_absenteeismmins > 0) { + // 下午旷工 + textPM = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + if (leaveEarlyMins > 0) { + // 早退 + textPM = SystemEnv.getHtmlLabelName(20082, user.getLanguage()); + } + if (graveLeaveEarlyMins > 0) { + // 严重早退 + textPM = SystemEnv.getHtmlLabelName(500547, user.getLanguage()); + } + if(forgotCheckMins > 0) { + // 下午漏签 + textPM = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + + if(workMins > 0 && flowinfo.length() > 0){ + Map jsonObject = JSON.parseObject(flowinfo); + for (Entry entry : jsonObject.entrySet()) { + + String jsonKey = entry.getKey(); + String jsonValue = ""; + if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())){ + jsonValue = SystemEnv.getHtmlLabelName(670, user.getLanguage()); + }else if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.EVECTION.getFlowType())){ + jsonValue = SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + }else if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.OUT.getFlowType())){ + jsonValue = SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + JSONArray jsonArray = JSONArray.parseArray(Util.null2String(entry.getValue())); + if(jsonArray != null && !jsonArray.isEmpty()){ + //客户不存在多个重复流程的情况,只是显示第一个就行 + for(int i = 0 ; i < jsonArray.size() ; i++){ + JSONObject jsonObject1 = (JSONObject) jsonArray.getJSONObject(i); + if(jsonObject1 != null && !jsonObject1.isEmpty()) { + String newLeaveType = Util.null2s(Util.null2String(jsonObject1.get("newLeaveType")), ""); + String begintime = Util.null2s(Util.null2String(jsonObject1.get("begintime")), ""); + String endtime = Util.null2s(Util.null2String(jsonObject1.get("endtime")), ""); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + if (newLeaveType.length() > 0) { + jsonValue = kqLeaveRulesComInfo.getLeaveName(newLeaveType); + } + } + if (begintime.equals(workbeigintime) && endIdx == split_time_index) { + textAM = jsonValue; + } else if (begintime.equals(workbeigintime) && endtime.equals(workendtime)) { + textAM = jsonValue; + textPM = jsonValue; + } else if (endIdx == split_time_index && endtime.equals(workendtime)) { + textPM = jsonValue; + } else { + if (beginIdx <= split_time_index && endIdx <= split_time_index) { + //上午 + textAM = jsonValue + (("".equals(textAM) || "√".equals(textAM)) ? "" : ", " + textAM); + } else if (beginIdx >= split_time_index && endIdx >= split_time_index) { + //下午 + textPM = jsonValue + (("".equals(textPM) || "√".equals(textPM)) ? "" : ", " + textPM); + } else { + //全天 + textAM = jsonValue + (("".equals(textAM) || "√".equals(textAM)) ? "" : ", " + textAM); + textPM = jsonValue + (("".equals(textPM) || "√".equals(textPM)) ? "" : ", " + textPM); + } + } + } + } + } + } + } + String text = ""; + String tmptext =""; + String flag ="true"; + if(datas.get(key)==null){ + data = new HashMap<>(); + }else{ + data = (Map)datas.get(key); + tmptext = Util.null2String(data.get("text")); + } + tmpdata = new HashMap<>(); + if(tmpdatas.get(key)!=null){ + tmpmap = (Map)tmpdatas.get(key); + flag = Util.null2String(tmpmap.get("text")); + } + + String yichang =""; + if(tmpstatusdata.get(key)!=null){ + yichang = Util.null2String(tmpstatusdata.get(key)); + } + String sign =""; + String signkey = key+"|text"; + if(tmpstatusdata.get(signkey)!=null){ + sign = Util.null2String(tmpstatusdata.get(signkey)); + } + + if (isNonWork) { + if(text.length()>0) text +=" "; + if(sign.indexOf(SystemEnv.getHtmlLabelName(26593, user.getLanguage()))==-1){ + if(text.length()>0) { + text+= isWrap?"\r\n":"
"; + } + text += SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + } + //休息日处理 + if(signinid.length()>0){ + text += (isWrap?"\r\n":"
")+signintime; + } + if(signoutid.length()>0){ + text += signouttime; + } + sign += text; + } else { + //处理打卡数据================== + if(text.length()>0) text+= isWrap?"\r\n":"
"; + text += signintime; + text += signouttime; + if(sign.length()>0) sign+= isWrap?"\r\n":"
"; + sign += text; + //处理打卡数据================== + + if (absenteeismMins > 0) {//旷工 + if(text.length()>0) text+=" "; + text += SystemEnv.getHtmlLabelName(20085, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+absenteeismMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20085, user.getLanguage()))==-1){ + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + }else { + if (beLateMins > 0) {//迟到 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20081, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+beLateMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20081, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20081, user.getLanguage()); + } + } + if (graveBeLateMins > 0) {//严重迟到 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(500546, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+graveBeLateMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(500546, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(500546, user.getLanguage()); + } + } + if (leaveEarlyMins > 0) {//早退 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20082, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+leaveEarlyMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20082, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20082, user.getLanguage()); + } + } + if (graveLeaveEarlyMins > 0) {//严重早退 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(500547, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+graveLeaveEarlyMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(500547, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(500547, user.getLanguage()); + } + } + if (forgotCheckMins > 0) {//漏签 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20086, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + if (forgotBeginWorkCheckMins > 0) {//漏签 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20086, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + } + } +// if (leaveMins > 0) {//请假 +// Map jsonObject = null; +// if(leaveInfo.length()>0){ +// jsonObject = JSON.parseObject(leaveInfo); +// for (Entry entry : jsonObject.entrySet()) { +// String newLeaveType = entry.getKey(); +// String tmpLeaveMins = Util.null2String(entry.getValue()); +// if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){ +// if (text.length() > 0) text += " "; +// //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); +// text += Util.formatMultiLang( kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); +//// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+leaveMins) / 60.0)))+"小时"; +// if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; +// yichang += Util.formatMultiLang( kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); +// } +// } +// }else{ +// if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { +// if (text.length() > 0) text += " "; +// text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); +// } +// } +// } +// if (evectionMins > 0) {//出差 +// if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { +// if (text.length() > 0) text += " "; +// text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); +//// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+evectionMins) / 60.0)))+"小时"; +// if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; +// yichang += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); +// } +// } +// if (outMins > 0) {//公出 +// if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { +// if (text.length() > 0) text += " "; +// text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); +//// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+outMins) / 60.0)))+"小时"; +// if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; +// yichang += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); +// } +// } + + if(text.length()==0) { + text = "√"; + }else{ + flag = "false";//有其他的异常状态,则表示为false,不需要处理直接全部显示即可 + } + text += overtime; + + + //需要处理下打卡时间和异常状态显示的顺序--start + tmpstatusdata.put(key, yichang); + tmpstatusdata.put(signkey, sign); + boolean hasyichang = tmpstatusdata.get(key).length()>0; + if(tmptext.length()>0){ +// text = tmpstatusdata.get(signkey)+(isWrap?"\r\n":"
")+tmpstatusdata.get(key)+(isWrap?"\r\n":"
"+overtime); + text = tmpstatusdata.get(signkey); + if(hasyichang){ + if(text.length()>0){ + text += (isWrap?"\r\n":"
")+tmpstatusdata.get(key); + }else{ + text += tmpstatusdata.get(key); + } + } + if(hasovertime){ + text += (isWrap?"\r\n":"
")+overtime; + } + }else{ + text = tmpstatusdata.get(signkey); + if(hasyichang){ + if(text.length()>0){ + text += (isWrap?"\r\n":"
")+tmpstatusdata.get(key); + }else{ + text += tmpstatusdata.get(key); + } + } + if(hasovertime){ + text += (isWrap?"\r\n":"
")+overtime; + } + } + //需要处理下打卡时间和异常状态显示的顺序--end + tmpdatass.put(key, (isWrap?"\r\n":"
")+overtime); + if(!"".equals(signintime)) { + textAM+=signintime; + } + if(!"".equals(signouttime)) { + textPM+=signouttime; + } + if(!"".equals(overtime)) { + textPM+=overtime; + } + data.put("text", textAM+""+textPM); + data.put("textAM", textAM); + data.put("textPM", textPM); +// text = tmptext.length()>0?tmptext+" "+text:text;//显示所有的状态 +// data.put("text", text); + datas.put(key, data); + + //add + tmpdata.put("text", flag); + tmpdatas.put(key, tmpdata); + //end + } + //全部搞一遍 +// if(tmpdatas != null){ +//// writeLog(n+">>>tmpdatas="+JSONObject.toJSONString(tmpdatas)); +// Map data1 = null; +// for(Entry entry : tmpdatas.entrySet()){ +// String mapKey = Util.null2String(entry.getKey()); +// Map mapValue = (Map)entry.getValue(); +// String flag = Util.null2String(mapValue.get("text")); +// if("true".equals(flag)){//需要加工的数据 +// String overtime = String.valueOf(tmpdatass.get(mapKey)); +// data1 = new HashMap<>(); +// data1.put("text", "√"+overtime); +// datas.put(mapKey, data1); +// } +// } +//// writeLog("datas="+JSONObject.toJSONString(datas)); +// } + }catch (Exception e){ + writeLog(e); + } + // 最后针对数据再处理一遍,不然出现2023-01-02: "休息" 形式的错误,导致页面记载报错,应该是2023-01-01: {text: "休息"}格式 +// boolean isEnd = false; +// for(String currentDate = fromDate; !isEnd;) { +// if (currentDate.equals(toDate)) isEnd = true; +// String dailyValue = Util.null2String(datas.get(currentDate)); +// if(!"".equals(dailyValue) && !dailyValue.contains("text")) { +// Map innerMap2 = new HashMap<>(); +// innerMap2.put("text", dailyValue); +// datas.put(currentDate, innerMap2); +// } +// currentDate = DateUtil.addDate(currentDate, 1); +// } + return datas; + } + + public Map getDetialDatas(String resourceId,String fromDate, String toDate, User user, + Map flowData,boolean isWrap,int uintType,String show_card_source){ + boolean isKqReportHalfOpen = "1".equals(new KQSettingsComInfo().getMain_val("kq_report_half")); + if(isKqReportHalfOpen) { + return getDetialDatasHalfOpen(resourceId, fromDate, toDate, user, flowData, isWrap, uintType, show_card_source); + } + return getDetialDatasHalfNotOpen(resourceId, fromDate, toDate, user, flowData, isWrap, uintType, show_card_source); + } + +// public String getSignStatus(Map data, User user){ +// String result = ""; +// String signtype = Util.null2String(data.get("signtype"));//上班 下班 +// String worktime = Util.null2String(data.get("worktime"));//工作时间 +// String signtime = Util.null2String(data.get("signtime"));//签到时间 +// String abnormalMins = Util.null2String(data.get("abnormalMins"));//异常分钟数 +// String forgotCheck = Util.null2String(data.get("forgotCheck"));//漏签 +// if(worktime.length()>0){ +// if(signtime.length()>0){ +// if(Util.getDoubleValue(abnormalMins)>0){ +// result =SystemEnv.getHtmlLabelName(signtype.equals("1")?20081:20082, user.getLanguage())+abnormalMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage());//迟到 早退 +// }else{ +// result =SystemEnv.getHtmlLabelName(225, user.getLanguage());//正常 +// } +// }else if(forgotCheck.equals("1")){ +// result =SystemEnv.getHtmlLabelName(20086, user.getLanguage());//漏签 +// } +// }else{ +// result = ""; +// } +// +// return result; +// } + + public int getSerialCount(String resourceId, String fromDate, String toDate, String serialId){ + RecordSet rs = new RecordSet(); + String sql = ""; + int serialCount = 0; + try{ + sql = "select count(1) from hrmresource a, kq_format_total b where a.id= b.resourceid and b.resourceid = ? and b.kqdate >=? and b.kqdate <=? and b.serialId = ? "; + rs.executeQuery(sql,resourceId,fromDate,toDate, serialId); + if(rs.next()){ + serialCount = rs.getInt(1); + } + }catch (Exception e){ + writeLog(e); + } + return serialCount; + } + + public static String getSignStatus(Map signInfo, User user){ + return getSignStatus(signInfo,user,""); + } + + public static String getSignStatusHalfNotOpen(Map signInfo, User user,String onOrOff){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String text = ""; + String isneedcal = Util.null2String(signInfo.get("isneedcal")); + String workdate = Util.null2String(signInfo.get("workdate")); + String worktime = Util.null2String(signInfo.get("worktime")); + if(!new KQFormatBiz().needCal(workdate,worktime,isneedcal)) {//还未到时间无需计算 + return text; + } + int absenteeismMins = Util.getIntValue(Util.null2String(signInfo.get("absenteeismMins"))); + int beLateMins = Util.getIntValue(Util.null2String(signInfo.get("beLateMins"))); + int graveBeLateMins = Util.getIntValue(Util.null2String(signInfo.get("graveBeLateMins"))); + int leaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("leaveEarlyMins"))); + int graveLeaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("graveLeaveEarlyMins"))); + int forgotCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotCheckMins"))); + int forgotBeginWorkCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotBeginWorkCheckMins"))); + int leaveMins = Util.getIntValue(Util.null2String(signInfo.get("leaveMins"))); + String leaveInfo = Util.null2String(signInfo.get("leaveInfo")); + int evectionMins = Util.getIntValue(Util.null2String(signInfo.get("evectionMins"))); + int outMins = Util.getIntValue(Util.null2String(signInfo.get("outMins"))); + + if(worktime.length()>0){ + if (absenteeismMins > 0) {//旷工 + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage())+absenteeismMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + }else { + if (beLateMins > 0) {//迟到 + text = SystemEnv.getHtmlLabelName(20081, user.getLanguage())+beLateMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (graveBeLateMins > 0) {//严重迟到 + text = SystemEnv.getHtmlLabelName( 500546, user.getLanguage())+graveBeLateMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (leaveEarlyMins > 0) {//早退 + text = SystemEnv.getHtmlLabelName(20082, user.getLanguage())+leaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (graveLeaveEarlyMins > 0) {//严重早退 + text = SystemEnv.getHtmlLabelName(500547, user.getLanguage())+graveLeaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (forgotCheckMins > 0) {//漏签 + text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + if(onOrOff.length() > 0 && "on".equalsIgnoreCase(onOrOff)){ + if (forgotBeginWorkCheckMins > 0) {//漏签 + text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + } + + if (leaveMins > 0) {//请假 + Map jsonObject = null; + if(leaveInfo.length()>0){ + jsonObject = JSON.parseObject(leaveInfo); + for (Entry entry : jsonObject.entrySet()) { + String newLeaveType = entry.getKey(); + String tmpLeaveMins = Util.null2String(entry.getValue()); + if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){ + if (text.length() > 0) text += " "; + //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + text += Util.formatMultiLang(kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); + } + } + }else{ + if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } + } + } + if (evectionMins > 0) {//出差 + if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } + } + if (outMins > 0) {//公出 + if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + } + if(text.equals("")){ + boolean needCal = new KQFormatBiz().needCal(workdate,worktime,isneedcal); + text = needCal?SystemEnv.getHtmlLabelName(225, user.getLanguage()):""; + } + }else{ + if (leaveMins > 0) {//请假 + Map jsonObject = null; + if(leaveInfo.length()>0){ + jsonObject = JSON.parseObject(leaveInfo); + for (Entry entry : jsonObject.entrySet()) { + String newLeaveType = entry.getKey(); + String tmpLeaveMins = Util.null2String(entry.getValue()); + if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){ + if (text.length() > 0) text += " "; + //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + text += Util.formatMultiLang(kqLeaveRulesComInfo.getLeaveName(newLeaveType)); + } + } + }else{ + if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } + } + } + if (evectionMins > 0) {//出差 + if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } + } + if (outMins > 0) {//公出 + if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + } + } + return text; + } + + /** + * 应用设置开启了考勤汇总报表半天开关方法 + * @param signInfo + * @param user + * @param onOrOff + * @return + */ + public static String getSignStatusHalfOpen(Map signInfo, User user,String onOrOff){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + String split_time = Util.null2s(kqTimesArrayComInfo.getPropValue("qc1054152","split_time"),"13:00"); + int split_time_index = kqTimesArrayComInfo.getArrayindexByTimes(split_time); + String text = ""; + String isneedcal = Util.null2String(signInfo.get("isneedcal")); + String workdate = Util.null2String(signInfo.get("workdate")); + String worktime = Util.null2String(signInfo.get("worktime")); + String flowinfo = Util.null2String(signInfo.get("flowinfo")); + boolean isNonWork = Util.str2bool(Util.null2String(signInfo.get("isNonWork"))); + if(!new KQFormatBiz().needCal(workdate,worktime,isneedcal)) {//还未到时间无需计算 + return text; + } + String resourceId = Util.null2String(signInfo.get("resourceId")); + String kqDate = Util.null2String(signInfo.get("kqdate")); + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceId, kqDate, false); + if(shiftInfoBean == null || isNonWork) { + text = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + if(shiftInfoBean != null) { + List halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + if (halfWorkIndex != null && !halfWorkIndex.isEmpty()) { + int[] halfWorkIndexs = halfWorkIndex.get(0); + split_time_index = halfWorkIndexs[1];//半天的时间 + } + } + if(flowinfo.length() > 0) { + Map jsonObject = JSON.parseObject(flowinfo); + for (Entry entry : jsonObject.entrySet()) { + String jsonKey = entry.getKey(); + String jsonValue = ""; + if (jsonObject.containsKey(FlowReportTypeEnum.LEAVE.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } else if (jsonObject.containsKey(FlowReportTypeEnum.EVECTION.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } else if (jsonObject.containsKey(FlowReportTypeEnum.OUT.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + if (jsonKey.length() > 0) { + JSONArray jsonArray = JSONArray.parseArray(Util.null2String(entry.getValue())); + if (jsonArray != null && !jsonArray.isEmpty()) { + //客户不存在多个重复流程的情况,只是显示第一个就行 + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject1 = (JSONObject) jsonArray.getJSONObject(i); + if (jsonObject1 != null && !jsonObject1.isEmpty()) { + String newLeaveType = Util.null2s(Util.null2String(jsonObject1.get("newLeaveType")), ""); + String begintime = Util.null2s(Util.null2String(jsonObject1.get("begintime")), ""); + String endtime = Util.null2s(Util.null2String(jsonObject1.get("endtime")), ""); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + if (newLeaveType.length() > 0) { + jsonValue = kqLeaveRulesComInfo.getLeaveName(newLeaveType); + } + } + if (beginIdx <= split_time_index && endIdx <= split_time_index) { + //上午 + if ("on".equalsIgnoreCase(onOrOff)) { + text = jsonValue; + } + } else if (beginIdx >= split_time_index && endIdx >= split_time_index) { + //下午 + if ("off".equalsIgnoreCase(onOrOff)) { + text = jsonValue; + } + } else { + //全天 + text = jsonValue; + } + } + } + } + } + } + } + return text; + } + List halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + if(halfWorkIndex != null && !halfWorkIndex.isEmpty()) { + int[] halfWorkIndexs = halfWorkIndex.get(0); + split_time_index = halfWorkIndexs[1];//半天的时间 + } + int absenteeismMins = Util.getIntValue(Util.null2String(signInfo.get("absenteeismMins"))); + int beLateMins = Util.getIntValue(Util.null2String(signInfo.get("beLateMins"))); + int graveBeLateMins = Util.getIntValue(Util.null2String(signInfo.get("graveBeLateMins"))); + int leaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("leaveEarlyMins"))); + int graveLeaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("graveLeaveEarlyMins"))); + int forgotCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotCheckMins"))); + int forgotBeginWorkCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotBeginWorkCheckMins"))); + int leaveMins = Util.getIntValue(Util.null2String(signInfo.get("leaveMins"))); + String leaveInfo = Util.null2String(signInfo.get("leaveInfo")); + int evectionMins = Util.getIntValue(Util.null2String(signInfo.get("evectionMins"))); + int outMins = Util.getIntValue(Util.null2String(signInfo.get("outMins"))); + + int on_absenteeismmins = Util.getIntValue(Util.null2String(signInfo.get("on_absenteeismmins"))); + int off_absenteeismmins = Util.getIntValue(Util.null2String(signInfo.get("off_absenteeismmins"))); + + String workbeigintime = Util.null2String(signInfo.get("workbegintime")); + String workendtime = Util.null2String(signInfo.get("workendtime")); + String halfPoint = shiftInfoBean.getHalfcalpoint(); + int halfPointIndex = kqTimesArrayComInfo.getArrayindexByTimes(halfPoint); + + if(worktime.length()>0){ +// if (on_absenteeismmins > 0) {//上午旷工 +// text = SystemEnv.getHtmlLabelName(20085, user.getLanguage())+absenteeismMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); +// }else { +// if (beLateMins > 0) {//迟到 +// text = SystemEnv.getHtmlLabelName(20081, user.getLanguage())+beLateMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); +// } +// if (graveBeLateMins > 0) {//严重迟到 +// text = SystemEnv.getHtmlLabelName( 500546, user.getLanguage())+graveBeLateMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); +// } +// if (leaveEarlyMins > 0) {//早退 +// text = SystemEnv.getHtmlLabelName(20082, user.getLanguage())+leaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); +// } +// if (graveLeaveEarlyMins > 0) {//严重早退 +// text = SystemEnv.getHtmlLabelName(500547, user.getLanguage())+graveLeaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); +// } +// if (forgotCheckMins > 0) {//漏签 +// text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); +// } +// if(onOrOff.length() > 0 && "on".equalsIgnoreCase(onOrOff)){ +// if (forgotBeginWorkCheckMins > 0) {//漏签 +// text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); +// } +// } +// } + + if("on".equalsIgnoreCase(onOrOff)) { + if (on_absenteeismmins > 0) { + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + if (beLateMins > 0) {//迟到 + if (text.length() > 0) { + text += " "; + } + text += SystemEnv.getHtmlLabelName(20081, user.getLanguage()) + beLateMins + SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (graveBeLateMins > 0) {//严重迟到 + if (text.length() > 0) { + text += " "; + } + text += SystemEnv.getHtmlLabelName(500546, user.getLanguage()) + graveBeLateMins + SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (forgotBeginWorkCheckMins > 0) {//漏签 + if (text.length() > 0) { + text += " "; + } + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + if("off".equalsIgnoreCase(onOrOff)){ + if(off_absenteeismmins > 0) { + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + if (leaveEarlyMins > 0) {//早退 + if (text.length() > 0) { + text += " "; + } + text += SystemEnv.getHtmlLabelName(20082, user.getLanguage())+leaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (graveLeaveEarlyMins > 0) {//严重早退 + if (text.length() > 0) { + text += " "; + } + text += SystemEnv.getHtmlLabelName(500547, user.getLanguage())+graveLeaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (forgotCheckMins > 0) {//漏签 + if (text.length() > 0) { + text += " "; + } + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + + if(flowinfo.length() > 0){ + Map jsonObject = JSON.parseObject(flowinfo); + for (Entry entry : jsonObject.entrySet()) { + String jsonKey = entry.getKey(); + String jsonValue = ""; + if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())){ + jsonValue = SystemEnv.getHtmlLabelName(670, user.getLanguage()); + }else if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.EVECTION.getFlowType())){ + jsonValue = SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + }else if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.OUT.getFlowType())){ + jsonValue = SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + if(jsonKey.length() > 0){ + JSONArray jsonArray = JSONArray.parseArray(Util.null2String(entry.getValue())); + if(jsonArray != null && !jsonArray.isEmpty()){ + //客户不存在多个重复流程的情况,只是显示第一个就行 + for(int i = 0 ; i < jsonArray.size() ; i++){ + JSONObject jsonObject1 = (JSONObject) jsonArray.getJSONObject(i); + if(jsonObject1 != null && !jsonObject1.isEmpty()){ + String newLeaveType = Util.null2s(Util.null2String(jsonObject1.get("newLeaveType")),""); + String begintime = Util.null2s(Util.null2String(jsonObject1.get("begintime")),""); + String endtime = Util.null2s(Util.null2String(jsonObject1.get("endtime")),""); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + + if(jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())){ + if(newLeaveType.length() > 0){ + jsonValue = kqLeaveRulesComInfo.getLeaveName(newLeaveType); + } + } + if(beginIdx <= split_time_index && endIdx <= split_time_index){ + //上午 + if("on".equalsIgnoreCase(onOrOff)){ + if(begintime.equals(workbeigintime) && endIdx == halfPointIndex) { + text = ""; + } else if(begintime.equals(workbeigintime) && endtime.equals(workendtime)) { + text = ""; + } + text = jsonValue+("".equals(text) ? "":", "+text); + } + }else if(beginIdx >= split_time_index && endIdx >= split_time_index){ + //下午 + if("off".equalsIgnoreCase(onOrOff)){ + if(endIdx == halfPointIndex && endtime.equals(workendtime)) { + text = ""; + } else if(begintime.equals(workbeigintime) && endtime.equals(workendtime)) { + text = ""; + } + text = jsonValue+("".equals(text) ? "":", "+text); + } + }else { + //全天 + if(begintime.equals(workbeigintime) && endtime.equals(workendtime)) { + text = ""; + } + text = jsonValue+("".equals(text) ? "":", "+text); + } + } + if(text.length() > 0){ + break; + } + } + } + } + } + } + + if(text.equals("")){ + boolean needCal = new KQFormatBiz().needCal(workdate,worktime); + text = needCal? SystemEnv.getHtmlLabelName(225, user.getLanguage()):""; + } + }else{ + text = SystemEnv.getHtmlLabelName(225, user.getLanguage()); + if("on".equalsIgnoreCase(onOrOff)){ + if(on_absenteeismmins > 0) { + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + } + if("off".equalsIgnoreCase(onOrOff)){ + if(off_absenteeismmins > 0) { + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + } + if(flowinfo.length() > 0) { + Map jsonObject = JSON.parseObject(flowinfo); + for (Entry entry : jsonObject.entrySet()) { + String jsonKey = entry.getKey(); + String jsonValue = ""; + if (jsonObject.containsKey(FlowReportTypeEnum.LEAVE.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } else if (jsonObject.containsKey(FlowReportTypeEnum.EVECTION.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } else if (jsonObject.containsKey(FlowReportTypeEnum.OUT.getFlowType())) { + jsonValue = SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + if (jsonKey.length() > 0) { + JSONArray jsonArray = JSONArray.parseArray(Util.null2String(entry.getValue())); + if (jsonArray != null && !jsonArray.isEmpty()) { + //客户不存在多个重复流程的情况,只是显示第一个就行 + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject1 = (JSONObject) jsonArray.getJSONObject(i); + if (jsonObject1 != null && !jsonObject1.isEmpty()) { + String newLeaveType = Util.null2s(Util.null2String(jsonObject1.get("newLeaveType")), ""); + String begintime = Util.null2s(Util.null2String(jsonObject1.get("begintime")), ""); + String endtime = Util.null2s(Util.null2String(jsonObject1.get("endtime")), ""); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + if (newLeaveType.length() > 0) { + jsonValue = kqLeaveRulesComInfo.getLeaveName(newLeaveType); + } + } + if (beginIdx <= split_time_index && endIdx <= split_time_index) { + //上午 + if ("on".equalsIgnoreCase(onOrOff)) { + text = jsonValue; + } + } else if (beginIdx >= split_time_index && endIdx >= split_time_index) { + //下午 + if ("off".equalsIgnoreCase(onOrOff)) { + text = jsonValue; + } + } else { + //全天 + text = jsonValue; + } + } + } + } + } + } + } + if(text.length() == 0){ + text = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + } + } + return text; + } + + public static String getSignStatus(Map signInfo, User user,String onOrOff){ + boolean isKqReportHalfOpen = "1".equals(new KQSettingsComInfo().getMain_val("kq_report_half")); + if(isKqReportHalfOpen) { + return getSignStatusHalfOpen(signInfo, user, onOrOff); + } + return getSignStatusHalfNotOpen(signInfo, user, onOrOff); + } + + /** + * 获取打卡状态(不包含具体分钟数) + * @param signInfo + * @param user + * @param onOrOff + * @return + */ + public static String getSignStatus2(Map signInfo, User user, String onOrOff) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String text = ""; + String worktime = Util.null2String(signInfo.get("worktime")); + int absenteeismMins = Util.getIntValue(Util.null2String(signInfo.get("absenteeismMins"))); + int beLateMins = Util.getIntValue(Util.null2String(signInfo.get("beLateMins"))); + int graveBeLateMins = Util.getIntValue(Util.null2String(signInfo.get("graveBeLateMins"))); + int leaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("leaveEarlyMins"))); + int graveLeaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("graveLeaveEarlyMins"))); + int forgotCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotCheckMins"))); + int forgotBeginWorkCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotBeginWorkCheckMins"))); + int leaveMins = Util.getIntValue(Util.null2String(signInfo.get("leaveMins"))); + String leaveInfo = Util.null2String(signInfo.get("leaveInfo")); + int evectionMins = Util.getIntValue(Util.null2String(signInfo.get("evectionMins"))); + int outMins = Util.getIntValue(Util.null2String(signInfo.get("outMins"))); + Boolean isNonWork = (Boolean) signInfo.get("isNonWork"); + + if (!isNonWork) { + if (absenteeismMins > 0) {//旷工 + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } else { + if (beLateMins > 0) {//迟到 + text = SystemEnv.getHtmlLabelName(20081, user.getLanguage()); + } + if (graveBeLateMins > 0) {//严重迟到 + text = SystemEnv.getHtmlLabelName(500546, user.getLanguage()); + } + if (leaveEarlyMins > 0) {//早退 + text = SystemEnv.getHtmlLabelName(20082, user.getLanguage()); + } + if (graveLeaveEarlyMins > 0) {//严重早退 + text = SystemEnv.getHtmlLabelName(500547, user.getLanguage()); + } + if (forgotCheckMins > 0) {//漏签 + text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + if (onOrOff.length() > 0 && "on".equalsIgnoreCase(onOrOff)) { + if (forgotBeginWorkCheckMins > 0) {//漏签 + text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + } + if (text.equals("") && leaveMins <= 0 && evectionMins <= 0 && outMins <= 0) { + text = SystemEnv.getHtmlLabelName(225, user.getLanguage()); + } + } + return text; + } + + public static boolean getShowFlowText(String leaveInfo,String onOrOff){ + Map jsonObject = null; + jsonObject = JSON.parseObject(leaveInfo); + String flow_signtype = ""; + for (Entry entry : jsonObject.entrySet()) { + String tmpSignType = Util.null2String(entry.getValue()); + flow_signtype += ","+tmpSignType; + } + if(flow_signtype.length() == 0){ + return true; + } + return isShowFlowText(flow_signtype,onOrOff); + } + + public static boolean isShowFlowText(String flow_signtype,String onOrOff){ + boolean showFlowText = true; + + if(flow_signtype.length() > 0){ + flow_signtype = flow_signtype.substring(1); + if("on".equalsIgnoreCase(onOrOff)){ + if((","+flow_signtype+",").indexOf(",1,") > -1){ + //抵扣了上班卡 + }else{ + //上班状态,但是没有上班抵扣流程 + showFlowText = false; + } + } + if("off".equalsIgnoreCase(onOrOff)){ + if((","+flow_signtype+",").indexOf(",2,") > -1){ + //抵扣了下班卡 + }else{ + //下班状态,但是没有下班抵扣流程 + showFlowText = false; + } + } + } + return showFlowText; + } + + public static int getPageSize(String pageSize, String pageUid, int userid){ + String sql = ""; + RecordSet rs = new RecordSet(); + int iPageSize= Util.getIntValue(pageSize,10); + if(iPageSize<10)iPageSize=10; + try{ + if(pageSize.length()>0){ + boolean flag = false; + sql = "select count(1) from ecology_pagesize where pageid = '"+pageUid+"' and userid ="+userid; + rs.executeQuery(sql); + if(rs.next()){ + if(rs.getInt(1)>0){ + flag = true; + } + } + if(flag){ + sql = "update ecology_pagesize set pagesize ="+pageSize+" where pageid = '"+pageUid+"' and userid ="+userid; + rs.executeUpdate(sql); + }else{ + sql = "insert into ecology_pagesize (pageid,pagesize,userid) values ('"+pageUid+"',"+pageSize+","+userid+")"; + rs.executeUpdate(sql); + } + }else{ + sql = "select pageSize from ecology_pagesize where pageid = '"+pageUid+"' and userid ="+userid; + rs.executeQuery(sql); + if(rs.next()){ + iPageSize = rs.getInt("pageSize"); + } + } + }catch (Exception e){ + new BaseBean().writeLog("KQReportBiz.getPageSize"+e); + } + + return iPageSize; + } + + //经常遇到申请变更流程或销假流程提示未归档,不胜其烦,所以搞一下 + public void reflow(String requestid){ + try { + requestid = Util.null2String(requestid); + String workflowid = ""; + String currentnodetype = ""; + if(requestid.length() == 0){ + return; + } + RecordSet rs2 = new RecordSet(); + String sql = "select requestid,workflowid,currentnodetype from workflow_requestbase where requestid = '"+requestid+"'"; + rs2.executeQuery(sql); + if(rs2.next()){ + workflowid = Util.null2String(rs2.getString("workflowid")); + currentnodetype = Util.null2String(rs2.getString("currentnodetype")); + } + + boolean isForce1 = false; + boolean isUpgrade1 = false; + if(requestid.length() == 0){ + return ; + } + if(workflowid.length() == 0){ + return ; + } + if(!"3".equals(currentnodetype)){ + return ; + } + long start = System.currentTimeMillis(); + + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? "; + rs.executeQuery(proc_set_sql, workflowid); + if(rs.next()){ + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + + int kqtype = Util.getIntValue(rs.getString("field006")); + + Map map = new HashMap(); + if(Util.getIntValue(requestid) > 0){ + map.put("requestId", "and t.requestId = " + requestid); + } + String tablename = ""; + if(kqtype == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.LEAVE.getTablename(); + }else if(kqtype == KqSplitFlowTypeEnum.EVECTION.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.EVECTION.getTablename(); + }else if(kqtype == KqSplitFlowTypeEnum.OUT.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.OUT.getTablename();; + }else if(kqtype == KqSplitFlowTypeEnum.OVERTIME.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.OVERTIME.getTablename(); + return; + }else if(kqtype == KqSplitFlowTypeEnum.SHIFT.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.SHIFT.getTablename();; + }else if(kqtype == KqSplitFlowTypeEnum.OTHER.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.OTHER.getTablename();; + }else if(kqtype == KqSplitFlowTypeEnum.CARD.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.CARD.getTablename();; + return; + }else if(kqtype == KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.LEAVEBACK.getTablename();; + }else{ + return; + } + if(null != tablename && tablename.length() > 0){ + String tmpsql = "select * from "+tablename+" where requestId="+requestid; + rs1.executeQuery(tmpsql); + if(rs1.next()){ + return;//表示已经产生了拆分数据 + } + } + + //先根据requestid删除中间表里的数据,再做啥插入操作 + if(kqtype == KqSplitFlowTypeEnum.OVERTIME.getFlowtype()) { + return;//加班就不搞了,有遇到用户销假选择错误流程,选择了加班流程导致这里reflow一次,多余生成了调休 + }else{ + String delSql = "delete from "+tablename+" where requestid = "+requestid; + rs1.executeUpdate(delSql); + Map result = kqFlowActiontBiz.handleKQFlowAction(proc_set_id, usedetails, Util.getIntValue(requestid), kqtype, Util.getIntValue(workflowid), isForce1,isUpgrade1,map); + } + + } + long end = System.currentTimeMillis(); + }catch (Exception e){ + e.printStackTrace(); + } + } + + public static String splitParamStr(String params) { + StringBuilder inClauseValues = new StringBuilder(); + String[] paramStr = params.split(","); + if(params.contains(",")) { + for (int i = 0; i < paramStr.length; i++) { + inClauseValues.append("?"); + if (i < paramStr.length - 1) { + inClauseValues.append(","); + } + } + } else { + inClauseValues.append("?"); + } + return inClauseValues.toString(); + } + + + //add + public Map getOverTime(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id 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<>'' "); + } + + int uintType = Util.getIntValue(Util.null2String(params.get("uintType")));//当前加班单位 + double hoursToDay = Util.getDoubleValue(Util.null2String(params.get("hoursToDay")));//当前天跟小时计算关系 + + String valueField = ""; + + sql = " select resourceid,belongdate,paidLeaveEnable,duration_min "+ + " from hrmresource a, kq_flow_overtime b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " order by resourceid,belongdate "; + rs.execute(sql); +// kqLog.info("getOverTime:sql:"+sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String paidLeaveEnable = rs.getString("paidLeaveEnable"); +// int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日 + double value = rs.getDouble("duration_min")<0?0:rs.getDouble("duration_min"); + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0)+"")); + }else{//按天计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0*hoursToDay)+"")); + } + String key = resourceid+"|"+belongdate+"|overtime"; + if(value>0){ + df.setMaximumFractionDigits(5); + if(datas.containsKey(key)){ + double tmpVal = Util.getDoubleValue(Util.null2String(datas.get(key)),0.0); + tmpVal += value; + datas.put(key,format(tmpVal)); + }else{ + datas.put(key,format(value)); + } + +// if(datas.containsKey(key)){ +// datas.put(key,"加班"); +//// datas.put(key,SystemEnv.getHtmlLabelName(6151, user.getLanguage())); +// }else{ +// datas.put(key,"加班"); +// } + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } +} diff --git a/src/com/engine/kq/biz/KQReportFieldComInfo.java b/src/com/engine/kq/biz/KQReportFieldComInfo.java new file mode 100644 index 0000000..a637ec7 --- /dev/null +++ b/src/com/engine/kq/biz/KQReportFieldComInfo.java @@ -0,0 +1,239 @@ +package com.engine.kq.biz; + +import weaver.cache.*; +import weaver.conn.RecordSet; +import weaver.general.Util; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 报表自定义字段 + */ +public class KQReportFieldComInfo extends CacheBase{ + protected static String TABLE_NAME = "kq_report_field"; + /** sql中的where信息,不要以where开始 */ + protected static String TABLE_WHERE = null; + /** sql中的order by信息,不要以order by开始 */ + protected static String TABLE_ORDER = "showorder"; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + @CacheColumn(name = "fieldname") + protected static int fieldname; + + @CacheColumn(name = "fieldlabel") + protected static int fieldlabel; + + @CacheColumn(name = "unittype") + protected static int unittype; + + @CacheColumn(name = "width") + protected static int width; + + @CacheColumn(name = "parentid") + protected static int parentid; + + @CacheColumn(name = "isdefinedcolumn") + protected static int isdefinedcolumn; + + @CacheColumn(name = "defaultshow") + protected static int defaultshow; + + @CacheColumn(name = "isleavetype") + protected static int isleavetype; + + @CacheColumn(name = "reporttype") + protected static int reporttype; + + @CacheColumn(name = "reporttype1") + protected static int reporttype1; + + @CacheColumn(name = "isdataColumn") + protected static int isdataColumn; + + @CacheColumn(name = "showDetial") + protected static int showDetial; + + @CacheColumn(name = "groupid") + protected static int groupid; + + @CacheColumn(name = "isenable") + protected static int isenable; + + // #1276494 概述:满足薪酬指标项关联考勤报表列数据需求 By T.W + @CacheColumn(name = "if_salary_need") + protected static int ifSalaryNeed; + + @CacheColumn(name = "formula") + protected static int formula; + + @CacheColumn(name = "issystem") + protected static int issystem; + + @CacheColumn(name = "cascadekey") + protected static int cascadekey; + + @CacheColumn(name = "dailyShowOrder") + protected static int dailyShowOrder; + + public static ConcurrentHashMap cascadekey2fieldname = new ConcurrentHashMap(); + public static ConcurrentHashMap field2Id = new ConcurrentHashMap(); + + @Override + protected CacheMap initCache() throws Exception { + CacheMap localData = createCacheMap(); + RecordSet rs = new RecordSet(); + cascadekey2fieldname.clear(); + field2Id.clear(); +// String sql = " select a.id,fieldname,fieldlabel,width,unittype,parentid,isdefinedcolumn,defaultshow,isleavetype," + +// " reporttype,isdatacolumn,showdetial,a.showorder,groupid,isenable,formula,issystem,cascadekey " + +// " from kq_report_field a left join kq_report_field_group b on a.groupid = b.id " + +// " order by b.showorder asc, a.showorder asc "; + + // #1276494 概述:满足薪酬指标项关联考勤报表列数据需求 By T.W + String sql = " SELECT id, fieldname,fieldlabel, unittype,width,parentid,isdefinedcolumn,defaultshow,isleavetype,'month' as reporttype, reporttype as reporttype1,isdataColumn," + + " showDetial,groupid,isenable,if_salary_need,formula,issystem,cascadekey,dailyShowOrder FROM kq_report_field where fieldname= 'lastname' "; + rs.executeQuery(sql); + while (rs.next()) { + if(Util.null2String(rs.getString("cascadekey")).length()>0){ + String[] arrCascadekey = Util.splitString(rs.getString("cascadekey"),","); + for(int i=0;i0){ + String[] arrCascadekey = Util.splitString(rs.getString("cascadekey"),","); + for(int i=0;i 0) needImport = false; + } + if (needImport) { + sql = " insert into HrmScheduleSign (userid, usertype, signtype, signdate, signtime, clientaddress, isincom, isimport, signfrom, longitude, latitude, addr) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?)"; + List params = new ArrayList<>(); + params.add(this.userid); + params.add(this.usertype); + params.add(this.signtype); + params.add(this.signdate); + params.add(this.signtime); + params.add(Util.null2String(this.clientaddress)); + params.add(this.isincom); + params.add(this.isimport); + params.add(Util.null2String(this.signfrom)); + params.add(Util.null2String(this.longitude)); + params.add(Util.null2String(this.latitude)); + params.add(Util.null2String(this.addr)); + rs.executeUpdate(sql,params); + } + } + + public static void delete(String date_from, String date_to) throws Exception { + String sql = ""; + RecordSet rs = new RecordSet(); + sql = " delete HrmScheduleSign where isimport=1 and signdate >='" + date_from + "' and signdate < '" + date_to + "'"; + rs.execute(sql); + } + + public static void delete(String date_from, String date_to, int userId) throws Exception { + String sql = ""; + RecordSet rs = new RecordSet(); + sql = " delete HrmScheduleSign where isimport=1 and signdate >='" + date_from + "' and signdate <= '" + date_to + "' and userId=" + userId; + rs.execute(sql); + } + + public void deleteByUser() throws Exception { + String sql = ""; + RecordSet rs = new RecordSet(); + sql = " delete HrmScheduleSign where signdate ='" + signdate + "' and signtype = '" + signtype + "' and userId=" + userid; + rs.execute(sql); + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getUserid() { + return userid; + } + + public void setUserid(int userid) { + this.userid = userid; + } + + public int getUsertype() { + return usertype; + } + + public void setUsertype(int usertype) { + this.usertype = usertype; + } + + public int getSigntype() { + return signtype; + } + + public void setSigntype(int signtype) { + this.signtype = signtype; + } + + public String getSigndate() { + return signdate; + } + + public void setSigndate(String signdate) { + this.signdate = signdate; + } + + public String getSigntime() { + return signtime; + } + + public void setSigntime(String signtime) { + this.signtime = signtime; + } + + public String getClientaddress() { + return clientaddress; + } + + public void setClientaddress(String clientaddress) { + this.clientaddress = clientaddress; + } + + public int getIsincom() { + return isincom; + } + + public void setIsincom(int isincom) { + this.isincom = isincom; + } + + public String getSignfrom() { + return signfrom; + } + + public void setSignfrom(String signfrom) { + this.signfrom = signfrom; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getAddr() { + return addr; + } + + public void setAddr(String addr) { + this.addr = addr; + } + + public int getIsimport() { + return isimport; + } + + public void setIsimport(int isimport) { + this.isimport = isimport; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getSuuid() { + return suuid; + } + + public void setSuuid(String suuid) { + this.suuid = suuid; + } + + public String getImportsql() { + return importsql; + } + + public void setImportsql(String importsql) { + this.importsql = importsql; + } +} diff --git a/src/com/engine/kq/biz/KQScheduleSignBiz.java b/src/com/engine/kq/biz/KQScheduleSignBiz.java new file mode 100644 index 0000000..f267849 --- /dev/null +++ b/src/com/engine/kq/biz/KQScheduleSignBiz.java @@ -0,0 +1,602 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.bean.KQHrmScheduleSign; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.util.KQSignUtil; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; + +/** + * 签到签退数据处理类 + */ +public class KQScheduleSignBiz { + + private KQLog kqLog = new KQLog(); + private DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + private String resourceid; + private int signoutOnlyOff; + private String offDateTime; + private String userType; + private String signDate; + private String signTime; + private String worksection; + /** + * 考勤数据所属日期 因为班次可能跨天 + */ + private String belongdate; + private String signtype; + private String signDateTimeSql; + /** + * 上班开始打卡时间 + */ + private String signSectionTime; + + /** + * 上班结束打卡时间 + */ + private String signSectionEndTime; + /** + * 下班开始打卡时间 + */ + private String signSectionBeginTime; + + /** + * 下班结束打卡时间 + */ + private String offSignSectionTime; + + private int shiftCount; + + private int shiftI; + + private String count4NoonStartDateTime; + + private String count4NoonEndDateTime; + + private KQScheduleSignBiz(KQScheduleSignParamBuilder build){ + this.resourceid = build.resourceid; + this.signoutOnlyOff = build.signoutOnlyOff; + this.offDateTime = build.offDateTime; + this.userType = build.userType; + this.signDate = build.signDate; + this.signTime = build.signTime; + this.belongdate = build.belongdate; + this.signtype = build.signtype; + this.worksection = build.worksection; + this.signDateTimeSql = build.signDateTimeSql; + this.signSectionTime = build.signSectionTime; + this.signSectionEndTime = build.signSectionEndTime; + this.signSectionBeginTime = build.signSectionBeginTime; + this.offSignSectionTime = build.offSignSectionTime; + this.shiftCount = build.shiftCount; + this.shiftI = build.shiftI; + this.count4NoonStartDateTime = build.count4NoonStartDateTime; + this.count4NoonEndDateTime = build.count4NoonEndDateTime; + } + + /** + * 自由班制的签到签退数据 + * @return + */ + public List getFreeScheduleSignInfo() { + + RecordSet rs = new RecordSet(); + String signSql = "select * from hrmschedulesign where 1=1 and isInCom='1' "; + String sqlWhere = sqlParamWhere(); + if(sqlWhere.length() > 0){ + signSql += sqlWhere; + } + signSql += " order by signdate,signtime"; + kqLog.info("fc--获取打卡数据--signSql=" + signSql); + List kqHrmScheduleSigns = new ArrayList<>(); + + try{ + rs.execute(signSql); + while (rs.next()){ + KQHrmScheduleSign kqHrmScheduleSign = getSignBean(rs); + + kqHrmScheduleSigns.add(kqHrmScheduleSign); + } + }catch (Exception e){ + e.printStackTrace(); + } + return kqHrmScheduleSigns; + } + /** + * 非自由班制的考勤数据 + * 针对设置了打卡开始范围,结束范围的数据,即可以出现,只签退没有签到的数据的处理 + * @return + */ + public Map getScheduleSignInfoWithCardRange(){ + + String signSql = ""; + Map signMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String dbtype = rs.getDBType(); + String baseSql = "select * from hrmschedulesign where 1=1 and isInCom='1' "; + String sqlWhere = sqlParamWhere(); + if(sqlWhere.length() > 0){ + baseSql += sqlWhere; + } + if(signSectionEndTime.length() == 0 && signSectionBeginTime.length() == 0){ + //如果没设置上班后,下班前打卡 + String signTimeSql = KQSignUtil.buildSignSql(signSectionTime,offSignSectionTime); + if(signTimeSql.length() > 0){ + baseSql += " and "+signTimeSql; + } + if(baseSql.length() > 0){ + signSql = baseSql; + signSql += " order by signdate,signtime"; + kqLog.info("signSql:"+signSql); +// rs.writeLog("signSql:"+signSql); + try{ + rs.execute(signSql); + while (rs.next()){ + getScheduleSignBean(rs,signMap); + } + if(1 == signoutOnlyOff){ + if(signMap != null && !signMap.isEmpty()) { + LocalDateTime offdatetime1 = LocalDateTime.parse(offDateTime,fullFormatter);//下班时间 +// rs.writeLog("offDateTime:"+offDateTime+":signMap1:"+ JSON.toJSON(signMap)); + //【上班打卡】处理 + KQHrmScheduleSign signInTimeBean = signMap.get("signin"); + KQHrmScheduleSign signOutTimeBean = signMap.get("signout"); + String signdatetime = signInTimeBean.getSigndate()+" "+signInTimeBean.getSigntime();//上班卡日期时间 + LocalDateTime signdatetime_tmp = LocalDateTime.parse(signdatetime,fullFormatter); + //打卡时间 >= 下班时间 + rs.writeLog("offDateTime:"+offDateTime+":signdatetime:"+ signdatetime); + if(signdatetime_tmp.isAfter(offdatetime1)||(signdatetime_tmp.isEqual(offdatetime1))){ + signMap = new HashMap<>(); + if(signOutTimeBean != null){//表示有下班打卡,也就是打卡是大于等于2次,就把原来的下班打卡加进去 + signMap.put("signout",signOutTimeBean); + }else{//没有下班打卡 + signMap.put("signout",signInTimeBean); + } + } +// rs.writeLog("offDateTime:"+offDateTime+":signMap2:"+ JSON.toJSON(signMap)); + } + } + }catch (Exception e){ + e.printStackTrace(); + } + } + }else { + if(shiftCount == 4 && shiftI==2) { + String signSectionEndTime2 = count4NoonStartDateTime.substring(0, count4NoonStartDateTime.length() - 2) + "00"; + String noonSignTimeSql = KQSignUtil.buildSignSql(signSectionEndTime2, count4NoonEndDateTime); + String sql = baseSql; + if (sqlWhere.length() > 0) { + sql += sqlWhere + " and " + noonSignTimeSql + " order by signdate, signtime"; + } + rs.executeQuery(sql); + int count = 0; + while (rs.next()) { + if(count == 0) { + count ++; + continue; + } + // 午休时段如果有打卡的话,取第二次打卡算作下午第一次签到 + KQHrmScheduleSign kqHrmScheduleSign = getSignBean(rs); + signMap.put("signin", kqHrmScheduleSign); + signMap.put("signinNoon", kqHrmScheduleSign); + if (count == 1) { + break; + } + } + } + String onSignTimeSql = ""; + if(shiftCount == 4 && shiftI==2) { + onSignTimeSql = KQSignUtil.buildSignSql(count4NoonEndDateTime,signSectionEndTime); + } else { + onSignTimeSql = KQSignUtil.buildSignSql(signSectionTime,signSectionEndTime); + } + String offSignTimeSql = KQSignUtil.buildSignSql(signSectionBeginTime,offSignSectionTime); + String onSql = ""; + String orderSql = ""; + if(onSignTimeSql.length() > 0){ + orderSql = " order by signdate asc, signtime asc "; + if("postgresql".equalsIgnoreCase(dbtype)){ + onSql += "select cast('on' as text) as belongtype,t.* from ("+baseSql+" and "+onSignTimeSql+") t"; + }else{ + onSql += "select 'on' as belongtype,t.* from ("+baseSql+" and "+onSignTimeSql+") t"; + } + if("oracle".equalsIgnoreCase(dbtype)){ + onSql = "select * from ("+onSql+" "+orderSql+" ) a where rownum=1"; + }else if("mysql".equalsIgnoreCase(dbtype)){ + onSql = "select * from (select * from ("+onSql+" "+orderSql+" ) a limit 0,1) a "; + } + else if("postgresql".equalsIgnoreCase(dbtype)){ + onSql = "select * from (select * from ("+onSql+" "+orderSql+" ) a limit 1 offset 0) a "; + } + else if("sqlserver".equalsIgnoreCase(dbtype)){ + onSql = "select top 1 * from ("+onSql+" ) a "+" "+orderSql ; + } + } + String offSql = ""; + if(offSignTimeSql.length() > 0){ + orderSql = " order by signdate desc, signtime desc "; + if("postgresql".equalsIgnoreCase(dbtype)){ + offSql += "select cast('off' as text) as belongtype,t.* from ("+baseSql+" and "+offSignTimeSql+") t"; + }else{ + offSql += "select 'off' as belongtype,t.* from ("+baseSql+" and "+offSignTimeSql+") t"; + } + + if("oracle".equalsIgnoreCase(dbtype)){ + offSql = "select * from ("+offSql+" "+orderSql+" ) a where rownum=1"; + }else if("mysql".equalsIgnoreCase(dbtype)){ + offSql = "select * from (select * from ("+offSql+" "+orderSql+" ) a limit 0,1) a "; + } + else if("postgresql".equalsIgnoreCase(dbtype)){ + offSql = "select * from (select * from ("+offSql+" "+orderSql+" ) a limit 1 offset 0) a "; + } + else if("sqlserver".equalsIgnoreCase(dbtype)){ + offSql = "select top 1 * from ("+offSql+" ) a "+" "+orderSql ; + } + } + if(onSql.length() > 0 && offSql.length() > 0){ + signSql = "select * from ("+onSql+" UNION ALL "+offSql+") s "; + kqLog.info("signSql:"+signSql); + try{ + Map checkMap = new HashMap<>(); + rs.execute(signSql); + while (rs.next()){ + getScheduleSignCardRangeBean(rs,signMap,checkMap); + } + }catch (Exception e){ + e.printStackTrace(); + } + } + if(shiftCount == 4 && shiftI==0) { // 一天4次卡的上午签退卡的统计 + String signSectionEndTime2 = signSectionEndTime.substring(0, signSectionEndTime.length()-2)+"00"; + String noonSignTimeSql = KQSignUtil.buildSignSql(signSectionEndTime2,offSignSectionTime); + String sql = baseSql; + if(sqlWhere.length() > 0){ + sql += sqlWhere+" and "+noonSignTimeSql + " order by signdate, signtime"; + } + rs.executeQuery(sql); + if (rs.next()) { + String signTime = rs.getString("signtime"); + KQHrmScheduleSign kqHrmScheduleSignOut = signMap.get("signout"); + String oldSignTime = kqHrmScheduleSignOut.getSigntime(); + // 午休时段如果有打卡的话,取第一次打卡算作签退 + if(signTime.compareTo(oldSignTime) < 0) { + kqHrmScheduleSignOut.setSigntime(signTime); + } + } + } + } + + return signMap; + } + + /** + * 如果签到和签退可以独立出来,用这个方法 + * @param rs + * @param signMap + * @param checkMap + */ + public void getScheduleSignCardRangeBean(RecordSet rs, Map signMap, + Map checkMap){ + String belongtype =Util.null2String(rs.getString("belongtype")); + if(shiftCount == 4 && shiftI==2) { + if(!signMap.isEmpty()) { + KQHrmScheduleSign kqHrmScheduleSignNoon = signMap.get("signinNoon"); + KQHrmScheduleSign kqHrmScheduleSignOn = signMap.get("signin"); + if(kqHrmScheduleSignNoon != null) { + if("on".equalsIgnoreCase(belongtype)) { + return; + } else { + KQHrmScheduleSign kqHrmScheduleSign = getSignBean(rs); + if(kqHrmScheduleSign != null && kqHrmScheduleSignOn.equals(kqHrmScheduleSign)) { + return; + } + signMap.put("signout",kqHrmScheduleSign); + return; + } + } + } + } + KQHrmScheduleSign kqHrmScheduleSign = getSignBean(rs); + if("on".equalsIgnoreCase(belongtype)){ + if(!checkMap.containsKey("on")){ + signMap.put("signin",kqHrmScheduleSign); + } + }else{ + KQHrmScheduleSign kqHrmScheduleSignOn = signMap.get("signin"); + if(kqHrmScheduleSignOn != null && kqHrmScheduleSign != null && kqHrmScheduleSignOn.equals(kqHrmScheduleSign)) { + return; + } + signMap.put("signout",kqHrmScheduleSign); + } + } + + + /** + * 原始的获取最早时间作为签到,最晚时间作为签退的方法 + * @param rs + * @param signMap + */ + public void getScheduleSignBean(RecordSet rs,Map signMap){ + getScheduleSignBean(rs,signMap,0); + } + public void getScheduleSignBean(RecordSet rs,Map signMap,int signoutOnlyOff){ + KQHrmScheduleSign kqHrmScheduleSign = getSignBean(rs); +// if(1 == signoutOnlyOff){ +// signMap.put("signout",kqHrmScheduleSign); +// }else{ + if(signMap.isEmpty()){ + signMap.put("signin",kqHrmScheduleSign); + }else { + signMap.put("signout",kqHrmScheduleSign); + } +// } + } + + public KQHrmScheduleSign getSignBean(RecordSet rs){ + + KQHrmScheduleSign kqHrmScheduleSign = new KQHrmScheduleSign(); + String id=Util.null2String(rs.getString("id")); + String userid=Util.null2String(rs.getString("userid")); + String usertype =Util.null2String(rs.getString("usertype")); + String signtype=Util.null2String(rs.getString("signtype")); + String signdate=Util.null2String(rs.getString("signdate")); + String signtime=Util.null2String(rs.getString("signtime")); + String clientaddress=Util.null2String(rs.getString("clientaddress")); + String signfrom=Util.null2String(rs.getString("signfrom")); + String longitude=Util.null2String(rs.getString("longitude")); + String latitude=Util.null2String(rs.getString("latitude")); + String addr=Util.null2String(rs.getString("addr")); + String isincom=Util.null2String(rs.getString("isincom")); + String isimport=Util.null2String(rs.getString("isimport")); + String importsql=Util.null2String(rs.getString("importsql")); + String belongdate=Util.null2String(rs.getString("belongdate")); + String serialid=Util.null2String(rs.getString("serialid")); + String worksections=Util.null2String(rs.getString("worksection")); + String signstatus=Util.null2String(rs.getString("signstatus")); + + kqHrmScheduleSign.setId(id); + kqHrmScheduleSign.setUserid(userid); + kqHrmScheduleSign.setUsertype(usertype); + kqHrmScheduleSign.setSigntype(signtype); + kqHrmScheduleSign.setSigndate(signdate); + kqHrmScheduleSign.setSigntime(signtime); + kqHrmScheduleSign.setClientaddress(clientaddress); + kqHrmScheduleSign.setSignfrom(signfrom); + kqHrmScheduleSign.setLongitude(longitude); + kqHrmScheduleSign.setLatitude(latitude); + kqHrmScheduleSign.setAddr(addr); + kqHrmScheduleSign.setIsincom(isincom); + kqHrmScheduleSign.setIsimport(isimport); + kqHrmScheduleSign.setImportsql(importsql); + kqHrmScheduleSign.setBelongdate(belongdate); + kqHrmScheduleSign.setSerialid(serialid); + kqHrmScheduleSign.setWorksections(worksections); + kqHrmScheduleSign.setSignstatus(signstatus); + + return kqHrmScheduleSign; + } + + /** + * 非自由班制的考勤数据 + * @return + */ + public Map getScheduleSignInfo(){ + + RecordSet rs = new RecordSet(); + String signSql = "select * from hrmschedulesign where 1=1 and isInCom='1' "; + String sqlWhere = sqlParamWhere(); + if(sqlWhere.length() > 0){ + signSql += sqlWhere; + } + signSql += " order by signdate,signtime"; + Map signMap = new HashMap<>(); + + try{ + kqLog.info("signSql:"+signSql); + rs.execute(signSql); + while (rs.next()){ + getScheduleSignBean(rs,signMap); + } + }catch (Exception e){ + e.printStackTrace(); + } + return signMap; + } + + /** + * 生成相应的查询条件 + * @return + */ + private String sqlParamWhere() { + String sqlWhere = ""; + if(resourceid.length() > 0){ + sqlWhere += " and userid in ( "+resourceid+" )"; + } + if(signDate.length() > 0){ + sqlWhere += " and signDate = '"+signDate+"' "; + } + if(signTime.length() > 0){ + sqlWhere += " and signTime = '"+signTime+"' "; + } + if(signDateTimeSql.length() > 0){ + sqlWhere += " and "+signDateTimeSql; + } + if(belongdate.length() > 0){ + sqlWhere += " and belongdate = '"+belongdate+"' "; + } + if(signtype.length() > 0){ + sqlWhere += " and signtype = '"+signtype+"' "; + } + //不需要userType,没啥用 +// if(userType.length() > 0){ +// sqlWhere += " and userType = '"+userType+"' "; +// } + if(worksection.length() > 0){ + sqlWhere += " and worksection = '"+worksection+"' "; + } + return sqlWhere; + } + + public static class KQScheduleSignParamBuilder{ + private String resourceid; + private int signoutOnlyOff; + private String offDateTime; + private String userType; + private String signDate; + private String signTime; + private String belongdate; + private String signtype; + private String worksection; + private int shiftCount; + private int shiftI; + private String count4NoonStartDateTime; + private String count4NoonEndDateTime; + /** + * 自定义sql + */ + private String signDateTimeSql; + /** + * 上班开始打卡时间 + */ + private String signSectionTime; + + /** + * 上班结束打卡时间 + */ + private String signSectionEndTime; + /** + * 下班开始打卡时间 + */ + private String signSectionBeginTime; + + /** + * 下班结束打卡时间 + */ + private String offSignSectionTime; + + public KQScheduleSignParamBuilder() { + this.resourceid = resourceid; + this.signoutOnlyOff = signoutOnlyOff; + this.offDateTime = offDateTime; + //初始化的时候需要把其他参数先清空下 + this.userType = ""; + this.signDate = ""; + this.signTime = ""; + this.belongdate = ""; + this.signtype = ""; + this.worksection = ""; + this.signDateTimeSql = ""; + this.signSectionTime = ""; + this.signSectionEndTime = ""; + this.signSectionBeginTime = ""; + this.offSignSectionTime = ""; + this.shiftCount = 0; + this.shiftI = 0; + this.count4NoonStartDateTime = ""; + this.count4NoonEndDateTime = ""; + } + //成员方法返回其自身,所以可以链式调用 + public KQScheduleSignParamBuilder resourceidParam(final String resourceid) { + this.resourceid = resourceid; + return this; + } + public KQScheduleSignParamBuilder signoutOnlyOffParam(final int signoutOnlyOff) { + this.signoutOnlyOff = signoutOnlyOff; + return this; + } + //下班日期时间 + public KQScheduleSignParamBuilder offDateTimeParam(final String offDateTime) { + this.offDateTime = offDateTime; + return this; + } + + public KQScheduleSignParamBuilder userTypeParam(final String userType) { + this.userType = userType; + return this; + } + + public KQScheduleSignParamBuilder shiftCountParam(final int shiftCount) { + this.shiftCount = shiftCount; + return this; + } + + public KQScheduleSignParamBuilder count4NoonStartDateTimeParam(final String count4NoonStartDateTime) { + this.count4NoonStartDateTime = count4NoonStartDateTime; + return this; + } + + public KQScheduleSignParamBuilder count4NoonEndDateTimeParam(final String count4NoonEndDateTime) { + this.count4NoonEndDateTime = count4NoonEndDateTime; + return this; + } + + public KQScheduleSignParamBuilder shiftIParam(final int shiftI) { + this.shiftI = shiftI; + return this; + } + + public KQScheduleSignParamBuilder signDateParam(final String signDate) { + this.signDate = signDate; + return this; + } + + public KQScheduleSignParamBuilder signTimeParam(final String signTime) { + this.signTime = signTime; + return this; + } + + public KQScheduleSignParamBuilder belongDateParam(final String belongdate) { + this.belongdate = belongdate; + return this; + } + + public KQScheduleSignParamBuilder signtypeParam(final String signtype) { + this.signtype = signtype; + return this; + } + + public KQScheduleSignParamBuilder worksectionParam(final String worksection) { + this.worksection = worksection; + return this; + } + + public KQScheduleSignParamBuilder signDateTimeSqlParam(final String signDateTimeSql) { + this.signDateTimeSql = signDateTimeSql; + return this; + } + + public KQScheduleSignParamBuilder signSectionTimeParam(final String signSectionTime) { + this.signSectionTime = signSectionTime; + return this; + } + + public KQScheduleSignParamBuilder signSectionEndTimeParam(final String signSectionEndTime) { + this.signSectionEndTime = signSectionEndTime; + return this; + } + + public KQScheduleSignParamBuilder signSectionBeginTimeParam(final String signSectionBeginTime) { + this.signSectionBeginTime = signSectionBeginTime; + return this; + } + + public KQScheduleSignParamBuilder offSignSectionTimeParam(final String offSignSectionTime) { + this.offSignSectionTime = offSignSectionTime; + return this; + } + //Builder的build方法,返回外部类的实例 + public KQScheduleSignBiz build() { + return new KQScheduleSignBiz(this); + } + + } + + +} diff --git a/src/com/engine/kq/biz/KQScheduleSignImport.java b/src/com/engine/kq/biz/KQScheduleSignImport.java new file mode 100644 index 0000000..3a296c1 --- /dev/null +++ b/src/com/engine/kq/biz/KQScheduleSignImport.java @@ -0,0 +1,873 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.bean.ImportSetting; +import com.engine.kq.entity.KQScheduleSignEntity; +import com.engine.kq.timer.KQQueue; +import com.engine.kq.timer.KQTaskBean; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.BatchRecordSet; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetDataSource; +import weaver.file.ImageFileManager; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.common.Tools; +import weaver.systeminfo.SystemEnv; + +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + + +public class KQScheduleSignImport extends BaseBean { + private List errorInfo = new ArrayList(); + private String fileName = ""; + private String keyField = ""; + private int userlanguage = 7; //登录语言 + + public KQScheduleSignImport() { + } + + public KQScheduleSignImport(Map params) { + this.keyField = Util.null2String(params.get("keyField")); + if (this.keyField.length() == 0) this.keyField = "workcode"; + this.fileName = Util.null2String(params.get("excelfile")); + } + + /** + * 私有方法,获取Excel表格对应表格中的数据 + * + * @param cell Excel表格的行 + * @param row Excel表格的列 + * @return Excel表格对应表格中的数据 + */ + private String getCellValue(HSSFCell cell, HSSFRow row) { + if (cell == null) return ""; + String cellValue = ""; + switch (cell.getCellType()) { + + case NUMERIC: + if (HSSFDateUtil.isCellDateFormatted(cell)) { + SimpleDateFormat sdf = null; + if (cell.getCellStyle().getDataFormat() == HSSFDataFormat.getBuiltinFormat("h:mm:ss")) { + sdf = new SimpleDateFormat("HH:mm:ss"); + } else {// 日期 + sdf = new SimpleDateFormat("yyyy-MM-dd"); + } + Date date = cell.getDateCellValue(); + cellValue = sdf.format(date); + } else { + cellValue = new java.text.DecimalFormat("0").format(cell.getNumericCellValue()); + } + break; + case STRING: + cellValue = cell.getStringCellValue(); + break; + case FORMULA: + cellValue = (DateFormat.getDateInstance().format((cell.getDateCellValue()))).toString(); + + break; + default: + + break; + } + return cellValue; + } + + /** + * 将Excel表格中的数据导入数据库 + */ + public synchronized void ExcelToDB() { + String sql = ""; + BatchRecordSet bRs = new BatchRecordSet(); + List> lsParams = new ArrayList<>(); + List params = null; + List> lsDelParams = new ArrayList<>(); + List delParams = null; + + List lsFormatData = new ArrayList<>(); + List> lsFormatParams = new ArrayList<>(); + List formatParams = null; + Map lsmap = new HashMap<>(); + + try { + ImageFileManager manager = new ImageFileManager(); + manager.getImageFileInfoById(Util.getIntValue(this.fileName)); + HSSFWorkbook workbook = new HSSFWorkbook(new POIFSFileSystem(manager.getInputStream())); + HSSFSheet sheet = workbook.getSheetAt(0); + HSSFRow row = null; + + Map> users = getUsers(this.userlanguage); + Map loginidMap = users.get("loginidMap"); + Map lastnameMap = users.get("lastnameMap"); + Map workcodeMap = users.get("workcodeMap"); + + int rowsNum = sheet.getLastRowNum(); + for (int i = 1; i < rowsNum + 1; i++) { + row = sheet.getRow(i); + if (row == null || !ScanRow(row)) continue; + int tmpUserId = 0; + String tmpLoginid = ""; + String tmpWorkcode = ""; + String tmpLastname = ""; + String tmpSigndate = ""; + String tmpSigntime = ""; + String tmpClientaddress = ""; + int tmpIsincom = 1; + String tmpLongitude = ""; + String tmpLatitude = ""; + String tmpAddr = ""; + for (int j = 0; j < row.getLastCellNum(); j++) { + if (j == 0) { + tmpLoginid = Util.null2String(this.getCellValue(row.getCell((short) j), row)).trim(); + } else if (j == 1) { + tmpWorkcode = Util.null2String(this.getCellValue(row.getCell((short) j), row)).trim(); + } else if (j == 2) { + tmpLastname = Util.null2String(this.getCellValue(row.getCell((short) j), row)).trim(); + } else if (j == 3) { + tmpSigndate = Util.null2String(this.getCellValue(row.getCell((short) j), row)); + if (tmpSigndate.length() == 0) continue; + SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(SDF.parse(tmpSigndate + " 00:00:00")); + tmpSigndate = TimeUtil.getFormartString(calendar, "yyyy-MM-dd"); + } else if (j == 4) { + tmpSigntime = Util.null2String(this.getCellValue(row.getCell((short) j), row)).trim(); + if (tmpSigntime.length() == 0) continue; + if (tmpSigntime.length() > 0) { + String[] a = tmpSigntime.split(":"); + if (a != null && a.length < 3) { + tmpSigntime += ":00"; + } + } + SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(SDF.parse("1999-01-01 " + tmpSigntime)); + tmpSigntime = TimeUtil.getFormartString(calendar, "HH:mm:ss"); + } else if (j == 5) { + tmpClientaddress = Util.null2String(this.getCellValue(row.getCell((short) j), row)); + } + } + if (tmpLoginid.length() == 0 && tmpWorkcode.length() == 0 && tmpLastname.length() == 0) continue; + if (this.keyField.equals("loginid")) { +// tmpUserId = getUserId(tmpLoginid); + tmpUserId = StringUtil.parseToInt(loginidMap.get(tmpLoginid), 0); + } else if (this.keyField.equals("workcode")) { +// tmpUserId = getUserId(tmpWorkcode); + tmpUserId = StringUtil.parseToInt(workcodeMap.get(tmpWorkcode), 0); + } else if (this.keyField.equals("lastname")) { +// tmpUserId = getUserId(tmpLastname); + tmpUserId = StringUtil.parseToInt(lastnameMap.get(tmpLastname), 0); + } + + if (tmpUserId <= 0) continue; + params = new ArrayList<>(); + params.add(tmpUserId); + params.add(1); + params.add(tmpSigndate); + params.add(tmpSigntime); + params.add(tmpClientaddress); + params.add(tmpIsincom); + params.add(1); + params.add("importExcel"); + params.add(tmpLongitude); + params.add(tmpLatitude); + params.add(tmpAddr); + lsParams.add(params); + + String belongDate = getBelongDate(new User(tmpUserId), tmpSigndate, tmpSigntime); + + String formatData = tmpUserId + "|" + tmpSigndate+ "|" + belongDate; + //Arraylist的底层源码采用的indexOf接口有性能问题,单独搞下 +// if (!lsFormatData.contains(formatData)) { +// lsFormatData.add(formatData); +// } + + //替换为hashmap,性能会高很多 + if(!lsmap.containsKey(formatData)){ + lsmap.put(formatData,formatData); + } + } + Map> overtimeMap = Maps.newHashMap(); + List overtimeList = Lists.newArrayList(); + //刷新报表数据 + if(null != lsmap){ + for(Map.Entry entry : lsmap.entrySet()){ + String mapKey = Util.null2String(entry.getKey()); + String mapValue = entry.getValue(); + formatParams = new ArrayList<>(); + String[] formatData = Util.splitString(mapValue, "|"); + +// for (int i = 0; lsFormatData != null && i < lsFormatData.size(); i++) { +// formatParams = new ArrayList<>(); +// String[] formatData = Util.splitString(lsFormatData.get(i), "|"); + + String date_1 = DateUtil.addDate(formatData[1], -1); + formatParams.add(formatData[0]); + formatParams.add(date_1); + lsFormatParams.add(formatParams); + + formatParams = new ArrayList<>(); + formatParams.add(formatData[0]); + formatParams.add(formatData[1]); + lsFormatParams.add(formatParams); + + delParams = new ArrayList<>(); + delParams.add(formatData[0]); + delParams.add(formatData[1]); + lsDelParams.add(delParams); + + String resourceId = formatData[0]; + String kqdate = formatData[1]; + String belongDate = formatData[2]; + if (overtimeMap.containsKey(resourceId)) { + List tmp_overtimeList = overtimeMap.get(resourceId); + if (!tmp_overtimeList.contains(kqdate)) { + tmp_overtimeList.add(kqdate); + if(!kqdate.equals(belongDate)) { + tmp_overtimeList.add(belongDate); + } + } + } else { + if (!overtimeList.contains(kqdate)) { + overtimeList.add(kqdate); + if(!kqdate.equals(belongDate)) { + overtimeList.add(belongDate); + } + } + overtimeMap.put(resourceId, overtimeList); + } + } + } + + + //删除本次同步数据 + sql = " delete from hrmschedulesign where signfrom='importExcel' and userid =? and signdate = ? "; + bRs.executeBatchSql(sql, lsDelParams); + + sql = " insert into HrmScheduleSign (userid, usertype, signdate, signtime, clientaddress, isincom, isimport, signfrom, longitude, latitude, addr) " + + " values(?,?,?,?,?,?,?,?,?,?,?)"; + bRs.executeBatchSql(sql, lsParams); + + new KQFormatBiz().format(lsFormatParams, 15); + //处理加班生成 + List tasks = new ArrayList<>(); + for (Map.Entry> mme : overtimeMap.entrySet()) { + String resid = mme.getKey(); + List overList = mme.getValue(); + for (String date : overList) { + SplitActionUtil.pushOverTimeTasks(date, date, resid, tasks); + } + } + if (!tasks.isEmpty()) { + KQQueue.writeTasks(tasks); + } + } catch (Exception e) { + writeLog(e); + } + + } + + /** + * 验证数据的合法性 + */ + public boolean ScanRow(HSSFRow row) { + boolean canImport = true; + try { + int userid = 0; + String loginid = "", workcode = "", lastname = ""; + for (int j = 0; j < row.getLastCellNum(); j++) { + if (j == 0) { + //验证loginid + loginid = this.getCellValue(row.getCell((short) j), row); + } else if (j == 1) { + //验证workcode + workcode = this.getCellValue(row.getCell((short) j), row); + } else if (j == 2) { + //验证用户名 + lastname = this.getCellValue(row.getCell((short) j), row); + } else if (j == 3) { + //验证考勤时间 + String signdate = Util.null2String(this.getCellValue(row.getCell((short) j), row)); + String signtime = Util.null2String(this.getCellValue(row.getCell((short) (j + 1)), row)).trim(); + if (signdate.length() == 0) { + canImport = false; + } + if (signtime.length() == 0) { + canImport = false; + } + if (signtime.length() > 0) { + String[] a = signtime.split(":"); + if (a != null && a.length < 3) { + signtime += ":00"; + } + } + + String signdatetime = signdate + " " + signtime; + if (signdate.length() > 0 && signtime.length() > 0 && checkData(signdatetime, "datetime")) + canImport = false; + } + } + if (this.keyField.equals("loginid")) { + if (loginid.length() == 0) canImport = false; + userid = getUserId(loginid); + } else if (this.keyField.equals("workcode")) { + if (workcode.length() == 0) canImport = false; + userid = getUserId(workcode); + } else if (this.keyField.equals("lastname")) { + if (lastname.length() == 0) canImport = false; + userid = getUserId(lastname); + } + if (userid == 0) { + canImport = false; + } + } catch (Exception e) { + writeLog(e); + } + return canImport; + } + + /** + * 验证数据的合法性 + */ + public List ScanFile() { + try { + ImageFileManager manager = new ImageFileManager(); + manager.getImageFileInfoById(Util.getIntValue(this.fileName)); + HSSFWorkbook workbook = new HSSFWorkbook(new POIFSFileSystem(manager.getInputStream())); + HSSFSheet sheet = workbook.getSheetAt(0); + + HSSFRow row = null; + + int number = 0; + int rowsNum = sheet.getLastRowNum(); + for (int i = 1; i < rowsNum + 1; i++) { + row = sheet.getRow(i); + if (row == null) continue; + number = i+1; + int userid = 0; + String loginid = "", workcode = "", lastname = ""; + for (int j = 0; j < row.getLastCellNum(); j++) { + if (j == 0) { + //验证loginid + loginid = Util.null2String(this.getCellValue(row.getCell((short) j), row)).trim(); + } else if (j == 1) { + //验证workcode + workcode = Util.null2String(this.getCellValue(row.getCell((short) j), row)).trim(); + } else if (j == 2) { + //验证用户名 + lastname = Util.null2String(this.getCellValue(row.getCell((short) j), row)).trim(); + } else if (j == 3) { + //验证考勤时间 + HSSFCell cell3 = row.getCell((short) j); + String signdate = Util.null2String(this.getCellValue(cell3, row)); + HSSFCell cell4 = row.getCell((short) (j + 1)); + String signtime = Util.null2String(this.getCellValue(cell4, row)).trim(); + + if (signtime.length() > 0) { + String[] a = signtime.split(":"); + if (a != null && a.length < 3) { + signtime += ":00"; + } + } + + if (this.keyField.equals("loginid")) { + if (loginid.length() == 0) { + errorInfo.add(SystemEnv.getHtmlLabelName(15323, userlanguage) + " " + number + " " + SystemEnv.getHtmlLabelName(503585, userlanguage)); + } else { + userid = getUserId(loginid); + if (userid == 0) { + errorInfo.add(SystemEnv.getHtmlLabelName(15323, userlanguage) + " " + number + " " + SystemEnv.getHtmlLabelName(503586, userlanguage)); + } + } + } else if (this.keyField.equals("workcode")) { + if (workcode.length() == 0) { + errorInfo.add(SystemEnv.getHtmlLabelName(15323, userlanguage) + " " + number + " " + SystemEnv.getHtmlLabelName(83770, userlanguage)); + } else { + userid = getUserId(workcode); + if (userid == 0) { + errorInfo.add(SystemEnv.getHtmlLabelName(15323, userlanguage) + " " + number + " " + SystemEnv.getHtmlLabelName(83772, userlanguage)); + } + } + } else if (this.keyField.equals("lastname")) { + if (lastname.length() == 0) { + errorInfo.add(SystemEnv.getHtmlLabelName(15323, userlanguage) + " " + number + " " + SystemEnv.getHtmlLabelName(83774, userlanguage)); + } else { + userid = getUserId(lastname); + if (userid == 0) { + errorInfo.add(SystemEnv.getHtmlLabelName(15323, userlanguage) + " " + number + " " + SystemEnv.getHtmlLabelName(83777, userlanguage)); + } + } + } + + if (signdate.length() == 0) { + errorInfo.add(SystemEnv.getHtmlLabelName(15323, userlanguage) + " " + number + " " + SystemEnv.getHtmlLabelName(83762, userlanguage)); + } + if (signtime.length() == 0) { + errorInfo.add(SystemEnv.getHtmlLabelName(15323, userlanguage) + " " + number + " " + SystemEnv.getHtmlLabelName(83763, userlanguage)); + } + String signdatetime = signdate + " " + signtime; + if (signdate.length() > 0 && signtime.length() > 0 && checkData(signdatetime, "datetime")) + errorInfo.add(SystemEnv.getHtmlLabelName(15323, userlanguage) + " " + number + " " + SystemEnv.getHtmlLabelName(83768, userlanguage)); + } + } + } + } catch (Exception e) { + writeLog(e); + errorInfo.add(SystemEnv.getHtmlLabelName(83779, userlanguage)); + } + return errorInfo; + } + + /** + * 判断数据类型 + * + * @param value + * @param type + * @return + */ + public static boolean checkData(String value, String type) { + boolean boo = false; + + if (type.equals("int")) { + try { + Integer.parseInt(value); + } catch (Exception e) { + boo = true; + } + } else if (type.equals("float")) { + try { + Float.parseFloat(value); + } catch (Exception e) { + boo = true; + } + } else if (type.equals("datetime")) { + try { + SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(SDF.parse(value)); + + } catch (ParseException e) { + boo = true; + } + } + return boo; + } + + public int getUserId(String val) { + int userid = 0; + RecordSet rs = new RecordSet(); + String sql = ""; + if (Util.isEnableMultiLang()) { + if (rs.getDBType().equalsIgnoreCase("sqlserver")) { + sql = "select id from hrmresource where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))='" + Util.null2String(val).trim() + "'"; + } else { + sql = "select id from hrmresource where ltrim(rtrim(convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))='" + Util.null2String(val).trim() + "'"; + } + } else { + sql = "select id from hrmresource where ltrim(rtrim( " + keyField + "))='" + Util.null2String(val).trim() + "'"; + } + rs.execute(sql); + if (rs.next()) { + userid = rs.getInt("id"); + } + return userid; + } + + public static int getUserId(String val, String keyField, int userlanguage) { + int userid = 0; + RecordSet rs = new RecordSet(); + String sql = ""; + if (Util.isEnableMultiLang()) { + if (rs.getDBType().equalsIgnoreCase("sqlserver")) { + sql = "select id from hrmresource where ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))='" + Util.null2String(val).trim() + "'"; + } else { + sql = "select id from hrmresource where ltrim(rtrim(convToMultiLang(ltrim(rtrim(" + keyField + "))," + userlanguage + ")))='" + Util.null2String(val).trim() + "'"; + } + } else { + sql = "select id from hrmresource where ltrim(rtrim(" + keyField + "))='" + Util.null2String(val).trim() + "'"; + } + rs.execute(sql); + if (rs.next()) { + userid = rs.getInt("id"); + } + return userid; + } + + public void importData(String beginDate, String endDate, boolean isSyn) throws Exception { + writeLog("考勤机同步:importData:开始>>>>>>beginDate>>"+beginDate+">>>>>endDate>>>>"+endDate+">>>>>>"+DateUtil.getFullDate()); + RecordSet rs = new RecordSet(); + RecordSet delrs = new RecordSet(); + String sql = ""; + endDate = Tools.getDate(endDate, 1); + BatchRecordSet bRs = new BatchRecordSet(); + List> lsParams = new ArrayList<>(); + List params = null; + + List> lsDelParams = new ArrayList<>(); + List delParams = null; + + List lsFormatData = new ArrayList<>(); + List> lsFormatParams = new ArrayList<>(); + List formatParams = null; + + Map> users = getUsers(this.userlanguage); + Map loginidMap = users.get("loginidMap"); + Map lastnameMap = users.get("lastnameMap"); + Map workcodeMap = users.get("workcodeMap"); + List keymap = new ArrayList<>(); + + + List lsImportSetting = new ArrayList<>(); + ImportSetting importSetting = null; + sql = " select datasourceid, loginid, workcode, lastname, signdate, signtime, tablename, clientaddress,longitude,latitude,addr,memo " + + " from HrmScheduleSignSet "; + rs.execute(sql); + while (rs.next()) { + importSetting = new ImportSetting(); + importSetting.setDatasourceid(Util.null2String(rs.getString("datasourceid")).trim()); + importSetting.setLoginid(Util.null2String(rs.getString("loginid")).trim()); + importSetting.setWorkcode(Util.null2String(rs.getString("workcode")).trim()); + importSetting.setLastname(Util.null2String(rs.getString("lastname")).trim()); + importSetting.setSigndate(Util.null2String(rs.getString("signdate")).trim()); + importSetting.setSigntime(Util.null2String(rs.getString("signtime")).trim()); + importSetting.setTablename(Util.null2String(rs.getString("tablename")).trim()); + importSetting.setClientaddress(Util.null2String(rs.getString("clientaddress")).trim()); + importSetting.setLongitude(Util.null2String(rs.getString("longitude")).trim()); + importSetting.setLatitude(Util.null2String(rs.getString("latitude")).trim()); + importSetting.setAddr(Util.null2String(rs.getString("addr")).trim()); + importSetting.setMemo(Util.null2String(rs.getString("memo")).trim()); + lsImportSetting.add(importSetting); + } + List lsKQScheduleSignData = new ArrayList<>(); + KQScheduleSignEntity kqScheduleSignData = null; + for (int i = 0; lsImportSetting != null && i < lsImportSetting.size(); i++) { +// DataSource ds = null; +// Connection conn = null; + try { + importSetting = lsImportSetting.get(i); + String datasourceid = importSetting.getDatasourceid(); + String loginid = importSetting.getLoginid(); + String workcode = importSetting.getWorkcode(); + String lastname = importSetting.getLastname(); + String signdate = importSetting.getSigndate(); + String signtime = importSetting.getSigntime(); + String tablename = importSetting.getTablename(); + String clientaddress = importSetting.getClientaddress(); + String longitude = importSetting.getLongitude(); + String latitude = importSetting.getLatitude(); + String addr = importSetting.getAddr(); + String memo = importSetting.getMemo(); + +// ds = (DataSource) StaticObj.getServiceByFullname(("datasource." + datasourceid), DataSource.class); +// if (ds == null) continue; +// conn = ds.getConnection(); +// conn.setAutoCommit(true); +// PreparedStatement pstmt = null; +// ResultSet resultSet = null; + + DateFormat df = new SimpleDateFormat("HH:mm:ss"); + + sql = "select * from " + tablename + " where " + signdate + " >= '" + beginDate + "' and " + signdate + " < '" + endDate + "' order by " + signdate + (signtime.length() == 0 || signtime.equalsIgnoreCase(signdate) ? "" : (", " + signtime)); + + //有遇到外部同步,上面的【conn = ds.getConnection();】这个阻塞住,导致下面的同步不执行,下面的用法和集成领导确认 + RecordSetDataSource rsds = new RecordSetDataSource(datasourceid); + +// pstmt = conn.prepareStatement(sql); +// resultSet = pstmt.executeQuery(); + + rsds.execute(sql); + + List noRepertSynData = new ArrayList<>(); + while (rsds.next()) { + String tmpLoginid = ""; + String tmpWorkcode = ""; + String tmpLastname = ""; + String tmpSigndate = ""; + String tmpSigntime = ""; + String tmpClientaddress = ""; + String tmpLongitude = ""; + String tmpLatitude = ""; + String tmpAddr = ""; + String tmpMemo = ""; + + if (loginid.length() > 0) tmpLoginid = Util.null2String(rsds.getString(loginid)).trim(); + if (workcode.length() > 0) tmpWorkcode = Util.null2String(rsds.getString(workcode)).trim(); + if (lastname.length() > 0) tmpLastname = Util.null2String(rsds.getString(lastname)).trim(); + if (signdate.length() > 0) tmpSigndate = Util.null2String(rsds.getString(signdate)).trim(); + if (clientaddress.length() > 0) + tmpClientaddress = Util.null2String(rsds.getString(clientaddress)); + if (longitude.length() > 0) tmpLongitude = Util.null2String(rsds.getString(longitude)).trim(); + if (latitude.length() > 0) tmpLatitude = Util.null2String(rsds.getString(latitude)).trim(); + if (addr.length() > 0) tmpAddr = Util.null2String(rsds.getString(addr)).trim(); + if (memo.length() > 0) tmpMemo = Util.null2String(rsds.getString(memo)).trim(); + + if (signtime.length() > 0) { + tmpSigntime = Util.null2String(rsds.getString(signtime)).trim(); + //判断tmpSigntime格式 08:21:11 如果为长格式需要格式化 + if (tmpSigntime.length() > 8) { + if(tmpSigntime.length()<16){//有遇到signtime格式为hh:mm:ss.0000的格式导致同步不成功 + tmpSigntime = tmpSigntime.substring(0,8); + }else{//比如上yyyy-mm-dd hh:mm的格式走原逻辑 + tmpSigntime = df.format(Timestamp.valueOf(tmpSigntime)); + } + } else if (tmpSigntime.length() < 8) { + //不带秒的情况 自动补齐 + tmpSigntime += ":00"; + } + } else { + tmpSigntime = ""; + } + + if (tmpSigndate.length() > 10) { + //如果时间为长格式,从signdate字段中格式化时间 + if (tmpSigndate.length() == 16) { + //不带秒的情况 自动补齐 + tmpSigndate += ":00"; + } + if (tmpSigntime.length() == 0) {//以signtime字段为有限 + tmpSigndate = tmpSigndate.length()>19?tmpSigndate.substring(0,19):tmpSigndate; + tmpSigntime = df.format(Timestamp.valueOf(tmpSigndate)); + } + tmpSigndate = Tools.formatDate(tmpSigndate, "yyyy-MM-dd"); + } + + //如果时间格式不带秒补齐 + if (tmpSigntime.length() <= 5) { + tmpSigntime += ":00"; + } + + kqScheduleSignData = new KQScheduleSignEntity(); + kqScheduleSignData.setLoginid(tmpLoginid); + kqScheduleSignData.setWorkcode(tmpWorkcode); + kqScheduleSignData.setLastname(tmpLastname); + kqScheduleSignData.setSigndate(tmpSigndate); + kqScheduleSignData.setSigntime(tmpSigntime); + kqScheduleSignData.setClientaddress(tmpClientaddress); + kqScheduleSignData.setLongitude(tmpLongitude); + kqScheduleSignData.setLatitude(tmpLatitude); + kqScheduleSignData.setAddr(tmpAddr); + kqScheduleSignData.setMemo(tmpMemo); + lsKQScheduleSignData.add(kqScheduleSignData); + } +// resultSet.close(); +// pstmt.close(); + } catch (Exception e) { + writeLog(e); + } +// finally { +// if (conn != null) conn.close(); +// } + } + List noRepertSynData = new ArrayList<>(); + for (int i = 0; lsKQScheduleSignData != null && i < lsKQScheduleSignData.size(); i++) { + kqScheduleSignData = lsKQScheduleSignData.get(i); + String tmpLoginid = kqScheduleSignData.getLoginid(); + String tmpWorkcode = kqScheduleSignData.getWorkcode(); + String tmpLastname = kqScheduleSignData.getLastname(); + String tmpSigndate = kqScheduleSignData.getSigndate(); + String tmpSigntime = kqScheduleSignData.getSigntime(); + String tmpClientaddress = kqScheduleSignData.getClientaddress(); + String tmpLongitude = kqScheduleSignData.getLongitude(); + String tmpLatitude = kqScheduleSignData.getLatitude(); + String tmpAddr = kqScheduleSignData.getAddr(); + String tmpMemo = kqScheduleSignData.getMemo(); + int userid = 0; + if (Util.null2String(tmpLoginid).length() > 0) { + userid = StringUtil.parseToInt(loginidMap.get(tmpLoginid), 0); +// userid = getUserId(tmpLoginid, "loginid", this.userlanguage); + } + if (userid == 0 && Util.null2String(tmpWorkcode).length() > 0) { + userid = StringUtil.parseToInt(workcodeMap.get(tmpWorkcode), 0); +// userid = getUserId(tmpWorkcode, "workcode", this.userlanguage); + } + if (userid == 0 && Util.null2String(tmpLastname).length() > 0) { + userid = StringUtil.parseToInt(lastnameMap.get(tmpLastname), 0); +// userid = getUserId(tmpLastname, "lastname", this.userlanguage); + } + + if (userid <= 0) { + writeLog("人员id未找到>>>>>>>>>>" + JSONObject.toJSONString(kqScheduleSignData)); + continue; + } + String dkParamData = userid + "#" + tmpSigndate + "#" + tmpSigntime; + if (noRepertSynData.contains(dkParamData)) { + continue; + } + noRepertSynData.add(dkParamData); + params = new ArrayList<>(); + params.add(userid); + params.add(1); + params.add(tmpSigndate); + params.add(tmpSigntime); + params.add(tmpClientaddress); + params.add(1); + params.add(1); + params.add("OutDataSourceSyn"); + params.add(tmpLongitude); + params.add(tmpLatitude); + params.add(tmpAddr); + params.add(tmpMemo); + lsParams.add(params); + + String belongDate = getBelongDate(new User(userid), tmpSigndate, tmpSigntime); + + String formatData = userid + "|" + tmpSigndate+ "|" + belongDate; + if (!lsFormatData.contains(formatData)) { + lsFormatData.add(formatData); + } + } + + Map> overtimeMap = Maps.newHashMap(); + List overtimeList = Lists.newArrayList(); + //刷新报表数据 + for (int i = 0; lsFormatData != null && i < lsFormatData.size(); i++) { + formatParams = new ArrayList<>(); + String key = lsFormatData.get(i);//String formatData = userid + "|" + tmpSigndate; + String[] formatData = Util.splitString(lsFormatData.get(i), "|"); + String date_1 = DateUtil.addDate(formatData[1], -1); + formatParams.add(formatData[0]); + formatParams.add(date_1); + lsFormatParams.add(formatParams); + + formatParams = new ArrayList<>(); + formatParams.add(formatData[0]); + formatParams.add(formatData[1]); + lsFormatParams.add(formatParams); + + if (!keymap.contains(key)) { + keymap.add(key); + delParams = new ArrayList<>(); + delParams.add(formatData[0]); + delParams.add(formatData[1]); + lsDelParams.add(delParams); + } + + String resourceId = formatData[0]; + String kqdate = formatData[1]; + String belongDate = formatData[2]; + if (overtimeMap.containsKey(resourceId)) { + List tmp_overtimeList = overtimeMap.get(resourceId); + if (!tmp_overtimeList.contains(kqdate)) { + tmp_overtimeList.add(kqdate); + if(!kqdate.equals(belongDate)) { + tmp_overtimeList.add(belongDate); + } + } + } else { + if (!overtimeList.contains(kqdate)) { + overtimeList.add(kqdate); + if(!kqdate.equals(belongDate)) { + overtimeList.add(belongDate); + } + } + overtimeMap.put(resourceId, overtimeList); + } + } + + writeLog("同步之前删除数据:"+ JSONObject.toJSONString(lsDelParams)); + writeLog("同步插入数据:"+ JSONObject.toJSONString(lsParams)); + + //删除本次同步数据 + sql = " delete from hrmschedulesign where signfrom='OutDataSourceSyn' and userid =? and signdate = ? "; + bRs.executeBatchSql(sql, lsDelParams); + + + sql = " insert into HrmScheduleSign (userid, usertype, signdate, signtime, clientaddress, isincom, isimport, signfrom, longitude, latitude, addr,memo) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?)"; + bRs.executeBatchSql(sql, lsParams); + + new KQFormatBiz().format(lsFormatParams, 12); + + //处理加班生成 + List tasks = new ArrayList<>(); + for (Map.Entry> mme : overtimeMap.entrySet()) { + String resid = mme.getKey(); + List overList = mme.getValue(); + for (String date : overList) { + SplitActionUtil.pushOverTimeTasks(date, date, resid, tasks); + } + } + writeLog("tasks:"+ JSON.toJSON(tasks)); + if (!tasks.isEmpty()) { + KQQueue.writeTasks(tasks); + } + } + + public Map> getUsers(int language) { + RecordSet rs = new RecordSet(); + String sql = "select id,loginid,lastname,workcode from hrmresource where status in(0,1,2,3,5)"; + if (Util.isEnableMultiLang()) { + if (rs.getDBType().equalsIgnoreCase("sqlserver")) { + sql = "select id,loginid,ltrim(rtrim(dbo.convToMultiLang(ltrim(rtrim(lastname)),"+language+"))) as lastname,workcode from hrmresource where status in(0,1,2,3,5)"; + } else { + sql = "select id,loginid,ltrim(rtrim(convToMultiLang(ltrim(rtrim(lastname)),"+language+"))) as lastname,workcode from hrmresource where status in(0,1,2,3,5)"; + } + } + + Map> users = new HashMap>(); + rs.execute(sql); + Map loginidMap = new HashMap(); + Map lastnameMap = new HashMap(); + Map workcodeMap = new HashMap(); + String resourceId = "", loginid = "",lastname = "", workcode = ""; + while (rs.next()) { + if (StringUtil.isNull(resourceId = StringUtil.vString(rs.getString("id")))) continue; + loginid = StringUtil.vString(rs.getString("loginid")); + if (StringUtil.isNull(loginid)){ +// continue;//以防离职人员账号被清空的直接跳过,如果没有被清空,那么也支持离职人员的同步 + }else{ + loginidMap.put(loginid, resourceId); + } +// if (StringUtil.isNotNull(loginid = StringUtil.vString(rs.getString("loginid")))) loginidMap.put(loginid, resourceId); + if (StringUtil.isNotNull(lastname = StringUtil.vString(rs.getString("lastname")))) lastnameMap.put(lastname, resourceId); + if (StringUtil.isNotNull(workcode = StringUtil.vString(rs.getString("workcode")))) workcodeMap.put(workcode, resourceId); + } + users.put("loginidMap", loginidMap); + users.put("lastnameMap", lastnameMap); + users.put("workcodeMap", workcodeMap); + return users; + } + + public int getUserlanguage() { + return userlanguage; + } + + public void setUserlanguage(int userlanguage) { + this.userlanguage = userlanguage; + } + + private String getBelongDate(User user, String curDate, String signDateTime) { + String belongDate = curDate; + Map todayLineMap = KQDurationCalculatorUtil.getWorkButton(user, curDate,true); + if(todayLineMap != null) { + List> preInfo = (ArrayList>)todayLineMap.get("pre_signTime"); + if(preInfo != null) { + for(Map entry : preInfo) { + String pre_endtime_across = entry.get("endtime_across"); + String pre_endtime = entry.get("endtime"); + String signEndInfo = "1".equals(pre_endtime_across) ? (curDate+" "+pre_endtime) : (DateUtil.addDate(curDate,-1)+" "+pre_endtime); + String signOutDateTime = curDate+" "+signDateTime; + if(signOutDateTime.compareTo(signEndInfo) <= 0) { + belongDate = DateUtil.addDate(curDate, -1); + } + } + } + } + return belongDate; + } + +} diff --git a/src/com/engine/kq/biz/KQScheduleSignImportJob.java b/src/com/engine/kq/biz/KQScheduleSignImportJob.java new file mode 100644 index 0000000..0d1f260 --- /dev/null +++ b/src/com/engine/kq/biz/KQScheduleSignImportJob.java @@ -0,0 +1,30 @@ +package com.engine.kq.biz; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.Util; +import weaver.hrm.common.Tools; +import weaver.interfaces.schedule.BaseCronJob; + +public class KQScheduleSignImportJob extends BaseCronJob{ + public void execute() { + RecordSet rs = new RecordSet(); + try{ + + rs.writeLog("begin do KQScheduleSignImportJob invoke ..."); + + KQScheduleSignImport kqScheduleSignImport = new KQScheduleSignImport(); + //导入策略 每天导入前一天和当天数据 + int kqScheduleSignImportDay = Util.getIntValue(Prop.getInstance().getPropValue("QC637173", "KQScheduleSignImportDay"),1);//考勤自动同步同步几天前的数据,默认一天 + String date_from = Tools.getDate(Tools.getToday(),-kqScheduleSignImportDay); + String date_to = Tools.getDate(Tools.getToday()); + + rs.writeLog("do KQScheduleSignImportJob invoke..["+date_from+";"+date_to+"]"); + + kqScheduleSignImport.importData(date_from,date_to,false); + + rs.writeLog("end do KQScheduleSignImportJob invoke ..."); + }catch (Exception e) { + rs.writeLog(e) ; + } + } +} diff --git a/src/com/engine/kq/biz/KQSettingsBiz.java b/src/com/engine/kq/biz/KQSettingsBiz.java new file mode 100644 index 0000000..44c1368 --- /dev/null +++ b/src/com/engine/kq/biz/KQSettingsBiz.java @@ -0,0 +1,220 @@ +package com.engine.kq.biz; + +import com.engine.kq.log.KQLog; +import weaver.conn.RecordSet; +import weaver.general.Util; + +/** + * 考勤自定义配置类 + */ +public class KQSettingsBiz { + + public static KQLog kqLog = new KQLog(); + + public static boolean showLeaveTypeSet(String main_key) { + RecordSet rs = new RecordSet(); + String main_val = "1"; + String sql = "select * from kq_settings where main_key=? "; + rs.executeQuery(sql, main_key); + if (rs.next()) { + main_val = Util.null2String(rs.getString("main_val")); + } + + return "1".equalsIgnoreCase(main_val); + } + + /** + * 考勤报表使用线程格式化 + * @return + */ + public static boolean getKqformatthread() { + RecordSet rs = new RecordSet(); + String main_val = "1"; + String sql = "select * from kq_settings where main_key='kqformatthread' "; + rs.executeQuery(sql); + if (rs.next()) { + main_val = Util.null2String(rs.getString("main_val")); + } + return "1".equalsIgnoreCase(main_val); + } + + /** + * 考勤报表按班次时间点触发计算 + * @return + */ + public static boolean getKqformatAccurate() { + RecordSet rs = new RecordSet(); + String main_val = "1"; + String sql = "select * from kq_settings where main_key='kqformataccurate' "; + rs.executeQuery(sql); + if (rs.next()) { + main_val = Util.null2String(rs.getString("main_val")); + } + return "1".equalsIgnoreCase(main_val); + } + + /** + * 销假流程带出的明细是否要清空默认值 + * @return + */ + public static boolean is_leaveback_clear() { + RecordSet rs = new RecordSet(); + String is_leaveback_clear = "0"; + String show_ajax_balance_sql = "select * from kq_settings where main_key='leaveback_clear'"; + rs.executeQuery(show_ajax_balance_sql); + if(rs.next()) { + String main_val = rs.getString("main_val"); + if ("1".equalsIgnoreCase(main_val)) { + is_leaveback_clear = "1"; + } + } + return "1".equalsIgnoreCase(is_leaveback_clear); + } + + /** + * 开启后,允许早到早走,允许晚到晚走,允许晚走晚到支持考勤流程抵扣;关闭,则不支持考勤流程抵扣;此开关默认关闭 + * @return + */ + public static boolean is_flow_humanized() { + RecordSet rs = new RecordSet(); + String is_flow_humanized = "0"; + String show_flow_humanized_sql = "select * from kq_settings where main_key='flow_humanized'"; + rs.executeQuery(show_flow_humanized_sql); + if(rs.next()) { + String main_val = rs.getString("main_val"); + if ("1".equalsIgnoreCase(main_val)) { + is_flow_humanized = "1"; + } + } + return "1".equalsIgnoreCase(is_flow_humanized); + } + + /** + * 开启了这个开关,晚到晚走,超过了设置的规则也可以按照晚到晚走设置来处理迟到 + * @return + */ + public static boolean is_lateinlateout_outrule() { + RecordSet rs = new RecordSet(); + String is_lateinlateout_outrule = "0"; + String show_lateinlateout_outrule_sql = "select * from kq_settings where main_key='lateinlateout_outrule'"; + rs.executeQuery(show_lateinlateout_outrule_sql); + if(rs.next()) { + String main_val = rs.getString("main_val"); + if ("1".equalsIgnoreCase(main_val)) { + is_lateinlateout_outrule = "1"; + } + } + return "1".equalsIgnoreCase(is_lateinlateout_outrule); + } + + /** + * 开启了这个开关,判断历年是否包含今年之后的假期。 + * @return + */ + public static boolean is_balanceofleave() { + RecordSet rs = new RecordSet(); + String is_balanceofleave = "0"; + String show_is_balanceofleave_sql = "select * from kq_settings where main_key='is_balanceofleave'"; + rs.executeQuery(show_is_balanceofleave_sql); + if(rs.next()) { + String main_val = rs.getString("main_val"); + if ("1".equalsIgnoreCase(main_val)) { + is_balanceofleave = "1"; + } + } + return "1".equalsIgnoreCase(is_balanceofleave); + } + + /** + * 开启了这个开关,判断晚走晚到是根据上一个工作日还是直接判断前一天,区别场景是:比如周五跨到下周一 + * @return + */ + public static boolean is_lateoutlatein() { + RecordSet rs = new RecordSet(); + String is_lateoutlatein = "1"; + String show_is_lateoutlatein_sql = "select main_val from kq_settings where main_key='is_lateoutlatein'"; + rs.executeQuery(show_is_lateoutlatein_sql); + if(rs.next()) { + String main_val = rs.getString("main_val"); + if ("1".equalsIgnoreCase(main_val)) { + is_lateoutlatein = "1"; + }else{ + is_lateoutlatein = "0"; + } + } + return "1".equalsIgnoreCase(is_lateoutlatein); + } + + /** + * 开启了这个开关,弹性工作制可以跨天 + * @return + */ + public static boolean is_freeAcross() { + RecordSet rs = new RecordSet(); + String is_balanceofleave = "0"; + String show_is_balanceofleave_sql = "select * from kq_settings where main_key='is_freeAcross'"; + rs.executeQuery(show_is_balanceofleave_sql); + if(rs.next()) { + String main_val = rs.getString("main_val"); + if ("1".equalsIgnoreCase(main_val)) { + is_balanceofleave = "1"; + } + } + return "1".equalsIgnoreCase(is_balanceofleave); + } + + /** + * 开启了这个开关,打卡按钮默认会显示获取地理位置 + * @return + */ + public static boolean isFirstLocation() { + RecordSet rs = new RecordSet(); + String is_balanceofleave = "0"; + String show_is_balanceofleave_sql = "select * from kq_settings where main_key='isFirstLocation'"; + rs.executeQuery(show_is_balanceofleave_sql); + if(rs.next()) { + String main_val = rs.getString("main_val"); + if ("1".equalsIgnoreCase(main_val)) { + is_balanceofleave = "1"; + } + } + return "1".equalsIgnoreCase(is_balanceofleave); + } + + /** + * 强制归档考勤流程处理,true的话强制归档流程写入报表且生成调休、扣减假期 + * false的话,不做考勤相关处理 + * @return + */ + public static boolean isforceflow_attend() { + RecordSet rs = new RecordSet(); + String isforceflow_attend = "1"; + String show_isforceflow_attend_sql = "select * from kq_settings where main_key='forceflow_attend'"; + rs.executeQuery(show_isforceflow_attend_sql); + if(rs.next()) { + String main_val = rs.getString("main_val"); + if ("0".equalsIgnoreCase(main_val)) { + isforceflow_attend = "0"; + } + } + return "1".equalsIgnoreCase(isforceflow_attend); + } + /** + * 是否按照本年、历年来显示假期余额,1表示是 + * @return + */ + public static boolean show_split_balance() { + boolean show_split_balance = true; + RecordSet rs = new RecordSet(); + String settingSql = "select * from KQ_SETTINGS where main_key='show_split_balance'"; + rs.executeQuery(settingSql); + if(rs.next()){ + String main_val = rs.getString("main_val"); + if(!"1".equalsIgnoreCase(main_val)){ + show_split_balance = false; + } + } + return show_split_balance; + } + +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQSettingsComInfo.java b/src/com/engine/kq/biz/KQSettingsComInfo.java new file mode 100644 index 0000000..5371351 --- /dev/null +++ b/src/com/engine/kq/biz/KQSettingsComInfo.java @@ -0,0 +1,42 @@ +package com.engine.kq.biz; + +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; + +/** + * 考勤自定义配置缓存类 + */ +public class KQSettingsComInfo extends CacheBase{ + protected static String TABLE_NAME = "kq_settings"; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "main_key"; + + @CacheColumn(name = "main_val") + protected static int main_val; + + @CacheColumn(name = "main_desc") + protected static int main_desc; + + @CacheColumn(name = "sub_fun_key") + protected static int sub_fun_key; + + @CacheColumn(name = "sub_fun_val") + protected static int sub_fun_val; + + @CacheColumn(name = "sub_fun_desc") + protected static int sub_fun_desc; + + public String getId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getMain_val() { return (String)getRowValue(main_val); } + public String getMain_val(String key) + { + return (String)getValue(main_val,key); + } + +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQShiftCycleSerialComInfo.java b/src/com/engine/kq/biz/KQShiftCycleSerialComInfo.java new file mode 100644 index 0000000..a6f60db --- /dev/null +++ b/src/com/engine/kq/biz/KQShiftCycleSerialComInfo.java @@ -0,0 +1,76 @@ +package com.engine.kq.biz; + +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; + +/** + * 排班周期缓存类 + */ +public class KQShiftCycleSerialComInfo extends CacheBase { + + /** + * 数据来源 + */ + protected static String TABLE_NAME = "kq_group_shiftcycle"; + /** + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = " "; + /** + * sql中的order by信息,不要以order by开始 + */ + protected static String TABLE_ORDER = "id"; + + /** 主键ID */ + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + /** + * 排班周期名称 + */ + @CacheColumn(name = "shiftcyclename") + protected static int shiftcyclename; + + /** + * 班次周期值 + */ + @CacheColumn(name = "shiftcycleserialids") + protected static int shiftcycleserialids; + + /** + * 考勤组id + */ + @CacheColumn(name = "groupid") + protected static int groupid; + + public String getId() { + return (String) getRowValue(PK_INDEX); + } + + public String getShiftcyclename() { + return (String) getRowValue(shiftcyclename); + } + + public String getShiftcyclename(String key) { + return (String) getValue(shiftcyclename, key); + } + + public String getShiftcycleserialids() { + return (String) getRowValue(shiftcycleserialids); + } + + public String getShiftcycleserialids(String key) { + return (String) getValue(shiftcycleserialids, key); + } + + public String getGroupid() { + return (String) getRowValue(groupid); + } + + public String getGroupid(String key) { + return (String) getValue(groupid, key); + } + +} diff --git a/src/com/engine/kq/biz/KQShiftManagementComInfo.java b/src/com/engine/kq/biz/KQShiftManagementComInfo.java new file mode 100644 index 0000000..176f4f0 --- /dev/null +++ b/src/com/engine/kq/biz/KQShiftManagementComInfo.java @@ -0,0 +1,814 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.chain.cominfo.HalfShiftComIndex; +import com.engine.kq.biz.chain.cominfo.RestShiftComIndex; +import com.engine.kq.biz.chain.cominfo.ShiftComIndex; +import com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean; +import com.engine.kq.biz.chain.cominfo.WorkShiftComIndex; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.log.KQLog; +import java.io.PrintWriter; +import java.io.Serializable; +import java.io.StringWriter; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; +import org.apache.commons.lang.math.NumberUtils; +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.CacheItem; +import weaver.cache.CacheMap; +import weaver.cache.PKColumn; +import weaver.conn.RecordSet; +import weaver.general.Util; + +/** + * 班次管理缓存类 + */ +public class KQShiftManagementComInfo extends CacheBase implements Serializable { + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化, 这个字段可以不定义 + */ + protected static String TABLE_NAME = ""; + + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化,或者不需要指定固定的条件, 这个字段可以不定义 + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = null; + + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化,或者不需要指定顺序, 这个字段可以不定义 sql中的order + * by信息,不要以order by开始 + * + */ + protected static String TABLE_ORDER = null; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + @CacheColumn + protected static int shiftbean; + + @CacheColumn + protected static int color; + + @CacheColumn + protected static int isoffdutyfreecheck; + + @CacheColumn + protected static int shiftonoffworkcount; + + @CacheColumn + protected static int serial; + + @CacheColumn + protected static int isresttimeopen; + + @CacheColumn + protected static int worktime; + + @CacheColumn + protected static int punchsetting; + + @CacheColumn + protected static int cardRemind; + + @CacheColumn + protected static int cardRemOfSignIn; + + @CacheColumn + protected static int minsBeforeSignIn; + + @CacheColumn + protected static int cardRemOfSignOut; + + @CacheColumn + protected static int minsAfterSignOut; + + @CacheColumn + protected static int remindMode; + + @CacheColumn + protected static int remindOnPC; + + @CacheColumn + protected static int signoutOnlyoff; + + @CacheColumn + protected static int isRest; + + @CacheColumn + protected static int overtimeRuleId; + + private KQLog kqLog = new KQLog(); + + private boolean isFormat = false; + + @Override + public CacheItem initCache(String key) { + if (key == null || "".equals(key.trim())) { + return null; + } + CacheMap localData = createCacheMap(); + String sql = ""; + kqLog = new KQLog(); + ConcurrentHashMap resourceKQGroups = new ConcurrentHashMap<>(); + //考勤组优先级 + try { + + ConcurrentHashMap shiftInfoBeanMap = new ConcurrentHashMap<>(); + ConcurrentHashMap idMap = new ConcurrentHashMap<>(); + ConcurrentHashMap colorsMap = new ConcurrentHashMap<>(); + ConcurrentHashMap isoffdutyfreechecksMap = new ConcurrentHashMap<>(); + ConcurrentHashMap shiftonoffworkcountsMap = new ConcurrentHashMap<>(); + ConcurrentHashMap serialsMap = new ConcurrentHashMap<>(); + ConcurrentHashMap isresttimeopensMap = new ConcurrentHashMap<>(); + ConcurrentHashMap worktimesMap = new ConcurrentHashMap<>(); + ConcurrentHashMap punchsettingsMap = new ConcurrentHashMap<>(); + ConcurrentHashMap cardRemindMap = new ConcurrentHashMap<>(); + ConcurrentHashMap cardRemOfSignInMap = new ConcurrentHashMap<>(); + ConcurrentHashMap minsBeforeSignInMap = new ConcurrentHashMap<>(); + ConcurrentHashMap cardRemOfSignOutMap = new ConcurrentHashMap<>(); + ConcurrentHashMap minsAfterSignOutMap = new ConcurrentHashMap<>(); + ConcurrentHashMap remindModeMap = new ConcurrentHashMap<>(); + ConcurrentHashMap remindOnPCMap = new ConcurrentHashMap<>(); + ConcurrentHashMap signoutOnlyoffMap = new ConcurrentHashMap<>(); + ConcurrentHashMap isResetMap = new ConcurrentHashMap<>(); + ConcurrentHashMap overtimeruleMap = new ConcurrentHashMap<>(); + RecordSet rs = new RecordSet(); + String getShiftInfo = "select * from kq_ShiftManagement where 1=1 and id="+key+" order by id "; + rs.execute(getShiftInfo); + while(rs.next()){ + String serialid = rs.getString("id"); + String isresttimeopen = rs.getString("isresttimeopen"); + String color = rs.getString("color"); + String shiftonoffworkcount = rs.getString("shiftonoffworkcount"); + String worktime = rs.getString("worktime"); + String serial = rs.getString("serial"); + String punchsetting = "1"; + String isoffdutyfreecheck = rs.getString("isoffdutyfreecheck"); + String cardRemind = rs.getString("cardRemind"); + String cardRemOfSignIn = rs.getString("cardRemOfSignIn"); + String minsBeforeSignIn = rs.getString("minsBeforeSignIn"); + String cardRemOfSignOut = rs.getString("cardRemOfSignOut"); + String minsAfterSignOut = rs.getString("minsAfterSignOut"); + String remindMode = rs.getString("remindMode"); + String remindOnPC = rs.getString("remindOnPC"); + String halfcalrule = rs.getString("halfcalrule"); + halfcalrule = Util.null2String(halfcalrule).length() == 0 ? "0" : halfcalrule; + String halfcalpoint = rs.getString("halfcalpoint"); + String halfcalpoint2cross = rs.getString("halfcalpoint2cross"); + String overtimeRuleId = rs.getString("overtime_rule_id"); + String signoutOnlyoff = rs.getString("signoutOnlyoff"); + String isRest = rs.getString("is_rest"); + + getShiftInfoBean(serialid,isresttimeopen,worktime,punchsetting,shiftInfoBeanMap,halfcalrule,halfcalpoint,halfcalpoint2cross,signoutOnlyoff); + + idMap.put(serialid, serialid); + colorsMap.put(serialid, color); + isoffdutyfreechecksMap.put(serialid, isoffdutyfreecheck); + shiftonoffworkcountsMap.put(serialid, shiftonoffworkcount); + serialsMap.put(serialid, serial); + isresttimeopensMap.put(serialid, isresttimeopen); + worktimesMap.put(serialid, worktime); + punchsettingsMap.put(serialid, punchsetting); + cardRemindMap.put(serialid,cardRemind); + cardRemOfSignInMap.put(serialid,cardRemOfSignIn); + minsBeforeSignInMap.put(serialid,minsBeforeSignIn); + cardRemOfSignOutMap.put(serialid,cardRemOfSignOut); + minsAfterSignOutMap.put(serialid,minsAfterSignOut); + remindModeMap.put(serialid,remindMode); + remindOnPCMap.put(serialid,remindOnPC); + signoutOnlyoffMap.put(serialid,signoutOnlyoff); + isResetMap.put(serialid,isRest); + overtimeruleMap.put(serialid,overtimeRuleId); + } + + + if(shiftInfoBeanMap.size()>0){ + CacheItem cacheItem = createCacheItem(); + Iterator> iterator = shiftInfoBeanMap.entrySet().iterator(); + while (iterator.hasNext()) { + Entry entry = iterator.next(); + String id = entry.getKey(); + Object value = entry.getValue(); + cacheItem.set(PK_INDEX, id); + cacheItem.set(shiftbean, value); + cacheItem.set(isoffdutyfreecheck, isoffdutyfreechecksMap.get(id)); + cacheItem.set(shiftonoffworkcount, shiftonoffworkcountsMap.get(id)); + cacheItem.set(serial, serialsMap.get(id)); + cacheItem.set(isresttimeopen, isresttimeopensMap.get(id)); + cacheItem.set(worktime, worktimesMap.get(id)); + cacheItem.set(punchsetting, punchsettingsMap.get(id)); + cacheItem.set(cardRemind,cardRemindMap.get(id)); + cacheItem.set(cardRemOfSignIn,cardRemOfSignInMap.get(id)); + cacheItem.set(minsBeforeSignIn,minsBeforeSignInMap.get(id)); + cacheItem.set(cardRemOfSignOut,cardRemOfSignOutMap.get(id)); + cacheItem.set(minsAfterSignOut,minsAfterSignOutMap.get(id)); + cacheItem.set(remindMode,remindModeMap.get(id)); + cacheItem.set(remindOnPC,remindOnPCMap.get(id)); + cacheItem.set(signoutOnlyoff,signoutOnlyoffMap.get(id)); + cacheItem.set(isRest,isResetMap.get(id)); + cacheItem.set(overtimeRuleId,overtimeruleMap.get(id)); + modifyCacheItem(id, cacheItem); + } + return cacheItem; + } + } catch (Exception e) { + kqLog.info(e); + } + return null; + } + + @Override + public CacheMap initCache() { + CacheMap localData = createCacheMap(); + String sql = ""; + kqLog = new KQLog(); + ConcurrentHashMap resourceKQGroups = new ConcurrentHashMap<>(); + //考勤组优先级 + try { + + ConcurrentHashMap shiftInfoBeanMap = new ConcurrentHashMap<>(); + ConcurrentHashMap idMap = new ConcurrentHashMap<>(); + ConcurrentHashMap colorsMap = new ConcurrentHashMap<>(); + ConcurrentHashMap isoffdutyfreechecksMap = new ConcurrentHashMap<>(); + ConcurrentHashMap shiftonoffworkcountsMap = new ConcurrentHashMap<>(); + ConcurrentHashMap serialsMap = new ConcurrentHashMap<>(); + ConcurrentHashMap isresttimeopensMap = new ConcurrentHashMap<>(); + ConcurrentHashMap worktimesMap = new ConcurrentHashMap<>(); + ConcurrentHashMap punchsettingsMap = new ConcurrentHashMap<>(); + ConcurrentHashMap cardRemindMap = new ConcurrentHashMap<>(); + ConcurrentHashMap cardRemOfSignInMap = new ConcurrentHashMap<>(); + ConcurrentHashMap minsBeforeSignInMap = new ConcurrentHashMap<>(); + ConcurrentHashMap cardRemOfSignOutMap = new ConcurrentHashMap<>(); + ConcurrentHashMap minsAfterSignOutMap = new ConcurrentHashMap<>(); + ConcurrentHashMap remindModeMap = new ConcurrentHashMap<>(); + ConcurrentHashMap remindOnPCMap = new ConcurrentHashMap<>(); + ConcurrentHashMap signoutOnlyoffMap = new ConcurrentHashMap<>(); + ConcurrentHashMap isResetMap = new ConcurrentHashMap<>(); + ConcurrentHashMap overtimeruleMap = new ConcurrentHashMap<>(); + RecordSet rs = new RecordSet(); + String getShiftInfo = "select * from kq_ShiftManagement where 1=1 order by id "; + rs.execute(getShiftInfo); + while(rs.next()){ + String serialid = rs.getString("id"); + String isresttimeopen = rs.getString("isresttimeopen"); + String color = rs.getString("color"); + String shiftonoffworkcount = rs.getString("shiftonoffworkcount"); + String worktime = rs.getString("worktime"); + String serial = rs.getString("serial"); + String punchsetting = "1"; + String isoffdutyfreecheck = rs.getString("isoffdutyfreecheck"); + String cardRemind = rs.getString("cardRemind"); + String cardRemOfSignIn = rs.getString("cardRemOfSignIn"); + String minsBeforeSignIn = rs.getString("minsBeforeSignIn"); + String cardRemOfSignOut = rs.getString("cardRemOfSignOut"); + String minsAfterSignOut = rs.getString("minsAfterSignOut"); + String remindMode = rs.getString("remindMode"); + String remindOnPC = rs.getString("remindOnPC"); + String halfcalrule = rs.getString("halfcalrule"); + halfcalrule = Util.null2String(halfcalrule).length() == 0 ? "0" : halfcalrule; + String halfcalpoint = rs.getString("halfcalpoint"); + String halfcalpoint2cross = rs.getString("halfcalpoint2cross"); + String signoutOnlyoff = rs.getString("signoutOnlyoff"); + String overtimeRuleId = rs.getString("overtime_rule_id"); + String isRest = rs.getString("is_rest"); + + getShiftInfoBean(serialid,isresttimeopen,worktime,punchsetting,shiftInfoBeanMap,halfcalrule,halfcalpoint,halfcalpoint2cross,signoutOnlyoff); + + idMap.put(serialid, serialid); + colorsMap.put(serialid, color); + isoffdutyfreechecksMap.put(serialid, isoffdutyfreecheck); + shiftonoffworkcountsMap.put(serialid, shiftonoffworkcount); + serialsMap.put(serialid, serial); + isresttimeopensMap.put(serialid, isresttimeopen); + worktimesMap.put(serialid, worktime); + punchsettingsMap.put(serialid, punchsetting); + cardRemindMap.put(serialid,cardRemind); + cardRemOfSignInMap.put(serialid,cardRemOfSignIn); + minsBeforeSignInMap.put(serialid,minsBeforeSignIn); + cardRemOfSignOutMap.put(serialid,cardRemOfSignOut); + minsAfterSignOutMap.put(serialid,minsAfterSignOut); + remindModeMap.put(serialid,remindMode); + remindOnPCMap.put(serialid,remindOnPC); + signoutOnlyoffMap.put(serialid,signoutOnlyoff); + isResetMap.put(serialid,isRest); + overtimeruleMap.put(serialid,overtimeRuleId); + } + + + if(shiftInfoBeanMap.size()>0){ + Iterator> iterator = shiftInfoBeanMap.entrySet().iterator(); + while (iterator.hasNext()) { + Entry entry = iterator.next(); + String id = entry.getKey(); + Object value = entry.getValue(); + CacheItem cacheItem = createCacheItem(); + cacheItem.set(PK_INDEX, id); + cacheItem.set(shiftbean, value); + cacheItem.set(isoffdutyfreecheck, isoffdutyfreechecksMap.get(id)); + cacheItem.set(shiftonoffworkcount, shiftonoffworkcountsMap.get(id)); + cacheItem.set(serial, serialsMap.get(id)); + cacheItem.set(isresttimeopen, isresttimeopensMap.get(id)); + cacheItem.set(worktime, worktimesMap.get(id)); + cacheItem.set(punchsetting, punchsettingsMap.get(id)); + cacheItem.set(cardRemind,cardRemindMap.get(id)); + cacheItem.set(cardRemOfSignIn,cardRemOfSignInMap.get(id)); + cacheItem.set(minsBeforeSignIn,minsBeforeSignInMap.get(id)); + cacheItem.set(cardRemOfSignOut,cardRemOfSignOutMap.get(id)); + cacheItem.set(minsAfterSignOut,minsAfterSignOutMap.get(id)); + cacheItem.set(remindMode,remindModeMap.get(id)); + cacheItem.set(remindOnPC,remindOnPCMap.get(id)); + cacheItem.set(signoutOnlyoff,signoutOnlyoffMap.get(id)); + cacheItem.set(isRest,isResetMap.get(id)); + cacheItem.set(overtimeRuleId,overtimeruleMap.get(id)); + modifyCacheItem(id, cacheItem); + localData.put(id, cacheItem); + } + } + } catch (Exception e) { + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + return localData; + } + + public String getId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getColor() { return (String)getRowValue(color); } + + public String getColor(String key) + { + return (String)getValue(color,key); + } + + public String getIsoffdutyfreecheck() { return (String)getRowValue(isoffdutyfreecheck); } + + public String getIsoffdutyfreecheck(String key) + { + return (String)getValue(isoffdutyfreecheck,key); + } + + public String getShiftonoffworkcounts() { return (String)getRowValue(shiftonoffworkcount); } + + public String getShiftonoffworkcounts(String key) + { + return (String)getValue(shiftonoffworkcount,key); + } + + public String getSerial() { return (String)getRowValue(serial); } + + public String getSerial(String key) + { + return (String)getValue(serial,key); + } + + public String getIsresttimeopen() { return (String)getRowValue(isresttimeopen); } + + public String getIsresttimeopen(String key) + { + return (String)getValue(isresttimeopen,key); + } + + public String getWorktime() { return (String)getRowValue(worktime); } + + public String getWorktime(String key) + { + return (String)getValue(worktime,key); + } + + public String getPunchsetting() { + return (String) getRowValue(punchsetting); + } + + public String getPunchsetting(String key) { + return (String) getValue(punchsetting, key); + } + + public String getCardRemind() { + return (String) getRowValue(cardRemind); + } + + public String getCardRemind(String key) { + return (String) getValue(cardRemind,key); + } + + public String getCardRemOfSignIn() { + return (String) getRowValue(cardRemOfSignIn); + } + + public String getCardRemOfSignIn(String key) { + return (String) getValue(cardRemOfSignIn, key); + } + + public String getMinsBeforeSignIn() { + return (String) getRowValue(minsBeforeSignIn); + } + + public String getMinsBeforeSignIn(String key) { + return (String) getValue(minsBeforeSignIn, key); + } + + public String getCardRemOfSignOut() { + return (String) getRowValue(cardRemOfSignOut); + } + + public String getCardRemOfSignOut(String key) { + return (String) getValue(cardRemOfSignOut, key); + } + + public String getMinsAfterSignOut() { + return (String) getRowValue(minsAfterSignOut); + } + + public String getMinsAfterSignOut(String key) { + return (String) getValue(minsAfterSignOut, key); + } + + public String getRemindMode() { + return (String) getRowValue(remindMode); + } + + public String getRemindMode(String key) { + return (String) getValue(remindMode, key); + } + + public String getRemindOnPC() { + return (String) getRowValue(remindOnPC); + } + + public String getRemindOnPC(String key) { + return (String) getValue(remindOnPC, key); + } + + public String getSignoutOnlyoff() { + return (String) getRowValue(signoutOnlyoff); + } + + public String getSignoutOnlyoff(String key) { + return (String) getValue(signoutOnlyoff, key); + } + + public String getIsRest() { + return (String) getRowValue(isRest); + } + + public String getIsRest(String key) { + return (String) getValue(isRest, key); + } + + public String getOvertimeRuleId() { + return (String) getRowValue(overtimeRuleId); + } + + public String getOvertimeRuleId(String key) { + return (String) getValue(overtimeRuleId, key); + } + + private void getShiftInfoBean(String serialid, String isresttimeopen, String worktime, + String punchsettings, + ConcurrentHashMap serialMap, + String halfcalrule,String halfcalpoint,String halfcalpoint2cross, String tmp_signoutOnlyoff) throws Exception { + + Map workTimeMap = new HashMap<>(); + int workmins = 0; + List workTimes = Collections.synchronizedList(new ArrayList<>()); + List restTimes = Collections.synchronizedList(new ArrayList<>()); + KQShiftOnOffWorkSectionComInfo kqShiftOnOffWorkSectionComInfo = new KQShiftOnOffWorkSectionComInfo(); + KQShiftRestTimeSectionComInfo kqShiftRestTimeSectionComInfo = new KQShiftRestTimeSectionComInfo(); + + workTimes = kqShiftOnOffWorkSectionComInfo.getWorkSectionTimes(serialid); + if(workTimes != null && !workTimes.isEmpty()){ + if("1".equalsIgnoreCase(isresttimeopen)) { + //如果开启了才去判断 + restTimes = kqShiftRestTimeSectionComInfo.getRestSectionTimes(serialid); + } + if(NumberUtils.isNumber(worktime)){ + if(worktime.indexOf('.') == -1){ + workmins = Util.getIntValue(worktime,0); + }else { + worktime = worktime.substring(0,worktime.indexOf('.')); + workmins = Util.getIntValue(worktime,0); + } + + }else{ + workmins = 0; + kqLog.info("班次有问题,serialid:"+serialid+"工作时长为:"+worktime); + } + workTimeMap.put("workTime", workTimes); + workTimeMap.put("restTime", restTimes); + workTimeMap.put("serialid", serialid); + //工作时长分钟数 + workTimeMap.put("workmins", workmins+""); + workTimeMap.put("punchsettings", punchsettings); + workTimeMap.put("isresttimeopen", isresttimeopen); + workTimeMap.put("halfcalrule", halfcalrule); + workTimeMap.put("halfcalpoint", halfcalpoint); + workTimeMap.put("halfcalpoint2cross", halfcalpoint2cross); + workTimeMap.put("signoutOnlyoff", tmp_signoutOnlyoff.equals("1") ? "1" : "0"); + + ShiftInfoCominfoBean shiftInfoCominfoBean = setShiftInfoBean(workTimeMap); + serialMap.put(serialid, shiftInfoCominfoBean); + } + + } + + private ShiftInfoCominfoBean setShiftInfoBean(Map workTimeMap) throws Exception { + + ShiftComIndex workComIndex = new WorkShiftComIndex(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005306,weaver.general.ThreadVarLanguage.getLang())+"",workTimeMap); + ShiftComIndex restComIndex = new RestShiftComIndex(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005307,weaver.general.ThreadVarLanguage.getLang())+"",workTimeMap); + ShiftComIndex halfComIndex = new HalfShiftComIndex(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005308,weaver.general.ThreadVarLanguage.getLang())+"",workTimeMap); + //创建执行链 + //前一天的都执行完了,去获取当天工作时段,再执行半天的规则 + workComIndex.setDuration(restComIndex); + //执行完了半天的规则,再最后判断休息的时段 + restComIndex.setDuration(halfComIndex); + + ShiftInfoCominfoBean shiftInfoCominfoBean = new ShiftInfoCominfoBean(); + + workComIndex.handleDuration(shiftInfoCominfoBean); + return shiftInfoCominfoBean; + } + + /** + * 考勤按钮 + * @param workdate + * @param serialidInfo + * @param containYesterday + * @return + */ + public Map getWorkButton(String workdate,Map serialidInfo, boolean containYesterday){ + Map shiftMap = new HashMap<>(); + + //考勤按钮还是走缓存 + KQShiftManagementRedis kqShiftManagementRedis = new KQShiftManagementRedis(); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + if(serialidInfo != null && !serialidInfo.isEmpty()){ + LocalDate preLocalDate = LocalDate.parse(workdate); + String preSplitDate = ""; + preLocalDate = preLocalDate.minusDays(1); + preSplitDate = preLocalDate.format(dateFormatter); + String serialid = Util.null2String(serialidInfo.get(workdate)); + String preSerialid = Util.null2String(serialidInfo.get(preSplitDate)); + if(containYesterday){ + if(Util.getIntValue(preSerialid) > 0){ + ShiftInfoCominfoBean pre_shiftInfoCominfoBean = kqShiftManagementRedis.getShiftInfoBean(preSerialid); + List timelineList = pre_shiftInfoCominfoBean.getTimelineList(); + if(timelineList!=null && !timelineList.isEmpty()){ + shiftMap.put("pre_timelineList", timelineList); + } + shiftMap.put("pre_isAcross", pre_shiftInfoCominfoBean.getIsAcross()); + shiftMap.put("pre_allWorkTime", pre_shiftInfoCominfoBean.getAllWorkTime()); + shiftMap.put("pre_allAcrossWorkTime", pre_shiftInfoCominfoBean.getAllAcrossWorkTime()); + shiftMap.put("pre_signTime", pre_shiftInfoCominfoBean.getSignWorkTime()); + shiftMap.put("pre_restTime", pre_shiftInfoCominfoBean.getRestAcrossLongTime()); + } + } + if(Util.getIntValue(serialid) > 0){ + ShiftInfoCominfoBean cur_shiftInfoCominfoBean = kqShiftManagementRedis.getShiftInfoBean(serialid); + Map shiftRuleMap = ShiftManagementToolKit.getShiftRuleInfo(serialid,false); + List timelineList = cur_shiftInfoCominfoBean.getTimelineList(); + if(timelineList!=null && !timelineList.isEmpty()){ + shiftMap.put("timelineList", timelineList); + } + shiftMap.put("isAcross", cur_shiftInfoCominfoBean.getIsAcross()); + shiftMap.put("allWorkTime", cur_shiftInfoCominfoBean.getAllWorkTime()); + shiftMap.put("allAcrossWorkTime", cur_shiftInfoCominfoBean.getAllAcrossWorkTime()); + shiftMap.put("signTime", cur_shiftInfoCominfoBean.getSignWorkTime()); + shiftMap.put("restTime", cur_shiftInfoCominfoBean.getRestAcrossLongTime()); + if(shiftRuleMap != null && !shiftRuleMap.isEmpty()){ + shiftMap.put("shiftRuleMap", shiftRuleMap); + } + } + } + + return shiftMap; + } + + /** + * 流程计算用的 + * @param workdate + * @param serialidInfo + * @param containYesterday + * @return + * shiftInfoBean 每一天内含有的班次都拆分出来,包含昨天班次在今天的时段0-24小时制的 + * shiftLongInfoBean 当天的班次数据,0-48小时制度的 + */ + public Map getWorkDuration(String workdate,Map serialidInfo,boolean containYesterday){ + + KQWorkTime kqWorkTime = new KQWorkTime(); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + Map dateWorkTimeMap = new HashMap<>(); + LocalDate preLocalDate = LocalDate.parse(workdate); + String preSplitDate = ""; + preLocalDate = preLocalDate.minusDays(1); + preSplitDate = preLocalDate.format(dateFormatter); + if(serialidInfo != null && !serialidInfo.isEmpty()){ + String preSerialid = Util.null2String(serialidInfo.get(preSplitDate)); + String serialid = Util.null2String(serialidInfo.get(workdate)); + Boolean isNonWork = kqWorkTime.isNonWork(serialidInfo); + ShiftInfoBean shiftInfoBean = new ShiftInfoBean(); + shiftInfoBean.setPreSplitDate(preSplitDate); + shiftInfoBean.setSplitDate(workdate); + shiftInfoBean.setD_Mins(0.0); + shiftInfoBean.setPreSerialid(preSerialid); + shiftInfoBean.setSerialid(serialid); + shiftInfoBean.setRestShift(isNonWork?1:0); + if(containYesterday){ + if(Util.getIntValue(serialid) > 0 || Util.getIntValue(preSerialid) > 0){ + fillShiftInfoBean(shiftInfoBean, preSerialid, serialid); + dateWorkTimeMap.put("shiftInfoBean", shiftInfoBean); + } + }else{ + if(Util.getIntValue(serialid) > 0){ + fillShiftInfoBean(shiftInfoBean, preSerialid, serialid); + dateWorkTimeMap.put("shiftInfoBean", shiftInfoBean); + } + } + } + + return dateWorkTimeMap; + } + + /** + * 根据班次id获取对应日期的上下班时间+休息时间 + * @param workdate + * @param serialidInfo + * @return + */ + public Map getWorkTimeMap(String workdate,Map serialidInfo){ + + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + Map dateWorkTimeMap = new HashMap<>(); + LocalDate preLocalDate = LocalDate.parse(workdate); + String preSplitDate = ""; + preLocalDate = preLocalDate.minusDays(1); + preSplitDate = preLocalDate.format(dateFormatter); + if(serialidInfo != null && !serialidInfo.isEmpty()){ + String preSerialid = Util.null2String(serialidInfo.get(preSplitDate)); + String serialid = Util.null2String(serialidInfo.get(workdate)); + getShiftInfoBeanMap(dateWorkTimeMap,preSerialid, serialid); + } + + return dateWorkTimeMap; + } + + /** + * 根据考勤报表需要的 返回相应格式的数据 + * @param dateWorkTimeMap + * @param preSerialid + * @param serialid + */ + private void getShiftInfoBeanMap(Map dateWorkTimeMap,String preSerialid, String serialid) { + ShiftInfoCominfoBean cur_shiftInfoCominfoBean = getShiftInfoCominfoBean(serialid); + + if(cur_shiftInfoCominfoBean != null){ + dateWorkTimeMap.put("restTime",cur_shiftInfoCominfoBean.getRestAcrossLongTime()); + dateWorkTimeMap.put("workTime",cur_shiftInfoCominfoBean.getWorkAcrossLongTime()); + dateWorkTimeMap.put("workMins",cur_shiftInfoCominfoBean.getWorkmins()); + dateWorkTimeMap.put("isAcross",cur_shiftInfoCominfoBean.getIsAcross()); + dateWorkTimeMap.put("signTime", cur_shiftInfoCominfoBean.getSignWorkTime()); + dateWorkTimeMap.put("halfWorkTime", cur_shiftInfoCominfoBean.getHalfWorkTime()); + dateWorkTimeMap.put("halfWorkIndex", cur_shiftInfoCominfoBean.getHalfWorkIndex()); + dateWorkTimeMap.put("convertAttendDay", cur_shiftInfoCominfoBean.getConvertAttendDay()); + } + } + + /** + * 每次获取的话都需要获取昨天和今天的班次数据 + * @param shiftInfoBean + * @param preSerialid 昨天的班次 + * @param serialid 今天的班次 + */ + private void fillShiftInfoBean(ShiftInfoBean shiftInfoBean,String preSerialid,String serialid){ + ShiftInfoCominfoBean pre_shiftInfoCominfoBean = getShiftInfoCominfoBean(preSerialid); + ShiftInfoCominfoBean cur_shiftInfoCominfoBean = getShiftInfoCominfoBean(serialid); + Map pre_shiftRuleMap = ShiftManagementToolKit.getShiftRuleInfo(preSerialid,false); + Map shiftRuleMap = ShiftManagementToolKit.getShiftRuleInfo(serialid,false); + + //把前一个班次的填充好 + if(pre_shiftInfoCominfoBean != null){ + shiftInfoBean.setPreWorkIndex(pre_shiftInfoCominfoBean.getPreWorkTimeIndex()); + shiftInfoBean.setPreWorkAcrossIndex(pre_shiftInfoCominfoBean.getWorkAcrossTimeIndex()); + shiftInfoBean.setPreWorkMinsAcrossIndex(pre_shiftInfoCominfoBean.getWorkPunchMins()); + shiftInfoBean.setPreRestIndex(pre_shiftInfoCominfoBean.getPreRestTimeIndex()); + shiftInfoBean.setPreHalfWorkIndex(pre_shiftInfoCominfoBean.getHalfWorkIndex()); + shiftInfoBean.setPreWorkmins(pre_shiftInfoCominfoBean.getWorkmins()); + shiftInfoBean.setPreAllWorkTime(pre_shiftInfoCominfoBean.getAllWorkTime()); + shiftInfoBean.setPreAllAcrossWorkTime(pre_shiftInfoCominfoBean.getAllAcrossWorkTime()); + shiftInfoBean.setPreAllRestTime(pre_shiftInfoCominfoBean.getAllRestTime()); + shiftInfoBean.setPreAllAcrossRestTime(pre_shiftInfoCominfoBean.getAllAcrossRestTime()); + shiftInfoBean.setPreSerialid(preSerialid); + shiftInfoBean.setIsPreAcross(pre_shiftInfoCominfoBean.getIsAcross()); + shiftInfoBean.setShiftRuleMap(pre_shiftRuleMap); + shiftInfoBean.setPreConvertAttendDay(pre_shiftInfoCominfoBean.getConvertAttendDay()); + } + + //把当前班次的填充好 + if(cur_shiftInfoCominfoBean != null){ + shiftInfoBean.setWorkIndex(cur_shiftInfoCominfoBean.getWorkTimeIndex()); + shiftInfoBean.setWorkAcrossIndex(cur_shiftInfoCominfoBean.getWorkAcrossTimeIndex()); + shiftInfoBean.setWorkMinsAcrossIndex(cur_shiftInfoCominfoBean.getWorkPunchMins()); + shiftInfoBean.setRestIndex(cur_shiftInfoCominfoBean.getRestTimeIndex()); + shiftInfoBean.setHalfWorkIndex(cur_shiftInfoCominfoBean.getHalfWorkIndex()); + shiftInfoBean.setWorkmins(cur_shiftInfoCominfoBean.getWorkmins()); + shiftInfoBean.setAllWorkTime(cur_shiftInfoCominfoBean.getAllWorkTime()); + shiftInfoBean.setAllAcrossWorkTime(cur_shiftInfoCominfoBean.getAllAcrossWorkTime()); + shiftInfoBean.setAllRestTime(cur_shiftInfoCominfoBean.getAllRestTime()); + shiftInfoBean.setAllAcrossRestTime(cur_shiftInfoCominfoBean.getAllAcrossRestTime()); + shiftInfoBean.setAllLongWorkTime(cur_shiftInfoCominfoBean.getAllLongWorkTime()); + shiftInfoBean.setRestLongTimeIndex(cur_shiftInfoCominfoBean.getRestLongTimeIndex()); + shiftInfoBean.setWorkLongTimeIndex(cur_shiftInfoCominfoBean.getWorkLongTimeIndex()); + shiftInfoBean.setIsAcross(cur_shiftInfoCominfoBean.getIsAcross()); + shiftInfoBean.setSerialid(serialid); + shiftInfoBean.setShiftRuleMap(shiftRuleMap); + + if(cur_shiftInfoCominfoBean.getWorkAcrossLongTime() != null){ + List workTime1 = cur_shiftInfoCominfoBean.getWorkAcrossLongTime().stream().collect(Collectors.toList()); + List lsWorkTime = new KQWorkTime().formatTimeScope(workTime1, false); + shiftInfoBean.setWorkTime(lsWorkTime); + } + if(cur_shiftInfoCominfoBean.getSignWorkTime() != null){ + List signTime1 = cur_shiftInfoCominfoBean.getSignWorkTime().stream().collect(Collectors.toList()); + List lsSignTime = new KQWorkTime().formatTimeScope(signTime1, true); + shiftInfoBean.setSignTime(lsSignTime); + } + shiftInfoBean.setHalfcalrule(cur_shiftInfoCominfoBean.getHalfcalrule()); + shiftInfoBean.setHalfcalpoint(cur_shiftInfoCominfoBean.getHalfcalpoint()); + shiftInfoBean.setHalfcalpoint2cross(cur_shiftInfoCominfoBean.getHalfcalpoint2cross()); + shiftInfoBean.setWorkAcrossTime(cur_shiftInfoCominfoBean.getWorkAcrossTime()); + shiftInfoBean.setEachWorkMins(cur_shiftInfoCominfoBean.getEachWorkMins()); + shiftInfoBean.setConvertAttendDay(cur_shiftInfoCominfoBean.getConvertAttendDay()); + } + } + + public void removeShiftManagementCache(){ + KQShiftRestTimeSectionComInfo kqShiftRestTimeSectionComInfo = new KQShiftRestTimeSectionComInfo(); + KQShiftOnOffWorkSectionComInfo kqShiftOnOffWorkSectionComInfo = new KQShiftOnOffWorkSectionComInfo(); + kqShiftRestTimeSectionComInfo.removeShiftRestTimeSectionCache(); + kqShiftOnOffWorkSectionComInfo.removeShiftWorkSectionCache(); + super.removeCache(); + //改用redis和staticobj的方式 + KQShiftManagementRedis kqShiftManagementRedis = new KQShiftManagementRedis(); + kqShiftManagementRedis.resetShiftValWithRedis(); + } + + /** + * 根据班次获取shiftInfoCominfoBean + * @param serialid + * @return + */ + public ShiftInfoCominfoBean getShiftInfoCominfoBean(String serialid){ +// Object object = getObjValue(shiftbean, serialid); +// if(object != null){ +// return (ShiftInfoCominfoBean) object; +// }else{ +// return null; +// } + //改用redis和staticobj的方式 + KQShiftManagementRedis kqShiftManagementRedis = new KQShiftManagementRedis(); + return kqShiftManagementRedis.getShiftInfoBeanMapBySql(serialid); + } + + /** + * 根据人员和日期获取shiftInfoCominfoBean + * @param workdate + * @param serialidInfo + * @return + */ + public ShiftInfoCominfoBean getShiftInfoCominfoBean(String workdate,Map serialidInfo){ + ShiftInfoCominfoBean shiftInfoCominfoBean = null; + if(serialidInfo != null && !serialidInfo.isEmpty()){ + String serialid = Util.null2String(serialidInfo.get(workdate)); + if(Util.getIntValue(serialid) > 0){ + shiftInfoCominfoBean = getShiftInfoCominfoBean(serialid); + } + } + return shiftInfoCominfoBean; + } + + public boolean isFormat() { + return isFormat; + } + + public void setFormat(boolean format) { + isFormat = format; + } +} diff --git a/src/com/engine/kq/biz/KQShiftManagementRedis.java b/src/com/engine/kq/biz/KQShiftManagementRedis.java new file mode 100644 index 0000000..70f0cac --- /dev/null +++ b/src/com/engine/kq/biz/KQShiftManagementRedis.java @@ -0,0 +1,280 @@ +package com.engine.kq.biz; + +import com.cloudstore.dev.api.util.Util_DataCache; +import com.engine.kq.biz.chain.cominfo.HalfShiftComIndex; +import com.engine.kq.biz.chain.cominfo.RestShiftComIndex; +import com.engine.kq.biz.chain.cominfo.ShiftComIndex; +import com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean; +import com.engine.kq.biz.chain.cominfo.WorkShiftComIndex; +import com.engine.kq.log.KQLog; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import org.apache.commons.lang.math.NumberUtils; +import weaver.cluster.CacheManager; +import weaver.cluster.CacheMessage; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.StaticObj; +import weaver.general.Util; + +/** + * 班次管理缓存类 改成用redis的 + */ +public class KQShiftManagementRedis { + public static final String KQ_SHIFT_COMINFO_STATUS = "KQ_SHIFT_COMINFO_STATUS"; + + private static final BaseBean baseBean = new BaseBean(); + + /** + * 是否是E9 radis缓存方案。false:未启用radis。true:使用radis。 + */ + public static boolean isNewSession = false; + + /** + * 非集群,单节点服务器部署时,账号接收状态量获取方法。(线程安全的) + */ + public static ConcurrentHashMap KQ_SHIFT_COMINFO_STATUS_MAP = new ConcurrentHashMap(); + + // 初始化执行 + static { + useNewSessionMode(); + } + + /** + * 判断是否开启redis缓存。 + */ + public static void useNewSessionMode() { + String status = Util.null2String(baseBean.getPropValue("weaver_new_session", "status")).trim(); + isNewSession = "1".equals(status); + } + + private KQLog kqLog = new KQLog(); + + public void getShiftInfoBean(String serialid, String isresttimeopen, String worktime, + String punchsettings, + ConcurrentHashMap shiftInfoBeanMap, + String halfcalrule,String halfcalpoint,String halfcalpoint2cross, String overtimeRuleId, + String isRest, String convertAttendDay) throws Exception { + + Map workTimeMap = new HashMap<>(); + int workmins = 0; + List workTimes = Collections.synchronizedList(new ArrayList<>()); + List restTimes = Collections.synchronizedList(new ArrayList<>()); + KQShiftOnOffWorkSectionComInfo kqShiftOnOffWorkSectionComInfo = new KQShiftOnOffWorkSectionComInfo(); + KQShiftRestTimeSectionComInfo kqShiftRestTimeSectionComInfo = new KQShiftRestTimeSectionComInfo(); + + workTimes = kqShiftOnOffWorkSectionComInfo.getWorkSectionTimes(serialid); + if(workTimes != null && !workTimes.isEmpty()){ + if("1".equalsIgnoreCase(isresttimeopen)) { + //如果开启了才去判断 + restTimes = kqShiftRestTimeSectionComInfo.getRestSectionTimes(serialid); + } + if(NumberUtils.isNumber(worktime)){ + if(worktime.indexOf('.') == -1){ + workmins = Util.getIntValue(worktime,0); + }else { + worktime = worktime.substring(0,worktime.indexOf('.')); + workmins = Util.getIntValue(worktime,0); + } + + }else{ + workmins = 0; + kqLog.info("班次有问题,serialid:"+serialid+"工作时长为:"+worktime); + } + workTimeMap.put("workTime", workTimes); + workTimeMap.put("restTime", restTimes); + workTimeMap.put("serialid", serialid); + //工作时长分钟数 + workTimeMap.put("workmins", workmins+""); + workTimeMap.put("punchsettings", punchsettings); + workTimeMap.put("isresttimeopen", isresttimeopen); + workTimeMap.put("halfcalrule", halfcalrule); + workTimeMap.put("halfcalpoint", halfcalpoint); + workTimeMap.put("halfcalpoint2cross", halfcalpoint2cross); + workTimeMap.put("overtimeRuleId", overtimeRuleId); + workTimeMap.put("isRest", isRest); + workTimeMap.put("convertAttendDay", convertAttendDay); + + ShiftInfoCominfoBean shiftInfoCominfoBean = setShiftInfoBean(workTimeMap); + shiftInfoBeanMap.put(serialid, shiftInfoCominfoBean); + } + + } + + public ShiftInfoCominfoBean setShiftInfoBean(Map workTimeMap) throws Exception { + + ShiftComIndex workComIndex = new WorkShiftComIndex(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005306,weaver.general.ThreadVarLanguage.getLang())+"",workTimeMap); + ShiftComIndex restComIndex = new RestShiftComIndex(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005307,weaver.general.ThreadVarLanguage.getLang())+"",workTimeMap); + ShiftComIndex halfComIndex = new HalfShiftComIndex(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005308,weaver.general.ThreadVarLanguage.getLang())+"",workTimeMap); + //创建执行链 + //前一天的都执行完了,去获取当天工作时段,再执行半天的规则 + workComIndex.setDuration(restComIndex); + //执行完了半天的规则,再最后判断休息的时段 + restComIndex.setDuration(halfComIndex); + + ShiftInfoCominfoBean shiftInfoCominfoBean = new ShiftInfoCominfoBean(); + + workComIndex.handleDuration(shiftInfoCominfoBean); + return shiftInfoCominfoBean; + } + + public ConcurrentHashMap getShiftInfoBeanMap() { + ConcurrentHashMap shiftInfoBeanMap = new ConcurrentHashMap<>(); + kqLog = new KQLog(); + try { + + RecordSet rs = new RecordSet(); + String getShiftInfo = "select * from kq_ShiftManagement where 1=1 order by id "; + rs.executeQuery(getShiftInfo); + while(rs.next()){ + String serialid = rs.getString("id"); + try { + String isresttimeopen = rs.getString("isresttimeopen"); + String worktime = rs.getString("worktime"); + String punchsetting = "1"; + String halfcalrule = rs.getString("halfcalrule"); + halfcalrule = Util.null2String(halfcalrule).length() == 0 ? "0" : halfcalrule; + String halfcalpoint = rs.getString("halfcalpoint"); + String halfcalpoint2cross = rs.getString("halfcalpoint2cross"); + String overtimeRuleId = rs.getString("overtime_rule_id"); + String isRest = rs.getString("is_rest"); + String convertAttendDay = rs.getString("convert_attend_day"); + getShiftInfoBean(serialid,isresttimeopen,worktime,punchsetting,shiftInfoBeanMap,halfcalrule,halfcalpoint,halfcalpoint2cross,overtimeRuleId,isRest, + convertAttendDay); + } catch (Exception e) { + kqLog.info("班次缓存报错:getShiftInfoBeanMap:serialid:"+serialid); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + } + + } catch (Exception e) { + kqLog.info("班次缓存报错:getShiftInfoBeanMap:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + return shiftInfoBeanMap; + } + + + public ShiftInfoCominfoBean getShiftInfoBeanMapBySql(String serialid) { + ConcurrentHashMap shiftInfoBeanMap = new ConcurrentHashMap<>(); + kqLog = new KQLog(); + try { + RecordSet rs = new RecordSet(); + String getShiftInfo = "select * from kq_ShiftManagement where 1=1 and id=? order by id "; + rs.executeQuery(getShiftInfo,serialid); + if(rs.next()){ + String isresttimeopen = rs.getString("isresttimeopen"); + String worktime = rs.getString("worktime"); + String punchsetting = "1"; + String halfcalrule = rs.getString("halfcalrule"); + halfcalrule = Util.null2String(halfcalrule).length() == 0 ? "0" : halfcalrule; + String halfcalpoint = rs.getString("halfcalpoint"); + String halfcalpoint2cross = rs.getString("halfcalpoint2cross"); + String overtimeRuleId = rs.getString("overtime_rule_id"); + String isRest = rs.getString("is_rest"); + String convertAttendDay = rs.getString("convert_attend_day"); + getShiftInfoBean(serialid,isresttimeopen,worktime,punchsetting,shiftInfoBeanMap,halfcalrule,halfcalpoint,halfcalpoint2cross,overtimeRuleId,isRest,convertAttendDay); + } + if(shiftInfoBeanMap.containsKey(serialid)){ + return shiftInfoBeanMap.get(serialid); + } + + } catch (Exception e) { + kqLog.info("班次缓存报错:getShiftInfoBeanMapBySql:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + return null; + } + + /** + * 三套缓存,redis staticobj 和当前本身自制的map + * 把缓存数据重置下 + */ + public void resetShiftValWithRedis(){ + boolean isCluster = StaticObj.getInstance().isCluster(); + Map shiftInfoBeanMap = getShiftInfoBeanMap(); + if(isCluster) { + if(isNewSession) { + try { + Util_DataCache.setObjValWithRedis(KQ_SHIFT_COMINFO_STATUS, shiftInfoBeanMap); + } catch (IOException e) { + baseBean.writeLog(e); + StaticObj staticObj = StaticObj.getInstance(); + staticObj.putObject(KQ_SHIFT_COMINFO_STATUS, shiftInfoBeanMap); + sendNotificationToCache(CacheManager.ACTION_UPDATE, KQ_SHIFT_COMINFO_STATUS); + } + }else{ + StaticObj staticObj = StaticObj.getInstance(); + staticObj.putObject(KQ_SHIFT_COMINFO_STATUS, shiftInfoBeanMap); + sendNotificationToCache(CacheManager.ACTION_UPDATE, KQ_SHIFT_COMINFO_STATUS); + } + } else { + KQ_SHIFT_COMINFO_STATUS_MAP.put(KQ_SHIFT_COMINFO_STATUS, shiftInfoBeanMap); + } + } + + public ShiftInfoCominfoBean getShiftInfoBean(String serialid){ + ShiftInfoCominfoBean shiftInfoCominfoBean = null; + Map shiftInfoBeanMap = getShiftBeanMapValWithRedis(); + if(shiftInfoBeanMap == null){ + resetShiftValWithRedis(); + shiftInfoBeanMap = getShiftBeanMapValWithRedis(); + } + if(shiftInfoBeanMap != null && shiftInfoBeanMap.containsKey(serialid)){ + shiftInfoCominfoBean = shiftInfoBeanMap.get(serialid); + } + return shiftInfoCominfoBean; + } + + public Map getShiftBeanMapValWithRedis() { + Map shiftInfoBeanMap = null; + boolean isCluster = StaticObj.getInstance().isCluster(); + + if(isCluster) { // 判断是否是集群环境。true 是集群,false非集群 + if(isNewSession){ + try { + if(Util_DataCache.containsKeyWithRedis(KQ_SHIFT_COMINFO_STATUS)) { + shiftInfoBeanMap = (Map) Util_DataCache.getObjValWithRedis(KQ_SHIFT_COMINFO_STATUS); + } + }catch (Exception e){ + StaticObj staticObj = StaticObj.getInstance(); + shiftInfoBeanMap = (Map) staticObj.getObject(KQ_SHIFT_COMINFO_STATUS); + } + }else{ + StaticObj staticObj = StaticObj.getInstance(); + shiftInfoBeanMap = (Map) staticObj.getObject(KQ_SHIFT_COMINFO_STATUS); + } + } else { + shiftInfoBeanMap = (Map) KQ_SHIFT_COMINFO_STATUS_MAP.get(KQ_SHIFT_COMINFO_STATUS); + } + return shiftInfoBeanMap; + } + + /** + * 通知其他集群环境其他节点进行更新等操作. + * @param optType + * @param cacheKey + */ + public static void sendNotificationToCache(String optType, String cacheKey) { + StaticObj staticObj = StaticObj.getInstance(); + if(staticObj.isCluster()) { + CacheMessage msg = new CacheMessage(); + msg.setAction(optType); + msg.setCacheType(cacheKey); + staticObj.sendNotification(msg); + } + } +} diff --git a/src/com/engine/kq/biz/KQShiftOnOffWorkSectionComInfo.java b/src/com/engine/kq/biz/KQShiftOnOffWorkSectionComInfo.java new file mode 100644 index 0000000..3bc459d --- /dev/null +++ b/src/com/engine/kq/biz/KQShiftOnOffWorkSectionComInfo.java @@ -0,0 +1,262 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.log.KQLog; +import weaver.cache.*; +import weaver.conn.RecordSet; +import weaver.general.Util; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 班次一天内上下班次数缓存类 + */ +public class KQShiftOnOffWorkSectionComInfo extends CacheBase implements Serializable { + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化, 这个字段可以不定义 + */ + protected static String TABLE_NAME = ""; + + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化,或者不需要指定固定的条件, 这个字段可以不定义 + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = null; + + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化,或者不需要指定顺序, 这个字段可以不定义 sql中的order + * by信息,不要以order by开始 + * + */ + protected static String TABLE_ORDER = null; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + @CacheColumn + protected static int serial; + + private KQLog kqLog = new KQLog(); + + @Override + protected boolean autoInitIfNotFound() { + return false; + } + + @Override + public CacheMap initCache() { + CacheMap localData = createCacheMap(); + RecordSet rs = new RecordSet(); + kqLog = new KQLog(); + try { + List serials = new ArrayList<>(); + List workSectionList = new ArrayList<>(); + List sectionList = new ArrayList<>(); + Map serialMaps = new HashMap<>();//分组用的map + Map groupSectionMaps = new HashMap<>();//分组用的map + Map sectionMap = new HashMap<>(); + String serialidold = ""; + + String getStartWorkSections = "select * from kq_ShiftOnOffWorkSections where 1=1 order by serialid,record "; + rs.executeQuery(getStartWorkSections); + while (rs.next()) { + String id = Util.null2String(rs.getString("id")); + String serialid = Util.null2String(rs.getString("serialid")); + String across = Util.null2String(rs.getString("across")); + String times = Util.null2String(rs.getString("times")); + String mins = Util.null2String(rs.getString("mins")); + //增加了打卡规则,每一个班次的时间点都有允许打卡开始时间和结束时间,这个_next就是和mins相对应的打卡开始和结束时间 + String mins_next = Util.null2s(rs.getString("mins_next"),"-1"); + String record = Util.null2String(rs.getString("record")); + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + + sectionMap = new HashMap<>(); + sectionMap.put("across", across); + sectionMap.put("times", times); + sectionMap.put("mins", mins); + sectionMap.put("mins_next", mins_next); + + if(serialMaps.get(serialid) != null){ + Map tmpgroupSectionMaps = (Map)serialMaps.get(serialid); + if(tmpgroupSectionMaps.get(record) != null){ + List tmpWorkSection = (List) tmpgroupSectionMaps.get(record); + List tmpSection = ((List)tmpWorkSection.get(tmpWorkSection.size()-1)); + if("start".equalsIgnoreCase(onoffworktype)){ + tmpSection.set(0, sectionMap); + }else if("end".equalsIgnoreCase(onoffworktype)){ + tmpSection.set(1, sectionMap); + } + }else{ + workSectionList = new ArrayList<>(); + sectionList = new ArrayList<>(); + sectionList.add(""); + sectionList.add(""); + if("start".equalsIgnoreCase(onoffworktype)){ + sectionList.set(0, sectionMap); + }else if("end".equalsIgnoreCase(onoffworktype)){ + sectionList.set(1, sectionMap); + } + workSectionList.add(sectionList); + tmpgroupSectionMaps.put(record, workSectionList); + } + }else{ + groupSectionMaps = new HashMap<>(); + workSectionList = new ArrayList<>(); + serialMaps.put(serialid, groupSectionMaps); + if(groupSectionMaps.get(record) != null){ + List tmpWorkSection = (List) groupSectionMaps.get(record); + List tmpSection = ((List)tmpWorkSection.get(tmpWorkSection.size()-1)); + if("start".equalsIgnoreCase(onoffworktype)){ + tmpSection.set(0, sectionMap); + }else if("end".equalsIgnoreCase(onoffworktype)){ + tmpSection.set(1, sectionMap); + } + }else{ + sectionList = new ArrayList<>(); + sectionList.add(""); + sectionList.add(""); + if("start".equalsIgnoreCase(onoffworktype)){ + sectionList.set(0, sectionMap); + }else if("end".equalsIgnoreCase(onoffworktype)){ + sectionList.set(1, sectionMap); + } + workSectionList.add(sectionList); + groupSectionMaps.put(record, workSectionList); + } + } + } + + List valList = new ArrayList<>(); + for(Map.Entry me : serialMaps.entrySet()){ + valList = new ArrayList<>(); + String id = me.getKey(); + Map val = (Map)me.getValue(); + for(Map.Entry mee : val.entrySet()){ + valList.addAll((List)mee.getValue()); + } + CacheItem cacheItem = createCacheItem(); + cacheItem.set(PK_INDEX, id); + cacheItem.set(serial, valList); + modifyCacheItem(id, cacheItem); + localData.put(id, cacheItem); + } + } catch (Exception e) { + writeLog(e); + } + return localData; + } + + /** + * 根据班次id获取工作时段 + * @param serialid + * @return + */ + public List getWorkSectionTimes(String serialid){ + //return (List) getObjValue(serial, serialid); + RecordSet rs = new RecordSet(); + kqLog = new KQLog(); + List valList = new ArrayList<>(); + List workSectionList = new ArrayList<>(); + try { + List serials = new ArrayList<>(); + List sectionList = new ArrayList<>(); + Map serialMaps = new HashMap<>();//分组用的map + Map groupSectionMaps = new HashMap<>();//分组用的map + Map sectionMap = new HashMap<>(); + String serialidold = ""; + + String getStartWorkSections = "select * from kq_ShiftOnOffWorkSections where serialid=? order by serialid,record "; + rs.executeQuery(getStartWorkSections,serialid); + while (rs.next()) { + String id = Util.null2String(rs.getString("id")); + //String serialid = Util.null2String(rs.getString("serialid")); + String across = Util.null2String(rs.getString("across")); + String times = Util.null2String(rs.getString("times")); + String mins = Util.null2String(rs.getString("mins")); + //增加了打卡规则,每一个班次的时间点都有允许打卡开始时间和结束时间,这个_next就是和mins相对应的打卡开始和结束时间 + String mins_next = Util.null2s(rs.getString("mins_next"),"-1"); + String record = Util.null2String(rs.getString("record")); + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + + sectionMap = new HashMap<>(); + sectionMap.put("across", across); + sectionMap.put("times", times); + sectionMap.put("mins", mins); + sectionMap.put("mins_next", mins_next); + + if(serialMaps.get(serialid) != null){ + Map tmpgroupSectionMaps = (Map)serialMaps.get(serialid); + if(tmpgroupSectionMaps.get(record) != null){ + List tmpWorkSection = (List) tmpgroupSectionMaps.get(record); + List tmpSection = ((List)tmpWorkSection.get(tmpWorkSection.size()-1)); + if("start".equalsIgnoreCase(onoffworktype)){ + tmpSection.set(0, sectionMap); + }else if("end".equalsIgnoreCase(onoffworktype)){ + tmpSection.set(1, sectionMap); + } + }else{ + workSectionList = new ArrayList<>(); + sectionList = new ArrayList<>(); + sectionList.add(""); + sectionList.add(""); + if("start".equalsIgnoreCase(onoffworktype)){ + sectionList.set(0, sectionMap); + }else if("end".equalsIgnoreCase(onoffworktype)){ + sectionList.set(1, sectionMap); + } + workSectionList.add(sectionList); + tmpgroupSectionMaps.put(record, workSectionList); + } + }else{ + groupSectionMaps = new HashMap<>(); + workSectionList = new ArrayList<>(); + serialMaps.put(serialid, groupSectionMaps); + if(groupSectionMaps.get(record) != null){ + List tmpWorkSection = (List) groupSectionMaps.get(record); + List tmpSection = ((List)tmpWorkSection.get(tmpWorkSection.size()-1)); + if("start".equalsIgnoreCase(onoffworktype)){ + tmpSection.set(0, sectionMap); + }else if("end".equalsIgnoreCase(onoffworktype)){ + tmpSection.set(1, sectionMap); + } + }else{ + sectionList = new ArrayList<>(); + sectionList.add(""); + sectionList.add(""); + if("start".equalsIgnoreCase(onoffworktype)){ + sectionList.set(0, sectionMap); + }else if("end".equalsIgnoreCase(onoffworktype)){ + sectionList.set(1, sectionMap); + } + workSectionList.add(sectionList); + groupSectionMaps.put(record, workSectionList); + } + } + } + + for(Map.Entry me : serialMaps.entrySet()){ + valList = new ArrayList<>(); + String id = me.getKey(); + Map val = (Map)me.getValue(); + for(Map.Entry mee : val.entrySet()){ + valList.addAll((List)mee.getValue()); + } + } + + } catch (Exception e) { + writeLog(e); + } + return valList; + } + + /** + * 删除缓存信息 + */ + public void removeShiftWorkSectionCache() { + removeCache(); + } +} diff --git a/src/com/engine/kq/biz/KQShiftPersonalizedRuleCominfo.java b/src/com/engine/kq/biz/KQShiftPersonalizedRuleCominfo.java new file mode 100644 index 0000000..77bd66b --- /dev/null +++ b/src/com/engine/kq/biz/KQShiftPersonalizedRuleCominfo.java @@ -0,0 +1,246 @@ +package com.engine.kq.biz; + +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; + +public class KQShiftPersonalizedRuleCominfo extends CacheBase { + + protected static String TABLE_NAME = "kq_ShiftPersonalizedRule"; + /** sql中的where信息,不要以where开始 */ + protected static String TABLE_WHERE = null; + /** sql中的order by信息,不要以order by开始 */ + protected static String TABLE_ORDER = "serialid"; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "serialid"; + + /** + * 外键 班次id 对应表ShiftManagement + */ + @CacheColumn(name = "id") + protected static int id; + + /** + * 允许迟到分钟数 + */ + @CacheColumn(name = "permitlateminutes") + protected static int permitlateminutes; + + /** + * 严重迟到分钟数 + */ + @CacheColumn(name = "seriouslateminutes") + protected static int seriouslateminutes; + + /** + * 迟到视作旷工分钟数 + */ + @CacheColumn(name = "lateabsentminutes") + protected static int lateabsentminutes; + + /** + * 允许早退分钟数 + */ + @CacheColumn(name = "permitleaveearlyminutes") + protected static int permitleaveearlyminutes; + + /** + * 严重早退分钟数 + */ + @CacheColumn(name = "seriousleaveearlyminutes") + protected static int seriousleaveearlyminutes; + + /** + * 早退视作旷工分钟数 + */ + @CacheColumn(name = "leaveearlyabsentminutes") + protected static int leaveearlyabsentminutes; + + /** + * 允许迟到是否开启 + */ + @CacheColumn(name = "permitlatestatus") + protected static int permitlatestatus; + + /** + * 严重迟到是否开启 + */ + @CacheColumn(name = "seriouslatestatus") + protected static int seriouslatestatus; + + /** + * 迟到视作旷工是否开启 + */ + @CacheColumn(name = "lateabsentstatus") + protected static int lateabsentstatus; + + /** + * 允许早退是否开启 + */ + @CacheColumn(name = "permitleaveearlystatus") + protected static int permitleaveearlystatus; + + /** + * 严重早退是否开启 + */ + @CacheColumn(name = "seriousleaveearlystatus") + protected static int seriousleaveearlystatus; + + /** + * 早退视作旷工是否开启 + */ + @CacheColumn(name = "leaveearlyabsentstatus") + protected static int leaveearlyabsentstatus; + + /** + * 是否排除迟到分钟数 + */ + @CacheColumn(name = "enableexcludelate") + protected static int enableexcludelate; + + /** + * 是否排除早退分钟数 + */ + @CacheColumn(name = "enableexcludeleaveearly") + protected static int enableexcludeleaveearly; + + /** + * 删除标识1标识删除 + */ + @CacheColumn(name = "isdelete") + protected static int isdelete; + + public String getSerialId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getID() { + return (String)getRowValue(id); + } + + public String getID(String key) { + return (String)getValue(id,key); + } + + public String getPermitlateminutes() { + return (String)getRowValue(permitlateminutes); + } + + public String getPermitlateminutes(String key) { + return (String)getValue(permitlateminutes,key); + } + + public String getSeriouslateminutes() { + return (String)getRowValue(seriouslateminutes); + } + + public String getSeriouslateminutes(String key) { + return (String)getValue(seriouslateminutes,key); + } + + public String getLateabsentminutes() { + return (String)getRowValue(lateabsentminutes); + } + + public String getLateabsentminutes(String key) { + return (String)getValue(lateabsentminutes,key); + } + + public String getPermitleaveearlyminutes() { + return (String)getRowValue(permitleaveearlyminutes); + } + + public String getPermitleaveearlyminutes(String key) { + return (String)getValue(permitleaveearlyminutes,key); + } + + public String getSeriousleaveearlyminutes() { + return (String)getRowValue(seriousleaveearlyminutes); + } + + public String getSeriousleaveearlyminutes(String key) { + return (String)getValue(seriousleaveearlyminutes,key); + } + + public String getLeaveearlyabsentminutes() { + return (String)getRowValue(leaveearlyabsentminutes); + } + + public String getLeaveearlyabsentminutes(String key) { + return (String)getValue(leaveearlyabsentminutes,key); + } + + public String getPermitlatestatus() { + return (String)getRowValue(permitlatestatus); + } + + public String getPermitlatestatus(String key) { + return (String)getValue(permitlatestatus,key); + } + + public String getSeriouslatestatus() { + return (String)getRowValue(seriouslatestatus); + } + + public String getSeriouslatestatus(String key) { + return (String)getValue(seriouslatestatus,key); + } + + public String getLateabsentstatus() { + return (String)getRowValue(lateabsentstatus); + } + + public String getLateabsentstatus(String key) { + return (String)getValue(lateabsentstatus,key); + } + + public String getPermitleaveearlystatus() { + return (String)getRowValue(permitleaveearlystatus); + } + + public String getPermitleaveearlystatus(String key) { + return (String)getValue(permitleaveearlystatus,key); + } + + public String getSeriousleaveearlystatus() { + return (String)getRowValue(seriousleaveearlystatus); + } + + public String getSeriousleaveearlystatus(String key) { + return (String)getValue(seriousleaveearlystatus,key); + } + + public String getLeaveearlyabsentstatus() { + return (String)getRowValue(leaveearlyabsentstatus); + } + + public String getLeaveearlyabsentstatus(String key) { + return (String)getValue(leaveearlyabsentstatus,key); + } + + public String getEnableexcludelate() { + return (String)getRowValue(enableexcludelate); + } + + public String getEnableexcludelate(String key) { + return (String)getValue(enableexcludelate,key); + } + + public String getEnableexcludeleaveearly() { + return (String)getRowValue(enableexcludeleaveearly); + } + + public String getEnableexcludeleaveearly(String key) { + return (String)getValue(enableexcludeleaveearly,key); + } + + public String getIsdelete() { + return (String)getRowValue(isdelete); + } + + public String getIsdelete(String key) { + return (String)getValue(isdelete,key); + } +} diff --git a/src/com/engine/kq/biz/KQShiftPersonalizedRuleDetailComInfo.java b/src/com/engine/kq/biz/KQShiftPersonalizedRuleDetailComInfo.java new file mode 100644 index 0000000..9625fc9 --- /dev/null +++ b/src/com/engine/kq/biz/KQShiftPersonalizedRuleDetailComInfo.java @@ -0,0 +1,308 @@ +package com.engine.kq.biz; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +import com.engine.kq.log.KQLog; +import weaver.cache.*; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.StaticObj; +import weaver.general.Util; + +/** + * 人性化班次设置其他规则缓存类 + */ +public class KQShiftPersonalizedRuleDetailComInfo extends CacheBase implements Serializable { + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化, 这个字段可以不定义 + */ + protected static String TABLE_NAME = ""; + + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化,或者不需要指定固定的条件, 这个字段可以不定义 + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = null; + + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化,或者不需要指定顺序, 这个字段可以不定义 sql中的order + * by信息,不要以order by开始 + * + */ + protected static String TABLE_ORDER = null; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + @CacheColumn + protected static int serial; + + private KQLog kqLog = new KQLog(); + + @Override + protected boolean autoInitIfNotFound() { + return false; + } + + @Override + public CacheMap initCache() { + CacheMap localData = createCacheMap(); + RecordSet rs = new RecordSet(); + kqLog = new KQLog(); + try { + List workSectionList = new ArrayList<>(); + Map serialMaps = new HashMap<>();//分组用的map + Map groupSectionMaps = new HashMap<>();//分组用的map + Map sectionMap = new HashMap<>(); + + //给考勤报表提供,排序方式如下 + String ruleSql = ""; + ruleSql = "select * from kq_ShiftPersonalizedRuleDetail where ruledetailtype='lateinlateout' order by personalizedruleid,postponetime desc "; + rs.executeQuery(ruleSql); + while (rs.next()) { + String id = Util.null2String(rs.getString("id")); + String personalizedruleid = Util.null2String(rs.getString("personalizedruleid")); + String enable = Util.null2String(rs.getString("enable")); + String enablesame = Util.null2String(rs.getString("enablesame")); + if (!"1".equalsIgnoreCase(enable)) { + //只取启用的 + continue; + } + //第一天下班晚走 + String advancetime = Util.null2String(rs.getString("advancetime")); + //第二天上班可以晚到 + String postponetime = Util.null2String(rs.getString("postponetime")); + String ruledetailtype = Util.null2String(rs.getString("ruledetailtype")); + String record = Util.null2String(rs.getString("record")); + + sectionMap = new HashMap<>(); + sectionMap.put("enable", enable); + sectionMap.put("enablesame", enablesame); + sectionMap.put("advancetime", advancetime); + sectionMap.put("postponetime", postponetime); + sectionMap.put("record", record); + if(serialMaps.get(personalizedruleid) != null){ + Map groupSectionMapsTmp = (Map)serialMaps.get(personalizedruleid); + if(groupSectionMapsTmp.get(ruledetailtype) != null){ + List workSectionListTmp = (List)groupSectionMapsTmp.get(ruledetailtype); + workSectionListTmp.add(sectionMap); + }else{ + workSectionList = new ArrayList<>(); + workSectionList.add(sectionMap); + groupSectionMapsTmp.put(ruledetailtype, workSectionList); + } + }else{ + groupSectionMaps = new HashMap<>(); + serialMaps.put(personalizedruleid, groupSectionMaps); + if(groupSectionMaps.get(ruledetailtype) != null){ + List workSectionListTmp = (List)groupSectionMaps.get(ruledetailtype); + workSectionListTmp.add(sectionMap); + }else{ + workSectionList = new ArrayList<>(); + workSectionList.add(sectionMap); + groupSectionMaps.put(ruledetailtype, workSectionList); + } + + } + } + + ruleSql = "select * from kq_ShiftPersonalizedRuleDetail where ruledetailtype in ('earlyinearlyout','lateoutlatein') order by personalizedruleid,advancetime desc "; + rs.executeQuery(ruleSql); + while (rs.next()) { + String id = Util.null2String(rs.getString("id")); + String personalizedruleid = Util.null2String(rs.getString("personalizedruleid")); + String enable = Util.null2String(rs.getString("enable")); + String enablesame = Util.null2String(rs.getString("enablesame")); + if (!"1".equalsIgnoreCase(enable)) { + //只取启用的 + continue; + } + //第一天下班晚走 + String advancetime = Util.null2String(rs.getString("advancetime")); + //第二天上班可以晚到 + String postponetime = Util.null2String(rs.getString("postponetime")); + String ruledetailtype = Util.null2String(rs.getString("ruledetailtype")); + String record = Util.null2String(rs.getString("record")); + + sectionMap = new HashMap<>(); + sectionMap.put("enable", enable); + sectionMap.put("enablesame", enablesame); + sectionMap.put("advancetime", advancetime); + sectionMap.put("postponetime", postponetime); + sectionMap.put("record", record); + if(serialMaps.get(personalizedruleid) != null){ + Map groupSectionMapsTmp = (Map)serialMaps.get(personalizedruleid); + if(groupSectionMapsTmp.get(ruledetailtype) != null){ + List workSectionListTmp = (List)groupSectionMapsTmp.get(ruledetailtype); + workSectionListTmp.add(sectionMap); + }else{ + workSectionList = new ArrayList<>(); + workSectionList.add(sectionMap); + groupSectionMapsTmp.put(ruledetailtype, workSectionList); + } + }else{ + groupSectionMaps = new HashMap<>(); + serialMaps.put(personalizedruleid, groupSectionMaps); + if(groupSectionMaps.get(ruledetailtype) != null){ + List workSectionListTmp = (List)groupSectionMaps.get(ruledetailtype); + workSectionListTmp.add(sectionMap); + }else{ + workSectionList = new ArrayList<>(); + workSectionList.add(sectionMap); + groupSectionMaps.put(ruledetailtype, workSectionList); + } + + } + } + + for(Map.Entry me : serialMaps.entrySet()){ + String id = me.getKey(); + Map val = (Map)me.getValue(); + CacheItem cacheItem = createCacheItem(); + cacheItem.set(PK_INDEX, id); + cacheItem.set(serial, val); + modifyCacheItem(id, cacheItem); + localData.put(id, cacheItem); + } + } catch (Exception e) { + writeLog(e); + } + return localData; + } + + /** + * 根据班次个性化设置id获取详细信息 + * @param personalizedruleid + * @return + */ + public Map getPersonalizedRuleDetail(String personalizedruleid){ + return (Map) getObjValue(serial, personalizedruleid); + } + + public Map getPersonalizedRuleDetail_sql(String personalizedruleid){ + Map groupSectionMaps = new HashMap<>();//分组用的map + CacheMap localData = createCacheMap(); + RecordSet rs = new RecordSet(); + kqLog = new KQLog(); + try { + List workSectionList = new ArrayList<>(); + Map serialMaps = new HashMap<>();//分组用的map + Map sectionMap = new HashMap<>(); + + //给考勤报表提供,排序方式如下 + String ruleSql = ""; + ruleSql = "select * from kq_ShiftPersonalizedRuleDetail where personalizedruleid=? and ruledetailtype='lateinlateout' order by personalizedruleid,postponetime desc "; + rs.executeQuery(ruleSql,personalizedruleid); + while (rs.next()) { + String id = Util.null2String(rs.getString("id")); + String enable = Util.null2String(rs.getString("enable")); + String enablesame = Util.null2String(rs.getString("enablesame")); + if (!"1".equalsIgnoreCase(enable)) { + //只取启用的 + continue; + } + //第一天下班晚走 + String advancetime = Util.null2String(rs.getString("advancetime")); + //第二天上班可以晚到 + String postponetime = Util.null2String(rs.getString("postponetime")); + String ruledetailtype = Util.null2String(rs.getString("ruledetailtype")); + String record = Util.null2String(rs.getString("record")); + + sectionMap = new HashMap<>(); + sectionMap.put("enable", enable); + sectionMap.put("enablesame", enablesame); + sectionMap.put("advancetime", advancetime); + sectionMap.put("postponetime", postponetime); + sectionMap.put("record", record); + if(serialMaps.get(personalizedruleid) != null){ + Map groupSectionMapsTmp = (Map)serialMaps.get(personalizedruleid); + if(groupSectionMapsTmp.get(ruledetailtype) != null){ + List workSectionListTmp = (List)groupSectionMapsTmp.get(ruledetailtype); + workSectionListTmp.add(sectionMap); + }else{ + workSectionList = new ArrayList<>(); + workSectionList.add(sectionMap); + groupSectionMapsTmp.put(ruledetailtype, workSectionList); + } + }else{ + groupSectionMaps = new HashMap<>(); + serialMaps.put(personalizedruleid, groupSectionMaps); + if(groupSectionMaps.get(ruledetailtype) != null){ + List workSectionListTmp = (List)groupSectionMaps.get(ruledetailtype); + workSectionListTmp.add(sectionMap); + }else{ + workSectionList = new ArrayList<>(); + workSectionList.add(sectionMap); + groupSectionMaps.put(ruledetailtype, workSectionList); + } + + } + } + + ruleSql = "select * from kq_ShiftPersonalizedRuleDetail where personalizedruleid=? and ruledetailtype in ('earlyinearlyout','lateoutlatein') order by personalizedruleid,advancetime desc "; + rs.executeQuery(ruleSql,personalizedruleid); + while (rs.next()) { + String id = Util.null2String(rs.getString("id")); + String enable = Util.null2String(rs.getString("enable")); + String enablesame = Util.null2String(rs.getString("enablesame")); + if (!"1".equalsIgnoreCase(enable)) { + //只取启用的 + continue; + } + //第一天下班晚走 + String advancetime = Util.null2String(rs.getString("advancetime")); + //第二天上班可以晚到 + String postponetime = Util.null2String(rs.getString("postponetime")); + String ruledetailtype = Util.null2String(rs.getString("ruledetailtype")); + String record = Util.null2String(rs.getString("record")); + + sectionMap = new HashMap<>(); + sectionMap.put("enable", enable); + sectionMap.put("enablesame", enablesame); + sectionMap.put("advancetime", advancetime); + sectionMap.put("postponetime", postponetime); + sectionMap.put("record", record); + if(serialMaps.get(personalizedruleid) != null){ + Map groupSectionMapsTmp = (Map)serialMaps.get(personalizedruleid); + if(groupSectionMapsTmp.get(ruledetailtype) != null){ + List workSectionListTmp = (List)groupSectionMapsTmp.get(ruledetailtype); + workSectionListTmp.add(sectionMap); + }else{ + workSectionList = new ArrayList<>(); + workSectionList.add(sectionMap); + groupSectionMapsTmp.put(ruledetailtype, workSectionList); + } + }else{ + groupSectionMaps = new HashMap<>(); + serialMaps.put(personalizedruleid, groupSectionMaps); + if(groupSectionMaps.get(ruledetailtype) != null){ + List workSectionListTmp = (List)groupSectionMaps.get(ruledetailtype); + workSectionListTmp.add(sectionMap); + }else{ + workSectionList = new ArrayList<>(); + workSectionList.add(sectionMap); + groupSectionMaps.put(ruledetailtype, workSectionList); + } + + } + } + + } catch (Exception e) { + writeLog(e); + } + return groupSectionMaps; + } + + /** + * 删除缓存信息 + */ + public void removePersonalizedRuleDetailCache() { + removeCache(); + } + +} diff --git a/src/com/engine/kq/biz/KQShiftRestTimeSectionComInfo.java b/src/com/engine/kq/biz/KQShiftRestTimeSectionComInfo.java new file mode 100644 index 0000000..4cab68f --- /dev/null +++ b/src/com/engine/kq/biz/KQShiftRestTimeSectionComInfo.java @@ -0,0 +1,242 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.log.KQLog; +import weaver.cache.*; +import weaver.conn.RecordSet; +import weaver.general.Util; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 班次休息时段设置缓存类 + */ +public class KQShiftRestTimeSectionComInfo extends CacheBase implements Serializable { + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化, 这个字段可以不定义 + */ + protected static String TABLE_NAME = ""; + + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化,或者不需要指定固定的条件, 这个字段可以不定义 + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = null; + + /* + * 需要关注 : 如果完全在 initCache 自己定义数据初始化,或者不需要指定顺序, 这个字段可以不定义 sql中的order + * by信息,不要以order by开始 + * + */ + protected static String TABLE_ORDER = null; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + @CacheColumn + protected static int serial; + + private KQLog kqLog = new KQLog(); + + @Override + protected boolean autoInitIfNotFound() { + return false; + } + + @Override + public CacheMap initCache() { + CacheMap localData = createCacheMap(); + RecordSet rs = new RecordSet(); + kqLog = new KQLog(); + + List restSectionList = new ArrayList<>(); + List sectionList = new ArrayList<>(); + Map sectionMap = new HashMap<>(); + + Map serialMaps = new HashMap<>();//分组用的map + try { + String getRestSections = "select * from kq_ShiftRestTimeSections where 1=1 "; + rs.executeQuery(getRestSections); + while(rs.next()){ + String id = Util.null2String(rs.getString("id")); + sectionMap = new HashMap<>(); + String serialid = Util.null2String(rs.getString("serialid")); + String resttype = Util.null2String(rs.getString("resttype")); + String across = Util.null2String(rs.getString("across")); + String times = Util.null2String(rs.getString("time")); + sectionMap.put("across", across); + sectionMap.put("times", times); + + if(serialMaps.get(serialid) != null){ + List tmpList = (List)serialMaps.get(serialid); + if("start".equalsIgnoreCase(resttype)){ + tmpList.set(0, sectionMap); + }else if("end".equalsIgnoreCase(resttype)){ + tmpList.set(1, sectionMap); + } + }else{ + restSectionList = new ArrayList<>(); + sectionList = new ArrayList<>(); + sectionList.add(""); + sectionList.add(""); + if("start".equalsIgnoreCase(resttype)){ + sectionList.set(0, sectionMap); + }else if("end".equalsIgnoreCase(resttype)){ + sectionList.set(1, sectionMap); + } + restSectionList.addAll(sectionList); + serialMaps.put(serialid, restSectionList); + + } + } + + for(Map.Entry me : serialMaps.entrySet()){ + String id = me.getKey(); + List valList = (List)me.getValue(); + CacheItem cacheItem = createCacheItem(); + cacheItem.set(PK_INDEX, id); + cacheItem.set(serial, valList); + modifyCacheItem(id, cacheItem); + localData.put(id, cacheItem); + } + }catch (Exception e){ + writeLog(e); + } + return localData; + } + + /** + * 根据班次id获取休息时段集合 + * @param serialid + * @return + */ + public List getRestSectionTimesList(String serialid){ + + String startSql = "select * from kq_ShiftRestTimeSections where (isdelete is null or isdelete <> '1') and resttype='start' and serialid = ? "; + String endSql = "select * from kq_ShiftRestTimeSections where (isdelete is null or isdelete <> '1') and resttype='end' and serialid = ? "; + List restList = new ArrayList<>(); + RecordSet rstemp=new RecordSet(); + rstemp.executeQuery(startSql, serialid); + while(rstemp.next()){ + String times = rstemp.getString("time"); + String[] timeArr = new String[2]; + timeArr[0] = times; + restList.add(timeArr); + } + + int i = 0; + rstemp=new RecordSet(); + rstemp.executeQuery(endSql, serialid); + while(rstemp.next()){ + String times = rstemp.getString("time"); + String[] timeArr = restList.get(i); + timeArr[1] = times; + i++; + } + + return restList; + } + /** + * 根据班次获取休息时段 + * @param serialid + * @return + */ + public List getRestSectionTimes(String serialid){ + //return (List) getObjValue(serial, serialid); + RecordSet rs = new RecordSet(); + kqLog = new KQLog(); + + List valList = new ArrayList<>(); + List restSectionList = new ArrayList<>(); + List sectionList = new ArrayList<>(); + Map sectionMap = new HashMap<>(); + + Map serialMaps = new HashMap<>();//分组用的map + Map groupSectionMaps = new HashMap<>();//分组用的map + try { + String getRestSections = "select * from kq_ShiftRestTimeSections where serialid=? order by orderId "; + rs.executeQuery(getRestSections,serialid); + while(rs.next()){ + String id = Util.null2String(rs.getString("id")); + sectionMap = new HashMap<>(); + String resttype = Util.null2String(rs.getString("resttype")); + String across = Util.null2String(rs.getString("across")); + String times = Util.null2String(rs.getString("time")); + String record = Util.null2String(rs.getString("record1")); + sectionMap.put("across", across); + sectionMap.put("times", times); + + if(serialMaps.get(serialid) != null){ + Map tmpgroupSectionMaps = (Map)serialMaps.get(serialid); + if(tmpgroupSectionMaps.get(record) != null){ + List tmpWorkSection = (List) tmpgroupSectionMaps.get(record); + List tmpSection = ((List)tmpWorkSection.get(tmpWorkSection.size()-1)); + if("start".equalsIgnoreCase(resttype)){ + tmpSection.set(0, sectionMap); + }else if("end".equalsIgnoreCase(resttype)){ + tmpSection.set(1, sectionMap); + } + }else{ + restSectionList = new ArrayList<>(); + sectionList = new ArrayList<>(); + sectionList.add(""); + sectionList.add(""); + if("start".equalsIgnoreCase(resttype)){ + sectionList.set(0, sectionMap); + }else if("end".equalsIgnoreCase(resttype)){ + sectionList.set(1, sectionMap); + } + restSectionList.add(sectionList); + tmpgroupSectionMaps.put(record, restSectionList); + } + }else{ + groupSectionMaps = new HashMap<>(); + restSectionList = new ArrayList<>(); + serialMaps.put(serialid, groupSectionMaps); + if(groupSectionMaps.get(record) != null){ + List tmpWorkSection = (List) groupSectionMaps.get(record); + List tmpSection = ((List)tmpWorkSection.get(tmpWorkSection.size()-1)); + if("start".equalsIgnoreCase(resttype)){ + tmpSection.set(0, sectionMap); + }else if("end".equalsIgnoreCase(resttype)){ + tmpSection.set(1, sectionMap); + } + }else{ + sectionList = new ArrayList<>(); + sectionList.add(""); + sectionList.add(""); + if("start".equalsIgnoreCase(resttype)){ + sectionList.set(0, sectionMap); + }else if("end".equalsIgnoreCase(resttype)){ + sectionList.set(1, sectionMap); + } + restSectionList.add(sectionList); + groupSectionMaps.put(record, restSectionList); + } + } + } + for(Map.Entry me : serialMaps.entrySet()){ + valList = new ArrayList<>(); + Map val = (Map)me.getValue(); + for(Map.Entry mee : val.entrySet()){ + valList.addAll((List)mee.getValue()); + } + } + + }catch (Exception e){ + writeLog(e); + } + return valList; + } + + /** + * 删除缓存信息 + */ + public void removeShiftRestTimeSectionCache() { + removeCache(); + } +} diff --git a/src/com/engine/kq/biz/KQShiftRuleInfoBiz.java b/src/com/engine/kq/biz/KQShiftRuleInfoBiz.java new file mode 100644 index 0000000..c976d63 --- /dev/null +++ b/src/com/engine/kq/biz/KQShiftRuleInfoBiz.java @@ -0,0 +1,1558 @@ +package com.engine.kq.biz; + +import com.engine.kq.bean.KQHrmScheduleSign; +import com.engine.kq.biz.chain.cominfo.HalfShiftComIndex; +import com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import weaver.common.DateUtil; +import weaver.general.BaseBean; +import weaver.general.Util; + +/** + * 考勤班次个性化设置 + */ +public class KQShiftRuleInfoBiz { + + public static KQLog kqLog = new KQLog(); + + public static void getShiftRuleInfo(ShiftInfoBean shiftInfoBean, String resourceId,Map shifRuleMap,List logList) { + getShiftRuleInfo(shiftInfoBean, resourceId, shifRuleMap, true,logList); + } + + public static void getShiftRuleInfo(ShiftInfoBean shiftInfoBean, String resourceId,Map shifRuleMap) { + getShiftRuleInfo(shiftInfoBean, resourceId, shifRuleMap, true); + } + + public static void getShiftRuleInfo(ShiftInfoBean shiftInfoBean, SplitBean splitBean,Map shifRuleMap) { + getShiftRuleInfo(shiftInfoBean, splitBean, shifRuleMap, true, Lists.newArrayList()); + } + + public static void getShiftRuleInfo(ShiftInfoBean shiftInfoBean, String resourceId,Map shifRuleMap,boolean need_lateoutlatein) { + getShiftRuleInfo(shiftInfoBean, resourceId, shifRuleMap, need_lateoutlatein, + Lists.newArrayList()); + } + + public static void getShiftRuleInfo(ShiftInfoBean shiftInfoBean, String resourceId,Map shifRuleMap,boolean need_lateoutlatein,List logList) { + boolean lateInlateOutWithFlow = KQSettingsBiz.showLeaveTypeSet("lateinlateout_kqflow"); + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter minFormatter = DateTimeFormatter.ofPattern("HH:mm"); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + List earlyinearlyout = null;//早到早走规则 + List lateinlateout = null;//晚到晚走规则 + List lateoutlatein = null;//晚走晚到规则 + if(shiftInfoBean == null){ + return ; + } + + String splitDate = shiftInfoBean.getSplitDate(); + String preDate = DateUtil.addDate(splitDate, -1);//上一天日期 + String nextDate = DateUtil.addDate(splitDate, 1);//下一天日期 + int signoutOnlyoff = shiftInfoBean.getSignoutOnlyoff(); + + KQWorkTime kqWorkTime = new KQWorkTime(); + kqWorkTime.setIsFormat(true); + String tmpKQPreDate = preDate; + if(KQSettingsBiz.is_lateoutlatein()) {//开启开关 + //前一天是非工作日,往前取到工作日 + for(int i=0;i<31;i++){ + WorkTimeEntity tmpworkTime = kqWorkTime.getWorkTime(resourceId, tmpKQPreDate); + if(tmpworkTime.getWorkMins()>0){ + break; + } + tmpKQPreDate = DateUtil.addDate(tmpKQPreDate, -1); + } + }else{ + //默认取前一天 + } + + WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceId, tmpKQPreDate); + if(workTime == null || (workTime.getWorkMins() == 0 && workTime.getNonWorkShift() != 1)){//如果前一天是休息日,那么直接就不需要走晚走晚到了,因为压根不存在前一天的晚走情况 + need_lateoutlatein = false; + }else{ + Map preshiftRuleMap = workTime.getShiftRuleInfo(); + if (preshiftRuleMap != null && !preshiftRuleMap.isEmpty() && preshiftRuleMap.containsKey("ruleDetail")) { + Map preruleDetail = (Map) preshiftRuleMap.get("ruleDetail"); + if(preruleDetail != null && !preruleDetail.isEmpty()){ + lateoutlatein = (List) preruleDetail.get("lateoutlatein");//晚走晚到应该取前一天的个性化班次的设置,而不是当天 + } + } + } + + Map shiftRuleMap = shiftInfoBean.getShiftRuleMap(); + if (shiftRuleMap != null && !shiftRuleMap.isEmpty() && shiftRuleMap.containsKey("ruleDetail")) {//处理人性化设置其他规则 + //允许迟到分钟数 + boolean usepermitlateminutes = Util.null2String(shiftRuleMap.get("permitlatestatus")).equals("1"); + //和蔡志军讨论,优先满足弹性,即如果晚到了,开启了弹性,那么就先按照弹性来处理,不满足弹性的部分再按照允许迟到来处理 + usepermitlateminutes = false; + int permitlateminutes = Util.getIntValue(Util.null2String(shiftRuleMap.get("permitlateminutes")), 0); +// //允许早退分钟数 +// boolean usepermitleaveearlyminutes = Util.null2String(shiftRuleMap.get("permitleaveearlystatus")).equals("1"); +// int permitleaveearlyminutes = Util.getIntValue(Util.null2String(shiftRuleMap.get("permitleaveearlyminutes")), 0); + + Map ruleDetail = (Map) shiftRuleMap.get("ruleDetail"); + if(ruleDetail != null && !ruleDetail.isEmpty()){ + earlyinearlyout = (List) ruleDetail.get("earlyinearlyout"); + lateinlateout = (List) ruleDetail.get("lateinlateout"); +// lateoutlatein = (List) ruleDetail.get("lateoutlatein"); +// String splitDate = shiftInfoBean.getSplitDate(); +// String preDate = DateUtil.addDate(splitDate, -1);//上一天日期 +// String nextDate = DateUtil.addDate(splitDate, 1);//下一天日期 +// KQWorkTime kqWorkTime = new KQWorkTime(); + //如果设置了个性化规则,需要先获取下打卡数据 + List lsSignTime = new ArrayList<>(); + List lsWorkTime = new ArrayList<>(); + List lsRestTime = new ArrayList<>(); + + lsSignTime = shiftInfoBean.getSignTime();//允许打卡时间 + lsWorkTime = shiftInfoBean.getWorkTime();//工作时间 + + //只有一次签到签退才有个性化的这些设置 + if(lsWorkTime != null && lsWorkTime.size() > 0){ + //早到早走后,引起下班时间变化后的时间 + LocalDateTime early_localEndDateTime = null; + //早到早走后,引起上班时间变化后的时间 + LocalDateTime early_localBeginDateTime = null; + //晚到晚走后,引起下班时间变化后的时间 + LocalDateTime late_localEndDateTime = null; + //晚到晚走后,引起上班时间变化后的时间 + LocalDateTime late_localBeginDateTime = null; + //晚走晚到后,引起上班时间变化后的时间 + LocalDateTime latein_localBeginDateTime = null; + + TimeScopeEntity signTimeScope = lsSignTime.get(0); + TimeScopeEntity workTimeScope = lsWorkTime.get(0); + + String signInDate = ""; + String signInTime = ""; + String signOutDate = ""; + String signOutTime = ""; + String workbeigintime = workTimeScope.getBeginTime(); + boolean beginTimeAcross = workTimeScope.getBeginTimeAcross(); + String workbegindate = splitDate; + if(beginTimeAcross){ + workbegindate = nextDate; + workbeigintime = kqTimesArrayComInfo.turn48to24Time(workbeigintime); + } + String workbegindatetime = workbegindate+" "+workbeigintime+":00"; + LocalDateTime localBeginDateTime = LocalDateTime.parse(workbegindatetime,fullFormatter); + + String workendtime = workTimeScope.getEndTime(); + boolean endTimeAcross = workTimeScope.getEndTimeAcross(); + String workenddate = splitDate; + if(endTimeAcross){ + workenddate = nextDate; + workendtime = kqTimesArrayComInfo.turn48to24Time(workendtime); + } + String workenddatetime = workenddate+" "+workendtime+":00"; + LocalDateTime localEndDateTime = LocalDateTime.parse(workenddatetime,fullFormatter); + + List lsCheckInfo = new KQFormatSignData().getSignInfo(resourceId,signTimeScope,workTimeScope,splitDate,preDate,nextDate,kqTimesArrayComInfo,Lists.newArrayList(), "",0,0,signoutOnlyoff); + if(lsCheckInfo.isEmpty()){ + //如果当天没有打卡数据,判断下是否存在昨天有打卡数据,晚走晚到的情况 + if ((lateoutlatein != null && lateoutlatein.size() > 0) || (lateinlateout != null && lateinlateout.size() > 0)) { + }else{ + return ; + } + } + + if(lsCheckInfo.size() > 1){ + for(int i = 0 ; i < lsCheckInfo.size() ; i++){ + Map checkInfo = (Map) lsCheckInfo.get(i); + if (checkInfo.get("signType").equals("1")) { + //签到 + signInDate = Util.null2String(checkInfo.get("signDate")); + signInTime = Util.null2String(checkInfo.get("signTime")); + } + if (checkInfo.get("signType").equals("2")) { + //签退 + signOutDate = Util.null2String(checkInfo.get("signDate")); + signOutTime = Util.null2String(checkInfo.get("signTime")); + } + } + }else if(lsCheckInfo.size() == 1){ + Map checkInfo = (Map) lsCheckInfo.get(0); + if (checkInfo.get("signType").equals("1")) { + //签到 + signInDate = Util.null2String(checkInfo.get("signDate")); + signInTime = Util.null2String(checkInfo.get("signTime")); + } + if (checkInfo.get("signType").equals("2")) { + //签退 + signOutDate = Util.null2String(checkInfo.get("signDate")); + signOutTime = Util.null2String(checkInfo.get("signTime")); + } + } + + if (need_lateoutlatein && lateoutlatein != null && lateoutlatein.size() > 0) { + + String log_str = ""; + KQFormatShiftRule kqFormatShiftRule = new KQFormatShiftRule(); + int preDayLateOutMins = kqFormatShiftRule.getPreDayLateOutMins(resourceId, splitDate,logList,signoutOnlyoff); + if(!logList.isEmpty()){ + for(int i = 0 ; i < logList.size() ; i++){ + if(i == 0){ + log_str += ""+logList.get(i); + }else{ + log_str += ","+logList.get(i); + } + } + logList.clear(); + } + int advancetimeValue = 0; + String log_str_temp = ""; + for (int i = 0; preDayLateOutMins > 0 && i < lateoutlatein.size(); i++) { + Map rule = (Map) lateoutlatein.get(i); + if (Util.null2String(rule.get("enable")).equals("1")) { + int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//晚走时间 + int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//允许晚到时间 + + boolean enablesame = Util.null2String(rule.get("enablesame")).equals("1"); + if (enablesame) { + if(log_str.length() > 0){ + log_str += ","+(" "+"开启了晚走晚到,"+(enablesame?"相对时间,前一天晚走,第二天可以晚到,弹性限额"+postponetime+"分钟":"绝对时间"+",前一天晚走"+advancetime+"分钟,第二天上班可以晚到"+postponetime+"分钟")); + }else{ + log_str += ""+(" "+"开启了晚走晚到,"+(enablesame?"相对时间,前一天晚走,第二天可以晚到,弹性限额"+postponetime+"分钟":"绝对时间"+",前一天晚走"+advancetime+"分钟,第二天上班可以晚到"+postponetime+"分钟")); + } + if(preDayLateOutMins >= advancetime){ + //如果昨日的晚走时长已经完全大于了设置的晚走时长,那么就可以晚到整个postponetime + latein_localBeginDateTime = localBeginDateTime.plusMinutes(postponetime); + }else{ + latein_localBeginDateTime = localBeginDateTime.plusMinutes(preDayLateOutMins); + } + break; + }else{ + if (preDayLateOutMins >= advancetime) { + //如果昨日的晚走时长已经完全大于了设置的晚走时长,那么就可以晚到整个postponetime + if(advancetimeValue 0){ + log_str_temp = ","+(" "+"开启了晚走晚到,"+(enablesame?"相对时间,前一天晚走,第二天可以晚到,弹性限额"+postponetime+"分钟":"绝对时间"+",前一天晚走"+advancetime+"分钟,第二天上班可以晚到"+postponetime+"分钟")); + }else{ + log_str_temp = ""+(" "+"开启了晚走晚到,"+(enablesame?"相对时间,前一天晚走,第二天可以晚到,弹性限额"+postponetime+"分钟":"绝对时间"+",前一天晚走"+advancetime+"分钟,第二天上班可以晚到"+postponetime+"分钟")); + } + } + }else{ + logList.clear(); + } + } + }else{ + logList.clear(); + } + } + log_str +=log_str_temp; + if(latein_localBeginDateTime != null){ + shifRuleMap.put("shift_type", "lateoutlatein"); + String beginDate = latein_localBeginDateTime.format(dateFormatter); + String beginmin = latein_localBeginDateTime.format(minFormatter); + // 前一天的晚到影响了今天的早到或者晚到 + workbegindatetime = latein_localBeginDateTime.format(fullFormatter); + localBeginDateTime = LocalDateTime.parse(workbegindatetime,fullFormatter); + log_str += ","+("满足了晚走晚到,所以今天的上班时间变化了,变成了:"+workbegindatetime+"-"+workenddatetime); + + shifRuleMap.put("shift_begindate", beginDate); + if(beginDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin)); + }else{ + shifRuleMap.put("shift_beginworktime", beginmin); + } + }else{ + log_str = ""; + } + if(log_str.length() > 0){ + logList.add(log_str); + }else{ + logList.clear(); + } + } + String log_str = ""; + long signIn_before_mins = 0; + long signIn_after_mins = 0; + long signOut_before_mins = 0; + long signOut_after_mins = 0; + + // 针对流程的特殊处理 + String flowFromDate = ""; + String flowToDate = ""; + String flowFromTime = ""; + String flowToTime = ""; + + String dateKey = resourceId + "|" + splitDate; + String kqDateNext = DateUtil.addDate(splitDate, 1); + KQFlowDataBiz kqFlowDataBiz = new KQFlowDataBiz.FlowDataParamBuilder().resourceidParam(resourceId).fromDateParam(splitDate).toDateParam(kqDateNext).build(); + Map workFlowInfo = new HashMap<>();//userid|date--工作流程 + List workFlow = null; + if(lateInlateOutWithFlow) { // 只有开启了晚到晚走结合流程统计开关 + kqFlowDataBiz.getAllFlowData(workFlowInfo, false); + if (workFlowInfo.get(dateKey) != null) { + workFlow = (List) workFlowInfo.get(dateKey); + } + } + Map dateTimeMap = new HashMap<>(); + List fromTimeList = new ArrayList<>(); + for (int j = 0; workFlow != null && j < workFlow.size(); j++) { + Map data = (Map) workFlow.get(j); + String fromtime = Util.null2String(data.get("begintime")); + String totime = Util.null2String(data.get("endtime")); + String flowType = Util.null2String(data.get("flowtype")); + String params = splitDate+"#"+fromtime+"#"+splitDate+"#"+totime; + if(flowType.equals(FlowReportTypeEnum.LEAVE.getFlowType()) || + flowType.equals(FlowReportTypeEnum.OUT.getFlowType()) || + flowType.equals(FlowReportTypeEnum.EVECTION.getFlowType())) { + dateTimeMap.put(fromtime, params); + fromTimeList.add(fromtime); + } + } + if(fromTimeList.size() > 0) { + Collections.sort(fromTimeList, new Comparator() { + @Override + public int compare(String o1, String o2) { + return o1.compareTo(o2); + } + }); + if(!dateTimeMap.isEmpty()) { + String flowDateTimeReal = dateTimeMap.get(fromTimeList.get(0)); + flowFromDate = flowDateTimeReal.split("#")[0]; + flowToDate = flowDateTimeReal.split("#")[2]; + flowFromTime = flowDateTimeReal.split("#")[1]; + flowToTime = flowDateTimeReal.split("#")[3]; + } + } + + String flowFromDateTime = ""; + String flowToDateTime = ""; + if(!"".equals(flowFromDate) && !"".equals(flowToDate) && !"".equals(flowFromTime) && !"".equals(flowToTime)) { + if (!splitDate.equals(flowFromDate) && !splitDate.equals(flowToDate)) { + return; + } + long flowIn_after_mins = 0; + // 如果流程上的开始时间在打卡时间之前,验证流程 + String signDateTime = signInDate+" "+signInTime; + boolean isearlyinearlyout = false; + // 如果满足了早到早走,就不return,继续往下走,避免影响早到早走 + if (earlyinearlyout != null && earlyinearlyout.size() > 0 && signDateTime.compareTo(workbegindatetime) < 0) { + isearlyinearlyout = true; + } + + if (splitDate.equals(flowFromDate)) { + flowFromDateTime = splitDate+" "+flowFromTime+":00"; + if(flowFromTime.compareTo("23:59") > 0){ + flowFromDateTime = nextDate+" "+kqTimesArrayComInfo.turn48to24Time(flowFromTime)+":00"; + } + if(flowFromDateTime.compareTo(workbegindatetime) >= 0) { // 如果流程上的开始时间小于打卡时间且要大于上班时间,则按流程走 + // 流程上的开始时间 +// flowIn_after_mins = Duration.between(LocalDateTime.parse(flowFromDateTime, fullFormatter), LocalDateTime.parse(workbegindatetime, fullFormatter)).toMinutes(); + } else if(flowFromDateTime.compareTo(workbegindatetime) < 0 && !isearlyinearlyout) { // 如果流程上的开始时间小于上班时间,则不走弹性 + return; + } else { + flowFromDateTime = ""; + } + } else if (splitDate.equals(flowToDate)) { + flowToDateTime = splitDate+" "+flowToTime+":00"; + if (flowToDateTime.compareTo(workbegindatetime) > 0) { // 请假流程的结束时间只要在9点之后的,那就不走弹性 + return; + } + } + } + boolean isFromFlow = false; + + if(signInDate.length() > 0 && signInTime.length() > 0){ + //判断下签到和上班时间,是否存在早到或者晚到的情况的情况 + String fromDateTime = signInDate+" "+signInTime; + String toDateTime = workbegindatetime; + // 如果流程上的时间在打卡时间之前并且是在上班时间之后,则按流程进行班次变化 + if(!"".equals(flowFromDateTime) && flowFromDateTime.compareTo(fromDateTime) <= 0 && flowFromDateTime.compareTo(workbegindatetime) >= 0) { + fromDateTime = flowFromDateTime; + signInTime = flowFromTime+":00"; + isFromFlow = true; + } + long signIn_mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + if(latein_localBeginDateTime != null){ + signIn_mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), latein_localBeginDateTime).toMinutes(); + } + boolean need_plus_one_min = false; + // new BaseBean().writeLog("fromDateTime="+fromDateTime+">>>toDateTime="+toDateTime); + if(signInTime.length() > 6){ + String signMinTime = signInTime.substring(0,5)+":00"; + if(signInTime.compareTo(signMinTime) > 0){ + //如果签到时间是带秒的且是迟到,那么签到时间多一秒和多一分钟是一样的 + need_plus_one_min = true; + String tmpfromDateTime = signInDate+" "+signMinTime; + if(!"".equals(flowFromDateTime) && flowFromDateTime.compareTo(tmpfromDateTime) <= 0 && flowFromDateTime.compareTo(workbegindatetime) >= 0) { + tmpfromDateTime = flowFromDateTime; + } + if(need_plus_one_min){ + signIn_mins = Duration.between(LocalDateTime.parse(tmpfromDateTime, fullFormatter).plusMinutes(1), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + if(latein_localBeginDateTime != null){ + signIn_mins = Duration.between(LocalDateTime.parse(tmpfromDateTime, fullFormatter).plusMinutes(1), latein_localBeginDateTime).toMinutes(); + } + } + } + } + if(signIn_mins > 0){ + log_str = (splitDate+" 上班时间是:"+toDateTime+",签到时间是:"+fromDateTime+",早到"+signIn_mins+"分钟"); + //确实是早到了 + signIn_before_mins = signIn_mins; + }else if(signIn_mins < 0){ + //这属于是晚到了 + signIn_after_mins = Math.abs(signIn_mins); + if(isFromFlow) { + log_str = (splitDate+" "+"上班时间是:"+toDateTime+",流程开始时间是:"+fromDateTime+",晚到"+signIn_after_mins+"分钟"); + } else { + log_str = (splitDate+" "+"上班时间是:"+toDateTime+",签到时间是:"+fromDateTime+",晚到"+signIn_after_mins+"分钟"); + } + if (usepermitlateminutes) {//允许迟到分钟数 + signIn_after_mins = signIn_after_mins - permitlateminutes; + } + } + } else { + // 没有签到卡的情况下,只看流程 + if(!"".equals(flowFromDateTime) && flowFromDateTime.compareTo(workbegindatetime) >= 0) { + isFromFlow = true; + String toDateTime = workbegindatetime; + long flowIn_mins = Duration.between(LocalDateTime.parse(flowFromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + if(latein_localBeginDateTime != null){ + flowIn_mins = Duration.between(LocalDateTime.parse(flowFromDateTime, fullFormatter), latein_localBeginDateTime).toMinutes(); + } + boolean need_plus_one_min = false; + new BaseBean().writeLog("fromDateTime="+flowFromDateTime+">>>toDateTime="+toDateTime); + String flowMinTime = flowFromTime.substring(0,5)+":00"; + if(flowFromTime.compareTo(flowMinTime) > 0){ + //如果签到时间是带秒的且是迟到,那么签到时间多一秒和多一分钟是一样的 + need_plus_one_min = true; + String tmpfromDateTime = signInDate+" "+flowMinTime; + if(need_plus_one_min){ + flowIn_mins = Duration.between(LocalDateTime.parse(tmpfromDateTime, fullFormatter).plusMinutes(1), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + if(latein_localBeginDateTime != null){ + flowIn_mins = Duration.between(LocalDateTime.parse(tmpfromDateTime, fullFormatter).plusMinutes(1), latein_localBeginDateTime).toMinutes(); + } + } + } + if(flowIn_mins > 0){ + log_str = (splitDate+" 上班时间是:"+toDateTime+",流程开始时间是:"+flowFromDateTime+",早到"+flowIn_mins+"分钟"); + //确实是早到了 + signIn_before_mins = flowIn_mins; + }else if(flowIn_mins < 0){ + //这属于是晚到了 + signIn_after_mins = Math.abs(flowIn_mins); + log_str = (splitDate+" "+"上班时间是:"+toDateTime+",流程开始时间是:"+flowFromDateTime+",晚到"+signIn_after_mins+"分钟"); + if (usepermitlateminutes) {//允许迟到分钟数 + signIn_after_mins = signIn_after_mins - permitlateminutes; + } + } + } + } + + if(signOutDate.length() > 0 && signOutTime.length() > 0){ + //判断下签退和下班时间,是否存在晚走的情况 + String fromDateTime = workenddatetime; + String toDateTime = signOutDate+" "+signOutTime; + long signOut_mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + + if(signOut_mins > 0){ + //这属于是晚走了 + signOut_after_mins = signOut_mins; + }else if(signOut_mins < 0){ + //这属于是早退了 + signOut_before_mins = Math.abs(signOut_mins); + } + } + + if (earlyinearlyout != null && earlyinearlyout.size() > 0 && signIn_before_mins > 0) { + //必须有早到时间才能继续下面的判断 + for (int i = 0; i < earlyinearlyout.size(); i++) { + Map rule = (Map) earlyinearlyout.get(i); + if (Util.null2String(rule.get("enable")).equals("1")) { + int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//早到时间 + int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//允许早走时间 + boolean enablesame = Util.null2String(rule.get("enablesame")).equals("1"); + if(log_str.length() > 0){ + log_str += ","+(" "+"开启了早到早走,"+(enablesame?"相对时间,早到可以早走,弹性限额"+postponetime+"分钟":"绝对时间"+",上班早到"+advancetime+"分钟,下班可以早走"+postponetime+"分钟")); + }else{ + log_str += ""+(" "+"开启了早到早走,"+(enablesame?"相对时间,早到可以早走,弹性限额"+postponetime+"分钟":"绝对时间"+",上班早到"+advancetime+"分钟,下班可以早走"+postponetime+"分钟")); + } + if (enablesame) { + //使用相对时间 + if(signIn_before_mins >= advancetime){ + //如果打卡的早到时长已经完全大于了设置的早到时长,那么就可以早走整个postponetime + early_localEndDateTime = localEndDateTime.minusMinutes(postponetime); + early_localBeginDateTime = localBeginDateTime.minusMinutes(advancetime); + }else{ + early_localEndDateTime = localEndDateTime.minusMinutes(signIn_before_mins); + early_localBeginDateTime = localBeginDateTime.minusMinutes(signIn_before_mins); + } + break; + }else{ + if(signIn_before_mins >= advancetime){ + //如果打卡的早到时长已经完全大于了设置的早到时长,那么就可以早走整个postponetime + early_localEndDateTime = localEndDateTime.minusMinutes(postponetime); + early_localBeginDateTime = localBeginDateTime.minusMinutes(advancetime); + break; + } + } + } + } + + String new_beginDateTime = ""; + String new_endDateTime = ""; + if(early_localBeginDateTime != null){ + shifRuleMap.put("shift_type", "earlyinearlyout"); + String beginDate = early_localBeginDateTime.format(dateFormatter); + String beginmin = early_localBeginDateTime.format(minFormatter); + shifRuleMap.put("shift_begindate", beginDate); + if(beginDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin)); + }else{ + shifRuleMap.put("shift_beginworktime", beginmin); + } + new_beginDateTime = beginDate+" "+beginmin; + } + if(early_localEndDateTime != null){ + shifRuleMap.put("shift_type", "earlyinearlyout"); + String endDate = early_localEndDateTime.format(dateFormatter); + String endmin = early_localEndDateTime.format(minFormatter); + shifRuleMap.put("shift_enddate", endDate); + if(endDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_endworktime", kqTimesArrayComInfo.turn24to48Time(endmin)); + }else{ + shifRuleMap.put("shift_endworktime", endmin); + } + new_endDateTime = endDate+" "+endmin; + } + if(new_beginDateTime.length() > 0 && new_endDateTime.length() > 0){ + log_str += ","+"满足了早到,所以"+splitDate+"的上班时间和下班时间变化了,上班时间变成了:"+new_beginDateTime+",下班时间变成了:"+new_endDateTime; + }else{ + log_str += ",不满足规则,所以"+splitDate+"的上班时间和下班时间未发生变化,上班时间还是:"+workbegindatetime+",下班时间还是:"+workenddatetime; + } + if(log_str.length() > 0){ + logList.add(log_str); + } + + } + + boolean isLateinlateout = false; + if (lateinlateout != null && lateinlateout.size() > 0) { + + if(signIn_after_mins > 0){ + isLateinlateout = true; + //必须有晚到时间才能继续下面的判断 + for (int i = 0; i < lateinlateout.size(); i++) { + Map rule = (Map) lateinlateout.get(i); + if (Util.null2String(rule.get("enable")).equals("1")) { + int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//晚到时间 + int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//需要晚走时间 + boolean enablesame = Util.null2String(rule.get("enablesame")).equals("1"); + if(isFromFlow) { + if(log_str.length() > 0){ + log_str += ","+(" "+"开启了晚到晚走,"+(enablesame?"相对时间,晚到可以晚走,弹性限额"+postponetime+"分钟":"绝对时间"+",流程开始时间晚到"+advancetime+"分钟,下班需要晚走"+postponetime+"分钟")); + }else{ + log_str += ""+(" "+"开启了晚到晚走,"+(enablesame?"相对时间,晚到可以晚走,弹性限额"+postponetime+"分钟":"绝对时间"+",流程开始时间晚到"+advancetime+"分钟,下班需要晚走"+postponetime+"分钟")); + } + } else { + if(log_str.length() > 0){ + log_str += ","+(" "+"开启了晚到晚走,"+(enablesame?"相对时间,晚到可以晚走,弹性限额"+postponetime+"分钟":"绝对时间"+",上班晚到"+advancetime+"分钟,下班需要晚走"+postponetime+"分钟")); + }else{ + log_str += ""+(" "+"开启了晚到晚走,"+(enablesame?"相对时间,晚到可以晚走,弹性限额"+postponetime+"分钟":"绝对时间"+",上班晚到"+advancetime+"分钟,下班需要晚走"+postponetime+"分钟")); + } + } + + if (enablesame) { + //使用相对时间 + if(signIn_after_mins <= advancetime){ + //如果打卡的晚到时长必须要小于等于设置的晚到时长,才算满足,晚到多久就可以晚走多久 + late_localEndDateTime = localEndDateTime.plusMinutes(signIn_after_mins); + late_localBeginDateTime = localBeginDateTime.plusMinutes(signIn_after_mins); + break; + }else{ + if(KQSettingsBiz.is_lateinlateout_outrule()){ + late_localEndDateTime = localEndDateTime.plusMinutes(advancetime); + late_localBeginDateTime = localBeginDateTime.plusMinutes(advancetime); + break; + } + } + }else{ + if (signIn_after_mins <= advancetime) { + //如果打卡的晚到时长已经完全小于了设置的晚到时长,那么需要晚走整个postponetime + late_localEndDateTime = localEndDateTime.plusMinutes(postponetime); + late_localBeginDateTime = localBeginDateTime.plusMinutes(advancetime); + break; + }else{ + if(KQSettingsBiz.is_lateinlateout_outrule()){ + late_localEndDateTime = localEndDateTime.plusMinutes(postponetime); + late_localBeginDateTime = localBeginDateTime.plusMinutes(advancetime); + break; + } + } + } + } + } + } + if(isLateinlateout){ + String new_beginDateTime = ""; + String new_endDateTime = ""; + if(late_localBeginDateTime != null){ + shifRuleMap.put("shift_type", "lateinlateout"); + String beginDate = late_localBeginDateTime.format(dateFormatter); + String beginmin = late_localBeginDateTime.format(minFormatter); + shifRuleMap.put("shift_begindate", beginDate); + if(beginDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin)); + }else{ + shifRuleMap.put("shift_beginworktime", beginmin); + } + new_beginDateTime = beginDate+" "+beginmin; + } + if(late_localEndDateTime != null){ + shifRuleMap.put("shift_type", "lateinlateout"); + String endDate = late_localEndDateTime.format(dateFormatter); + String endmin = late_localEndDateTime.format(minFormatter); + shifRuleMap.put("shift_enddate", endDate); + if(endDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_endworktime", kqTimesArrayComInfo.turn24to48Time(endmin)); + }else{ + shifRuleMap.put("shift_endworktime", endmin); + } + new_endDateTime = endDate+" "+endmin; + } + if(new_beginDateTime.length() > 0 && new_endDateTime.length() > 0){ + log_str += ",满足了晚到,所以"+splitDate+"的上班时间和下班时间变化了,上班时间变成了:"+new_beginDateTime+",下班时间变成了:"+new_endDateTime; + }else{ + log_str += ",不满足规则,所以"+splitDate+"的上班时间和下班时间未发生变化,上班时间还是:"+workbegindatetime+",下班时间还是:"+workenddatetime; + } + if(log_str.length() > 0){ + logList.add(log_str); + } + } + } + } + } + } + } + /** + * 根据班次获取个性化设置 这个方法改逻辑的话 ,记得要把do4ShiftRule也一起改 + * @param shiftInfoBean + * @param need_lateoutlatein 是否需要处理晚走晚到 + */ + public static void getShiftRuleInfo(ShiftInfoBean shiftInfoBean, SplitBean splitBean,Map shifRuleMap,boolean need_lateoutlatein,List logList) { + String resourceId = splitBean.getResourceId(); + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter minFormatter = DateTimeFormatter.ofPattern("HH:mm"); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + List earlyinearlyout = null;//早到早走规则 + List lateinlateout = null;//晚到晚走规则 + List lateoutlatein = null;//晚走晚到规则 + if(shiftInfoBean == null){ + return ; + } + + String splitDate = shiftInfoBean.getSplitDate(); + String preDate = DateUtil.addDate(splitDate, -1);//上一天日期 + String nextDate = DateUtil.addDate(splitDate, 1);//下一天日期 + + KQWorkTime kqWorkTime = new KQWorkTime(); + kqWorkTime.setIsFormat(true); + String tmpKQPreDate = preDate; + if(KQSettingsBiz.is_lateoutlatein()) {//开启开关 + //前一天是非工作日,往前取到工作日 + for(int i=0;i<31;i++){ + WorkTimeEntity tmpworkTime = kqWorkTime.getWorkTime(resourceId, tmpKQPreDate); + if(tmpworkTime.getWorkMins()>0){ + break; + } + tmpKQPreDate = DateUtil.addDate(tmpKQPreDate, -1); + } + }else{ + //默认取前一天 + } + + WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceId, tmpKQPreDate); + if(workTime == null || (workTime.getWorkMins() == 0 && workTime.getNonWorkShift() != 1)){//如果前一天是休息日,那么直接就不需要走晚走晚到了,因为压根不存在前一天的晚走情况 + need_lateoutlatein = false; + }else{ + Map preshiftRuleMap = workTime.getShiftRuleInfo(); + if (preshiftRuleMap != null && !preshiftRuleMap.isEmpty() && preshiftRuleMap.containsKey("ruleDetail")) { + Map preruleDetail = (Map) preshiftRuleMap.get("ruleDetail"); + if(preruleDetail != null && !preruleDetail.isEmpty()){ + lateoutlatein = (List) preruleDetail.get("lateoutlatein");//晚走晚到应该取前一天的个性化班次的设置,而不是当天 + } + } + } + + Map shiftRuleMap = shiftInfoBean.getShiftRuleMap(); + if (shiftRuleMap != null && !shiftRuleMap.isEmpty() && shiftRuleMap.containsKey("ruleDetail")) {//处理人性化设置其他规则 + //允许迟到分钟数 + boolean usepermitlateminutes = Util.null2String(shiftRuleMap.get("permitlatestatus")).equals("1"); + //和蔡志军讨论,优先满足弹性,即如果晚到了,开启了弹性,那么就先按照弹性来处理,不满足弹性的部分再按照允许迟到来处理 + usepermitlateminutes = false; + int permitlateminutes = Util.getIntValue(Util.null2String(shiftRuleMap.get("permitlateminutes")), 0); +// //允许早退分钟数 +// boolean usepermitleaveearlyminutes = Util.null2String(shiftRuleMap.get("permitleaveearlystatus")).equals("1"); +// int permitleaveearlyminutes = Util.getIntValue(Util.null2String(shiftRuleMap.get("permitleaveearlyminutes")), 0); + + Map ruleDetail = (Map) shiftRuleMap.get("ruleDetail"); + if(ruleDetail != null && !ruleDetail.isEmpty()){ + earlyinearlyout = (List) ruleDetail.get("earlyinearlyout"); + lateinlateout = (List) ruleDetail.get("lateinlateout"); + //上面已经搞了下面注释掉 +// lateoutlatein = (List) ruleDetail.get("lateoutlatein"); + +// KQWorkTime kqWorkTime = new KQWorkTime(); + //如果设置了个性化规则,需要先获取下打卡数据 + List lsSignTime = new ArrayList<>(); + List lsWorkTime = new ArrayList<>(); + List lsRestTime = new ArrayList<>(); + + lsSignTime = shiftInfoBean.getSignTime();//允许打卡时间 + lsWorkTime = shiftInfoBean.getWorkTime();//工作时间 + + //只有一次签到签退才有个性化的这些设置 + if(lsWorkTime != null && lsWorkTime.size() > 0){ + //早到早走后,引起下班时间变化后的时间 + LocalDateTime early_localEndDateTime = null; + //早到早走后,引起上班时间变化后的时间 + LocalDateTime early_localBeginDateTime = null; + //晚到晚走后,引起下班时间变化后的时间 + LocalDateTime late_localEndDateTime = null; + //晚到晚走后,引起上班时间变化后的时间 + LocalDateTime late_localBeginDateTime = null; + //晚走晚到后,引起上班时间变化后的时间 + LocalDateTime latein_localBeginDateTime = null; + + TimeScopeEntity signTimeScope = lsSignTime.get(0); + TimeScopeEntity workTimeScope = lsWorkTime.get(0); + + String signInDate = ""; + String signInTime = ""; + String signOutDate = ""; + String signOutTime = ""; + String workbeigintime = workTimeScope.getBeginTime(); + boolean beginTimeAcross = workTimeScope.getBeginTimeAcross(); + String workbegindate = splitDate; + if(beginTimeAcross){ + workbegindate = nextDate; + workbeigintime = kqTimesArrayComInfo.turn48to24Time(workbeigintime); + } + String workbegindatetime = workbegindate+" "+workbeigintime+":00"; + LocalDateTime localBeginDateTime = LocalDateTime.parse(workbegindatetime,fullFormatter); + + String workendtime = workTimeScope.getEndTime(); + boolean endTimeAcross = workTimeScope.getEndTimeAcross(); + String workenddate = splitDate; + if(endTimeAcross){ + workenddate = nextDate; + workendtime = kqTimesArrayComInfo.turn48to24Time(workendtime); + } + String workenddatetime = workenddate+" "+workendtime+":00"; + LocalDateTime localEndDateTime = LocalDateTime.parse(workenddatetime,fullFormatter); + int signoutOnlyoff = shiftInfoBean.getSignoutOnlyoff(); + List lsCheckInfo = new KQFormatSignData().getSignInfo(resourceId,signTimeScope,workTimeScope,splitDate,preDate,nextDate,kqTimesArrayComInfo,Lists.newArrayList(), "",0,0,signoutOnlyoff); + if(lsCheckInfo.isEmpty()){ + //如果当天没有打卡数据,判断下是否存在昨天有打卡数据,晚走晚到的情况 + if ((lateoutlatein != null && lateoutlatein.size() > 0) || (lateinlateout != null && lateinlateout.size() > 0)) { + }else{ + return ; + } + } + + if(lsCheckInfo.size() > 1){ + for(int i = 0 ; i < lsCheckInfo.size() ; i++){ + Map checkInfo = (Map) lsCheckInfo.get(i); + if (checkInfo.get("signType").equals("1")) { + //签到 + signInDate = Util.null2String(checkInfo.get("signDate")); + signInTime = Util.null2String(checkInfo.get("signTime")); + } + if (checkInfo.get("signType").equals("2")) { + //签退 + signOutDate = Util.null2String(checkInfo.get("signDate")); + signOutTime = Util.null2String(checkInfo.get("signTime")); + } + } + }else if(lsCheckInfo.size() == 1){ + Map checkInfo = (Map) lsCheckInfo.get(0); + if (checkInfo.get("signType").equals("1")) { + //签到 + signInDate = Util.null2String(checkInfo.get("signDate")); + signInTime = Util.null2String(checkInfo.get("signTime")); + } + if (checkInfo.get("signType").equals("2")) { + //签退 + signOutDate = Util.null2String(checkInfo.get("signDate")); + signOutTime = Util.null2String(checkInfo.get("signTime")); + } + } + + if (need_lateoutlatein && lateoutlatein != null && lateoutlatein.size() > 0) { + + String log_str = ""; + KQFormatShiftRule kqFormatShiftRule = new KQFormatShiftRule(); + int preDayLateOutMins = kqFormatShiftRule.getPreDayLateOutMins(resourceId, splitDate,logList,signoutOnlyoff); + if(!logList.isEmpty()){ + for(int i = 0 ; i < logList.size() ; i++){ + if(i == 0){ + log_str += ""+logList.get(i); + }else{ + log_str += ","+logList.get(i); + } + } + logList.clear(); + } + for (int i = 0; preDayLateOutMins > 0 && i < lateoutlatein.size(); i++) { + Map rule = (Map) lateoutlatein.get(i); + if (Util.null2String(rule.get("enable")).equals("1")) { + int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//晚走时间 + int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//允许晚到时间 + + boolean enablesame = Util.null2String(rule.get("enablesame")).equals("1"); + if(log_str.length() > 0){ + log_str += ","+(" "+"开启了晚走晚到,"+(enablesame?"相对时间,前一天晚走,第二天可以晚到,弹性限额"+postponetime+"分钟":"绝对时间"+",前一天晚走"+advancetime+"分钟,第二天上班可以晚到"+postponetime+"分钟")); + }else{ + log_str += ""+(" "+"开启了晚走晚到,"+(enablesame?"相对时间,前一天晚走,第二天可以晚到,弹性限额"+postponetime+"分钟":"绝对时间"+",前一天晚走"+advancetime+"分钟,第二天上班可以晚到"+postponetime+"分钟")); + } + if (enablesame) { + if(preDayLateOutMins >= advancetime){ + //如果昨日的晚走时长已经完全大于了设置的晚走时长,那么就可以晚到整个postponetime + latein_localBeginDateTime = localBeginDateTime.plusMinutes(postponetime); + }else{ + latein_localBeginDateTime = localBeginDateTime.plusMinutes(preDayLateOutMins); + } + break; + }else{ + if (preDayLateOutMins >= advancetime) { + //如果昨日的晚走时长已经完全大于了设置的晚走时长,那么就可以晚到整个postponetime + latein_localBeginDateTime = localBeginDateTime.plusMinutes(postponetime); + break; + }else{ + logList.clear(); + } + } + }else{ + logList.clear(); + } + } + if(latein_localBeginDateTime != null){ + shifRuleMap.put("shift_type", "lateoutlatein"); + String beginDate = latein_localBeginDateTime.format(dateFormatter); + String beginmin = latein_localBeginDateTime.format(minFormatter); + // 前一天的晚到影响了今天的早到或者晚到 + workbegindatetime = latein_localBeginDateTime.format(fullFormatter); + localBeginDateTime = LocalDateTime.parse(workbegindatetime,fullFormatter); + log_str += ","+("满足了晚走晚到,所以今天的上班时间变化了,变成了:"+workbegindatetime+"-"+workenddatetime); + + shifRuleMap.put("shift_begindate", beginDate); + if(beginDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin)); + }else{ + shifRuleMap.put("shift_beginworktime", beginmin); + } + }else{ + log_str = ""; + } + if(log_str.length() > 0){ + logList.add(log_str); + }else{ + logList.clear(); + } + } + String log_str = ""; + long signIn_before_mins = 0; + long signIn_after_mins = 0; + long signOut_before_mins = 0; + long signOut_after_mins = 0; + + // 针对流程的特殊处理 + String flowFromDate = Util.null2String(splitBean.getFromdatedb()); + String flowToDate = Util.null2String(splitBean.getTodatedb()); + String flowFromTime = Util.null2String(splitBean.getFromtimedb()); + String flowToTime = Util.null2String(splitBean.getTotimedb()); + String flowFromDateTime = ""; + String flowToDateTime = ""; + if(!"".equals(flowFromDate) && !"".equals(flowToDate) && !"".equals(flowFromTime) && !"".equals(flowToTime)) { + if (!splitDate.equals(flowFromDate) && !splitDate.equals(flowToDate)) { + return; + } + long flowIn_after_mins = 0; + // 如果流程上的开始时间在打卡时间之前,验证流程 + String signDateTime = signInDate+" "+signInTime; + boolean isearlyinearlyout = false; + // 如果满足了早到早走,就不return,继续往下走,避免影响早到早走 + if (earlyinearlyout != null && earlyinearlyout.size() > 0 && signDateTime.compareTo(workbegindatetime) < 0) { + isearlyinearlyout = true; + } + + if (splitDate.equals(flowFromDate)) { + flowFromDateTime = splitDate+" "+flowFromTime+":00"; + if(flowFromTime.compareTo("23:59") > 0){ + flowFromDateTime = nextDate+" "+kqTimesArrayComInfo.turn48to24Time(flowFromTime)+":00"; + } + if(flowFromDateTime.compareTo(workbegindatetime) >= 0) { // 如果流程上的开始时间小于打卡时间且要大于上班时间,则按流程走 + // 流程上的开始时间 +// flowIn_after_mins = Duration.between(LocalDateTime.parse(flowFromDateTime, fullFormatter), LocalDateTime.parse(workbegindatetime, fullFormatter)).toMinutes(); + } else if(flowFromDateTime.compareTo(workbegindatetime) < 0 && !isearlyinearlyout) { // 如果流程上的开始时间小于上班时间,则不走弹性 + return; + } else { + flowFromDateTime = ""; + } + } else if (splitDate.equals(flowToDate)) { + flowToDateTime = splitDate+" "+flowToTime+":00"; + if (flowToDateTime.compareTo(workbegindatetime) > 0) { // 请假流程的结束时间只要在9点之后的,那就不走弹性 + return; + } + } + } + + boolean isFromFlow = false; + + if(signInDate.length() > 0 && signInTime.length() > 0){ + //判断下签到和上班时间,是否存在早到或者晚到的情况的情况 + String fromDateTime = signInDate+" "+signInTime; + String toDateTime = workbegindatetime; + // 如果流程上的时间在打卡时间之前并且是在上班时间之后,则按流程进行班次变化 + if(!"".equals(flowFromDateTime) && flowFromDateTime.compareTo(fromDateTime) <= 0 && flowFromDateTime.compareTo(workbegindatetime) >= 0) { + fromDateTime = flowFromDateTime; + signInTime = flowFromTime+":00"; + isFromFlow = true; + } + long signIn_mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + if(latein_localBeginDateTime != null){ + signIn_mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), latein_localBeginDateTime).toMinutes(); + } + boolean need_plus_one_min = false; + new BaseBean().writeLog("fromDateTime="+fromDateTime+">>>toDateTime="+toDateTime); + if(signInTime.length() > 6){ + String signMinTime = signInTime.substring(0,5)+":00"; + if(signInTime.compareTo(signMinTime) > 0){ + //如果签到时间是带秒的且是迟到,那么签到时间多一秒和多一分钟是一样的 + need_plus_one_min = true; + String tmpfromDateTime = signInDate+" "+signMinTime; + if(need_plus_one_min){ + signIn_mins = Duration.between(LocalDateTime.parse(tmpfromDateTime, fullFormatter).plusMinutes(1), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + if(latein_localBeginDateTime != null){ + signIn_mins = Duration.between(LocalDateTime.parse(tmpfromDateTime, fullFormatter).plusMinutes(1), latein_localBeginDateTime).toMinutes(); + } + } + } + } + if(signIn_mins > 0){ + log_str = (splitDate+" 上班时间是:"+toDateTime+",签到时间是:"+fromDateTime+",早到"+signIn_mins+"分钟"); + //确实是早到了 + signIn_before_mins = signIn_mins; + }else if(signIn_mins < 0){ + //这属于是晚到了 + signIn_after_mins = Math.abs(signIn_mins); + if(isFromFlow) { + log_str = (splitDate+" "+"上班时间是:"+toDateTime+",流程开始时间是:"+fromDateTime+",晚到"+signIn_after_mins+"分钟"); + } else { + log_str = (splitDate+" "+"上班时间是:"+toDateTime+",签到时间是:"+fromDateTime+",晚到"+signIn_after_mins+"分钟"); + } + if (usepermitlateminutes) {//允许迟到分钟数 + signIn_after_mins = signIn_after_mins - permitlateminutes; + } + } + } else { + // 没有签到卡的情况下,只看流程 + if(!"".equals(flowFromDateTime) && flowFromDateTime.compareTo(workbegindatetime) >= 0) { + isFromFlow = true; + String toDateTime = workbegindatetime; + long flowIn_mins = Duration.between(LocalDateTime.parse(flowFromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + if(latein_localBeginDateTime != null){ + flowIn_mins = Duration.between(LocalDateTime.parse(flowFromDateTime, fullFormatter), latein_localBeginDateTime).toMinutes(); + } + boolean need_plus_one_min = false; + new BaseBean().writeLog("fromDateTime="+flowFromDateTime+">>>toDateTime="+toDateTime); + String flowMinTime = flowFromTime.substring(0,5)+":00"; + if(flowFromTime.compareTo(flowMinTime) > 0){ + //如果签到时间是带秒的且是迟到,那么签到时间多一秒和多一分钟是一样的 + need_plus_one_min = true; + String tmpfromDateTime = signInDate+" "+flowMinTime; + if(need_plus_one_min){ + flowIn_mins = Duration.between(LocalDateTime.parse(tmpfromDateTime, fullFormatter).plusMinutes(1), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + if(latein_localBeginDateTime != null){ + flowIn_mins = Duration.between(LocalDateTime.parse(tmpfromDateTime, fullFormatter).plusMinutes(1), latein_localBeginDateTime).toMinutes(); + } + } + } + if(flowIn_mins > 0){ + log_str = (splitDate+" 上班时间是:"+toDateTime+",流程开始时间是:"+flowFromDateTime+",早到"+flowIn_mins+"分钟"); + //确实是早到了 + signIn_before_mins = flowIn_mins; + }else if(flowIn_mins < 0){ + //这属于是晚到了 + signIn_after_mins = Math.abs(flowIn_mins); + log_str = (splitDate+" "+"上班时间是:"+toDateTime+",流程开始时间是:"+flowFromDateTime+",晚到"+signIn_after_mins+"分钟"); + if (usepermitlateminutes) {//允许迟到分钟数 + signIn_after_mins = signIn_after_mins - permitlateminutes; + } + } + } + } + + if(signOutDate.length() > 0 && signOutTime.length() > 0){ + //判断下签退和下班时间,是否存在晚走的情况 + String fromDateTime = workenddatetime; + String toDateTime = signOutDate+" "+signOutTime; + long signOut_mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + + if(signOut_mins > 0){ + //这属于是晚走了 + signOut_after_mins = signOut_mins; + }else if(signOut_mins < 0){ + //这属于是早退了 + signOut_before_mins = Math.abs(signOut_mins); + } + } + + if (earlyinearlyout != null && earlyinearlyout.size() > 0 && signIn_before_mins > 0) { + //必须有早到时间才能继续下面的判断 + for (int i = 0; i < earlyinearlyout.size(); i++) { + Map rule = (Map) earlyinearlyout.get(i); + if (Util.null2String(rule.get("enable")).equals("1")) { + int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//早到时间 + int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//允许早走时间 + boolean enablesame = Util.null2String(rule.get("enablesame")).equals("1"); + if(log_str.length() > 0){ + log_str += ","+(" "+"开启了早到早走,"+(enablesame?"相对时间,早到可以早走,弹性限额"+postponetime+"分钟":"绝对时间"+",上班早到"+advancetime+"分钟,下班可以早走"+postponetime+"分钟")); + }else{ + log_str += ""+(" "+"开启了早到早走,"+(enablesame?"相对时间,早到可以早走,弹性限额"+postponetime+"分钟":"绝对时间"+",上班早到"+advancetime+"分钟,下班可以早走"+postponetime+"分钟")); + } + if (enablesame) { + //使用相对时间 + if(signIn_before_mins >= advancetime){ + //如果打卡的早到时长已经完全大于了设置的早到时长,那么就可以早走整个postponetime + early_localEndDateTime = localEndDateTime.minusMinutes(postponetime); + early_localBeginDateTime = localBeginDateTime.minusMinutes(advancetime); + }else{ + early_localEndDateTime = localEndDateTime.minusMinutes(signIn_before_mins); + early_localBeginDateTime = localBeginDateTime.minusMinutes(signIn_before_mins); + } + break; + }else{ + if(signIn_before_mins >= advancetime){ + //如果打卡的早到时长已经完全大于了设置的早到时长,那么就可以早走整个postponetime + early_localEndDateTime = localEndDateTime.minusMinutes(postponetime); + early_localBeginDateTime = localBeginDateTime.minusMinutes(advancetime); + break; + } + } + } + } + + String new_beginDateTime = ""; + String new_endDateTime = ""; + if(early_localBeginDateTime != null){ + shifRuleMap.put("shift_type", "earlyinearlyout"); + String beginDate = early_localBeginDateTime.format(dateFormatter); + String beginmin = early_localBeginDateTime.format(minFormatter); + shifRuleMap.put("shift_begindate", beginDate); + if(beginDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin)); + }else{ + shifRuleMap.put("shift_beginworktime", beginmin); + } + new_beginDateTime = beginDate+" "+beginmin; + } + if(early_localEndDateTime != null){ + shifRuleMap.put("shift_type", "earlyinearlyout"); + String endDate = early_localEndDateTime.format(dateFormatter); + String endmin = early_localEndDateTime.format(minFormatter); + shifRuleMap.put("shift_enddate", endDate); + if(endDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_endworktime", kqTimesArrayComInfo.turn24to48Time(endmin)); + }else{ + shifRuleMap.put("shift_endworktime", endmin); + } + new_endDateTime = endDate+" "+endmin; + } + if(new_beginDateTime.length() > 0 && new_endDateTime.length() > 0){ + log_str += ","+"满足了早到,所以"+splitDate+"的上班时间和下班时间变化了,上班时间变成了:"+new_beginDateTime+",下班时间变成了:"+new_endDateTime; + }else{ + log_str += ",不满足规则,所以"+splitDate+"的上班时间和下班时间未发生变化,上班时间还是:"+workbegindatetime+",下班时间还是:"+workenddatetime; + } + if(log_str.length() > 0){ + logList.add(log_str); + } + + } + + boolean isLateinlateout = false; + if (lateinlateout != null && lateinlateout.size() > 0) { + + if(signIn_after_mins > 0){ + isLateinlateout = true; + //必须有晚到时间才能继续下面的判断 + for (int i = 0; i < lateinlateout.size(); i++) { + Map rule = (Map) lateinlateout.get(i); + if (Util.null2String(rule.get("enable")).equals("1")) { + int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//晚到时间 + int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//需要晚走时间 + boolean enablesame = Util.null2String(rule.get("enablesame")).equals("1"); + if(isFromFlow) { + if(log_str.length() > 0){ + log_str += ","+(" "+"开启了晚到晚走,"+(enablesame?"相对时间,晚到可以晚走,弹性限额"+postponetime+"分钟":"绝对时间"+",流程开始时间晚到"+advancetime+"分钟,下班需要晚走"+postponetime+"分钟")); + }else{ + log_str += ""+(" "+"开启了晚到晚走,"+(enablesame?"相对时间,晚到可以晚走,弹性限额"+postponetime+"分钟":"绝对时间"+",流程开始时间晚到"+advancetime+"分钟,下班需要晚走"+postponetime+"分钟")); + } + } else { + if(log_str.length() > 0){ + log_str += ","+(" "+"开启了晚到晚走,"+(enablesame?"相对时间,晚到可以晚走,弹性限额"+postponetime+"分钟":"绝对时间"+",上班晚到"+advancetime+"分钟,下班需要晚走"+postponetime+"分钟")); + }else{ + log_str += ""+(" "+"开启了晚到晚走,"+(enablesame?"相对时间,晚到可以晚走,弹性限额"+postponetime+"分钟":"绝对时间"+",上班晚到"+advancetime+"分钟,下班需要晚走"+postponetime+"分钟")); + } + } + + if (enablesame) { + //使用相对时间 + if(signIn_after_mins <= advancetime){ + //如果打卡的晚到时长必须要小于等于设置的晚到时长,才算满足,晚到多久就可以晚走多久 + late_localEndDateTime = localEndDateTime.plusMinutes(signIn_after_mins); + late_localBeginDateTime = localBeginDateTime.plusMinutes(signIn_after_mins); + break; + }else{ + if(KQSettingsBiz.is_lateinlateout_outrule()){ + late_localEndDateTime = localEndDateTime.plusMinutes(advancetime); + late_localBeginDateTime = localBeginDateTime.plusMinutes(advancetime); + break; + } + } + }else{ + if (signIn_after_mins <= advancetime) { + //如果打卡的晚到时长已经完全小于了设置的晚到时长,那么需要晚走整个postponetime + late_localEndDateTime = localEndDateTime.plusMinutes(postponetime); + late_localBeginDateTime = localBeginDateTime.plusMinutes(advancetime); + break; + }else{ + if(KQSettingsBiz.is_lateinlateout_outrule()){ + late_localEndDateTime = localEndDateTime.plusMinutes(postponetime); + late_localBeginDateTime = localBeginDateTime.plusMinutes(advancetime); + break; + } + } + } + } + } + } + if(isLateinlateout){ + String new_beginDateTime = ""; + String new_endDateTime = ""; + if(late_localBeginDateTime != null){ + shifRuleMap.put("shift_type", "lateinlateout"); + String beginDate = late_localBeginDateTime.format(dateFormatter); + String beginmin = late_localBeginDateTime.format(minFormatter); + shifRuleMap.put("shift_begindate", beginDate); + if(beginDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin)); + }else{ + shifRuleMap.put("shift_beginworktime", beginmin); + } + new_beginDateTime = beginDate+" "+beginmin; + } + if(late_localEndDateTime != null){ + shifRuleMap.put("shift_type", "lateinlateout"); + String endDate = late_localEndDateTime.format(dateFormatter); + String endmin = late_localEndDateTime.format(minFormatter); + shifRuleMap.put("shift_enddate", endDate); + if(endDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_endworktime", kqTimesArrayComInfo.turn24to48Time(endmin)); + }else{ + shifRuleMap.put("shift_endworktime", endmin); + } + new_endDateTime = endDate+" "+endmin; + } + if(new_beginDateTime.length() > 0 && new_endDateTime.length() > 0){ + log_str += ",满足了晚到,所以"+splitDate+"的上班时间和下班时间变化了,上班时间变成了:"+new_beginDateTime+",下班时间变成了:"+new_endDateTime; + }else{ + log_str += ",不满足规则,所以"+splitDate+"的上班时间和下班时间未发生变化,上班时间还是:"+workbegindatetime+",下班时间还是:"+workenddatetime; + } + if(log_str.length() > 0){ + logList.add(log_str); + } + } + } + } + } + } + } + + public void rest_workLongTimeIndex(ShiftInfoBean shiftInfoBean, + SplitBean splitBean, List real_workLongTimeIndex, + KQTimesArrayComInfo kqTimesArrayComInfo, + List real_allLongWorkTime){ + rest_workLongTimeIndex(shiftInfoBean,splitBean,real_workLongTimeIndex,kqTimesArrayComInfo,real_allLongWorkTime,false); + } + + public void rest_workLongTimeIndex(ShiftInfoBean shiftInfoBean, + SplitBean splitBean, List real_workLongTimeIndex, + KQTimesArrayComInfo kqTimesArrayComInfo, + List real_allLongWorkTime,boolean is_flow_humanized){ +// boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + if(!is_flow_humanized){ + return ; + } + boolean lateInlateOutWithFlow = KQSettingsBiz.showLeaveTypeSet("lateinlateout_kqflow"); + //个性化设置只支持一次打卡的 + Map shifRuleMap = Maps.newHashMap(); + if(lateInlateOutWithFlow && (splitBean.getDurationTypeEnum() == DurationTypeEnum.EVECTION + || splitBean.getDurationTypeEnum() == DurationTypeEnum.OUT + || splitBean.getDurationTypeEnum() == DurationTypeEnum.LEAVE)){ + KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean,splitBean,shifRuleMap); + } else { + KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean,splitBean.getResourceId(),shifRuleMap); + } + if(!shifRuleMap.isEmpty()){ + if(shifRuleMap.containsKey("shift_beginworktime")){ + String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime")); + if(shift_beginworktime.length() > 0){ + int[] workLongTimeIndex_arr = real_workLongTimeIndex.get(0); + workLongTimeIndex_arr[0] = kqTimesArrayComInfo.getArrayindexByTimes(shift_beginworktime); + if(real_allLongWorkTime != null){ + real_allLongWorkTime.set(0,shift_beginworktime); + } + } + } + if(shifRuleMap.containsKey("shift_endworktime")){ + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if(shift_endworktime.length() > 0){ + int[] workLongTimeIndex_arr = real_workLongTimeIndex.get(0); + workLongTimeIndex_arr[1] = kqTimesArrayComInfo.getArrayindexByTimes(shift_endworktime); + if(real_allLongWorkTime != null){ + real_allLongWorkTime.set(1,shift_endworktime); + } + } + } + reset_halfIndex(shiftInfoBean,real_allLongWorkTime,kqTimesArrayComInfo); + } + + } + + public void reset_halfIndex(ShiftInfoBean shiftInfoBean, List real_allLongWorkTime, KQTimesArrayComInfo kqTimesArrayComInfo) { + try{ + List real_workAcrossTime = shiftInfoBean.getWorkAcrossTime(); + List shift_halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + List real_shift_halfWorkIndex = Lists.newArrayList(); + + List eachWorkMins = Lists.newArrayList(); + List tmp_eachWorkMins = Lists.newArrayList(); + List workLongTimeIndex = shiftInfoBean.getWorkLongTimeIndex(); + List restLongTimeIndex = shiftInfoBean.getRestLongTimeIndex(); + String allLongWorkBeginTime = real_allLongWorkTime.get(0); + String allLongWorkEndTime = real_allLongWorkTime.get(1); + + String[] real_workAcrossTimes = new String[2]; + real_workAcrossTimes[0] = allLongWorkBeginTime; + real_workAcrossTimes[1] = allLongWorkEndTime; + if(!workLongTimeIndex.isEmpty()){ + real_workAcrossTime.set(0,real_workAcrossTimes); + } + + int[] real_workLongTimeIndex = new int[2]; + real_workLongTimeIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(allLongWorkBeginTime); + real_workLongTimeIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(allLongWorkEndTime); + if(!workLongTimeIndex.isEmpty()){ + workLongTimeIndex.set(0, real_workLongTimeIndex); + } + + int allLongWorkBeginTime_Index = kqTimesArrayComInfo.getArrayindexByTimes(allLongWorkBeginTime); + int allLongWorkEndTime_Index = kqTimesArrayComInfo.getArrayindexByTimes(allLongWorkEndTime); + tmp_eachWorkMins.add(allLongWorkBeginTime_Index); + int real_workmins = allLongWorkEndTime_Index-allLongWorkBeginTime_Index; + for(int k = 0 ; k < restLongTimeIndex.size() ; k++){ + int[] rests = restLongTimeIndex.get(k); + if(rests != null && rests.length == 2){ + real_workmins = real_workmins - (rests[1]-rests[0]); + tmp_eachWorkMins.add(rests[0]); + tmp_eachWorkMins.add(rests[1]); + } + } + tmp_eachWorkMins.add(allLongWorkEndTime_Index); + for(int j = 0 ; j < tmp_eachWorkMins.size() ; ){ + int end_index = tmp_eachWorkMins.get(j+1); + int begin_index = tmp_eachWorkMins.get(j); + int tmp = end_index-begin_index; + if(tmp > 0){ + eachWorkMins.add(end_index-begin_index); + } + j = j + 2; + } + + Map workTimeMap = Maps.newHashMap(); + workTimeMap.put("halfcalrule", shiftInfoBean.getHalfcalrule()); + workTimeMap.put("halfcalpoint", shiftInfoBean.getHalfcalpoint()); + workTimeMap.put("halfcalpoint2cross", shiftInfoBean.getHalfcalpoint2cross()); + workTimeMap.put("workmins", real_workmins); + + HalfShiftComIndex halfShiftComIndex = new HalfShiftComIndex(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005308,weaver.general.ThreadVarLanguage.getLang())+"",workTimeMap); + ShiftInfoCominfoBean shiftInfoCominfoBean = new ShiftInfoCominfoBean(); + shiftInfoCominfoBean.setAllLongWorkTime(real_allLongWorkTime); + shiftInfoCominfoBean.setRestLongTimeIndex(shiftInfoBean.getRestLongTimeIndex()); + shiftInfoCominfoBean.setWorkAcrossTime(real_workAcrossTime); + shiftInfoCominfoBean.setEachWorkMins(eachWorkMins); + shiftInfoCominfoBean.setHalfWorkIndex(real_shift_halfWorkIndex); + shiftInfoCominfoBean.setWorkLongTimeIndex(workLongTimeIndex); + halfShiftComIndex.handleHalfTime(shiftInfoCominfoBean); + if(!real_shift_halfWorkIndex.isEmpty()){ + shiftInfoBean.setHalfWorkIndex(real_shift_halfWorkIndex); + } + }catch (Exception e){ + kqLog.info("加班生成数据报错:KQOverTimeRuleCalBiz:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + } + + + /** + * 开启了个性化设置之后,对加班数据的影响 + * @param ruleDetail + * @param signInTimeBean + * @param signOutTimeBean + * @param allWorkTime + * @param splitDate + * @param nextday + * @param resourceid + */ + public static Map do4ShiftRule(Map ruleDetail, + KQHrmScheduleSign signInTimeBean, KQHrmScheduleSign signOutTimeBean, + List allWorkTime, String splitDate, String nextday, String resourceid) { + Map shifRuleMap = Maps.newHashMap(); + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + if(!is_flow_humanized){ + return shifRuleMap; + } + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter minFormatter = DateTimeFormatter.ofPattern("HH:mm"); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + + List earlyinearlyout = null;//早到早走规则 + List lateinlateout = null;//晚到晚走规则 + List lateoutlatein = null;//晚走晚到规则 + String begintime = allWorkTime.get(0); + String endtime = allWorkTime.get(allWorkTime.size()-1); + boolean isEndAcross = false; + if(begintime.compareTo(endtime) > 0){ + //结束时间跨天了 + isEndAcross = true; + } + //早到早走后,引起下班时间变化后的时间 + LocalDateTime early_localEndDateTime = null; + //早到早走后,引起上班时间变化后的时间 + LocalDateTime early_localBeginDateTime = null; + //晚到晚走后,引起下班时间变化后的时间 + LocalDateTime late_localEndDateTime = null; + //晚到晚走后,引起上班时间变化后的时间 + LocalDateTime late_localBeginDateTime = null; + //晚走晚到后,引起上班时间变化后的时间 + LocalDateTime latein_localBeginDateTime = null; + + earlyinearlyout = (List) ruleDetail.get("earlyinearlyout"); + lateinlateout = (List) ruleDetail.get("lateinlateout"); + lateoutlatein = (List) ruleDetail.get("lateoutlatein"); + + String workbegindatetime = splitDate+" "+begintime+":00"; + LocalDateTime localBeginDateTime = LocalDateTime.parse(workbegindatetime,fullFormatter); + String workenddatetime = (isEndAcross ? nextday : splitDate)+" "+endtime+":00"; + LocalDateTime localEndDateTime = LocalDateTime.parse(workenddatetime,fullFormatter); + + long signIn_before_mins = 0; + long signIn_after_mins = 0; + long signOut_before_mins = 0; + long signOut_after_mins = 0; + if(signInTimeBean != null){ + String signInDate = signInTimeBean.getSigndate(); + String signInTime = signInTimeBean.getSigntime(); + //判断下签到和上班时间,是否存在早到或者晚到的情况的情况 + String fromDateTime = signInDate+" "+signInTime; + String toDateTime = workbegindatetime; + long signIn_mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + + if(signIn_mins > 0){ + //确实是早到了 + signIn_before_mins = signIn_mins; + }else if(signIn_mins < 0){ + //这属于是晚到了 + signIn_after_mins = Math.abs(signIn_mins); + } + } + if(signOutTimeBean != null){ + String signOutDate = signOutTimeBean.getSigndate(); + String signOutTime = signOutTimeBean.getSigntime(); + //判断下签退和下班时间,是否存在晚走的情况 + String fromDateTime = workenddatetime; + String toDateTime = signOutDate+" "+signOutTime; + long signOut_mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + + if(signOut_mins > 0){ + //这属于是晚走了 + signOut_after_mins = signOut_mins; + }else if(signOut_mins < 0){ + //这属于是早退了 + signOut_before_mins = Math.abs(signOut_mins); + } + } + + if (earlyinearlyout != null && earlyinearlyout.size() > 0 && signIn_before_mins > 0) { + //必须有早到时间才能继续下面的判断 + for (int i = 0; i < earlyinearlyout.size(); i++) { + Map rule = (Map) earlyinearlyout.get(i); + if (Util.null2String(rule.get("enable")).equals("1")) { + int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//早到时间 + int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//允许早走时间 + if (Util.null2String(rule.get("enablesame")).equals("1")) { + //使用相对时间 + if(signIn_before_mins >= advancetime){ + //如果打卡的早到时长已经完全大于了设置的早到时长,那么就可以早走整个postponetime + early_localEndDateTime = localEndDateTime.minusMinutes(postponetime); + early_localBeginDateTime = localBeginDateTime.minusMinutes(advancetime); + }else{ + early_localEndDateTime = localEndDateTime.minusMinutes(signIn_before_mins); + early_localBeginDateTime = localBeginDateTime.minusMinutes(signIn_before_mins); + } + break; + }else{ + if(signIn_before_mins >= advancetime){ + //如果打卡的早到时长已经完全大于了设置的早到时长,那么就可以早走整个postponetime + early_localEndDateTime = localEndDateTime.minusMinutes(postponetime); + early_localBeginDateTime = localBeginDateTime.minusMinutes(advancetime); + break; + } + } + } + } + } + + if (lateinlateout != null && lateinlateout.size() > 0 && signIn_after_mins > 0) { + //必须有晚到时间才能继续下面的判断 + for (int i = 0; i < lateinlateout.size(); i++) { + Map rule = (Map) lateinlateout.get(i); + if (Util.null2String(rule.get("enable")).equals("1")) { + int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//晚到时间 + int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//需要晚走时间 + if (Util.null2String(rule.get("enablesame")).equals("1")) { + //使用相对时间 + if(signIn_after_mins <= advancetime){ + //如果打卡的晚到时长必须要小于等于设置的晚到时长,才算满足,晚到多久就可以晚走多久 + late_localEndDateTime = localEndDateTime.plusMinutes(signIn_after_mins); + late_localBeginDateTime = localBeginDateTime.plusMinutes(signIn_after_mins); + } + break; + }else{ + if (signIn_after_mins <= advancetime) { + //如果打卡的晚到时长已经完全小于了设置的晚到时长,那么需要晚走整个postponetime + late_localEndDateTime = localEndDateTime.plusMinutes(postponetime); + late_localBeginDateTime = localBeginDateTime.plusMinutes(advancetime); + break; + } + } + } + } + } + + + if (lateoutlatein != null && lateoutlatein.size() > 0) { + + LocalDateTime tmp_localBeginDateTime = localBeginDateTime; + if(early_localBeginDateTime != null){ + tmp_localBeginDateTime = early_localBeginDateTime; + } + if(late_localBeginDateTime != null){ + tmp_localBeginDateTime = late_localBeginDateTime; + } + KQFormatShiftRule kqFormatShiftRule = new KQFormatShiftRule(); + int preDayLateOutMins = kqFormatShiftRule.getPreDayLateOutMins(resourceid, splitDate); + for (int i = 0; preDayLateOutMins > 0 && i < lateoutlatein.size(); i++) { + Map rule = (Map) lateoutlatein.get(i); + if (Util.null2String(rule.get("enable")).equals("1")) { + int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//晚走时间 + int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//允许晚到时间 + + if (Util.null2String(rule.get("enablesame")).equals("1")) { + if(preDayLateOutMins >= advancetime){ + //如果昨日的晚走时长已经完全大于了设置的晚走时长,那么就可以晚到整个postponetime + latein_localBeginDateTime = tmp_localBeginDateTime.plusMinutes(postponetime); + }else{ + latein_localBeginDateTime = tmp_localBeginDateTime.plusMinutes(preDayLateOutMins); + } + break; + }else{ + if (preDayLateOutMins >= advancetime) { + //如果昨日的晚走时长已经完全大于了设置的晚走时长,那么就可以晚到整个postponetime + latein_localBeginDateTime = tmp_localBeginDateTime.plusMinutes(postponetime); + break; + } + } + } + } + } + + + if(early_localEndDateTime != null){ + shifRuleMap.put("shift_type", "earlyinearlyout"); + String endDate = early_localEndDateTime.format(dateFormatter); + String endmin = early_localEndDateTime.format(minFormatter); + if(endDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_endworktime", kqTimesArrayComInfo.turn24to48Time(endmin)); + }else{ + shifRuleMap.put("shift_endworktime", endmin); + } + } + if(late_localEndDateTime != null){ + shifRuleMap.put("shift_type", "lateinlateout"); + String endDate = late_localEndDateTime.format(dateFormatter); + String endmin = late_localEndDateTime.format(minFormatter); + if(endDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_endworktime", kqTimesArrayComInfo.turn24to48Time(endmin)); + }else{ + shifRuleMap.put("shift_endworktime", endmin); + } + } + if(early_localBeginDateTime != null){ + shifRuleMap.put("shift_type", "earlyinearlyout"); + String beginDate = early_localBeginDateTime.format(dateFormatter); + String beginmin = early_localBeginDateTime.format(minFormatter); + if(beginDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin)); + }else{ + shifRuleMap.put("shift_beginworktime", beginmin); + } + } + if(late_localBeginDateTime != null){ + shifRuleMap.put("shift_type", "lateinlateout"); + String beginDate = late_localBeginDateTime.format(dateFormatter); + String beginmin = late_localBeginDateTime.format(minFormatter); + if(beginDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin)); + }else{ + shifRuleMap.put("shift_beginworktime", beginmin); + } + } + if(latein_localBeginDateTime != null){ + shifRuleMap.put("shift_type", "lateoutlatein"); + String beginDate = latein_localBeginDateTime.format(dateFormatter); + String beginmin = latein_localBeginDateTime.format(minFormatter); + if(beginDate.compareTo(splitDate) > 0){ + shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin)); + }else{ + shifRuleMap.put("shift_beginworktime", beginmin); + } + } + return shifRuleMap; + } + +} diff --git a/src/com/engine/kq/biz/KQShiftScheduleComInfo.java b/src/com/engine/kq/biz/KQShiftScheduleComInfo.java new file mode 100644 index 0000000..550745b --- /dev/null +++ b/src/com/engine/kq/biz/KQShiftScheduleComInfo.java @@ -0,0 +1,167 @@ +package com.engine.kq.biz; + +import weaver.cache.*; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; + +public class KQShiftScheduleComInfo extends CacheBase{ + + protected static String TABLE_NAME = "kq_shiftschedule"; + /** sql中的where信息,不要以where开始 */ + protected static String TABLE_WHERE = "where (isdelete is null or isdelete <> '1') ";//默认加载今天之前一个月数据 + /** sql中的order by信息,不要以order by开始 */ + protected static String TABLE_ORDER = "id"; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + @CacheColumn(name = "serialid") + protected static int serialid; + + @CacheColumn(name = "groupid") + protected static int groupid; + + private boolean isFormat = false; + private int shiftGroupId = -1; + + @Override + public CacheMap initCache() throws Exception { + CacheMap localData = super.createCacheMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + if ("mysql".equals(rs.getDBType())) { + sql += " select CONCAT(resourceid,'|',kqdate) as id, serialid,groupid from kq_shiftschedule "+TABLE_WHERE + " and kqdate>='"+DateUtil.getFirstDayOfMonth(DateUtil.getCurrentDate())+"' and kqdate<='"+ DateUtil.getCurrentDate()+"'"; + }else if("sqlserver".equals(rs.getDBType())){ + sql += " select CONVERT(varchar,resourceid)+'|'+kqdate as id, serialid,groupid from kq_shiftschedule "+TABLE_WHERE + " and kqdate>='"+DateUtil.getFirstDayOfMonth(DateUtil.getCurrentDate())+"' and kqdate<='"+ DateUtil.getCurrentDate()+"'"; + } else { + sql = "select resourceid||'|'||kqdate as id, serialid,groupid from kq_shiftschedule "+TABLE_WHERE + " and kqdate>='"+DateUtil.getFirstDayOfMonth(DateUtil.getCurrentDate())+"' and kqdate<='"+ DateUtil.getCurrentDate()+"'"; + } + + sql += " and (isdelete is null or isdelete <> '1')"; + rs.executeQuery(sql); + while (rs.next()) { + String id = Util.null2String(rs.getString(PK_NAME)); + CacheItem row = createCacheItem(); + parseResultSetToCacheItem(rs, row); + + // 这里需要记得调用这个 转化方法, 否则 这些自己加载的数据就不能正确转化,当然你也可以直接在转化逻辑写在这里,不过这样先让代码重复了 + modifyCacheItem(id, row); + localData.put(id, row); + } + return localData; + } + +// /** +// * 性能原因取消后续加载 +// * @return +// */ +// protected boolean autoInitIfNotFound() { +// return false; +// } + + @Override + public CacheItem initCache(String key) { + if (key == null || "".equals(key.trim())) { + return null; + } + + String[] keys = Util.splitString(key,"|"); + String resourceid = keys[0]; + String kqdate = keys[1]; + RecordSet rs = new RecordSet(); + String sql = ""; + if ("mysql".equals(rs.getDBType())) { + sql += " select CONCAT(resourceid,'|',kqdate) as id, serialid,groupid from kq_shiftschedule "+TABLE_WHERE+ " and resourceid ='"+resourceid+"' and kqdate='"+kqdate+"'"; + }else if("sqlserver".equals(rs.getDBType())){ + sql += " select CONVERT(varchar,resourceid)+'|'+kqdate as id, serialid,groupid from kq_shiftschedule "+TABLE_WHERE+ " and resourceid ='"+resourceid+"' and kqdate='"+kqdate+"'"; + } else { + sql = "select resourceid||'|'||kqdate as id, serialid,groupid from kq_shiftschedule "+TABLE_WHERE+ " and resourceid ='"+resourceid+"' and kqdate='"+kqdate+"'"; + } + + sql += " and (isdelete is null or isdelete <> '1')"; + rs.executeQuery(sql); + if (rs.next()) { + CacheItem cacheItem = createCacheItem(); + parseResultSetToCacheItem(rs, cacheItem); + modifyCacheItem(key, cacheItem); + return cacheItem; + } + return null; + } + + private String getId() { + return (String) getRowValue(PK_INDEX); + } + + private String getSerialId() { + return (String) getRowValue(serialid); + } + + private String getSerialId(String key) { + if(!this.isFormat){ + return (String) getValue(serialid, key); + } + return getSerialidBySql(key); + } + + private String getSerialidBySql(String key) { + + String sql_serialid = ""; + if (key == null || "".equals(key.trim())) { + return null; + } + String[] keys = Util.splitString(key,"|"); + String resourceid = keys[0]; + String kqdate = keys[1]; + RecordSet rs = new RecordSet(); + String sql = ""; + if ("mysql".equals(rs.getDBType())) { + sql += " select CONCAT(resourceid,'|',kqdate) as id, serialid,groupid from kq_shiftschedule where (isdelete is null or isdelete <> '1') and resourceid ='"+resourceid+"' and kqdate='"+kqdate+"'"; + }else if("sqlserver".equals(rs.getDBType())){ + sql += " select CONVERT(varchar,resourceid)+'|'+kqdate as id, serialid,groupid from kq_shiftschedule where (isdelete is null or isdelete <> '1') and resourceid ='"+resourceid+"' and kqdate='"+kqdate+"'"; + } else { + sql = "select resourceid||'|'||kqdate as id, serialid,groupid from kq_shiftschedule where (isdelete is null or isdelete <> '1') and resourceid ='"+resourceid+"' and kqdate='"+kqdate+"'"; + } + + if(shiftGroupId > 0) { + sql += " and groupid = "+shiftGroupId; + } + sql += " and (isdelete is null or isdelete <> '1')"; + rs.executeQuery(sql); + if (rs.next()) { + sql_serialid = rs.getString("serialid"); + } + return sql_serialid; + } + + private String getGroupId(String key) { + return (String) getValue(groupid, key); + } + + public String getSerialId(String resourceid, String kqdate) { + if(Util.null2String(resourceid).length()==0||Util.null2String(kqdate).length()==0)return ""; + return this.getSerialId(resourceid+"|"+kqdate); + } + + public String getGroupId(String resourceid, String kqdate) { + if(Util.null2String(resourceid).length()==0||Util.null2String(kqdate).length()==0)return ""; + return this.getGroupId(resourceid+"|"+kqdate); + } + + public boolean isFormat() { + return isFormat; + } + + public void setFormat(boolean format) { + isFormat = format; + } + + public int getShiftGroupId() { + return shiftGroupId; + } + + public void setShiftGroupId(int shiftGroupId) { + this.shiftGroupId = shiftGroupId; + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQShiftscheduleBiz.java b/src/com/engine/kq/biz/KQShiftscheduleBiz.java new file mode 100644 index 0000000..46c33ed --- /dev/null +++ b/src/com/engine/kq/biz/KQShiftscheduleBiz.java @@ -0,0 +1,196 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.bean.KqShiftscheduleOperateLog; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; +import com.engine.kq.log.KQLog; +import weaver.common.DateUtil; +import weaver.conn.BatchRecordSet; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; + +import java.util.*; + +public class KQShiftscheduleBiz extends BaseBean { + private KQLog kqLog = new KQLog(); + public static final Map>> keyList = new HashMap<>(); + + // 添加日志功能 + private List> operateLogParams = new ArrayList<>(); + // 操作类型 操作人 考勤组名称+id 被修改人 被修改班次日期 被修改班次+id 排班设置行id + private List operateLogParam = null; + + private String creatorId; + + public String getCreatorId() { + return creatorId; + } + + public void setCreatorId(String creatorId) { + this.creatorId = creatorId; + } + + public void saveShiftschedule(String userIds, String fromDate, String toDate, String serialId, String groupId){ + saveShiftschedule(userIds, fromDate, toDate, serialId, groupId, null); + } + /** + * 调班流程 保存排班数据 + * @param userIds + * @param fromDate + * @param toDate + * @param serialId + * @param groupId + */ + public void saveShiftschedule(String userIds, String fromDate, String toDate, String serialId, String groupId, Map result){ + BatchRecordSet bRs = new BatchRecordSet(); + RecordSet rs = new RecordSet(); + List> paramInsert = new ArrayList<>(); + List params = null; + String sql = ""; + try { + KQShiftScheduleComInfo kqShiftScheduleComInfo = new KQShiftScheduleComInfo(); + KqShiftScheduleRoleBiz kqShiftScheduleRoleBiz = new KqShiftScheduleRoleBiz(); + List sqlParams = new ArrayList(); + List kqShiftsRoleList = null; + Object[] objects= DBUtil.transListIn(userIds,sqlParams); + + sql = "select * from kq_shiftschedule where resourceid in("+objects[0]+") and groupid=? and kqdate>=? and kqdate<=? and (isdelete is null or isdelete <> '1')"; + rs.executeQuery(sql, sqlParams,groupId, fromDate,toDate); + Map oldShiftValue = new HashMap<>(); + Map oldShiftId = new HashMap<>(); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("resourceid")); + String shiftScheduleDate = Util.null2String(rs.getString("kqdate")); + String oldSerialid = Util.null2String(rs.getString("serialid")); + String oldId = Util.null2String(rs.getString("id")); + if(!"".equals(oldSerialid)) { + String key = resourceid+"#"+shiftScheduleDate; + oldShiftValue.put(key, oldSerialid); + oldShiftId.put(key, oldId); + } + } + + List lsUserId = Util.splitString2List(userIds,","); + Map paramsValidate = new HashMap<>(); + paramsValidate.put("groupId",groupId); + if(result != null) { + String operatorId = getCreatorId(); + kqShiftsRoleList = kqShiftScheduleRoleBiz.getUfKqShiftScheduleRoleValue(operatorId, groupId); + kqLog.info("operatorId:::"+operatorId+":::kqShiftsRoleList:::"+ JSON.toJSONString(kqShiftsRoleList)); + } + KqMembersValidateBiz kqMembersValidateBiz = new KqMembersValidateBiz(); + paramsValidate.put("isNoAccount","1"); + Map> validateResult = null; + if(keyList.containsKey(("groupId#"+groupId))) { + validateResult = keyList.get("groupId#"+groupId); + } else { + validateResult = new KqMembersValidateBiz(paramsValidate, null).getKqMembersValidateList(); + keyList.put(("groupId#"+groupId), validateResult); + } + + for(String userId : lsUserId) { + if(!"".equals(getCreatorId()) && !userId.equals(getCreatorId())) { + if(kqShiftsRoleList != null && !kqShiftsRoleList.isEmpty()) { + if(!kqShiftsRoleList.contains(userId)) { + ResourceComInfo rci = new ResourceComInfo(); + String lastName = rci.getLastname(userId); + String operatorName = rci.getLastname(getCreatorId()); + User user = new User(Integer.valueOf(getCreatorId())); + result.put("message",lastName+ SystemEnv.getHtmlLabelName(19008,user.getLanguage())+operatorName+SystemEnv.getHtmlLabelName(545899,user.getLanguage())); + return; + } + } + } + boolean isEnd = false; + List validateList = validateResult.get(userId); + if(validateList == null) { // 可能是新入职人员找到,那么重新再找一次 + validateResult = new KqMembersValidateBiz(paramsValidate, null).getKqMembersValidateList(); + keyList.put(("groupId#"+groupId), validateResult); + validateList = validateResult.get(userId); + } + Calendar cal = DateUtil.getCalendar(); + for (String date = fromDate; !isEnd; ) { + if (date.equals(toDate)) isEnd = true; + // 如果超过了有效期,就不存储数据 + boolean isInRange = kqMembersValidateBiz.isInRange(date, validateList); + if(!isInRange) { + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + continue; + } + params = new ArrayList(); + params.add(date); + params.add(serialId); + params.add(userId); + params.add(groupId); + paramInsert.add(params); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + } + List> lsFormatParams = new ArrayList<>(); + List formatParams = null; + KqShiftscheduleOperateLog bean = null; + ResourceComInfo rci = new ResourceComInfo(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + String flowCreateUserId = "".equals(Util.null2String(creatorId)) ? "1" : creatorId; + User user = new User(Integer.parseInt(flowCreateUserId)); + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + for (int i = 0; paramInsert != null && i < paramInsert.size(); i++) { + params = paramInsert.get(i); + String kqdate = Util.null2String(params.get(0)); + String serialid = Util.null2String(params.get(1)); + String resourceid = Util.null2String(params.get(2)); + String tmp_groupId = Util.null2String(params.get(3)); + String key = resourceid+"#"+kqdate; + String oldSerialid = Util.null2String(oldShiftValue.get(key)); + if(oldSerialid.equals(serialid)) { + continue; + } + boolean flag = false; + if("".equals(oldSerialid)) { // 原先这天没有班次,属于新增 + bean = new KqShiftscheduleOperateLog(0,user.getLastname(),kqGroupComInfo.getGroupname(groupId)+"(id:"+groupId+")",rci.getLastname(resourceid), + kqdate, "", "", ("-1".equals(serialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftManagementComInfo.getSerial(serialid)+"(id:"+serialid+")"), user.getLanguage()); + addLog(bean); + sql = "insert into kq_shiftschedule (kqdate,serialid,resourceid,groupid,isdelete) values(?,?,?,?,0)"; + flag = rs.executeUpdate(sql, kqdate,serialid,resourceid,tmp_groupId); + } else { // 更新 + bean = new KqShiftscheduleOperateLog(1,user.getLastname(),kqGroupComInfo.getGroupname(groupId)+"(id:"+groupId+")",rci.getLastname(resourceid), + kqdate, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftManagementComInfo.getSerial(oldSerialid)+"(id:"+oldSerialid+")"), Util.null2String(oldShiftId.get(key)), ("-1".equals(serialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftManagementComInfo.getSerial(serialid)+"(id:"+serialid+")"), user.getLanguage()); + addLog(bean); + String oldId = Util.null2String(oldShiftId.get(key)); + sql = "update kq_shiftschedule set serialid=? where id=? "; + flag = rs.executeUpdate(sql,serialid,oldId); + } + kqLog.info("flag"+flag+",kqdate"+kqdate+",serialid"+serialid+",resourceid"+resourceid+",tmp_groupId"+tmp_groupId); + formatParams = new ArrayList<>(); + formatParams.add(resourceid); + formatParams.add(kqdate); + lsFormatParams.add(formatParams); + } + sql = "insert into kq_shiftscheduleoperate_log(operatetype,operator,kqgroupname,changeduser,changedshiftdate,changedshiftname,kqshiftid) values(?,?,?,?,?,?,?)"; + bRs.executeBatchSqlNew(sql, operateLogParams); + new KQFormatBiz().format(lsFormatParams, 17); + + kqShiftScheduleComInfo.removeCache(); + }catch (Exception e){ + writeLog(e); + } + } + + private void addLog(KqShiftscheduleOperateLog bean) { + operateLogParam = new ArrayList<>(); + operateLogParam.add(bean.getOperatetype()); + operateLogParam.add(bean.getOperator()); + operateLogParam.add(bean.getKqgroupname()); + operateLogParam.add(bean.getChangeduser()); + operateLogParam.add(bean.getChangedshiftdate()); + operateLogParam.add(bean.getChangedshiftname()); + operateLogParam.add(bean.getKqshiftid()); + operateLogParams.add(operateLogParam); + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQSignDataFormat.java b/src/com/engine/kq/biz/KQSignDataFormat.java new file mode 100644 index 0000000..455486b --- /dev/null +++ b/src/com/engine/kq/biz/KQSignDataFormat.java @@ -0,0 +1,916 @@ +package com.engine.kq.biz; +import com.engine.kq.bean.KQHrmScheduleSign; +import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum; +import com.engine.kq.entity.KQGroupEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +/** + * 获取签到签退按钮 + * 以及考勤流程数据 + * 以及上次签到时间 + */ +public class KQSignDataFormat extends BaseBean{ + + private KQLog kqLog = new KQLog(); + private String curDate = DateUtil.getCurrentDate(); + private DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + private DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + private LocalDateTime now = LocalDateTime.now(); + private User user; + private Map params = null; + public KQSignDataFormat(Map params, User user) { + this.user = user; + this.params = params; + this.curDate = Util.null2String(params.get("curDate")); + this.now = (LocalDateTime)(params.get("now")); + } + + /** + * 一个完整的timelines里map的样子 + * { + * across: "0" 是否是次日 + * active: "1" 是否是允许签到签退的范围 + * belongdate: "2018-12-27" 根据班次获取的所属日期 + * canSignTime: "2018-12-27 00:00:00" 允许签到签退的时间范围 + * date: "2018-12-27" 签到签退的日期 + * datetime: "2018-12-27 08:30:00" 签到签退日期+上下班时间 + * isYellow: "1" 当前时间是否已经是迟到或者早退 + * isacross: "0" 当前时间对应的班次是否是跨天班次 + * islastsign: "0" 是否是最后一次签退 + * min: "0" 允许打卡时段控制 + * needSign: "1" 是否可以签到签退,在active的基础上增加了hrmschedulesign签到签退数据的判断 + * pre: "0" 是否是昨日 + * serialid: "521" 班次id + * signsection: "2018-12-27 00:00:00#2018-12-27 14:00:00" 允许签到签退的范围 + * time: "08:30" 上班时间/下班时间 + * type: "on" 对应的是签到还是签退的状态 + * workdatesection: "2018-12-27 08:30:00#2018-12-27 11:30:00" 上下班日期时段 + * worksection: "08:30-11:30" 上下班时间 + * } + * @return + */ + public Map execute() { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + + //真正的考勤时间线 + List timelineList = new ArrayList<>(); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + KQReportBiz kqReportBiz = new KQReportBiz(); + + String lastname = user.getLastname(); + String messagerurl = resourceComInfo.getMessagerUrls(""+user.getUID()); + String shortname = ""; + + String ismobile = Util.null2String(params.get("ismobile")); + + boolean USERICONLASTNAME = Util.null2String(new BaseBean().getPropValue("Others" , "USERICONLASTNAME")).equals("1"); + if(USERICONLASTNAME&&(messagerurl.indexOf("icon_w_wev8.jpg")>-1||messagerurl.indexOf("icon_m_wev8.jpg")>-1||messagerurl.indexOf("dummyContact.png")>-1)){ + shortname = User.getLastname(Util.null2String(Util.formatMultiLang(lastname, ""+user.getLanguage()))); + } + + String groupname = ""; + String groupid = kqGroupMemberComInfo.getKQGroupId(user.getUID()+""); + String outsidesign = ""; + KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID()+""); + if (kqGroupEntity != null) { + outsidesign = kqGroupEntity.getOutsidesign(); + }else{ + groupname = SystemEnv.getHtmlLabelName(10000799,weaver.general.Util.getIntValue(user.getLanguage())); + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + retmap.put("groupname", groupname); + return retmap; + } + + boolean isAdmin = user.isAdmin(); + if(isAdmin){ + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + return retmap; + } +// * 1、PC和移动端均可打卡 +// * 2、仅PC可打卡 +// * 3、仅移动端可打卡 +// * 4、无需打卡 + String groupSignType = getSignType(); + //无需打卡 + if("4".equalsIgnoreCase(groupSignType)){ + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + return retmap; + } + if("2".equalsIgnoreCase(groupSignType)){ + if("1".equalsIgnoreCase(ismobile)){ + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + return retmap; + } + } + if("3".equalsIgnoreCase(groupSignType)){ + if(!"1".equalsIgnoreCase(ismobile)){ + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + return retmap; + } + } + + String yesterday = LocalDate.parse(curDate).minusDays(1).format(dateFormatter); + List yesterdayLineButton = new ArrayList<>(); + List todayLineButton = new ArrayList<>(); + List restLineButton = new ArrayList<>(); + + //弹性工作制 + List freeLineButton = new ArrayList<>(); + + //先获取考勤工作时段的按钮 上下班时间 + Map todayLineMap = KQDurationCalculatorUtil.getWorkButton(user, curDate,true); + boolean isfree = "1".equalsIgnoreCase(Util.null2String(todayLineMap.get("isfree"))); + + if(isfree){ + do4FreeLine(user,freeLineButton,todayLineMap); + if(freeLineButton != null && !freeLineButton.isEmpty()){ + timelineList.addAll(freeLineButton); + retmap.put("lastname", lastname); + retmap.put("shortname", shortname); + retmap.put("messagerurl", messagerurl); + retmap.put("groupname", groupname+SystemEnv.getHtmlLabelName(10000800,weaver.general.Util.getIntValue(user.getLanguage()))); + retmap.put("outsidesign", outsidesign); + retmap.put("date", curDate); + retmap.put("timeline", timelineList); + retmap.put("status", "1"); + return retmap; + } + } + //每次打开考勤按钮的时候,都只能有一个活动按钮 + List activeList = new ArrayList<>(); + + if(!todayLineMap.isEmpty()){ + if(todayLineMap.get("pre_timelineList") != null){ + do4YesterdayLine(todayLineMap,yesterdayLineButton,kqReportBiz,timelineList,yesterday,activeList); + } + if(todayLineMap.get("timelineList") != null){ + do4TodayLine(todayLineMap,todayLineButton,kqReportBiz,timelineList,activeList); + } + }else{ + //节假日或者休息日需要默认给客户拼接一个timelineList + retmap.put("isrest", "1"); + do4RestLine(""+user.getUID(),restLineButton); + timelineList.addAll(restLineButton); + } + + + + + + if(groupid.length() > 0){ + groupname = SystemEnv.getHtmlLabelName(10000801,weaver.general.Util.getIntValue(user.getLanguage()))+kqGroupComInfo.getGroupname(groupid); + }else{ + groupname = SystemEnv.getHtmlLabelName(10000799,weaver.general.Util.getIntValue(user.getLanguage())); + } + + retmap.put("lastname", lastname); + retmap.put("shortname", shortname); + retmap.put("messagerurl", messagerurl); + retmap.put("groupname", groupname); + retmap.put("outsidesign", outsidesign); + retmap.put("date", curDate); + retmap.put("timeline", timelineList); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + /** + * 当日的考勤按钮处理 + * @param todayLineMap + * @param todayLineButton + * @param kqReportBiz + * @param timelineList + * @param activeList + */ + private void do4TodayLine(Map todayLineMap, List todayLineButton, + KQReportBiz kqReportBiz, List timelineList, + List activeList) { + + List todayLine = (List)todayLineMap.get("timelineList"); + if(todayLine != null && !todayLine.isEmpty()){ + getWorkTimeButton(false, todayLine,todayLineButton); + //获取当天的考勤数据 +// List reports = kqReportBiz.getKqDateInfo(""+user.getUID(),curDate,curDate,true); + List reports = new ArrayList<>(); + getSignButton(user.getUID()+"",todayLineButton,reports); + timelineList.addAll(todayLineButton); + } + } + + /** + * 昨日跨天的考勤按钮处理 + * @param yesterdayLineMap + * @param yesterdayLineButton + * @param kqReportBiz + * @param timelineList + * @param yesterday + * @param activeList + */ + private void do4YesterdayLine(Map yesterdayLineMap, + List yesterdayLineButton, KQReportBiz kqReportBiz, + List timelineList, String yesterday, List activeList) { + + List yesterdayLine = (List)yesterdayLineMap.get("pre_timelineList"); + if(yesterdayLine != null && !yesterdayLine.isEmpty()){ + getWorkTimeButton(true, yesterdayLine,yesterdayLineButton); + //获取前一天的考勤数据 +// List reports = kqReportBiz.getKqDateInfo(""+user.getUID(),yesterday,yesterday,true); + List reports = new ArrayList<>(); + getSignButton(user.getUID()+"",yesterdayLineButton,reports); + timelineList.addAll(yesterdayLineButton); + } + } + + /** + * 针对自由工作制的人员单独处理 + * @param user + * @param freeLineButton + * @param todayLineMap + */ + private void do4FreeLine(User user, List freeLineButton, + Map todayLineMap) { + String resourceId = ""+user.getUID(); + if(todayLineMap != null && !todayLineMap.isEmpty()){ + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + LocalTime curTime = LocalTime.now(); + + String signStart = Util.null2String(todayLineMap.get("signStart"));//签到开始时间 + String workMins = Util.null2String(todayLineMap.get("workMins"));//工作时长 + LocalTime signStartLocal = LocalTime.parse(signStart+":00", dateTimeFormatter); + boolean canSign = false; + if(curTime.isAfter(signStartLocal)){ + canSign = true; + } + + List signInList = new ArrayList<>(); + List signOutList = new ArrayList<>(); + + KQScheduleSignBiz kqScheduleSignBiz = new KQScheduleSignBiz.KQScheduleSignParamBuilder().resourceidParam(resourceId) + .userTypeParam(user.getLogintype()).signDateParam(curDate).build(); + List kqHrmScheduleSigns = kqScheduleSignBiz.getFreeScheduleSignInfo(); + if(kqHrmScheduleSigns != null && !kqHrmScheduleSigns.isEmpty()) { + for(KQHrmScheduleSign sign : kqHrmScheduleSigns){ + String signtype = sign.getSigntype(); + String signtime = sign.getSigntime(); + String signdate = sign.getSigndate(); + String signStatus = sign.getSignstatus(); + String addr = sign.getAddr(); + Map signWorkMapTmp = new HashMap<>(); + signWorkMapTmp.put("signtime", signtime); + signWorkMapTmp.put("addr", addr); + signWorkMapTmp.put("signdate", signdate); + signWorkMapTmp.put("signStatus", signStatus); + + //签到 + if("1".equalsIgnoreCase(signtype)){ + signInList.add(signWorkMapTmp); + } + //签退 + if("2".equalsIgnoreCase(signtype)){ + signOutList.add(signWorkMapTmp); + } + } + for(int i = 0 ; i signWorkMap = (Map) signInList.get(i); + String signtime = Util.null2String(signWorkMap.get("signtime")); + String addr = Util.null2String(signWorkMap.get("addr")); + freeLineButton.add(reBuildFreeButton("on", curDate, "0", "0",signtime,addr)); + } + + for(int i = 0 ; i signWorkMap = (Map) signOutList.get(i); + String signtime = Util.null2String(signWorkMap.get("signtime")); + String addr = Util.null2String(signWorkMap.get("addr")); + freeLineButton.add(reBuildFreeButton("off", curDate, "0", "0",signtime,addr)); + } + if(signInList.size() == signOutList.size()){ + //如果是成对存在的,那么需要再多出来俩,支持多次签到签退 + freeLineButton.add(reBuildFreeButton("on", curDate, "1", canSign?"1":"0","","")); + freeLineButton.add(reBuildFreeButton("off", curDate, "0", "0","","")); + }else{ + //如果不是成对存在,一定是签到多,签退少,当前处于需要签退的状态 + freeLineButton.add(reBuildFreeButton("off", curDate, "1", "1","","")); + } + + }else{ + //如果没有考勤数据,那么就是先签到再签退 + freeLineButton.add(reBuildFreeButton("on", curDate, "1", canSign?"1":"0","","")); + freeLineButton.add(reBuildFreeButton("off", curDate, "0", "0","","")); + } + } + + } + + private Map reBuildFreeButton(String type,String date,String active,String needSign,String signTime,String position){ + Map freetimelineMap = new HashMap<>(); + freetimelineMap.put("type", type); + freetimelineMap.put("belongdate", date); + freetimelineMap.put("date", date); + freetimelineMap.put("active", active); + freetimelineMap.put("needSign", needSign); + freetimelineMap.put("signTime", signTime); + freetimelineMap.put("position", position); + freetimelineMap.put("time", ""); + freetimelineMap.put("isfree", "1"); + + return freetimelineMap; + } + + /** + * 真对非工作时间的签到签退 + * @param resourceId + * @param restLineButton + */ + private void do4RestLine(String resourceId, List restLineButton) { + boolean hasSignIn = false; + boolean hasSignOut = false; + boolean isActive = true; + Map timelineOnMap = new HashMap<>(); + timelineOnMap.put("type", "on"); + timelineOnMap.put("time", ""); + timelineOnMap.put("belongdate", curDate); + timelineOnMap.put("date", curDate); + Map timelineOffMap = new HashMap<>(); + timelineOffMap.put("type", "off"); + timelineOffMap.put("time", ""); + timelineOffMap.put("belongdate", curDate); + timelineOffMap.put("date", curDate); + + KQScheduleSignBiz kqScheduleSignBiz = new KQScheduleSignBiz.KQScheduleSignParamBuilder().resourceidParam(resourceId) + .userTypeParam(user.getLogintype()).signDateParam(curDate).build(); + Map signMap = kqScheduleSignBiz.getScheduleSignInfo(); + if(signMap != null && !signMap.isEmpty()) { + KQHrmScheduleSign signInTimeBean = signMap.get("signin"); + KQHrmScheduleSign signOutTimeBean = signMap.get("signout"); + if(signInTimeBean != null){ + String signtimeTmp = Util.null2String(signInTimeBean.getSigntime()); + timelineOnMap.put("signTime", signtimeTmp); + timelineOnMap.put("position", Util.null2String(signInTimeBean.getAddr())); + hasSignIn = true; + } + if(signOutTimeBean != null){ + String signtimeTmp = Util.null2String(signOutTimeBean.getSigntime()); + timelineOffMap.put("signTime", signtimeTmp); + timelineOffMap.put("position", Util.null2String(signOutTimeBean.getAddr())); + hasSignOut = true; + } + if(hasSignIn){ + //有签到 就记录下 + timelineOffMap.put("signInTime4Out", timelineOnMap.get("signTime")); + } + } + getActiveSign(isActive, hasSignIn, hasSignOut, timelineOnMap, timelineOffMap); + restLineButton.add(timelineOnMap); + restLineButton.add(timelineOffMap); + } + + /** + * 获取考勤组的考勤方式 + * 1、PC和移动端均可打卡 + * 2、仅PC可打卡 + * 3、仅移动端可打卡 + */ + private String getSignType() { + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID()+""); + if(kqGroupEntity == null){ + return ""; + } + return kqGroupEntity != null ? kqGroupEntity.getSignintype(): ""; + } + + /** + * 根据工作时段来获取对应工作时段下的签到签退数据 + * @param resourceId + * @param timelineList + * @param reports + */ + private void getSignButton(String resourceId,List timelineList,List reports) { + if(!timelineList.isEmpty()){ + //获取当前时间 + LocalDateTime now = LocalDateTime.now(); + + //因为工作时段是成对存在的,所以timelineList一定是两两一对的复数[0,1] [2,3] [4,5] + int count = timelineList.size(); + + int workCnt = 0; + for(int i = 0 ; i < count ; ){ + //成对出现的上下班时间 + int on_i = i; + int off_i = i+1; + Map timelineOnMap = (Map)timelineList.get(on_i); + Map timelineOffMap = (Map)timelineList.get(off_i); + if(timelineOnMap != null && !timelineOnMap.isEmpty() && timelineOffMap != null && !timelineOffMap.isEmpty()){ + String onTime = Util.null2String(timelineOnMap.get("time")); + String belongdate = Util.null2String(timelineOnMap.get("belongdate")); + String onSignSectionTime = Util.null2String(timelineOnMap.get("signSectionTime")); + String onDateTime = Util.null2String(timelineOnMap.get("datetime")); + String onIsacross = Util.null2String(timelineOnMap.get("isacross")); + + String offTime = Util.null2String(timelineOffMap.get("time")); + String offSignSectionTime = Util.null2String(timelineOffMap.get("signSectionTime")); + String offDateTime = Util.null2String(timelineOffMap.get("datetime")); + String offIsacross = Util.null2String(timelineOffMap.get("isacross")); + + LocalDateTime onLocalDateTime = LocalDateTime.parse(onSignSectionTime,fullFormatter); + LocalDateTime offLocalDateTime = LocalDateTime.parse(offSignSectionTime,fullFormatter); + + LocalDateTime onworkDateTime = LocalDateTime.parse(onDateTime,fullFormatter); + LocalDateTime offworkDateTime = LocalDateTime.parse(offDateTime,fullFormatter); + + if("1".equalsIgnoreCase(onIsacross)){ + onTime = new KQTimesArrayComInfo().turn24to48Time(onTime); + timelineOffMap.put("belongtime", onTime); + } + if("1".equalsIgnoreCase(offIsacross)){ + offTime = new KQTimesArrayComInfo().turn24to48Time(offTime); + timelineOffMap.put("belongtime", offTime); + } + String worksection = onTime+"-"+offTime; + + if(i == (count-2)){ + //如果当前工作时段是最后一个工作时段 + timelineOnMap.put("islastsign", "1"); + timelineOffMap.put("islastsign", "1"); + }else{ + timelineOnMap.put("islastsign", "0"); + timelineOffMap.put("islastsign", "0"); + } + + boolean hasSignIn = false; + boolean hasSignOut = false; + boolean isActive = false; + + if((now.isAfter(onLocalDateTime) && now.isBefore(offLocalDateTime))||(now.isEqual(onLocalDateTime))||(now.isEqual(offLocalDateTime))){ + isActive = true; + } + if(now.isAfter(onworkDateTime)){ + timelineOnMap.put("isYellow", "1"); + }else{ + timelineOnMap.put("isYellow", "0"); + } + if(now.isBefore(offworkDateTime)){ + timelineOffMap.put("isYellow", "1"); + }else{ + timelineOffMap.put("isYellow", "0"); + } + if(onSignSectionTime.length() == 0 || offSignSectionTime.length() == 0){ + timelineOnMap.put("active", "0"); + timelineOffMap.put("active", "0"); + timelineOnMap.put("needSign", "0"); + timelineOffMap.put("needSign", "0"); + kqLog.info("考勤按钮报错:"+user.getLastname()+"::"+curDate+":onSignSectionTime:"+onSignSectionTime+":offSignSectionTime:"+offSignSectionTime); + return ; + } + String signDateTimeSql = buildSignSql(onSignSectionTime,offSignSectionTime); + + KQScheduleSignBiz kqScheduleSignBiz = new KQScheduleSignBiz.KQScheduleSignParamBuilder().resourceidParam(resourceId) + .userTypeParam(user.getLogintype()).signDateTimeSqlParam(signDateTimeSql).build(); + Map signMap = kqScheduleSignBiz.getScheduleSignInfo(); + if(signMap != null && !signMap.isEmpty()){ + KQHrmScheduleSign signInTimeBean = signMap.get("signin"); + KQHrmScheduleSign signOutTimeBean = signMap.get("signout"); + if(signInTimeBean != null){ + String signdate = Util.null2String(signInTimeBean.getSigndate()); + String signtimeTmp = Util.null2String(signInTimeBean.getSigntime()); + timelineOnMap.put("signbelong", "today"); + timelineOnMap.put("signbelongspan", SystemEnv.getHtmlLabelName(15537, user.getLanguage())); + if(signdate.compareTo(curDate) < 0){ + timelineOnMap.put("signbelong", "yesterday"); + timelineOnMap.put("signbelongspan", SystemEnv.getHtmlLabelName(82640, user.getLanguage())); + } + timelineOnMap.put("signTime", signtimeTmp); + timelineOnMap.put("position", Util.null2String(signInTimeBean.getAddr())); + hasSignIn = true; + } + if(signOutTimeBean != null){ + String signdate = Util.null2String(signOutTimeBean.getSigndate()); + String signtimeTmp = Util.null2String(signOutTimeBean.getSigntime()); + timelineOffMap.put("signbelong", SystemEnv.getHtmlLabelName(15537, user.getLanguage())); + timelineOffMap.put("signbelongspan", SystemEnv.getHtmlLabelName(15537, user.getLanguage())); + if(signdate.compareTo(curDate) < 0){ + timelineOffMap.put("signbelong", SystemEnv.getHtmlLabelName(82640, user.getLanguage())); + timelineOffMap.put("signbelongspan", SystemEnv.getHtmlLabelName(82640, user.getLanguage())); + } + timelineOffMap.put("signTime", signtimeTmp); + timelineOffMap.put("position", Util.null2String(signOutTimeBean.getAddr())); + hasSignOut = true; + } + } + //根据考勤工作时段获取相应时段下的签到签退数据 + if(!reports.isEmpty()){ + updateStatusByReport(reports,belongdate, timelineOnMap, timelineOffMap,worksection); + } + getActiveSign(isActive, hasSignIn, hasSignOut, timelineOnMap, timelineOffMap); + } + + i = i + 2; + workCnt++; + } + } + + } + + /** + * 根据考勤范围生成要查询的考勤表 + * @param onSignSectionTime + * @param offSignSectionTime + * @return + */ + private String buildSignSql(String onSignSectionTime, String offSignSectionTime) { + RecordSet rs = new RecordSet(); + StringBuffer sql = new StringBuffer(); + if(rs.getDBType().equals("oracle")||rs.getDBType().equals("postgresql")){ + sql.append(" AND signDate||' '||signTime>='").append(onSignSectionTime).append("' "); + sql.append(" AND signDate||' '||signTime<='").append(offSignSectionTime).append("' "); + }else if(rs.getDBType().equals("mysql")){ + sql.append(" AND concat(signDate,' ',signTime)>='").append(onSignSectionTime).append("' "); + sql.append(" AND concat(signDate,' ',signTime)<='").append(offSignSectionTime).append("' "); + }else{ + sql.append(" AND signDate+' '+signTime>='").append(onSignSectionTime).append("' "); + sql.append(" AND signDate+' '+signTime<='").append(offSignSectionTime).append("' "); + } + return sql.toString(); + } + + /** + * 根据考勤报表数据,更新打卡界面状态 + * @param reports + * @param belongdate + * @param timelineOnMap + * @param timelineOffMap + * @param worksection + */ + public void updateStatusByReport(List reports, String belongdate, + Map timelineOnMap, + Map timelineOffMap, String worksection) { + List checkInfoList = new ArrayList<>(); + for(int i = 0 ; i < reports.size() ; i++){ + Map reportData = (Map) reports.get(i); + if(reportData != null && !reportData.isEmpty()){ + String kqdate = Util.null2String(reportData.get("kqdate")); + if(belongdate.equalsIgnoreCase(kqdate)){ + checkInfoList = (List) reportData.get("checkInfo"); + if(checkInfoList != null && !checkInfoList.isEmpty()){ + for(int j = 0 ; j < checkInfoList.size() ; j++){ + Map kqData = (Map) checkInfoList.get(j); + String workbegintime = Util.null2String(kqData.get("workbegintime")); + String workendtime = Util.null2String(kqData.get("workendtime")); + if(worksection.equalsIgnoreCase((workbegintime+"-"+workendtime))){ + //如果有考勤数据,再根据考勤数据同步更新下 + setStatusByReport(kqData,timelineOnMap,timelineOffMap); + break; + } + } + } + } + } + } + + } + + /** + * 根据考勤报表数据返回签到签退按钮状态 + * @param reportData + * @param timelineOnMap + * @param timelineOffMap + */ + private void setStatusByReport(Map reportData, Map timelineOnMap, Map timelineOffMap) { + + String status = Util.null2String(reportData.get("status")); + if(status.contains(ButtonStatusEnum.ABSENT.getStatusCode())){ + //旷工 旷工大于一切 + timelineOnMap.put("status", ButtonStatusEnum.ABSENT.getStatusCode()); + timelineOffMap.put("status", ButtonStatusEnum.ABSENT.getStatusCode()); + return ; + } + if(status.contains(ButtonStatusEnum.NORMAL.getStatusCode())){ + timelineOnMap.put("status", ButtonStatusEnum.NORMAL.getStatusCode()); + timelineOffMap.put("status", ButtonStatusEnum.NORMAL.getStatusCode()); + return ; + } + + if(status.contains(ButtonStatusEnum.BELATE.getStatusCode())){ + //迟到 + timelineOnMap.put("status", ButtonStatusEnum.BELATE.getStatusCode()); + } + if(status.contains(ButtonStatusEnum.LEAVEERALY.getStatusCode())){ + //早退 + timelineOffMap.put("status", ButtonStatusEnum.LEAVEERALY.getStatusCode()); + } + if(status.contains(ButtonStatusEnum.NOSIGN.getStatusCode())){ + //漏签 + timelineOffMap.put("status", ButtonStatusEnum.NOSIGN.getStatusCode()); + } + } + + /** + * 生成时间轴上 需要签到和活动考勤点的标识 + * @param isActive + * @param hasSignIn + * @param hasSignOut + * @param timelineOnMap + * @param timelineOffMap + */ + private void getActiveSign(boolean isActive,boolean hasSignIn,boolean hasSignOut,Map timelineOnMap,Map timelineOffMap) { + + if(isActive){ + if(hasSignIn){ + if(hasSignOut){ + //签到了,签退了 + timelineOnMap.put("active", "0"); + timelineOffMap.put("active", "0"); + + timelineOnMap.put("needSign", "0"); + timelineOffMap.put("needSign", "0"); + timelineOffMap.put("reSign", "1"); + + }else{ + //签到了,未签退 + timelineOnMap.put("active", "0"); + timelineOffMap.put("active", "1"); + + timelineOnMap.put("needSign", "0"); + timelineOffMap.put("needSign", "1"); + + } + }else{ + if(hasSignOut){ + //未签到,签退了 理论上是不可能的 + + }else{ + //未签到未签退 + timelineOnMap.put("active", "1"); + timelineOffMap.put("active", "0"); + + timelineOnMap.put("needSign", "1"); + timelineOffMap.put("needSign", "0"); + + } + } + + }else{ + //如果都不在考勤范围内肯定不能签到签退 + timelineOnMap.put("active", "0"); + timelineOffMap.put("active", "0"); + + timelineOnMap.put("needSign", "0"); + timelineOffMap.put("needSign", "0"); + + } + } + + /** + * 先根据工作时段把考勤timeline基本信息加载一下 + * @param isYesterday + * @param timeLine + * @param timeLineButton + */ + private void getWorkTimeButton(boolean isYesterday, List timeLine, + List timeLineButton) { + + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + String yesterday = LocalDate.parse(curDate).minusDays(1).format(dateFormatter); + String nextday = LocalDate.parse(curDate).plusDays(1).format(dateFormatter); + + for(int i = 0 ; i < timeLine.size() ;){ + Map onTimelineMap = (Map)timeLine.get(i); + Map offTimelineMap = (Map)timeLine.get(i+1); + if(isYesterday){ + Map onTimelineMapTmp = reBuildYesTimeMap(onTimelineMap,yesterday,"on"); + Map offTimelineMapTmp = reBuildYesTimeMap(offTimelineMap,yesterday,"off"); + //如果允许打卡时间也跨天,那么也需要显示出来按钮 + if(Util.null2String(offTimelineMapTmp.get("signAcross")).equalsIgnoreCase("1")){ + timeLineButton.add(onTimelineMapTmp); + timeLineButton.add(offTimelineMapTmp); + } + }else{ + Map onTimelineMapTmp = reBuildTimeMap(onTimelineMap,nextday,"on"); + Map offTimelineMapTmp = reBuildTimeMap(offTimelineMap,nextday,"off"); + timeLineButton.add(onTimelineMapTmp); + timeLineButton.add(offTimelineMapTmp); + } + i = i + 2; + } + + } + + /** + * 针对前一天的工作时间 根据跨天判断重构一遍数据 + * @param timelineMap + * @param yesterday + * @param isOnOff + */ + private Map reBuildYesTimeMap(Map timelineMap, String yesterday, + String isOnOff) { + + Map lineMap = new HashMap<>(); + + String isacross = Util.null2String(timelineMap.get("isacross")); + String min = Util.null2String(timelineMap.get("min")); + String time = Util.null2String(timelineMap.get("time")); + String workmins = Util.null2String(timelineMap.get("workmins")); +// 打卡时段设置 一定是要开启的 + String isPunchOpen = "1"; + String signAcross = Util.null2String(timelineMap.get("signAcross")); + int tMin = Util.getIntValue(min,0); + + lineMap.put("type", timelineMap.get("type")); + lineMap.put("serialid", timelineMap.get("serialid")); + lineMap.put("isacross", isacross); + lineMap.put("time", time); + lineMap.put("belongtime", time); + lineMap.put("min", min); + lineMap.put("workmins", workmins); + lineMap.put("isPunchOpen", isPunchOpen); + lineMap.put("signAcross", signAcross); + + if("on".equalsIgnoreCase(isOnOff)){ + if("1".equalsIgnoreCase(isacross)){ + //上班时间,跨天 + lineMap.put("date", curDate);//打卡日期 + lineMap.put("belongdate", yesterday);//工作时段所属日期 + lineMap.put("pre", "0");//是否是昨日 + lineMap.put("across", "0");//是否是次日 + lineMap.put("datetime", curDate+" "+time+":00");//应打卡日期+时间 + + String canSignTime = curDate + " "+ time + ":00"; + if(tMin > 0) { + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + }else{ + //上班时间,不跨天 + lineMap.put("date", curDate); + lineMap.put("belongdate", yesterday); + lineMap.put("pre", "1"); + lineMap.put("across", "0"); + lineMap.put("datetime", yesterday+" "+time+":00");//应打卡日期+时间 + String canSignTime = yesterday + " "+ time + ":00"; + + if(tMin > 0) { + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + } + }else{ + if("1".equalsIgnoreCase(isacross)){ + //下班时间,跨天 + lineMap.put("date", curDate); + lineMap.put("belongdate", yesterday); + lineMap.put("pre", "0"); + lineMap.put("across", "0"); + lineMap.put("datetime", curDate+" "+time+":00");//应打卡日期+时间 + String canSignTime = curDate + " "+ time + ":00"; + if(tMin > 0) { + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + }else{ + //下班时间,不跨天 + lineMap.put("date", curDate); + lineMap.put("belongdate", yesterday); + lineMap.put("pre", "1"); + lineMap.put("across", "0"); + lineMap.put("datetime", yesterday+" "+time+":00");//应打卡日期+时间 + String canSignTime = yesterday + " "+ time + ":00"; + //如果开启了打卡时段设置 + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + } + + } + return lineMap; + } + + /** + * 针对今天的工作时间 根据跨天判断重构一遍数据 + * @param timelineMap + * @param nextday + * @param isOnOff + */ + private Map reBuildTimeMap(Map timelineMap, String nextday, + String isOnOff) { + Map lineMap = new HashMap<>(); + + String isacross = Util.null2String(timelineMap.get("isacross")); + String min = Util.null2String(timelineMap.get("min")); + String time = Util.null2String(timelineMap.get("time")); + String workmins = Util.null2String(timelineMap.get("workmins")); +// 打卡时段设置 一定是要开启的 + String isPunchOpen = "1"; + String signAcross = Util.null2String(timelineMap.get("signAcross")); + int tMin = Util.getIntValue(min,0); + + lineMap.put("type", timelineMap.get("type")); + lineMap.put("serialid", timelineMap.get("serialid")); + lineMap.put("isacross", isacross); + lineMap.put("time", time); + lineMap.put("belongtime", time); + lineMap.put("min", min); + lineMap.put("workmins", workmins); + lineMap.put("isPunchOpen", isPunchOpen); + lineMap.put("signAcross", signAcross); + + if("on".equalsIgnoreCase(isOnOff)){ + if("1".equalsIgnoreCase(isacross)){ + //上班时间,跨天 + lineMap.put("date", curDate); + lineMap.put("belongdate", curDate); + lineMap.put("pre", "0"); + lineMap.put("across", "1"); + lineMap.put("datetime", nextday+" "+time+":00");//应打卡日期+时间 + String canSignTime = nextday + " "+ time + ":00"; + //如果开启了打卡时段设置 + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + }else{ + //上班时间,不跨天 + lineMap.put("date", curDate); + lineMap.put("belongdate", curDate); + lineMap.put("pre", "0"); + lineMap.put("across", "0"); + lineMap.put("datetime", curDate+" "+time+":00");//应打卡日期+时间 + String canSignTime = curDate + " "+ time + ":00"; + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + } + }else{ + if("1".equalsIgnoreCase(isacross)){ + //下班时间,跨天 + lineMap.put("date", nextday); + lineMap.put("belongdate", curDate); + lineMap.put("pre", "0"); + lineMap.put("across", "1"); + lineMap.put("datetime", nextday+" "+time+":00");//应打卡日期+时间 + String canSignTime = nextday + " "+ time + ":00"; + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + }else{ + //下班时间,不跨天 + lineMap.put("date", curDate); + lineMap.put("belongdate", curDate); + lineMap.put("pre", "0"); + lineMap.put("across", "0"); + lineMap.put("datetime", curDate+" "+time+":00");//应打卡日期+时间 + String canSignTime = curDate + " "+ time + ":00"; + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + } + + } + return lineMap; + } + +} diff --git a/src/com/engine/kq/biz/KQSignRemindJob.java b/src/com/engine/kq/biz/KQSignRemindJob.java new file mode 100644 index 0000000..d16a76d --- /dev/null +++ b/src/com/engine/kq/biz/KQSignRemindJob.java @@ -0,0 +1,605 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +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.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.KQGroupEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.msgcenter.biz.ConfigManager; +import com.engine.msgcenter.biz.WeaMessageTypeConfig; +import com.google.common.collect.Sets; +import java.io.PrintWriter; +import java.io.StringWriter; +import weaver.common.DateUtil; +import weaver.common.MessageUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.email.EmailWorkRunnable; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.common.Tools; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.schedule.BaseCronJob; + +import java.util.*; + +public class KQSignRemindJob extends BaseCronJob { + + private BaseBean log = new BaseBean(); + + private KQLog kqLog = new KQLog(); + + private static List myTimerTaskList = new ArrayList(); + private static Timer timer = new Timer(); + + public void execute() { + String currentDate = Tools.getCurrentDate(); + kqLog.info(">>>>>>>>>>>>>>>>KQSignRemind>>>>>>>>>>>>>>begin>>>>>>>>>>>>>>>>"); + handleKqRemind(currentDate); + kqLog.info(">>>>>>>>>>>>>>>>KQSignRemind>>>>>>>>>>>>>>end>>>>>>>>>>>>>>>>"); + } + + private void handleKqRemind(String date) { + ResourceComInfo rci = null; + try { + rci = new ResourceComInfo(); + } catch (Exception e) { + log.writeLog(e); + } + Map> timeMap_begin = new HashMap>(); + Map> timeMap_end = new HashMap>(); + List beginList = new ArrayList(); + List endList = new ArrayList(); + KQGroupEntity kqGroupEntity = null; + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQShiftManagementComInfo shiftComInfo = new KQShiftManagementComInfo(); + + //add + Map shiftmap = new HashMap(); + String shiftsql = "select id,cardRemind from kq_shiftmanagement"; + RecordSet rs1 = new RecordSet(); + rs1.executeQuery(shiftsql); + while (rs1.next()){ + String id = Util.null2String(rs1.getString("id")); + String cardRemind = Util.null2String(rs1.getString("cardRemind")); + shiftmap.put(id,cardRemind); + } +// kqLog.info("KQSignRemind>>>>>shiftmap:" + shiftmap.toString()); + //end + boolean signremindCheck = signremindCheck(); + + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTime = null; + + String sql = "SELECT DISTINCT resourceId FROM (" + new KQGroupBiz().getGroupMemberSql() + ") t "; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String resourceId = recordSet.getString("resourceId"); + String status = StringUtil.vString(rci.getStatus(resourceId)); + String accountType = StringUtil.vString(rci.getAccountType(resourceId), "0"); + if (!("0".equals(status) || "1".equals(status) || "2".equals(status) || "3".equals(status))) { + continue; + } + if (!"0".equals(accountType)) { + continue; + } + kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(resourceId, date); + if (kqGroupEntity == null) { + kqLog.info("KQSignRemind>>>>>resourceId:" + resourceId + ">>>>kqGroupEntity:null"); + continue; + } + //判断是否是无需考勤人员 + String excludeId = kqGroupEntity.getExcludeid(); + List excludeIdList = Arrays.asList(excludeId.split(",")); + if (excludeIdList != null && excludeIdList.contains(resourceId)) { + kqLog.info("KQSignRemind>>>>>resourceId:" + resourceId + ">>>>无需考勤人员"); + continue; + } + String signtype = kqGroupEntity.getSignintype(); + //打卡方式是 无需打卡 + if("4".equalsIgnoreCase(signtype)){ + kqLog.info("KQSignRemind>>>>>resourceId:" + resourceId + ">>>>打卡方式是无需打卡"); + continue; + } + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceId, date, false); + if (shiftInfoBean == null) { + kqLog.info("KQSignRemind>>>>>resourceId:" + resourceId + ">>>>shiftInfoBean:null"); + continue; + } + String serialId = shiftInfoBean.getSerialid(); + if (serialId == null || "".equals(serialId)) { + kqLog.info("KQSignRemind>>>>>resourceId:" + resourceId + ">>>>serialId:"); + continue; + }else{ + if(serialId.length() > 0){ + String isRest = Util.null2s(kqShiftManagementComInfo.getIsRest(serialId),""); + if("1".equals(isRest)){ + kqLog.info("KQSignRemind>>>>>resourceId:" + resourceId + ">>>>isRest:"); + continue; + } + workTime = kqWorkTime.getWorkTime(resourceId, date); + if (workTime == null || (workTime != null && workTime.getWorkMins() == 0 && workTime.getNonWorkShift() != 1)) { + kqLog.info("KQSignRemind>>>>>resourceId:" + resourceId + ">>>>workmins=0:"); + continue; + }else{ + if(1 == workTime.getNonWorkShift()){ + kqLog.info("KQSignRemind>>>>>resourceId:" + resourceId + ">>>>getNonWorkShift=1:"); + continue; + } + } + } + } + String cardRemind = shiftComInfo.getCardRemind(serialId); + if (!"1".equals(cardRemind) || !"1".equals(shiftmap.get(serialId))) { + continue; + } + String cardRemOfSignIn = shiftComInfo.getCardRemOfSignIn(serialId); + String minsBeforeSignIn = shiftComInfo.getMinsBeforeSignIn(serialId); + String cardRemOfSignOut = shiftComInfo.getCardRemOfSignOut(serialId); + String minsAfterSignOut = shiftComInfo.getMinsAfterSignOut(serialId); + String remindMode = shiftComInfo.getRemindMode(serialId); + if (!"1".equals(remindMode) && !"2".equals(remindMode) && !"3".equals(remindMode)) { + kqLog.info("KQSignRemind>>>>>resourceId:" + resourceId + ">>>>remindMode:"); + continue; + } + String remindTimeStr = getAllRemindTimeStr(minsBeforeSignIn, minsAfterSignOut, shiftInfoBean, shiftComInfo); + kqLog.info("KQSignRemind>>>>>resourceId:" + resourceId + ">>>>remindTimeStr:"+remindTimeStr); + String[] remindTimeArr = remindTimeStr.split(";"); + for (String remindTime : remindTimeArr) { + if (remindTime == null || remindTime.equals("")) { + continue; + } + long reminTime_start = Long.parseLong(remindTime.split("-")[0]); + long reminTime_end = Long.parseLong(remindTime.split("-")[1]); + boolean beginsign = true; + boolean endsign = true; + String serialNumber = remindTime.split("-")[2]; + + //满足请假或出差后考勤打卡无需提醒,获取当天的开始和结束时间,然后和班次时间作比较,如果班次的时间包含的话就不进行提醒 + Map noneRemindFlowDatas = getworkFlowInfo(resourceId, date); + if(noneRemindFlowDatas != null && noneRemindFlowDatas.size() > 0){ + kqLog.info("KQSignRemind>>>>>resourceId:" + resourceId + ">>>>noneRemindFlowDatas:" + JSONObject.toJSONString(noneRemindFlowDatas)); + List> noneRemindFlowDataList = (List>)noneRemindFlowDatas.get(resourceId + "|" + date); + for (Map noneRemindFlowData : noneRemindFlowDataList) { + long remindFlowBeginTime = getRemindTime(date, noneRemindFlowData.get("begintime"), "begin", minsBeforeSignIn); + long remindFlowEndTime = getRemindTime(date, noneRemindFlowData.get("endtime"), "end", minsAfterSignOut); + if (reminTime_start >= remindFlowBeginTime && reminTime_start <= remindFlowEndTime && signremindCheck) { + kqLog.info("KQSignRemind>>>>>resourceId:" + resourceId + ">>>>上班打卡免提醒考勤人员"); + beginsign = false; + } + + if (reminTime_end >= remindFlowBeginTime && reminTime_end <= remindFlowEndTime && signremindCheck) { + kqLog.info("KQSignRemind>>>>>resourceId:" + resourceId + ">>>>下班打卡免提醒考勤人员"); + endsign = false; + } + } + } + if (reminTime_start > 0 && "1".equals(cardRemOfSignIn) && beginsign) { + beginList = timeMap_begin.get(reminTime_start); + if (beginList == null) { + beginList = new ArrayList(); + } + beginList.add(resourceId + "-" + serialId + "-" + remindMode + "-" + serialNumber); + timeMap_begin.put(reminTime_start, beginList); + } + if (reminTime_end > 0 && "1".equals(cardRemOfSignOut) && endsign) { + endList = timeMap_end.get(reminTime_end); + if (endList == null) { + endList = new ArrayList(); + } + endList.add(resourceId + "-" + serialId + "-" + remindMode + "-" + serialNumber); + timeMap_end.put(reminTime_end, endList); + } + } + } + kqLog.info("timeMap_begin:"+ JSONObject.toJSONString(timeMap_begin)); + kqLog.info("timeMap_end:"+ JSONObject.toJSONString(timeMap_end)); + doTimer(timeMap_begin, 1); + doTimer(timeMap_end, 2); + } + + public long getRemindTime(String date,String time,String type,String SignTime){ + if (time == null || time.equals("")){ + return 0; + } + long timestamp = Tools.parseToDate(date + " " + time + ":00", "yyyy-MM-dd HH:mm:ss").getTime(); + + if("begin".equals(type)){ + timestamp = timestamp - 60 * 1000 * Util.getIntValue(SignTime); + }else if("end".equals(type)){ + timestamp = timestamp + 60 * 1000 * Util.getIntValue(SignTime); + } + return timestamp; + } + + private String getAllRemindTimeStr(String minsBeforeSignIn, String minsAfterSignOut, ShiftInfoBean shiftInfoBean, KQShiftManagementComInfo kqComInfo) { + StringBuilder builder = new StringBuilder(); + String currentDate = DateUtil.getCurrentDate(); + String nextDate = currentDate; + String nextDate2 = currentDate; + String nextDate3 = currentDate; + List allWorkTime = shiftInfoBean.getAllWorkTime(); + // 1天1次或1天2次或1天3次上下班 + int shiftonoffworkcounts = Util.getIntValue(kqComInfo.getShiftonoffworkcounts(shiftInfoBean.getSerialid()), 0); + String startWorkTime = ""; + String endWorkTime = ""; + String startWorkTime2 = ""; + String endWorkTime2 = ""; + String startWorkTime3 = ""; + String endWorkTime3 = ""; + switch (shiftonoffworkcounts) { + case 1: + //1天1次上下班 + startWorkTime = allWorkTime.get(0); + endWorkTime = allWorkTime.get(1); + if (startWorkTime.compareTo(endWorkTime) > 0) { + nextDate = DateUtil.addDate(currentDate, 1); + } + break; + case 2: + //1天2次上下班 + startWorkTime = allWorkTime.get(0); + endWorkTime = allWorkTime.get(1); + startWorkTime2 = allWorkTime.get(2); + endWorkTime2 = allWorkTime.get(3); + if (startWorkTime.compareTo(endWorkTime) > 0) { + nextDate = DateUtil.addDate(currentDate, 1); + } + if (startWorkTime2.compareTo(endWorkTime2) > 0) { + nextDate2 = DateUtil.addDate(currentDate, 1); + } + break; + case 3: + //1天3次上下班 + startWorkTime = allWorkTime.get(0); + endWorkTime = allWorkTime.get(1); + startWorkTime2 = allWorkTime.get(2); + endWorkTime2 = allWorkTime.get(3); + startWorkTime3 = allWorkTime.get(4); + endWorkTime3 = allWorkTime.get(5); + if (startWorkTime.compareTo(endWorkTime) > 0) { + nextDate = DateUtil.addDate(currentDate, 1); + } + if (startWorkTime2.compareTo(endWorkTime2) > 0) { + nextDate2 = DateUtil.addDate(currentDate, 1); + } + if (startWorkTime3.compareTo(endWorkTime3) > 0) { + nextDate3 = DateUtil.addDate(currentDate, 1); + } + break; + } + + long afterBeforeTime_begin1 = 0; + long afterBeforeTime_end1 = 0; + long afterBeforeTime_begin2 = 0; + long afterBeforeTime_end2 = 0; + long afterBeforeTime_begin3 = 0; + long afterBeforeTime_end3 = 0; + if (!"".equals(startWorkTime)) { + long time_begin = Tools.parseToDate(currentDate + " " + startWorkTime + ":00", "yyyy-MM-dd HH:mm:ss").getTime(); + afterBeforeTime_begin1 = time_begin - 60 * 1000 * Util.getIntValue(minsBeforeSignIn); + } + if (!"".equals(endWorkTime)) { + long time_end = Tools.parseToDate(nextDate + " " + endWorkTime + ":00", "yyyy-MM-dd HH:mm:ss").getTime(); + afterBeforeTime_end1 = time_end + 60 * 1000 * Util.getIntValue(minsAfterSignOut); + } + + if (!"".equals(startWorkTime2)) { + long time_begin = Tools.parseToDate(currentDate + " " + startWorkTime2 + ":00", "yyyy-MM-dd HH:mm:ss").getTime(); + afterBeforeTime_begin2 = time_begin - 60 * 1000 * Util.getIntValue(minsBeforeSignIn); + } + if (!"".equals(endWorkTime2)) { + long time_end = Tools.parseToDate(nextDate2 + " " + endWorkTime2 + ":00", "yyyy-MM-dd HH:mm:ss").getTime(); + afterBeforeTime_end2 = time_end + 60 * 1000 * Util.getIntValue(minsAfterSignOut); + } + + if (!"".equals(startWorkTime3)) { + long time_begin = Tools.parseToDate(currentDate + " " + startWorkTime3 + ":00", "yyyy-MM-dd HH:mm:ss").getTime(); + afterBeforeTime_begin3 = time_begin - 60 * 1000 * Util.getIntValue(minsBeforeSignIn); + } + if (!"".equals(endWorkTime3)) { + long time_end = Tools.parseToDate(nextDate3 + " " + endWorkTime3 + ":00", "yyyy-MM-dd HH:mm:ss").getTime(); + afterBeforeTime_end3 = time_end + 60 * 1000 * Util.getIntValue(minsAfterSignOut); + } + builder.append(afterBeforeTime_begin1).append("-").append(afterBeforeTime_end1).append("-").append("1").append(";") + .append(afterBeforeTime_begin2).append("-").append(afterBeforeTime_end2).append("-").append("2").append(";") + .append(afterBeforeTime_begin3).append("-").append(afterBeforeTime_end3).append("-").append("3"); + return builder.toString(); + } + + private void doTimer(Map> timerMap, int type) { + kqLog.info(">>>>SignRemind>>>>type="+type+">>>>timerMap=" + JSONObject.toJSONString(timerMap)); + for (Map.Entry> entry : timerMap.entrySet()) { + Date d = new Date(); + d.setTime(entry.getKey()); + Date currentDate = new Date(); + if (currentDate.getTime() > d.getTime()) { + continue; + } + final List list = entry.getValue(); + kqLog.info(">>>>SignRemind>>>>time=" + entry.getKey() + ">>>>list.size=" + list.size()+ ">>>>list=" + list.toString()); + if (list.size() == 0) continue; + MyTimerTask myTimerTask = new MyTimerTask("" + entry.getKey(), list, type); + if (!myTimerTaskList.contains(myTimerTask.getKey())) { + kqLog.info(">>>>SignRemind>>>>Add TimerTask>>>>time=" + entry.getKey()+":d:"+d); + myTimerTaskList.add(myTimerTask.getKey()); + try{ + timer.schedule(myTimerTask, d); + }catch (Exception e){ + e.printStackTrace(); + kqLog.info("MyTimerTask:Exception"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + } + } + } + + public void appNotification(Set resourceIDSet,int type) { + try { + + String detailTitle = "510146"; + String title = ""; + if (1 == type) { + title = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005295, weaver.general.ThreadVarLanguage.getLang()) + ""; + } else { + title = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005309, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + String content = ""; + int createrId = 1; + String pcUrl = ""; + String mobileUrl = "/spa/hrm/static4mobile/index.html#/sign"; + kqLog.info(">>>>>>>>appNotification>>>>>>>>>>>>>>time>>>>>>>"+DateUtil.getDateTime()+">>>>>>resourceIDSet>>>>>>"+ JSON.toJSON(resourceIDSet)); + ConfigManager configManager = new ConfigManager(); + // 2、默认规则检查用户配置,返回后台自定义消息类型和对应通过配置的用户 + // @param singPath 与需求变更之前的path参数含义一致,代表该消息类型详细配置中唯一标志值,各模块参考自己的值(有疑问请联系云商店-田泽法) + // @param userid 按默认规则检查的用户配置信息(检查多人参考重载方法) + Map> accessConfig = configManager.defaultRuleCheckConfig(MessageType.HRM_KQ_REMIND, resourceIDSet, null); + + // 3、遍历自定义消息类型集合 + for (Map.Entry> entry : accessConfig.entrySet()) { + // 4、构造消息实体 + MessageBean bean = Util_Message.createMessage(MessageType.HRM_KQ_REMIND, 0, title, detailTitle, content, pcUrl, mobileUrl, createrId); + + // 5、获取新的自定义消息类型 + WeaMessageTypeConfig config = entry.getKey(); + + // 6、新的自定义消息类型相关信息通知到消息实体bean上 + bean.setMessageConfig(config); + + // 7、设置检查配置通过需要发送消息的用户 + bean.setUserList(Sets.newHashSet(entry.getValue())); + + // 8、发送消息 + kqLog.info("in>>>>SignRemind>>>>MyTimerTask>>>appNotification=bean::"+bean); + Util_Message.sendAndpublishMessage(bean); + } + } catch (Exception e) { + log.writeLog(e); + + } + } + + private void emailNotification(String resourceId, String serialId, String emailAddress, String emailTitle, String emailContent, String serialNumber, int type) { + String sendTo = Util.null2String(emailAddress); + if ("".equals(sendTo)) { + kqLog.info("邮箱地址为空,resourceId:" + resourceId + ">>>>>>emailAddress>>>>>>" + emailAddress); + return; + } + String currentDate = DateUtil.getCurrentDate(); + //是否已经签到过了,如果已经签到过了,就不提醒了 + boolean hasSign = hasSign(resourceId, serialNumber, type); + if (hasSign) { + kqLog.info("已经签到或签退过了,resourceId:" + resourceId + ">>>>>>emailAddress>>>>>>" + emailAddress); + return; + } + EmailWorkRunnable.threadModeReminder(sendTo, emailTitle, emailContent); + } + + private void mobileNotification(String resourceId, String serialId, String mobile, String content, String serialNumber, int type) { + if (mobile == null || "".equals(mobile)) { + kqLog.info("手机号码为空,resourceId:" + resourceId + ">>>>>>mobile>>>>>>" + mobile); + return; + } + //是否已经签到过了,如果已经签到过了,就不提醒了 + boolean hasSign = hasSign(resourceId, serialNumber, type); + if (hasSign) { + kqLog.info("已经签到或签退过了,resourceId:" + resourceId + ">>>>>>mobile>>>>>>" + mobile); + return; + } + try { + MessageUtil.sendSMS(mobile, content); + } catch (Exception e) { + kqLog.info("SendSMS error.resourceId:" + resourceId + ">>>>>>mobile>>>>>>" + mobile); + log.writeLog(e); + } + } + + + /** + * 获取不需考勤提醒的数据 + * 请假,出差,公出 + * @param resourceId + * @param kqDate + * @return + */ + public Map getworkFlowInfo(String resourceId, String kqDate) { + KQFlowDataBiz kqFlowDataBiz = new KQFlowDataBiz.FlowDataParamBuilder().resourceidParam(resourceId).fromDateParam(kqDate).toDateParam(kqDate).build(); + Map workFlowInfo = new HashMap<>();//userid|date--工作流程 + List allSplitBeans = new ArrayList<>(); + + Map flowDeductCard = kqFlowDataBiz.getFlowDeductCard(); + + allSplitBeans.addAll(kqFlowDataBiz.getLeaveData(workFlowInfo,flowDeductCard)); + allSplitBeans.addAll(kqFlowDataBiz.getEvectionData(workFlowInfo,flowDeductCard)); + allSplitBeans.addAll(kqFlowDataBiz.getOutData(workFlowInfo,flowDeductCard)); + return workFlowInfo; + } + public boolean hasSign(String resourceId, String serialNumber, int type) { + boolean hasSign = false; + try { + boolean hasSignIn = false; + boolean hasSignOut = false; + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + String currentDate = DateUtil.getCurrentDate(); + String preDate = DateUtil.addDate(currentDate, -1);//上一天日期 + String nextDate = DateUtil.addDate(currentDate, 1);//下一天日期 + + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(resourceId, currentDate); + List lsSignTime = new ArrayList<>(); + List lsWorkTime = new ArrayList<>(); + List lsRestTime = new ArrayList<>(); + List workFlow = null; + + if (workTimeEntity != null) { + lsSignTime = workTimeEntity.getSignTime();//允许打卡时间 + lsWorkTime = workTimeEntity.getWorkTime();//工作时间 + lsRestTime = workTimeEntity.getRestTime();//休息时段时间 + } + if (!lsWorkTime.isEmpty()) { + //这个serialNumber传过来1表示是第一个打卡区间的,传过来2是第二个,以此类推 + int inx_serialNumber = Util.getIntValue(serialNumber) - 1; + if (inx_serialNumber > -1) { + TimeScopeEntity signTimeScope = lsSignTime.get(inx_serialNumber); + TimeScopeEntity workTimeScope = lsWorkTime.get(inx_serialNumber); + TimeScopeEntity restTimeScope = lsRestTime.isEmpty() ? null : lsRestTime.get(inx_serialNumber); + List lsCheckInfo = new KQFormatSignData().getSignInfo(resourceId, signTimeScope, workTimeScope, currentDate, preDate, nextDate, kqTimesArrayComInfo); + if (!lsCheckInfo.isEmpty()) { + for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) { + Map checkInfo = (Map) lsCheckInfo.get(j); + String signType = Util.null2String(checkInfo.get("signType")); + //签到 + if ("1".equalsIgnoreCase(signType)) { + hasSignIn = true; + } + //签退 + if ("2".equalsIgnoreCase(signType)) { + hasSignOut = true; + } + } + } + kqLog.info("hasSign:resourceId:"+resourceId+":type:" + type+":lsCheckInfo:" + lsCheckInfo + ":hasSignIn:" + hasSignIn + ":hasSignOut:" + hasSignOut); + } + } + if (1 == type) { + if (hasSignIn) { + hasSign = true; + } + } else { + if (hasSignOut) { + hasSign = true; + } + } + } catch (Exception e) { + log.writeLog(e); + } + return hasSign; + } + + class MyTimerTask extends TimerTask { + + private String key; + private List list; + private int type; + + public MyTimerTask(String key, List list, int type) { + this.key = key; + this.list = list; + this.type = type; + } + + public String getKey() { + return key; + } + + @Override + public void run() { + kqLog.info("in>>>>SignRemind>>>>MyTimerTask>>>time="); + ResourceComInfo rci = null; + try { + rci = new ResourceComInfo(); + KQEmailRemindComInfo emailComInfo = new KQEmailRemindComInfo(); + KQMessageRemindComInfo messageComInfo = new KQMessageRemindComInfo(); + Set resourceIDSet = new HashSet(); + Set resourceIDlog = new HashSet(); + for (String info : list) { + try { + String resourceId = info.split("-")[0]; + String serailId = info.split("-")[1]; + String remindMode = info.split("-")[2]; + String serialNumber = info.split("-")[3]; + resourceIDlog.add(resourceId); + // 1. 消息中心 + kqLog.info("in>>>>SignRemind>>>>MyTimerTask>>>remindMode="+remindMode); + if ("1".equals(remindMode) && checkAppNotification(resourceId, serailId, serialNumber, type)) { + resourceIDSet.add(resourceId); + } + //2. 邮件提醒 + if ("2".equals(remindMode)) { + String emailAddress = rci.getEmail(resourceId); + String emailTitle = emailComInfo.getEmailTitle(serailId, "" + type); + String emailConTent = emailComInfo.getEmailContent(serailId, "" + type); + emailNotification(resourceId, serailId, emailAddress, emailTitle, emailConTent, serialNumber, type); + } + // 3. 短信提醒 + if ("3".equals(remindMode)) { + String mobile = rci.getMobile(resourceId); + String content = messageComInfo.getMessageContent(serailId, "" + type); + mobileNotification(resourceId, serailId, mobile, content, serialNumber, type); + } + } catch (Exception e) { + log.writeLog(e); + } + } + kqLog.info("in>>>>SignRemind>>>>resourceIDlog="+resourceIDlog); + kqLog.info("in>>>>SignRemind>>>>resourceIDSet="+resourceIDSet); + appNotification(resourceIDSet,type); + kqLog.info("out>>>>SignRemind>>>>MyTimerTask>>>time="); + } catch (Exception e) { + log.writeLog("MyTimerTask:"+e); + } + } + } + + public boolean checkAppNotification(String resourceId, String serialId, String serialNumber, int type) { + //是否已经签到过了,如果已经签到过了,就不提醒了 + boolean hasSign = hasSign(resourceId, serialNumber, type); + kqLog.info("in>>>>SignRemind>>>>MyTimerTask>>>resourceId="+resourceId+"::hasSign::"+hasSign); + if (hasSign) { + kqLog.info("已经签到或签退过了,resourceId:" + resourceId); + return false; + } + return true; + } + + public boolean signremindCheck() { + RecordSet rs = new RecordSet(); + String is_signremind_check = "0"; + String signremind_check_sql = "select * from kq_settings where main_key='signremind_check'"; + rs.executeQuery(signremind_check_sql); + if(rs.next()) { + String main_val = rs.getString("main_val"); + if ("1".equalsIgnoreCase(main_val)) { + is_signremind_check = "1"; + } + } + return "1".equalsIgnoreCase(is_signremind_check); + } + + + public static List getMyTimerTaskList() { + return myTimerTaskList; + } + +} diff --git a/src/com/engine/kq/biz/KQTimeSelectionComInfo.java b/src/com/engine/kq/biz/KQTimeSelectionComInfo.java new file mode 100644 index 0000000..ea11fec --- /dev/null +++ b/src/com/engine/kq/biz/KQTimeSelectionComInfo.java @@ -0,0 +1,158 @@ +package com.engine.kq.biz; + +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.CacheItem; +import weaver.cache.CacheMap; +import weaver.cache.PKColumn; +import weaver.conn.RecordSet; +import weaver.general.Util; + +/** + * 时间选择方式缓存类 + */ +public class KQTimeSelectionComInfo extends CacheBase implements Serializable { + + protected static String TABLE_NAME = "kq_timeselection"; + /** sql中的where信息,不要以where开始 */ + protected static String TABLE_WHERE = "";//默认加载今天之前一个月数据 + /** sql中的order by信息,不要以order by开始 */ + protected static String TABLE_ORDER = "id"; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + @CacheColumn(name = "timeselection") + protected static int timeselection; + + @Override + protected boolean autoInitIfNotFound() { + return false; + } + + @Override + public CacheMap initCache() throws Exception { + CacheMap localData = super.createCacheMap(); + RecordSet rs = new RecordSet(); + Map> timeSelectionMap = new HashMap<>(); + + String sql = "select * from KQ_TIMESELECTION "; + rs.executeQuery(sql); + while (rs.next()){ + String selectiontype = rs.getString("selectiontype"); + if(Util.getIntValue(selectiontype) < 0){ + continue; + } + String leaveruleid = rs.getString("leaveruleid"); + String minimumunit = rs.getString("minimumunit"); + String key = ""; + if(Util.getIntValue(selectiontype) == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + key = selectiontype+"_"+leaveruleid+"_"+minimumunit; + }else{ + key = selectiontype+"_0_"+minimumunit; + } + Map map = new HashMap<>(); + String half_on = Util.null2String(rs.getString("half_on")); + String half_off = Util.null2String(rs.getString("half_off")); + String whole = Util.null2String(rs.getString("whole")); + map.put("half_on", half_on); + map.put("half_off", half_off); + map.put("whole", whole); + timeSelectionMap.put(key, map); + } + + if(!timeSelectionMap.isEmpty()){ + for(Map.Entry me : timeSelectionMap.entrySet()){ + String id = Util.null2String(me.getKey()); + Object value = me.getValue(); + CacheItem cacheItem = createCacheItem(); + cacheItem.set(PK_INDEX, id); + cacheItem.set(timeselection, value); + modifyCacheItem(id, cacheItem); + localData.put(id, cacheItem); + } + } + return localData; + } + + @Override + public CacheItem initCache(String key) { + if (key == null || "".equals(key.trim())) { + return null; + } + Map> timeSelectionMap = new HashMap<>(); + String[] keys = Util.splitString(key,"_"); + String selectiontype = keys[0]; + String leaveruleid = keys[1]; + String minimumunit = keys[2]; + RecordSet rs = new RecordSet(); + String sql = ""; + if(Util.getIntValue(selectiontype) == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + sql = "select * from KQ_TIMESELECTION where selectiontype="+selectiontype+" and leaveruleid='"+leaveruleid+"' and minimumunit="+minimumunit; + }else{ + sql = "select * from KQ_TIMESELECTION where selectiontype="+selectiontype+" and minimumunit="+minimumunit; + } + rs.executeQuery(sql); + while (rs.next()){ + Map map = new HashMap<>(); + String half_on = Util.null2String(rs.getString("half_on")); + String half_off = Util.null2String(rs.getString("half_off")); + String whole = Util.null2String(rs.getString("whole")); + map.put("half_on", half_on); + map.put("half_off", half_off); + map.put("whole", whole); + timeSelectionMap.put(key, map); + } + if(!timeSelectionMap.isEmpty()){ + CacheItem cacheItem = createCacheItem(); + for(Map.Entry me : timeSelectionMap.entrySet()){ + String id = Util.null2String(me.getKey()); + Object value = me.getValue(); + cacheItem.set(PK_INDEX, id); + cacheItem.set(timeselection, value); + modifyCacheItem(key, cacheItem); + } + } + return null; + } + + private String getId() { + return (String) getRowValue(PK_INDEX); + } + + private Map getTimeselection() { + return (Map) getRowValue(timeselection); + } + + private Map getTimeselection(String key) { + if(getObjValue(timeselection, key) != null){ + return (Map) getObjValue(timeselection, key); + }else{ + return new HashMap<>(); + } + } + + /** + * + * @param selectiontype + * @param leaveruleid 请假类型id,没有的话传0 + * @param minimumunit + * @return + */ + public Map getTimeselections(String selectiontype, String leaveruleid, String minimumunit) { + if(Util.null2String(selectiontype).length()==0||Util.null2String(minimumunit).length()==0){ + return new HashMap<>(); + } + String key = Util.null2String(selectiontype)+"_"+Util.null2String(leaveruleid)+"_"+Util.null2String(minimumunit); + if(Util.getIntValue(selectiontype) != KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + key = Util.null2String(selectiontype)+"_0_"+Util.null2String(minimumunit); + } + return this.getTimeselection(key); + } + +} diff --git a/src/com/engine/kq/biz/KQTimesArrayComInfo.java b/src/com/engine/kq/biz/KQTimesArrayComInfo.java new file mode 100644 index 0000000..ca7a5d4 --- /dev/null +++ b/src/com/engine/kq/biz/KQTimesArrayComInfo.java @@ -0,0 +1,280 @@ +package com.engine.kq.biz; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.CacheItem; +import weaver.cache.PKColumn; +import weaver.conn.RecordSet; +import weaver.general.Util; + +public class KQTimesArrayComInfo extends CacheBase{ + protected static String TABLE_NAME = "kq_timesarray"; + /** sql中的where信息,不要以where开始 */ + /** + * 这个缓存类里只需要存储一条数据供虚拟列使用就可以了 + */ + protected static String TABLE_WHERE = "arrayindex=0"; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "arrayindex"; + + @CacheColumn(name = "times") + protected static int times; + + /** + * 主要是用这个虚拟列存储map 可以 通过时间获取下标 + */ + @CacheColumn(isVirtual = true) + protected static int timesArrayindexMap; + + + /** + * 主要是用这个虚拟列存储map 可以 通过下标获取时间 + */ + @CacheColumn(isVirtual = true) + protected static int arrayindexTimesMap; + + /** + * 原始数组 + */ + @CacheColumn(isVirtual = true) + protected static int initArray; + + + public String getId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getTimes() { return (String)getRowValue(times); } + + public String getTimes(String key) { + return (String)getValue(times,key); + } + + public String getTimesArrayindexMap() { return (String)getRowValue(timesArrayindexMap); } + + public String getTimesArrayindexMap(String key) { + return (String)getValue(timesArrayindexMap,key); + } + + public String getArrayindexTimesMap() { return (String)getRowValue(arrayindexTimesMap); } + + public String getArrayindexTimesMap(String key) { + return (String)getValue(arrayindexTimesMap,key); + } + + @Override + protected void modifyCacheItem(String key, CacheItem cacheItem) { + String sql = "select times,arrayindex from kq_timesarray"; + Map timeMap = new HashMap(); + Map arrayMap = new HashMap(); + // 列值转换 + RecordSet rstemp=new RecordSet(); + rstemp.executeQuery(sql); + int[] initArrays = new int[rstemp.getCounts()]; + int i = 0; + while(rstemp.next()){ + String times = rstemp.getString("times"); + String arrayindex = rstemp.getString("arrayindex"); + timeMap.put(times, arrayindex); + arrayMap.put(arrayindex, times); + initArrays[i] = -1; + i++; + } + + // 虚拟列赋值 + cacheItem.set(timesArrayindexMap, timeMap); + // 虚拟列赋值 + cacheItem.set(arrayindexTimesMap, arrayMap); + // 虚拟列赋值 + cacheItem.set(initArray, initArrays); + } + + /** + * 根据传过来的时间获取数组下标 + * + * @param times + * @return 无设置时返回Null + */ + public int getArrayindexByTimes(String times) { + if(times.length()>5){ + times = times.substring(0,5); + } + //sqlwhere里决定了pk只能是0 + Map timeMap = (Map)getObjValue(timesArrayindexMap,"0"); + if (timeMap == null){ + return -1; + } + + return Util.getIntValue(timeMap.get(times)); + } + + /** + * 根据传过来的数组下标获取时间 + * + * @param arrayIndex + * @return 无设置时返回Null + */ + public String getTimesByArrayindex(int arrayIndex) { + //sqlwhere里决定了pk只能是0 + Map arrayMap = (Map)getObjValue(arrayindexTimesMap,"0"); + if (arrayMap == null){ + return ""; + } + + return arrayMap.get(""+arrayIndex); + } + + /** + * 获取总的下标长度 + * @return + */ + public int getIndexSize(){ + Map timeMap = (Map)getObjValue(timesArrayindexMap,"0"); + return timeMap.size(); + } + + /** + * 获取原始的数组 + * @return + */ + public int[] getInitArr(){ + int[] initArraysCom = (int[])getObjValue(initArray,"0"); + int length = 2881; + if(initArraysCom != null){ + length = initArraysCom.length; + } + int[] initArrays = new int[length]; + + Arrays.fill(initArrays, -1); + return initArrays; + } + + /** + * 获取分钟数 数组 + * @param initArrays 需要遍历的数组 + * @param startIndex 遍历数组开始下标 + * @param endIndex 遍历数组结束下标 + * @param checkVal 需要判断的值 + */ + public int[] getCnts(int[] initArrays,int startIndex,int endIndex,int checkVal){ + int cnt = 0; + int[] cntArray = new int[3]; + for(int i = startIndex ; i < endIndex ; i++){ + if(initArrays[i] == checkVal){ + if(cnt == 0){ + cntArray[0] = i; + }else{ + cntArray[1] = i; + } + cnt++; + } + } + cntArray[2] = cnt; + return cntArray; + } + + /** + * 获取分钟数 + * @param initArrays 需要遍历的数组 + * @param startIndex 遍历数组开始下标 + * @param endIndex 遍历数组结束下标 + * @param checkVal 需要判断的值 + */ + public int getCnt(int[] initArrays,int startIndex,int endIndex,int checkVal){ + int cnt = 0; + for(int i = startIndex ; i < endIndex ; i++){ + if(initArrays[i] == checkVal){ + cnt++; + } + } + return cnt; + } + + /** + * 把24小时制的时间下标转换成48小时制的 + * @param timeIndex + * @return + */ + public int turn24to48TimeIndex(int timeIndex){ + int longtimeIndex = timeIndex; + try{ + if(timeIndex > 1440){ + return longtimeIndex; + } + longtimeIndex = timeIndex+1440; + }catch (Exception e){ + e.printStackTrace(); + } + return longtimeIndex; + } + + /** + * 把24小时制的时间转换成48小时制的 + * @param time + * @return + */ + public String turn24to48Time(String time){ + String longtime = time; + try{ + int timeIndex = getArrayindexByTimes(time); + if(timeIndex > 1440){ + return time; + } + int timeIndexTmp = turn24to48TimeIndex(timeIndex); + longtime = getTimesByArrayindex(timeIndexTmp); + }catch (Exception e){ + e.printStackTrace(); + } + return longtime; + } + + /** + * 把48小时制度时间下标转换成24小时制的 + * @param timeIndex + * @return + */ + public int turn48to24TimeIndex(int timeIndex){ + int longtimeIndex = timeIndex; + try{ + if(timeIndex > 1439){ + longtimeIndex = timeIndex-1440; + longtimeIndex = longtimeIndex > 0 ? longtimeIndex : 0; + } + }catch (Exception e){ + e.printStackTrace(); + } + return longtimeIndex; + } + + /** + * 把48小时制度时间转换成24小时制的 + * @param time + * @return + */ + public String turn48to24Time(String time){ + String longtime = time; + try{ + int timeIndex = getArrayindexByTimes(time); + int timeIndexTmp = turn48to24TimeIndex(timeIndex); + longtime = getTimesByArrayindex(timeIndexTmp); + }catch (Exception e){ + e.printStackTrace(); + } + return longtime; + } + + /** + * 获取一天的工作总时长1439分钟 + * @return + */ + public static int getOneDayArraySize(){ + return 1439; + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQTodayFormatJob.java b/src/com/engine/kq/biz/KQTodayFormatJob.java new file mode 100644 index 0000000..572131c --- /dev/null +++ b/src/com/engine/kq/biz/KQTodayFormatJob.java @@ -0,0 +1,38 @@ +package com.engine.kq.biz; + +import com.engine.kq.log.KQLog; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; + +/** + * 格式化今天的考勤数据 + */ +public class KQTodayFormatJob extends BaseCronJob{ + private KQLog kqLog = new KQLog(); + + public void execute() { + RecordSet rs = new RecordSet(); + try{ + + kqLog.info("begin do KQScheduleFormatJob invoke ..."); + String date = DateUtil.getCurrentDate(); + String yesterday = DateUtil.addDate(date,-1); + + kqLog.info("do KQScheduleFormatJob invoke..["+date+";"+yesterday+"]"); + RecordSet rs1 = new RecordSet(); + String sql = "select id from hrmresource where status in (0,1,2,3)"; + rs1.execute(sql); + while (rs1.next()){ + String resourceid = Util.null2String(rs1.getString("id")); + kqLog.info("KQScheduleFormatJob:resourceid:"+resourceid+":date:"+date); + new KQFormatData().formatKqDateByLock(resourceid, date,20); + } + + kqLog.info("end do KQScheduleFormatJob invoke ..."); + }catch (Exception e) { + kqLog.info(e) ; + } + } +} diff --git a/src/com/engine/kq/biz/KQTravelRulesBiz.java b/src/com/engine/kq/biz/KQTravelRulesBiz.java new file mode 100644 index 0000000..3910533 --- /dev/null +++ b/src/com/engine/kq/biz/KQTravelRulesBiz.java @@ -0,0 +1,80 @@ +package com.engine.kq.biz; + +import weaver.conn.RecordSet; +import weaver.general.Util; + +/** + * 出差规则相关接口 + */ +public class KQTravelRulesBiz { + + /** + * 获取最小出差单位 + * 1-按天出差 + * 2-按半天出差 + * 3-按小时出差 + * 4-按整天出差 + * 其他:无效数据 + * + * @return + */ + public static String getMinimumUnit() { + KQTravelRulesComInfo kqTravelRulesComInfo = new KQTravelRulesComInfo(); + return kqTravelRulesComInfo.getMinimumUnit("1"); + } + + /** + * 获取换算比例 + * 当公出单位由天、半天、整天切换成小时或者由小时切换成天、半天、整天时,历史数据会按照此换算比例自动进行换算 + * + * @return + */ + public static String getProportion() { + KQTravelRulesComInfo kqTravelRulesComInfo = new KQTravelRulesComInfo(); + return String.format("%.2f", Util.getDoubleValue(kqTravelRulesComInfo.getProportion("1"))); + } + + /** + * 获取计算出差时长方式 + * 1-按工作日计算出差时长 + * 2-按自然日计算出差时长 + * 其他:无效数据 + * + * @return + */ + public static String getComputingMode() { + KQTravelRulesComInfo kqTravelRulesComInfo = new KQTravelRulesComInfo(); + return kqTravelRulesComInfo.getComputingMode("1"); + } + + /** + * 获取日折算时长 + * + * @return + */ + public static String getHoursToDay() { + int minimumUnit = -1;//最小出差单位 + int computingMode = -1;//计算出差时长方式 + double hoursToDay = -1;//日折算时长 + KQTravelRulesComInfo kqTravelRulesComInfo = new KQTravelRulesComInfo(); + minimumUnit = Util.getIntValue(kqTravelRulesComInfo.getMinimumUnit("1"), -1); + computingMode = Util.getIntValue(kqTravelRulesComInfo.getComputingMode("1"), -1); + hoursToDay = Util.getDoubleValue(kqTravelRulesComInfo.getHoursToDay("1"), -1.00); + return String.valueOf(hoursToDay); + } + + /** + * 获取半天显示类型,是时间还是下拉框 + * 半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + * @return + */ + public static String getTimeselection() { + KQTravelRulesComInfo kqTravelRulesComInfo = new KQTravelRulesComInfo(); + String timeSelection = kqTravelRulesComInfo.getTimeSelection("1"); + if("1".equalsIgnoreCase(timeSelection) || "2".equalsIgnoreCase(timeSelection)){ + return timeSelection; + }else{ + return "1"; + } + } +} diff --git a/src/com/engine/kq/biz/KQTravelRulesComInfo.java b/src/com/engine/kq/biz/KQTravelRulesComInfo.java new file mode 100644 index 0000000..ce1bde6 --- /dev/null +++ b/src/com/engine/kq/biz/KQTravelRulesComInfo.java @@ -0,0 +1,122 @@ +package com.engine.kq.biz; + +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; + +/** + * 出差规则缓存类 + */ +public class KQTravelRulesComInfo extends CacheBase { + + /** + * 数据来源 + */ + protected static String TABLE_NAME = "kq_TravelRules"; + /** + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = " (isDelete is null or isDelete<>1) "; + /** + * sql中的order by信息,不要以order by开始 + */ + protected static String TABLE_ORDER = "id"; + + /** 主键ID */ + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + /** + * 获取最小出差单位 + * 1-按天出差 + * 2-按半天出差 + * 3-按小时出差 + * 4-按整天出差 + * 其他:无效数据 + */ + @CacheColumn(name = "minimumUnit") + protected static int minimumUnit; + + /** + * 获取换算比例 + * 当公出单位由天、半天、整天切换成小时或者由小时切换成天、半天、整天时,历史数据会按照此换算比例自动进行换算 + */ + @CacheColumn(name = "proportion") + protected static int proportion; + + /** + * 获取计算出差时长方式 + * 1-按工作日计算出差时长 + * 2-按自然日计算出差时长 + * 其他:无效数据 + */ + @CacheColumn(name = "computingMode") + protected static int computingMode; + + /** + * 获取日折算时长 + * 只有当按天出差、按半天出差、按整天出差并且按照自然日计算出差时长的时候才有效 + * -1:无效数据 + */ + @CacheColumn(name = "hoursToDay") + protected static int hoursToDay; + + /** + * 半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + */ + @CacheColumn(name = "timeselection") + protected static int timeselection; + + public String getId() { + return (String) getRowValue(PK_INDEX); + } + + public String getMinimumUnit() { + return (String) getRowValue(minimumUnit); + } + + public String getMinimumUnit(String key) { + return (String) getValue(minimumUnit, key); + } + + public String getProportion() { + return (String) getRowValue(proportion); + } + + public String getProportion(String key) { + return (String) getValue(proportion, key); + } + + public String getComputingMode() { + return (String) getRowValue(computingMode); + } + + public String getComputingMode(String key) { + return (String) getValue(computingMode, key); + } + + public String getHoursToDay() { + return (String) getRowValue(hoursToDay); + } + + public String getHoursToDay(String key) { + return (String) getValue(hoursToDay, key); + } + + public String getTimeSelection() { + String value = (String) getRowValue(timeselection); + if (value == null || value.equals("")) { + value = "1"; + } + return value; + } + + public String getTimeSelection(String key) { + String value = (String) getValue(timeselection, key); + if (value == null || value.equals("")) { + value = "1"; + } + return value; + } +} diff --git a/src/com/engine/kq/biz/KQUnitBiz.java b/src/com/engine/kq/biz/KQUnitBiz.java new file mode 100644 index 0000000..6955744 --- /dev/null +++ b/src/com/engine/kq/biz/KQUnitBiz.java @@ -0,0 +1,29 @@ +package com.engine.kq.biz; + +/** + * 考勤单位类 + */ +public class KQUnitBiz { + + /** + * 根据单位类型 判断请假是否是小时为单位 + * @param durationrule + * @return + */ + public static boolean isLeaveHour(String durationrule){ + if((durationrule.equals("3") || durationrule.equals("5") || durationrule.equals("6"))){ + return true; + } + return false; + } + + /** + * 根据请假类型 判断请假是否是小时为单位 + * @param durationrule + * @return + */ + public static boolean isLeaveHour(String newleavetype,KQLeaveRulesComInfo kqLeaveRulesComInfo){ + String durationrule = kqLeaveRulesComInfo.getMinimumUnit(newleavetype); + return isLeaveHour(durationrule); + } +} diff --git a/src/com/engine/kq/biz/KQUsageHistoryBiz.java b/src/com/engine/kq/biz/KQUsageHistoryBiz.java new file mode 100644 index 0000000..b723813 --- /dev/null +++ b/src/com/engine/kq/biz/KQUsageHistoryBiz.java @@ -0,0 +1,419 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.entity.KQUsageHistoryEntity; +import com.engine.kq.log.KQLog; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; + +/** + * @Auther: Administrator + * @Date: 2019-03-12 22:36 + * @Description: + */ +public class KQUsageHistoryBiz { + + /** + * 保存员工假期余额的变更记录 + * + * @param usageHistoryEntityList + * @return + */ + public boolean save(List usageHistoryEntityList) { + boolean flag = false;//记录操作是否执行成功 + try { + List valueList = new ArrayList();//每一个记录使用记录SQL操作的参数集合 + List paramList = new ArrayList();//所有记录使用记录SQL操作的参数集合 + + for (KQUsageHistoryEntity usageHistoryEntity : usageHistoryEntityList) { + valueList = new ArrayList();//每一个记录使用记录SQL操作的参数集合 + + Class usageHistoryEntityClass = usageHistoryEntity.getClass(); + Field[] fieldArr = usageHistoryEntityClass.getDeclaredFields(); + for (int i = 0; i < fieldArr.length; i++) { + Field field = fieldArr[i]; + field.setAccessible(true); + valueList.add(field.get(usageHistoryEntity)); + } + + paramList.add(valueList); + } + + String sql = "insert into kq_UsageHistory(leaveRulesId,relatedId,wfRequestId,operator,operateDate,operateTime,operateType," + + "belongYear,oldBaseAmount,newBaseAmount,oldExtraAmount,newExtraAmount,oldUsedAmount,newUsedAmount,oldBaseAmount2,newBaseAmount2,oldExtraAmount2,newExtraAmount2,oldUsedAmount2,newUsedAmount2," + + "oldMinimumUnit,newMinimumUnit,insertOrUpdate,balanceOfLeaveId,workflowid,belongdate,duration) values(?,?,?,?,?,?,?," + + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + RecordSet recordSet = new RecordSet(); + flag = recordSet.executeBatchSql(sql, paramList); + new KQLog().info("KQUsageHistoryBiz:save:"+"::paramList::"+ JSON.toJSONString(paramList)); + } catch (Exception e) { + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + new KQLog().info(errorsWriter.toString()); + e.printStackTrace(); + } + return flag; + } + + /** + * 将员工假期余额的变更记录转换成文字表达 + * + * @param id kq_UsageHistory表的主键ID + * @return + */ + public static String getDescription(String id, User user) { + String description = ""; + try { + /*系统语言*/ + String languageIdStr = "" + user.getLanguage(); + int languageId =user.getLanguage(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + String sql = "select * from Kq_UsageHistory where id=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, id); + if (recordSet.next()) { + /*假期类型的ID*/ + String leaveRulesId = recordSet.getString("leaveRulesId"); + String balanceOfLeaveId = recordSet.getString("balanceOfLeaveId"); + /*假期类型的名称*/ + String leaveName = Util.formatMultiLang(rulesComInfo.getLeaveName(leaveRulesId), languageIdStr); + /*假期余额被修改的人员ID*/ + String relatedId = recordSet.getString("relatedId"); + //分部ID + String subCompanyId = resourceComInfo.getSubCompanyID(relatedId); + String departmentId = resourceComInfo.getDepartmentID(relatedId); + //保留几位小数 + int decimalDigit = Util.getIntValue(detailComInfo.getDecimalDigit(leaveRulesId, subCompanyId, departmentId, relatedId), 2); + /*流程的requestId*/ + String wfRequestId = recordSet.getString("wfRequestId"); + /*操作者:-1--系统*/ + String operator = recordSet.getString("operator"); + /*操作者名称*/ + String operatorName = operator.equals("-1") ? SystemEnv.getHtmlLabelName(468,languageId) : Util.formatMultiLang(resourceComInfo.getLastnames(operator), languageIdStr); + /*操作日期*/ + String operateDate = recordSet.getString("operateDate"); + + /*操作时间*/ + String operateTime = recordSet.getString("operateTime"); + /*操作类型:0--单位变更、1--请假流程、2--销假流程、3--加班流程生成调休、4--打卡数据生成调休、5--管理员修改员工假期余额、6--批处理(管理员手动批处理或者系统凌晨自动批处理)、7--管理员Excel导入*/ + String operateType = recordSet.getString("operateType"); + /*员工假期余额的所属年份*/ + String belongYear = recordSet.getString("belongYear"); + /*操作之前的员工假期余额基数*/ + BigDecimal _oldBaseAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("oldBaseAmount"), 0)); + String oldBaseAmount = _oldBaseAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + /*操作之后的员工假期余额基数*/ + BigDecimal _newBaseAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("newBaseAmount"), 0)); + String newBaseAmount = _newBaseAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + /*操作之前的员工额外假期余额*/ + BigDecimal _oldExtraAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("oldExtraAmount"), 0)); + String oldExtraAmount = _oldExtraAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + /*操作之后的员工额外假期余额*/ + BigDecimal _newExtraAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("newExtraAmount"), 0)); + String newExtraAmount = _newExtraAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + /*操作之前的员工已休假期余额*/ + BigDecimal _oldUsedAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("oldUsedAmount"), 0)); + String oldUsedAmount = _oldUsedAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + /*操作之后的员工已休假期余额*/ + BigDecimal _newUsedAmount = new BigDecimal(Util.getDoubleValue(recordSet.getString("newUsedAmount"), 0)); + String newUsedAmount = _newUsedAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + /*操作之前的员工福利年假基数*/ + BigDecimal _oldBaseAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("oldBaseAmount2"), 0)); + String oldBaseAmount2 = _oldBaseAmount2.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + /*操作之后的员工福利年假基数*/ + BigDecimal _newBaseAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("newBaseAmount2"), 0)); + String newBaseAmount2 = _newBaseAmount2.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + /*操作之前的员工额外福利年假*/ + BigDecimal _oldExtraAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("oldExtraAmount2"), 0)); + String oldExtraAmount2 = _oldExtraAmount2.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + /*操作之后的员工额外福利年假*/ + BigDecimal _newExtraAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("newExtraAmount2"), 0)); + String newExtraAmount2 = _newExtraAmount2.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + /*操作之前的员工已休福利年假*/ + BigDecimal _oldUsedAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("oldUsedAmount2"), 0)); + String oldUsedAmount2 = _oldUsedAmount2.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + /*操作之后的员工已休福利年假*/ + BigDecimal _newUsedAmount2 = new BigDecimal(Util.getDoubleValue(recordSet.getString("newUsedAmount2"), 0)); + String newUsedAmount2 = _newUsedAmount2.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + /*操作之前的员工假期余额单位:1-按天(单位:天)、2-按半天(单位:天)、3-按小时(单位:小时)、4-按整天(单位:天)*/ + String oldMinimumUnit = recordSet.getString("oldMinimumUnit"); + /*操作之后的员工假期余额单位:*/ + String newMinimumUnit = recordSet.getString("newMinimumUnit"); + /*是新增的员工假期余额还是更新员工假期余额*/ + String insertOrUpdate = recordSet.getString("insertOrUpdate"); + /*员工假期余额变更之前单位是天还是小时*/ + String oldUnitName = "";//单位名称,天/小时 + if (oldMinimumUnit.equals("1") || oldMinimumUnit.equals("2") || oldMinimumUnit.equals("4")) { + oldUnitName = SystemEnv.getHtmlLabelName(389325, languageId);//(天) + } else { + oldUnitName = SystemEnv.getHtmlLabelName(389326, languageId);//(小时) + } + /*员工假期余额变更之后单位是天还是小时*/ + String newUnitName = "";//单位名称,天/小时 + if (newMinimumUnit.equals("1") || newMinimumUnit.equals("2") || newMinimumUnit.equals("4")) { + newUnitName = SystemEnv.getHtmlLabelName(389325, languageId);//(天) + } else { + newUnitName = SystemEnv.getHtmlLabelName(389326, languageId);//(小时) + } + /*是否是混合模式(福利年假+法定年假)*/ + boolean isMixMode = KQLeaveRulesBiz.isMixMode(leaveRulesId); + /*是否是调休*/ + boolean isTiaoXiu = KQLeaveRulesBiz.isTiaoXiu(leaveRulesId); + //操作之前的[调休]的总数 + BigDecimal _oldTotalAmount = _oldBaseAmount.add(_oldExtraAmount); + String oldTotalAmount = _oldTotalAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + //操作之后的[调休]的总数 + BigDecimal _newTotalAmount = _newBaseAmount.add(_newExtraAmount); + String newTotalAmount = _newTotalAmount.setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + //使用记录描述: + if(balanceOfLeaveId.length()>0){ + description = SystemEnv.getHtmlLabelName(1811, languageId) + "ID:" + balanceOfLeaveId + "。"; + } + description += "{operatorName}{operateDesc},"+ SystemEnv.getHtmlLabelName(10005310, languageId)+ + "{belongYear}"+ SystemEnv.getHtmlLabelName(10005311, languageId)+"{leaveName}"+ SystemEnv.getHtmlLabelName(10005312, languageId)+""; + String balanceofleaveid = recordSet.getString("balanceofleaveid"); + boolean leaveOfParental = KQLeaveRulesBiz.isLeaveOfParentalNum(leaveRulesId); + String childname = ""; + if(leaveOfParental&&balanceofleaveid.length()>0){ + childname = KQLeaveRulesBiz.getChildName(balanceofleaveid); + if(StringUtils.isBlank(childname)){ + childname=SystemEnv.getHtmlLabelName(129878, user.getLanguage())+":"+ SystemEnv.getHtmlLabelName(82393, user.getLanguage())+","; + }else{ + childname=SystemEnv.getHtmlLabelName(129878, user.getLanguage())+":"+ childname+","; + } + description += childname; + } + + String operateDesc = ""; + //进行了什么操作 + switch (operateType) { + case "0": + operateDesc = ""+ SystemEnv.getHtmlLabelName(10005313,languageId)+""; + break; + case "1": + operateDesc = ""+ SystemEnv.getHtmlLabelName(10005314,languageId)+""; + break; + case "2": + operateDesc = ""+ SystemEnv.getHtmlLabelName(10005315,languageId)+""; + break; + case "3": + operateDesc = ""+ SystemEnv.getHtmlLabelName(10005316,languageId)+""; + break; + case "4": + operateDesc = ""+ SystemEnv.getHtmlLabelName(10005317,languageId)+""; + break; + case "5": + operateDesc = ""+ SystemEnv.getHtmlLabelName(10005318,languageId)+""; + break; + case "6": + operateDesc = ""+ SystemEnv.getHtmlLabelName(10005319,languageId)+""; + break; + case "7": + operateDesc = ""+ SystemEnv.getHtmlLabelName(15376,languageId)+"Excel"+ SystemEnv.getHtmlLabelName(10005320,languageId)+""; + break; + case "8": + operateDesc = ""+ SystemEnv.getHtmlLabelName(10005321,languageId)+""; + break; + case "9": + operateDesc = ""+ SystemEnv.getHtmlLabelName(547070,languageId)+""; + break; + } + description = description.replace("{operatorName}", operatorName).replace("{operateDesc}", operateDesc) + .replace("{belongYear}", belongYear).replace("{leaveName}", leaveName); + if ("PaidLeaveEnable".equalsIgnoreCase(insertOrUpdate)) { + String paidLeaveEnableDesc = "{operatorName}{operateDesc}, "+SystemEnv.getHtmlLabelName( 525184, languageId)+"。"; + description = paidLeaveEnableDesc.replace("{operatorName}", operatorName).replace("{operateDesc}", operateDesc); + } else if ("OnlyRecordLog".equalsIgnoreCase(insertOrUpdate)) { + String onlyRecordLogDesc = "{operatorName}{operateDesc}, "+SystemEnv.getHtmlLabelName( 525185, languageId)+"。"; + description = onlyRecordLogDesc.replace("{operatorName}", operatorName).replace("{operateDesc}", operateDesc); + } else if (insertOrUpdate.equalsIgnoreCase("insert")) { + String detailDesc = ""+ SystemEnv.getHtmlLabelName(501707,languageId)+"{item}"+ SystemEnv.getHtmlLabelName(10005322,languageId)+"{newAmount}{newUntName}"; + if (isMixMode) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 500228, languageId)).replace("{newAmount}", newBaseAmount).replace("{newUntName}", newUnitName) + "," + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 389745, languageId)).replace("{newAmount}", newExtraAmount).replace("{newUntName}", newUnitName) + "," + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 389743, languageId)).replace("{newAmount}", newUsedAmount).replace("{newUntName}", newUnitName) + "," + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 500229, languageId)).replace("{newAmount}", newBaseAmount2).replace("{newUntName}", newUnitName) + "," + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 389746, languageId)).replace("{newAmount}", newExtraAmount2).replace("{newUntName}", newUnitName) + "," + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 389744, languageId)).replace("{newAmount}", newUsedAmount2).replace("{newUntName}", newUnitName); + } else if (isTiaoXiu) { + if ("7".equals(operateType)) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 355, languageId)).replace("{newAmount}", newTotalAmount).replace("{newUntName}", newUnitName) + "," + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 26642, languageId)).replace("{newAmount}", newUsedAmount).replace("{newUntName}", newUnitName); + } else { + detailDesc = "{item}"+ SystemEnv.getHtmlLabelName(10005323,languageId)+"{newAmount}{newUntName}"; + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 355, languageId)).replace("{newAmount}", newTotalAmount).replace("{newUntName}", newUnitName); + } + } else { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 17638, languageId)).replace("{newAmount}", newBaseAmount).replace("{newUntName}", newUnitName) + "," + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 130286, languageId)).replace("{newAmount}", newExtraAmount).replace("{newUntName}", newUnitName) + "," + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 26642, languageId)).replace("{newAmount}", newUsedAmount).replace("{newUntName}", newUnitName); + } + } else if (insertOrUpdate.equalsIgnoreCase("update")) { + String detailDesc = ""+ SystemEnv.getHtmlLabelName(501707,languageId)+"{item}"+ SystemEnv.getHtmlLabelName(623,languageId)+"{oldAmount}{oldUnitName}"+ SystemEnv.getHtmlLabelName(10005324,languageId)+"{newAmount}{newUnitName}。"; + switch (operateType) { + case "1": + detailDesc = "{item}"+ SystemEnv.getHtmlLabelName(10005325,languageId)+"{diffAmount}{oldUnitName}。"; + if (isMixMode) { + if (_newUsedAmount.compareTo(_oldBaseAmount) > 0) { + String diffAmount = _newUsedAmount.subtract(_oldUsedAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 525193, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName); + } + if (_newUsedAmount2.compareTo(_oldBaseAmount2) > 0) { + String diffAmount = _newUsedAmount2.subtract(_oldUsedAmount2).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 525194, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName); + } + } else { + if (_newUsedAmount.compareTo(_oldBaseAmount) > 0) { + String diffAmount = _newUsedAmount.subtract(_oldUsedAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 1811, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName); + }else{ + double diffAmountValue = _oldUsedAmount.subtract(_newUsedAmount).setScale(decimalDigit, RoundingMode.HALF_UP).doubleValue(); + if(diffAmountValue>0){ + detailDesc = "{item}"+ SystemEnv.getHtmlLabelName(10005323,languageId)+"{diffAmount}{oldUnitName}。"; + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 1811, languageId)).replace("{diffAmount}", diffAmountValue+"").replace("{oldUnitName}", oldUnitName); + + } + } + } + break; + case "2": + detailDesc = "{item}"+ SystemEnv.getHtmlLabelName(10005323,languageId)+"{diffAmount}{oldUnitName}。"; + if (isMixMode) { + if (_newUsedAmount.compareTo(_oldUsedAmount) < 0) { + String diffAmount = _oldUsedAmount.subtract(_newUsedAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 525193, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName); + } + if (_newUsedAmount2.compareTo(_oldUsedAmount2) < 0) { + String diffAmount = _oldUsedAmount2.subtract(_newUsedAmount2).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 525194, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName); + } + } else { + if (_newUsedAmount.compareTo(_oldUsedAmount) < 0) { + String diffAmount = _oldUsedAmount.subtract(_newUsedAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 1811, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName); + } + } + break; + case "3": + case "4": + detailDesc = "{item}"+ SystemEnv.getHtmlLabelName(10005323,languageId)+"{diffAmount}{oldUnitName}。"; + if (_oldTotalAmount.compareTo(_newTotalAmount) != 0) { + String diffAmount = _newTotalAmount.subtract(_oldTotalAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 1811, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName); + } + break; + case "0": + case "5": + case "6": + case "7": + if (isMixMode) { + if (_oldBaseAmount.compareTo(_newBaseAmount) != 0) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 500228, languageId)).replace("{oldAmount}", oldBaseAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newBaseAmount).replace("{newUnitName}", newUnitName); + } + if (_oldExtraAmount.compareTo(_newExtraAmount) != 0) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 389745, languageId)).replace("{oldAmount}", oldExtraAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newExtraAmount).replace("{newUnitName}", newUnitName); + } + if (_oldUsedAmount.compareTo(_newUsedAmount) != 0) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 389743, languageId)).replace("{oldAmount}", oldUsedAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newUsedAmount).replace("{newUnitName}", newUnitName); + } + if (_oldBaseAmount2.compareTo(_newBaseAmount2) != 0) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 500229, languageId)).replace("{oldAmount}", oldBaseAmount2).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newBaseAmount2).replace("{newUnitName}", newUnitName); + } + if (_oldExtraAmount2.compareTo(_newExtraAmount2) != 0) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 389746, languageId)).replace("{oldAmount}", oldExtraAmount2).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newExtraAmount2).replace("{newUnitName}", newUnitName); + } + if (_oldUsedAmount2.compareTo(_newUsedAmount2) != 0) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 389744, languageId)).replace("{oldAmount}", oldUsedAmount2).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newUsedAmount2).replace("{newUnitName}", newUnitName); + } + } else if (isTiaoXiu) { + if (_oldTotalAmount.compareTo(_newTotalAmount) != 0) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 355, languageId)).replace("{oldAmount}", oldTotalAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newTotalAmount).replace("{newUnitName}", newUnitName); + } + if (_oldUsedAmount.compareTo(_newUsedAmount) != 0) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 26642, languageId)).replace("{oldAmount}", oldUsedAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newUsedAmount).replace("{newUnitName}", newUnitName); + } + } else { + if (_oldBaseAmount.compareTo(_newBaseAmount) != 0) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 17638, languageId)).replace("{oldAmount}", oldBaseAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newBaseAmount).replace("{newUnitName}", newUnitName); + } + if (_oldExtraAmount.compareTo(_newExtraAmount) != 0) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 130286, languageId)).replace("{oldAmount}", oldExtraAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newExtraAmount).replace("{newUnitName}", newUnitName); + } + if (_oldUsedAmount.compareTo(_newUsedAmount) != 0) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 26642, languageId)).replace("{oldAmount}", oldUsedAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newUsedAmount).replace("{newUnitName}", newUnitName); + } + } + break; + case "8": + if (_oldTotalAmount.compareTo(_newTotalAmount) != 0) { + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 355, languageId)).replace("{oldAmount}", oldUsedAmount).replace("{oldUnitName}", oldUnitName).replace("{newAmount}", newUsedAmount).replace("{newUnitName}", newUnitName); + } + break; + case "9": + detailDesc = "{item}"+ SystemEnv.getHtmlLabelName(10005325,languageId)+"{diffAmount}{oldUnitName}。"; + if (isMixMode) { + if (_newUsedAmount.compareTo(_oldBaseAmount) > 0) { + String diffAmount = _newUsedAmount.subtract(_oldUsedAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 525193, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName); + } + if (_newUsedAmount2.compareTo(_oldBaseAmount2) > 0) { + String diffAmount = _newUsedAmount2.subtract(_oldUsedAmount2).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 525194, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName); + } + } else { + if (_newUsedAmount.compareTo(_oldBaseAmount) > 0) { + String diffAmount = _newUsedAmount.subtract(_oldUsedAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + description = description + + detailDesc.replace("{item}", SystemEnv.getHtmlLabelName( 1811, languageId)).replace("{diffAmount}", diffAmount).replace("{oldUnitName}", oldUnitName); + } + } + break; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return description; + } +} diff --git a/src/com/engine/kq/biz/KQWifiComInfo.java b/src/com/engine/kq/biz/KQWifiComInfo.java new file mode 100644 index 0000000..aba7214 --- /dev/null +++ b/src/com/engine/kq/biz/KQWifiComInfo.java @@ -0,0 +1,44 @@ +package com.engine.kq.biz; + +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; + +public class KQWifiComInfo extends CacheBase{ + protected static String TABLE_NAME = "kq_wifi"; + + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + @CacheColumn(name = "wifiname") + protected static int wifiname; + + @CacheColumn(name = "mac") + protected static int mac; + + @CacheColumn(name = "groupid") + protected static int groupid; + + public String getId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getWifiname() { return (String)getRowValue(wifiname); } + + public String getWifiname(String key) { + return (String)getValue(wifiname,key); + } + + public String getMac() { return (String)getRowValue(mac); } + + public String getMac(String key) { + return (String)getValue(mac,key); + } + + public String getGroupid() { return (String)getRowValue(groupid); } + + public String getGroupid(String key) { + return (String)getValue(groupid,key); + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQWorkTime.java b/src/com/engine/kq/biz/KQWorkTime.java new file mode 100644 index 0000000..790d29e --- /dev/null +++ b/src/com/engine/kq/biz/KQWorkTime.java @@ -0,0 +1,471 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.entity.KQGroupEntity; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.TimeSignScopeEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; + +public class KQWorkTime extends BaseBean { + private KQLog kqLog = new KQLog(); + private boolean isFormat = false; + + public WorkTimeEntity getWorkTime(String userId) { + return getWorkTime(userId, null); + } + + /** + * 判断是否是工作日 + * @param userId + * @param workdate + * @return + */ + public boolean isWorkDay(String userId, String workdate) { + boolean isWorkDay = false; + if(!KQHolidaySetBiz.isHoliday(userId,workdate)) {//不是节假日,且有班次 + Map serialInfo = getSerialInfo( userId, workdate, false); + if(!serialInfo.isEmpty()){ + if(Util.null2String(serialInfo.get("kqType")).equals("3")){ + Map result = (Map) serialInfo.get(workdate); + if(result!=null && result.size()>0 && Util.null2String(result.get("signStart")).length()>0 && Util.null2String(result.get("workMins")).length()>0){ + isWorkDay = true; + } + }else{ + boolean isRest = isNonWork(serialInfo); + if(isRest){ + return isWorkDay; + } + isWorkDay = Util.getIntValue(Util.null2String(serialInfo.get(workdate)))>0; + } + } + } + return isWorkDay; + } + + public boolean isNonWork(Map serialInfo){ + boolean isR = false; + if(serialInfo.containsKey("isRest")){ + Boolean isRest = (Boolean) serialInfo.get("isRest"); + if(isRest){ + isR = true; + } + } + if(serialInfo.containsKey("isHoliday")){ + Boolean isHoliday = (Boolean) serialInfo.get("isHoliday"); + if(isHoliday){ + isR = true; + } + } + return isR; + } + + public Map getWorkButton(String userId, String workdate, boolean containYesterday) { + Map result = new HashMap<>(); + try { + KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); + Map serialInfo = getSerialInfo(userId, workdate, containYesterday); + kqLog.info("考勤组获取成员所在的班次 getWorkButton:serialInfo:"+ serialInfo); + String kqType = Util.null2String(serialInfo.get("kqType")); + if(serialInfo!=null&&serialInfo.size()>0){ + if("3".equalsIgnoreCase(kqType)){ + //自由班制的单独处理 + result = (Map) serialInfo.get(workdate); + if(result != null && !result.isEmpty()){ + result.put("isfree", "1"); + }else{ + result = new HashMap<>(); + } + }else{ + result = kQShiftManagementComInfo.getWorkButton(workdate,serialInfo,containYesterday); + kqLog.info("考勤组获取成员所在的班次 getWorkButton:result:"+ JSON.toJSONString(result)); + } + } + } catch (Exception e) { + writeLog(e); + } + return result; + } + + /** + * + * 获取今天所含班次的考勤时间(包含今天和昨天的) + * @param userId + * @param workdate + * @param containYesterday + * @param isLog 是否记录日志 + * @return + */ + public Map getWorkDuration(String userId, String workdate,boolean containYesterday,boolean isLog) { + Map result = new HashMap<>(); + try { + Map workTimeMap = null; + KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); + Map serialInfo = getSerialInfo(userId, workdate, true); + if(isLog){ + //kqLog.info("考勤组获取成员所在的班次 getWorkDuration:"+serialInfo); + } + if(serialInfo!=null&&serialInfo.size()>0){ + String kqType = Util.null2String(serialInfo.get("kqType")); + if("3".equalsIgnoreCase(kqType)){ + //自由班制的单独处理 + result = (Map) serialInfo.get(workdate); + if(result != null && !result.isEmpty()){ + result.put("isfree", "1"); + }else{ + result = new HashMap<>(); + } + }else{ + workTimeMap = kQShiftManagementComInfo.getWorkDuration(workdate,serialInfo,containYesterday); + if(workTimeMap!=null){ + if(isLog) { + //kqLog.info( + // "考勤组获取成员所在的班次 getWorkDuration:workTimeMap:" + JSON.toJSONString(workTimeMap)); + } + result.put("shiftInfoBean",workTimeMap.get("shiftInfoBean")); + } + } + } + } catch (Exception e) { + writeLog(e); + } + return result; + } + + /** + * 获取今天所含班次的考勤时间(包含今天和昨天的) + * @param userId + * @param workdate + * @param containYesterday + * @return + */ + public Map getWorkDuration(String userId, String workdate,boolean containYesterday) { + return getWorkDuration(userId,workdate,containYesterday,true); + } + + /** + * 获取今天所含班次的考勤时间(今天的) + * @param userId + * @param workdate + * @return + */ + public ShiftInfoCominfoBean getShiftInfoCominfoBean(String userId, String workdate) { + ShiftInfoCominfoBean shiftInfoCominfoBean = null; + try { + Map workTimeMap = null; + KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); + Map serialInfo = getSerialInfo(userId, workdate, false); + + if(serialInfo!=null&&serialInfo.size()>0){ + shiftInfoCominfoBean = kQShiftManagementComInfo.getShiftInfoCominfoBean(workdate,serialInfo); + } + } catch (Exception e) { + writeLog(e); + } + return shiftInfoCominfoBean; + } + + /** + * 获取考勤时间 + * @param userId + * @param workdate + * @return + */ + public WorkTimeEntity getWorkTime(String userId, String workdate) { + WorkTimeEntity workTimeEntity = new WorkTimeEntity(); + try { + KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); + Map serialInfo = getSerialInfo(userId, workdate, false); + workTimeEntity.setIsExclude(Util.null2String(serialInfo.get("isExclude")).equals("1")); + workTimeEntity.setGroupId(Util.null2String(serialInfo.get("groupId"))); + if(serialInfo!=null&&serialInfo.size()>0) { + String kqType = Util.null2String(serialInfo.get("kqType")); + Boolean isNonWork = isNonWork(serialInfo); + String dayType = "work"; + if(serialInfo.containsKey("isRest")){ + Boolean isRest1 = (Boolean) serialInfo.get("isRest"); + if(isRest1){ + dayType = "playday"; + } + } + if(serialInfo.containsKey("isHoliday")){ + Boolean isHoliday1 = (Boolean) serialInfo.get("isHoliday"); + if(isHoliday1){ + dayType = "holiday"; + } + } + if(kqType.equals("3")){ + Map map = (Map)serialInfo.get(workdate); + workTimeEntity.setGroupId(Util.null2String(serialInfo.get("groupId"))); + workTimeEntity.setGroupName(Util.null2String(serialInfo.get("groupName"))); + workTimeEntity.setKQType(Util.null2String(kqType)); + workTimeEntity.setIsExclude(Util.null2String(serialInfo.get("isExclude")).equals("1")); + if(map!=null) { + workTimeEntity.setSignStart(Util.null2String(map.get("signStart"))); + workTimeEntity.setWorkMins(Util.getIntValue(Util.null2String(map.get("workMins")))); + workTimeEntity.setCalmethod(Util.null2String(map.get("calmethod"))); + }else{ + dayType = "playday"; + } + workTimeEntity.setNonWorkShift(0); + }else{ + int serialid = Util.getIntValue(Util.null2String(serialInfo.get(workdate)), 0); + + int signouOnlyoff = StringUtil.parseToInt(kQShiftManagementComInfo.getSignoutOnlyoff(String.valueOf(serialid)), 0); + workTimeEntity.setSignoutOnlyoff(signouOnlyoff); + + if (serialid > 0){ + workTimeEntity.setNonWorkShift(isNonWork?1:0); + + Map dateWorkTimeMap = kQShiftManagementComInfo.getWorkTimeMap(workdate, serialInfo); + workTimeEntity.setGroupId(Util.null2String(serialInfo.get("groupId"))); + workTimeEntity.setGroupName(Util.null2String(serialInfo.get("groupName"))); + workTimeEntity.setKQType(kqType); + workTimeEntity.setSerialId(""+serialid); + workTimeEntity.setShiftRuleInfo(ShiftManagementToolKit.getShiftRuleInfo(""+serialid,true)); + workTimeEntity.setSignTime(formatTimeScope((List)dateWorkTimeMap.get("signTime"),false)); + workTimeEntity.setWorkTime(formatTimeScope((List)dateWorkTimeMap.get("workTime"),true)); + workTimeEntity.setRestTime(formatTimeScope((List)dateWorkTimeMap.get("restTime"),false)); + workTimeEntity.setWorkMins(Util.getIntValue(Util.null2String(dateWorkTimeMap.get("workMins")))); + workTimeEntity.setIsAcross(Util.null2String(dateWorkTimeMap.get("isAcross"))); + workTimeEntity.setConvertAttendDay(Util.null2s(Util.null2String(dateWorkTimeMap.get("convertAttendDay")), "1.0")); + workTimeEntity.setHalfWorkTime((List)dateWorkTimeMap.get("halfWorkTime")); + workTimeEntity.setHalfWorkIndex((List)dateWorkTimeMap.get("halfWorkIndex")); + }else{ + dayType = "playday"; + } + } + workTimeEntity.setDayType(dayType); + } + } catch (Exception e) { + writeLog(e); + } + return workTimeEntity; + } + + public List formatTimeScope(List timeScope, boolean needWorkMins){ + List timeScopes = new ArrayList<>(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + TimeScopeEntity timeScopeEntity = null; + for(int i=0;timeScope!=null && i obj = (Map)timeScope.get(i); + String bengintime_end = Util.null2String(obj.get("bengintime_end")); + String bengintime_end_across = Util.null2String(obj.get("bengintime_end_across")); + String endtime_start = Util.null2String(obj.get("endtime_start")); + String endtime_start_across = Util.null2String(obj.get("endtime_start_across")); + String bengintime_pre_across = Util.null2String(obj.get("bengintime_pre_across")); + timeScopeEntity = new TimeScopeEntity(); + timeScopeEntity.setBeginTime(Util.null2String(obj.get("bengintime"))); + timeScopeEntity.setBeginTimeAcross(Util.null2String(obj.get("bengintime_across")).equals("1"));//标记是否跨天 + timeScopeEntity.setEndTime(Util.null2String(obj.get("endtime"))); + timeScopeEntity.setEndTimeAcross(Util.null2String(obj.get("endtime_across")).equals("1"));//标记是否跨天 + timeScopeEntity.setBeginTimePreAcross("1".equalsIgnoreCase(bengintime_pre_across)); + + if(needWorkMins) { + int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(timeScopeEntity.getBeginTime()); + int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(timeScopeEntity.getEndTime()); + timeScopeEntity.setWorkMins(workEndIdx - workBeginIdx); + } + if((bengintime_end != null && bengintime_end.length() >0) || (endtime_start != null && endtime_start.length() > 0)){ + TimeSignScopeEntity timeSignScopeEntity = new TimeSignScopeEntity(); + timeSignScopeEntity.setBeginTimeEnd(bengintime_end); + timeSignScopeEntity.setBeginTimeEndAcross("1".equalsIgnoreCase(bengintime_end_across)); + timeSignScopeEntity.setEndTimeStart(endtime_start); + timeSignScopeEntity.setEndTimeStartAcross("1".equalsIgnoreCase(endtime_start_across)); + timeSignScopeEntity.setBeginTimePreAcross("1".equalsIgnoreCase(bengintime_pre_across)); + timeScopeEntity.setTimeSignScopeEntity(timeSignScopeEntity); + } + timeScopes.add(timeScopeEntity); + } + return timeScopes; + } + + /** + * 获取当天班次 + * @param userId + * @param workdate + * @return + */ + public String getSerialIds(String userId, String workdate) { + Map serialInfo = getSerialInfo( userId, workdate, false); + return serialInfo!=null?Util.null2String(serialInfo.get(workdate)):""; + } + + /** + * 获取班次信息 获取顺序 工作日调整、排班、固定班和周期班 + * @param userId + * @param workdate + * @param containYesterday + * @return + */ + public Map getSerialInfo(String userId, String workdate, boolean containYesterday) { + Map serialInfo = new HashMap<>(); + String preworkdate = ""; + try { + KQGroupMemberComInfo groupMemberComInfo = new KQGroupMemberComInfo(); + groupMemberComInfo.setIsFormat(this.isFormat); + KQFixedSchedulceComInfo kqFixedSchedulceComInfo = new KQFixedSchedulceComInfo(); + kqFixedSchedulceComInfo.setFormat(this.isFormat); + KQShiftScheduleComInfo kqShiftScheduleComInfo = new KQShiftScheduleComInfo(); + kqShiftScheduleComInfo.setFormat(this.isFormat); + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + kqShiftManagementComInfo.setFormat(this.isFormat); + KQGroupEntity kqGroupEntity = groupMemberComInfo.getUserKQGroupInfo(userId,workdate); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + + preworkdate = DateUtil.addDate(workdate,-1); + if(containYesterday){ + Map pre_serialInfo = getSerialInfo(userId, preworkdate, false); + if(pre_serialInfo != null && !pre_serialInfo.isEmpty()){ + if(pre_serialInfo.containsKey(preworkdate)){ + serialInfo.put(preworkdate,pre_serialInfo.get(preworkdate));//获取前一天的班次 + } + } + } + + if(kqGroupEntity==null){//不在考勤组内 + serialInfo.put("isRest",true); + return serialInfo; + } + + + //无需考勤人员需要计算考勤时间,但不计算异常状态 +// if (("," + kqGroupEntity.getExcludeid() + ",").indexOf("," + userId + ",")>-1) {//排除人员无需计算考勤时间 +// return serialInfo; +// } + + if (("," + kqGroupEntity.getExcludeid() + ",").indexOf("," + userId + ",")>-1) {//排除人员无需计算考勤时间 + serialInfo.put("isExclude","1"); + } + + String begindate = Util.null2String(resourceComInfo.getCreatedate(userId)).trim(); + String companyStartDate = Util.null2String(resourceComInfo.getCompanyStartDate(userId)).trim(); + if(companyStartDate.length()!=10){ + companyStartDate = ""; + } + if(companyStartDate.length()>0 && companyStartDate.indexOf("-")>0){ + begindate=companyStartDate; + } + if(begindate.length()>0 && DateUtil.compDate(begindate,workdate)<0 ){//人员入职日期前无需计算考勤,如果没有入职日期,已创建日期为准 +// kqLog.writeLog("getSerialInfo 入职日期不满足条件:userId:"+userId+":workdate:"+workdate+":companyStartDate:"+companyStartDate+":begindate:"+begindate+":DateUtil.compDate(begindate,workdate):"+DateUtil.compDate(begindate,workdate)); + serialInfo.put("isRest",true); + return serialInfo; + } + + String endDate = Util.null2String(resourceComInfo.getEndDate(userId)); + + String status = Util.null2String(resourceComInfo.getStatus(userId)); + if(status.equals("0")||status.equals("1")||status.equals("2")||status.equals("3")){ + //在职 + }else{ + //其他状态 + if(endDate.length()>0 && DateUtil.compDate(endDate,workdate)>0){//人员合同结束日期无需计算考勤 +// kqLog.writeLog("getSerialInfo 人员合同结束日期不满足条件:userId:"+userId+":workdate:"+workdate+":endDate:"+endDate+":status:"+status+":DateUtil.compDate(endDate,workdate):"+DateUtil.compDate(endDate,workdate)); + serialInfo.put("isRest",true); + return serialInfo; + } + } + + String groupid = kqGroupEntity.getId(); + String groupname = kqGroupEntity.getGroupname(); + String kqtype = kqGroupEntity.getKqtype(); + int dayOfweek = DateUtil.getWeek(workdate)-1; + int preDayOfweek = DateUtil.getWeek(preworkdate)-1; + boolean preDayIsHoliday = KQHolidaySetBiz.isHoliday(userId,preworkdate); + boolean isHoliday = KQHolidaySetBiz.isHoliday(userId,workdate); + serialInfo.put("isHoliday",isHoliday); + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + boolean needSkipHoliday = isHoliday; + //节假日或者调配休息日,是否需要返回当天的班次 + String holidayRestShift = Util.null2String(kqSettingsComInfo.getMain_val("holiday_rest_shift"),"0"); + if("1".equals(holidayRestShift)){ + //如果需要返回班次,那么isHoliday的判断就不需要了 + needSkipHoliday = false; + } + String serialid = ""; + + if(!kqtype.equals("2")){//处理调配工作日(除排班外) + if(KQHolidaySetBiz.getChangeType(groupid,preworkdate)==2){ + preDayOfweek = KQHolidaySetBiz.getRelatedDay(userId,preworkdate); + } + + if(KQHolidaySetBiz.getChangeType(groupid,workdate)==2){ + dayOfweek = KQHolidaySetBiz.getRelatedDay(userId,workdate); + } + } + serialInfo.put("groupId",groupid); + serialInfo.put("groupName",groupname); + serialInfo.put("kqType",kqtype); + if (kqtype.equals("1")) {//固定班 +// if(containYesterday && !serialInfo.containsKey(preworkdate)) { +// serialid = Util.null2String(kqFixedSchedulceComInfo.getSerialid(groupid,preDayOfweek)); +// if(!preDayIsHoliday&&serialid.length()>0 && Util.getIntValue(serialid) > 0){ +// serialInfo.put(preworkdate,serialid);//获取前一天的班次 +// } +// } + if(!serialInfo.containsKey(workdate)){ + serialid = Util.null2String(kqFixedSchedulceComInfo.getSerialid(groupid,dayOfweek)); + if( !needSkipHoliday&&serialid.length()>0 && Util.getIntValue(serialid) > 0){ + serialInfo.put(workdate, serialid);//获取当天的班次 + } + } + } else if (kqtype.equals("2")) {//排班 + //先取排班设置里的班次 +// serialid = Util.null2String(kqShiftScheduleComInfo.getSerialId(userId,preworkdate)); +// if(containYesterday && serialid.length()>0 && !preDayIsHoliday && Util.getIntValue(serialid) > 0){ +// serialInfo.put(preworkdate,Util.null2String(kqShiftScheduleComInfo.getSerialId(userId,preworkdate)));//获取前一天的班次 +// } + kqShiftScheduleComInfo.setShiftGroupId(Util.getIntValue(groupid)); + serialid = Util.null2String(kqShiftScheduleComInfo.getSerialId(userId,workdate)); + if(serialid.length()>0 && !needSkipHoliday && Util.getIntValue(serialid) > 0){ + serialInfo.put(workdate,Util.null2String(kqShiftScheduleComInfo.getSerialId(userId,workdate)));//获取当天的班次 + } + } else if (kqtype.equals("3")) {//自由班 + List weekDay = Util.splitString2List(kqGroupEntity.getWeekday(), ","); + String signStart = Util.null2String(kqGroupEntity.getSignstart());//签到开始时间 + int workMins = Util.getIntValue(Util.getIntValues(""+Util.getDoubleValue(Util.null2String(kqGroupEntity.getWorkhour()))*60));//工作时长 + if(signStart.length()>0 && workMins>0) { + String calmethod = Util.null2s(kqGroupEntity.getCalmethod(),"1"); + Map map = null; + if (weekDay.contains(""+preDayOfweek) && !preDayIsHoliday) {//前一天 + map = new HashMap<>(); + map.put("signStart", signStart); + map.put("workMins", workMins); + map.put("calmethod", calmethod); + serialInfo.put(preworkdate, map); + } + if (weekDay.contains(""+dayOfweek) && !isHoliday) {//当前天 + map = new HashMap<>(); + map.put("signStart", signStart); + map.put("workMins", workMins); + map.put("calmethod", calmethod); + serialInfo.put(workdate, map); + } + } + } + if(StringUtil.isNotNull(serialid)){ + String isRest = Util.null2s(kqShiftManagementComInfo.getIsRest(serialid),""); + serialInfo.put("isRest","1".equals(isRest)); + } + } catch (Exception e) { + writeLog(e); + } + return serialInfo; + } + + + public void setIsFormat(boolean isFormat){ + this.isFormat = isFormat; + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KQYesterdayAbnormalRemindJob.java b/src/com/engine/kq/biz/KQYesterdayAbnormalRemindJob.java new file mode 100644 index 0000000..b792afc --- /dev/null +++ b/src/com/engine/kq/biz/KQYesterdayAbnormalRemindJob.java @@ -0,0 +1,220 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +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.kq.entity.KQGroupEntity; +import com.engine.kq.log.KQLog; +import com.engine.msgcenter.biz.ConfigManager; +import com.engine.msgcenter.biz.WeaMessageTypeConfig; +import com.google.common.collect.Sets; +import com.weaver.general.Util; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.hrm.common.Tools; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class KQYesterdayAbnormalRemindJob extends BaseCronJob { + + private BaseBean log = new BaseBean(); + + private KQLog kqLog = new KQLog(); + + public void execute() { + String currentDate = Tools.getCurrentDate(); + String yesterDay = DateUtil.addDate(currentDate, -1); + kqLog.info(">>>>>>>>>>>>>>>>KQYesterdayAbnormalRemindJob>>>>>>>>>>>>>>begin>>>>>>>>>>>>>>>>"); + handleKqRemind(yesterDay); + kqLog.info(">>>>>>>>>>>>>>>>KQYesterdayAbnormalRemindJob>>>>>>>>>>>>>>end>>>>>>>>>>>>>>>>"); + } + + private void handleKqRemind(String date) { + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + Map managerMessages = new HashMap<>(); + Map managerMessagesUUID = new HashMap<>(); + Map> yesterdayAbnormalData = new KqYesterdayAbnormalRemindBiz().getYesterdayAbnormalData(date, date); + String curDateTime = DateUtil.getDateTime(); + RecordSet recordSet = new RecordSet(); + for(Map.Entry> entry : yesterdayAbnormalData.entrySet()) { + String resourceId = entry.getKey(); + Map value = entry.getValue(); + + KQGroupEntity kQGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(resourceId, date); + String abnormalremind = Util.null2String(kQGroupEntity.getAbnormalremind()); + if(!"1".equals(abnormalremind)){ + kqLog.info(">>>>>>>>>>>>>>>>KQYesterdayAbnormalRemindJob>>>>>>>>>>>>>>abnormalremind is closed>>>>>>>>>>>>>>>>"+resourceId); + continue; + } + + kqLog.info(">>>>>>>>>>>>>>>>KQYesterdayAbnormalRemindJob>>>>>>>>>>>>>>value>>>>>>>>>>>>>>>>"+value); + double late = value.get("late") == null ? 0.0 : value.get("late"); + double leaveearly = value.get("leaveearly") == null ? 0.0 : value.get("leaveearly"); + double absent = value.get("absent") == null ? 0.0 : value.get("absent"); + double forgot = value.get("forgot") == null ? 0.0 : value.get("forgot"); + double gravelate = value.get("gravelate") == null ? 0.0 : value.get("gravelate"); + double graveleaveearly = value.get("graveleaveearly") == null ? 0.0 : value.get("graveleaveearly"); + String content = getLabelName(97) +":"+date+" " + getLabelName(1867)+":"+resourceComInfo.getLastname(resourceId) +" "+ getLabelName(24770)+":"; + StringBuffer remindContentStr = new StringBuffer(); + StringBuffer sb = new StringBuffer(); + + if(late > 0) { + sb.append(getLabelName(20081)) ;//迟到 + remindContentStr.append(getLabelName(390055)).append(":").append(late).append(getLabelName(518516)); + } + + if(gravelate > 0){ + if(sb.length() > 0) { + sb.append( ","); + } + sb.append(getLabelName(500546)) ;//严重迟到 + if(remindContentStr.length() >0) { + remindContentStr.append(","); + } + remindContentStr.append(getLabelName(390056)).append(":").append(gravelate).append(getLabelName(518516)); + } + + if(leaveearly > 0){ + if(sb.length() > 0) { + sb.append( ","); + } + sb.append(getLabelName(20082)) ;//早退 + if(remindContentStr.length() >0) { + remindContentStr.append(","); + } + remindContentStr.append(getLabelName(390057)).append(":").append(leaveearly).append(getLabelName(518516)); + } + + if(graveleaveearly > 0){ + if(sb.length() > 0) { + sb.append( ","); + } + sb.append(getLabelName(500547)) ;//严重早退 + if(remindContentStr.length() >0) { + remindContentStr.append(","); + } + remindContentStr.append(getLabelName(390058)).append(":").append(graveleaveearly).append(getLabelName(518516)); + } + + if(absent > 0) { + if(sb.length() > 0) { + sb.append( ","); + } + sb.append( getLabelName(20085));//旷工 + + if(remindContentStr.length() >0) { + remindContentStr.append(","); + } + remindContentStr.append(getLabelName(390059)).append(":").append(absent).append(getLabelName(518516)); + } + if(forgot > 0) { + if(sb.length() > 0) { + sb.append( ","); + } + sb.append(getLabelName(20086));//漏签 + + if(remindContentStr.length() >0) { + remindContentStr.append(","); + } + remindContentStr.append(getLabelName(20086)).append(getLabelName(21551)).append(":").append(forgot).append(getLabelName(518516)); + } + if(sb.length() > 0) { + content += sb.toString(); + content += "
"+remindContentStr.toString(); + } else { + continue; + } + kqLog.info(">>>>>>>>>>>>>>>>KQYesterdayAbnormalRemindJob>>>>>>>>>>>>>>content>>>>>>>>>>>>>>>>"+content); + String uuid = UUID.randomUUID().toString().replace("-", ""); + + appNotification(resourceId, content, uuid); + insertMessageLog(resourceId, content, resourceId, curDateTime, uuid, recordSet); + + + String managerID = resourceComInfo.getManagerID(resourceId); + if (managerID != null && !"".equals(managerID) && Util.getIntValue(managerID, 0) > 0) { + String managerUUID = ""; + if(managerMessagesUUID.containsKey(managerID)) { + managerUUID = managerMessagesUUID.get(managerID).toString(); + } else { + managerUUID = UUID.randomUUID().toString().replace("-", ""); + managerMessagesUUID.put(managerID, new StringBuilder(managerUUID)); + } + insertMessageLog(resourceId, content, managerID, curDateTime, managerUUID, recordSet); + managerMessages.putIfAbsent(managerID, new StringBuilder()); + managerMessages.get(managerID).append(content).append("

"); + + } + } + // 统一发送给上级 + for (Map.Entry entry : managerMessages.entrySet()) { + String managerID = entry.getKey(); + String content = entry.getValue().toString(); + String managerUUID = managerMessagesUUID.get(managerID).toString(); + appNotification(managerID, content, managerUUID); + } + } catch (Exception e) { + log.writeLog(e); + } + } + + private static String getLabelName(int labelId) { + return SystemEnv.getHtmlLabelName(labelId, weaver.general.ThreadVarLanguage.getLang()); + } + + private void insertMessageLog(String resourceId, String content, String receiverId, String sendTime, String uuid, RecordSet rs) { + + String sql = "INSERT INTO abnormalremindmsg_log (resourceId, content, sendTime, receiverId,uuid) VALUES (?, ?, ?, ?, ?)"; + try { + rs.executeUpdate(sql, resourceId, content, sendTime, receiverId, uuid); + } catch (Exception e) { + log.writeLog(e); + kqLog.info("KQYesterdayAbnormalRemindJob::insertMessageLog: error inserting log for resourceId=" + resourceId + ", receiverId=" + receiverId, e); + } +} + + + public void appNotification(String resourceId,String content, String uuid) { + try { + String detailTitle = "539214"; + String title = content; + int createrId = 1; + String pcUrl = "/spa/hrm/static4attendance/index.html#/attendance/abnormalremindMsg?uuid="+uuid; + String mobileUrl = "/spa/hrm/static4mobile/index.html#/abnormalremindMsg?uuid="+uuid; + ConfigManager configManager = new ConfigManager(); + // 2、默认规则检查用户配置,返回后台自定义消息类型和对应通过配置的用户 + // @param singPath 与需求变更之前的path参数含义一致,代表该消息类型详细配置中唯一标志值,各模块参考自己的值(有疑问请联系云商店-田泽法) + // @param userid 按默认规则检查的用户配置信息(检查多人参考重载方法) + Map> accessConfig = configManager.defaultRuleCheckConfig(MessageType.HRM_KQ_REMIND, resourceId, null); + + // 3、遍历自定义消息类型集合 + for (Map.Entry> entry : accessConfig.entrySet()) { + // 4、构造消息实体 + MessageBean bean = Util_Message.createMessage(MessageType.HRM_KQ_REMIND, 0, title, detailTitle, content, pcUrl, mobileUrl, createrId); + + // 5、获取新的自定义消息类型 + WeaMessageTypeConfig config = entry.getKey(); + + // 6、新的自定义消息类型相关信息通知到消息实体bean上 + bean.setMessageConfig(config); + + // 7、设置检查配置通过需要发送消息的用户 + bean.setUserList(Sets.newHashSet(entry.getValue())); + + // 8、发送消息 + Util_Message.sendAndpublishMessage(bean); + kqLog.info("in>>>>KQYesterdayAbnormalRemindJob>>>>>>appNotification=bean::"+ JSON.toJSONString(bean)); + } + } catch (Exception e) { + log.writeLog(e); + } + } + +} diff --git a/src/com/engine/kq/biz/KQYesterdayFormatJob.java b/src/com/engine/kq/biz/KQYesterdayFormatJob.java new file mode 100644 index 0000000..ead2c17 --- /dev/null +++ b/src/com/engine/kq/biz/KQYesterdayFormatJob.java @@ -0,0 +1,40 @@ +package com.engine.kq.biz; + +import com.engine.kq.log.KQLog; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; + +/** + * 格式化昨天的考勤数据 + */ +public class KQYesterdayFormatJob extends BaseCronJob{ + private KQLog kqLog = new KQLog(); + + public void execute() { + RecordSet rs = new RecordSet(); + try{ + + kqLog.info("begin do KQScheduleFormatJob invoke ..."); + String date = DateUtil.getCurrentDate(); + String yesterday = DateUtil.addDate(date,-1); + + kqLog.info("do KQScheduleFormatJob invoke..["+date+";"+yesterday+"]"); + RecordSet rs1 = new RecordSet(); + String sql = "select id from hrmresource where status in (0,1,2,3)"; + rs1.execute(sql); + while (rs1.next()){ + String resourceid = Util.null2String(rs1.getString("id")); + kqLog.info("KQScheduleFormatJob:resourceid:"+resourceid+":yesterday:"+yesterday); + new KQFormatData().formatKqDateByLock(resourceid, yesterday,20); + //处理一下今天的数据,不然的话今天的数据会显示成休息 + new KQFormatData().formatKqDateByLock(resourceid, date,20); + } + + kqLog.info("end do KQScheduleFormatJob invoke ..."); + }catch (Exception e) { + kqLog.info(e) ; + } + } +} diff --git a/src/com/engine/kq/biz/KqAutoNotifyCheckBiz.java b/src/com/engine/kq/biz/KqAutoNotifyCheckBiz.java new file mode 100644 index 0000000..ec672a6 --- /dev/null +++ b/src/com/engine/kq/biz/KqAutoNotifyCheckBiz.java @@ -0,0 +1,71 @@ +package com.engine.kq.biz; + +import com.cloudstore.dev.api.bean.AppNotifyInfo; +import com.engine.kq.log.KQLog; +import weaver.common.DateUtil; +import weaver.file.Prop; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 自动打卡 给云桥提供接口 + */ +public class KqAutoNotifyCheckBiz extends BaseBean { + public KQLog kqLog = new KQLog(); + public static final int NOTIFY_SHAKE = Util.getIntValue(Prop.getPropValue("appnotify_setting", "NOTIFY_SHAKE"), 0); + public static final int NOTIFY_SHAKE_TIMES = Util.getIntValue(Prop.getPropValue("appnotify_setting", "NOTIFY_SHAKE_TIMES"), 0); + + public static final int NOTIFY_TEXT = Util.getIntValue(Prop.getPropValue("appnotify_setting", "NOTIFY_TEXT"), 0); + public static int NOTIFY_PUSH_CONTENT_SUCCESS = Util.getIntValue(Prop.getPropValue("appnotify_setting", "NOTIFY_PUSH_CONTENT_SUCCESS"), 519318); + public static int NOTIFY_PUSH_CONTENT_FAIL = Util.getIntValue(Prop.getPropValue("appnotify_setting", "NOTIFY_PUSH_CONTENT_FAIL"), 540844); + + public static final int NOTIFY_VOICE = Util.getIntValue(Prop.getPropValue("appnotify_setting", "NOTIFY_VOICE"), 0); + public static final String NOTIFY_VOICE_FILE_SUCCESS = Util.null2String(Prop.getPropValue("appnotify_setting", "NOTIFY_VOICE_FILE_SUCCESS")); + public static final String NOTIFY_VOICE_FILE_FAIL = Util.null2String(Prop.getPropValue("appnotify_setting", "NOTIFY_VOICE_FILE_FAIL")); + + public static final int NOTIFY_VOICE_TEXT = Util.getIntValue(Prop.getPropValue("appnotify_setting", "NOTIFY_VOICE_TEXT"), 0); + public static int NOTIFY_VOICE_TEXT_CONTENT_SUCCESS = Util.getIntValue(Prop.getPropValue("appnotify_setting", "NOTIFY_VOICE_TEXT_CONTENT_SUCCESS"),519318); + public static int NOTIFY_VOICE_TEXT_CONTENT_FAIL = Util.getIntValue(Prop.getPropValue("appnotify_setting", "NOTIFY_VOICE_TEXT_CONTENT_FAIL"),540844); + + public AppNotifyInfo handle(boolean isSuccess, String userid, String currentDateTime) { + User tmp_user = new User(Integer.valueOf(userid)); + AppNotifyInfo appNotifyInfo = new AppNotifyInfo(); + //震动 + if(NOTIFY_SHAKE == 1) { + appNotifyInfo.setVibrateCount(NOTIFY_SHAKE_TIMES); + } + // 文本推送弹出提醒 + if(NOTIFY_TEXT == 1) { + String pushTest = ""; + if(isSuccess) { + pushTest = SystemEnv.getHtmlLabelName(NOTIFY_PUSH_CONTENT_SUCCESS, tmp_user.getLanguage())+currentDateTime; + } else { + pushTest = SystemEnv.getHtmlLabelName(NOTIFY_PUSH_CONTENT_FAIL, tmp_user.getLanguage()); + } + appNotifyInfo.setPushText(pushTest); + } + // 音频 + if(NOTIFY_VOICE == 1) { + String voiceFile = ""; + if(isSuccess) { + voiceFile = NOTIFY_VOICE_FILE_SUCCESS; + } else { + voiceFile = NOTIFY_VOICE_FILE_FAIL; + } + appNotifyInfo.setVoiceFileUrl(voiceFile); + } + // 语音播报 + if(NOTIFY_VOICE_TEXT == 1) { + String voiceText = ""; + if(isSuccess) { + voiceText = SystemEnv.getHtmlLabelName(NOTIFY_VOICE_TEXT_CONTENT_SUCCESS, tmp_user.getLanguage())+currentDateTime; + } else { + voiceText = SystemEnv.getHtmlLabelName(NOTIFY_VOICE_TEXT_CONTENT_FAIL, tmp_user.getLanguage()); + } + appNotifyInfo.setVoiceText(voiceText); + } + return appNotifyInfo; + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/KqFormatPoolRecordBiz.java b/src/com/engine/kq/biz/KqFormatPoolRecordBiz.java new file mode 100644 index 0000000..48fccec --- /dev/null +++ b/src/com/engine/kq/biz/KqFormatPoolRecordBiz.java @@ -0,0 +1,17 @@ +package com.engine.kq.biz; + +import com.engine.kq.jucailin.genid.IdGenerator; +import weaver.conn.RecordSet; + +/** + * 考勤重算线程池记录 + */ +public class KqFormatPoolRecordBiz { + + public static void poolRecord(int creator,String formatSource,Long formatCount, String batchid){ + RecordSet recordSet = new RecordSet(); + Long id = IdGenerator.generate(); + String sql = "insert into kq_format_pool_record(id,creator,format_source,batchid,format_count) values(?,?,?,?,?)"; + recordSet.executeUpdate(sql, id,creator,formatSource,batchid,formatCount); + } +} diff --git a/src/com/engine/kq/biz/KqMembersValidateBiz.java b/src/com/engine/kq/biz/KqMembersValidateBiz.java new file mode 100644 index 0000000..e4993e4 --- /dev/null +++ b/src/com/engine/kq/biz/KqMembersValidateBiz.java @@ -0,0 +1,232 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.log.KQLog; +import org.apache.commons.lang.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +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 KqMembersValidateBiz { + private KQLog kqLog = new KQLog(); + private Map params; + private User user; + + public KqMembersValidateBiz() { + } + + public KqMembersValidateBiz(Map params, User user) { + this.params = params; + this.user = user; + } + + /** + * 获取建模表中维护的管理员可显示排班设置中的数据过滤 + * @return 返回这个管理员拥有的所有的人员id + */ + public List> getKqMembersValidate() { + kqLog.info("params: "+JSON.toJSONString(params)); + List> result = new ArrayList<>(); + Map>> resultByResourceId = new HashMap<>(); + Map map = null; + Map userIdLevelMap = new HashMap<>(); + try { + RecordSet rs = new RecordSet(); + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + String status = Util.null2String(params.get("status")); + + String groupId = Util.null2String(params.get("groupId"));//考勤组id + List managerRoleUserIdList = new KqShiftScheduleRoleBiz().getUfKqShiftScheduleRoleValue((user==null ? "" : ""+user.getUID()), groupId); + String viewscope = Util.null2String(params.get("viewscope"));//0:总部 1:分部 2:部门 3:人员 4:我的下属 + int pageIndex = 0;//Util.getIntValue(Util.null2String(params.get("pageIndex")), 1); + int pageSize = 0;//Util.getIntValue(Util.null2String(params.get("pageSize")), 20); + + String sqlWhere = " "; + if (viewscope.length() > 0) { + if (viewscope.equals("1")) {//分部 + String subCompanyId = Util.null2String(params.get("subCompanyId")); + sqlWhere += " and t.subcompanyid1 in (" + subCompanyId + ") "; + } else if (viewscope.equals("2")) {//部门 + String departmentId = Util.null2String(params.get("departmentId")); + sqlWhere += " and t.departmentid in (" + departmentId + ") "; + } else if (viewscope.equals("3")) {//人员 + String resourceId = Util.null2String(params.get("resourceId")); + sqlWhere += " and t.resourceid in (" + resourceId + ") "; + } + } + + String isNoAccount = Util.null2String(params.get("isNoAccount"));// 是否显示无账号人员 + if (!"1".equals(isNoAccount)) { + sqlWhere += " and t.status in(0,1,2,3) and t.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and t.loginid<>'' "); + } + if (status.length() > 0) { + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and t.status = " + status + ""; + } else if (status.equals("8")) { + sqlWhere += " and (t.status = 0 or t.status = 1 or t.status = 2 or t.status = 3) "; + } + } + + if (!Util.null2String(kQGroupComInfo.getExcludecount(groupId)).equals("1")) { + //剔除无需排班人员 + String excludeid = Util.null2String(kQGroupComInfo.getExcludeid(groupId)); + if (excludeid.length() > 0) { + sqlWhere += " and t.resourceid not in (" + excludeid + ")"; + } + } + + + String backFields = " t.resourceid, t.validatefrom, t.validateto,t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid,t.type "; + String sqlFrom = " from (SELECT distinct t.resourceid, t.validatefrom, t.validateto,t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid,t.type FROM ( \n" + + " SELECT a.id AS resourceid, b.validatefrom, b.validateto,b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid,b.type FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.validatefrom, b.validateto,b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid,b.type FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.validatefrom, b.validateto,b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid,b.type FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.validatefrom, b.validateto,b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid,b.type FROM HrmResource a, kq_groupmember b \n" + + " WHERE (a.jobtitle = b.typevalue AND b.type=5 and (b.isdelete is null or b.isdelete <> '1') AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue)))) \n" + + " UNION ALL " + + " SELECT a.id AS resourceid, b.validatefrom, b.validateto,b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid,b.type FROM HrmResource a, kq_groupmember b \n" + + " WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1')" + + " )t ) t where t.groupid = " + groupId; + if (!managerRoleUserIdList.isEmpty()) { + String allUserIds = StringUtils.join(managerRoleUserIdList, ','); + sqlFrom += " and " + Util.getSubINClause(allUserIds, "t.resourceid", "in"); + } + String groupBy = " "; + + String sql = backFields + sqlFrom + sqlWhere + groupBy; + sql = " select " + sql; + kqLog.info("GetShiftScheduleCmd:" + sql); + rs.executeQuery(sql); + while (rs.next()) { + String resourceId = Util.null2String(rs.getString("resourceid")); + String validatefrom = Util.null2String(rs.getString("validatefrom")); + validatefrom = "".equals(validatefrom) ? KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE : validatefrom; + String validateto = Util.null2String(rs.getString("validateto")); + validateto = "".equals(validateto) ? KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE : validateto; + int type = Util.getIntValue(rs.getString("type")); + int oldType = userIdLevelMap.getOrDefault(resourceId, 0); + boolean needAdd = false; + if (oldType == 0) { // 如果userIdLevelMap里面没有,就添加进去 + needAdd = true; + } else { + //1: 人力资源 + //2:分部 + //3:部门 + //5:岗位 + //6:所有人 + //优先级: 人力资源>部门>分部>岗位>所有人 + switch (type) { + case 1: + if(oldType == 1 || oldType == 3 || oldType == 2 || oldType == 5 || oldType == 6) { + needAdd = true; + } + break; + case 2: + if(oldType == 2 || oldType == 5 || oldType == 6) { + needAdd = true; + } + break; + case 3: + if(oldType == 3 || oldType == 2 || oldType == 5 || oldType == 6) { + needAdd = true; + } + break; + case 5: + if(oldType == 5 || oldType == 6) { + needAdd = true; + } + break; + default: + break; + } + } + if(needAdd) { + List> list = null; + userIdLevelMap.put(resourceId, type); + map = new HashMap<>(); + map.put("resourceId", resourceId); + map.put("validatefrom", validatefrom); + map.put("validateto", validateto); + + if(resultByResourceId.containsKey(resourceId)) { + list = resultByResourceId.get(resourceId); + } else { + list = new ArrayList<>(); + } + list.add(map); + resultByResourceId.put(resourceId, list); + } + } + for(Map.Entry>> entry : resultByResourceId.entrySet()) { + List> list = entry.getValue(); + result.addAll(list); + } + }catch (Exception e) { + new BaseBean().writeLog(e); + kqLog.info(e.getMessage()); + } + kqLog.info("排班设置界面的人员id总数: "+result.size()+"::::有效期详情: "+ JSON.toJSONString(result)); + return result; + } + + public Map> getKqMembersValidateList() { + Map> result = new HashMap<>(); + List> validateResult = getKqMembersValidate(); + List validateList = null; + for(Map entry : validateResult) { + String resourceId = Util.null2String(entry.get("resourceId")); + if(result.containsKey(resourceId)) { + validateList = result.get(resourceId); + } else { + validateList = new ArrayList<>(); + } + String validatefrom = Util.null2String(entry.get("validatefrom")); + String validateto = Util.null2String(entry.get("validateto")); + validateList.add(validatefrom); + validateList.add(validateto); + result.put(resourceId, validateList); + } + kqLog.info("按每个人拆分后有效期汇总详情:::::::"+JSON.toJSON(result)); + return result; + } + + public boolean isInRange(String kqDate, List rangeDate) { + boolean isInRange = false; + if(rangeDate != null) { + for(int i=0; i= 0 && kqDate.compareTo(toDate) <= 0; + if(isInRange) { + break; + } + i=i+1; + } + } + return isInRange; + } + + public boolean isInRange(String kqFromDate, String kqToDate, String fromDate, String toDate) { + fromDate = "".equals(fromDate) ? KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE : fromDate; + toDate = "".equals(toDate) ? KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE : toDate; + return (kqFromDate.compareTo(fromDate) >= 0 && kqFromDate.compareTo(toDate) <= 0) || + (kqToDate.compareTo(fromDate) >= 0 && kqToDate.compareTo(toDate) <= 0) || + (fromDate.compareTo(kqFromDate) >= 0 && fromDate.compareTo(kqToDate) <= 0) || + (toDate.compareTo(kqFromDate) >= 0 && toDate.compareTo(kqToDate) <= 0); + } +} diff --git a/src/com/engine/kq/biz/KqShiftScheduleRoleBiz.java b/src/com/engine/kq/biz/KqShiftScheduleRoleBiz.java new file mode 100644 index 0000000..d8240bb --- /dev/null +++ b/src/com/engine/kq/biz/KqShiftScheduleRoleBiz.java @@ -0,0 +1,127 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.bean.KqShiftscheduleRole; +import com.engine.kq.log.KQLog; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.Util; + +import java.util.*; + +/** + * 获取建模表中排班设置权限中的相关数据 + */ +public class KqShiftScheduleRoleBiz { + private static final String KQSHIFTSCHEDULE_TABKE = Util.null2String(Prop.getPropValue("kqshiftschedule_role", "KQSHIFTSCHEDULE_TABKE")); + private static final String KQSHIFTSCHEDULE_MANAGER_IDS = Util.null2String(Prop.getPropValue("kqshiftschedule_role", "KQSHIFTSCHEDULE_MANAGER_IDS")); + private static final String KQSHIFTSCHEDULE_GROUPS = Util.null2String(Prop.getPropValue("kqshiftschedule_role", "KQSHIFTSCHEDULE_GROUPS")); + private static final String KQSHIFTSCHEDULE_SUBCOMPANYS = Util.null2String(Prop.getPropValue("kqshiftschedule_role", "KQSHIFTSCHEDULE_SUBCOMPANYS")); + private static final String KQSHIFTSCHEDULE_DEPARTMENTS = Util.null2String(Prop.getPropValue("kqshiftschedule_role", "KQSHIFTSCHEDULE_DEPARTMENTS")); + private static final String KQSHIFTSCHEDULE_RESOURCE_IDS = Util.null2String(Prop.getPropValue("kqshiftschedule_role", "KQSHIFTSCHEDULE_RESOURCE_IDS")); + private KQLog kqLog = new KQLog(); + + /** + * 获取建模表中维护的管理员可显示排班设置中的数据过滤 + * @param resourceId + * @param groupId + * @return 返回这个管理员拥有的所有的人员id + */ + public List getUfKqShiftScheduleRoleValue(String resourceId, String groupId) { + List result = new ArrayList<>(); + if("".equals(KQSHIFTSCHEDULE_TABKE)) { + return result; + } + kqLog.info("管理员id: "+resourceId+"::::考勤组id: "+ groupId); + List beanList = getKqShiftsRileList(Util.null2String(resourceId), Util.null2String(groupId)); + RecordSet rs = new RecordSet(); + for(KqShiftscheduleRole bean : beanList) { + String subcompanyIds = bean.getKqShiftRoleSubcompanyIds(); + String departmentIds = bean.getKqShiftRoleDepartmentIds(); + String resourceIds = bean.getKqShiftRoleResourceIds(); + if(!"".equals(subcompanyIds)) { + rs.executeQuery("select id from hrmresource where subcompanyid1 in("+subcompanyIds+")"); + while (rs.next()) { + String userId = rs.getString("id"); + if(!result.contains(userId)) { + result.add(userId); + } + } + } + if(!"".equals(departmentIds)) { + rs.executeQuery("select id from hrmresource where departmentid in("+departmentIds+")"); + while (rs.next()) { + String userId = rs.getString("id"); + if(!result.contains(userId)) { + result.add(userId); + } + } + } + if(!"".equals(resourceIds)) { + for(String userId : resourceIds.split(",")) { + if(!result.contains(userId)) { + result.add(userId); + } + } + } + } + kqLog.info("管理员拥有的所有的人员id总数: "+result.size()+"::::详情: "+ JSON.toJSONString(result)); + return result; + } + + public List getKqShiftsRileList(String resourceId, String groupId) { + List beanList = new ArrayList<>(); + if("".equals(KQSHIFTSCHEDULE_TABKE)) { + return beanList; + } + RecordSet rs = new RecordSet(); + StringBuilder sql = new StringBuilder(); + sql.append("select * from "+KQSHIFTSCHEDULE_TABKE +" where 1=1 "); +// if (rs.getDBType().equalsIgnoreCase("sqlserver") +// || rs.getDBType().equalsIgnoreCase("mysql")) { +// sql.append(" and ("+KQSHIFTSCHEDULE_MANAGER_IDS+" is not null and "+KQSHIFTSCHEDULE_MANAGER_IDS+"<>'')"); +// sql.append(" and ("+KQSHIFTSCHEDULE_GROUPS+" is not null and "+KQSHIFTSCHEDULE_GROUPS+"<>'')"); +// } else { + sql.append(" and ("+KQSHIFTSCHEDULE_MANAGER_IDS+" is not null)"); + sql.append(" and ("+KQSHIFTSCHEDULE_GROUPS+" is not null)"); +// } + if(!"".equals(resourceId)) { + if(rs.getDBType().equals("oracle")){ + sql.append(" and ','||CAST("+KQSHIFTSCHEDULE_MANAGER_IDS+" AS VARCHAR(1000))||',' like '%,"+resourceId+",%'"); + }else if(rs.getDBType().equals("mysql")){ + sql.append(" and concat(',',CAST("+KQSHIFTSCHEDULE_MANAGER_IDS+" AS VARCHAR(1000)),',') like '%,"+resourceId+",%'"); + }else{ + sql.append(" and ','+CAST("+KQSHIFTSCHEDULE_MANAGER_IDS+" AS VARCHAR(1000))+',' like '%,"+resourceId+",%'"); + } + } + if(!"".equals(groupId)) { + if(rs.getDBType().equals("oracle")){ + sql.append(" and ','||CAST("+KQSHIFTSCHEDULE_GROUPS+" AS VARCHAR(1000))||',' like '%,"+groupId+",%'"); + }else if(rs.getDBType().equals("mysql")){ + sql.append(" and concat(',',CAST("+KQSHIFTSCHEDULE_GROUPS+" AS VARCHAR(1000)),',') like '%,"+groupId+",%'"); + }else{ + sql.append(" and ','+CAST("+KQSHIFTSCHEDULE_GROUPS+" AS VARCHAR(1000))+',' like '%,"+groupId+",%'"); + } + } + kqLog.info("sql>>>>>>>>>>>>>>>"+sql.toString()); + rs.executeQuery(sql.toString()); + + KqShiftscheduleRole bean = null; + while (rs.next()) { + bean = new KqShiftscheduleRole(); + String managerIds = Util.null2String(rs.getString(KQSHIFTSCHEDULE_MANAGER_IDS)); + bean.setKqShiftRoleManagerIds(managerIds); + String groupIds = Util.null2String(rs.getString(KQSHIFTSCHEDULE_GROUPS)); + bean.setKqShiftRoleGroupIds(groupIds); + String subcompanyIds = Util.null2String(rs.getString(KQSHIFTSCHEDULE_SUBCOMPANYS)); + bean.setKqShiftRoleSubcompanyIds(subcompanyIds); + String departmentIds = Util.null2String(rs.getString(KQSHIFTSCHEDULE_DEPARTMENTS)); + bean.setKqShiftRoleDepartmentIds(departmentIds); + String resouceIds = Util.null2String(rs.getString(KQSHIFTSCHEDULE_RESOURCE_IDS)); + bean.setKqShiftRoleResourceIds(resouceIds); + beanList.add(bean); + } + return beanList; + } + +} diff --git a/src/com/engine/kq/biz/KqYesterdayAbnormalRemindBiz.java b/src/com/engine/kq/biz/KqYesterdayAbnormalRemindBiz.java new file mode 100644 index 0000000..551a6c0 --- /dev/null +++ b/src/com/engine/kq/biz/KqYesterdayAbnormalRemindBiz.java @@ -0,0 +1,96 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.log.KQLog; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.Util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 考勤异常提醒公共接口 + */ +public class KqYesterdayAbnormalRemindBiz { + + private KQLog kqLog = new KQLog(); + /** + * 获取昨天考勤异常相关数据 + * @return + */ + public Map> getYesterdayAbnormalData(String fromDate, String toDate) { + return getYesterdayAbnormalData(fromDate, toDate, null); + } + + public Map> getYesterdayAbnormalData(String fromDate, String toDate, String resourceId) { + kqLog.info("KqAbnormalRemindBiz::getYesterdayAbnormalData:fromDate"+fromDate+":toDate:"+toDate+":resourceId:"+resourceId); + RecordSet rs = new RecordSet(); + Map> yesterdayAbnormalMap = new HashMap<>(); + String forgotBeginWorkCheck_field = " sum(b.forgotBeginWorkCheck) "; + + if(rs.getDBType().equalsIgnoreCase("oracle") || rs.getDBType().equalsIgnoreCase("gs")) { + forgotBeginWorkCheck_field = " sum(nvl(b.forgotbeginworkcheckmins,0)) "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + forgotBeginWorkCheck_field = " sum(ifnull(b.forgotbeginworkcheckmins,0)) "; + }else { + forgotBeginWorkCheck_field = " sum(isnull(b.forgotbeginworkcheckmins,0)) "; + } + String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," + + " sum(b.beLateMins) as beLateMins, " + + " sum(b.graveBeLateMins) as graveBeLateMins," + + " sum(b.leaveEarlyMins) as leaveEarlyMins, " + + " sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins, " + + " sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotcheckmins)+"+forgotBeginWorkCheck_field+" as forgotCheckMins "; + + if(rs.getDBType().equals("oracle")){ + backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields; + } + String sqlFrom = " from hrmresource a, kq_format_detail b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'"; + if(resourceId != null) { + sqlFrom += " and (a.accounttype = 0 or a.accounttype is null) and a.id="+resourceId; + } + sqlFrom += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle "; + String sql = backFields + sqlFrom + groupBy; + sql = " select " + sql; + kqLog.info("KqAbnormalRemindBiz::sql:"+sql); + rs.executeQuery(sql); + while (rs.next()) { + Map abnormalDataMap = new HashMap<>(); + String userId = rs.getString("id"); + double beLateMins = Util.getDoubleValue(rs.getString("beLateMins"), 0.0);//迟到 + double graveBeLateMins = Util.getDoubleValue(rs.getString("graveBeLateMins"), 0.0);//严重迟到 + double leaveEarlyMins = Util.getDoubleValue(rs.getString("leaveEarlyMins"), 0.0);//早退 + double graveLeaveEarlyMins = Util.getDoubleValue(rs.getString("graveLeaveEarlyMins"), 0.0);//严重早退 + double absenteeismMins = Util.getDoubleValue(rs.getString("absenteeismMins"), 0.0);//旷工 + double forgotCheck = Util.getDoubleValue(rs.getString("forgotCheckMins"), 0.0);//漏签 + if(beLateMins> 0) { + abnormalDataMap.put("late", beLateMins); + } + if(graveBeLateMins> 0) { + abnormalDataMap.put("gravelate", graveBeLateMins); + } + if(leaveEarlyMins> 0) { + abnormalDataMap.put("leaveearly", leaveEarlyMins); + } + if(graveLeaveEarlyMins> 0) { + abnormalDataMap.put("graveleaveearly", graveLeaveEarlyMins); + } + if(absenteeismMins> 0) { + abnormalDataMap.put("absent", absenteeismMins); + } + if(forgotCheck> 0) { + abnormalDataMap.put("forgot", forgotCheck); + } + if(!abnormalDataMap.isEmpty()) { + yesterdayAbnormalMap.put(userId, abnormalDataMap); + } + } + kqLog.info("KqAbnormalRemindBiz::getYesterdayAbnormalData:yesterdayAbnormalMap"+yesterdayAbnormalMap); + return yesterdayAbnormalMap; + } +} diff --git a/src/com/engine/kq/biz/Test.java b/src/com/engine/kq/biz/Test.java new file mode 100644 index 0000000..f71d669 --- /dev/null +++ b/src/com/engine/kq/biz/Test.java @@ -0,0 +1,355 @@ +package com.engine.kq.biz; + +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.RegionUtil; +import weaver.common.DateUtil; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.*; + +/** + * @author jiaqing.xu@hand-china.com + * @version 1.0 + * @name + * @description + * @date 2017/10/19 + */ +public class Test extends BaseBean { + + /** + * 显示的导出表的标题 + */ + private String title; + + /** + * 导出表的列名 + */ + private List columnName; + + /** + * 需要导出的数据集合 + */ + private List dataList = new ArrayList(); + + + /** + * @param title + * @param columnName + * @param dataList + * @description 构造方法,传入要导出的数据 + */ + public Test(String title, List columns, List dataList) { + this.dataList = dataList; + this.columnName = columns; + this.title = title; + } + + + /** + * @param + * @return + * @author jiaqing.xu@hand-china.com + * @date 2017/10/19 13:21 + * @description 导出数据到excel + */ + public void export() throws Exception { + + try { + HSSFWorkbook workbook = new HSSFWorkbook(); // 创建工作簿对象 + HSSFSheet sheet = workbook.createSheet(title); // 创建工作表 + + // 产生表格标题行 + HSSFRow rowm = sheet.createRow(0); + HSSFCell cellTiltle = rowm.createCell(0); + + //设置标题和单元格样式 + HSSFCellStyle columnTopStyle = this.getColumnTopStyle(workbook); //获取列头样式对象 + HSSFCellStyle style = this.getStyle(workbook); //单元格样式对象 + + //合并单元格 +// sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, (columnName.length - 1))); +// cellTiltle.setCellStyle(columnTopStyle); +// cellTiltle.setCellValue(title); + + List lsMergedRegion = new ArrayList<>(); + Map mergedRegion = null; + int rowIdx = 2; + int firstTitleRow = rowIdx; + int lastTitleRow = rowIdx+1; + HSSFRow rowRowName = sheet.createRow(rowIdx++); // 在索引2的位置创建行(最顶端的行开始的第二行) + HSSFRow childRowRowName = null; + // 定义所需列数 + int columnNum = getColumnLength(columnName); + Map column = null; + List childColumn = null; + for(int i=0;i) columnName.get(i); + childColumn = (List)column.get("children"); + if(Util.getIntValue(Util.null2String(column.get("rowSpan")))==2){ + if(childRowRowName==null) { + childRowRowName = sheet.createRow(rowIdx++); + } + mergedRegion = new HashMap(); + mergedRegion.put("startRow",firstTitleRow); + mergedRegion.put("overRow",lastTitleRow); + mergedRegion.put("startCol",i); + mergedRegion.put("overCol",i); + lsMergedRegion.add(mergedRegion); + } + HSSFCell cellRowName = rowRowName.createCell(i); //创建列头对应个数的单元格 + cellRowName.setCellType(CellType.STRING); //设置列头单元格的数据类型 + HSSFRichTextString text = new HSSFRichTextString(Util.null2String(column.get("title"))); + cellRowName.setCellValue(text); //设置列头单元格的值 + cellRowName.setCellStyle(columnTopStyle); //设置列头单元格样式 + + if(childColumn!=null){ + mergedRegion = new HashMap(); + mergedRegion.put("startRow",firstTitleRow); + mergedRegion.put("overRow",firstTitleRow); + mergedRegion.put("startCol",i); + mergedRegion.put("overCol",childColumn.size()-1); + lsMergedRegion.add(mergedRegion); + for(int j=i;j) childColumn.get(j); + cellRowName = childRowRowName.createCell(j); //创建列头对应个数的单元格 + cellRowName.setCellType(CellType.STRING); //设置列头单元格的数据类型 + text = new HSSFRichTextString(Util.null2String(column.get("title"))); + cellRowName.setCellValue(text); //设置列头单元格的值 + cellRowName.setCellStyle(columnTopStyle); //设置列头单元格样式 + } + } + } + + for (int i = 0; i < lsMergedRegion.size(); i++) { + mergedRegion = (Map) lsMergedRegion.get(i); + Integer startrow = Util.getIntValue(Util.null2String(mergedRegion.get("startRow"))); + Integer overrow = Util.getIntValue(Util.null2String(mergedRegion.get("overRow"))); + Integer startcol = Util.getIntValue(Util.null2String(mergedRegion.get("startCol"))); + Integer overcol = Util.getIntValue(Util.null2String(mergedRegion.get("overCol"))); + CellRangeAddress region = new CellRangeAddress(startrow, overrow, startcol, overcol); + int border = 1; + RegionUtil.setBorderBottom(BorderStyle.THIN,region, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN,region, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN,region, sheet); + RegionUtil.setBorderTop(BorderStyle.THIN,region, sheet); + sheet.addMergedRegion(region); + } + + //让列宽随着导出的列长自动适应 + for (int colNum = 0; colNum < columnNum; colNum++) { + int columnWidth = sheet.getColumnWidth(colNum) / 256; + for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) { + HSSFRow currentRow; + //当前行未被使用过 + if (sheet.getRow(rowNum) == null) { + currentRow = sheet.createRow(rowNum); + } else { + currentRow = sheet.getRow(rowNum); + } + if (currentRow.getCell(colNum) != null) { + //取得当前的单元格 + HSSFCell currentCell = currentRow.getCell(colNum); + //如果当前单元格类型为字符串 + if (currentCell.getCellTypeEnum() == CellType.STRING) { + int length = currentCell.getStringCellValue().getBytes().length; + if (columnWidth < length) { + //将单元格里面值大小作为列宽度 + columnWidth = length; + } + } + } + } + //再根据不同列单独做下处理 + if (colNum == 0) { + sheet.setColumnWidth(colNum, (columnWidth - 2) * 256); + } else { + sheet.setColumnWidth(colNum, (columnWidth + 4) * 256); + } + } + + if (workbook != null) { + String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls"; + File file = new File("c:\\poi\\"); + OutputStream stream = null; + try { + stream = new FileOutputStream(new File(file, fileName)); + workbook.write(stream); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (stream != null){ + try { + stream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + /** + * @param + * @return + * @author jiaqing.xu@hand-china.com + * @date 2017/10/19 13:31 + * @description 标题行的单元格样式 + */ + public HSSFCellStyle getColumnTopStyle(HSSFWorkbook workbook) { + + // 设置字体 + HSSFFont font = workbook.createFont(); + //设置字体大小 + font.setFontHeightInPoints((short) 11); + //字体加粗 + font.setBold(true); + //设置字体名字 + font.setFontName("Courier New"); + //设置样式; + HSSFCellStyle style = workbook.createCellStyle(); + style.setFillForegroundColor(IndexedColors.BLUE.getIndex()); + //设置底边框; + style.setBorderBottom(BorderStyle.THIN); + //设置底边框颜色; + style.setBottomBorderColor(IndexedColors.BLACK.index); + //设置左边框; + style.setBorderLeft(BorderStyle.THIN); + //设置左边框颜色; + style.setLeftBorderColor(IndexedColors.BLACK.index); + //设置右边框; + style.setBorderRight(BorderStyle.THIN); + //设置右边框颜色; + style.setRightBorderColor(IndexedColors.BLACK.index); + //设置顶边框; + style.setBorderTop(BorderStyle.THIN); + //设置顶边框颜色; + style.setTopBorderColor(IndexedColors.BLACK.index); + //在样式用应用设置的字体; + style.setFont(font); + //设置自动换行; + style.setWrapText(false); + //设置水平对齐的样式为居中对齐; + style.setAlignment(HorizontalAlignment.CENTER); + //设置垂直对齐的样式为居中对齐; + style.setVerticalAlignment(VerticalAlignment.CENTER); + return style; + } + + /** + * @param + * @return + * @author jiaqing.xu@hand-china.com + * @date 2017/10/19 13:31 + * @description 列数据信息单元格样式 + */ + public HSSFCellStyle getStyle(HSSFWorkbook workbook) { + // 设置字体 + HSSFFont font = workbook.createFont(); + //设置字体大小 + //font.setFontHeightInPoints((short)10); + //字体加粗 + //font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); + //设置字体名字 + font.setFontName("Courier New"); + //设置样式; + HSSFCellStyle style = workbook.createCellStyle(); + //设置底边框; + style.setBorderBottom(BorderStyle.THIN); + //设置底边框颜色; + style.setBottomBorderColor(IndexedColors.BLACK.index); + //设置左边框; + style.setBorderLeft(BorderStyle.THIN); + //设置左边框颜色; + style.setLeftBorderColor(IndexedColors.BLACK.index); + //设置右边框; + style.setBorderRight(BorderStyle.THIN); + //设置右边框颜色; + style.setRightBorderColor(IndexedColors.BLACK.index); + //设置顶边框; + style.setBorderTop(BorderStyle.THIN); + //设置顶边框颜色; + style.setTopBorderColor(IndexedColors.BLACK.index); + //在样式用应用设置的字体; + style.setFont(font); + //设置自动换行; + style.setWrapText(false); + //设置水平对齐的样式为居中对齐; + style.setAlignment(HorizontalAlignment.CENTER); + //设置垂直对齐的样式为居中对齐; + style.setVerticalAlignment(VerticalAlignment.CENTER); + return style; + } + + public int getColumnLength(List columns){ + int columnLength = 0; + Map column = null; + for(int i=0;i)columns.get(i); + if(column.get("colSpan")!=null){ + columnLength += Util.getIntValue(Util.null2String(column.get("colSpan"))); + }else{ + columnLength++; + } + } + return columnLength; + } + public static void main(String[] args) { + String title = "货运单据导出"; + List columns = new ArrayList<>();; + Map column = null; + + column = new HashMap<>(); + column.put("title","序号"); + column.put("rowSpan",2); + columns.add(column); + + String fromDate = "2019-01-01"; + String toDate = "2019-01-31"; + boolean isEnd = false; + Calendar cal = DateUtil.getCalendar(); + List 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("width",30*256); + childColumns.add(column); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + + column = new HashMap(); + column.put("title", "日历"); + if(childColumns.size()>0) {//跨列width取子列的width + column.put("children", childColumns); + column.put("colSpan",childColumns.size()); + } + columns.add(column); + + List dataList = new ArrayList(); + //实例化工具类 + Test ex = new Test(title, columns, dataList); + try { + //导出excel + ex.export(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/src/com/engine/kq/biz/chain/cominfo/HalfShiftComIndex.java b/src/com/engine/kq/biz/chain/cominfo/HalfShiftComIndex.java new file mode 100644 index 0000000..1e9be2a --- /dev/null +++ b/src/com/engine/kq/biz/chain/cominfo/HalfShiftComIndex.java @@ -0,0 +1,202 @@ +package com.engine.kq.biz.chain.cominfo; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.log.KQLog; +import com.google.common.collect.Lists; +import java.util.ArrayList; +import java.util.List; +import java.util.Arrays; +import java.util.Map; +import weaver.general.BaseBean; +import weaver.general.Util; + +/** + * 半天规则计算类 + */ +public class HalfShiftComIndex extends ShiftComIndex { + + public HalfShiftComIndex(String name,Map workTimeMap){ + super(name,workTimeMap); + } + + @Override + public void handleDuration(ShiftInfoCominfoBean shiftInfoCominfoBean) throws Exception { + handleHalfTime(shiftInfoCominfoBean); + } + + public void handleHalfTime(ShiftInfoCominfoBean shiftInfoCominfoBean) throws Exception { + String halfcalrule = Util.null2String(workTimeMap.get("halfcalrule")); + String halfcalpoint = Util.null2String(workTimeMap.get("halfcalpoint")); + String halfcalpoint2cross = Util.null2String(workTimeMap.get("halfcalpoint2cross")); + // shiftInfoCominfoBean.setHalfcalrule(halfcalrule); + shiftInfoCominfoBean.setHalfcalpoint(halfcalpoint); + shiftInfoCominfoBean.setHalfcalpoint2cross(halfcalpoint2cross); + if("0".equalsIgnoreCase(halfcalrule)){ + //采用总工作时长的一般作为半天 + setHalfWorkTime(shiftInfoCominfoBean); + }else{ + setCustomizeHalfWorkTime(shiftInfoCominfoBean); + } + } + + /** + * 采用自定义的半天规则 + * @param shiftInfoCominfoBean + */ + public void setCustomizeHalfWorkTime(ShiftInfoCominfoBean shiftInfoCominfoBean) { + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + String halfcalpoint = Util.null2String(workTimeMap.get("halfcalpoint")); + String halfcalpoint2cross = Util.null2String(workTimeMap.get("halfcalpoint2cross")); + + List halfWorkTime = shiftInfoCominfoBean.getHalfWorkTime(); + List halfWorkIndex = shiftInfoCominfoBean.getHalfWorkIndex(); + List allWorkTime = shiftInfoCominfoBean.getAllLongWorkTime(); + + if(!allWorkTime.isEmpty() && halfcalpoint.length() > 0){ + String firstTime = allWorkTime.get(0); + String lastTime = allWorkTime.get(allWorkTime.size()-1); + int firstTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(firstTime); + int lastTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(lastTime); + int halfcalpointIndex = kqTimesArrayComInfo.getArrayindexByTimes(halfcalpoint); + if("1".equalsIgnoreCase(halfcalpoint2cross)){ + halfcalpointIndex = kqTimesArrayComInfo.turn24to48TimeIndex(halfcalpointIndex); + } + if(halfcalpointIndex>=firstTimeIndex && halfcalpointIndex<=lastTimeIndex){ + int[] halfs = new int[3]; + halfs[0] = firstTimeIndex; + halfs[1] = halfcalpointIndex; + halfs[2] = lastTimeIndex; + halfWorkIndex.add(halfs); + + halfWorkTime.add(kqTimesArrayComInfo.getTimesByArrayindex(firstTimeIndex)); + halfWorkTime.add(kqTimesArrayComInfo.getTimesByArrayindex(halfcalpointIndex)); + halfWorkTime.add(kqTimesArrayComInfo.getTimesByArrayindex(lastTimeIndex)); + }else{ + + String serialid = Util.null2String(workTimeMap.get("serialid")); + if(halfcalpointIndex<=lastTimeIndex){ + int[] halfs = new int[3]; + halfs[0] = halfcalpointIndex; + halfs[1] = halfcalpointIndex; + halfs[2] = lastTimeIndex; + halfWorkIndex.add(halfs); + + halfWorkTime.add(kqTimesArrayComInfo.getTimesByArrayindex(halfcalpointIndex)); + halfWorkTime.add(kqTimesArrayComInfo.getTimesByArrayindex(halfcalpointIndex)); + halfWorkTime.add(kqTimesArrayComInfo.getTimesByArrayindex(lastTimeIndex)); + }else{ + new KQLog().info("serialid:"+serialid+"半天规则有误:firstTimeIndex:"+ firstTimeIndex + +":halfcalpointIndex:"+halfcalpointIndex+":lastTimeIndex:"+lastTimeIndex); + } + } + } + } + + /** + * 采用总工作时长的一般作为半天 + * @param shiftInfoCominfoBean + * @throws Exception + */ + public void setHalfWorkTime(ShiftInfoCominfoBean shiftInfoCominfoBean) throws Exception { + KQLog kqLog = new KQLog(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + + List halfWorkTime = shiftInfoCominfoBean.getHalfWorkTime(); + List halfWorkIndex = shiftInfoCominfoBean.getHalfWorkIndex(); + List restLongTimeIndex = shiftInfoCominfoBean.getRestLongTimeIndex(); + + List allWorkTime = shiftInfoCominfoBean.getAllLongWorkTime(); + String serialid = shiftInfoCominfoBean.getSerialid(); + int[] initArrays = kqTimesArrayComInfo.getInitArr(); + + int workmins = Util.getIntValue(Util.null2String(workTimeMap.get("workmins"))); + + int halfMins = workmins/2; + if(restLongTimeIndex != null && !restLongTimeIndex.isEmpty()){ + List workLongTimeIndex = shiftInfoCominfoBean.getWorkLongTimeIndex(); + if(workLongTimeIndex != null && !workLongTimeIndex.isEmpty() ){ + //目前只有一天一次考勤才有半天的规则 + int workStart0 = workLongTimeIndex.get(0)[0]; + int workEnd0 = workLongTimeIndex.get(workLongTimeIndex.size()-1)[1]; + for (int i = 0; i < workLongTimeIndex.size(); i++) { + int[] workIndex = workLongTimeIndex.get(i); + int workStart = workIndex[0]; + int workEnd = workIndex[1]; + Arrays.fill(initArrays, workStart, workEnd, 0); + } + for(int i = 0 ; i < restLongTimeIndex.size();i++){ + int[] restTimes1 = restLongTimeIndex.get(i); + int restStart = restTimes1[0]; + int restEnd = restTimes1[1]; + Arrays.fill(initArrays, restStart, restEnd, 1); + } + int halfCnt = 0; + int haflIndex = workStart0; + for(int i = workStart0 ; i < workEnd0+1 ; i++){ + if(halfCnt == halfMins){ + break; + } + haflIndex = haflIndex + 1; + if(initArrays[i] == 0){ + //是工作时间点 + halfCnt = halfCnt + 1; + } + } + if(haflIndex > -1){ + String time0 = allWorkTime.get(0); + String time1 = kqTimesArrayComInfo.getTimesByArrayindex(haflIndex); + String time2 = allWorkTime.get(allWorkTime.size()-1); + halfWorkTime.add(time0); + halfWorkTime.add(time1); + halfWorkTime.add(time2); + int[] halfs = new int[3]; + halfs[0] = kqTimesArrayComInfo.getArrayindexByTimes(time0); + halfs[1] = kqTimesArrayComInfo.getArrayindexByTimes(time1); + halfs[2] = kqTimesArrayComInfo.getArrayindexByTimes(time2); + halfWorkIndex.add(halfs); + } + } + }else{ + List workLongTimeIndex = shiftInfoCominfoBean.getWorkLongTimeIndex(); + List eachWorkMins = shiftInfoCominfoBean.getEachWorkMins(); + //说明下workIndex里可能是[09:00,12:00] [13:00,18:00] + //workmins是7小时*60 420分钟,所以他表示的是实际的工作时长 + //如果取一半的时段的话,应该是3.5小时,那么应该是13:30 + + int halfCount = 0; + int preHalfCount = 0; + int halfIndex = -1; + int interval = 0; + for(int i = 0 ;i < eachWorkMins.size() ; i++){ + preHalfCount = halfCount; + halfCount = halfCount+eachWorkMins.get(i); + if(halfCount > halfMins){ + //这里表示半天的时长出现在这个时段里面 + halfIndex = i; + if(halfIndex == 0){ + interval = halfMins; + }else{ + interval = halfMins-preHalfCount; + } + break; + } + } + if(halfIndex > -1 ){ + int[] acrossTimes = workLongTimeIndex.get(halfIndex); + int halfTimeIndex = acrossTimes[0]+interval; + String time0 = allWorkTime.get(0); + String time1 = kqTimesArrayComInfo.getTimesByArrayindex(halfTimeIndex); + String time2 = allWorkTime.get(allWorkTime.size()-1); + halfWorkTime.add(time0); + halfWorkTime.add(time1); + halfWorkTime.add(time2); + int[] halfs = new int[3]; + halfs[0] = kqTimesArrayComInfo.getArrayindexByTimes(time0); + halfs[1] = kqTimesArrayComInfo.getArrayindexByTimes(time1); + halfs[2] = kqTimesArrayComInfo.getArrayindexByTimes(time2); + halfWorkIndex.add(halfs); + } + } + } +} diff --git a/src/com/engine/kq/biz/chain/cominfo/RestShiftComIndex.java b/src/com/engine/kq/biz/chain/cominfo/RestShiftComIndex.java new file mode 100644 index 0000000..d16a0e2 --- /dev/null +++ b/src/com/engine/kq/biz/chain/cominfo/RestShiftComIndex.java @@ -0,0 +1,36 @@ +package com.engine.kq.biz.chain.cominfo; + +import com.engine.kq.biz.KQTimesArrayComInfo; +import java.util.List; +import java.util.Map; +import weaver.general.Util; + +/** + * 休息时段计算类 + */ +public class RestShiftComIndex extends ShiftComIndex { + + public RestShiftComIndex(String name,Map workTimeMap){ + super(name,workTimeMap); + } + + @Override + public void handleDuration(ShiftInfoCominfoBean shiftInfoCominfoBean) throws Exception { + + String isresttimeopen = Util.null2String(workTimeMap.get("isresttimeopen")); + if("1".equalsIgnoreCase(isresttimeopen)){ + handleRestTime(shiftInfoCominfoBean); + } + this.success.handleDuration(shiftInfoCominfoBean); + + } + + private void handleRestTime(ShiftInfoCominfoBean shiftInfoCominfoBean) throws Exception { + + List restTimes = (List)workTimeMap.get("restTime"); + + setRestDuration(restTimes, shiftInfoCominfoBean); + + } + +} diff --git a/src/com/engine/kq/biz/chain/cominfo/ShiftComIndex.java b/src/com/engine/kq/biz/chain/cominfo/ShiftComIndex.java new file mode 100644 index 0000000..2d38d4f --- /dev/null +++ b/src/com/engine/kq/biz/chain/cominfo/ShiftComIndex.java @@ -0,0 +1,797 @@ +package com.engine.kq.biz.chain.cominfo; + +import com.engine.kq.biz.KQTimesArrayComInfo; +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +import java.time.temporal.ChronoUnit; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.DateUtil; +import weaver.general.Util; + +/** + * 针对时长计算的基类 + */ +public abstract class ShiftComIndex { + + protected ShiftComIndex success; //定义下一个处理对象 + protected String name ; //定义下一个对象的名字 + protected Map workTimeMap ; //每个地方都会用到的缓存类 + private LocalDateTime localDateTime = LocalDateTime.now(); + private DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + private DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + private DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + + public ShiftComIndex(String name,Map workTimeMap) { + this.name=name; + this.workTimeMap = workTimeMap; + } + //创建链 + public void setDuration(ShiftComIndex durationIndex) { + this.success=durationIndex; + } + + public abstract void handleDuration(ShiftInfoCominfoBean shiftInfoCominfoBean) throws Exception ; + + /** + * 得到需要的上下班时间 + * @param workTimes + * @param shiftInfoCominfoBean + */ + public void setWorkDuration(List workTimes,ShiftInfoCominfoBean shiftInfoCominfoBean) throws Exception { + + String tmpDate = localDateTime.toLocalDate().format(dateFormatter); + String nextDate = localDateTime.toLocalDate().plusDays(1).format(dateFormatter); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + List preWorkTime = shiftInfoCominfoBean.getPreWorkTime(); + List workTime = shiftInfoCominfoBean.getWorkTime(); + List workAcrossTime = shiftInfoCominfoBean.getWorkAcrossTime(); + + List preWorkTimeIndex = shiftInfoCominfoBean.getPreWorkTimeIndex(); + List workTimeIndex = shiftInfoCominfoBean.getWorkTimeIndex(); + List workAcrossTimeIndex = shiftInfoCominfoBean.getWorkAcrossTimeIndex(); + + List workPunchMins =shiftInfoCominfoBean.getWorkPunchMins(); + List allWorkTime = shiftInfoCominfoBean.getAllWorkTime(); + List allAcrossWorkTime = shiftInfoCominfoBean.getAllAcrossWorkTime(); + List eachWorkMins = shiftInfoCominfoBean.getEachWorkMins(); + + List> workAcrossLongTime = shiftInfoCominfoBean.getWorkAcrossLongTime(); + List timelineList = shiftInfoCominfoBean.getTimelineList(); + List allLongWorkTime = shiftInfoCominfoBean.getAllLongWorkTime(); + List> signWorkTime = shiftInfoCominfoBean.getSignWorkTime(); + List allWorkTimeisAcross = shiftInfoCominfoBean.getAllWorkTimeisAcross(); + + int workmins = shiftInfoCominfoBean.getWorkmins(); + + List workLongTimeIndex = shiftInfoCominfoBean.getWorkLongTimeIndex(); + + for(int k = 0 ; k < workTimes.size() ; k++){ + List sectionList = (List)workTimes.get(k); + if(sectionList == null || sectionList.isEmpty()){ + break; + } + String[][] workMinsAcrossArr = new String[2][]; + workMinsAcrossArr[0]=new String[2]; + workMinsAcrossArr[1]=new String[2]; + //sectionList一定是成对存在的,开始时间和结束时间 + if(sectionList.size() == 2) { + Map onWorkMap = (Map) sectionList.get(0); + buildWorkIndex(onWorkMap, workMinsAcrossArr, allAcrossWorkTime, allWorkTime,allLongWorkTime,0,kqTimesArrayComInfo,allWorkTimeisAcross); + + Map offWorkMap = (Map) sectionList.get(1); + buildWorkIndex(offWorkMap, workMinsAcrossArr,allAcrossWorkTime, allWorkTime,allLongWorkTime,1, + kqTimesArrayComInfo,allWorkTimeisAcross); + workPunchMins.add(workMinsAcrossArr); + } + } + + int j = 0 ; + for(int i = 0 ; i < allWorkTime.size() ; ){ + String[] preWorkArr = new String[2]; + String[] workArr = new String[2]; + String[] workAcrossArr = new String[2]; + + int[] preWorkIndexArr = new int[2]; + int[] workIndexArr = new int[2]; + int[] workLongIndexArr = new int[2]; + int[] workAcrossIndexArr = new int[2]; + + if(allWorkTime.size() % 2 != 0){ + break; + } + //是否是第一个打卡 针对多次打卡的情况来说的 + boolean isFirst = false; + if(i == 0){ + isFirst = true; + } + String onWorkTime = Util.null2String(allWorkTime.get(i)); + String offWorkTime = Util.null2String(allWorkTime.get(i+1)); + String onWorkTimeIsAcross = Util.null2String(allWorkTimeisAcross.get(i)); + String offWorkTimeIsAcross = Util.null2String(allWorkTimeisAcross.get(i+1)); + + String[][] workPunchMin = workPunchMins.get(j); + //上班 允许最早打卡分钟数 + String punchMin00 = workPunchMin[0][0]; +// //上班 允许最晚打卡分钟数 + String punchMin01 = workPunchMin[0][1]; + //下班 允许最早打卡分钟数 + String punchMin10 = workPunchMin[1][0]; + //下班 允许最晚打卡分钟数 + String punchMin11 = workPunchMin[1][1]; + + String onDateTime = tmpDate+" "+onWorkTime; + String offDateTime = tmpDate+" "+offWorkTime; + + if(!allAcrossWorkTime.isEmpty()){ + //当前班次存在跨天 + shiftInfoCominfoBean.setIsAcross("1"); + + //如果有跨天,分为几种情况 当前工作时段跨天,当前工作时段不跨天 + if(!"1".equalsIgnoreCase(onWorkTimeIsAcross) && !"1".equalsIgnoreCase(offWorkTimeIsAcross)){ + //当前工作时段不跨天的 + workArr[0] = onWorkTime; + workArr[1] = offWorkTime; + workTime.add(workArr); + + workIndexArr[0] = kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime); + workIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime); + workTimeIndex.add(workIndexArr); + + workAcrossArr[0] = onWorkTime; + workAcrossArr[1] = offWorkTime; + workAcrossTime.add(workAcrossArr); + + workAcrossIndexArr[0] = kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime); + workAcrossIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime); + workAcrossTimeIndex.add(workAcrossIndexArr); + + Map longTimeMap = new HashMap<>(); + longTimeMap.put("bengintime", onWorkTime); + longTimeMap.put("endtime", offWorkTime); + longTimeMap.put("bengintime_across", "0"); + longTimeMap.put("endtime_across", "0"); + workAcrossLongTime.add(longTimeMap); + + eachWorkMins.add(kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime)-kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime)); + + workLongIndexArr[0] = kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime); + workLongIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime); + workLongTimeIndex.add(workLongIndexArr); + + Map isSignAcrossMap = new HashMap<>(); + isSignAcrossMap.put("onsign", "0"); + isSignAcrossMap.put("offsign", "0"); + isSignAcrossMap.put("bengintime", onWorkTime); + isSignAcrossMap.put("endtime", offWorkTime); + + buildSignList(signWorkTime,onDateTime,offDateTime,Util.getIntValue(punchMin00),Util.getIntValue(punchMin11),isSignAcrossMap,Util.getIntValue(punchMin01),Util.getIntValue(punchMin10),isFirst); + + buildTimeList(timelineList, "on", shiftInfoCominfoBean.getSerialid(), "0", onWorkTime, punchMin00,workmins,isSignAcrossMap, punchMin01); + buildTimeList(timelineList, "off", shiftInfoCominfoBean.getSerialid(), "0", offWorkTime, punchMin11,workmins,isSignAcrossMap, punchMin10); + + }else{ + //当前工作时段存在跨天的 ,只有两种情况 (上班不跨天,下班跨天)和(上班下班都跨天的) + if(!"1".equalsIgnoreCase(onWorkTimeIsAcross) && "1".equalsIgnoreCase(offWorkTimeIsAcross)){ +// 这是上班不跨天,下班跨天 + preWorkArr[0] = "00:00"; + preWorkArr[1] = offWorkTime; + preWorkTime.add(preWorkArr); + + preWorkIndexArr[0] = 0; + preWorkIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime); + preWorkTimeIndex.add(preWorkIndexArr); + + workArr[0] = onWorkTime; + workArr[1] = "24:00"; + workTime.add(workArr); + + workIndexArr[0] = kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime); + workIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes("24:00"); + workTimeIndex.add(workIndexArr); + + workAcrossArr[0] = onWorkTime; + workAcrossArr[1] = offWorkTime; + workAcrossTime.add(workAcrossArr); + + workAcrossIndexArr[0] = kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime); + workAcrossIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime); + workAcrossTimeIndex.add(workAcrossIndexArr); + + String longofftime = kqTimesArrayComInfo.turn24to48Time(offWorkTime); + + Map longTimeMap = new HashMap<>(); + longTimeMap.put("bengintime", onWorkTime); + longTimeMap.put("endtime", longofftime); + longTimeMap.put("bengintime_across", "0"); + longTimeMap.put("endtime_across", "1"); + workAcrossLongTime.add(longTimeMap); + + eachWorkMins.add(1440-kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime)+kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime)); + + workLongIndexArr[0] = kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime); + workLongIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes(longofftime); + workLongTimeIndex.add(workLongIndexArr); + + Map isSignAcrossMap = new HashMap<>(); + isSignAcrossMap.put("onsign", "0"); + isSignAcrossMap.put("offsign", "1"); + isSignAcrossMap.put("bengintime", onWorkTime); + isSignAcrossMap.put("endtime", offWorkTime); + + offDateTime = nextDate+" "+offWorkTime; + buildSignList(signWorkTime,onDateTime,offDateTime,Util.getIntValue(punchMin00),Util.getIntValue(punchMin11),isSignAcrossMap, + Util.getIntValue(punchMin01), Util.getIntValue(punchMin10),isFirst); + + buildTimeList(timelineList, "on", shiftInfoCominfoBean.getSerialid(), "0", onWorkTime, punchMin00,workmins,isSignAcrossMap, + punchMin01); + buildTimeList(timelineList, "off", shiftInfoCominfoBean.getSerialid(), "1", offWorkTime, punchMin11,workmins,isSignAcrossMap, + punchMin10); + + }else if("1".equalsIgnoreCase(onWorkTimeIsAcross) && "1".equalsIgnoreCase(offWorkTimeIsAcross)){ +// 这是上班下班都跨天的 + preWorkArr[0] = onWorkTime; + preWorkArr[1] = offWorkTime; + preWorkTime.add(preWorkArr); + + preWorkIndexArr[0] = kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime); + preWorkIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime); + preWorkTimeIndex.add(preWorkIndexArr); + + workAcrossArr[0] = onWorkTime; + workAcrossArr[1] = offWorkTime; + workAcrossTime.add(workAcrossArr); + + workIndexArr[0] = kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime); + workIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes("24:00"); + workTimeIndex.add(workIndexArr); + + workAcrossIndexArr[0] = kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime); + workAcrossIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime); + workAcrossTimeIndex.add(workAcrossIndexArr); + + String longontime = kqTimesArrayComInfo.turn24to48Time(onWorkTime); + String longofftime = kqTimesArrayComInfo.turn24to48Time(offWorkTime); + + Map longTimeMap = new HashMap<>(); + longTimeMap.put("bengintime", longontime); + longTimeMap.put("endtime", longofftime); + longTimeMap.put("bengintime_across", "1"); + longTimeMap.put("endtime_across", "1"); + workAcrossLongTime.add(longTimeMap); + eachWorkMins.add(kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime)-kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime)); + + workLongIndexArr[0] = kqTimesArrayComInfo.getArrayindexByTimes(longontime); + workLongIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes(longofftime); + workLongTimeIndex.add(workLongIndexArr); + + Map isSignAcrossMap = new HashMap<>(); + isSignAcrossMap.put("onsign", "1"); + isSignAcrossMap.put("offsign", "1"); + isSignAcrossMap.put("bengintime", onWorkTime); + isSignAcrossMap.put("endtime", offWorkTime); + + onDateTime = nextDate+" "+onWorkTime; + offDateTime = nextDate+" "+offWorkTime; + buildSignList(signWorkTime,onDateTime,offDateTime,Util.getIntValue(punchMin00),Util.getIntValue(punchMin11),isSignAcrossMap, + Util.getIntValue(punchMin01), Util.getIntValue(punchMin10),isFirst); + + buildTimeList(timelineList, "on", shiftInfoCominfoBean.getSerialid(), "1", onWorkTime, punchMin00,workmins,isSignAcrossMap, + punchMin01); + buildTimeList(timelineList, "off", shiftInfoCominfoBean.getSerialid(), "1", offWorkTime, punchMin11,workmins,isSignAcrossMap, + punchMin10); + + } + } + }else{ + //如果没有跨天 + workArr[0] = onWorkTime; + workArr[1] = offWorkTime; + workTime.add(workArr); + + workIndexArr[0] = kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime); + workIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime); + workTimeIndex.add(workIndexArr); + + workAcrossArr[0] = onWorkTime; + workAcrossArr[1] = offWorkTime; + workAcrossTime.add(workAcrossArr); + + + workAcrossIndexArr[0] = kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime); + workAcrossIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime); + workAcrossTimeIndex.add(workAcrossIndexArr); + + Map longTimeMap = new HashMap<>(); + longTimeMap.put("bengintime", onWorkTime); + longTimeMap.put("endtime", offWorkTime); + longTimeMap.put("bengintime_across", "0"); + longTimeMap.put("endtime_across", "0"); + workAcrossLongTime.add(longTimeMap); + + eachWorkMins.add(kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime)-kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime)); + + workLongIndexArr[0] = kqTimesArrayComInfo.getArrayindexByTimes(onWorkTime); + workLongIndexArr[1] = kqTimesArrayComInfo.getArrayindexByTimes(offWorkTime); + workLongTimeIndex.add(workLongIndexArr); + + Map isSignAcrossMap = new HashMap<>(); + isSignAcrossMap.put("onsign", "0"); + isSignAcrossMap.put("offsign", "0"); + isSignAcrossMap.put("bengintime", onWorkTime); + isSignAcrossMap.put("endtime", offWorkTime); + + buildSignList(signWorkTime,onDateTime,offDateTime,Util.getIntValue(punchMin00),Util.getIntValue(punchMin11),isSignAcrossMap, + Util.getIntValue(punchMin01), Util.getIntValue(punchMin10),isFirst); + + buildTimeList(timelineList, "on", shiftInfoCominfoBean.getSerialid(), "0", onWorkTime, punchMin00,workmins,isSignAcrossMap, + punchMin01); + buildTimeList(timelineList, "off", shiftInfoCominfoBean.getSerialid(), "0", offWorkTime, punchMin11,workmins,isSignAcrossMap, + punchMin10); + } + + i = i + 2; + j++; + } + } + + /** + * 填充允许打卡的范围list集合 + * @param signWorkTime 最终返回的集合 + * @param onDateTime 上班开始时间 + * @param offDateTime 下班结束时间 + * @param punchMin00 上班前多久开始打卡 + * @param punchMin11 下班后多久结束打卡 + * @param isSignAcrossMap 上班工作时间是否跨天 + * @param punchMin01 上班后多久停止打卡 + * @param punchMin10 上班前多久开始打卡 + * @param isFirst 多次打卡的时候是否是第一次打卡 只有第一次打卡的上班卡允许打卡才会跨到前一天 + */ + private void buildSignList(List> signWorkTime, String onDateTime, + String offDateTime, int punchMin00, int punchMin11, Map isSignAcrossMap, + int punchMin01, int punchMin10,boolean isFirst){ + Map signMap = new HashMap<>(); + + //上班前 允许最早打卡是否跨天 + boolean isSignAcross00 = false; + //上班 允许最晚打卡是否跨天 + boolean isSignAcross01 = false; + //下班后 允许最早打卡是否跨天 + boolean isSignAcross10 = false; + //下班后 允许最晚打卡是否跨天 + boolean isSignAcross11 = false; + + //工作时段是否跨天 + boolean workAcross0 = "1".equalsIgnoreCase(Util.null2String(isSignAcrossMap.get("onsign"))); + //工作时段是否跨天 + boolean workAcross1 = "1".equalsIgnoreCase(Util.null2String(isSignAcrossMap.get("offsign"))); + + signMap.put("workbengintime", Util.null2String(isSignAcrossMap.get("bengintime"))); + signMap.put("workendtime", Util.null2String(isSignAcrossMap.get("endtime"))); + signMap.put("workbengintime_across", Util.null2String(isSignAcrossMap.get("onsign"))); + signMap.put("workendtime_across", Util.null2String(isSignAcrossMap.get("offsign"))); + + LocalDateTime onLocalDateTime = LocalDateTime.parse(onDateTime,dateTimeFormatter); + if(punchMin00 > 0){ + boolean is_pre_across = false; + LocalDateTime canOnLocalDateTime = onLocalDateTime.minusMinutes(punchMin00); + if(workAcross0){ + if(onLocalDateTime.toLocalDate().isEqual(canOnLocalDateTime.toLocalDate())){ + isSignAcross00 = true; + } + }else{ + //如果是上班前的话,只要当前工作时间不跨天,上班前多久都不会再跨天了,只会跨到前一天 + if(onLocalDateTime.toLocalDate().isAfter(canOnLocalDateTime.toLocalDate())){ + if(isFirst){ + is_pre_across = true; + } + } + } + buildSignTimeMap(canOnLocalDateTime,isSignAcross00,"on",signMap,"start"); + if(is_pre_across){ + signMap.put("bengintime_pre_across", "1"); + isSignAcrossMap.put("bengintime_pre_across", "1"); + } + } + if(punchMin01 > -1){ + LocalDateTime endOnLocalDateTime = onLocalDateTime.plusMinutes(punchMin01); + if(workAcross0){ + if(onLocalDateTime.toLocalDate().isEqual(endOnLocalDateTime.toLocalDate())){ + isSignAcross01 = true; + } + }else{ + if(onLocalDateTime.toLocalDate().isBefore(endOnLocalDateTime.toLocalDate())){ + isSignAcross01 = true; + isSignAcrossMap.put("onsign_end", "1"); + }else { + isSignAcross01 = false; + } + } + buildSignTimeMap(endOnLocalDateTime,isSignAcross01,"on",signMap,"end"); + if(punchMin10 < 0){ + LocalDateTime tmpStartOffLocalDateTime = endOnLocalDateTime.plusMinutes(1); + if(tmpStartOffLocalDateTime.toLocalDate().isAfter(endOnLocalDateTime.toLocalDate())){ + buildSignTimeMap(tmpStartOffLocalDateTime,true,"off",signMap,"start"); + }else{ + buildSignTimeMap(tmpStartOffLocalDateTime,isSignAcross01,"off",signMap,"start"); + } + } + } + LocalDateTime offLocalDateTime = LocalDateTime.parse(offDateTime,dateTimeFormatter); + if(punchMin10 > -1){ + LocalDateTime startOffLocalDateTime = offLocalDateTime.minusMinutes(punchMin10); + if(workAcross1){ + if(offLocalDateTime.toLocalDate().isEqual(startOffLocalDateTime.toLocalDate())){ + isSignAcross10 = true; + isSignAcrossMap.put("offsign_start", "1"); + } + }else{ + if(offLocalDateTime.toLocalDate().isEqual(startOffLocalDateTime.toLocalDate())){ + }else { + isSignAcross10 = true; + isSignAcrossMap.put("offsign_start", "1"); + } + } + buildSignTimeMap(startOffLocalDateTime,isSignAcross10,"off",signMap,"start"); + if(punchMin01 < 0){ + LocalDateTime tmpEndOnLocalDateTime = startOffLocalDateTime.minusMinutes(1); + long betweenDays = tmpEndOnLocalDateTime.toLocalDate().toEpochDay() - onLocalDateTime.toLocalDate().toEpochDay(); + if(betweenDays > 0){ + buildSignTimeMap(tmpEndOnLocalDateTime,isSignAcross10,"on",signMap,"end"); + }else{ + buildSignTimeMap(tmpEndOnLocalDateTime,false,"on",signMap,"end"); + } + } + } + if(punchMin11 > 0){ + LocalDateTime canOffLocalDateTime = offLocalDateTime.plusMinutes(punchMin11); + if(workAcross1){ + isSignAcross11 = true; + }else{ + if(offLocalDateTime.toLocalDate().isBefore(canOffLocalDateTime.toLocalDate())){ + isSignAcross11 = true; + isSignAcrossMap.put("offsign", "1"); + } + } + buildSignTimeMap(canOffLocalDateTime,isSignAcross11,"off",signMap,"end"); + } + signWorkTime.add(signMap); + } + + /** + * 填充允许打卡的map集合 + * @param canLocalDateTime + * @param isSignAcross + * @param type + * @param signMap + * @param punchMinsType 允许打卡的类型,是上班前开始还是上班后结束 + */ + private void buildSignTimeMap(LocalDateTime canLocalDateTime, boolean isSignAcross, String type, + Map signMap, String punchMinsType){ + String signTime = canLocalDateTime.toLocalTime().format(timeFormatter); + String isAcross = isSignAcross?"1":"0"; + if("on".equalsIgnoreCase(type)){ + if("end".equalsIgnoreCase(punchMinsType)){ + signMap.put("bengintime_end", signTime); + signMap.put("bengintime_end_across", isAcross); + }else{ + signMap.put("bengintime", signTime); + signMap.put("bengintime_across", isAcross); + } + }else{ + if("start".equalsIgnoreCase(punchMinsType)){ + signMap.put("endtime_start", signTime); + signMap.put("endtime_start_across", isAcross); + }else{ + signMap.put("endtime", signTime); + signMap.put("endtime_across", isAcross); + } + } + } + + + + /** + * @param timelineList + * @param type 签到签退标识 + * @param serialid 班次id + * @param across 时间是否跨天 + * @param time 上下班时间 + * @param min 打卡时段控制 + * @param workmins + * @param isSignAcrossMap 允许打卡时间是否跨天 + * @param min_next + */ + private void buildTimeList(List timelineList, String type, String serialid, String across, + String time, String min, int workmins, Map isSignAcrossMap, + String min_next){ + Map timelineMap = new HashMap<>(); + + timelineMap = new HashMap<>(); + timelineMap.put("type", type); + timelineMap.put("serialid", serialid); + timelineMap.put("isacross", across); + timelineMap.put("time", time); + timelineMap.put("min", min); + timelineMap.put("min_next", min_next); + timelineMap.put("isPunchOpen", "1"); + timelineMap.put("workmins",workmins); + if("on".equalsIgnoreCase(type)){ + timelineMap.put("signAcross","1".equalsIgnoreCase(Util.null2String(isSignAcrossMap.get("onsign")))?"1":"0"); + timelineMap.put("signAcross_next","1".equalsIgnoreCase(Util.null2String(isSignAcrossMap.get("onsign_end")))?"1":"0"); + if(isSignAcrossMap.containsKey("bengintime_pre_across")){ + timelineMap.put("sign_preAcross","1"); + } + }else{ + timelineMap.put("signAcross","1".equalsIgnoreCase(Util.null2String(isSignAcrossMap.get("offsign")))?"1":"0"); + timelineMap.put("signAcross_next","1".equalsIgnoreCase(Util.null2String(isSignAcrossMap.get("offsign_start")))?"1":"0"); + } + timelineList.add(timelineMap); + } + + private void buildWorkIndex(Map workMap, String[][] workMinsAcrossArr, + List allAcrossWorkTime, List allWorkTime, List allLongWorkTime, + int index, KQTimesArrayComInfo kqTimesArrayComInfo, + List allWorkTimeisAcross){ + + if(workMap == null || workMap.isEmpty()){ + return ; + } + String across = Util.null2String(workMap.get("across")); + String times = Util.null2String(workMap.get("times")); + int mins = Util.getIntValue(Util.null2String(workMap.get("mins")), 0); + int mins_next = Util.getIntValue(Util.null2String(workMap.get("mins_next")), -1); + + if(times.length() == 0){ + return ; + } + + String longtime = times; + + allWorkTime.add(times); + allWorkTimeisAcross.add(across); + if("1".equalsIgnoreCase(across)){ + allAcrossWorkTime.add(times); + longtime = kqTimesArrayComInfo.turn24to48Time(times); + } + allLongWorkTime.add(longtime); + if(index ==0){ + //上班时间打卡区间 + if(workMinsAcrossArr != null){ + workMinsAcrossArr[index][0] = ""+mins; + workMinsAcrossArr[index][1] = ""+mins_next; + } + }else{ + //下班时间打卡区间 + if(workMinsAcrossArr != null){ + workMinsAcrossArr[index][0] = ""+mins_next; + workMinsAcrossArr[index][1] = ""+mins; + } + } + } + + /** + * 处理休息时间 + */ + public void setRestDuration(List restTimes,ShiftInfoCominfoBean shiftInfoCominfoBean) throws Exception { + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + + List allRestTime = shiftInfoCominfoBean.getAllRestTime(); + List allAcrossRestTime = shiftInfoCominfoBean.getAllAcrossRestTime(); + + List preRestTime = shiftInfoCominfoBean.getPreRestTime(); + List restTime = shiftInfoCominfoBean.getRestTime(); + List restAcrossTime = shiftInfoCominfoBean.getRestAcrossTime(); + + List preRestTimeIndex = shiftInfoCominfoBean.getPreRestTimeIndex(); + List restTimeIndex = shiftInfoCominfoBean.getRestTimeIndex(); + List restAcrossTimeIndex = shiftInfoCominfoBean.getRestAcrossTimeIndex(); + + List> restAcrossLongTime = shiftInfoCominfoBean.getRestAcrossLongTime(); + List restLongTimeIndex = shiftInfoCominfoBean.getRestLongTimeIndex(); + + if (restTimes != null && !restTimes.isEmpty()) { + for(int k = 0 ; k < restTimes.size() ; k++){ + List sectionList = (List)restTimes.get(k); + if(sectionList == null || sectionList.isEmpty()){ + break; + } + if(sectionList.size() == 2) { + Map restMap0 = (Map) sectionList.get(0); + buildRestIndex(restMap0,allAcrossRestTime,allRestTime,0); + Map restMap1 = (Map) sectionList.get(1); + buildRestIndex(restMap1,allAcrossRestTime,allRestTime,1); + } + } + } + + for(int i = 0 ; i < allRestTime.size() ; ){ + + String[] preRestArr = new String[2]; + String[] restkArr = new String[2]; + String[] restAcrossArr = new String[2]; + + int[] preRestArrIndex = new int[2]; + int[] restkArrIndex = new int[2]; + int[] restAcrossArrIndex = new int[2]; + int[] restLongArrIndex = new int[2]; + if(allRestTime.size() % 2 != 0){ + break; + } + + String onRestTime = Util.null2String(allRestTime.get(i)); + String offRestTime = Util.null2String(allRestTime.get(i+1)); + + if(!allAcrossRestTime.isEmpty()){ + + //休息时段跨天只有两种可能 (休息开始时间不跨天,结束时间跨天)和(休息开始和结束时间都跨天) + if(!allAcrossRestTime.contains(onRestTime) && allAcrossRestTime.contains(offRestTime)){ +// 这是休息开始时间不跨天,结束时间跨天 + preRestArr[0] = "00:00"; + preRestArr[1] = offRestTime; + preRestTime.add(preRestArr); + + preRestArrIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes("00:00"); + preRestArrIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(offRestTime); + preRestTimeIndex.add(preRestArrIndex); + + restkArr[0] = onRestTime; + restkArr[1] = "24:00"; + restTime.add(restkArr); + + restkArrIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(onRestTime); + restkArrIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes("24:00"); + restTimeIndex.add(restkArrIndex); + + restAcrossArr[0] = onRestTime; + restAcrossArr[1] = offRestTime; + restAcrossTime.add(restAcrossArr); + + restAcrossArrIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(onRestTime); + restAcrossArrIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(offRestTime); + restAcrossTimeIndex.add(restAcrossArrIndex); + + String longofftime = offRestTime; + String[] strTimes = offRestTime.split(":"); + String strTimesHead = ""+(Integer.valueOf(strTimes[0])+24); + String strTimesBody = strTimes[1]; + longofftime = strTimesHead+":"+strTimesBody; + + Map longTimeMap = new HashMap<>(); + longTimeMap.put("bengintime", onRestTime); + longTimeMap.put("endtime", longofftime); + longTimeMap.put("bengintime_across", "0"); + longTimeMap.put("endtime_across", "1"); + restAcrossLongTime.add(longTimeMap); + + restLongArrIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(onRestTime); + restLongArrIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(longofftime); + restLongTimeIndex.add(restLongArrIndex); + + }else if(allAcrossRestTime.contains(onRestTime) && allAcrossRestTime.contains(offRestTime)){ +// 这是休息开始和结束时间都是跨天的 + preRestArr[0] = onRestTime; + preRestArr[1] = offRestTime; + preRestTime.add(preRestArr); + + preRestArrIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(onRestTime); + preRestArrIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(offRestTime); + preRestTimeIndex.add(preRestArrIndex); + + restAcrossArr[0] = onRestTime; + restAcrossArr[1] = offRestTime; + restAcrossTime.add(restAcrossArr); + + restAcrossArrIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(onRestTime); + restAcrossArrIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(offRestTime); + restAcrossTimeIndex.add(restAcrossArrIndex); + + String longontime = onRestTime; + String[] onstrTimes = onRestTime.split(":"); + String onstrTimesHead = ""+(Integer.valueOf(onstrTimes[0])+24); + String onstrTimesBody = onstrTimes[1]; + longontime = onstrTimesHead+":"+onstrTimesBody; + + String longofftime = offRestTime; + String[] offstrTimes = offRestTime.split(":"); + String offstrTimesHead = ""+(Integer.valueOf(offstrTimes[0])+24); + String pffstrTimesBody = offstrTimes[1]; + longofftime = offstrTimesHead+":"+pffstrTimesBody; + + Map longTimeMap = new HashMap<>(); + longTimeMap.put("bengintime", longontime); + longTimeMap.put("endtime", longofftime); + longTimeMap.put("bengintime_across", "1"); + longTimeMap.put("endtime_across", "1"); + restAcrossLongTime.add(longTimeMap); + + restLongArrIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(longontime); + restLongArrIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(longofftime); + restLongTimeIndex.add(restLongArrIndex); + }else{ + + //如果没有跨天 + restkArr[0] = onRestTime; + restkArr[1] = offRestTime; + restTime.add(restkArr); + + restkArrIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(onRestTime); + restkArrIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(offRestTime); + restTimeIndex.add(restkArrIndex); + + restAcrossArr[0] = onRestTime; + restAcrossArr[1] = offRestTime; + restAcrossTime.add(restAcrossArr); + + restAcrossArrIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(onRestTime); + restAcrossArrIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(offRestTime); + restAcrossTimeIndex.add(restAcrossArrIndex); + + Map longTimeMap = new HashMap<>(); + longTimeMap.put("bengintime", onRestTime); + longTimeMap.put("endtime", offRestTime); + longTimeMap.put("bengintime_across", "0"); + longTimeMap.put("endtime_across", "0"); + restAcrossLongTime.add(longTimeMap); + + restLongArrIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(onRestTime); + restLongArrIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(offRestTime); + restLongTimeIndex.add(restLongArrIndex); + } + }else{ + + //如果没有跨天 + restkArr[0] = onRestTime; + restkArr[1] = offRestTime; + restTime.add(restkArr); + + restkArrIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(onRestTime); + restkArrIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(offRestTime); + restTimeIndex.add(restkArrIndex); + + restAcrossArr[0] = onRestTime; + restAcrossArr[1] = offRestTime; + restAcrossTime.add(restAcrossArr); + + restAcrossArrIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(onRestTime); + restAcrossArrIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(offRestTime); + restAcrossTimeIndex.add(restAcrossArrIndex); + + Map longTimeMap = new HashMap<>(); + longTimeMap.put("bengintime", onRestTime); + longTimeMap.put("endtime", offRestTime); + longTimeMap.put("bengintime_across", "0"); + longTimeMap.put("endtime_across", "0"); + restAcrossLongTime.add(longTimeMap); + + restLongArrIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(onRestTime); + restLongArrIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(offRestTime); + restLongTimeIndex.add(restLongArrIndex); + } + + i = i + 2; + } + } + + private void buildRestIndex(Map restMap,List allAcrossRestTime,List allRestTime,int index){ + + if(restMap == null || restMap.isEmpty()){ + return ; + } + String across = Util.null2String(restMap.get("across")); + String times = Util.null2String(restMap.get("times")); + + if(times.length() == 0){ + return ; + } + + if("1".equalsIgnoreCase(across)){ + allAcrossRestTime.add(times); + } + allRestTime.add(times); + } + +} diff --git a/src/com/engine/kq/biz/chain/cominfo/ShiftInfoCominfoBean.java b/src/com/engine/kq/biz/chain/cominfo/ShiftInfoCominfoBean.java new file mode 100644 index 0000000..12ee6bb --- /dev/null +++ b/src/com/engine/kq/biz/chain/cominfo/ShiftInfoCominfoBean.java @@ -0,0 +1,521 @@ +package com.engine.kq.biz.chain.cominfo; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + */ +public class ShiftInfoCominfoBean implements Serializable { + + + private static final long serialVersionUID = -1735765502081116461L; + + /** + * 当前班次如果是作为前一个班次存在,跨到次日的工作时段 + */ + private List preWorkTime; + + /** + * 当前班次作为当前班次存在,在0-24小时内的工作时段 + */ + private List workTime; + + /** + * 当前班次作为当前班次存在,如果存在跨天的话,包含跨天的工作时段,显示成0-24小时的 + */ + private List workAcrossTime; + + + /** + * 当前班次如果是作为前一个班次存在,跨到次日的工作时段 + */ + private List preWorkTimeIndex; + + /** + * 当前班次作为当前班次存在,在0-24小时内的工作时段 + */ + private List workTimeIndex; + + /** + * 当前班次作为当前班次存在,在0-48小时内的工作时段下标 + */ + private List workLongTimeIndex; + + /** + * 当前班次作为当前班次存在,在0-48小时内的工作时段下标 + */ + private List restLongTimeIndex; + + /** + * 存储所有的工作时间 48小时制休息时段 + */ + private List allLongWorkTime; + + /** + * 当前班次作为当前班次存在,如果存在跨天的话,包含跨天的工作时段,显示成0-24小时的 + */ + private List workAcrossTimeIndex; + + /** + * 考勤报表用的 48小时制工作时段 + */ + private List> workAcrossLongTime; + + /** + * 当天打卡时段时间:多少分钟可以开始签到签退的 + */ + private List workPunchMins; + + /** + * 当前班次如果是作为前一个班次存在,跨到次日的休息时段 + */ + private List preRestTime; + + /** + * 当前班次作为当前班次存在,在0-24小时内的休息时段 + */ + private List restTime; + + /** + * 当前班次作为当前班次存在,如果存在跨r天的话,包含跨天的休息时段,显示成0-24小时的 + */ + private List restAcrossTime; + /** + * 当前班次如果是作为前一个班次存在,跨到次日的休息时段 + */ + private List preRestTimeIndex; + + /** + * 当前班次作为当前班次存在,在0-24小时内的休息时段 + */ + private List restTimeIndex; + + /** + * 当前班次作为当前班次存在,如果存在跨r天的话,包含跨天的休息时段,显示成0-24小时的 + */ + private List restAcrossTimeIndex; + + /** + * 考勤报表用的 48小时制休息时段 + */ + private List> restAcrossLongTime; + + /** + * 要返回的半天规则时间区间对应的数组下标 + * 这里有值的话是三个,最早的开始时间 中间时间 最晚的下班时间 + */ + private List halfWorkTime; + + /** + * 要返回的半天规则时间区间对应的数组下标 + * 这里有值的话是三个,最早的开始时间 中间时间 最晚的下班时间 + */ + private List halfWorkIndex; + + /** + * 存储所有的工作时间 + */ + private List allWorkTime; + + /** + * 存储所有的跨天时间 + */ + private List allAcrossWorkTime; + /** + * 存储所有的休息时间 + */ + private List allRestTime; + + /** + * 存储所有的休息时间 + */ + private List allAcrossRestTime; + + /** + * 存储每一段工作时段内的工作时长 + */ + private List eachWorkMins; + + /** + * 工作时长 + */ + private int workmins; + + /** + * 当前日期的班次 + */ + private String serialid; + + /** + * 判断当前班次是否存在跨天 + */ + private String isAcross; + + /** + * 半天计算规则 + */ + private String halfcalrule; + + /** + * 自定义 半天计算规则 时间点 + */ + private String halfcalpoint; + + private String halfcalpoint2cross; + + private List timelineList; + + /** + * 允许签到签退的时段范围 + */ + private List> signWorkTime; + + /** + * 存储所有的工作时间是否跨天 和allWorkTime对应 + */ + private List allWorkTimeisAcross; + + private String uuid = ""; + + /** + * 应出勤折算天数 + */ + private String convertAttendDay = ""; + + public ShiftInfoCominfoBean() { + + this.preWorkTime = new ArrayList<>(); + this.workTime = new ArrayList<>(); + this.workAcrossTime = new ArrayList<>(); + this.preWorkTimeIndex = new ArrayList<>(); + this.workTimeIndex = new ArrayList<>(); + this.workAcrossTimeIndex = new ArrayList<>(); + this.workAcrossLongTime = new ArrayList<>(); + this.workPunchMins = new ArrayList<>(); + this.preRestTime = new ArrayList<>(); + this.restTime = new ArrayList<>(); + this.restAcrossTime = new ArrayList<>(); + this.preRestTimeIndex = new ArrayList<>(); + this.restTimeIndex = new ArrayList<>(); + this.restAcrossTimeIndex = new ArrayList<>(); + this.restAcrossLongTime = new ArrayList<>(); + this.halfWorkTime = new ArrayList<>(); + this.allWorkTime = new ArrayList<>(); + this.allAcrossWorkTime = new ArrayList<>(); + this.allRestTime = new ArrayList<>(); + this.allAcrossRestTime = new ArrayList<>(); + this.eachWorkMins = new ArrayList<>(); + this.workmins = 0; + this.serialid = ""; + this.isAcross = "0"; + this.halfcalrule = "0"; + this.halfWorkIndex = new ArrayList<>(); + + this.timelineList = new ArrayList<>(); + + this.workLongTimeIndex = new ArrayList<>(); + this.restLongTimeIndex = new ArrayList<>(); + this.allLongWorkTime = new ArrayList<>(); + this.signWorkTime = new ArrayList<>(); + this.allWorkTimeisAcross = new ArrayList<>(); + this.uuid = UUID.randomUUID().toString(); + this.halfcalpoint = "0"; + this.halfcalpoint2cross = "0"; + } + + public List getPreWorkTime() { + return preWorkTime; + } + + public void setPreWorkTime(List preWorkTime) { + this.preWorkTime = preWorkTime; + } + + public List getWorkTime() { + return workTime; + } + + public void setWorkTime(List workTime) { + this.workTime = workTime; + } + + public List getWorkAcrossTime() { + return workAcrossTime; + } + + public void setWorkAcrossTime(List workAcrossTime) { + this.workAcrossTime = workAcrossTime; + } + + public List> getWorkAcrossLongTime() { + return workAcrossLongTime; + } + + public void setWorkAcrossLongTime( + List> workAcrossLongTime) { + this.workAcrossLongTime = workAcrossLongTime; + } + + public List getWorkPunchMins() { + return workPunchMins; + } + + public void setWorkPunchMins(List workPunchMins) { + this.workPunchMins = workPunchMins; + } + + public List getHalfWorkTime() { + return halfWorkTime; + } + + public void setHalfWorkTime(List halfWorkTime) { + this.halfWorkTime = halfWorkTime; + } + + public int getWorkmins() { + return workmins; + } + + public void setWorkmins(int workmins) { + this.workmins = workmins; + } + + public String getSerialid() { + return serialid; + } + + public void setSerialid(String serialid) { + this.serialid = serialid; + } + + public List getAllWorkTime() { + return allWorkTime; + } + + public void setAllWorkTime(List allWorkTime) { + this.allWorkTime = allWorkTime; + } + + public List getAllAcrossWorkTime() { + return allAcrossWorkTime; + } + + public void setAllAcrossWorkTime(List allAcrossWorkTime) { + this.allAcrossWorkTime = allAcrossWorkTime; + } + + public List getRestTime() { + return restTime; + } + + public void setRestTime(List restTime) { + this.restTime = restTime; + } + + public String getIsAcross() { + return isAcross; + } + + public void setIsAcross(String isAcross) { + this.isAcross = isAcross; + } + + public List getPreRestTime() { + return preRestTime; + } + + public void setPreRestTime(List preRestTime) { + this.preRestTime = preRestTime; + } + + public List getRestAcrossTime() { + return restAcrossTime; + } + + public void setRestAcrossTime(List restAcrossTime) { + this.restAcrossTime = restAcrossTime; + } + + public List> getRestAcrossLongTime() { + return restAcrossLongTime; + } + + public void setRestAcrossLongTime( + List> restAcrossLongTime) { + this.restAcrossLongTime = restAcrossLongTime; + } + + public List getAllRestTime() { + return allRestTime; + } + + public void setAllRestTime(List allRestTime) { + this.allRestTime = allRestTime; + } + + public List getAllAcrossRestTime() { + return allAcrossRestTime; + } + + public void setAllAcrossRestTime(List allAcrossRestTime) { + this.allAcrossRestTime = allAcrossRestTime; + } + + public List getEachWorkMins() { + return eachWorkMins; + } + + public void setEachWorkMins(List eachWorkMins) { + this.eachWorkMins = eachWorkMins; + } + + public List getPreWorkTimeIndex() { + return preWorkTimeIndex; + } + + public void setPreWorkTimeIndex(List preWorkTimeIndex) { + this.preWorkTimeIndex = preWorkTimeIndex; + } + + public List getWorkTimeIndex() { + return workTimeIndex; + } + + public void setWorkTimeIndex(List workTimeIndex) { + this.workTimeIndex = workTimeIndex; + } + + public List getWorkAcrossTimeIndex() { + return workAcrossTimeIndex; + } + + public void setWorkAcrossTimeIndex(List workAcrossTimeIndex) { + this.workAcrossTimeIndex = workAcrossTimeIndex; + } + + public List getPreRestTimeIndex() { + return preRestTimeIndex; + } + + public void setPreRestTimeIndex(List preRestTimeIndex) { + this.preRestTimeIndex = preRestTimeIndex; + } + + public List getRestTimeIndex() { + return restTimeIndex; + } + + public void setRestTimeIndex(List restTimeIndex) { + this.restTimeIndex = restTimeIndex; + } + + public List getRestAcrossTimeIndex() { + return restAcrossTimeIndex; + } + + public void setRestAcrossTimeIndex(List restAcrossTimeIndex) { + this.restAcrossTimeIndex = restAcrossTimeIndex; + } + + public List getHalfWorkIndex() { + return halfWorkIndex; + } + + public void setHalfWorkIndex(List halfWorkIndex) { + this.halfWorkIndex = halfWorkIndex; + } + + public List getTimelineList() { + return timelineList; + } + + public void setTimelineList(List timelineList) { + this.timelineList = timelineList; + } + + public List getWorkLongTimeIndex() { + return workLongTimeIndex; + } + + public void setWorkLongTimeIndex(List workLongTimeIndex) { + this.workLongTimeIndex = workLongTimeIndex; + } + + public List getRestLongTimeIndex() { + return restLongTimeIndex; + } + + public void setRestLongTimeIndex(List restLongTimeIndex) { + this.restLongTimeIndex = restLongTimeIndex; + } + + public List getAllLongWorkTime() { + return allLongWorkTime; + } + + public void setAllLongWorkTime(List allLongWorkTime) { + this.allLongWorkTime = allLongWorkTime; + } + + public List> getSignWorkTime() { + return signWorkTime; + } + + public void setSignWorkTime( + List> signWorkTime) { + this.signWorkTime = signWorkTime; + } + + public List getAllWorkTimeisAcross() { + return allWorkTimeisAcross; + } + + public void setAllWorkTimeisAcross(List allWorkTimeisAcross) { + this.allWorkTimeisAcross = allWorkTimeisAcross; + } + + public String getHalfcalrule() { + return halfcalrule; + } + + public void setHalfcalrule(String halfcalrule) { + this.halfcalrule = halfcalrule; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getHalfcalpoint() { + return halfcalpoint; + } + + public void setHalfcalpoint(String halfcalpoint) { + this.halfcalpoint = halfcalpoint; + } + + public String getHalfcalpoint2cross() { + return halfcalpoint2cross; + } + + public void setHalfcalpoint2cross(String halfcalpoint2cross) { + this.halfcalpoint2cross = halfcalpoint2cross; + } + + public String getConvertAttendDay() { + return convertAttendDay; + } + + public void setConvertAttendDay(String convertAttendDay) { + this.convertAttendDay = convertAttendDay; + } +} + diff --git a/src/com/engine/kq/biz/chain/cominfo/WorkShiftComIndex.java b/src/com/engine/kq/biz/chain/cominfo/WorkShiftComIndex.java new file mode 100644 index 0000000..679f909 --- /dev/null +++ b/src/com/engine/kq/biz/chain/cominfo/WorkShiftComIndex.java @@ -0,0 +1,37 @@ +package com.engine.kq.biz.chain.cominfo; + +import com.engine.kq.biz.KQTimesArrayComInfo; +import java.util.List; +import java.util.Map; +import weaver.general.Util; + +/** + * 规则时段计算规则 + */ +public class WorkShiftComIndex extends ShiftComIndex { + + public WorkShiftComIndex(String name,Map workTimeMap){ + super(name,workTimeMap); + } + + @Override + public void handleDuration(ShiftInfoCominfoBean shiftInfoCominfoBean) throws Exception { + + handleWorkTime(shiftInfoCominfoBean); + this.success.handleDuration(shiftInfoCominfoBean); + } + + private void handleWorkTime(ShiftInfoCominfoBean shiftInfoCominfoBean) throws Exception { + List workTimes = (List)workTimeMap.get("workTime"); + int workmins = Util.getIntValue(Util.null2String(workTimeMap.get("workmins"))); + String convertAttendDay = Util.null2s(Util.null2String(workTimeMap.get("convertAttendDay")),"1.0"); + shiftInfoCominfoBean.setWorkmins(workmins); + String serialid = Util.null2String(workTimeMap.get("serialid")); + shiftInfoCominfoBean.setSerialid(serialid); + shiftInfoCominfoBean.setConvertAttendDay(convertAttendDay); + + setWorkDuration(workTimes, shiftInfoCominfoBean); + + } + +} diff --git a/src/com/engine/kq/biz/chain/duration/NonDayUnitSplitChain.java b/src/com/engine/kq/biz/chain/duration/NonDayUnitSplitChain.java new file mode 100644 index 0000000..fdc2f3a --- /dev/null +++ b/src/com/engine/kq/biz/chain/duration/NonDayUnitSplitChain.java @@ -0,0 +1,30 @@ +package com.engine.kq.biz.chain.duration; + +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.SplitActionUtil; +import java.util.List; + +/** + * 非工作时长 按天计算 + */ +public class NonDayUnitSplitChain extends NonWorkDurationChain { + + + public NonDayUnitSplitChain(List splitBeans) { + super(splitBeans); + } + + @Override + public void handleDuration(SplitBean splitBean) throws Exception{ + String durationrule = splitBean.getDurationrule(); + if("1".equalsIgnoreCase(durationrule)){ + getSplitDurationBean(splitBean); + if(!splitBeans.isEmpty()){ + SplitActionUtil.turnOvertimeBeansWithRule(splitBeans); + } + }else{ + this.success.handleDuration(splitBean); + } + } + +} diff --git a/src/com/engine/kq/biz/chain/duration/NonHalfUnitSplitChain.java b/src/com/engine/kq/biz/chain/duration/NonHalfUnitSplitChain.java new file mode 100644 index 0000000..c2e9088 --- /dev/null +++ b/src/com/engine/kq/biz/chain/duration/NonHalfUnitSplitChain.java @@ -0,0 +1,165 @@ +package com.engine.kq.biz.chain.duration; + +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.engine.kq.wfset.util.SplitSelectSet; +import java.util.List; +import java.util.Map; +import org.springframework.beans.BeanUtils; +import weaver.general.BaseBean; +import weaver.general.Util; + +/** + * 非工作时长 按半天计算 + */ +public class NonHalfUnitSplitChain extends NonWorkDurationChain { + + /** + * 半天规则下 上午-上午 + */ + public static final int fore_fore_index = 0; + + /** + * 半天规则下 上午-下午 + */ + public static final int fore_after_index = 1; + + /** + * 半天规则下 下午-上午 + */ + public static final int after_fore_index = 2; + + /** + * 半天规则下 下午-下午 + */ + public static final int after_after_index = 3; + + + public NonHalfUnitSplitChain(List splitBeans) { + super(splitBeans); + } + + @Override + public void handleDuration(SplitBean splitBean) throws Exception{ + String durationrule = splitBean.getDurationrule(); + if("2".equalsIgnoreCase(durationrule)){ + getSplitDurationBean(splitBean); + if(!splitBeans.isEmpty()){ + SplitActionUtil.turnOvertimeBeansWithRule(splitBeans); + } + }else{ + this.success.handleDuration(splitBean); + } + } + + @Override + public void getSplitDurationBean(SplitBean splitBean){ + + String resourceid = splitBean.getResourceId(); + String fromDate = splitBean.getFromdatedb(); + String toDate = splitBean.getTodatedb(); + String fromTime = splitBean.getFromtimedb(); + String toTime = splitBean.getTotimedb(); + + if(!(fromTime.equalsIgnoreCase(SplitSelectSet.forenoon_start) || fromTime.equalsIgnoreCase(SplitSelectSet.forenoon_end))){ + return; + } + if(!(toTime.equalsIgnoreCase(SplitSelectSet.afternoon_start) || toTime.equalsIgnoreCase(SplitSelectSet.afternoon_end))){ + return; + } + //获取对应人员和对应日期下的工作时段 + List> splitLists = SplitActionUtil.getSplitHalfDayList(fromDate,toDate,fromTime,toTime); + double hoursToDay = KQOvertimeRulesBiz.getHoursToDay(); + int workmins = (int)(hoursToDay * 60); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + + if(!splitLists.isEmpty()) { + for (int i = 0; i < splitLists.size(); i++) { + Map splitMap = splitLists.get(i); + String splitDate = Util.null2String(splitMap.get("splitDate")); + int foreOrAfter = Util.getIntValue(Util.null2String(splitMap.get("foreOrAfter"))); + + int overtimeEnable = KQOvertimeRulesBiz.getOvertimeEnable(resourceid, splitDate); + String groupId = kqGroupMemberComInfo.getKQGroupId(resourceid, splitDate); + + //如果人再当前指定日期下未开启加班,直接跳过 + if(overtimeEnable != 1){ + kqLog.info("getOvertimeEnable:resourceid:"+resourceid+":splitDate:"+splitDate+"不允许加班"); + continue; + } + + int changeType = KQOvertimeRulesBiz.getChangeType(resourceid, splitDate); + int computingMode = KQOvertimeRulesBiz.getComputingMode(resourceid, splitDate); + if(computingMode == 3){ +// 无需审批,根据打卡时间计算加班时长 + continue; + } + + String splitFromTime = ""; + String splitToTime = ""; + String duration = ""; + boolean isRightTime = true; + switch (foreOrAfter){ + case NonHalfUnitSplitChain.fore_fore_index: + splitFromTime = SplitSelectSet.forenoon_start; + splitToTime = SplitSelectSet.forenoon_end; + duration = "0.5"; + break; + case NonHalfUnitSplitChain.fore_after_index: + splitFromTime = SplitSelectSet.forenoon_start; + splitToTime = SplitSelectSet.afternoon_end; + duration = "1.0"; + break; + case NonHalfUnitSplitChain.after_fore_index: + break; + case NonHalfUnitSplitChain.after_after_index: + splitFromTime = SplitSelectSet.forenoon_end; + splitToTime = SplitSelectSet.afternoon_end; + duration = "0.5"; + break; + default: + isRightTime = false; + break; + } + if(!isRightTime){ + continue; + } + splitBean.setFromTime(splitFromTime); + splitBean.setToTime(splitToTime); + splitBean.setDuration(duration); + splitBean.setOneDayHour(hoursToDay); + splitBean.setWorkmins(workmins); + splitBean.setBelongDate(splitDate); + splitBean.setFromDate(splitDate); + splitBean.setToDate(splitDate); + splitBean.setComputingMode(computingMode+""); + splitBean.setGroupid(groupId); + double d_mins = Util.getDoubleValue(splitBean.getDuration())*splitBean.getWorkmins(); + splitBean.setD_Mins(d_mins); + +// 1-节假日、2-工作日、3-休息日 + if(changeType == 1){ + splitBean.setChangeType(1); + splitBean.setPub_duration(duration); + } + + if(changeType == 2){ + splitBean.setChangeType(2); + splitBean.setWork_duration(duration); + } + + if(changeType == 3){ + splitBean.setChangeType(3); + splitBean.setRest_duration(duration); + } + //然后把bean重新赋值下,根据拆分后的时间 + SplitBean newsplitBean = new SplitBean(); + BeanUtils.copyProperties(splitBean, newsplitBean); + splitBeans.add(newsplitBean); + } + } + } + +} diff --git a/src/com/engine/kq/biz/chain/duration/NonHourUnitSplitChain.java b/src/com/engine/kq/biz/chain/duration/NonHourUnitSplitChain.java new file mode 100644 index 0000000..b334a7d --- /dev/null +++ b/src/com/engine/kq/biz/chain/duration/NonHourUnitSplitChain.java @@ -0,0 +1,31 @@ +package com.engine.kq.biz.chain.duration; + +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.SplitActionUtil; +import java.util.List; + +/** + * 非工作时长 按小时计算 + */ +public class NonHourUnitSplitChain extends NonWorkDurationChain { + + + public NonHourUnitSplitChain(List splitBeans) { + super(splitBeans); + } + + @Override + public void handleDuration(SplitBean splitBean) throws Exception{ + String durationrule = splitBean.getDurationrule(); + if("3".equalsIgnoreCase(durationrule) || "5".equalsIgnoreCase(durationrule) + || "6".equalsIgnoreCase(durationrule)){ + getSplitDurationBean(splitBean); + if(!splitBeans.isEmpty()){ + SplitActionUtil.turnOvertimeBeansWithRule(splitBeans); + } + }else{ + this.success.handleDuration(splitBean); + } + } + +} diff --git a/src/com/engine/kq/biz/chain/duration/NonWholeUnitSplitChain.java b/src/com/engine/kq/biz/chain/duration/NonWholeUnitSplitChain.java new file mode 100644 index 0000000..882b6a4 --- /dev/null +++ b/src/com/engine/kq/biz/chain/duration/NonWholeUnitSplitChain.java @@ -0,0 +1,119 @@ +package com.engine.kq.biz.chain.duration; + +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.engine.kq.wfset.util.SplitSelectSet; +import java.util.List; +import java.util.Map; +import org.springframework.beans.BeanUtils; +import weaver.general.BaseBean; +import weaver.general.Util; + +/** + * 非工作时长 按整天计算 + */ +public class NonWholeUnitSplitChain extends NonWorkDurationChain { + + /** + * 全天规则 下拉框对应的开始时间 + */ + public static final String daylong_start = "08:00"; + + /** + * 全天规则 下拉框对应的结束时间 + */ + public static final String daylong_end = "18:00"; + + public NonWholeUnitSplitChain(List splitBeans) { + super(splitBeans); + } + + @Override + public void handleDuration(SplitBean splitBean) throws Exception{ + String durationrule = splitBean.getDurationrule(); + if("4".equalsIgnoreCase(durationrule)){ + getSplitDurationBean(splitBean); + if(!splitBeans.isEmpty()){ + SplitActionUtil.turnOvertimeBeansWithRule(splitBeans); + } + } + } + + @Override + public void getSplitDurationBean(SplitBean splitBean) { + + String resourceid = splitBean.getResourceId(); + String fromDate = splitBean.getFromdatedb(); + String toDate = splitBean.getTodatedb(); + String fromTime = splitBean.getFromtimedb(); + String toTime = splitBean.getTotimedb(); + if(!(fromTime.equalsIgnoreCase(SplitSelectSet.daylong_start))){ + return; + } + if(!(toTime.equalsIgnoreCase(SplitSelectSet.daylong_end))){ + return; + } + + //获取对应人员和对应日期下的工作时段 + List> splitLists = SplitActionUtil.getSplitDayList(fromDate,toDate); + double hoursToDay = KQOvertimeRulesBiz.getHoursToDay(); + int workmins = (int)(hoursToDay * 60); + + if(!splitLists.isEmpty()) { + for (int i = 0; i < splitLists.size(); i++) { + Map splitMap = splitLists.get(i); + String splitDate = Util.null2String(splitMap.get("splitDate")); + + int overtimeEnable = KQOvertimeRulesBiz.getOvertimeEnable(resourceid, splitDate); + + //如果人再当前指定日期下未开启加班,直接跳过 + if(overtimeEnable != 1){ + kqLog.info("getOvertimeEnable:resourceid:"+resourceid+":splitDate:"+splitDate+"不允许加班"); + continue; + } + + int changeType = KQOvertimeRulesBiz.getChangeType(resourceid, splitDate); + int computingMode = KQOvertimeRulesBiz.getComputingMode(resourceid, splitDate); + if(computingMode == 3){ +// 无需审批,根据打卡时间计算加班时长 + continue; + } + + String duration = "1.0"; + + splitBean.setFromTime(daylong_start); + splitBean.setToTime(daylong_end); + splitBean.setDuration(duration); + splitBean.setOneDayHour(hoursToDay); + splitBean.setWorkmins(workmins); + splitBean.setBelongDate(splitDate); + splitBean.setFromDate(splitDate); + splitBean.setToDate(splitDate); + splitBean.setComputingMode(computingMode+""); + double d_mins = Util.getDoubleValue(splitBean.getDuration())*splitBean.getWorkmins(); + splitBean.setD_Mins(d_mins); + +// 1-节假日、2-工作日、3-休息日 + if(changeType == 1){ + splitBean.setChangeType(1); + } + + if(changeType == 2){ + splitBean.setChangeType(2); + } + + if(changeType == 3){ + splitBean.setChangeType(3); + } + //然后把bean重新赋值下,根据拆分后的时间 + SplitBean newsplitBean = new SplitBean(); + BeanUtils.copyProperties(splitBean, newsplitBean); + if(duration.length() > 0 && Util.getDoubleValue(duration) > -1){ + splitBeans.add(newsplitBean); + } + } + } + } + +} diff --git a/src/com/engine/kq/biz/chain/duration/NonWorkDurationChain.java b/src/com/engine/kq/biz/chain/duration/NonWorkDurationChain.java new file mode 100644 index 0000000..69bdf72 --- /dev/null +++ b/src/com/engine/kq/biz/chain/duration/NonWorkDurationChain.java @@ -0,0 +1,149 @@ +package com.engine.kq.biz.chain.duration; + +import com.engine.kq.biz.KQOverTimeFlowBiz; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.chain.overtime.OvertimeChain; +import com.engine.kq.biz.chain.overtime.OvertimeHoliday2HolidayChain; +import com.engine.kq.biz.chain.overtime.OvertimeHoliday2RestdayChain; +import com.engine.kq.biz.chain.overtime.OvertimeHoliday2WorkdayChain; +import com.engine.kq.biz.chain.overtime.OvertimeRestday2HolidayChain; +import com.engine.kq.biz.chain.overtime.OvertimeRestday2RestdayChain; +import com.engine.kq.biz.chain.overtime.OvertimeRestday2WorkdayChain; +import com.engine.kq.biz.chain.overtime.OvertimeWorkday2HolidayChain; +import com.engine.kq.biz.chain.overtime.OvertimeWorkday2RestdayChain; +import com.engine.kq.biz.chain.overtime.OvertimeWorkday2WorkdayChain; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.KQFlowUtil; +import com.engine.kq.wfset.util.SplitActionUtil; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Map; +import org.springframework.beans.BeanUtils; +import weaver.general.Util; + +/** + * 非工作时长 计算 + */ +public abstract class NonWorkDurationChain { + + protected NonWorkDurationChain success; //定义下一个处理对象 + protected List splitBeans; + protected KQLog kqLog = new KQLog(); + + public NonWorkDurationChain(List splitBeans) { + this.splitBeans = splitBeans; + } + //创建链 + public void setDurationChain(NonWorkDurationChain durationIndex) { + this.success=durationIndex; + } + + public abstract void handleDuration(SplitBean splitBean) throws Exception; + + /** + * 这个是流程上使用的,当流程拆分了之后,每一天的日期和时间传过来 + * 需要根据这些条件和请假,出差的半全天的规则给开始时间和结束时间重新赋值 + * 在这里获取到bean从splitBean里拿到需要的开始时间和结束时间 + * @return + */ + public void getSplitDurationBean(SplitBean splitBean) throws Exception{ + try{ + if(true){ + KQOverTimeFlowBiz kqNonWorkDurationBiz = new KQOverTimeFlowBiz(); + kqNonWorkDurationBiz.getSplitDurationBean_new(splitBean,splitBeans); + }else{ + getSplitDurationBean_old(splitBean); + } + }catch (Exception e){ + KQLog kqLog = new KQLog(); + kqLog.info("WorkDurationChain:getSplitDurationBean:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + e.printStackTrace(); + throw new Exception("NonWorkDurationChain 报错异常:"+e.getMessage()); + } + } + + public void getSplitDurationBean_old(SplitBean splitBean) throws Exception{ + + String resourceid = splitBean.getResourceId(); + String fromDate = splitBean.getFromdatedb(); + String toDate = splitBean.getTodatedb(); + String fromTime = splitBean.getFromtimedb(); + String toTime = splitBean.getTotimedb(); + + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + double oneDayHour = KQFlowUtil.getOneDayHour(splitBean.getDurationTypeEnum(),""); + int workmins = (int)(oneDayHour * 60); + + //获取对应人员和对应日期下的工作时段 + List> splitLists = SplitActionUtil.getSplitList(fromDate,toDate,fromTime,toTime); + + if(!splitLists.isEmpty()) { + int splitCount = splitLists.size(); + for (int i = 0; i < splitCount; i++) { + Map splitMap = splitLists.get(i); + String splitDate = Util.null2String(splitMap.get("splitDate")); + int changeType = KQOvertimeRulesBiz.getChangeType(resourceid, splitDate); + String preSplitDate = LocalDate.parse(splitDate).minusDays(1).format(dateFormatter); + int preChangeType = KQOvertimeRulesBiz.getChangeType(resourceid, preSplitDate); + String splitFromTime = Util.null2String(splitMap.get("fromTime")); + String splitToTime = Util.null2String(splitMap.get("toTime")); + + splitMap.put("preSplitDate", preSplitDate); + + splitBean.setOneDayHour(oneDayHour); + splitBean.setWorkmins(workmins); + kqLog.info("getSplitDurationBean:resourceid:"+resourceid+":preChangeType:"+preChangeType+":changeType:"+changeType); + + //如果是跨天的,而且班次也跨天,流程存在跨天的情况,那么除了第一天,其他的每一天都针对前一天的班次需要多加1分钟 + if(splitCount > 1){ + if(!splitDate.equalsIgnoreCase(toDate)){ + splitMap.put("shouldAcross", "1"); + } + } + splitBean.setFromDate(splitDate); + splitBean.setFromTime(splitFromTime); + splitBean.setToDate(splitDate); + splitBean.setToTime(splitToTime); + splitBean.setBelongDate(splitDate); + splitBean.setChangeType(changeType); + splitBean.setPreChangeType(preChangeType); + + SplitBean overSplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + BeanUtils.copyProperties(splitBean, overSplitBean); + + OvertimeChain holiday2HolidayChain = new OvertimeHoliday2HolidayChain(splitMap,splitBeans); + OvertimeChain holiday2WorkdayChain = new OvertimeHoliday2WorkdayChain(splitMap,splitBeans); + OvertimeChain holiday2RestdayChain = new OvertimeHoliday2RestdayChain(splitMap,splitBeans); + + OvertimeChain workday2HolidayChain = new OvertimeWorkday2HolidayChain(splitMap,splitBeans); + OvertimeChain workday2WorkdayChain = new OvertimeWorkday2WorkdayChain(splitMap,splitBeans); + OvertimeChain workday2RestdayChain = new OvertimeWorkday2RestdayChain(splitMap,splitBeans); + + OvertimeChain restday2HolidayChain = new OvertimeRestday2HolidayChain(splitMap,splitBeans); + OvertimeChain restday2WorkdayChain = new OvertimeRestday2WorkdayChain(splitMap,splitBeans); + OvertimeChain restday2RestdayChain = new OvertimeRestday2RestdayChain(splitMap,splitBeans); + + holiday2HolidayChain.setOvertimeChain(holiday2WorkdayChain); + holiday2WorkdayChain.setOvertimeChain(holiday2RestdayChain); + holiday2RestdayChain.setOvertimeChain(workday2HolidayChain); + workday2HolidayChain.setOvertimeChain(workday2WorkdayChain); + workday2WorkdayChain.setOvertimeChain(workday2RestdayChain); + workday2RestdayChain.setOvertimeChain(restday2HolidayChain); + restday2HolidayChain.setOvertimeChain(restday2WorkdayChain); + restday2WorkdayChain.setOvertimeChain(restday2RestdayChain); + + holiday2HolidayChain.handleOvertimeChain(overSplitBean); + + } + } + } + +} diff --git a/src/com/engine/kq/biz/chain/duration/WorkDayUnitSplitChain.java b/src/com/engine/kq/biz/chain/duration/WorkDayUnitSplitChain.java new file mode 100644 index 0000000..c66c569 --- /dev/null +++ b/src/com/engine/kq/biz/chain/duration/WorkDayUnitSplitChain.java @@ -0,0 +1,26 @@ +package com.engine.kq.biz.chain.duration; + +import com.engine.kq.wfset.bean.SplitBean; +import java.util.List; + +/** + * 工作时长 按天计算 + */ +public class WorkDayUnitSplitChain extends WorkDurationChain { + + + public WorkDayUnitSplitChain(List splitBeans) { + super(splitBeans); + } + + @Override + public void handleDuration(SplitBean splitBean) throws Exception { + String durationrule = splitBean.getDurationrule(); + if("1".equalsIgnoreCase(durationrule)){ + getSplitDurationBean(splitBean); + }else{ + this.success.handleDuration(splitBean); + } + } + +} diff --git a/src/com/engine/kq/biz/chain/duration/WorkDurationChain.java b/src/com/engine/kq/biz/chain/duration/WorkDurationChain.java new file mode 100644 index 0000000..9813f79 --- /dev/null +++ b/src/com/engine/kq/biz/chain/duration/WorkDurationChain.java @@ -0,0 +1,49 @@ +package com.engine.kq.biz.chain.duration; + +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.SplitActionUtil; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.List; + +/** + * 针对流程天数计算的基类 + */ +public abstract class WorkDurationChain { + + protected WorkDurationChain success; //定义下一个处理对象 + protected List splitBeans; + + public WorkDurationChain(List splitBeans) { + this.splitBeans = splitBeans; + } + //创建链 + public void setDurationChain(WorkDurationChain durationIndex) { + this.success=durationIndex; + } + + public abstract void handleDuration(SplitBean splitBean) throws Exception; + + /** + * 这个是流程上使用的,当流程拆分了之后,每一天的日期和时间传过来 + * 需要根据这些条件和请假,出差的半全天的规则给开始时间和结束时间重新赋值 + * 在这里获取到bean从splitBean里拿到需要的开始时间和结束时间 + * @return + */ + public void getSplitDurationBean(SplitBean splitBean) throws Exception { + try { + SplitActionUtil splitActionUtil = new SplitActionUtil(); + splitActionUtil.doSerialSplitList(splitBean, splitBeans); + }catch (Exception e){ + KQLog kqLog = new KQLog(); + kqLog.info("WorkDurationChain:getSplitDurationBean:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + e.printStackTrace(); + throw new Exception("WorkDurationChain 报错异常:"+e.getMessage()); + } + } + +} diff --git a/src/com/engine/kq/biz/chain/duration/WorkHalfUnitSplitChain.java b/src/com/engine/kq/biz/chain/duration/WorkHalfUnitSplitChain.java new file mode 100644 index 0000000..a3dcea6 --- /dev/null +++ b/src/com/engine/kq/biz/chain/duration/WorkHalfUnitSplitChain.java @@ -0,0 +1,472 @@ +package com.engine.kq.biz.chain.duration; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.bean.KQRepeatBean; +import com.engine.kq.biz.*; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.engine.kq.wfset.util.SplitSelectSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.BeanUtils; +import weaver.common.StringUtil; +import weaver.general.Util; + +/** + * 工作时长 按半天计算 + */ +public class WorkHalfUnitSplitChain extends WorkDurationChain { + + public static KQLog kqLog = new KQLog(); + + /** + * 半天规则下 上午-上午 + */ + public static final int fore_fore_index = 0; + + /** + * 半天规则下 上午-下午 + */ + public static final int fore_after_index = 1; + + /** + * 半天规则下 下午-上午 + */ + public static final int after_fore_index = 2; + + /** + * 半天规则下 下午-下午 + */ + public static final int after_after_index = 3; + + /** + * 半天规则下 非工作日中间点 12:00 + */ + public static final String non_work_half_time = "12:00"; + + + public WorkHalfUnitSplitChain(List splitBeans) { + super(splitBeans); + } + + @Override + public void handleDuration(SplitBean splitBean) throws Exception{ + String durationrule = splitBean.getDurationrule(); + //哺乳假用到 + KQRepeatBean kqRepeatBean = KQRepeatLengthContext.getRepeatBean(); + if(kqRepeatBean != null){ + //流程上有重复时段,就不需要请假类型的重复时间了 + splitBean.setRepeatTime("0"); + } + if("2".equalsIgnoreCase(durationrule)){ + String timeselection = "1"; + if(splitBean.getDurationTypeEnum() == DurationTypeEnum.EVECTION){ + timeselection = KQTravelRulesBiz.getTimeselection(); + } + if(splitBean.getDurationTypeEnum() == DurationTypeEnum.OUT){ + timeselection = KQExitRulesBiz.getTimeselection(); + } + if(splitBean.getDurationTypeEnum() == DurationTypeEnum.LEAVE || splitBean.getDurationTypeEnum() == DurationTypeEnum.LEAVEBACK){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + timeselection = kqLeaveRulesComInfo.getTimeSelection(splitBean.getNewLeaveType()); + } + splitBean.setTimeselection(timeselection); + if("2".equalsIgnoreCase(timeselection)){ + //按照具体时间来算半天的话,还是要按照班次来拆分每一天 + SplitActionUtil splitActionUtil = new SplitActionUtil(); + splitActionUtil.doSerialSplitList(splitBean, splitBeans); + }else{ + getSplitDurationBean(splitBean); + } + }else{ + this.success.handleDuration(splitBean); + } + } + + /** + * 工作日根据具体时间来计算半天 + * @param initArrays + * @param shiftInfoBean + * @param kqTimesArrayComInfo + * @param splitBean + * @param flowbegintimeIndex + * @param flowendtimeIndex + */ + public static boolean getSplitDurationBean4Time(int[] initArrays, + ShiftInfoBean shiftInfoBean, KQTimesArrayComInfo kqTimesArrayComInfo, + SplitBean splitBean, int flowbegintimeIndex, int flowendtimeIndex){ + + boolean isSplit = false; + List halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + String convertAttendDay = Util.null2s(Util.null2String(shiftInfoBean.getConvertAttendDay()),"1.0"); + if(halfWorkIndex != null && !halfWorkIndex.isEmpty()){ + int[] halfWorkIndexs = halfWorkIndex.get(0); + if(halfWorkIndexs != null && halfWorkIndexs.length == 3){ + int flowMins = kqTimesArrayComInfo.getCnt(initArrays, flowbegintimeIndex, flowendtimeIndex, 1); + if(flowMins > 0){ + int firstTimeIndex = halfWorkIndexs[0];//当天班次的最早时间 这个时间肯定不可能跨天的 + int middleTimeIndex = halfWorkIndexs[1];//当天班次的中间时间 这个时间可能会跨天 + int lastTimeIndex = halfWorkIndexs[2];//当天班次的最晚时间 这个时间也可能会跨天 + if(middleTimeIndex > flowbegintimeIndex && middleTimeIndex < flowendtimeIndex){ + int am_half = kqTimesArrayComInfo.getCnt(initArrays, flowbegintimeIndex, middleTimeIndex, 1); + int pm_half = kqTimesArrayComInfo.getCnt(initArrays, middleTimeIndex, flowendtimeIndex, 1); + if(am_half > 0 && pm_half > 0){ + splitBean.setFromTime(kqTimesArrayComInfo.getTimesByArrayindex(firstTimeIndex)); + splitBean.setToTime(kqTimesArrayComInfo.getTimesByArrayindex(lastTimeIndex)); + splitBean.setD_Mins(shiftInfoBean.getWorkmins()*1.0); + splitBean.setDuration("1.0"); + isSplit = true; + }else if(am_half > 0){ + splitBean.setFromTime(kqTimesArrayComInfo.getTimesByArrayindex(firstTimeIndex)); + splitBean.setToTime(kqTimesArrayComInfo.getTimesByArrayindex(middleTimeIndex)); + splitBean.setD_Mins((shiftInfoBean.getWorkmins()*1.0)/2.0); + splitBean.setDuration("0.5"); + isSplit = true; + }else if(pm_half > 0){ + splitBean.setFromTime(kqTimesArrayComInfo.getTimesByArrayindex(middleTimeIndex)); + splitBean.setToTime(kqTimesArrayComInfo.getTimesByArrayindex(lastTimeIndex)); + splitBean.setD_Mins((shiftInfoBean.getWorkmins()*1.0)/2.0); + splitBean.setDuration("0.5"); + isSplit = true; + } + }else if(middleTimeIndex <= flowbegintimeIndex){ + splitBean.setFromTime(kqTimesArrayComInfo.getTimesByArrayindex(middleTimeIndex)); + splitBean.setToTime(kqTimesArrayComInfo.getTimesByArrayindex(lastTimeIndex)); + splitBean.setD_Mins((shiftInfoBean.getWorkmins()*1.0)/2.0); + splitBean.setDuration("0.5"); + isSplit = true; + }else if(middleTimeIndex >= flowendtimeIndex){ + splitBean.setFromTime(kqTimesArrayComInfo.getTimesByArrayindex(firstTimeIndex)); + splitBean.setToTime(kqTimesArrayComInfo.getTimesByArrayindex(middleTimeIndex)); + splitBean.setD_Mins((shiftInfoBean.getWorkmins()*1.0)/2.0); + splitBean.setDuration("0.5"); + isSplit = true; + } + } + } + } + if(splitBean != null){ + if(StringUtil.isNotNull(splitBean.getDuration())){ + double d = Util.getDoubleValue(splitBean.getDuration()); + double convertAttendDayD = Util.getDoubleValue(convertAttendDay); + splitBean.setDuration(StringUtil.vString(convertAttendDayD*d)); + } + } + return isSplit; + } + + /** + * 非工作日 根据半天来计算时长 + * @param kqTimesArrayComInfo + * @param splitBean + * @param flowbegintimeIndex + * @param flowendtimeIndex + */ + public static boolean getSplitDurationBean4NonTime(KQTimesArrayComInfo kqTimesArrayComInfo, SplitBean splitBean, int flowbegintimeIndex, int flowendtimeIndex) { + int half_index = kqTimesArrayComInfo.getArrayindexByTimes(non_work_half_time); + int flowMins = flowendtimeIndex - flowbegintimeIndex; + flowMins = flowMins > 0 ? flowMins : 0; + boolean isSplit = false; + if(flowMins > 0){ + if(flowbegintimeIndex < half_index && flowendtimeIndex > half_index){ + splitBean.setFromTime(kqTimesArrayComInfo.getTimesByArrayindex(flowbegintimeIndex)); + splitBean.setToTime(kqTimesArrayComInfo.getTimesByArrayindex(flowendtimeIndex)); + splitBean.setD_Mins(splitBean.getWorkmins()); + splitBean.setDuration("1.0"); + isSplit = true; + }else { + splitBean.setFromTime(kqTimesArrayComInfo.getTimesByArrayindex(flowbegintimeIndex)); + splitBean.setToTime(kqTimesArrayComInfo.getTimesByArrayindex(flowendtimeIndex)); + splitBean.setD_Mins((splitBean.getWorkmins()*1.0)/2.0); + splitBean.setDuration("0.5"); + isSplit = true; + } + } + return isSplit; + } + + /** + * 根据下拉框来计算半天 + * @param splitBean + */ + @Override + public void getSplitDurationBean(SplitBean splitBean) throws Exception{ + + SplitActionUtil splitActionUtil = new SplitActionUtil(); + String resourceid = splitBean.getResourceId(); + String fromDate = splitBean.getFromdatedb(); + String toDate = splitBean.getTodatedb(); + String fromTime = splitBean.getFromtimedb(); + String toTime = splitBean.getTotimedb(); + DurationTypeEnum durationTypeEnum = splitBean.getDurationTypeEnum(); + if(!(fromTime.equalsIgnoreCase(SplitSelectSet.forenoon_start) || fromTime.equalsIgnoreCase(SplitSelectSet.forenoon_end))){ + return; + } + if(!(toTime.equalsIgnoreCase(SplitSelectSet.afternoon_start) || toTime.equalsIgnoreCase(SplitSelectSet.afternoon_end))){ + return; + } + String fromtimedbOri = splitBean.getFromtimedb(); + String totimedbOri = splitBean.getTotimedb(); + String repeatTime = "0"; + if(DurationTypeEnum.LEAVE == durationTypeEnum || DurationTypeEnum.LEAVEBACK == durationTypeEnum){ + repeatTime = splitBean.getRepeatTime(); + } + + //获取对应人员和对应日期下的工作时段 + List> splitLists = Lists.newArrayList(); + if("1".equals(repeatTime)){ + splitLists = SplitActionUtil.getSplitHalfDayListRepeat(fromDate,toDate,fromTime,toTime); + }else{ + splitLists = SplitActionUtil.getSplitHalfDayList(fromDate,toDate,fromTime,toTime); + } + + if(!splitLists.isEmpty()) { + KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo(); + + for (int i = 0; i < splitLists.size(); i++) { + Map splitMap = splitLists.get(i); + String splitDate = Util.null2String(splitMap.get("splitDate")); + int foreOrAfter = Util.getIntValue(Util.null2String(splitMap.get("foreOrAfter"))); + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate,false); + splitBean.setBelongDate(splitDate); + boolean shouldLog = true; + if(durationTypeEnum == DurationTypeEnum.COMMON_CAL){ + shouldLog = false; + } + if(shouldLog){ + kqLog.info("doSerialSplitList:"+ (splitBean != null ? JSON.toJSONString(splitBean):null)); + } + int restShift = 0; + if (shiftInfoBean != null) { + restShift = shiftInfoBean.getRestShift(); + } + kqLog.info(i+":splitDate:"+splitDate+"::shiftInfoBean:"+ (shiftInfoBean != null ? JSON.toJSONString(shiftInfoBean):null)); + + if (shiftInfoBean != null && 1 != restShift) { + if(!shiftInfoBean.isIsfree()){ + //先计算下时长 + splitBean.setWorkmins(shiftInfoBean.getWorkmins()); + List halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + List shift_halfWorkIndex = Lists.newArrayList(); + if(!halfWorkIndex.isEmpty()){ + List workLongTimeIndex = shiftInfoBean.getWorkLongTimeIndex(); + if(workLongTimeIndex.size() == 1){ +// 根据个性化设置获取到真实的半天班次 + get_shift_halfWorkIndex_by_rule(shift_halfWorkIndex,shiftInfoBean,arrayComInfo,splitBean.getResourceId()); + } + kqLog.info(i+":splitDate:"+splitDate+"::shift_halfWorkIndex:"+ (shift_halfWorkIndex != null ? JSON.toJSONString(shift_halfWorkIndex):null)); + + if(!shift_halfWorkIndex.isEmpty()){ + splitHalftoBean(splitBean,splitDate, foreOrAfter, shift_halfWorkIndex,arrayComInfo,shiftInfoBean); + }else{ + splitHalftoBean(splitBean,splitDate, foreOrAfter, halfWorkIndex,arrayComInfo,shiftInfoBean); + } + } + }else{ + int freeWorkMins = Util.getIntValue(shiftInfoBean.getFreeWorkMins()); + splitBean.setWorkmins(freeWorkMins); + String freeSignStart = shiftInfoBean.getFreeSignStart(); + String freeSignMiddle = shiftInfoBean.getFreeSignMiddle(); + String freeSignEnd = shiftInfoBean.getFreeSignEnd(); + if(freeSignStart.length() > 0){ + List halfWorkIndex = new ArrayList<>(); + int[] halfWorkIndexs = new int[3]; + halfWorkIndexs[0]=arrayComInfo.getArrayindexByTimes(freeSignStart);//当天班次的最早时间 这个时间肯定不可能跨天的 + halfWorkIndexs[1]=arrayComInfo.getArrayindexByTimes(freeSignMiddle);//当天班次的中间时间 这个时间可能会跨天 + halfWorkIndexs[2]=arrayComInfo.getArrayindexByTimes(freeSignEnd);//当天班次的最晚时间 这个时间也可能会跨天 + halfWorkIndex.add(halfWorkIndexs); + splitHalftoBean(splitBean,splitDate, foreOrAfter, halfWorkIndex, arrayComInfo,shiftInfoBean); + } + } + }else{ + String computingMode = splitBean.getComputingMode(); + if("2".equalsIgnoreCase(computingMode)){ + String filterholidays = splitBean.getFilterholidays(); + boolean is_filterholidays = splitActionUtil.check_filterholidays(filterholidays,resourceid,splitDate,-1); + if(is_filterholidays){ + continue; + } + splitNaturalHalf(splitBean,splitDate,foreOrAfter); + } + } + } + } + } + + /** + * 根据个性化设置获取到真实的半天班次 + * @param shift_halfWorkIndex + * @param shiftInfoBean + * @param arrayComInfo + * @param resourceId + */ + public void get_shift_halfWorkIndex_by_rule(List shift_halfWorkIndex, + ShiftInfoBean shiftInfoBean, KQTimesArrayComInfo arrayComInfo, String resourceId) throws Exception { + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + if(!is_flow_humanized){ + return ; + } + List real_allLongWorkTime = Lists.newArrayList(); + List allLongWorkTime = shiftInfoBean.getAllLongWorkTime(); + CollectionUtils.addAll(real_allLongWorkTime,new Object[allLongWorkTime.size()]); + Collections.copy(real_allLongWorkTime, allLongWorkTime); + List real_workAcrossTime = Lists.newArrayList(); + List workAcrossTime = shiftInfoBean.getWorkAcrossTime(); + //个性化设置只支持一次打卡的 + Map shifRuleMap = Maps.newHashMap(); + KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean,resourceId,shifRuleMap); + if(!shifRuleMap.isEmpty()){ + if(shifRuleMap.containsKey("shift_beginworktime")){ + String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime")); + if(shift_beginworktime.length() > 0){ + real_allLongWorkTime.set(0,shift_beginworktime); + } + } + if(shifRuleMap.containsKey("shift_endworktime")){ + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if(shift_endworktime.length() > 0){ + real_allLongWorkTime.set(1,shift_endworktime); + } + } + KQShiftRuleInfoBiz kqShiftRuleInfoBiz = new KQShiftRuleInfoBiz(); + kqShiftRuleInfoBiz.reset_halfIndex(shiftInfoBean, real_allLongWorkTime, arrayComInfo); + shift_halfWorkIndex.addAll(shiftInfoBean.getHalfWorkIndex()); + } + } + + /** + * 针对非自然日半天的拆分 + * @param splitBean + * @param splitDate + * @param foreOrAfter + */ + private void splitNaturalHalf(SplitBean splitBean,String splitDate,int foreOrAfter) { + + String fromDate = splitDate; + String toDate = splitDate; + String splitFromTime = ""; + String splitToTime = ""; + String duration = ""; + + switch (foreOrAfter){ + case WorkHalfUnitSplitChain.fore_fore_index: + splitFromTime = SplitSelectSet.forenoon_start; + splitToTime = SplitSelectSet.forenoon_end; + duration = "0.5"; + break; + case WorkHalfUnitSplitChain.fore_after_index: + splitFromTime = SplitSelectSet.forenoon_start; + splitToTime = SplitSelectSet.afternoon_end; + duration = "1.0"; + break; + case WorkHalfUnitSplitChain.after_fore_index: + break; + case WorkHalfUnitSplitChain.after_after_index: + splitFromTime = SplitSelectSet.afternoon_start; + splitToTime = SplitSelectSet.afternoon_end; + duration = "0.5"; + break; + default: + break; + } + splitBean.setFromDate(fromDate); + splitBean.setFromTime(splitFromTime); + splitBean.setToDate(toDate); + splitBean.setToTime(splitToTime); + splitBean.setDuration(duration); + + SplitBean newsplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + BeanUtils.copyProperties(splitBean, newsplitBean); + splitBeans.add(newsplitBean); + } + + /** + * 单独针对半天规则的 拆分流程数据 理论上是需要先把半天的工作时段拆分 根据拆分后的工作时段,再进行拆分 + */ + private void splitHalftoBean(SplitBean splitBean,String splitDate,int foreOrAfter,List halfWorkIndex,KQTimesArrayComInfo arrayComInfo, + ShiftInfoBean shiftInfoBean){ + + int[] halfWorkIndexs = halfWorkIndex.get(0); + int firstTimeIndex = halfWorkIndexs[0];//当天班次的最早时间 这个时间肯定不可能跨天的 + int middleTimeIndex = halfWorkIndexs[1];//当天班次的中间时间 这个时间可能会跨天 + int lastTimeIndex = halfWorkIndexs[2];//当天班次的最晚时间 这个时间也可能会跨天 + + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + String fromDate = splitDate; + String toDate = splitDate; + String splitFromTime = ""; + String splitToTime = ""; + String duration = ""; + //跨天的话需要得到跨天的日期 + LocalDate localDateAcross = LocalDate.parse(splitDate).plusDays(1); + int workmins = splitBean.getWorkmins(); + + switch (foreOrAfter){ + case WorkHalfUnitSplitChain.fore_fore_index: + splitFromTime = arrayComInfo.getTimesByArrayindex(firstTimeIndex); + splitToTime = arrayComInfo.getTimesByArrayindex(middleTimeIndex); + if(middleTimeIndex > 1439){ + toDate = localDateAcross.format(dateFormatter); + } + splitBean.setD_Mins(workmins/2); + duration = "0.5"; + break; + case WorkHalfUnitSplitChain.fore_after_index: + splitFromTime = arrayComInfo.getTimesByArrayindex(firstTimeIndex); + splitToTime = arrayComInfo.getTimesByArrayindex(lastTimeIndex); + if(lastTimeIndex > 1439){ + toDate = localDateAcross.format(dateFormatter); + } + duration = "1.0"; + splitBean.setD_Mins(workmins); + break; + case WorkHalfUnitSplitChain.after_fore_index: + duration = "0.0"; + break; + case WorkHalfUnitSplitChain.after_after_index: + splitFromTime = arrayComInfo.getTimesByArrayindex(middleTimeIndex); + splitToTime = arrayComInfo.getTimesByArrayindex(lastTimeIndex); + if(middleTimeIndex > 1439){ + fromDate = localDateAcross.format(dateFormatter); + } + if(lastTimeIndex > 1439){ + toDate = localDateAcross.format(dateFormatter); + } + duration = "0.5"; + splitBean.setD_Mins(workmins/2); + break; + default: + break; + } + splitBean.setFromDate(fromDate); + splitBean.setFromTime(splitFromTime); + splitBean.setToDate(toDate); + splitBean.setToTime(splitToTime); + if(shiftInfoBean != null){ + String convertAttendDay = Util.null2s(shiftInfoBean.getConvertAttendDay(),"1.0"); + double convertAttendDayD = Util.getDoubleValue(convertAttendDay); + double durationD = Util.getDoubleValue(duration)*convertAttendDayD; + duration = String.valueOf(durationD); + } + splitBean.setDuration(duration); + + SplitBean newsplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + BeanUtils.copyProperties(splitBean, newsplitBean); + splitBeans.add(newsplitBean); + + } + +} diff --git a/src/com/engine/kq/biz/chain/duration/WorkHourUnitSplitChain.java b/src/com/engine/kq/biz/chain/duration/WorkHourUnitSplitChain.java new file mode 100644 index 0000000..1702ed2 --- /dev/null +++ b/src/com/engine/kq/biz/chain/duration/WorkHourUnitSplitChain.java @@ -0,0 +1,26 @@ +package com.engine.kq.biz.chain.duration; + +import com.engine.kq.wfset.bean.SplitBean; +import java.util.List; + +/** + * 工作时长 按小时计算 + */ +public class WorkHourUnitSplitChain extends WorkDurationChain { + + + public WorkHourUnitSplitChain(List splitBeans) { + super(splitBeans); + } + + @Override + public void handleDuration(SplitBean splitBean) throws Exception{ + String durationrule = splitBean.getDurationrule(); + if("3".equalsIgnoreCase(durationrule) || "5".equalsIgnoreCase(durationrule) || "6".equalsIgnoreCase(durationrule)){ + getSplitDurationBean(splitBean); + }else{ + this.success.handleDuration(splitBean); + } + } + +} diff --git a/src/com/engine/kq/biz/chain/duration/WorkWholeUnitSplitChain.java b/src/com/engine/kq/biz/chain/duration/WorkWholeUnitSplitChain.java new file mode 100644 index 0000000..40e63af --- /dev/null +++ b/src/com/engine/kq/biz/chain/duration/WorkWholeUnitSplitChain.java @@ -0,0 +1,268 @@ +package com.engine.kq.biz.chain.duration; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.bean.KQRepeatBean; +import com.engine.kq.biz.KQRepeatLengthContext; +import com.engine.kq.biz.KQSettingsBiz; +import com.engine.kq.biz.KQShiftRuleInfoBiz; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.engine.kq.wfset.util.SplitSelectSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.BeanUtils; +import weaver.general.Util; + +/** + * 工作时长 按整天计算 + */ +public class WorkWholeUnitSplitChain extends WorkDurationChain { + + public static KQLog kqLog = new KQLog(); + + public WorkWholeUnitSplitChain(List splitBeans) { + super(splitBeans); + } + + @Override + public void handleDuration(SplitBean splitBean) { + String durationrule = splitBean.getDurationrule(); + if("4".equalsIgnoreCase(durationrule)){ + getSplitDurationBean(splitBean); + } + } + + @Override + public void getSplitDurationBean(SplitBean splitBean){ + SplitActionUtil splitActionUtil = new SplitActionUtil(); + + //哺乳假用到 + KQRepeatBean kqRepeatBean = KQRepeatLengthContext.getRepeatBean(); + if(kqRepeatBean != null){ + //流程上有重复时段,就不需要请假类型的重复时间了 + splitBean.setRepeatTime("0"); + } + String resourceid = splitBean.getResourceId(); + String fromDate = splitBean.getFromdatedb(); + String toDate = splitBean.getTodatedb(); + String fromTime = splitBean.getFromtimedb(); + String toTime = splitBean.getTotimedb(); + DurationTypeEnum durationTypeEnum = splitBean.getDurationTypeEnum(); + if(!(fromTime.equalsIgnoreCase(SplitSelectSet.daylong_start))){ + return; + } + if(!(toTime.equalsIgnoreCase(SplitSelectSet.daylong_end))){ + return; + } + String fromtimedbOri = splitBean.getFromtimedb(); + String totimedbOri = splitBean.getTotimedb(); + String repeatTime = "0"; + if(DurationTypeEnum.LEAVE == durationTypeEnum || DurationTypeEnum.LEAVEBACK == durationTypeEnum){ + repeatTime = splitBean.getRepeatTime(); + } + + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + //获取对应人员和对应日期下的工作时段 + List> splitLists = SplitActionUtil.getSplitDayList(fromDate,toDate); + + if(!splitLists.isEmpty()) { + KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo(); + for (int i = 0; i < splitLists.size(); i++) { + Map splitMap = splitLists.get(i); + String splitDate = Util.null2String(splitMap.get("splitDate")); + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate,false); + splitBean.setBelongDate(splitDate); + boolean shouldLog = true; + if(durationTypeEnum == DurationTypeEnum.COMMON_CAL){ + shouldLog = false; + } + if(shouldLog){ + kqLog.info("doSerialSplitList:"+ (splitBean != null ? JSON.toJSONString(splitBean):null)); + } + int restShift = 0; + if (shiftInfoBean != null) { + restShift = shiftInfoBean.getRestShift(); + } + + if (shiftInfoBean != null && 1 != restShift) { + if(!shiftInfoBean.isIsfree()){ + //先计算下时长 + splitBean.setWorkmins(shiftInfoBean.getWorkmins()); + List halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + List shift_halfWorkIndex = Lists.newArrayList(); + if(!halfWorkIndex.isEmpty()){ + List workLongTimeIndex = shiftInfoBean.getWorkLongTimeIndex(); + if(workLongTimeIndex.size() == 1){ + if(workLongTimeIndex.size() == 1){ +// 根据个性化设置获取到真实的半天班次 + get_shift_wholeWorkIndex_by_rule(shift_halfWorkIndex,shiftInfoBean,halfWorkIndex,splitBean.getResourceId(),arrayComInfo); + } + } + if(!shift_halfWorkIndex.isEmpty()){ + splitWholetoBean(splitBean,splitDate, shift_halfWorkIndex, arrayComInfo,shiftInfoBean); + }else{ + splitWholetoBean(splitBean,splitDate, halfWorkIndex, arrayComInfo,shiftInfoBean); + } + } + }else{ + int freeWorkMins = Util.getIntValue(shiftInfoBean.getFreeWorkMins()); + splitBean.setWorkmins(freeWorkMins); + String freeSignStart = shiftInfoBean.getFreeSignStart(); + String freeSignMiddle = shiftInfoBean.getFreeSignMiddle(); + String freeSignEnd = shiftInfoBean.getFreeSignEnd(); + if(freeSignStart.length() > 0){ + List halfWorkIndex = new ArrayList<>(); + int[] halfWorkIndexs = new int[3]; + halfWorkIndexs[0]=arrayComInfo.getArrayindexByTimes(freeSignStart);//当天班次的最早时间 这个时间肯定不可能跨天的 + halfWorkIndexs[1]=arrayComInfo.getArrayindexByTimes(freeSignMiddle);//当天班次的中间时间 这个时间可能会跨天 + halfWorkIndexs[2]=arrayComInfo.getArrayindexByTimes(freeSignEnd);//当天班次的最晚时间 这个时间也可能会跨天 + halfWorkIndex.add(halfWorkIndexs); + splitWholetoBean(splitBean,splitDate, halfWorkIndex, arrayComInfo,shiftInfoBean); + } + } + }else{ + String computingMode = splitBean.getComputingMode(); + if("2".equalsIgnoreCase(computingMode)){ + String filterholidays = splitBean.getFilterholidays(); + boolean is_filterholidays = splitActionUtil.check_filterholidays(filterholidays,resourceid,splitDate,-1); + if(is_filterholidays){ + continue; + } + splitNaturalWhole(splitBean,splitDate); + } + } + } + } + } + + /** + * 根据个性化设置获取到真实的整天班次 + * @param shift_halfWorkIndex + * @param shiftInfoBean + * @param halfWorkIndex + * @param resourceId + * @param arrayComInfo + */ + public void get_shift_wholeWorkIndex_by_rule(List shift_halfWorkIndex, + ShiftInfoBean shiftInfoBean, List halfWorkIndex, String resourceId, + KQTimesArrayComInfo arrayComInfo) { + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + if(!is_flow_humanized){ + return ; + } + + List real_allLongWorkTime = Lists.newArrayList(); + List allLongWorkTime = shiftInfoBean.getAllLongWorkTime(); + CollectionUtils.addAll(real_allLongWorkTime,new Object[allLongWorkTime.size()]); + Collections.copy(real_allLongWorkTime, allLongWorkTime); + + //个性化设置只支持一次打卡的 + Map shifRuleMap = Maps.newHashMap(); + KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean,resourceId,shifRuleMap); + if(!shifRuleMap.isEmpty()){ + if(shifRuleMap.containsKey("shift_beginworktime")){ + String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime")); + if(shift_beginworktime.length() > 0){ + real_allLongWorkTime.set(0,shift_beginworktime); + } + } + if(shifRuleMap.containsKey("shift_endworktime")){ + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if(shift_endworktime.length() > 0){ + real_allLongWorkTime.set(1,shift_endworktime); + } + } + if(!real_allLongWorkTime.isEmpty()){ + int[] shift_halfWorkIndex_arr = new int[halfWorkIndex.get(0).length]; + shift_halfWorkIndex_arr[0] = arrayComInfo.getArrayindexByTimes(real_allLongWorkTime.get(0)); + shift_halfWorkIndex_arr[1] = halfWorkIndex.get(0)[1]; + shift_halfWorkIndex_arr[2] = arrayComInfo.getArrayindexByTimes(real_allLongWorkTime.get(real_allLongWorkTime.size()-1)); + shift_halfWorkIndex.add(shift_halfWorkIndex_arr); + } + } + } + + /** + * 针对非自然日整天的拆分 + * @param splitBean + * @param splitDate + */ + private void splitNaturalWhole(SplitBean splitBean, String splitDate) { + String fromDate = splitDate; + String toDate = splitDate; + String splitFromTime = SplitSelectSet.daylong_start; + String splitToTime = SplitSelectSet.daylong_end; + String duration = "1.0"; + + splitBean.setFromDate(fromDate); + splitBean.setFromTime(splitFromTime); + splitBean.setToDate(toDate); + splitBean.setToTime(splitToTime); + splitBean.setDuration(duration); + + SplitBean newsplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + BeanUtils.copyProperties(splitBean, newsplitBean); + splitBeans.add(newsplitBean); + } + + /** + * 单独针对整天规则的 拆分流程数据 理论上是需要先把整天的工作时段拆分 根据拆分后的工作时段,再进行拆分 + */ + private void splitWholetoBean(SplitBean splitBean,String splitDate,List halfWorkIndex,KQTimesArrayComInfo arrayComInfo, + ShiftInfoBean shiftInfoBean){ + + String fromDate = splitDate; + String toDate = splitDate; + + int[] halfWorkIndexs = halfWorkIndex.get(0); + int firstTimeIndex = halfWorkIndexs[0];//当天班次的最早时间 这个时间肯定不可能跨天的 + int lastTimeIndex = halfWorkIndexs[2];//当天班次的最晚时间 这个时间也可能会跨天 + //整天的话,跨天只有可能是最晚下班时间跨天 + String splitFromTime = arrayComInfo.getTimesByArrayindex(firstTimeIndex); + String splitToTime = arrayComInfo.getTimesByArrayindex(lastTimeIndex); + boolean isAcross = lastTimeIndex > 1440; + String duration = "1.0"; + int workmins = splitBean.getWorkmins(); + + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + //跨天的话需要得到跨天的日期 + LocalDate localDateAcross = LocalDate.parse(splitDate).plusDays(1); + + if(isAcross){ + toDate = localDateAcross.format(dateFormatter); + } + + splitBean.setFromDate(fromDate); + splitBean.setFromTime(splitFromTime); + splitBean.setToDate(toDate); + splitBean.setToTime(splitToTime); + if(shiftInfoBean != null){ + String convertAttendDay = Util.null2s(shiftInfoBean.getConvertAttendDay(),"1.0"); + double convertAttendDayD = Util.getDoubleValue(convertAttendDay); + double durationD = Util.getDoubleValue(duration)*convertAttendDayD; + duration = String.valueOf(durationD); + } + splitBean.setDuration(duration); + splitBean.setD_Mins(workmins*Util.getDoubleValue(duration)); + + SplitBean newsplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + BeanUtils.copyProperties(splitBean, newsplitBean); + splitBeans.add(newsplitBean); + + } + +} diff --git a/src/com/engine/kq/biz/chain/overtime/OvertimeChain.java b/src/com/engine/kq/biz/chain/overtime/OvertimeChain.java new file mode 100644 index 0000000..9e2439e --- /dev/null +++ b/src/com/engine/kq/biz/chain/overtime/OvertimeChain.java @@ -0,0 +1,807 @@ +package com.engine.kq.biz.chain.overtime; + +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQSettingsBiz; +import com.engine.kq.biz.KQShiftRuleInfoBiz; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.bean.SplitBean; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import org.springframework.beans.BeanUtils; +import weaver.general.Util; + +/** + * 加班链 基类 + */ +public abstract class OvertimeChain { + + protected OvertimeChain success; //定义下一个处理对象 + protected List splitBeans; + protected Map splitMap; + protected KQLog kqLog = new KQLog(); + + public OvertimeChain(Map splitMap,List splitBeans) { + this.splitMap = splitMap; + this.splitBeans = splitBeans; + } + //创建链 + public void setOvertimeChain(OvertimeChain overtimeChain) { + this.success=overtimeChain; + } + + public abstract void handleOvertimeChain(SplitBean splitBean) throws Exception; + + /** + * 非跨天情况下的 节假日加班 + * @param splitBean + */ + public void doOverTimeSplit1(SplitBean splitBean){ + KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo(); + + int[] initArrays = arrayComInfo.getInitArr(); + String resourceid = splitBean.getResourceId(); + String durationrule = splitBean.getDurationrule(); + String splitDate = splitBean.getBelongDate(); + String splitFromTime = splitBean.getFromTime(); + String splitToTime = splitBean.getToTime(); + boolean shouldAcross = "1".equalsIgnoreCase(Util.null2String(splitMap.get("shouldAcross"))); + + int computingMode = KQOvertimeRulesBiz.getComputingMode(resourceid, splitDate); + splitBean.setComputingMode(computingMode+""); + + kqLog.info("OvertimeChain doOverTimeSplit1:resourceid:"+resourceid+":computingMode:"+computingMode); + if(computingMode == 3){ +// 无需审批,根据打卡时间计算加班时长 + splitBean.setD_Mins(0.0); + kqLog.info("doOverTimeSplit1:resourceid:"+resourceid+":splitDate:"+splitDate+"无需审批,根据打卡时间计算加班时长"); + return ; + } + + int overtimeEnable = KQOvertimeRulesBiz.getOvertimeEnable(resourceid, splitDate); + + List restTimeList = KQOvertimeRulesBiz.getRestTimeList(resourceid, splitDate); + + int startIndex = arrayComInfo.getArrayindexByTimes(splitFromTime); + int endIndex = arrayComInfo.getArrayindexByTimes(splitToTime); + if(shouldAcross){ + endIndex = arrayComInfo.getArrayindexByTimes("24:00"); + } + + //先把要计算的时长填充上0 + Arrays.fill(initArrays, startIndex, endIndex, 0); + //再把休息时间填充上去 + if(!restTimeList.isEmpty()){ + for(int i =0 ; i < restTimeList.size() ; i++){ + String[] restTimes = restTimeList.get(i); + if(restTimes.length == 2){ + int restStart = arrayComInfo.getArrayindexByTimes(restTimes[0]); + int restEnd = arrayComInfo.getArrayindexByTimes(restTimes[1]); + if(shouldAcross && restEnd == 1439){ + //针对跨天的休息时段单独处理排除掉23:59-00:00的时间 + restEnd = 1440; + } + Arrays.fill(initArrays, restStart, restEnd, 1); + } + } + } + + //最后排除掉休息时间还剩多少加班时长就是最终的结果 + int curMins = arrayComInfo.getCnt(initArrays, startIndex, endIndex, 0); + kqLog.info("doOverTimeSplit1:resourceid:"+resourceid+":startIndex:"+startIndex+":endIndex:"+endIndex+":curMins:"+curMins); + + //如果人再当前指定日期下未开启加班,直接跳过 + if(overtimeEnable != 1){ + curMins = 0; + kqLog.info("doOverTimeSplit1:resourceid:"+resourceid+":splitDate:"+splitDate+"不允许加班"); + } + if(curMins > 0){ + splitBean.setD_Mins(curMins); + splitBean.setChangeType(1); + splitBean.setComputingMode(""+computingMode); + fillNewBean(splitBean); + } + + } + + /** + * 非跨天情况下的 工作日加班 + * @param splitBean + */ + public void doOverTimeSplit2(SplitBean splitBean){ + KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo(); + + int[] initArrays = arrayComInfo.getInitArr(); + String resourceid = splitBean.getResourceId(); + String splitDate = splitBean.getBelongDate(); + String splitFromTime = splitBean.getFromTime(); + String splitToTime = splitBean.getToTime(); + boolean shouldAcross = "1".equalsIgnoreCase(Util.null2String(splitMap.get("shouldAcross"))); + + int computingMode = KQOvertimeRulesBiz.getComputingMode(resourceid, splitDate); + splitBean.setComputingMode(computingMode+""); + if(computingMode == 3){ +// 无需审批,根据打卡时间计算加班时长 + splitBean.setD_Mins(0.0); + kqLog.info("doOverTimeSplit2:resourceid:"+resourceid+":splitDate:"+splitDate+"无需审批,根据打卡时间计算加班时长"); + return ; + } + int overtimeEnable = KQOvertimeRulesBiz.getOvertimeEnable(resourceid, splitDate); + + int startIndex = arrayComInfo.getArrayindexByTimes(splitFromTime); + int endIndex = arrayComInfo.getArrayindexByTimes(splitToTime); + if(shouldAcross){ + endIndex = arrayComInfo.getArrayindexByTimes("24:00"); + } + + //先把要计算的时长填充上0 + Arrays.fill(initArrays, startIndex, endIndex, 0); + + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate,true); + if(shiftInfoBean != null){ + List workLongTimeIndex = shiftInfoBean.getWorkLongTimeIndex(); + List real_workLongTimeIndex = Lists.newArrayList(); + + //list带数组,这里要深拷贝 + for(int[] tmp : workLongTimeIndex){ + int[] real_tmp = new int[tmp.length]; + System.arraycopy(tmp, 0, real_tmp, 0, tmp.length); + real_workLongTimeIndex.add(real_tmp); + } + if(real_workLongTimeIndex.size() == 1){ + //个性化设置只支持一次打卡的 + KQShiftRuleInfoBiz kqShiftRuleInfoBiz = new KQShiftRuleInfoBiz(); + kqShiftRuleInfoBiz.rest_workLongTimeIndex(shiftInfoBean,splitBean,real_workLongTimeIndex,arrayComInfo,null); + } + if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){ + int[] workTimes = real_workLongTimeIndex.get(real_workLongTimeIndex.size()-1); + for(int i = 0 ; i < real_workLongTimeIndex.size() ;i++){ + //工作日填充1 + Arrays.fill(initArrays, real_workLongTimeIndex.get(i)[0], real_workLongTimeIndex.get(i)[1], 1); + } + List restIndex = shiftInfoBean.getRestIndex(); + for(int i = 0 ; i < restIndex.size() ; i++){ + //休息时段填充2 + Arrays.fill(initArrays, restIndex.get(i)[0], restIndex.get(i)[1], 2); + } + //加班起算时间是必填项 + int startTimeMin = KQOvertimeRulesBiz.getStartTime(resourceid,splitDate); + startTimeMin = startTimeMin < 0 ? 0 : startTimeMin; + int lastWorkTimeIndex = workTimes[1]; + //从下班时间到下班起算时间这段时间填充4 + Arrays.fill(initArrays, lastWorkTimeIndex, (lastWorkTimeIndex+startTimeMin), 4); + + int overMins = arrayComInfo.getCnt(initArrays, 0, 1440, 0); + + kqLog.info("OvertimeChain doOverTimeSplit2:resourceid:"+resourceid+":overMins:"+overMins); + //如果人再当前指定日期下未开启加班,直接跳过 + if(overtimeEnable != 1){ + overMins= 0; + kqLog.info("doOverTimeSplit2:resourceid:"+resourceid+":splitDate:"+splitDate+"不允许加班"); + } + if(overMins > 0){ + splitBean.setD_Mins(overMins); + splitBean.setChangeType(2); + splitBean.setComputingMode(""+computingMode); + fillNewBean(splitBean); + } + }else{ + kqLog.info("doOverTimeSplit2,当天工作日取不到当天工作时段:resourceid:"+resourceid+":splitDate:"+splitDate); + } + }else{ + kqLog.info("doOverTimeSplit2,工作日加班shiftInfoBean为null:resourceid:"+resourceid+":splitDate:"+splitDate); + } + } + + /** + * 非跨天情况下的 休息日加班 + * @param splitBean + */ + public void doOverTimeSplit3(SplitBean splitBean){ + + KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo(); + + int[] initArrays = arrayComInfo.getInitArr(); + String resourceid = splitBean.getResourceId(); + String durationrule = splitBean.getDurationrule(); + String splitDate = splitBean.getBelongDate(); + String splitFromTime = splitBean.getFromTime(); + String splitToTime = splitBean.getToTime(); + boolean shouldAcross = "1".equalsIgnoreCase(Util.null2String(splitMap.get("shouldAcross"))); + + int computingMode = KQOvertimeRulesBiz.getComputingMode(resourceid, splitDate); + splitBean.setComputingMode(computingMode+""); + + kqLog.info("OvertimeChain doOverTimeSplit3:resourceid:"+resourceid+":computingMode:"+computingMode); + if(computingMode == 3){ +// 无需审批,根据打卡时间计算加班时长 + kqLog.info("OvertimeChain doOverTimeSplit3:resourceid:"+resourceid+":splitDate:"+splitDate+"无需审批,根据打卡时间计算加班时长"); + splitBean.setD_Mins(0.0); + return ; + } + + int overtimeEnable = KQOvertimeRulesBiz.getOvertimeEnable(resourceid, splitDate); + + List restTimeList = KQOvertimeRulesBiz.getRestTimeList(resourceid, splitDate); + + int startIndex = arrayComInfo.getArrayindexByTimes(splitFromTime); + int endIndex = arrayComInfo.getArrayindexByTimes(splitToTime); + if(shouldAcross){ + endIndex = arrayComInfo.getArrayindexByTimes("24:00"); + } + + //先把要计算的时长填充上0 + Arrays.fill(initArrays, startIndex, endIndex, 0); + //再把休息时间填充上去 + if(!restTimeList.isEmpty()){ + for(int i =0 ; i < restTimeList.size() ; i++){ + String[] restTimes = restTimeList.get(i); + if(restTimes.length == 2){ + int restStart = arrayComInfo.getArrayindexByTimes(restTimes[0]); + int restEnd = arrayComInfo.getArrayindexByTimes(restTimes[1]); + if(shouldAcross && restEnd == 1439){ + //针对跨天的休息时段单独处理排除掉23:59-00:00的时间 + restEnd = 1440; + } + Arrays.fill(initArrays, restStart, restEnd, 1); + } + } + } + //最后排除掉休息时间还剩多少加班时长就是最终的结果 + int curMins = arrayComInfo.getCnt(initArrays, startIndex, endIndex, 0); + kqLog.info("OvertimeChain doOverTimeSplit3:resourceid:"+resourceid+":startIndex:"+startIndex+":endIndex:"+endIndex+":curMins:"+curMins); + + //如果人再当前指定日期下未开启加班,直接跳过 + if(overtimeEnable != 1){ + curMins = 0; + kqLog.info("doOverTimeSplit3:resourceid:"+resourceid+":splitDate:"+splitDate+"不允许加班"); + } + if(curMins > 0){ + splitBean.setD_Mins(curMins); + splitBean.setChangeType(3); + splitBean.setComputingMode(""+computingMode); + fillNewBean(splitBean); + } + } + + /** + * 针对工作日 前一天跨天的情况处理 + * @param splitBean + * @param arrayComInfo + * @param shiftInfoBean + * @param real_workLongTimeIndex + */ + public int handlePreWork(SplitBean splitBean, KQTimesArrayComInfo arrayComInfo, + ShiftInfoBean shiftInfoBean, List real_workLongTimeIndex){ + int curFirstTimeIndex = -1; + String resourceid = splitBean.getResourceId(); + String splitDate = splitBean.getBelongDate(); + String splitFromTime = splitBean.getFromTime(); + String splitToTime = splitBean.getToTime(); + boolean shouldAcross = "1".equalsIgnoreCase(Util.null2String(splitMap.get("shouldAcross"))); + String preSplitDate = splitMap.get("preSplitDate"); + + int[] initArrays = arrayComInfo.getInitArr(); + int startIndex = arrayComInfo.getArrayindexByTimes(splitFromTime); + + int endIndex = arrayComInfo.getArrayindexByTimes(splitToTime); + if(shouldAcross){ + endIndex = arrayComInfo.getArrayindexByTimes("24:00"); + } + int overtimeEnable = KQOvertimeRulesBiz.getOvertimeEnable(resourceid, preSplitDate); + + //加班起算时间是必填项 + int startTimeMin = KQOvertimeRulesBiz.getStartTime(resourceid,preSplitDate); + int preLastWorkTimeIndex = -1; + List allWorkTime = shiftInfoBean.getAllWorkTime(); + String curFirstTime = allWorkTime.get(0); + curFirstTimeIndex = arrayComInfo.getArrayindexByTimes(curFirstTime); + if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){ + int[] cur_real_startIndex = real_workLongTimeIndex.get(0); + if(curFirstTimeIndex > cur_real_startIndex[0]){ + curFirstTimeIndex = cur_real_startIndex[0]; + } + } + + //先把要计算的时长填充上0 + Arrays.fill(initArrays, startIndex, endIndex, 0); + + List preWorkIndex = shiftInfoBean.getPreWorkIndex(); + if(preWorkIndex != null && !preWorkIndex.isEmpty()){ + int[] preWorkIndexs = preWorkIndex.get(preWorkIndex.size()-1); + for(int i = 0 ; i < preWorkIndex.size() ;i++){ + //跨天工作日填充1 + Arrays.fill(initArrays, preWorkIndex.get(i)[0], preWorkIndex.get(i)[1], 1); + } + preLastWorkTimeIndex = preWorkIndexs[1]; + } + + int shift_beginworktime_index = -1; + int shift_endworktime_index = -1; + if(preWorkIndex.size() == 1){ + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + if(is_flow_humanized){ + ShiftInfoBean preShiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, preSplitDate,false); + Map shifRuleMap = Maps.newHashMap(); + KQShiftRuleInfoBiz.getShiftRuleInfo(preShiftInfoBean,resourceid,shifRuleMap); + if(!shifRuleMap.isEmpty()) { + if (shifRuleMap.containsKey("shift_beginworktime")) { + String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime")); + if (shift_beginworktime.length() > 0) { + shift_beginworktime_index = arrayComInfo.getArrayindexByTimes(shift_beginworktime); + } + } + if (shifRuleMap.containsKey("shift_endworktime")) { + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if (shift_endworktime.length() > 0) { + shift_endworktime_index = arrayComInfo.getArrayindexByTimes(shift_endworktime); + } + } + } + } + } + if(shift_beginworktime_index > -1){ + curFirstTimeIndex = shift_beginworktime_index; + } + if(shift_endworktime_index > -1) { + if (shift_endworktime_index > 1440) { + //如果个性化之后的下班时间还是在第二天 + int tmp_shift_endworktime_index = shift_endworktime_index - 1440; + if(preLastWorkTimeIndex > -1){ + if(preLastWorkTimeIndex > tmp_shift_endworktime_index){ + Arrays.fill(initArrays, tmp_shift_endworktime_index, preLastWorkTimeIndex, -1); + }else{ + Arrays.fill(initArrays, preLastWorkTimeIndex, tmp_shift_endworktime_index, 1); + } + }else{ + Arrays.fill(initArrays, 0, tmp_shift_endworktime_index, 1); + } + }else{ + //如果个性化之后的下班时间不在第二天了,但是原始的下班时间还是在第二天,那么需要把这段时间给填补回来 + if(preLastWorkTimeIndex > -1){ + Arrays.fill(initArrays, 0, preLastWorkTimeIndex, -1); + } + } + } + + List preRestIndex = shiftInfoBean.getPreRestIndex(); + if(preRestIndex != null && !preRestIndex.isEmpty()){ + for(int i = 0 ; i < preRestIndex.size() ; i++){ + //跨天休息时段填充2 + Arrays.fill(initArrays, preRestIndex.get(i)[0], preRestIndex.get(i)[1], 2); + } + } + //工作日还有一个加班起算时间的设置 + if(preLastWorkTimeIndex >= 0){ + if(shift_endworktime_index > -1) { + if (shift_endworktime_index > 1440) { + //如果个性化之后的下班时间还是在第二天 + preLastWorkTimeIndex = shift_endworktime_index - 1440; + }else{ + preLastWorkTimeIndex = shift_endworktime_index; + } + } + Arrays.fill(initArrays, preLastWorkTimeIndex, preLastWorkTimeIndex+startTimeMin, 4); + } + + int preOverMins = arrayComInfo.getCnt(initArrays, startIndex, curFirstTimeIndex, 0); + kqLog.info("handlePreWork:resourceid:"+resourceid+":startIndex:"+startIndex+":curFirstTimeIndex:"+curFirstTimeIndex+"
"); + kqLog.info("handlePreWork:resourceid:"+resourceid+":preOverMins:"+preOverMins+"
"); + + //如果人再当前指定日期下未开启加班,直接跳过 + if(overtimeEnable != 1){ + preOverMins = 0; + kqLog.info("handlePreWork:resourceid:"+resourceid+":preSplitDate:"+preSplitDate+"不允许加班"); + } + if(preOverMins > 0){ + SplitBean preSplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + BeanUtils.copyProperties(splitBean, preSplitBean); + preSplitBean.setD_Mins(preOverMins); + preSplitBean.setBelongDate(preSplitDate); + preSplitBean.setChangeType(2); + int computingMode = KQOvertimeRulesBiz.getComputingMode(preSplitBean.getResourceId(), preSplitDate); + preSplitBean.setComputingMode(""+computingMode); + fillNewBean(preSplitBean); + } + return curFirstTimeIndex; + } + + /** + * 针对工作日 处理完前一天的数据处理当天情况 + * @param splitBean + * @param arrayComInfo + * @param curShiftInfoBean + * @param real_workLongTimeIndex + * @param firstWorkIndex 前一天 + */ + public void handleCurWork(SplitBean splitBean, KQTimesArrayComInfo arrayComInfo, + ShiftInfoBean curShiftInfoBean, List real_workLongTimeIndex, int firstWorkIndex) throws Exception{ + String resourceid = splitBean.getResourceId(); + String splitDate = splitBean.getBelongDate(); + String splitFromTime = splitBean.getFromTime(); + String splitToTime = splitBean.getToTime(); + boolean shouldAcross = "1".equalsIgnoreCase(Util.null2String(splitMap.get("shouldAcross"))); + String preSplitDate = splitMap.get("preSplitDate"); + + int curComputingMode = KQOvertimeRulesBiz.getComputingMode(resourceid, splitDate); + if(curComputingMode == 3) { +// 前一天是无需审批,根据打卡时间计算加班时长,那么只需要按照普通的工作日加班处理就可以 + kqLog.info("OvertimeChain handleCurWork:resourceid:"+resourceid+":splitDate:"+splitDate+"前一天是无需审批,根据打卡时间计算加班时长,那么只需要按照普通的工作日加班处理就可以"); + return ; + } + + int overtimeEnable = KQOvertimeRulesBiz.getOvertimeEnable(resourceid, splitDate); + + int[] initArrays = arrayComInfo.getInitArr(); + int startIndex = arrayComInfo.getArrayindexByTimes(splitFromTime); + int endIndex = arrayComInfo.getArrayindexByTimes(splitToTime); + if(shouldAcross){ + endIndex = arrayComInfo.getArrayindexByTimes("24:00"); + } + + //先把要计算的时长填充上0 + Arrays.fill(initArrays, startIndex, endIndex, 0); + + int[] workTimeIndexs = real_workLongTimeIndex.get(real_workLongTimeIndex.size()-1); + if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()) { + for (int i = 0; i < real_workLongTimeIndex.size(); i++) { + //工作日填充1 + Arrays.fill(initArrays, real_workLongTimeIndex.get(i)[0], real_workLongTimeIndex.get(i)[1], 1); + } + List restIndex = curShiftInfoBean.getRestIndex(); + for (int i = 0; i < restIndex.size(); i++) { + //休息时段填充2 + Arrays.fill(initArrays, restIndex.get(i)[0], restIndex.get(i)[1], 2); + } + } + //加班起算时间是必填项 + int startTimeMin = KQOvertimeRulesBiz.getStartTime(resourceid,splitDate); + startTimeMin = startTimeMin < 0 ? 0 : startTimeMin; + int lastWorkTimeIndex = workTimeIndexs[1]; + //从下班时间到下班起算时间这段时间填充4 + Arrays.fill(initArrays, lastWorkTimeIndex, (lastWorkTimeIndex+startTimeMin), 4); + + int need_startIndex = startIndex; + if(firstWorkIndex > startIndex){ + need_startIndex = firstWorkIndex; + } + int overMins = arrayComInfo.getCnt(initArrays, need_startIndex, 1440, 0); + + kqLog.info("OvertimeChain:resourceid:"+resourceid+":startIndex:"+startIndex+":overMins:"+overMins); + //如果人再当前指定日期下未开启加班,直接跳过 + if(overtimeEnable != 1){ + overMins= 0; + kqLog.info("handleCurWork:resourceid:"+resourceid+":splitDate:"+splitDate+"不允许加班"); + } + if(overMins > 0){ + SplitBean curSplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + BeanUtils.copyProperties(splitBean, curSplitBean); + curSplitBean.setD_Mins(overMins); + curSplitBean.setBelongDate(splitDate); + curSplitBean.setChangeType(2); + curSplitBean.setFromTime(arrayComInfo.getTimesByArrayindex(lastWorkTimeIndex)); + curSplitBean.setToTime(arrayComInfo.getTimesByArrayindex(endIndex)); + int computingMode = KQOvertimeRulesBiz.getComputingMode(curSplitBean.getResourceId(), splitDate); + curSplitBean.setComputingMode(""+computingMode); + fillNewBean(curSplitBean); + } + } + + /** + * 针对节假日 处理完前一天的数据处理当天情况 + * @param splitBean + * @param arrayComInfo + * @param curFirstTimeIndex + */ + public void handleCurHoliday(SplitBean splitBean,KQTimesArrayComInfo arrayComInfo,int curFirstTimeIndex) { + String resourceid = splitBean.getResourceId(); + String splitDate = splitBean.getBelongDate(); + String splitFromTime = splitBean.getFromTime(); + String splitToTime = splitBean.getToTime(); + boolean shouldAcross = "1".equalsIgnoreCase(Util.null2String(splitMap.get("shouldAcross"))); + String preSplitDate = splitMap.get("preSplitDate"); + + int computingMode = KQOvertimeRulesBiz.getComputingMode(resourceid, splitDate); + splitBean.setComputingMode(computingMode+""); + if(computingMode == 3){ +// 无需审批,根据打卡时间计算加班时长 + splitBean.setD_Mins(0.0); + kqLog.info("handleCurHoliday:resourceid:"+resourceid+":splitDate:"+splitDate+"无需审批,根据打卡时间计算加班时长"); + return ; + } + + int overtimeEnable = KQOvertimeRulesBiz.getOvertimeEnable(resourceid, splitDate); + + int[] initArrays = arrayComInfo.getInitArr(); + int startIndex = arrayComInfo.getArrayindexByTimes(splitFromTime); + int endIndex = arrayComInfo.getArrayindexByTimes(splitToTime); + if(shouldAcross){ + endIndex = arrayComInfo.getArrayindexByTimes("24:00"); + } + + List restTimeList = KQOvertimeRulesBiz.getRestTimeList(resourceid, splitDate); + + //先把要计算的时长填充上0 + Arrays.fill(initArrays, startIndex, endIndex, 0); + //再把休息时间填充上去 + if(!restTimeList.isEmpty()){ + for(int i =0 ; i < restTimeList.size() ; i++){ + String[] restTimes = restTimeList.get(i); + if(restTimes.length == 2){ + int restStart = arrayComInfo.getArrayindexByTimes(restTimes[0]); + int restEnd = arrayComInfo.getArrayindexByTimes(restTimes[1]); + if(shouldAcross && restEnd == 1439){ + //针对跨天的休息时段单独处理排除掉23:59-00:00的时间 + restEnd = 1440; + } + Arrays.fill(initArrays, restStart, restEnd, 1); + } + } + } + //最后排除掉休息时间还剩多少加班时长就是最终的结果 + int curMins = arrayComInfo.getCnt(initArrays, curFirstTimeIndex, endIndex, 0); + curMins = curMins > 0 ? curMins : 0; + + kqLog.info("OvertimeChain handleCurHoliday:resourceid:"+resourceid+":curFirstTimeIndex:"+curFirstTimeIndex+":endIndex:"+endIndex+":curMins:"+curMins); + //如果人再当前指定日期下未开启加班,直接跳过 + if(overtimeEnable != 1){ + curMins = 0; + kqLog.info("handleCurHoliday:resourceid:"+resourceid+":splitDate:"+splitDate+"不允许加班"); + } + if(curMins > 0){ + SplitBean curSplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + BeanUtils.copyProperties(splitBean, curSplitBean); + curSplitBean.setD_Mins(curMins); + curSplitBean.setFromTime(arrayComInfo.getTimesByArrayindex(curFirstTimeIndex)); + curSplitBean.setToTime(arrayComInfo.getTimesByArrayindex(endIndex)); + curSplitBean.setBelongDate(splitDate); + curSplitBean.setComputingMode(""+computingMode); + curSplitBean.setChangeType(1); + fillNewBean(curSplitBean); + } + } + + /** + * 针对休息日 处理完前一天的数据处理当天情况 + * @param splitBean + * @param arrayComInfo + * @param curFirstTimeIndex + */ + public void handleCurRestday(SplitBean splitBean,KQTimesArrayComInfo arrayComInfo,int curFirstTimeIndex) { + String resourceid = splitBean.getResourceId(); + String splitDate = splitBean.getBelongDate(); + String splitFromTime = splitBean.getFromTime(); + String splitToTime = splitBean.getToTime(); + boolean shouldAcross = "1".equalsIgnoreCase(Util.null2String(splitMap.get("shouldAcross"))); + String preSplitDate = splitMap.get("preSplitDate"); + + int computingMode = KQOvertimeRulesBiz.getComputingMode(resourceid, splitDate); + + kqLog.info("OvertimeChain handleCurRestday:resourceid:"+resourceid+":computingMode:"+computingMode); + splitBean.setComputingMode(computingMode+""); + if(computingMode == 3){ +// 无需审批,根据打卡时间计算加班时长 + splitBean.setD_Mins(0.0); + return ; + } + int overtimeEnable = KQOvertimeRulesBiz.getOvertimeEnable(resourceid, splitDate); + + int[] initArrays = arrayComInfo.getInitArr(); + int startIndex = arrayComInfo.getArrayindexByTimes(splitFromTime); + int endIndex = arrayComInfo.getArrayindexByTimes(splitToTime); + if(shouldAcross){ + endIndex = arrayComInfo.getArrayindexByTimes("24:00"); + } + + List restTimeList = KQOvertimeRulesBiz.getRestTimeList(resourceid, splitDate); + + //先把要计算的时长填充上0 + Arrays.fill(initArrays, startIndex, endIndex, 0); + //再把休息时间填充上去 + if(!restTimeList.isEmpty()){ + for(int i =0 ; i < restTimeList.size() ; i++){ + String[] restTimes = restTimeList.get(i); + if(restTimes.length == 2){ + int restStart = arrayComInfo.getArrayindexByTimes(restTimes[0]); + int restEnd = arrayComInfo.getArrayindexByTimes(restTimes[1]); + if(shouldAcross && restEnd == 1439){ + //针对跨天的休息时段单独处理排除掉23:59-00:00的时间 + restEnd = 1440; + } + Arrays.fill(initArrays, restStart, restEnd, 1); + } + } + } + //最后排除掉休息时间还剩多少加班时长就是最终的结果 + int curMins = arrayComInfo.getCnt(initArrays, curFirstTimeIndex, endIndex, 0); + curMins = curMins > 0 ? curMins : 0; + kqLog.info("OvertimeChain handleCurRestday:resourceid:"+resourceid+":curFirstTimeIndex:"+curFirstTimeIndex+":endIndex:"+endIndex+":curMins:"+curMins); + //如果人再当前指定日期下未开启加班,直接跳过 + if(overtimeEnable != 1){ + curMins = 0; + kqLog.info("handlePreWork:resourceid:"+resourceid+":splitDate:"+splitDate+"不允许加班"); + } + + if(curMins > 0){ + SplitBean curSplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + BeanUtils.copyProperties(splitBean, curSplitBean); + curSplitBean.setBelongDate(splitDate); + curSplitBean.setFromTime(arrayComInfo.getTimesByArrayindex(curFirstTimeIndex)); + curSplitBean.setToTime(arrayComInfo.getTimesByArrayindex(endIndex)); + curSplitBean.setD_Mins(curMins); + curSplitBean.setBelongDate(splitDate); + curSplitBean.setChangeType(3); + curSplitBean.setComputingMode(""+computingMode); + fillNewBean(curSplitBean); + } + } + + /** + * 前一天是工作日,处理前一天工作日的跨天数据 + * @param splitBean + * @param arrayComInfo + * @param shiftInfoBean + * @return + */ + public int handlePreWorkday(SplitBean splitBean, KQTimesArrayComInfo arrayComInfo, ShiftInfoBean shiftInfoBean) { + + String resourceid = splitBean.getResourceId(); + String splitDate = splitBean.getBelongDate(); + String splitFromTime = splitBean.getFromTime(); + String splitToTime = splitBean.getToTime(); + boolean shouldAcross = "1".equalsIgnoreCase(Util.null2String(splitMap.get("shouldAcross"))); + String preSplitDate = splitMap.get("preSplitDate"); + + int overtimeEnable = KQOvertimeRulesBiz.getOvertimeEnable(resourceid, preSplitDate); + + int[] initArrays = arrayComInfo.getInitArr(); + int startIndex = arrayComInfo.getArrayindexByTimes(splitFromTime); + int endIndex = arrayComInfo.getArrayindexByTimes(splitToTime); + if(shouldAcross){ + endIndex = arrayComInfo.getArrayindexByTimes("24:00"); + } + List preWorkAcrossIndex = shiftInfoBean.getPreWorkAcrossIndex(); + if(preWorkAcrossIndex != null && !preWorkAcrossIndex.isEmpty()){ + int shift_beginworktime_index = -1; + int shift_endworktime_index = -1; + if(preWorkAcrossIndex.size() == 1){ + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + if(is_flow_humanized){ + ShiftInfoBean preShiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, preSplitDate,false); + Map shifRuleMap = Maps.newHashMap(); + KQShiftRuleInfoBiz.getShiftRuleInfo(preShiftInfoBean,resourceid,shifRuleMap); + if(!shifRuleMap.isEmpty()) { + if (shifRuleMap.containsKey("shift_beginworktime")) { + String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime")); + if (shift_beginworktime.length() > 0) { + shift_beginworktime_index = arrayComInfo.getArrayindexByTimes(shift_beginworktime); + } + } + if (shifRuleMap.containsKey("shift_endworktime")) { + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if (shift_endworktime.length() > 0) { + shift_endworktime_index = arrayComInfo.getArrayindexByTimes(shift_endworktime); + } + } + } + } + } + + int[] preWorkAcrossIndexs = preWorkAcrossIndex.get(0); + //得到当天最早的上班时间,则从0-firstWorkIndex都属于前一天的加班 + int firstWorkIndex = preWorkAcrossIndexs != null ? preWorkAcrossIndexs[0] : -1; + if(shift_beginworktime_index > -1){ + firstWorkIndex = shift_beginworktime_index; + } + + //先把要计算的时长填充上0 + Arrays.fill(initArrays, startIndex, endIndex, 0); + + int last_preworkIndex = -1; + List preWorkIndex = shiftInfoBean.getPreWorkIndex(); + for(int i = 0 ; preWorkIndex != null && i < preWorkIndex.size() ;i++){ + //跨天工作日填充1 + Arrays.fill(initArrays, preWorkIndex.get(i)[0], preWorkIndex.get(i)[1], 1); + last_preworkIndex = preWorkIndex.get(i)[1]; + } + if(shift_endworktime_index > -1) { + if (shift_endworktime_index > 1440) { + //如果个性化之后的下班时间还是在第二天 + int tmp_shift_endworktime_index = shift_endworktime_index - 1440; + if(last_preworkIndex > -1){ + if(last_preworkIndex > tmp_shift_endworktime_index){ + Arrays.fill(initArrays, tmp_shift_endworktime_index, last_preworkIndex, -1); + }else{ + Arrays.fill(initArrays, last_preworkIndex, tmp_shift_endworktime_index, 1); + } + }else{ + Arrays.fill(initArrays, 0, tmp_shift_endworktime_index, 1); + } + }else{ + //如果个性化之后的下班时间不在第二天了,但是原始的下班时间还是在第二天,那么需要把这段时间给填补回来 + if(last_preworkIndex > -1){ + Arrays.fill(initArrays, 0, last_preworkIndex, -1); + } + } + } + + List preRestIndex = shiftInfoBean.getPreRestIndex(); + for(int i = 0 ;preRestIndex != null && i < preRestIndex.size() ; i++){ + //跨天休息时段填充2 + Arrays.fill(initArrays, preRestIndex.get(i)[0], preRestIndex.get(i)[1], 2); + } + //加班起算时间是必填项 + int startTimeMin = KQOvertimeRulesBiz.getStartTime(resourceid,preSplitDate); + startTimeMin = startTimeMin < 0 ? 0 : startTimeMin; + int lastWorkTimeIndex = preWorkAcrossIndexs[1]; + if(shift_endworktime_index > -1) { + if (shift_endworktime_index > 1440) { + //如果个性化之后的下班时间还是在第二天 + lastWorkTimeIndex = shift_endworktime_index - 1440; + }else{ + lastWorkTimeIndex = shift_endworktime_index; + } + } + //从下班时间到下班起算时间这段时间填充4 + Arrays.fill(initArrays, lastWorkTimeIndex, (lastWorkTimeIndex+startTimeMin), 4); + + int overMins = arrayComInfo.getCnt(initArrays, startIndex, firstWorkIndex, 0); + kqLog.info("handlePreWorkday:resourceid:"+resourceid+":startIndex:"+startIndex+":firstWorkIndex:"+firstWorkIndex+":overMins:"+overMins); + overMins = overMins > 0 ? overMins : 0; + //如果人再当前指定日期下未开启加班,直接跳过 + if(overtimeEnable != 1){ + overMins = 0; + kqLog.info("handlePreWorkday:resourceid:"+resourceid+":preSplitDate:"+preSplitDate+"不允许加班"); + } + if(overMins > 0){ + SplitBean preSplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + BeanUtils.copyProperties(splitBean, preSplitBean); + preSplitBean.setD_Mins(overMins); + preSplitBean.setBelongDate(preSplitDate); + preSplitBean.setFromTime(arrayComInfo.getTimesByArrayindex(startIndex)); + preSplitBean.setToTime(arrayComInfo.getTimesByArrayindex(firstWorkIndex)); + preSplitBean.setChangeType(2); + int computingMode = KQOvertimeRulesBiz.getComputingMode(preSplitBean.getResourceId(), preSplitDate); + preSplitBean.setComputingMode(""+computingMode); + fillNewBean(preSplitBean); + } + return firstWorkIndex; + }else{ + return -1; + } + } + + public void fillNewBean(SplitBean splitBean){ + getDurationByRule(splitBean); + splitBeans.add(splitBean); + //客户有的时候加班流程选择几年十几年的,这个日志会很大,屏蔽了吧 +// kqLog.info("getDurationByRule:splitBeans:"+JSON.toJSON(splitBeans)); + } + + /** + * 根据加班单位得到加班时长 + * @param splitBean + */ + public void getDurationByRule(SplitBean splitBean) { + double D_Mins = splitBean.getD_Mins(); + int workmins = splitBean.getWorkmins(); + String durationrule = splitBean.getDurationrule(); + if("3".equalsIgnoreCase(durationrule)){ + double d_hour = D_Mins/60.0; + splitBean.setDuration(KQDurationCalculatorUtil.getDurationRound5(""+d_hour)); + }else if("1".equalsIgnoreCase(durationrule)){ + double d_day = D_Mins/workmins; + splitBean.setDuration(KQDurationCalculatorUtil.getDurationRound5(""+d_day)); + } + } +} diff --git a/src/com/engine/kq/biz/chain/overtime/OvertimeHoliday2HolidayChain.java b/src/com/engine/kq/biz/chain/overtime/OvertimeHoliday2HolidayChain.java new file mode 100644 index 0000000..653cf03 --- /dev/null +++ b/src/com/engine/kq/biz/chain/overtime/OvertimeHoliday2HolidayChain.java @@ -0,0 +1,26 @@ +package com.engine.kq.biz.chain.overtime; + +import com.engine.kq.wfset.bean.SplitBean; +import java.util.List; +import java.util.Map; + +/** + * 如果前一天是节假日,当天是节假日的情况 + */ +public class OvertimeHoliday2HolidayChain extends OvertimeChain{ + + public OvertimeHoliday2HolidayChain(Map splitMap,List splitBeans) { + super(splitMap,splitBeans); + } + + @Override + public void handleOvertimeChain(SplitBean splitBean) throws Exception { + int changeType = splitBean.getChangeType(); + int preChangeType = splitBean.getPreChangeType(); + if(preChangeType == 1 && changeType == 1){ + doOverTimeSplit1(splitBean); + }else{ + this.success.handleOvertimeChain(splitBean); + } + } +} diff --git a/src/com/engine/kq/biz/chain/overtime/OvertimeHoliday2RestdayChain.java b/src/com/engine/kq/biz/chain/overtime/OvertimeHoliday2RestdayChain.java new file mode 100644 index 0000000..13520b7 --- /dev/null +++ b/src/com/engine/kq/biz/chain/overtime/OvertimeHoliday2RestdayChain.java @@ -0,0 +1,27 @@ +package com.engine.kq.biz.chain.overtime; + +import com.engine.kq.wfset.bean.SplitBean; +import java.util.List; +import java.util.Map; + +/** + * 如果前一天是节假日,当天是休息日的情况 + */ +public class OvertimeHoliday2RestdayChain extends OvertimeChain{ + + public OvertimeHoliday2RestdayChain(Map splitMap,List splitBeans) { + super(splitMap,splitBeans); + } + + @Override + public void handleOvertimeChain(SplitBean splitBean) throws Exception { + + int changeType = splitBean.getChangeType(); + int preChangeType = splitBean.getPreChangeType(); + if(preChangeType == 1 && changeType == 3){ + doOverTimeSplit3(splitBean); + }else{ + this.success.handleOvertimeChain(splitBean); + } + } +} diff --git a/src/com/engine/kq/biz/chain/overtime/OvertimeHoliday2WorkdayChain.java b/src/com/engine/kq/biz/chain/overtime/OvertimeHoliday2WorkdayChain.java new file mode 100644 index 0000000..2f633d5 --- /dev/null +++ b/src/com/engine/kq/biz/chain/overtime/OvertimeHoliday2WorkdayChain.java @@ -0,0 +1,154 @@ +package com.engine.kq.biz.chain.overtime; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQShiftRuleInfoBiz; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.bean.SplitBean; +import com.google.common.collect.Lists; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import org.springframework.beans.BeanUtils; +import weaver.general.Util; + +/** + * 如果前一天是节假日,当天是工作日的情况 + */ +public class OvertimeHoliday2WorkdayChain extends OvertimeChain{ + + public OvertimeHoliday2WorkdayChain(Map splitMap,List splitBeans) { + super(splitMap,splitBeans); + } + + @Override + public void handleOvertimeChain(SplitBean splitBean) throws Exception { + int changeType = splitBean.getChangeType(); + int preChangeType = splitBean.getPreChangeType(); + if(preChangeType == 1 && changeType == 2){ + doOverTimeSplit1_2(splitBean); + }else{ + this.success.handleOvertimeChain(splitBean); + } + } + + /** + * 工作日上班前的时间都属于前一天的节假日跨天加班 + * @param splitBean + */ + public void doOverTimeSplit1_2(SplitBean splitBean) throws Exception{ + + KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo(); + String resourceid = splitBean.getResourceId(); + String splitDate = splitBean.getBelongDate(); + String preSplitDate = splitMap.get("preSplitDate"); + int preComputingMode = KQOvertimeRulesBiz.getComputingMode(resourceid, preSplitDate); + + kqLog.info("OvertimeHoliday2WorkdayChain:resourceid:"+resourceid+":preComputingMode:"+preComputingMode); + if(preComputingMode == 3){ +// 前一天是无需审批,根据打卡时间计算加班时长,那么只需要按照普通的工作日加班处理就可以 + doOverTimeSplit2(splitBean); + }else{ + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate,true); + kqLog.info("OvertimeHoliday2WorkdayChain:resourceid:"+resourceid+":shiftInfoBean:"+ (shiftInfoBean != null ? JSON.toJSONString(shiftInfoBean): null) ); + if(shiftInfoBean != null){ + List workLongTimeIndex = shiftInfoBean.getWorkLongTimeIndex(); + List real_workLongTimeIndex = Lists.newArrayList(); + + //list带数组,这里要深拷贝 + for(int[] tmp : workLongTimeIndex){ + int[] real_tmp = new int[tmp.length]; + System.arraycopy(tmp, 0, real_tmp, 0, tmp.length); + real_workLongTimeIndex.add(real_tmp); + } + if(real_workLongTimeIndex.size() == 1){ + //个性化设置只支持一次打卡的 + KQShiftRuleInfoBiz kqShiftRuleInfoBiz = new KQShiftRuleInfoBiz(); + kqShiftRuleInfoBiz.rest_workLongTimeIndex(shiftInfoBean,splitBean,real_workLongTimeIndex,arrayComInfo,null); + } + if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){ + int firstWorkIndex = doOverTimePreHoliday(splitBean, arrayComInfo, real_workLongTimeIndex); + kqLog.info("OvertimeHoliday2WorkdayChain:resourceid:"+resourceid+":firstWorkIndex:"+firstWorkIndex); + handleCurWork(splitBean, arrayComInfo, shiftInfoBean, real_workLongTimeIndex,firstWorkIndex); + }else{ + doOverTimeSplit2(splitBean); + } + }else{ + doOverTimeSplit2(splitBean); + } + } + } + + /** + * 前一天是节假日,处理前一天节假日的跨天数据 + * @param splitBean + * @param arrayComInfo + * @param real_workLongTimeIndex + */ + public int doOverTimePreHoliday(SplitBean splitBean, KQTimesArrayComInfo arrayComInfo,List real_workLongTimeIndex){ + String resourceid = splitBean.getResourceId(); + String splitDate = splitBean.getBelongDate(); + String splitFromTime = splitBean.getFromTime(); + String splitToTime = splitBean.getToTime(); + int[] initArrays = arrayComInfo.getInitArr(); + int startIndex = arrayComInfo.getArrayindexByTimes(splitFromTime); + boolean shouldAcross = "1".equalsIgnoreCase(Util.null2String(splitMap.get("shouldAcross"))); + String preSplitDate = splitMap.get("preSplitDate"); + + int overtimeEnable = KQOvertimeRulesBiz.getOvertimeEnable(resourceid, preSplitDate); + + int endIndex = arrayComInfo.getArrayindexByTimes(splitToTime); + if(shouldAcross){ + endIndex = arrayComInfo.getArrayindexByTimes("24:00"); + } + int[] workIndexs = real_workLongTimeIndex.get(0); + //得到当天最早的上班时间,则从0-firstWorkIndex都属于前一天的加班 + int firstWorkIndex = workIndexs[0]; + + //先把要计算的时长填充上0 + Arrays.fill(initArrays, startIndex, endIndex, 0); + + List restTimeList = KQOvertimeRulesBiz.getRestTimeList(resourceid, preSplitDate); + + //再把休息时间填充上去 + if(!restTimeList.isEmpty()){ + for(int i =0 ; i < restTimeList.size() ; i++){ + String[] restTimes = restTimeList.get(i); + if(restTimes.length == 2){ + int restStart = arrayComInfo.getArrayindexByTimes(restTimes[0]); + int restEnd = arrayComInfo.getArrayindexByTimes(restTimes[1]); + if(shouldAcross && restEnd == 1439){ + //针对跨天的休息时段单独处理排除掉23:59-00:00的时间 + restEnd = 1440; + } + Arrays.fill(initArrays, restStart, restEnd, 1); + } + } + } + + int overMins = arrayComInfo.getCnt(initArrays, startIndex, firstWorkIndex, 0); + + overMins = overMins > 0 ? overMins : 0; + //如果人再当前指定日期下未开启加班,直接跳过 + if(overtimeEnable != 1){ + overMins= 0; + kqLog.info("doOverTimePreHoliday:resourceid:"+resourceid+":preSplitDate:"+preSplitDate+"不允许加班"); + } + if(overMins > 0){ + SplitBean preSplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + BeanUtils.copyProperties(splitBean, preSplitBean); + preSplitBean.setD_Mins(overMins); + preSplitBean.setBelongDate(preSplitDate); + preSplitBean.setChangeType(1); + int computingMode = KQOvertimeRulesBiz.getComputingMode(preSplitBean.getResourceId(), preSplitDate); + preSplitBean.setComputingMode(""+computingMode); + fillNewBean(preSplitBean); + } + + return firstWorkIndex; + } + +} diff --git a/src/com/engine/kq/biz/chain/overtime/OvertimeRestday2HolidayChain.java b/src/com/engine/kq/biz/chain/overtime/OvertimeRestday2HolidayChain.java new file mode 100644 index 0000000..643de54 --- /dev/null +++ b/src/com/engine/kq/biz/chain/overtime/OvertimeRestday2HolidayChain.java @@ -0,0 +1,26 @@ +package com.engine.kq.biz.chain.overtime; + +import com.engine.kq.wfset.bean.SplitBean; +import java.util.List; +import java.util.Map; + +/** + * 如果前一天是休息日,当天是节假日的情况 + */ +public class OvertimeRestday2HolidayChain extends OvertimeChain{ + + public OvertimeRestday2HolidayChain(Map splitMap,List splitBeans) { + super(splitMap,splitBeans); + } + + @Override + public void handleOvertimeChain(SplitBean splitBean) throws Exception { + int changeType = splitBean.getChangeType(); + int preChangeType = splitBean.getPreChangeType(); + if(preChangeType == 3 && changeType == 1){ + doOverTimeSplit1(splitBean); + }else{ + this.success.handleOvertimeChain(splitBean); + } + } +} diff --git a/src/com/engine/kq/biz/chain/overtime/OvertimeRestday2RestdayChain.java b/src/com/engine/kq/biz/chain/overtime/OvertimeRestday2RestdayChain.java new file mode 100644 index 0000000..5a62405 --- /dev/null +++ b/src/com/engine/kq/biz/chain/overtime/OvertimeRestday2RestdayChain.java @@ -0,0 +1,24 @@ +package com.engine.kq.biz.chain.overtime; + +import com.engine.kq.wfset.bean.SplitBean; +import java.util.List; +import java.util.Map; + +/** + * 如果前一天是休息日,当天是休息日的情况 + */ +public class OvertimeRestday2RestdayChain extends OvertimeChain{ + + public OvertimeRestday2RestdayChain(Map splitMap,List splitBeans) { + super(splitMap,splitBeans); + } + + @Override + public void handleOvertimeChain(SplitBean splitBean) throws Exception { + int changeType = splitBean.getChangeType(); + int preChangeType = splitBean.getPreChangeType(); + if(preChangeType == 3 && changeType == 3){ + doOverTimeSplit3(splitBean); + } + } +} diff --git a/src/com/engine/kq/biz/chain/overtime/OvertimeRestday2WorkdayChain.java b/src/com/engine/kq/biz/chain/overtime/OvertimeRestday2WorkdayChain.java new file mode 100644 index 0000000..97a1deb --- /dev/null +++ b/src/com/engine/kq/biz/chain/overtime/OvertimeRestday2WorkdayChain.java @@ -0,0 +1,158 @@ +package com.engine.kq.biz.chain.overtime; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQShiftRuleInfoBiz; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.bean.SplitBean; +import com.google.common.collect.Lists; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import org.springframework.beans.BeanUtils; +import weaver.general.Util; + +/** + * 如果前一天是休息日,当天是工作日的情况 + */ +public class OvertimeRestday2WorkdayChain extends OvertimeChain{ + + public OvertimeRestday2WorkdayChain(Map splitMap,List splitBeans) { + super(splitMap,splitBeans); + } + + @Override + public void handleOvertimeChain(SplitBean splitBean) throws Exception { + int changeType = splitBean.getChangeType(); + int preChangeType = splitBean.getPreChangeType(); + if(preChangeType == 3 && changeType == 2){ + doOverTimeSplit3_2(splitBean); + }else{ + this.success.handleOvertimeChain(splitBean); + } + } + + /** + * 工作日上班前的时间都属于前一天的休息日跨天加班 + * @param splitBean + */ + public void doOverTimeSplit3_2(SplitBean splitBean) throws Exception{ + + KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo(); + String resourceid = splitBean.getResourceId(); + String splitDate = splitBean.getBelongDate(); + String preSplitDate = splitMap.get("preSplitDate"); + int preComputingMode = KQOvertimeRulesBiz.getComputingMode(resourceid, preSplitDate); + + kqLog.info("OvertimeRestday2WorkdayChain doOverTimeSplit3_2:resourceid:"+resourceid+":preComputingMode:"+preComputingMode); + if(preComputingMode == 3){ +// 前一天是无需审批,根据打卡时间计算加班时长,那么只需要按照普通的工作日加班处理就可以 + doOverTimeSplit2(splitBean); + }else{ + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate,true); + kqLog.info("OvertimeRestday2WorkdayChain doOverTimeSplit3_2:resourceid:"+resourceid+":shiftInfoBean:"+(shiftInfoBean != null ? JSON + .toJSONString(shiftInfoBean) : null)); + + if(shiftInfoBean != null){ + List workLongTimeIndex = shiftInfoBean.getWorkLongTimeIndex(); + List real_workLongTimeIndex = Lists.newArrayList(); + + //list带数组,这里要深拷贝 + for(int[] tmp : workLongTimeIndex){ + int[] real_tmp = new int[tmp.length]; + System.arraycopy(tmp, 0, real_tmp, 0, tmp.length); + real_workLongTimeIndex.add(real_tmp); + } + if(real_workLongTimeIndex.size() == 1){ + //个性化设置只支持一次打卡的 + KQShiftRuleInfoBiz kqShiftRuleInfoBiz = new KQShiftRuleInfoBiz(); + kqShiftRuleInfoBiz.rest_workLongTimeIndex(shiftInfoBean,splitBean,real_workLongTimeIndex,arrayComInfo,null); + } + if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){ + int firstWorkIndex = doOverTimePreRestday(splitBean, arrayComInfo, real_workLongTimeIndex); + kqLog.info("OvertimeRestday2WorkdayChain doOverTimeSplit3_2:resourceid:"+resourceid+":firstWorkIndex:"+firstWorkIndex); + handleCurWork(splitBean, arrayComInfo, shiftInfoBean, real_workLongTimeIndex, + firstWorkIndex); + }else{ + doOverTimeSplit2(splitBean); + } + }else{ + doOverTimeSplit2(splitBean); + } + } + } + + /** + * 前一天是休息日,处理前一天休息日的跨天数据 + * @param splitBean + * @param arrayComInfo + * @param workIndex + */ + public int doOverTimePreRestday(SplitBean splitBean,KQTimesArrayComInfo arrayComInfo,List workIndex){ + String resourceid = splitBean.getResourceId(); + String splitDate = splitBean.getBelongDate(); + String splitFromTime = splitBean.getFromTime(); + String splitToTime = splitBean.getToTime(); + int[] initArrays = arrayComInfo.getInitArr(); + int startIndex = arrayComInfo.getArrayindexByTimes(splitFromTime); + boolean shouldAcross = "1".equalsIgnoreCase(Util.null2String(splitMap.get("shouldAcross"))); + String preSplitDate = splitMap.get("preSplitDate"); + + int overtimeEnable = KQOvertimeRulesBiz.getOvertimeEnable(resourceid, preSplitDate); + + int endIndex = arrayComInfo.getArrayindexByTimes(splitToTime); + if(shouldAcross){ + endIndex = arrayComInfo.getArrayindexByTimes("24:00"); + } + int[] workIndexs = workIndex.get(0); + //得到当天最早的上班时间,则从0-firstWorkIndex都属于前一天的加班 + int firstWorkIndex = workIndexs[0]; + + //先把要计算的时长填充上0 + Arrays.fill(initArrays, startIndex, endIndex, 0); + + List restTimeList = KQOvertimeRulesBiz.getRestTimeList(resourceid, preSplitDate); + + //再把休息时间填充上去 + if(!restTimeList.isEmpty()){ + for(int i =0 ; i < restTimeList.size() ; i++){ + String[] restTimes = restTimeList.get(i); + if(restTimes.length == 2){ + int restStart = arrayComInfo.getArrayindexByTimes(restTimes[0]); + int restEnd = arrayComInfo.getArrayindexByTimes(restTimes[1]); + if(shouldAcross && restEnd == 1439){ + //针对跨天的休息时段单独处理排除掉23:59-00:00的时间 + restEnd = 1440; + } + Arrays.fill(initArrays, restStart, restEnd, 1); + } + } + } + + int overMins = arrayComInfo.getCnt(initArrays, startIndex, firstWorkIndex, 0); + + overMins = overMins > 0 ? overMins : 0; + //如果人再当前指定日期下未开启加班,直接跳过 + if(overtimeEnable != 1){ + overMins =0; + kqLog.info("doOverTimePreRestday:resourceid:"+resourceid+":preSplitDate:"+preSplitDate+"不允许加班"); + } + if(overMins > 0){ + SplitBean preSplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + BeanUtils.copyProperties(splitBean, preSplitBean); + preSplitBean.setD_Mins(overMins); + preSplitBean.setBelongDate(preSplitDate); + preSplitBean.setChangeType(3); + preSplitBean.setFromTime(arrayComInfo.getTimesByArrayindex(startIndex)); + preSplitBean.setToTime(arrayComInfo.getTimesByArrayindex(firstWorkIndex)); + int computingMode = KQOvertimeRulesBiz.getComputingMode(preSplitBean.getResourceId(), preSplitDate); + preSplitBean.setComputingMode(""+computingMode); + fillNewBean(preSplitBean); + } + + return firstWorkIndex; + } +} diff --git a/src/com/engine/kq/biz/chain/overtime/OvertimeWorkday2HolidayChain.java b/src/com/engine/kq/biz/chain/overtime/OvertimeWorkday2HolidayChain.java new file mode 100644 index 0000000..8430420 --- /dev/null +++ b/src/com/engine/kq/biz/chain/overtime/OvertimeWorkday2HolidayChain.java @@ -0,0 +1,68 @@ +package com.engine.kq.biz.chain.overtime; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.bean.SplitBean; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import org.springframework.beans.BeanUtils; +import weaver.general.Util; + +/** + * 如果前一天是工作日,当天是节假日的情况 + */ +public class OvertimeWorkday2HolidayChain extends OvertimeChain{ + + public OvertimeWorkday2HolidayChain(Map splitMap,List splitBeans) { + super(splitMap,splitBeans); + } + + @Override + public void handleOvertimeChain(SplitBean splitBean) throws Exception { + int changeType = splitBean.getChangeType(); + int preChangeType = splitBean.getPreChangeType(); + if(preChangeType == 2 && changeType == 1){ + doOverTimeSplit2_1(splitBean); + }else{ + this.success.handleOvertimeChain(splitBean); + } + } + + /** + * 前一天是工作日,今天是节假日的情况,存在前一天工作日跨天的情况 + */ + public void doOverTimeSplit2_1(SplitBean splitBean) { + KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo(); + + String resourceid = splitBean.getResourceId(); + String splitDate = splitBean.getBelongDate(); + String preSplitDate = splitMap.get("preSplitDate"); + int preComputingMode = KQOvertimeRulesBiz.getComputingMode(resourceid, preSplitDate); + kqLog.info("OvertimeWorkday2HolidayChain doOverTimeSplit2_1:resourceid:"+resourceid+":preComputingMode:"+preComputingMode); + + if(preComputingMode == 3){ +// 前一天是无需审批,根据打卡时间计算加班时长,那么只需要按照普通的节假日加班处理就可以 + doOverTimeSplit1(splitBean); + }else{ + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate,true); + kqLog.info("OvertimeWorkday2HolidayChain doOverTimeSplit2_1:resourceid:"+resourceid+":shiftInfoBean:"+(shiftInfoBean != null ? JSON.toJSONString(shiftInfoBean) : null)); + + if(shiftInfoBean != null){ + int firstWorkIndex = handlePreWorkday(splitBean, arrayComInfo, shiftInfoBean); + kqLog.info("OvertimeWorkday2HolidayChain doOverTimeSplit2_1:resourceid:"+resourceid+":firstWorkIndex:"+firstWorkIndex); + if(firstWorkIndex >= 0){ + handleCurHoliday(splitBean, arrayComInfo, firstWorkIndex); + } + }else{ + //前一天工作日为null 直接视为普通的节假日加班 + doOverTimeSplit1(splitBean); + } + } + + } + +} diff --git a/src/com/engine/kq/biz/chain/overtime/OvertimeWorkday2RestdayChain.java b/src/com/engine/kq/biz/chain/overtime/OvertimeWorkday2RestdayChain.java new file mode 100644 index 0000000..d53c9e0 --- /dev/null +++ b/src/com/engine/kq/biz/chain/overtime/OvertimeWorkday2RestdayChain.java @@ -0,0 +1,64 @@ +package com.engine.kq.biz.chain.overtime; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.bean.SplitBean; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import weaver.general.Util; + +/** + * 如果前一天是工作日,当天是休息日的情况 + */ +public class OvertimeWorkday2RestdayChain extends OvertimeChain{ + + public OvertimeWorkday2RestdayChain(Map splitMap,List splitBeans) { + super(splitMap,splitBeans); + } + + @Override + public void handleOvertimeChain(SplitBean splitBean) throws Exception { + int changeType = splitBean.getChangeType(); + int preChangeType = splitBean.getPreChangeType(); + if(preChangeType == 2 && changeType == 3){ + doOverTimeSplit2_3(splitBean); + }else{ + this.success.handleOvertimeChain(splitBean); + } + } + + public void doOverTimeSplit2_3(SplitBean splitBean) { + + KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo(); + + String resourceid = splitBean.getResourceId(); + String splitDate = splitBean.getBelongDate(); + String preSplitDate = splitMap.get("preSplitDate"); + int preComputingMode = KQOvertimeRulesBiz.getComputingMode(resourceid, preSplitDate); + + kqLog.info("OvertimeWorkday2RestdayChain doOverTimeSplit2_3:resourceid:"+resourceid+":preComputingMode:"+preComputingMode); + if(preComputingMode == 3){ +// 前一天是无需审批,根据打卡时间计算加班时长,那么只需要按照普通的休息日加班处理就可以 + doOverTimeSplit3(splitBean); + }else{ + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate,true); + kqLog.info("OvertimeWorkday2RestdayChain doOverTimeSplit2_3:resourceid:"+resourceid+":shiftInfoBean:"+(shiftInfoBean != null ? JSON + .toJSONString(shiftInfoBean) : null)); + + if(shiftInfoBean != null) { + int firstWorkIndex = handlePreWorkday(splitBean, arrayComInfo, shiftInfoBean); + if(firstWorkIndex >= 0){ + handleCurRestday(splitBean, arrayComInfo, firstWorkIndex); + } + }else{ + //前一天工作日为null 直接视为普通的休息日加班 + doOverTimeSplit3(splitBean); + } + + } + } +} diff --git a/src/com/engine/kq/biz/chain/overtime/OvertimeWorkday2WorkdayChain.java b/src/com/engine/kq/biz/chain/overtime/OvertimeWorkday2WorkdayChain.java new file mode 100644 index 0000000..0178b26 --- /dev/null +++ b/src/com/engine/kq/biz/chain/overtime/OvertimeWorkday2WorkdayChain.java @@ -0,0 +1,85 @@ +package com.engine.kq.biz.chain.overtime; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQShiftRuleInfoBiz; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.bean.SplitBean; +import com.google.common.collect.Lists; +import java.util.List; +import java.util.Map; + +/** + * 如果前一天是工作日,当天是工作日的情况 + */ +public class OvertimeWorkday2WorkdayChain extends OvertimeChain{ + + public OvertimeWorkday2WorkdayChain(Map splitMap,List splitBeans) { + super(splitMap,splitBeans); + } + + @Override + public void handleOvertimeChain(SplitBean splitBean) throws Exception { + int changeType = splitBean.getChangeType(); + int preChangeType = splitBean.getPreChangeType(); + if(preChangeType == 2 && changeType == 2){ + doOverTimeSplit2_2(splitBean); + }else{ + this.success.handleOvertimeChain(splitBean); + } + } + + public void doOverTimeSplit2_2(SplitBean splitBean) throws Exception { + KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo(); + + String resourceid = splitBean.getResourceId(); + String splitDate = splitBean.getBelongDate(); + String preSplitDate = splitMap.get("preSplitDate"); + + int preComputingMode = KQOvertimeRulesBiz.getComputingMode(resourceid, preSplitDate); + + kqLog.info("OvertimeWorkday2WorkdayChain doOverTimeSplit2_2:resourceid:"+resourceid+":preComputingMode:"+preComputingMode); + if(preComputingMode == 3){ +// 无需审批,根据打卡时间计算加班时长 + splitBean.setD_Mins(0.0); + splitBean.setComputingMode(preComputingMode+""); + return ; + }else{ + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate,true); + kqLog.info("OvertimeWorkday2WorkdayChain doOverTimeSplit2_2:resourceid:"+resourceid+":shiftInfoBean:"+(shiftInfoBean != null ? JSON + .toJSONString(shiftInfoBean) : null)); + + if(shiftInfoBean != null){ + List workLongTimeIndex = shiftInfoBean.getWorkLongTimeIndex(); + List real_workLongTimeIndex = Lists.newArrayList(); + + //list带数组,这里要深拷贝 + for(int[] tmp : workLongTimeIndex){ + int[] real_tmp = new int[tmp.length]; + System.arraycopy(tmp, 0, real_tmp, 0, tmp.length); + real_workLongTimeIndex.add(real_tmp); + } + if(real_workLongTimeIndex.size() == 1){ + //个性化设置只支持一次打卡的 + KQShiftRuleInfoBiz kqShiftRuleInfoBiz = new KQShiftRuleInfoBiz(); + kqShiftRuleInfoBiz.rest_workLongTimeIndex(shiftInfoBean,splitBean,real_workLongTimeIndex,arrayComInfo,null); + } + int curFirstTimeIndex = handlePreWork(splitBean, arrayComInfo, shiftInfoBean,real_workLongTimeIndex); + kqLog.info("OvertimeWorkday2WorkdayChain doOverTimeSplit2_2:resourceid:"+resourceid+":curFirstTimeIndex:"+curFirstTimeIndex); + if(curFirstTimeIndex >= 0){ + handleCurWork(splitBean, arrayComInfo, shiftInfoBean, real_workLongTimeIndex, + curFirstTimeIndex); + }else{ + kqLog.info("doOverTimeSplit2_2,工作日加班shiftInfoBean为null:resourceid:"+resourceid+":splitDate:"+splitDate); + } + }else{ + //前一天工作日为null 直接视为普通的工作日加班 + doOverTimeSplit2(splitBean); + } + } + + + } +} diff --git a/src/com/engine/kq/biz/chain/shiftinfo/DurationIndex.java b/src/com/engine/kq/biz/chain/shiftinfo/DurationIndex.java new file mode 100644 index 0000000..b971f3a --- /dev/null +++ b/src/com/engine/kq/biz/chain/shiftinfo/DurationIndex.java @@ -0,0 +1,83 @@ +package com.engine.kq.biz.chain.shiftinfo; + +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.util.Map; + +/** + * 针对时长计算的基类 + */ +public abstract class DurationIndex { + + protected DurationIndex success; //定义下一个处理对象 + protected String name ; //定义下一个对象的名字 + protected KQTimesArrayComInfo arrayComInfo ; //每个地方都会用到的缓存类 + protected KQLog kqLog = new KQLog(); + /** + * 工作区间 里面含有工作时段 + */ + protected Map dateWorkTimeMap; + + public DurationIndex(String name,KQTimesArrayComInfo arrayComInfo,Map dateWorkTimeMap) { + this.name=name; + this.arrayComInfo=arrayComInfo; + this.dateWorkTimeMap=dateWorkTimeMap; + } + //创建链 + public void setDuration(DurationIndex durationIndex) { + this.success=durationIndex; + } + public abstract void handleDuration(ShiftInfoBean shiftInfoBean) ; + + /** + * 按天请假 + * @param workmins + * @param mins + * @return + */ + public String minimumUnit1(int workmins, int mins) { + + if(workmins > 0 && mins > 0){ + double days = 0.0; + days = mins/(workmins*1.0); + days = days > 0 ? days : 0.0; + + return KQDurationCalculatorUtil.getDurationRound(""+(days)); + }else{ + return ""; + } + } + + /** + * 按小时请假 + * @param mins + * @return + */ + public String minimumUnit3(int mins) { + if(mins > 0){ + double hours = mins/60.0; + return KQDurationCalculatorUtil.getDurationRound(""+(hours)); + }else{ + return ""; + } + } + + /** + * 根据最终的index生成分钟这时长 + * @param workmins + * @param mins + * @param minimumUnit + */ + public String handleDurationMins(int workmins, int mins,String minimumUnit){ + String duration = ""; + //计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假 + //按照天和小时的可以在这里计算,半天的和整天的单独处理 + if("1".equalsIgnoreCase(minimumUnit)){ + duration = minimumUnit1(workmins,mins); + }else if("3".equalsIgnoreCase(minimumUnit)){ + duration = minimumUnit3(mins); + } + return duration; + } +} diff --git a/src/com/engine/kq/biz/chain/shiftinfo/OverTimeDurationIndex.java b/src/com/engine/kq/biz/chain/shiftinfo/OverTimeDurationIndex.java new file mode 100644 index 0000000..cc949f0 --- /dev/null +++ b/src/com/engine/kq/biz/chain/shiftinfo/OverTimeDurationIndex.java @@ -0,0 +1,240 @@ +package com.engine.kq.biz.chain.shiftinfo; + +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import org.apache.commons.collections.map.HashedMap; +import weaver.general.Util; + +/** + * 工作日 加班用的计算类 + */ +public class OverTimeDurationIndex extends DurationIndex { + + public OverTimeDurationIndex(String name,KQTimesArrayComInfo arrayComInfo,Map dateWorkTimeMap){ + super(name,arrayComInfo,dateWorkTimeMap); + } + + @Override + public void handleDuration(ShiftInfoBean shiftInfoBean) { + + String minimumUnit = shiftInfoBean.getMinimumUnit(); + + int[] initArrays = arrayComInfo.getInitArr(); + Map cntMap = handleArray(initArrays,shiftInfoBean); + + if(!cntMap.isEmpty()){ + handleDurationMins(shiftInfoBean,cntMap,minimumUnit); + } + } + + /** + * 根据数组和下标得到分钟数 + * @param initArrays + * @param shiftInfoBean + * @return + */ + private Map handleArray(int[] initArrays, ShiftInfoBean shiftInfoBean) { + String splitFromTime = shiftInfoBean.getSplitFromTime(); + String splitToTime = shiftInfoBean.getSplitToTime(); + int flowSplitStartIndex = arrayComInfo.getArrayindexByTimes(splitFromTime); + int flowSplitEndIndex = arrayComInfo.getArrayindexByTimes(splitToTime); + String splitDate = shiftInfoBean.getSplitDate(); + String preSplitDate = shiftInfoBean.getPreSplitDate(); + + int overMins = 0; + Map cntMap = new HashedMap(); + +// 1、先把流程填充到数组里 + Arrays.fill(initArrays, flowSplitStartIndex, flowSplitEndIndex, 0); + kqLog.info("OverTimeDurationIndex:flowSplitStartIndex:"+flowSplitStartIndex+":flowSplitEndIndex:"+flowSplitEndIndex+":cnt:"+arrayComInfo.getCnt(initArrays, 0, 1440, 0)); + + int finalEndTime = fillNonPreWorkIndex(preSplitDate,initArrays,shiftInfoBean); + +// 2、再把工作时段填充到数组里 + fillNonWorkIndex(splitDate,initArrays,shiftInfoBean,finalEndTime); + + // 3、需要排除休息时段(前一天和当天的),所以还需要把休息时段也填充到数组里 + fillNonPreRestIndex(splitDate,initArrays,shiftInfoBean); + + fillNonRestIndex(splitDate,initArrays,shiftInfoBean); + + //在一整天的数组里,先把流程赋值,再用工作时段填充覆盖掉流程,那么未被覆盖的流程时段就是在非工作时段里的 + overMins = arrayComInfo.getCnt(initArrays, 0, 1440, 0); + + cntMap.put("overMins", overMins); + shiftInfoBean.setD_Mins(Util.getDoubleValue(""+overMins)); + + return cntMap; + } + + /** + * 排除掉加班里的休息时段 + * @param splitDate + * @param initArrays + * @param shiftInfoBean + */ + private void fillNonRestIndex(String splitDate, int[] initArrays, ShiftInfoBean shiftInfoBean) { + List restIndex = shiftInfoBean.getRestIndex(); + for(int i = 0 ; i < restIndex.size() ; i++){ + int[] restIndexTmp = restIndex.get(i); + int reststartIndex = restIndexTmp[0]; + int restendIndex = restIndexTmp[1]; + Arrays.fill(initArrays, reststartIndex, restendIndex, -1); + } + } + + /** + * 排除掉前一天加班里的休息时段 + * @param preSplitDate + * @param initArrays + * @param shiftInfoBean + */ + private void fillNonPreRestIndex(String preSplitDate, int[] initArrays, ShiftInfoBean shiftInfoBean) { + List preRestIndex = shiftInfoBean.getPreRestIndex(); + for(int i = 0 ; i < preRestIndex.size() ; i++){ + int[] preRestIndexTmp = preRestIndex.get(i); + int reststartIndex = preRestIndexTmp[0]; + int restendIndex = preRestIndexTmp[1]; + Arrays.fill(initArrays, reststartIndex, restendIndex, -1); + } + } + + /** + * 根据加班规则重新填充 前一天的加班时长数据 + * @param preSplitDate + * @param initArrays + * @param shiftInfoBean + */ + private int fillNonPreWorkIndex(String preSplitDate, int[] initArrays, ShiftInfoBean shiftInfoBean) { + int startTime = 0; + //记录前一天班次跨到今天的最晚时间 + int finalEndTime = 0; + //这个是跨到今天的工作时段 + List preWorkIndex = shiftInfoBean.getPreWorkIndex(); + if(!preWorkIndex.isEmpty()){ + String resourceid = Util.null2String(dateWorkTimeMap.get("resourceid")); + startTime = KQOvertimeRulesBiz.getStartTime(resourceid,preSplitDate); + startTime = startTime < 0 ? 0 : startTime; + + //取跨到今天的最后一次下班时间 + int[] workIndexTmp = preWorkIndex.get(preWorkIndex.size()-1); + //如果设置了最后一次下班后才能加班 + if(startTime > -1){ + if(workIndexTmp != null){ + //workIndexTmp[1]最晚下班时间+startTime + finalEndTime = workIndexTmp[1]+startTime; + Arrays.fill(initArrays, 0, finalEndTime, 2); + } + }else{ + kqLog.info("OverTimeDurationIndex:fillNonPreWorkIndex:加班起算时间未填写:resourceid:"+resourceid+":preSplitDate:"+preSplitDate+":startTime:"+startTime); + } + } + return finalEndTime; + } + + /** + * 根据加班规则重新填充 当天的加班时长数据 + * @param splitDate + * @param initArrays + * @param shiftInfoBean + * @param finalEndTime + */ + private void fillNonWorkIndex(String splitDate,int[] initArrays,ShiftInfoBean shiftInfoBean,int finalEndTime) { + int startTime = 0; + //工作时段的最晚时间 + int finalStartTime = 0; + List workIndex = shiftInfoBean.getWorkIndex(); + List workAcrossIndex = shiftInfoBean.getWorkAcrossIndex(); + if(!workIndex.isEmpty()){ + String resourceid = Util.null2String(dateWorkTimeMap.get("resourceid")); + //加班起算时间是必填项 + startTime = KQOvertimeRulesBiz.getStartTime(resourceid,splitDate); + startTime = startTime < 0 ? 0 : startTime; + //如果设置了最后一次下班后才能加班 + if(startTime > -1){ + //最早的上班时间 + int[] workIndexTmp0 = workIndex.get(0); + + //不跨天时段最后一次下班时间 + int[] workIndexTmp = workIndex.get(workIndex.size()-1); + //跨天时段最后一次下班时间 + int[] workAcrossIndexTmp = workAcrossIndex.get(workAcrossIndex.size()-1); + //如果这两个值相等,表示不跨天 + if(workIndexTmp[1] == workAcrossIndexTmp[1]){ + finalStartTime = workIndexTmp[1] + startTime; + if(finalStartTime > 1439){ + //最后一次下班后多久允许加班在第二天 + finalStartTime = 1439; + } + Arrays.fill(initArrays, workIndexTmp0[0], finalStartTime, 1); + + kqLog.info("不跨天OverTimeDurationIndex:fillNonWorkIndex:workIndexTmp0[0]:"+workIndexTmp0[0]+":finalStartTime:"+finalStartTime+":startTime:"+startTime+":cnt:"+arrayComInfo.getCnt(initArrays, 0, 1440, 1)); + + }else{ + //如果不一致,表示跨天了,最后一次下班时间不在今天在第二天 + //这种情况下,表示今天从最早的上班时间到23:59这段时间都不算加班 + Arrays.fill(initArrays, workIndexTmp0[0], workIndexTmp[1], 1); + kqLog.info("跨天OverTimeDurationIndex:fillNonWorkIndex:workIndexTmp0[0]:"+workIndexTmp0[0]+":workIndexTmp[1]:"+workIndexTmp[1]+":startTime:"+startTime+":cnt:"+arrayComInfo.getCnt(initArrays, 0, 1440, 1)); + } + }else{ + kqLog.info("OverTimeDurationIndex:fillNonWorkIndex:加班起算时间未填写:resourceid:"+resourceid+":splitDate:"+splitDate+":startTime:"+startTime); + } + } + } + + /** + * 根据最终的index生成分钟这时长 + * @param shiftInfoBean + * @param cntMap + * @param minimumUnit + */ + private void handleDurationMins(ShiftInfoBean shiftInfoBean,Map cntMap,String minimumUnit){ + //计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假 + //按照天和小时的可以在这里计算,半天的和整天的单独处理 + if("1".equalsIgnoreCase(minimumUnit)){ + minimumUnit1(shiftInfoBean,cntMap); + }else if("3".equalsIgnoreCase(minimumUnit)){ + minimumUnit3(shiftInfoBean); + } + } + + /** + * 获取加班单位的工作日日折算时长 + * @param shiftInfoBean + * @param cntMap + * @return + */ + private void minimumUnit1(ShiftInfoBean shiftInfoBean, Map cntMap) { + int workmins = shiftInfoBean.getWorkmins(); + //分别得到前一个工作时段的小时数和当前时段的分钟数数 + int overMins = cntMap.get("overMins") != null ? cntMap.get("overMins") : 0; + + double curDays = 0.0; + double D_Mins = 0.0; + + if(workmins > 0){ + curDays = overMins/(workmins*1.0); + curDays = curDays > 0.0 ? curDays : 0.0; + D_Mins = Util.getDoubleValue(""+overMins); + } + shiftInfoBean.setDuration(KQDurationCalculatorUtil.getDurationRound(""+(curDays))); + shiftInfoBean.setD_Mins(D_Mins); + } + + /** + * 按小时请假 + * @param shiftInfoBean + * @return + */ + private double minimumUnit3(ShiftInfoBean shiftInfoBean) { + double D_Mins = shiftInfoBean.getD_Mins(); + double hours = D_Mins/60.0; + hours = hours > 0.0 ? hours : 0.0; + shiftInfoBean.setDuration(KQDurationCalculatorUtil.getDurationRound(""+(hours))); + return hours; + } +} diff --git a/src/com/engine/kq/biz/chain/shiftinfo/ShiftInfoBean.java b/src/com/engine/kq/biz/chain/shiftinfo/ShiftInfoBean.java new file mode 100644 index 0000000..85311c0 --- /dev/null +++ b/src/com/engine/kq/biz/chain/shiftinfo/ShiftInfoBean.java @@ -0,0 +1,804 @@ +package com.engine.kq.biz.chain.shiftinfo; + +import com.engine.kq.entity.TimeScopeEntity; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 1、首先有个KQTimesArrayComInfo缓存类,这个类把00:00-23:59的时间点都转换成了0-1439的数值 + * 我把这个数值视作下标index + * + * 2、假如班次设置的工作时段是 + * 8:00-12:00 + * 13:00-18:00 + * 22:00-次日4:00 + * + * 3、... + * + * 4、那么restTimes表示的就是休息时段15:00-16:00对应的数组下标{[100,200]},举个栗子而已 + * + * 5、那么workIndex表示的就是休息时段8:00-12:00...对应的数组下标{[50,80],[90,180],[250,280]},workIndexTime存的就是时间点举个栗子而已 + * + * 6、那么halfWorkIndex表示的就是半天规则情况下需要用到的数组下标 + * 上面的例子里的工作时长的15个小时,所以半天的话,需要从8:00-16:30,只要是满足小于这个范围段内的都是半天,大于的就是1天了 + * halfWorkIndex对应的数组下标就是{[50,70]},halfWorkIndexTime存的就是时间点举个栗子而已 + * + * 7、那么wholeWorkIndex表示的就是整天规则情况下需要用到的数组下标,我只需要知道workIndex就可以了。wholeWorkIndexTime存的就是时间点 + * + */ +public class ShiftInfoBean { + /** + * 指定开始时间 + */ + private String splitFromTime; + /** + * 指定结束时间 + */ + private String splitToTime; + + /** + * 指定日期 因为流程时段区间已经被拆分成一天一条了 + */ + private String splitDate; + /** + * 要返回当天的工作时间区间对应的数组下标 这个是不包含跨天的 + */ + private List workIndex; + + /** + * 要返回当天的工作时间区间对应的数组下标 这个是包含跨天的 + */ + private List workAcrossIndex; + + /** + * 要返回当天的工作时间区间对应的时间 这个是包含跨天的 + */ + private List workAcrossTime; + + /** + * 当天打卡时段时间:多少分钟可以开始签到签退的 + */ + private List workMinsAcrossIndex; + /** + * 要返回的休息时间区间对应的数组下标 不包含跨天 + */ + private List restIndex; + /** + * 要返回的休息时间区间对应的数组下标 包含跨天的 + */ + private List restAcrossIndex; + /** + * 要返回的半天规则时间区间对应的数组下标 + * 这里有值的话是三个,最早的开始时间 中间时间 最晚的下班时间 + */ + private List halfWorkIndex; + + /** + * 工作时长 + */ + private int workmins; + + private int signoutOnlyoff; + + /** + * 加班用的前日期是何种类型 + */ + private int changeType; + + /** + * 当前日期的班次 + */ + private String serialid; + + /** + * 指定日期的前一天,因为存在跨天,昨天数据可能也需要在今天统计 + */ + private String preSplitDate; + + /** + * 这个返回的是前一天的班次存在跨天,跨到今天的工作时段区间 + */ + private List preWorkIndex; + + /** + * 要返回前一天天的工作时间区间对应的数组下标 这个是包含跨天的 + */ + private List preWorkAcrossIndex; + + /** + * 要返回前一天打卡时段信息:多少分钟可以开始签到签退的 + */ + private List preWorkMinsAcrossIndex; + + /** + * 映射前一天的跨天和时间区间下标 + */ + private Map preWorktimeAcrossMap; + /** + * 要返回前一天的休息时间区间对应的数组下标 + */ + private List preRestIndex; + /** + * 要返回的前一天的半天规则时间区间对应的数组下标 + * 这里有值的话是三个,开始时间 中间时间 下班时间 + */ + private List preHalfWorkIndex; + + /** + * 前一天的工作时长 + */ + private int preWorkmins; + + /** + * 前一个日期的班次 + */ + private String preSerialid; + + /** + * 得到实际时长分钟数 + */ + private double D_Mins; + + /** + * 流程判断的各种规则 + * 半天小时的 + */ + private String minimumUnit; + + /** + * 流程用的时候存的值 + */ + private String duration; + + /** + * 针对时段跨天 流程跨天的情况,23:59-24:00差一分钟的处理 + */ + private String oneMoreMinute; + + /** + * 当前时间段 + */ + private int[] curMins; + + /** + * 当前时间段 + */ + private int[] preMins; + + /** + * 存储所有的工作时间 + */ + private List allWorkTime; + + /** + * 存储所有的跨天时间 + */ + private List allAcrossWorkTime; + /** + * 存储所有的休息时间 + */ + private List allRestTime; + + /** + * 存储所有的休息时间 + */ + private List allAcrossRestTime; + + + + /** + * 存储所有的工作时间 + */ + private List preAllWorkTime; + + /** + * 存储所有的跨天时间 + */ + private List preAllAcrossWorkTime; + /** + * 存储所有的休息时间 + */ + private List preAllRestTime; + + /** + * 存储所有的休息时间 + */ + private List preAllAcrossRestTime; + + /** + * 是否是自由班製 + */ + private boolean isfree; + /** + * 自由班制签到开始时间 + */ + private String freeSignStart; + /** + * 自由班制工作时长 + */ + private String freeWorkMins; + /** + * 自由班制应该签退时间 + */ + private String freeSignEnd; + /** + * 自由班制 半天中间点 + */ + private String freeSignMiddle; + + + /** + * 当前班次作为当前班次存在,在0-48小时内的工作时段下标 + */ + private List workLongTimeIndex; + + /** + * 当前班次作为当前班次存在,在0-48小时内的工作时段下标 + */ + private List restLongTimeIndex; + + /** + * 存储所有的工作时间 48小时制休息时段 + */ + private List allLongWorkTime; + + /** + * 判断当前班次是否存在跨天 + */ + private String isAcross; + + /** + * 判断前一天班次是否存在跨天 + */ + private String isPreAcross; + + private Map shiftRuleMap; + + /** + * 和kqformdate里的workTimeEntity用到的保持一致 + */ + private List signTime;//允许打卡时间 + /** + * 和kqformdate里的workTimeEntity用到的保持一致 + */ + private List workTime;//工作时间 + + /** + * 半天计算规则 + */ + private String halfcalrule; + + /** + * 自定义 半天计算规则 时间点 + */ + private String halfcalpoint; + + private String halfcalpoint2cross; + + /** + * 存储每一段工作时段内的工作时长 + */ + private List eachWorkMins; + /** + * 是否是非工作日 1表示是非工作日班次 + */ + private int restShift; + + /** + * 昨天应出勤折算天数 + */ + private String preConvertAttendDay = ""; + + /** + * 应出勤折算天数 + */ + private String convertAttendDay = ""; + + public ShiftInfoBean() { + this.splitFromTime = ""; + this.splitToTime = ""; + this.splitDate = ""; + this.workIndex = new ArrayList<>(); + this.workAcrossIndex = new ArrayList<>(); + this.restIndex = new ArrayList<>(); + this.restAcrossIndex = new ArrayList<>(); + this.halfWorkIndex = new ArrayList<>(); + this.workmins = 0; + this.signoutOnlyoff = 0; + this.preSplitDate = ""; + this.preWorkIndex = new ArrayList<>(); + this.preWorkAcrossIndex = new ArrayList<>(); + this.preWorktimeAcrossMap = new HashMap<>(); + this.preRestIndex = new ArrayList<>(); + this.preHalfWorkIndex = new ArrayList<>(); + this.preWorkmins = 0; + this.D_Mins = 0.0; + this.minimumUnit = ""; + this.duration = ""; + this.oneMoreMinute = ""; + this.preWorkMinsAcrossIndex = new ArrayList<>(); + this.workMinsAcrossIndex = new ArrayList<>(); + this.preSerialid = ""; + this.serialid = ""; + this.workAcrossTime = new ArrayList<>(); + this.isfree = false; + this.freeSignStart = ""; + this.freeWorkMins = ""; + this.freeSignEnd = ""; + this.freeSignMiddle = ""; + + this.workLongTimeIndex = new ArrayList<>(); + this.restLongTimeIndex = new ArrayList<>(); + this.allLongWorkTime = new ArrayList<>(); + this.isAcross = ""; + this.isPreAcross = ""; + this.shiftRuleMap = Maps.newHashMap(); + this.workTime = Lists.newArrayList(); + this.signTime = Lists.newArrayList(); + this.halfcalrule = ""; + this.halfcalpoint = ""; + this.halfcalpoint2cross = ""; + this.eachWorkMins = new ArrayList<>(); + } + + public String getSplitDate() { + return splitDate; + } + + public void setSplitDate(String splitDate) { + this.splitDate = splitDate; + } + + public String getSplitFromTime() { + return splitFromTime; + } + + public void setSplitFromTime(String splitFromTime) { + this.splitFromTime = splitFromTime; + } + + public String getSplitToTime() { + return splitToTime; + } + + public void setSplitToTime(String splitToTime) { + this.splitToTime = splitToTime; + } + + public List getWorkIndex() { + return workIndex; + } + + public void setWorkIndex(List workIndex) { + this.workIndex = workIndex; + } + + public List getRestIndex() { + return restIndex; + } + + public void setRestIndex(List restIndex) { + this.restIndex = restIndex; + } + + public List getHalfWorkIndex() { + return halfWorkIndex; + } + + public void setHalfWorkIndex(List halfWorkIndex) { + this.halfWorkIndex = halfWorkIndex; + } + + public double getD_Mins() { + return D_Mins; + } + + public void setD_Mins(double d_Mins) { + D_Mins = d_Mins; + } + + public String getPreSplitDate() { + return preSplitDate; + } + + public void setPreSplitDate(String preSplitDate) { + this.preSplitDate = preSplitDate; + } + + public List getPreWorkIndex() { + return preWorkIndex; + } + + public void setPreWorkIndex(List preWorkIndex) { + this.preWorkIndex = preWorkIndex; + } + + public List getWorkAcrossIndex() { + return workAcrossIndex; + } + + public void setWorkAcrossIndex(List workAcrossIndex) { + this.workAcrossIndex = workAcrossIndex; + } + + public int getWorkmins() { + return workmins; + } + + public void setWorkmins(int workmins) { + this.workmins = workmins; + } + + public int getSignoutOnlyoff() { + return signoutOnlyoff; + } + + public void setSignoutOnlyoff(int signoutOnlyoff) { + this.signoutOnlyoff = signoutOnlyoff; + } + + public String getMinimumUnit() { + return minimumUnit; + } + + public void setMinimumUnit(String minimumUnit) { + this.minimumUnit = minimumUnit; + } + + public List getPreHalfWorkIndex() { + return preHalfWorkIndex; + } + + public void setPreHalfWorkIndex(List preHalfWorkIndex) { + this.preHalfWorkIndex = preHalfWorkIndex; + } + + public List getPreWorkAcrossIndex() { + return preWorkAcrossIndex; + } + + public void setPreWorkAcrossIndex(List preWorkAcrossIndex) { + this.preWorkAcrossIndex = preWorkAcrossIndex; + } + + public Map getPreWorktimeAcrossMap() { + return preWorktimeAcrossMap; + } + + public void setPreWorktimeAcrossMap( + Map preWorktimeAcrossMap) { + this.preWorktimeAcrossMap = preWorktimeAcrossMap; + } + + public List getPreRestIndex() { + return preRestIndex; + } + + public void setPreRestIndex(List preRestIndex) { + this.preRestIndex = preRestIndex; + } + + public int getPreWorkmins() { + return preWorkmins; + } + + public void setPreWorkmins(int preWorkmins) { + this.preWorkmins = preWorkmins; + } + + public List getRestAcrossIndex() { + return restAcrossIndex; + } + + public void setRestAcrossIndex(List restAcrossIndex) { + this.restAcrossIndex = restAcrossIndex; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getOneMoreMinute() { + return oneMoreMinute; + } + + public void setOneMoreMinute(String oneMoreMinute) { + this.oneMoreMinute = oneMoreMinute; + } + + public List getWorkMinsAcrossIndex() { + return workMinsAcrossIndex; + } + + public void setWorkMinsAcrossIndex(List workMinsAcrossIndex) { + this.workMinsAcrossIndex = workMinsAcrossIndex; + } + + public List getPreWorkMinsAcrossIndex() { + return preWorkMinsAcrossIndex; + } + + public void setPreWorkMinsAcrossIndex(List preWorkMinsAcrossIndex) { + this.preWorkMinsAcrossIndex = preWorkMinsAcrossIndex; + } + + public String getSerialid() { + return serialid; + } + + public void setSerialid(String serialid) { + this.serialid = serialid; + } + + public String getPreSerialid() { + return preSerialid; + } + + public void setPreSerialid(String preSerialid) { + this.preSerialid = preSerialid; + } + + public int[] getCurMins() { + return curMins; + } + + public void setCurMins(int[] curMins) { + this.curMins = curMins; + } + + public int[] getPreMins() { + return preMins; + } + + public void setPreMins(int[] preMins) { + this.preMins = preMins; + } + + public List getWorkAcrossTime() { + return workAcrossTime; + } + + public void setWorkAcrossTime(List workAcrossTime) { + this.workAcrossTime = workAcrossTime; + } + + public int getChangeType() { + return changeType; + } + + public void setChangeType(int changeType) { + this.changeType = changeType; + } + + public List getAllWorkTime() { + return allWorkTime; + } + + public void setAllWorkTime(List allWorkTime) { + this.allWorkTime = allWorkTime; + } + + public List getAllAcrossWorkTime() { + return allAcrossWorkTime; + } + + public void setAllAcrossWorkTime(List allAcrossWorkTime) { + this.allAcrossWorkTime = allAcrossWorkTime; + } + + public List getAllRestTime() { + return allRestTime; + } + + public void setAllRestTime(List allRestTime) { + this.allRestTime = allRestTime; + } + + public List getAllAcrossRestTime() { + return allAcrossRestTime; + } + + public void setAllAcrossRestTime(List allAcrossRestTime) { + this.allAcrossRestTime = allAcrossRestTime; + } + + public List getPreAllWorkTime() { + return preAllWorkTime; + } + + public void setPreAllWorkTime(List preAllWorkTime) { + this.preAllWorkTime = preAllWorkTime; + } + + public List getPreAllAcrossWorkTime() { + return preAllAcrossWorkTime; + } + + public void setPreAllAcrossWorkTime(List preAllAcrossWorkTime) { + this.preAllAcrossWorkTime = preAllAcrossWorkTime; + } + + public List getPreAllRestTime() { + return preAllRestTime; + } + + public void setPreAllRestTime(List preAllRestTime) { + this.preAllRestTime = preAllRestTime; + } + + public List getPreAllAcrossRestTime() { + return preAllAcrossRestTime; + } + + public void setPreAllAcrossRestTime(List preAllAcrossRestTime) { + this.preAllAcrossRestTime = preAllAcrossRestTime; + } + + public boolean isIsfree() { + return isfree; + } + + public void setIsfree(boolean isfree) { + this.isfree = isfree; + } + + public String getFreeSignStart() { + return freeSignStart; + } + + public void setFreeSignStart(String freeSignStart) { + this.freeSignStart = freeSignStart; + } + + public String getFreeWorkMins() { + return freeWorkMins; + } + + public void setFreeWorkMins(String freeWorkMins) { + this.freeWorkMins = freeWorkMins; + } + + public String getFreeSignEnd() { + return freeSignEnd; + } + + public void setFreeSignEnd(String freeSignEnd) { + this.freeSignEnd = freeSignEnd; + } + + public String getFreeSignMiddle() { + return freeSignMiddle; + } + + public void setFreeSignMiddle(String freeSignMiddle) { + this.freeSignMiddle = freeSignMiddle; + } + + public List getWorkLongTimeIndex() { + return workLongTimeIndex; + } + + public void setWorkLongTimeIndex(List workLongTimeIndex) { + this.workLongTimeIndex = workLongTimeIndex; + } + + public List getRestLongTimeIndex() { + return restLongTimeIndex; + } + + public void setRestLongTimeIndex(List restLongTimeIndex) { + this.restLongTimeIndex = restLongTimeIndex; + } + + public List getAllLongWorkTime() { + return allLongWorkTime; + } + + public void setAllLongWorkTime(List allLongWorkTime) { + this.allLongWorkTime = allLongWorkTime; + } + + public String getIsAcross() { + return isAcross; + } + + public void setIsAcross(String isAcross) { + this.isAcross = isAcross; + } + + public String getIsPreAcross() { + return isPreAcross; + } + + public void setIsPreAcross(String isPreAcross) { + this.isPreAcross = isPreAcross; + } + + public Map getShiftRuleMap() { + return shiftRuleMap; + } + + public void setShiftRuleMap(Map shiftRuleMap) { + this.shiftRuleMap = shiftRuleMap; + } + + public List getSignTime() { + return signTime; + } + + public void setSignTime(List signTime) { + this.signTime = signTime; + } + + public List getWorkTime() { + return workTime; + } + + public void setWorkTime(List workTime) { + this.workTime = workTime; + } + + public String getHalfcalrule() { + return halfcalrule; + } + + public void setHalfcalrule(String halfcalrule) { + this.halfcalrule = halfcalrule; + } + + public List getEachWorkMins() { + return eachWorkMins; + } + + public void setEachWorkMins(List eachWorkMins) { + this.eachWorkMins = eachWorkMins; + } + + public String getHalfcalpoint() { + return halfcalpoint; + } + + public void setHalfcalpoint(String halfcalpoint) { + this.halfcalpoint = halfcalpoint; + } + + public String getHalfcalpoint2cross() { + return halfcalpoint2cross; + } + + public void setHalfcalpoint2cross(String halfcalpoint2cross) { + this.halfcalpoint2cross = halfcalpoint2cross; + } + + public int getRestShift() { + return restShift; + } + + public void setRestShift(int restShift) { + this.restShift = restShift; + } + + public String getConvertAttendDay() { + return convertAttendDay; + } + + public void setConvertAttendDay(String convertAttendDay) { + this.convertAttendDay = convertAttendDay; + } + + public String getPreConvertAttendDay() { + return preConvertAttendDay; + } + + public void setPreConvertAttendDay(String preConvertAttendDay) { + this.preConvertAttendDay = preConvertAttendDay; + } +} diff --git a/src/com/engine/kq/cmd/abnormalremind/GetAbnormalremindConditionCmd.java b/src/com/engine/kq/cmd/abnormalremind/GetAbnormalremindConditionCmd.java new file mode 100644 index 0000000..f3b9a87 --- /dev/null +++ b/src/com/engine/kq/cmd/abnormalremind/GetAbnormalremindConditionCmd.java @@ -0,0 +1,66 @@ +package com.engine.kq.cmd.abnormalremind; + +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.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetAbnormalremindConditionCmd extends AbstractCommonCommand> { + + public GetAbnormalremindConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String ismobile = Util.null2String(params.get("ismobile")); + + ConditionFactory conditionFactory = new ConditionFactory(user); + List addGroups = new ArrayList(); + List addItems = new ArrayList(); + + //考勤异常对象 + SearchConditionItem searchConditionItemUser = conditionFactory.createCondition(ConditionType.BROWSER, 16048 , "abnormalResourceName","1"); + addItems.add(searchConditionItemUser); + + //提醒内容 + SearchConditionItem searchConditionItemText = conditionFactory.createCondition(ConditionType.INPUT, 27415 , "content"); + addItems.add(searchConditionItemText); + + + /* + SearchConditionItem searchConditionItemBeginTime = conditionFactory.createCondition(ConditionType.DATEPICKER, 740, "fromDate"); + addItems.add(searchConditionItemBeginTime); + + SearchConditionItem searchConditionItemEntTime = conditionFactory.createCondition(ConditionType.DATEPICKER, 1323, "toDate"); + addItems.add(searchConditionItemEntTime); + */ + + addGroups.add(new SearchConditionGroup(SystemEnv.getHtmlLabelName(15774,weaver.general.Util.getIntValue(user.getLanguage())),true,addItems)); + + if("1".equals(ismobile)){ + retmap.put("conditions",addItems); + }else { + retmap.put("condition",addGroups); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/abnormalremind/GetAbnormalremindInfoCmd.java b/src/com/engine/kq/cmd/abnormalremind/GetAbnormalremindInfoCmd.java new file mode 100644 index 0000000..db71847 --- /dev/null +++ b/src/com/engine/kq/cmd/abnormalremind/GetAbnormalremindInfoCmd.java @@ -0,0 +1,128 @@ +package com.engine.kq.cmd.abnormalremind; + +import com.api.hrm.util.PageUidFactory; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import org.apache.commons.lang.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.common.database.dialect.DialectUtil; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +public class GetAbnormalremindInfoCmd extends AbstractCommonCommand> { + + public GetAbnormalremindInfoCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet recordSet = new RecordSet(); + boolean isOracle = recordSet.getDBType().equals("oracle") || recordSet.getDBType().equals("postgresql"); + String mysqlEscope = "/"; + String keyword = Util.null2String(params.get("keyword"));//考勤人员姓名 + + + + String abnormalResourceName = Util.null2String(params.get("abnormalResourceName"));//人员id + String receiver = Util.null2String(params.get("receiver"));//人员id + String content = Util.null2String(params.get("content"));//人员id + String fromDate = Util.null2String(params.get("fromDate"));//人员id + String toDate = Util.null2String(params.get("toDate"));//人员id + String uuid = Util.null2String(params.get("uuid"));//人员id + String sqlwhere =" where 1=1 "; + + if (!"".equals(abnormalResourceName)) { + sqlwhere += " and a.resourceid = " + abnormalResourceName ; + } + + if (!"".equals(uuid)) { + sqlwhere += " and a.uuid = '" + uuid +"'"; + } + + //4、提醒内容 + if (StringUtils.isNotBlank(content)) { + sqlwhere += " and a.content like '%" + content + "%'"; + } + + //非管理员只能查看自己收到的提醒数据 + if(!user.isAdmin()){ + if(!"".equals(receiver) && user.getUID() != Integer.parseInt(receiver)){ + sqlwhere += " and a.receiverId = 0 "; + } else { + sqlwhere += " and a.receiverid = " + user.getUID(); + } + }else { + if(!"".equals(receiver)){ + sqlwhere += " and a.receiverId = "+receiver; + } + } + if (StringUtils.isNotBlank(keyword)) { + if (DialectUtil.isMySql()) { + sqlwhere += " and a.resourceid in (select id from hrmresource where lastname like '%" + Util.StringReplace(keyword, "_", mysqlEscope + "_") +"%' )"; + } else { + sqlwhere += " and a.resourceid in (select id from hrmresource where lastname like '%" + Util.StringReplace(keyword, "_", "\\_") +"%' )"; + } + } + + + if (!fromDate.equals("")) { + if (isOracle) { + sqlwhere += " and to_date(a.sendTime,'YYYY-MM-DD') >= to_date('" + fromDate + "','YYYY-MM-DD')"; + } else { + sqlwhere += " and a.sendTime >= '" + fromDate + "'"; + } + } + if (!toDate.equals("")) { + if (isOracle) { + sqlwhere += " and to_date(a.sendTime,'YYYY-MM-DD') <= to_date('" + toDate + "','YYYY-MM-DD')"; + } else { + sqlwhere += " and a.sendTime <= '" + toDate + "'"; + } + } + + try { + + String tabletype="checkbox"; + String backfields = " * "; + String fromSql = " from abnormalremindmsg_log a "; + String orderby = " id " ; + String pageUid = PageUidFactory.getHrmPageUid("abnormalremindmsgList"); + String tableString =" "+ + " "+ + " "+ + " "+ + " " + + " " + + " " + + " "+ + " "+ + "
"; + + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + retmap.put("sessionkey", sessionkey); + + retmap.put("status", "1"); + } catch (Exception e) { + writeLog("获取考勤异常提醒信息失败:" + e); + retmap.put("status", "-1"); + retmap.put("message","system error"); + } + return retmap; + } +} diff --git a/src/com/engine/kq/cmd/attendanceButton/ButtonStatusEnum.java b/src/com/engine/kq/cmd/attendanceButton/ButtonStatusEnum.java new file mode 100644 index 0000000..e25494e --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/ButtonStatusEnum.java @@ -0,0 +1,34 @@ +package com.engine.kq.cmd.attendanceButton; + +public enum ButtonStatusEnum { + NORMAL("NORMAL","0"),//正常 + BELATE("BELATE","1"),//迟到 + LEAVEERALY("LEAVEERALY","2"),//早退 + ABSENT("ABSENT","3"),//旷工 + NOSIGN("NOSIGN","4"),//漏签 + NOSIGN_ON("NOSIGN_ON","44");//上班漏签 + + private String statusName; + private String statusCode; + + private ButtonStatusEnum(String statusName,String statusCode) { + this.statusName = statusName; + this.statusCode = statusCode; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getStatusCode() { + return statusCode; + } + + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } +} diff --git a/src/com/engine/kq/cmd/attendanceButton/GetAutoEMSetCmd.java b/src/com/engine/kq/cmd/attendanceButton/GetAutoEMSetCmd.java new file mode 100644 index 0000000..7e4cd65 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/GetAutoEMSetCmd.java @@ -0,0 +1,159 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQAutoCheckComInfo; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.log.KQLog; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import weaver.common.DateUtil; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; +import weaver.upgradetool.wscheck.Util; + +/** + * EM端自动打卡设置界面 + */ +public class GetAutoEMSetCmd extends AbstractCommonCommand> { + private KQLog kqLog = new KQLog(); + private HttpServletRequest request; + private HttpServletResponse response; + + public GetAutoEMSetCmd(Map params, User user) { + this.request = request; + this.user = user; + this.params = params; + this.response = response; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + String resourceId = ""+user.getUID(); + String curDate = DateUtil.getCurrentDate(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, curDate); + boolean can_auto_checkin = false; + boolean can_auto_checkout = false; + String auto_checkin = "0"; + String auto_checkout = "0"; + boolean can_set = false; + if(groupId.length() > 0){ + auto_checkin = Util.null2String(kqGroupComInfo.getAuto_checkin(groupId)); + auto_checkout = Util.null2String(kqGroupComInfo.getAuto_checkout(groupId)); + if(auto_checkin.length() > 0 && auto_checkout.length() > 0){ + if("1".equalsIgnoreCase(auto_checkin) || "1".equalsIgnoreCase(auto_checkout)){ + //只要自动打卡开了一个就可以 + can_set = true; + } + if("1".equalsIgnoreCase(auto_checkin)){ + can_auto_checkin = true; + } + if("1".equalsIgnoreCase(auto_checkout)){ + can_auto_checkout = true; + } + } + } + if(!can_set){ + retmap.put("status", "1"); + retmap.put("can_set", "0"); + return retmap; + }else{ + retmap.put("can_set", "1"); + } + KQAutoCheckComInfo kqAutoCheckComInfo = new KQAutoCheckComInfo(); + String cus_auto_checkin = Util.null2String(kqAutoCheckComInfo.getAuto_checkin(resourceId)); + String cus_auto_checkout = Util.null2String(kqAutoCheckComInfo.getAuto_checkout(resourceId)); + if(cus_auto_checkin.length() > 0){ + auto_checkin = cus_auto_checkin; + } + if(cus_auto_checkout.length() > 0){ + auto_checkout = cus_auto_checkout; + } + + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("auto_checkin"); + hrmFieldBean.setFieldlabel("518736"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(auto_checkin); + if(can_auto_checkin){ + lsField.add(hrmFieldBean); + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("auto_checkin_desc"); + hrmFieldBean.setFieldlabel("518736"); + hrmFieldBean.setFieldhtmltype("8"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(SystemEnv.getHtmlLabelName(518800, user.getLanguage())); + if(can_auto_checkin){ + lsField.add(hrmFieldBean); + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("auto_checkout"); + hrmFieldBean.setFieldlabel("518738"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(auto_checkout); + if(can_auto_checkout){ + lsField.add(hrmFieldBean); + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("auto_checkout_desc"); + hrmFieldBean.setFieldlabel("518736"); + hrmFieldBean.setFieldhtmltype("8"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(SystemEnv.getHtmlLabelName(518801, user.getLanguage())); + if(can_auto_checkout){ + lsField.add(hrmFieldBean); + } + + List> grouplist = new ArrayList>(); + Map groupitem = new HashMap(); + List itemlist = new ArrayList<>(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + + for (int j = 0; j < lsField.size(); j++) { + hrmFieldBean = lsField.get(j); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + + retmap.put("formField", grouplist); + retmap.put("status", "1"); + return retmap; + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/GetButtonBaseInfoCmd.java b/src/com/engine/kq/cmd/attendanceButton/GetButtonBaseInfoCmd.java new file mode 100644 index 0000000..898d431 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/GetButtonBaseInfoCmd.java @@ -0,0 +1,272 @@ +package com.engine.kq.cmd.attendanceButton; + +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.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.entity.KQGroupEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import com.engine.portal.biz.constants.ModuleConstants; +import com.engine.portal.biz.nonstandardfunction.SysModuleInfoBiz; +import com.google.common.collect.Maps; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 获取考勤组的基本信息的 + */ +public class GetButtonBaseInfoCmd extends AbstractCommonCommand> { + public KQLog kqLog = new KQLog(); + private DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + private DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + private DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + private DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + private DateTimeFormatter fullTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + private Map logMap = Maps.newHashMap(); + private Map workTimeEntityLogMap = Maps.newHashMap(); + + public GetButtonBaseInfoCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try { + + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + + String ismobile = Util.null2String(params.get("ismobile")); + + String lastname = user.getLastname(); + String messagerurl = resourceComInfo.getMessagerUrls("" + user.getUID()); + String shortname = ""; + + boolean USERICONLASTNAME = Util.null2String(new BaseBean().getPropValue("Others", "USERICONLASTNAME")).equals("1"); + if (USERICONLASTNAME && (messagerurl.indexOf("icon_w_wev8.jpg") > -1 || messagerurl.indexOf("icon_m_wev8.jpg") > -1 || messagerurl.indexOf("dummyContact.png") > -1)) { + shortname = User.getLastname(Util.null2String(Util.formatMultiLang(lastname, "" + user.getLanguage()))); + } + String curDate = DateUtil.getCurrentDate(); + LocalDateTime now = LocalDateTime.now(); + String now_date = now.format(dateFormatter); + String now_time = now.format(fullTimeFormatter); + GetButtonsCmd getButtonsCmd = new GetButtonsCmd(params, user); + LocalDateTime now_zone = getButtonsCmd.getZoneOfClientDateTime(now_date, now_time, logMap); + if (now_zone != null) { + curDate = now_zone.format(dateFormatter); + } + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(user.getUID() + "", curDate); + String userinfo = "#userid#" + user.getUID() + "#getUserSubCompany1#" + user.getUserSubCompany1() + "#getUserSubCompany1#" + user.getUserDepartment() + + "#getJobtitle#" + user.getJobtitle(); + workTimeEntityLogMap.put("resourceid", userinfo); + workTimeEntityLogMap.put("splitDate", curDate); + workTimeEntityLogMap.put("workTimeEntity", workTimeEntity); + + String groupid = workTimeEntity.getGroupId(); + String groupname = ""; + String locationshowaddress = Util.null2String(kqGroupComInfo.getLocationshowaddress(groupid));//是否记录统一地址 + String locationfacecheck = Util.null2String(kqGroupComInfo.getLocationfacecheck(groupid));//办公地点启用人脸识别拍照打卡 + String locationfacechecktype = Util.null2String(kqGroupComInfo.getLocationfacechecktype(groupid));//办公地点启用人脸识别拍照打卡方式 + String wififacecheck = Util.null2String(kqGroupComInfo.getWififacecheck(groupid));//wifi启用人脸识别拍照打卡 + String wififacechecktype = Util.null2String(kqGroupComInfo.getWififacechecktype(groupid));//wifi启用人脸识别拍照打卡方式 + if (groupid.length() > 0) { + groupname = SystemEnv.getHtmlLabelName(10000801, Util.getIntValue(user.getLanguage())) + kqGroupComInfo.getGroupname(groupid); + } else { + groupname = SystemEnv.getHtmlLabelName(10000799, Util.getIntValue(user.getLanguage())); + retmap.put("showbutton", "0"); + groupid = "0"; + } + logMap.put("locationshowaddress", locationshowaddress); + logMap.put("locationfacecheck", locationfacecheck); + logMap.put("locationfacechecktype", locationfacechecktype); + logMap.put("wififacecheck", wififacecheck); + logMap.put("wififacechecktype", wififacechecktype); + logMap.put("groupid", groupid); + + retmap.put("groupid", groupid); + if (user == null) { + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + retmap.put("userid", 1); + return retmap; + } + kqLog.info(user.getLastname() + ":GetButtonBaseInfoCmd:params:" + params); + + logMap.put("lastname", user.getLastname()); + logMap.put("params", params); + + boolean isAdmin = user.isAdmin(); + logMap.put("isAdmin", isAdmin); + if (isAdmin) { + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + retmap.put("userid", user.getUID()); + KQCardLogBiz.logCardInfo(user.getUID() + "", logMap, workTimeEntityLogMap, "buttonBaseInfo"); + return retmap; + } +// * 1、PC和移动端均可打卡 +// * 2、仅PC可打卡 +// * 3、仅移动端可打卡 +// * 4、无需打卡 + String groupSignType = getSignType(); + logMap.put("groupSignType", groupSignType); + //无需打卡 + if ("4".equalsIgnoreCase(groupSignType)) { + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + retmap.put("userid", user.getUID()); + KQCardLogBiz.logCardInfo(user.getUID() + "", logMap, workTimeEntityLogMap, "buttonBaseInfo"); + return retmap; + } + if ("2".equalsIgnoreCase(groupSignType)) { + if ("1".equalsIgnoreCase(ismobile)) { + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + retmap.put("userid", user.getUID()); + KQCardLogBiz.logCardInfo(user.getUID() + "", logMap, workTimeEntityLogMap, "buttonBaseInfo"); + return retmap; + } + } + if ("3".equalsIgnoreCase(groupSignType)) { + if (!"1".equalsIgnoreCase(ismobile)) { + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + retmap.put("userid", user.getUID()); + KQCardLogBiz.logCardInfo(user.getUID() + "", logMap, workTimeEntityLogMap, "buttonBaseInfo"); + return retmap; + } + } + String self_shift = "0"; + if(kqGroupComInfo.getKqtype(groupid).equalsIgnoreCase("2")&&kqGroupComInfo.getSelf_shift(groupid).equalsIgnoreCase("1")){ + List lsSerialDatas = new ArrayList<>(); + Map data = Maps.newHashMap(); + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + List serialids = new ArrayList<>(); + + String serialidStr = Util.null2String(kQGroupComInfo.getSerialids(groupid)); + if(serialidStr.length() > 0){ + KQShiftScheduleComInfo kqShiftScheduleComInfo = new KQShiftScheduleComInfo(); + kqShiftScheduleComInfo.setFormat(true); + String serialid = Util.null2String(kqShiftScheduleComInfo.getSerialId(user.getUID()+"",curDate)); + serialids = Util.splitString2List(serialidStr,","); + serialids.add("-1"); + for(int i=0;i(); + data.put("key", i); + if(serialid.length() > 0 ){ + if(tmp_serialid.equalsIgnoreCase(serialid)){ + data.put("selected", true); + }else{ + data.put("selected", false); + } + }else{ + data.put("selected", false); + } + data.put("serialid",serialids.get(i)); + if("-1".equalsIgnoreCase(tmp_serialid)){ + //休息日 必有 + data.put("name",SystemEnv.getHtmlLabelNames("26593", user.getLanguage())); + }else{ + data.put("name",shiftManagementToolKit.getShiftOnOffWorkSections(serialids.get(i),user.getLanguage())); + } + lsSerialDatas.add(data); + } + } + retmap.put("lsSerialDatas", lsSerialDatas); + } + + retmap.put("hasCrmModule", SysModuleInfoBiz.checkModuleStatus(ModuleConstants.Crm)); + + retmap.put("userid", user.getUID()); + retmap.put("lastname", lastname); + retmap.put("shortname", shortname); + retmap.put("messagerurl", messagerurl); + + retmap.put("groupname", groupname); + retmap.put("groupid", groupid); + retmap.put("locationshowaddress", locationshowaddress); + retmap.put("locationfacecheck", locationfacecheck); + retmap.put("locationfacechecktype", locationfacechecktype); + retmap.put("wififacecheck", wififacecheck); + retmap.put("wififacechecktype", wififacechecktype); + retmap.put("date", curDate); + retmap.put("timemillis", System.currentTimeMillis()); + retmap.put("wificheck", Util.null2String(kqGroupComInfo.getWificheck(groupid)).equals("1")); + retmap.put("locationcheck", Util.null2String(kqGroupComInfo.getLocationcheck(groupid)).equals("1")); + retmap.put("locationcheckscope", Util.null2String(kqGroupComInfo.getLocationcheckscope(groupid))); + retmap.put("isPhotoPunchEnabled", Util.null2String(kqGroupComInfo.getIsPhotoPunchEnabled(groupid)).equals("1")); + + String user_last_map = get_user_last_map(user.getUID() + ""); + logMap.put("user_last_map", user_last_map); + if (user_last_map.length() > 0) { + retmap.put("user_last_map", user_last_map); + } + + retmap.put("isFirstLocation", KQSettingsBiz.isFirstLocation() ? "1" : "0"); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + kqLog.info(user.getLastname() + ":GetButtonBaseInfoCmd:retmap:" + retmap); + logMap.put("result", retmap); + KQCardLogBiz.logCardInfo(user.getUID() + "", logMap, workTimeEntityLogMap, "buttonBaseInfo"); + return retmap; + } + + /** + * 获取当前用户选择的地图 + * + * @param userid + */ + public static String get_user_last_map(String userid) { + RecordSet rs = new RecordSet(); + String sql = "select * from user_last_map where userid = ? "; + rs.executeQuery(sql, userid); + if (rs.next()) { + return rs.getString("last_map"); + } + return ""; + } + + /** + * 获取考勤组的考勤方式 + * 1、PC和移动端均可打卡 + * 2、仅PC可打卡 + * 3、仅移动端可打卡 + */ + private String getSignType() { + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID() + ""); + if (kqGroupEntity == null) { + return ""; + } + return kqGroupEntity.getSignintype(); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/GetButtonsCmd.java b/src/com/engine/kq/cmd/attendanceButton/GetButtonsCmd.java new file mode 100644 index 0000000..869c69d --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/GetButtonsCmd.java @@ -0,0 +1,1719 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.alibaba.fastjson.JSON; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.KQHrmScheduleSign; +import com.engine.kq.biz.*; +import com.engine.kq.entity.KQGroupEntity; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.google.common.collect.Maps; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.dateformat.DateTransformer; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 获取签到签退按钮 + * 以及考勤流程数据 + * 以及上次签到时间 + */ +public class GetButtonsCmd extends AbstractCommonCommand> { + + private KQLog kqLog = new KQLog(); + private String curDate = DateUtil.getCurrentDate(); + private LocalDateTime now = LocalDateTime.now(); + private DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + private DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + private DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + private DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + private DateTimeFormatter fullTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + private Map logMap = Maps.newHashMap(); + private Map workTimeEntityLogMap = Maps.newHashMap(); + + public GetButtonsCmd(Map params, User user) { + this.user = user; + this.params = params; + String now_date = now.format(dateFormatter); + String now_time = now.format(fullTimeFormatter); + LocalDateTime now_zone = getZoneOfClientDateTime(now_date,now_time, logMap); + if(now_zone != null){ + setNow(now_zone); + setCurDate(now_zone.format(dateFormatter)); + } + } + + /** + * 一个完整的timelines里map的样子 + * { + * across: "0" 是否是次日 + * active: "1" 是否是允许签到签退的范围 + * belongdate: "2018-12-27" 根据班次获取的所属日期 + * canSignTime: "2018-12-27 00:00:00" 允许签到签退的时间范围 + * date: "2018-12-27" 签到签退的日期 + * datetime: "2018-12-27 08:30:00" 签到签退日期+上下班时间 + * isYellow: "1" 当前时间是否已经是迟到或者早退 + * isacross: "0" 当前时间对应的班次是否是跨天班次 + * islastsign: "0" 是否是最后一次签退 + * min: "0" 允许打卡时段控制 + * needSign: "1" 是否可以签到签退,在active的基础上增加了hrmschedulesign签到签退数据的判断 + * pre: "0" 是否是昨日 + * serialid: "521" 班次id + * signsection: "2018-12-27 00:00:00#2018-12-27 14:00:00" 允许签到签退的范围 + * time: "08:30" 上班时间/下班时间 + * type: "on" 对应的是签到还是签退的状态 + * workdatesection: "2018-12-27 08:30:00#2018-12-27 11:30:00" 上下班日期时段 + * worksection: "08:30-11:30" 上下班时间 + * } + * @param commandContext + * @return + */ + @Override + public Map execute(CommandContext commandContext) { + logMap.put("lastname", user.getLastname()); + logMap.put("params", params); + kqLog.info(user.getLastname()+":GetButtonsCmd:params:"+params); + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + curDate = getCurDate(); + //真正的考勤时间线 + List timelineList = new ArrayList<>(); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + KQReportBiz kqReportBiz = new KQReportBiz(); + + String lastname = user.getLastname(); + String messagerurl = resourceComInfo.getMessagerUrls(""+user.getUID()); + String shortname = ""; + //自由切换班次 + String serialid = Util.null2String(params.get("serialid")); + String ismobile = Util.null2String(params.get("ismobile")); + + boolean USERICONLASTNAME = Util.null2String(new BaseBean().getPropValue("Others" , "USERICONLASTNAME")).equals("1"); + if(USERICONLASTNAME&&(messagerurl.indexOf("icon_w_wev8.jpg")>-1||messagerurl.indexOf("icon_m_wev8.jpg")>-1||messagerurl.indexOf("dummyContact.png")>-1)){ + shortname = User.getLastname(Util.null2String(Util.formatMultiLang(lastname, ""+user.getLanguage()))); + } + + int signoutOnlyoff = 0; + String groupname = ""; + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(user.getUID()+"", curDate); + signoutOnlyoff = null !=workTimeEntity?workTimeEntity.getSignoutOnlyoff():0; + String userinfo = "#userid#"+user.getUID()+"#getUserSubCompany1#"+user.getUserSubCompany1()+"#getUserSubCompany1#"+user.getUserDepartment() + +"#getJobtitle#"+user.getJobtitle(); + workTimeEntityLogMap.put("resourceid", userinfo); + workTimeEntityLogMap.put("splitDate", curDate); + workTimeEntityLogMap.put("workTimeEntity", workTimeEntity); + String groupid = workTimeEntity.getGroupId(); + logMap.put("groupid", groupid); + String outsidesign = ""; + KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID()+""); + String kqGroupEntityInfo = kqGroupEntity != null ? JSON.toJSONString(kqGroupEntity): ""; + logMap.put("kqGroupEntityInfo", kqGroupEntityInfo); + if (kqGroupEntity != null) { + outsidesign = kqGroupEntity.getOutsidesign(); + }else{ + groupname = SystemEnv.getHtmlLabelName(10000799, Util.getIntValue(user.getLanguage())); + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + retmap.put("groupname", groupname); + KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "buttons"); + return retmap; + } + + boolean isAdmin = user.isAdmin(); + if(isAdmin){ + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "buttons"); + return retmap; + } +// * 1、PC和移动端均可打卡 +// * 2、仅PC可打卡 +// * 3、仅移动端可打卡 +// * 4、无需打卡 + String groupSignType = getSignType(); + //无需打卡 + if("4".equalsIgnoreCase(groupSignType)){ + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "buttons"); + return retmap; + } + if("2".equalsIgnoreCase(groupSignType)){ + if("1".equalsIgnoreCase(ismobile)){ + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "buttons"); + return retmap; + } + } + if("3".equalsIgnoreCase(groupSignType)){ + if(!"1".equalsIgnoreCase(ismobile)){ + retmap.put("showbutton", "0"); + retmap.put("status", "1"); + KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "buttons"); + return retmap; + } + } + + String yesterday = LocalDate.parse(curDate).minusDays(1).format(dateFormatter); + String nextday = LocalDate.parse(curDate).plusDays(1).format(dateFormatter); + List yesterdayLineButton = new ArrayList<>(); + List todayLineButton = new ArrayList<>(); + List restLineButton = new ArrayList<>(); + + //弹性工作制 + List freeLineButton = new ArrayList<>(); + + //先获取考勤工作时段的按钮 上下班时间 + Map todayLineMap = KQDurationCalculatorUtil.getWorkButton(user, curDate,true); + //明天的班次可能会存在上班开始时间在前一天的情况,这个也需要考虑 + Map nextLineMap = KQDurationCalculatorUtil.getWorkButton(user, nextday,true); + boolean isfree = "1".equalsIgnoreCase(Util.null2String(todayLineMap.get("isfree"))); + logMap.put("todayLineMap", todayLineMap); + logMap.put("nextLineMap", nextLineMap); + + if(isfree){ + do4FreeLine(user,freeLineButton,todayLineMap); + if(freeLineButton != null && !freeLineButton.isEmpty()){ + timelineList.addAll(freeLineButton); + retmap.put("lastname", lastname); + retmap.put("shortname", shortname); + retmap.put("messagerurl", messagerurl); + retmap.put("groupname", groupname+SystemEnv.getHtmlLabelName(10000800, Util.getIntValue(user.getLanguage()))); + retmap.put("outsidesign", outsidesign); + retmap.put("date", curDate); + retmap.put("timeline", timelineList); + retmap.put("status", "1"); + KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "buttons"); + return retmap; + } + } + //每次打开考勤按钮的时候,都只能有一个活动按钮 + List activeList = new ArrayList<>(); + + if(!todayLineMap.isEmpty()){ + if(todayLineMap.get("pre_timelineList") != null){ + do4YesterdayLine(todayLineMap,yesterdayLineButton,kqReportBiz,timelineList,yesterday,activeList); + } + if(todayLineMap.get("timelineList") != null){ + do4TodayLine(todayLineMap,todayLineButton,kqReportBiz,timelineList,activeList); + }else{ + //节假日或者休息日需要默认给客户拼接一个timelineList + retmap.put("isrest", "1"); + //kqLog.info("yesterdayLineButton:"+yesterdayLineButton); + if(yesterdayLineButton.isEmpty()){ + List yesterdayLine = (List)todayLineMap.get("pre_timelineList"); + //kqLog.info("yesterdayLine:"+yesterdayLine); + if(yesterdayLine != null){ + Map offTimelineMap = (Map)yesterdayLine.get(yesterdayLine.size()-1); + //kqLog.info("offTimelineMap:"+offTimelineMap); + //kqLog.info("signAcross:"+Util.null2String(offTimelineMap.get("signAcross")).equalsIgnoreCase("1")); + if(offTimelineMap.containsKey("signAcross") && Util.null2String(offTimelineMap.get("signAcross")).equalsIgnoreCase("1")){ + Map offTimelineMapTmp = reBuildYesTimeMap(offTimelineMap,yesterday,"off"); + //kqLog.info("offTimelineMapTmp:"+offTimelineMapTmp); + yesterdayLineButton.add(offTimelineMapTmp); + } + } + } + do4RestLine(""+user.getUID(),restLineButton,yesterdayLineButton,nextLineMap,signoutOnlyoff); + timelineList.addAll(restLineButton); + } + }else{ + //节假日或者休息日需要默认给客户拼接一个timelineList + retmap.put("isrest", "1"); + do4RestLine(""+user.getUID(),restLineButton, null,nextLineMap,signoutOnlyoff); + timelineList.addAll(restLineButton); + } + if(!nextLineMap.isEmpty()){ + List nextdayLineButton = new ArrayList<>(); + do4NextdayLine(nextLineMap,nextdayLineButton,kqReportBiz,timelineList,nextday,activeList); + } + + if(groupid.length() > 0){ + groupname = SystemEnv.getHtmlLabelName(10000801, Util.getIntValue(user.getLanguage()))+kqGroupComInfo.getGroupname(groupid); + }else{ + groupname = SystemEnv.getHtmlLabelName(10000799, Util.getIntValue(user.getLanguage())); + } + + retmap.put("lastname", lastname); + retmap.put("shortname", shortname); + retmap.put("messagerurl", messagerurl); + retmap.put("groupname", groupname); + retmap.put("outsidesign", outsidesign); + retmap.put("date", curDate); + retmap.put("timeline", timelineList); + retmap.put("status", "1"); + retmap.put("now", now.format(fullFormatter)); + + kqLog.info(user.getLastname()+":GetButtonsCmd:timelineList:"+timelineList); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + kqLog.info("考勤按钮报错",e); + } + logMap.put("retmap", retmap); + KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "buttons"); + return retmap; + } + + /** + * 当日的考勤按钮处理 + * @param todayLineMap + * @param todayLineButton + * @param kqReportBiz + * @param timelineList + * @param activeList + */ + private void do4TodayLine(Map todayLineMap, List todayLineButton, + KQReportBiz kqReportBiz, List timelineList, + List activeList) { + + List todayLine = (List)todayLineMap.get("timelineList"); + if(todayLine != null && !todayLine.isEmpty()){ + getWorkTimeButton(false, todayLine,todayLineButton, false); + //获取当天的考勤数据 +// List reports = kqReportBiz.getKqDateInfo(""+user.getUID(),curDate,curDate,true); + List reports = new ArrayList<>(); + getSignButton(user.getUID()+"",todayLineButton,reports,curDate); + timelineList.addAll(todayLineButton); + } + } + + /** + * 明日的跨天到今天的考勤按钮处理 + * 只有一种情况,那就是明日的班次设置的开始打卡时间在今天 + * 所以只有上班时间有这个情况要处理 + * @param nextLineMap + * @param nextdayLineButton + * @param kqReportBiz + * @param timelineList + * @param nextday + * @param activeList + */ + private void do4NextdayLine(Map nextLineMap, + List nextdayLineButton, KQReportBiz kqReportBiz, + List timelineList, String nextday, List activeList) { + + List nextdayLine = (List)nextLineMap.get("timelineList"); + if(nextdayLine != null && !nextdayLine.isEmpty()){ + Map onTimelineMap = (Map) nextdayLine.get(0); + if(onTimelineMap.containsKey("sign_preAcross")){ + boolean is_sign_preAcross = "1".equalsIgnoreCase(Util.null2String(onTimelineMap.get("sign_preAcross"))); + if(!is_sign_preAcross){ + return ; + } + } + getWorkTimeButton(false, nextdayLine,nextdayLineButton,true); + List reports = new ArrayList<>(); + getSignButton(user.getUID()+"",nextdayLineButton,reports,nextday); + timelineList.addAll(nextdayLineButton); + } + } + + /** + * 昨日跨天的考勤按钮处理 + * @param yesterdayLineMap + * @param yesterdayLineButton + * @param kqReportBiz + * @param timelineList + * @param yesterday + * @param activeList + */ + private void do4YesterdayLine(Map yesterdayLineMap, + List yesterdayLineButton, KQReportBiz kqReportBiz, + List timelineList, String yesterday, List activeList) { + + List yesterdayLine = (List)yesterdayLineMap.get("pre_timelineList"); + if(yesterdayLine != null && !yesterdayLine.isEmpty()){ + getWorkTimeButton(true, yesterdayLine,yesterdayLineButton, false); + //获取前一天的考勤数据 +// List reports = kqReportBiz.getKqDateInfo(""+user.getUID(),yesterday,yesterday,true); + List reports = new ArrayList<>(); + getSignButton(user.getUID()+"",yesterdayLineButton,reports,yesterday); + timelineList.addAll(yesterdayLineButton); + } + } + + /** + * 针对自由工作制的人员单独处理 + * @param user + * @param freeLineButton + * @param todayLineMap + */ + private void do4FreeLine(User user, List freeLineButton, + Map todayLineMap) { + RecordSet rs = new RecordSet(); + String resourceId = ""+user.getUID(); + if(todayLineMap != null && !todayLineMap.isEmpty()){ + LocalTime curTime = now.toLocalTime(); + + String signStart = Util.null2String(todayLineMap.get("signStart"));//签到开始时间 + String workMins = Util.null2String(todayLineMap.get("workMins"));//工作时长 + LocalTime signStartLocal = LocalTime.parse(signStart+":00", fullTimeFormatter); + + // 弹性工作制是否可以跨天 + boolean isFreezeAcross = KQSettingsBiz.is_freeAcross(); + boolean canSign = false; + String signDateTimeSql = " signtime >= '"+signStart+":00"+"'"; + if (isFreezeAcross) { + canSign = true; + String compareDate = curDate; + String endCompareDate = DateUtil.addDate(curDate, 1); + if (curTime.isBefore(signStartLocal)) { + compareDate = DateUtil.addDate(curDate, -1); + endCompareDate = curDate; + } + if(rs.getDBType().equals("oracle")){ + signDateTimeSql = " signdate||' '||signtime >= '" + compareDate + " " + signStart + ":00" + "' and signdate||' '||signtime <= '" + endCompareDate + " " + signStart + ":00' "; + }else if("sqlserver".equals(rs.getDBType())){ + signDateTimeSql = " signdate + ' ' + signtime >= '" + compareDate + " " + signStart + ":00" + "' and signdate + ' ' + signtime <= '" + endCompareDate + " " + signStart + ":00' "; + }else{ + signDateTimeSql = " concat(signdate,' ',signtime) >= '" + compareDate + " " + signStart + ":00" + "' and concat(signdate,' ',signtime) <= '" + endCompareDate + " " + signStart + ":00' "; + } + } else { + if(curTime.isAfter(signStartLocal)){ + canSign = true; + } + } + + KQScheduleSignBiz kqScheduleSignBiz = null; + if (isFreezeAcross) { + kqScheduleSignBiz = new KQScheduleSignBiz.KQScheduleSignParamBuilder().resourceidParam(resourceId).userTypeParam(user.getLogintype()).signDateTimeSqlParam(signDateTimeSql).build(); + } else { + kqScheduleSignBiz = new KQScheduleSignBiz.KQScheduleSignParamBuilder().resourceidParam(resourceId).userTypeParam(user.getLogintype()).signDateParam(curDate).signDateTimeSqlParam(signDateTimeSql).build(); + } + List kqHrmScheduleSigns = kqScheduleSignBiz.getFreeScheduleSignInfo(); + if(kqHrmScheduleSigns != null && !kqHrmScheduleSigns.isEmpty()) { + int i = 0 ; + for(KQHrmScheduleSign sign : kqHrmScheduleSigns){ + String signtype = sign.getSigntype(); + String signtime = sign.getSigntime(); + String signdate = sign.getSigndate(); + String signStatus = sign.getSignstatus(); + String addr = sign.getAddr(); + + if(i%2 == 0){ + //签到 + freeLineButton.add(reBuildFreeButton("on", signdate, "0", "0",signtime,addr)); + }else{ +// 签退 + freeLineButton.add(reBuildFreeButton("off", signdate, "0", "0",signtime,addr)); + } + + i++; + } + //i是加1之后的结果 + if(i%2 == 0){ + //如果是成对存在的,那么需要再多出来俩,支持多次签到签退 + freeLineButton.add(reBuildFreeButton("on", curDate, "1", canSign?"1":"0","","")); + freeLineButton.add(reBuildFreeButton("off", curDate, "0", "0","","")); + }else{ + //如果不是成对存在,一定是签到多,签退少,当前处于需要签退的状态 + freeLineButton.add(reBuildFreeButton("off", curDate, "1", "1","","")); + } + + }else{ + //如果没有考勤数据,那么就是先签到再签退 + freeLineButton.add(reBuildFreeButton("on", curDate, "1", canSign?"1":"0","","")); + freeLineButton.add(reBuildFreeButton("off", curDate, "0", "0","","")); + } + } + + } + + private Map reBuildFreeButton(String type,String date,String active,String needSign,String signTime,String position){ + Map freetimelineMap = new HashMap<>(); + freetimelineMap.put("type", type); + freetimelineMap.put("belongdate", date); + freetimelineMap.put("date", date); + freetimelineMap.put("active", active); + freetimelineMap.put("needSign", needSign); + freetimelineMap.put("signTime", signTime); + freetimelineMap.put("position", position); + freetimelineMap.put("time", ""); + freetimelineMap.put("isfree", "1"); + + return freetimelineMap; + } + + /** + * 真对非工作时间的签到签退 + * @param resourceId + * @param restLineButton + * @param yesterdayLineButton + * @param nextLineMap + */ + private void do4RestLine(String resourceId, List restLineButton, + List yesterdayLineButton, + Map nextLineMap) { + do4RestLine(resourceId,restLineButton, yesterdayLineButton,nextLineMap,0); + } + + private void do4RestLine(String resourceId, List restLineButton, + List yesterdayLineButton, + Map nextLineMap,int signoutOnlyoff) { + boolean hasSignIn = false; + boolean hasSignOut = false; + boolean isActive = true; + Map timelineOnMap = new HashMap<>(); + timelineOnMap.put("type", "on"); + timelineOnMap.put("time", ""); + timelineOnMap.put("isfirstsign", "1"); + timelineOnMap.put("belongdate", curDate); + timelineOnMap.put("date", curDate); + Map timelineOffMap = new HashMap<>(); + timelineOffMap.put("type", "off"); + timelineOffMap.put("time", ""); + timelineOffMap.put("islastsign", "1"); + timelineOffMap.put("belongdate", curDate); + timelineOffMap.put("date", curDate); + String yesterday = LocalDate.parse(curDate).minusDays(1).format(dateFormatter); + String canSignTime = ""; + String next_canSignTime = ""; + String signDateTimeSql = ""; + //kqLog.info("do4RestLine::yesterdayLineButton"+yesterdayLineButton); + if(yesterdayLineButton != null && !yesterdayLineButton.isEmpty()){ + Map yesterdayMap = (Map)yesterdayLineButton.get(yesterdayLineButton.size()-1); + //kqLog.info("do4RestLine::yesterdayMap"+yesterdayMap); + if(yesterdayMap != null){ + canSignTime = Util.null2String(yesterdayMap.get("canSignTime")); + kqLog.info("do4RestLine::canSignTime"+canSignTime); + if(canSignTime != null && canSignTime.length() > 0){ + LocalTime localTime = LocalTime.parse(canSignTime, timeFormatter); + localTime = localTime.plusMinutes(1); + canSignTime = localTime.format(timeFormatter); + } + } + } + if(!nextLineMap.isEmpty()){ + List nextdayLine = (List)nextLineMap.get("timelineList"); + if(nextdayLine != null && !nextdayLine.isEmpty()){ + Map onTimelineMap = (Map) nextdayLine.get(0); + if(onTimelineMap.containsKey("sign_preAcross")){ + boolean is_sign_preAcross = "1".equalsIgnoreCase(Util.null2String(onTimelineMap.get("sign_preAcross"))); + if(is_sign_preAcross){ + int tMin = Util.getIntValue(Util.null2String(onTimelineMap.get("min"))); + String time = Util.null2String(onTimelineMap.get("time")); + String nextday = LocalDate.parse(curDate).plusDays(1).format(dateFormatter); + String next_date_canSignTime = nextday + " "+ time + ":00"; + if(tMin > 0) { + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(next_date_canSignTime, fullFormatter).minusMinutes(tMin); + next_canSignTime = tmpLocalDateTime.format(timeFormatter); + } + } + } + } + + } + if(canSignTime.length() > 0){ + signDateTimeSql = " signtime >= '"+canSignTime+":00"+"'"; + timelineOnMap.put("signSectionTime",curDate+" "+canSignTime+":00"); + timelineOnMap.put("signSection",curDate+" "+canSignTime+":00"+"#"+curDate+" "+"23:59:59"); + timelineOnMap.put("canSignTime","00:00:00"); + timelineOffMap.put("signSectionTime",curDate+" "+"23:59:59"); + timelineOffMap.put("canSignTime","23:59:59"); + timelineOffMap.put("signSection",curDate+" "+canSignTime+":00"+"#"+curDate+" "+"23:59:59"); + if(next_canSignTime.length() > 0){ + signDateTimeSql += " and signtime <= '"+next_canSignTime+":59"+"'"; + String offSignSectionTime = curDate+" "+next_canSignTime+":59"; + LocalDateTime offLocalDateTime = LocalDateTime.parse(offSignSectionTime,fullFormatter); + if(now.isAfter(offLocalDateTime)){ + isActive = false; + } + timelineOffMap.put("signSectionTime",curDate+" "+next_canSignTime+":59"); + timelineOffMap.put("canSignTime",next_canSignTime+":59"); + timelineOffMap.put("signSection",curDate+" "+canSignTime+":00"+"#"+curDate+" "+next_canSignTime+":59"); + } + String onSignSectionTime = curDate+" "+canSignTime+":00"; + LocalDateTime onLocalDateTime = LocalDateTime.parse(onSignSectionTime,fullFormatter); + if(now.isBefore(onLocalDateTime)){ + isActive = false; + } + }else{ + timelineOnMap.put("signSectionTime",curDate+" "+"00:00:00"); + timelineOnMap.put("canSignTime","00:00:00"); + timelineOnMap.put("signSection",curDate+" "+"00:00:00"+":00"+"#"+curDate+" "+"23:59:59"); + timelineOffMap.put("signSectionTime",curDate+" "+"23:59:59"); + timelineOffMap.put("canSignTime","23:59:59"); + timelineOffMap.put("signSection",curDate+" "+"00:00:00"+":00"+"#"+curDate+" "+"23:59:59"); + if(next_canSignTime.length() > 0){ + String offSignSectionTime = curDate+" "+next_canSignTime+":59"; + LocalDateTime offLocalDateTime = LocalDateTime.parse(offSignSectionTime,fullFormatter); + if(now.isAfter(offLocalDateTime)){ + isActive = false; + } + signDateTimeSql += " signtime <= '"+next_canSignTime+":59"+"'"; + timelineOffMap.put("signSectionTime",curDate+" "+next_canSignTime+":59"); + timelineOffMap.put("canSignTime",next_canSignTime+":59"); + timelineOnMap.put("signSection",curDate+" "+"00:00:00"+":00"+"#"+curDate+" "+next_canSignTime+":59"); + timelineOffMap.put("signSection",curDate+" "+"00:00:00"+":00"+"#"+curDate+" "+next_canSignTime+":59"); + } + } + + KQScheduleSignBiz kqScheduleSignBiz = new KQScheduleSignBiz.KQScheduleSignParamBuilder().resourceidParam(resourceId) + .userTypeParam(user.getLogintype()).signDateParam(curDate).signDateTimeSqlParam(signDateTimeSql).build(); + Map signMap = kqScheduleSignBiz.getScheduleSignInfo(); + if(signMap != null && !signMap.isEmpty()) { + KQHrmScheduleSign signInTimeBean = signMap.get("signin"); + KQHrmScheduleSign signOutTimeBean = signMap.get("signout"); + if(signInTimeBean != null){ + String signtimeTmp = Util.null2String(signInTimeBean.getSigntime()); + timelineOnMap.put("signTime", signtimeTmp); + timelineOnMap.put("position", Util.null2String(signInTimeBean.getAddr())); + hasSignIn = true; + } + if(signOutTimeBean != null){ + String signtimeTmp = Util.null2String(signOutTimeBean.getSigntime()); + timelineOffMap.put("signTime", signtimeTmp); + timelineOffMap.put("position", Util.null2String(signOutTimeBean.getAddr())); + hasSignOut = true; + } + if(hasSignIn){ + //有签到 就记录下 + timelineOffMap.put("signInTime4Out", timelineOnMap.get("signTime")); + } + } + getActiveRestSign(isActive, hasSignIn, hasSignOut, timelineOnMap, timelineOffMap,false); + restLineButton.add(timelineOnMap); + restLineButton.add(timelineOffMap); + } + + /** + * 获取考勤组的考勤方式 + * 1、PC和移动端均可打卡 + * 2、仅PC可打卡 + * 3、仅移动端可打卡 + */ + private String getSignType() { + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID()+""); + if(kqGroupEntity == null){ + return ""; + } + return kqGroupEntity != null ? kqGroupEntity.getSignintype(): ""; + } + + /** + * 根据工作时段来获取对应工作时段下的签到签退数据 + * @param resourceId + * @param timelineList + * @param reports + */ + private void getSignButton(String resourceId,List timelineList,List reports,String kqDate) { + if(!timelineList.isEmpty()){ + //获取当前时间 + LocalDateTime now = getNow(); + + //因为工作时段是成对存在的,所以timelineList一定是两两一对的复数[0,1] [2,3] [4,5] + int count = timelineList.size(); + // 一天4次打卡单独做判断,如果是上午下班打卡和下午上班打卡时间重叠,那么上午的下班卡取最早的,下午的上班卡取最晚的。用shiftCount是否等于-1判断,-1就走标准不重叠。2就表示重叠走新的逻辑 + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTime=kqWorkTime.getWorkTime(resourceId, kqDate); + String preDate = DateUtil.addDate(kqDate, -1);//上一天日期 + String nextDate = DateUtil.addDate(kqDate, 1);//下一天日期 + List lsSignTime = new ArrayList<>(); + List lsWorkTime = new ArrayList<>(); + int signoutOnlyoff = 0; + if (workTime != null) { + lsSignTime = workTime.getSignTime();//允许打卡时间 + lsWorkTime = workTime.getWorkTime();//工作时间 + signoutOnlyoff = workTime.getSignoutOnlyoff(); + } + int shiftCount = lsWorkTime == null ? 0 : lsWorkTime.size(); + int shiftI = 0; + String signEndDateTimeZero = ""; + for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) { + shiftI = i; + TimeScopeEntity signTimeScope = lsSignTime.get(i); + String signBeginDateTime = signTimeScope.getBeginTimeAcross() ? nextDate : kqDate; + if(signTimeScope.isBeginTimePreAcross()){ + signBeginDateTime = preDate; + } + signBeginDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(signTimeScope.getBeginTime())+":00"; + String signEndDateTime = signTimeScope.getEndTimeAcross() ? nextDate : kqDate; + signEndDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(signTimeScope.getEndTime())+":59"; + if (shiftCount == 2 && shiftI == 0) { + signEndDateTimeZero = signEndDateTime; + } + if (shiftCount == 2 && shiftI == 1) { + shiftCount = signBeginDateTime.compareTo(signEndDateTimeZero) <= 0 ? shiftCount : -1; + } + } + int workCnt = 0; + List recordLastButtomInfo = new ArrayList<>(); + String count4NoonStartDateTime = ""; + String count4NoonEndDateTime = ""; + for(int i = 0 ; i < count ; ){ + //成对出现的上下班时间 + int on_i = i; + int off_i = i+1; + Map timelineOnMap = (Map)timelineList.get(on_i); + Map timelineOffMap = (Map)timelineList.get(off_i); + if(timelineOnMap != null && !timelineOnMap.isEmpty() && timelineOffMap != null && !timelineOffMap.isEmpty()){ + String onTime = Util.null2String(timelineOnMap.get("time")); + String belongdate = Util.null2String(timelineOnMap.get("belongdate")); + //上班开始打卡时间 + String onSignSectionTime = Util.null2String(timelineOnMap.get("signSectionTime")); + //上班结束打卡时间 + String signSectionEndTime = Util.null2String(timelineOnMap.get("signSectionEndTime")); + String onDateTime = Util.null2String(timelineOnMap.get("datetime")); + String onIsacross = Util.null2String(timelineOnMap.get("isacross")); + + String offTime = Util.null2String(timelineOffMap.get("time")); + //下班开始打卡时间 + String signSectionBeginTime = Util.null2String(timelineOffMap.get("signSectionBeginTime")); + //下班结束打卡时间 + String offSignSectionTime = Util.null2String(timelineOffMap.get("signSectionTime")); + String offDateTime = Util.null2String(timelineOffMap.get("datetime")); + String offIsacross = Util.null2String(timelineOffMap.get("isacross")); + if(onSignSectionTime.length() == 0 || offSignSectionTime.length() == 0){ + kqLog.info(user.getLastname()+":"+curDate+":onSignSectionTime is null:"+onSignSectionTime+":offSignSectionTime is null:"+offSignSectionTime); + continue; + } + if(signSectionEndTime.length() == 0 || signSectionBeginTime.length() == 0){ + } + boolean isOn = false; + if(i == (count-2) && shiftCount == 4&&count4NoonEndDateTime.equals(onSignSectionTime)){ + isOn = true; + } + LocalDateTime onLocalDateTime = LocalDateTime.parse(onSignSectionTime,fullFormatter); + LocalDateTime onLocalDateEndTime = null; + if(signSectionEndTime.length() > 0){ + onLocalDateEndTime = LocalDateTime.parse(signSectionEndTime,fullFormatter); + } + + LocalDateTime offLocalDateBeginTime = null; + if(signSectionBeginTime.length() > 0){ + offLocalDateBeginTime = LocalDateTime.parse(signSectionBeginTime,fullFormatter); + } + LocalDateTime offLocalDateTime = LocalDateTime.parse(offSignSectionTime,fullFormatter); + + LocalDateTime onworkDateTime = LocalDateTime.parse(onDateTime,fullFormatter); + LocalDateTime offworkDateTime = LocalDateTime.parse(offDateTime,fullFormatter); + + if("1".equalsIgnoreCase(onIsacross)){ + onTime = new KQTimesArrayComInfo().turn24to48Time(onTime); + timelineOffMap.put("belongtime", onTime); + } + if("1".equalsIgnoreCase(offIsacross)){ + offTime = new KQTimesArrayComInfo().turn24to48Time(offTime); + timelineOffMap.put("belongtime", offTime); + } + String worksection = onTime+"-"+offTime; + String signSection = onSignSectionTime+"#"+offSignSectionTime; + timelineOnMap.put("signSection", signSection); + timelineOnMap.put("signSectionEndTime", signSectionEndTime); + timelineOffMap.put("signSection", signSection); + timelineOffMap.put("signSectionBeginTime", signSectionBeginTime); + + if(i == (count-2)){ + //如果当前工作时段是最后一个工作时段 + timelineOnMap.put("islastsign", "1"); + timelineOffMap.put("islastsign", "1"); + }else{ + timelineOnMap.put("islastsign", "0"); + timelineOffMap.put("islastsign", "0"); + } + if(i == 0){ + timelineOnMap.put("isfirstsign", "1"); + }else{ + timelineOnMap.put("isfirstsign", "0"); + } + + boolean hasSignIn = false; + boolean hasSignOut = false; + //是否在这个整体的签到签退范围内 + boolean isActive = false; + //签到是否在允许的打卡范围内 + boolean isOnActive = false; + //签推是否在允许的打卡范围内 + boolean isOffActive = false; + if((now.isAfter(onLocalDateTime) && now.isBefore(offLocalDateTime))||(now.isEqual(onLocalDateTime))||(now.isEqual(offLocalDateTime))){ + if(isOn&&i == (count-2) && shiftCount == 4){ //如果当前工作时段是最后一个工作时段 + if(now.isAfter(onLocalDateTime) && now.isBefore(offworkDateTime)||(now.isEqual(onLocalDateTime))||(now.isEqual(offworkDateTime))) { + if(recordLastButtomInfo.size() > 0 && "true".equals(recordLastButtomInfo.get(0))) { + isActive = true; + } + } else { + isActive = true; + } + } else { + isActive = true; + } + } + + if(now.isAfter(onworkDateTime)){ + timelineOnMap.put("isYellow", "1"); + }else{ + timelineOnMap.put("isYellow", "0"); + } + if(now.isBefore(offworkDateTime)){ + timelineOffMap.put("isYellow", "1"); + }else{ + timelineOffMap.put("isYellow", "0"); + } + if(onSignSectionTime.length() == 0 || offSignSectionTime.length() == 0){ + timelineOnMap.put("active", "0"); + timelineOffMap.put("active", "0"); + timelineOnMap.put("needSign", "0"); + timelineOffMap.put("needSign", "0"); + kqLog.info("考勤按钮报错:"+user.getLastname()+"::"+curDate+":onSignSectionTime:"+onSignSectionTime+":offSignSectionTime:"+offSignSectionTime); + return ; + } + //针对签到签退数据获取用的 + String sign_signSectionTime = ""; + String sign_signSectionEndTime = ""; + String sign_signSectionBeginTime = ""; + String sign_offSignSectionTime = ""; + if(signSectionEndTime.length() == 0 && signSectionBeginTime.length() == 0){ + //如果没设置上班后,下班前打卡 + sign_signSectionTime = onSignSectionTime; + sign_offSignSectionTime = offSignSectionTime; + }else{ + if(signSectionEndTime.length() > 0){ + if(signSectionBeginTime.length() > 0){ + //如果上班后,下班前打卡范围都做了控制 + if(isOn&&shiftCount == 4) { // 针对一天4次卡的二开 + if(onLocalDateTime.isAfter(offworkDateTime)) { + if((now.isAfter(onLocalDateTime) && now.isBefore(offworkDateTime)) ||(now.isEqual(onLocalDateTime))||(now.isEqual(offworkDateTime))){ + isOnActive = true; + } + } else { + if((now.isAfter(onLocalDateTime) && now.isBefore(onLocalDateEndTime)) ||(now.isEqual(onLocalDateTime))||(now.isEqual(onLocalDateEndTime))){ + isOnActive = true; + } + } + } else { + if((now.isAfter(onLocalDateTime) && now.isBefore(onLocalDateEndTime)) ||(now.isEqual(onLocalDateTime))||(now.isEqual(onLocalDateEndTime))){ + isOnActive = true; + } + } + if((now.isAfter(offLocalDateBeginTime) && now.isBefore(offLocalDateTime)) ||(now.isEqual(offLocalDateBeginTime))||(now.isEqual(offLocalDateTime))){ + isOffActive = true; + } + String onSignSection = onLocalDateTime.format(fullFormatter)+"#"+onLocalDateEndTime.format(fullFormatter); + String offSignSection = offLocalDateBeginTime.format(fullFormatter)+"#"+offLocalDateTime.format(fullFormatter); + timelineOnMap.put("signSection", onSignSection); + timelineOffMap.put("signSection", offSignSection); + sign_signSectionTime = onSignSectionTime; + sign_signSectionEndTime = signSectionEndTime; + sign_signSectionBeginTime = signSectionBeginTime; + sign_offSignSectionTime = offSignSectionTime; + + }else{ + //如果只是上班后打卡范围做了控制 + if(isOn&&shiftCount == 4) { // 针对一天4次卡的二开 + if(onLocalDateTime.isAfter(offworkDateTime)) { + if((now.isAfter(onLocalDateTime) && now.isBefore(offworkDateTime)) ||(now.isEqual(onLocalDateTime))||(now.isEqual(offworkDateTime))){ + isOnActive = true; + } + } else { + if((now.isAfter(onLocalDateTime) && now.isBefore(onLocalDateEndTime)) ||(now.isEqual(onLocalDateTime))||(now.isEqual(onLocalDateEndTime))){ + isOnActive = true; + } + } + } else { + if((now.isAfter(onLocalDateTime) && now.isBefore(onLocalDateEndTime)) ||(now.isEqual(onLocalDateTime))||(now.isEqual(onLocalDateEndTime))){ + isOnActive = true; + } + } + LocalDateTime tmp = LocalDateTime.parse(onLocalDateEndTime.plusMinutes(1).format(datetimeFormatter)+":00",fullFormatter); + String tmp_datetime = tmp.format(fullFormatter); + if((now.isAfter(tmp) && now.isBefore(offLocalDateTime)) ||(now.isEqual(tmp))||(now.isEqual(offLocalDateTime))){ + isOffActive = true; + } + String onSignSection = onLocalDateTime.format(fullFormatter)+"#"+onLocalDateEndTime.format(fullFormatter); + String offSignSection = tmp.format(fullFormatter)+"#"+offLocalDateTime.format(fullFormatter); + timelineOnMap.put("signSection", onSignSection); + timelineOffMap.put("signSection", offSignSection); + sign_signSectionTime = onSignSectionTime; + sign_signSectionEndTime = signSectionEndTime; + sign_signSectionBeginTime = tmp_datetime; + sign_offSignSectionTime = offSignSectionTime; + + } + }else if(signSectionBeginTime.length() > 0){ + //如果只是下班前打卡范围做了控制 + LocalDateTime tmp = LocalDateTime.parse(offLocalDateBeginTime.minusMinutes(1).format(datetimeFormatter)+":59",fullFormatter); + String tmp_datetime = tmp.format(fullFormatter); + if((now.isAfter(onLocalDateTime) && now.isBefore(tmp)) ||(now.isEqual(onLocalDateTime))||(now.isEqual(tmp))){ + isOnActive = true; + } + if((now.isAfter(offLocalDateBeginTime) && now.isBefore(offLocalDateTime)) ||(now.isEqual(offLocalDateBeginTime))||(now.isEqual(offLocalDateTime))){ + isOffActive = true; + } + String onSignSection = onLocalDateTime.format(fullFormatter)+"#"+tmp_datetime; + String offSignSection = offLocalDateBeginTime.format(fullFormatter)+"#"+offLocalDateTime.format(fullFormatter); + timelineOnMap.put("signSection", onSignSection); + timelineOffMap.put("signSection", offSignSection); + sign_signSectionTime = onSignSectionTime; + sign_signSectionEndTime = tmp_datetime; + sign_signSectionBeginTime = signSectionBeginTime; + sign_offSignSectionTime = offSignSectionTime; + } + + timelineOnMap.put("signSectionEndTime", sign_signSectionEndTime); + timelineOffMap.put("signSectionBeginTime", sign_signSectionBeginTime); + } + if(shiftCount == 4 && i == 0) { + count4NoonStartDateTime = sign_signSectionEndTime.length()>0?sign_signSectionEndTime:offDateTime; + count4NoonEndDateTime = sign_offSignSectionTime; + } + boolean isSignoutOnlyoff = false; + if(i%2 == 0){ + isSignoutOnlyoff = isSignoutOnlyoff(signoutOnlyoff,offDateTime,now); + } + writeLog(user.getLastname()+":"+i+":isSignoutOnlyoff:"+isSignoutOnlyoff); + + KQScheduleSignBiz kqScheduleSignBiz = new KQScheduleSignBiz.KQScheduleSignParamBuilder().resourceidParam(resourceId).signoutOnlyOffParam(isSignoutOnlyoff?1:0) + .offDateTimeParam(offDateTime).shiftCountParam(shiftCount).shiftIParam(i) + .count4NoonStartDateTimeParam(count4NoonStartDateTime).count4NoonEndDateTimeParam(count4NoonEndDateTime) + .userTypeParam(user.getLogintype()).signSectionTimeParam(sign_signSectionTime) + .signSectionEndTimeParam(sign_signSectionEndTime).signSectionBeginTimeParam(sign_signSectionBeginTime) + .offSignSectionTimeParam(sign_offSignSectionTime).build(); + + Map signMap = kqScheduleSignBiz.getScheduleSignInfoWithCardRange(); + writeLog(user.getLastname()+":"+i+":signMap:"+JSON.toJSON(signMap)); + if(signMap != null && !signMap.isEmpty()){ + KQHrmScheduleSign signInTimeBean = signMap.get("signin"); + KQHrmScheduleSign signOutTimeBean = signMap.get("signout"); + if(signInTimeBean != null){ + String signdate = Util.null2String(signInTimeBean.getSigndate()); + String signtimeTmp = Util.null2String(signInTimeBean.getSigntime()); + String signfrom = Util.null2String(signInTimeBean.getSignfrom()); + timelineOnMap.put("signfrom", signfrom); + timelineOnMap.put("signbelong", "today"); + timelineOnMap.put("signbelongspan", SystemEnv.getHtmlLabelName(15537, user.getLanguage())); + if(signdate.compareTo(curDate) < 0){ + timelineOnMap.put("signbelong", "yesterday"); + timelineOnMap.put("signbelongspan", SystemEnv.getHtmlLabelName(82640, user.getLanguage())); + } + timelineOnMap.put("signTime", signtimeTmp); + timelineOnMap.put("position", Util.null2String(signInTimeBean.getAddr())); + hasSignIn = true; + } + if(signOutTimeBean != null){ + String signdate = Util.null2String(signOutTimeBean.getSigndate()); + String signtimeTmp = Util.null2String(signOutTimeBean.getSigntime()); + String signfrom = Util.null2String(signOutTimeBean.getSignfrom()); + timelineOffMap.put("signfrom", signfrom); + timelineOffMap.put("signbelong", SystemEnv.getHtmlLabelName(15537, user.getLanguage())); + timelineOffMap.put("signbelongspan", SystemEnv.getHtmlLabelName(15537, user.getLanguage())); + if(signdate.compareTo(curDate) < 0){ + timelineOffMap.put("signbelong", SystemEnv.getHtmlLabelName(82640, user.getLanguage())); + timelineOffMap.put("signbelongspan", SystemEnv.getHtmlLabelName(82640, user.getLanguage())); + } + timelineOffMap.put("signTime", signtimeTmp); + timelineOffMap.put("position", Util.null2String(signOutTimeBean.getAddr())); + hasSignOut = true; + } + } + //根据考勤工作时段获取相应时段下的签到签退数据 + if(!reports.isEmpty()){ + updateStatusByReport(reports,belongdate, timelineOnMap, timelineOffMap,worksection); + } + + if(signSectionEndTime.length() == 0 && signSectionBeginTime.length() == 0){ + getActiveRestSign(isActive, hasSignIn, hasSignOut, timelineOnMap, timelineOffMap,isSignoutOnlyoff); + }else{ + getActiveSign(isActive, hasSignIn, hasSignOut, timelineOnMap, timelineOffMap,isOnActive,isOffActive,shiftCount, i, isSignoutOnlyoff); + } + String lastButtomInfo = ""+hasSignOut; + recordLastButtomInfo.add(lastButtomInfo); + } + + i = i + 2; + workCnt++; + } + } + + } + /* + 返回true表示需要处理按钮的显示,false走标准不需要动 + */ + + public boolean isSignoutOnlyoff(int signoutOnlyoff,String offDateTime,LocalDateTime now1){ + boolean flag = false; + if(1 == signoutOnlyoff){//开启了下班后只能签退 + LocalDateTime offdatetime1 = LocalDateTime.parse(offDateTime,fullFormatter);//下班时间 + //当前时间 >= 下班时间 + if(now1.isAfter(offdatetime1)||(now1.isEqual(offdatetime1))){ + flag = true; + } + } + return flag; + } + + /** + * 根据考勤报表数据,更新打卡界面状态 + * @param reports + * @param belongdate + * @param timelineOnMap + * @param timelineOffMap + * @param worksection + */ + public void updateStatusByReport(List reports, String belongdate, + Map timelineOnMap, + Map timelineOffMap, String worksection) { + List checkInfoList = new ArrayList<>(); + for(int i = 0 ; i < reports.size() ; i++){ + Map reportData = (Map) reports.get(i); + if(reportData != null && !reportData.isEmpty()){ + String kqdate = Util.null2String(reportData.get("kqdate")); + if(belongdate.equalsIgnoreCase(kqdate)){ + checkInfoList = (List) reportData.get("checkInfo"); + if(checkInfoList != null && !checkInfoList.isEmpty()){ + for(int j = 0 ; j < checkInfoList.size() ; j++){ + Map kqData = (Map) checkInfoList.get(j); + String workbegintime = Util.null2String(kqData.get("workbegintime")); + String workendtime = Util.null2String(kqData.get("workendtime")); + if(worksection.equalsIgnoreCase((workbegintime+"-"+workendtime))){ + //如果有考勤数据,再根据考勤数据同步更新下 + setStatusByReport(kqData,timelineOnMap,timelineOffMap); + break; + } + } + } + } + } + } + + } + + /** + * 根据考勤报表数据返回签到签退按钮状态 + * @param reportData + * @param timelineOnMap + * @param timelineOffMap + */ + private void setStatusByReport(Map reportData, Map timelineOnMap, Map timelineOffMap) { + + String status = Util.null2String(reportData.get("status")); + if(status.contains(ButtonStatusEnum.ABSENT.getStatusCode())){ + //旷工 旷工大于一切 + timelineOnMap.put("status", ButtonStatusEnum.ABSENT.getStatusCode()); + timelineOffMap.put("status", ButtonStatusEnum.ABSENT.getStatusCode()); + return ; + } + if(status.contains(ButtonStatusEnum.NORMAL.getStatusCode())){ + timelineOnMap.put("status", ButtonStatusEnum.NORMAL.getStatusCode()); + timelineOffMap.put("status", ButtonStatusEnum.NORMAL.getStatusCode()); + return ; + } + + if(status.contains(ButtonStatusEnum.BELATE.getStatusCode())){ + //迟到 + timelineOnMap.put("status", ButtonStatusEnum.BELATE.getStatusCode()); + } + if(status.contains(ButtonStatusEnum.LEAVEERALY.getStatusCode())){ + //早退 + timelineOffMap.put("status", ButtonStatusEnum.LEAVEERALY.getStatusCode()); + } + if(status.contains(ButtonStatusEnum.NOSIGN.getStatusCode())){ + //漏签 + timelineOffMap.put("status", ButtonStatusEnum.NOSIGN.getStatusCode()); + } + } + + private void getActiveRestSign(boolean isActive, boolean hasSignIn, boolean hasSignOut, + Map timelineOnMap, Map timelineOffMap) { + getActiveRestSign(isActive,hasSignIn,hasSignOut,timelineOnMap,timelineOffMap,false); + } + private void getActiveRestSign(boolean isActive, boolean hasSignIn, boolean hasSignOut, + Map timelineOnMap, Map timelineOffMap,boolean signoutOnlyoff) { + + if(isActive){ + if(hasSignIn){ + if(hasSignOut){ + //签到了,签退了 + timelineOnMap.put("active", "0"); + timelineOffMap.put("active", "0"); + + timelineOnMap.put("needSign", "0"); + timelineOffMap.put("needSign", "0"); + timelineOffMap.put("reSign", "1"); + + }else{ + //签到了,未签退 + timelineOnMap.put("active", "0"); + timelineOffMap.put("active", "1"); + + timelineOnMap.put("needSign", "0"); + timelineOffMap.put("needSign", "1"); + } + }else{ + if(hasSignOut){ + //未签到,签退了 理论上是不可能的 + if(signoutOnlyoff){ + timelineOnMap.put("active", "0"); + timelineOffMap.put("active", "0"); + + timelineOnMap.put("needSign", "0"); + timelineOffMap.put("needSign", "0"); + timelineOffMap.put("reSign", "1"); + } + }else{ + //未签到未签退 + if(signoutOnlyoff){ + timelineOnMap.put("active", "0"); + timelineOffMap.put("active", "1"); + + timelineOnMap.put("needSign", "0"); + timelineOffMap.put("needSign", "1"); + }else{ + timelineOnMap.put("active", "1"); + timelineOffMap.put("active", "0"); + + timelineOnMap.put("needSign", "1"); + timelineOffMap.put("needSign", "0"); + } + } + } + + }else{ + //如果都不在考勤范围内肯定不能签到签退 + timelineOnMap.put("active", "0"); + timelineOffMap.put("active", "0"); + + timelineOnMap.put("needSign", "0"); + timelineOffMap.put("needSign", "0"); + + } + } + /** + * 生成时间轴上 需要签到和活动考勤点的标识 + * @param isActive + * @param hasSignIn + * @param hasSignOut + * @param timelineOnMap + * @param timelineOffMap + * @param isOnActive + * @param isOffActive + */ + private void getActiveSign(boolean isActive, boolean hasSignIn, boolean hasSignOut, + Map timelineOnMap, Map timelineOffMap, + boolean isOnActive, boolean isOffActive, int count, int i) { + getActiveSign(isActive, hasSignIn, hasSignOut, timelineOnMap, timelineOffMap,isOnActive,isOffActive,count, i, false); + } + private void getActiveSign(boolean isActive, boolean hasSignIn, boolean hasSignOut, + Map timelineOnMap, Map timelineOffMap, + boolean isOnActive, boolean isOffActive, int count, int i,boolean signoutOnlyoff) { + + if(isActive){ + if(hasSignIn){ + if(hasSignOut){ + //签到了,签退了 + timelineOnMap.put("active", "0"); + timelineOnMap.put("needSign", "0"); + + timelineOffMap.put("active", "0"); + timelineOffMap.put("needSign", "0"); + if(i == 0 && count == 4) { //如果当前工作时段是最后一个工作时段, 上午时段有过签退就不能再更新签退了,因为第二次打卡是下午的上班卡 + + } else { + if (isOffActive) { + timelineOffMap.put("reSign", "1"); + } + } + }else{ + //签到了,未签退 + timelineOnMap.put("active", "0"); + timelineOnMap.put("needSign", "0"); + + if(isOffActive){ + timelineOffMap.put("needSign", "1"); + timelineOffMap.put("active", "1"); + }else{ + timelineOffMap.put("needSign", "0"); + timelineOffMap.put("active", "0"); + } + } + }else{ + if(hasSignOut){ + //未签到,签退了 + if(signoutOnlyoff){ + if(isOnActive){ + timelineOnMap.put("active", "0"); + timelineOnMap.put("needSign", "0"); + }else{ + timelineOnMap.put("active", "0"); + } + timelineOffMap.put("active", "0"); + timelineOffMap.put("needSign", "0"); + + if(i == 0 && count == 4) { //如果当前工作时段是最后一个工作时段, 上午时段有过签退就不能再更新签退了,因为第二次打卡是下午的上班卡 + + } else { + if(isOffActive){ + timelineOffMap.put("reSign", "1"); + } + } + }else{ + if(isOnActive){ + timelineOnMap.put("active", "1"); + timelineOnMap.put("needSign", "1"); + }else{ + timelineOnMap.put("active", "0"); + } + timelineOffMap.put("active", "0"); + timelineOffMap.put("needSign", "0"); + + if(i == 0 && count == 4) { //如果当前工作时段是最后一个工作时段, 上午时段有过签退就不能再更新签退了,因为第二次打卡是下午的上班卡 + + } else { + if(isOffActive){ + timelineOffMap.put("reSign", "1"); + } + } + } + }else{ + //未签到未签退 + if(signoutOnlyoff){ + if(isOnActive){ + timelineOnMap.put("active", "0"); + timelineOnMap.put("needSign", "0"); + }else{ + timelineOnMap.put("active", "0"); + } + if(isOffActive && !isOnActive){ + timelineOffMap.put("needSign", "1"); + timelineOffMap.put("active", "1"); + }else{ + timelineOffMap.put("active", "0"); + } + }else{ + if(isOnActive){ + timelineOnMap.put("active", "1"); + timelineOnMap.put("needSign", "1"); + }else{ + timelineOnMap.put("active", "0"); + } + if(isOffActive && !isOnActive){ + timelineOffMap.put("needSign", "1"); + timelineOffMap.put("active", "1"); + }else{ + timelineOffMap.put("active", "0"); + } + } + } + } + + }else{ + //如果都不在考勤范围内肯定不能签到签退 + timelineOnMap.put("active", "0"); + timelineOffMap.put("active", "0"); + + timelineOnMap.put("needSign", "0"); + timelineOffMap.put("needSign", "0"); + + } + } + + /** + * 先根据工作时段把考勤timeline基本信息加载一下 + * @param isYesterday + * @param timeLine + * @param timeLineButton + * @param isNextday 是否是明日的 + */ + private void getWorkTimeButton(boolean isYesterday, List timeLine, + List timeLineButton, boolean isNextday) { + boolean show_yes_button = show_yes_button(); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + String yesterday = LocalDate.parse(curDate).minusDays(1).format(dateFormatter); + String nextday = LocalDate.parse(curDate).plusDays(1).format(dateFormatter); + String next_nextday = LocalDate.parse(nextday).plusDays(1).format(dateFormatter); + + for(int i = 0 ; i < timeLine.size() ;){ + Map onTimelineMap = (Map)timeLine.get(i); + Map offTimelineMap = (Map)timeLine.get(i+1); + if(isYesterday){ + //如果允许打卡时间也跨天,那么也需要显示出来按钮 + if(Util.null2String(offTimelineMap.get("signAcross")).equalsIgnoreCase("1")){ + Map onTimelineMapTmp = reBuildYesTimeMap(onTimelineMap,yesterday,"on"); + Map offTimelineMapTmp = reBuildYesTimeMap(offTimelineMap,yesterday,"off"); + if(!show_yes_button && offTimelineMapTmp.containsKey("signSectionTime")){ + String signSectionTime = Util.null2s(Util.null2String(offTimelineMapTmp.get("signSectionTime")),""); + if(signSectionTime.length() > 0 && now.isAfter(LocalDateTime.parse(signSectionTime,fullFormatter))){ + i = i + 2; + continue; + } + } + timeLineButton.add(onTimelineMapTmp); + timeLineButton.add(offTimelineMapTmp); + } + }else if(isNextday){ + if(onTimelineMap.containsKey("sign_preAcross")){ + if("1".equalsIgnoreCase(Util.null2String(onTimelineMap.get("sign_preAcross")))){ + Map onTimelineMapTmp = reBuildNextTimeMap(onTimelineMap,nextday,next_nextday,"on"); + Map offTimelineMapTmp = reBuildNextTimeMap(offTimelineMap,nextday,next_nextday,"off"); + timeLineButton.add(onTimelineMapTmp); + timeLineButton.add(offTimelineMapTmp); + } + } + }else { + Map onTimelineMapTmp = reBuildTimeMap(onTimelineMap,nextday,"on"); + Map offTimelineMapTmp = reBuildTimeMap(offTimelineMap,nextday,"off"); + timeLineButton.add(onTimelineMapTmp); + timeLineButton.add(offTimelineMapTmp); + } + i = i + 2; + } + + } + + /** + * 是否显示昨日失效的考勤按钮 + * @return + */ + public boolean show_yes_button() { + boolean show_yes_button = true; + RecordSet rs = new RecordSet(); + String settingSql = "select * from KQ_SETTINGS where main_key='show_yes_button'"; + rs.executeQuery(settingSql); + if(rs.next()){ + String main_val = rs.getString("main_val"); + if(!"1".equalsIgnoreCase(main_val)){ + show_yes_button = false; + } + } + return show_yes_button; + } + + /** + * 针对前一天的工作时间 根据跨天判断重构一遍数据 + * @param timelineMap + * @param yesterday + * @param isOnOff + */ + private Map reBuildYesTimeMap(Map timelineMap, String yesterday, + String isOnOff) { + + Map lineMap = new HashMap<>(); + + String isacross = Util.null2String(timelineMap.get("isacross")); + String min = Util.null2String(timelineMap.get("min")); + String min_next = Util.null2String(timelineMap.get("min_next")); + String time = Util.null2String(timelineMap.get("time")); + String workmins = Util.null2String(timelineMap.get("workmins")); +// 打卡时段设置 一定是要开启的 + String isPunchOpen = "1"; + String signAcross = Util.null2String(timelineMap.get("signAcross")); + String signAcross_next = Util.null2String(timelineMap.get("signAcross_next")); + int tMin = Util.getIntValue(min,0); + int tMin_next = Util.getIntValue(min_next,-1); + + lineMap.put("type", timelineMap.get("type")); + lineMap.put("serialid", timelineMap.get("serialid")); + lineMap.put("isacross", isacross); + lineMap.put("time", time); + lineMap.put("belongtime", time); + lineMap.put("min", min); + lineMap.put("min_next", min_next); + lineMap.put("workmins", workmins); + lineMap.put("isPunchOpen", isPunchOpen); + lineMap.put("signAcross", signAcross); + lineMap.put("signAcross_next", signAcross_next); + + if("on".equalsIgnoreCase(isOnOff)){ + if("1".equalsIgnoreCase(isacross)){ + //上班时间,跨天 + lineMap.put("date", curDate);//打卡日期 + lineMap.put("belongdate", yesterday);//工作时段所属日期 + lineMap.put("pre", "0");//是否是昨日 + lineMap.put("across", "0");//是否是次日 + lineMap.put("datetime", curDate+" "+time+":00");//应打卡日期+时间 + + String canSignTime = curDate + " "+ time + ":00"; + if(tMin > 0) { + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + if(tMin_next > -1) { + canSignTime = curDate + " "+ time + ":59"; + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin_next); + lineMap.put("signSectionEndTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignEndTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + }else{ + //上班时间,不跨天 + lineMap.put("date", yesterday); + lineMap.put("belongdate", yesterday); + lineMap.put("pre", "1"); + lineMap.put("across", "0"); + lineMap.put("datetime", yesterday+" "+time+":00");//应打卡日期+时间 + String canSignTime = yesterday + " "+ time + ":00"; + + if(tMin > 0) { + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + if(tMin_next > -1) { + canSignTime = yesterday + " "+ time + ":59"; + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin_next); + lineMap.put("signSectionEndTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignEndTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + } + }else{ + if("1".equalsIgnoreCase(isacross)){ + //下班时间,跨天 + lineMap.put("date", curDate); + lineMap.put("belongdate", yesterday); + lineMap.put("pre", "0"); + lineMap.put("across", "0"); + lineMap.put("datetime", curDate+" "+time+":00");//应打卡日期+时间 + String canSignTime = curDate + " "+ time + ":59"; + if(tMin > 0) { + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + if(tMin_next > -1) { + canSignTime = curDate + " "+ time + ":00"; + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin_next); + lineMap.put("signSectionBeginTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignBeginTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + }else{ + //下班时间,不跨天 + lineMap.put("date", yesterday); + lineMap.put("belongdate", yesterday); + lineMap.put("pre", "1"); + lineMap.put("across", "0"); + lineMap.put("datetime", yesterday+" "+time+":00");//应打卡日期+时间 + String canSignTime = yesterday + " "+ time + ":59"; + //如果开启了打卡时段设置 + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + if(tMin_next > -1) { + canSignTime = yesterday + " "+ time + ":00"; + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin_next); + lineMap.put("signSectionBeginTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignBeginTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + } + + } + return lineMap; + } + + /** + * 针对今天的工作时间 根据跨天判断重构一遍数据 + * @param timelineMap + * @param nextday + * @param isOnOff + */ + private Map reBuildTimeMap(Map timelineMap, String nextday, + String isOnOff) { + Map lineMap = new HashMap<>(); + + String isacross = Util.null2String(timelineMap.get("isacross")); + String min = Util.null2String(timelineMap.get("min")); + String time = Util.null2String(timelineMap.get("time")); + String min_next = Util.null2String(timelineMap.get("min_next")); + String workmins = Util.null2String(timelineMap.get("workmins")); +// 打卡时段设置 一定是要开启的 + String isPunchOpen = "1"; + String signAcross = Util.null2String(timelineMap.get("signAcross")); + String signAcross_next = Util.null2String(timelineMap.get("signAcross_next")); + int tMin = Util.getIntValue(min,0); + int tMin_next = Util.getIntValue(min_next,-1); + + lineMap.put("type", timelineMap.get("type")); + lineMap.put("serialid", timelineMap.get("serialid")); + lineMap.put("isacross", isacross); + lineMap.put("time", time); + lineMap.put("belongtime", time); + lineMap.put("min", min); + lineMap.put("min_next", min_next); + lineMap.put("workmins", workmins); + lineMap.put("isPunchOpen", isPunchOpen); + lineMap.put("signAcross", signAcross); + lineMap.put("signAcross_next", signAcross_next); + + if("on".equalsIgnoreCase(isOnOff)){ + if("1".equalsIgnoreCase(isacross)){ + //上班时间,跨天 + lineMap.put("date", nextday); + lineMap.put("belongdate", curDate); + lineMap.put("pre", "0"); + lineMap.put("across", "1"); + lineMap.put("datetime", nextday+" "+time+":00");//应打卡日期+时间 + String canSignTime = nextday + " "+ time + ":00"; + //如果开启了打卡时段设置 + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + if(tMin_next > -1) { + canSignTime = nextday + " "+ time + ":59"; + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin_next); + lineMap.put("signSectionEndTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignEndTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + }else{ + //上班时间,不跨天 + lineMap.put("date", curDate); + lineMap.put("belongdate", curDate); + lineMap.put("pre", "0"); + lineMap.put("across", "0"); + lineMap.put("datetime", curDate+" "+time+":00");//应打卡日期+时间 + String canSignTime = curDate + " "+ time + ":00"; + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + if(tMin_next > -1) { + canSignTime = curDate + " "+ time + ":59"; + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin_next); + lineMap.put("signSectionEndTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignEndTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + } + }else{ + if("1".equalsIgnoreCase(isacross)){ + //下班时间,跨天 + lineMap.put("date", nextday); + lineMap.put("belongdate", curDate); + lineMap.put("pre", "0"); + lineMap.put("across", "1"); + lineMap.put("datetime", nextday+" "+time+":00");//应打卡日期+时间 + String canSignTime = nextday + " "+ time + ":59"; + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + if(tMin_next > -1) { + canSignTime = nextday + " "+ time + ":00"; + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin_next); + lineMap.put("signSectionBeginTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignBeginTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + }else{ + //下班时间,不跨天 + lineMap.put("date", curDate); + lineMap.put("belongdate", curDate); + lineMap.put("pre", "0"); + lineMap.put("across", "0"); + lineMap.put("datetime", curDate+" "+time+":00");//应打卡日期+时间 + String canSignTime = curDate + " "+ time + ":59"; + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + if(tMin_next > -1) { + canSignTime = curDate + " "+ time + ":00"; + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin_next); + lineMap.put("signSectionBeginTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignBeginTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + } + + } + return lineMap; + } + + + /** + * 针对明日的工作时间 根据跨天判断重构一遍数据 + * @param timelineMap + * @param nextday + * @param next_nextday + * @param isOnOff + */ + private Map reBuildNextTimeMap(Map timelineMap, String nextday, String next_nextday, + String isOnOff) { + Map lineMap = new HashMap<>(); + + String isacross = Util.null2String(timelineMap.get("isacross")); + String min = Util.null2String(timelineMap.get("min")); + String time = Util.null2String(timelineMap.get("time")); + String min_next = Util.null2String(timelineMap.get("min_next")); + String workmins = Util.null2String(timelineMap.get("workmins")); +// 打卡时段设置 一定是要开启的 + String isPunchOpen = "1"; + String signAcross = Util.null2String(timelineMap.get("signAcross")); + String signAcross_next = Util.null2String(timelineMap.get("signAcross_next")); + int tMin = Util.getIntValue(min,0); + int tMin_next = Util.getIntValue(min_next,-1); + + lineMap.put("type", timelineMap.get("type")); + lineMap.put("serialid", timelineMap.get("serialid")); + lineMap.put("isacross", isacross); + lineMap.put("time", time); + lineMap.put("belongtime", time); + lineMap.put("min", min); + lineMap.put("min_next", min_next); + lineMap.put("workmins", workmins); + lineMap.put("isPunchOpen", isPunchOpen); + lineMap.put("signAcross", signAcross); + lineMap.put("signAcross_next", signAcross_next); + +// 因为当前是明日的班次,所以这个across就都搞成1,前端的话就显示次日 + if("on".equalsIgnoreCase(isOnOff)){ + if("1".equalsIgnoreCase(isacross)){ + //上班时间,跨天 + lineMap.put("date", next_nextday); + lineMap.put("belongdate", nextday); + lineMap.put("across", "1"); + lineMap.put("datetime", next_nextday+" "+time+":00");//应打卡日期+时间 + String canSignTime = next_nextday + " "+ time + ":00"; + //如果开启了打卡时段设置 + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + if(tMin_next > -1) { + canSignTime = next_nextday + " "+ time + ":59"; + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin_next); + lineMap.put("signSectionEndTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignEndTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + }else{ + //上班时间,不跨天 + lineMap.put("date", nextday); + lineMap.put("belongdate", nextday); + lineMap.put("pre", "0"); + lineMap.put("across", "1"); + lineMap.put("datetime", nextday+" "+time+":00");//应打卡日期+时间 + String canSignTime = nextday + " "+ time + ":00"; + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + if(tMin_next > -1) { + canSignTime = nextday + " "+ time + ":59"; + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin_next); + lineMap.put("signSectionEndTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignEndTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + } + }else{ + if("1".equalsIgnoreCase(isacross)){ + //下班时间,跨天 + lineMap.put("date", next_nextday); + lineMap.put("belongdate", nextday); + lineMap.put("pre", "0"); + lineMap.put("across", "1"); + lineMap.put("datetime", next_nextday+" "+time+":00");//应打卡日期+时间 + String canSignTime = next_nextday + " "+ time + ":59"; + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + if(tMin_next > -1) { + canSignTime = next_nextday + " "+ time + ":00"; + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin_next); + lineMap.put("signSectionBeginTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignBeginTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + }else{ + //下班时间,不跨天 + lineMap.put("date", nextday); + lineMap.put("belongdate", nextday); + lineMap.put("pre", "0"); + lineMap.put("across", "1"); + lineMap.put("datetime", nextday+" "+time+":00");//应打卡日期+时间 + String canSignTime = nextday + " "+ time + ":59"; + if(tMin > 0){ + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).plusMinutes(tMin); + lineMap.put("signSectionTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + if(tMin_next > -1) { + canSignTime = nextday + " "+ time + ":00"; + LocalDateTime tmpLocalDateTime = LocalDateTime.parse(canSignTime, fullFormatter).minusMinutes(tMin_next); + lineMap.put("signSectionBeginTime",tmpLocalDateTime.format(fullFormatter)); + lineMap.put("canSignBeginTime",tmpLocalDateTime.toLocalTime().format(timeFormatter)); + } + } + + } + return lineMap; + } + + public String getCurDate() { + return curDate; + } + + public void setCurDate(String curDate) { + this.curDate = curDate; + } + + public void setNow(LocalDateTime now){ + this.now = now; + } + + public LocalDateTime getNow() { + return now; + } + + public LocalDateTime getZoneOfClientDateTime(String now_date, String now_time, + Map logMap){ + LocalDateTime now_zone = null; + //处理多时区 + String timeZoneConversion = Util.null2String(new BaseBean().getPropValue("weaver_timezone_conversion","timeZoneConversion")).trim(); + logMap.put("timeZoneConversion", timeZoneConversion); + if("1".equals(timeZoneConversion)) { + DateTransformer dateTransformer=new DateTransformer(); + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String[] zone_localTime = dateTransformer.getLocaleDateAndTime(now_date,now_time); + kqLog.info((user != null ? user.getLastname() : "")+"::"+"now_date:"+now_date+":now_time:"+now_time+"::" + +(zone_localTime !=null ? JSON.toJSONString(zone_localTime): "")); + logMap.put("zone_localTime", (zone_localTime !=null ? JSON.toJSONString(zone_localTime): "")); + if(zone_localTime != null && zone_localTime.length == 2){ + now_date = zone_localTime[0]; + now_time = zone_localTime[1]; + } + String dateTime = now_date+" "+now_time; + now_zone = LocalDateTime.parse(dateTime,fullFormatter); + } + logMap.put("now_zone", now_zone); + return now_zone; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/GetExtraMapConfigCmd.java b/src/com/engine/kq/cmd/attendanceButton/GetExtraMapConfigCmd.java new file mode 100644 index 0000000..b7065e0 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/GetExtraMapConfigCmd.java @@ -0,0 +1,52 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.alibaba.fastjson.JSON; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.log.KQLog; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + */ +public class GetExtraMapConfigCmd extends AbstractCommonCommand> { + public KQLog kqLog = new KQLog(); + + public GetExtraMapConfigCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + kqLog.info("params:::::::::"+ JSON.toJSON(params)); + Map retmap = new HashMap(); + try { + RecordSet rs = new RecordSet(); + String mapKey = "extramapconfig"; + rs.executeQuery("select main_val from kq_settings where main_key=?", mapKey); + String mapKeyValue = ""; + if(rs.next()) { + mapKeyValue = rs.getString("main_val"); + } + retmap.put("status", "1"); + retmap.put("mapKeyValue", mapKeyValue); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/attendanceButton/GetOutButtonConditionCmd.java b/src/com/engine/kq/cmd/attendanceButton/GetOutButtonConditionCmd.java new file mode 100644 index 0000000..704d5a6 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/GetOutButtonConditionCmd.java @@ -0,0 +1,87 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 外勤记录 查询条件 + */ +public class GetOutButtonConditionCmd extends AbstractCommonCommand> { + private HttpServletRequest request; + + public GetOutButtonConditionCmd(HttpServletRequest request,Map params, User user) { + this.request = request; + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + List lsCondition = new ArrayList(); + List selOptions = null; + String[] options = null; + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + + HrmFieldBean hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("typeselect"); + hrmFieldBean.setFieldlabel("19482"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setIsFormField(false); +// hrmFieldBean.setFieldvalue(awardDate); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + lsCondition.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("signtypecondition"); + hrmFieldBean.setFieldlabel("25996"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + selOptions = new ArrayList<>(); + selOptions.add(new SearchConditionOption("0",SystemEnv.getHtmlLabelName(332, user.getLanguage()))); + selOptions.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(82634, user.getLanguage()),true)); + selOptions.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(386502, user.getLanguage()))); + hrmFieldBean.setSelectOption(selOptions); + hrmFieldBean.setFieldvalue("2"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setLabelcol(3); + searchConditionItem.setFieldcol(20); + searchConditionItem.setViewAttr(2); + + lsCondition.add(searchConditionItem); + + retmap.put("conditions", lsCondition); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/GetOutButtonRangeCmd.java b/src/com/engine/kq/cmd/attendanceButton/GetOutButtonRangeCmd.java new file mode 100644 index 0000000..e42a92f --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/GetOutButtonRangeCmd.java @@ -0,0 +1,133 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.alibaba.fastjson.JSON; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.entity.KQGroupEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.DateUtil; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 外勤签到签退 关联考勤的时候,打卡范围 + */ +public class GetOutButtonRangeCmd extends AbstractCommonCommand> { + + private KQLog kqLog = new KQLog(); + private String curDate = DateUtil.getCurrentDate(); + private DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + public GetOutButtonRangeCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String outsidesign = ""; + KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID()+""); + if (kqGroupEntity != null) { + outsidesign = kqGroupEntity.getOutsidesign(); + } + kqLog.info("GetOutButtonRangeCmd:outsidesign:"+outsidesign); + List todayLineButton = new ArrayList<>(); + if("1".equalsIgnoreCase(outsidesign)){ + Map todayLineMap = KQDurationCalculatorUtil.getWorkButton(user, curDate,true); + kqLog.info("GetOutButtonRangeCmd:todayLineMap:"+ JSON.toJSONString(todayLineMap)); + if(todayLineMap.get("pre_signTime") != null){ + do4YesterdayLine(todayLineMap,todayLineButton); + } + if(todayLineMap.get("signTime") != null){ + do4TodayLine(todayLineMap,todayLineButton); + } + } + + retmap.put("outsidesign", outsidesign); + retmap.put("signSection", todayLineButton); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private void do4TodayLine(Map todayLineMap, + List todayLineButton) { + List> todaySignTime = (List>)todayLineMap.get("signTime"); + if(todaySignTime != null && !todaySignTime.isEmpty()){ + String yesterday = LocalDate.parse(curDate).minusDays(1).format(dateFormatter); + String nextday = LocalDate.parse(curDate).plusDays(1).format(dateFormatter); + for(int i = 0 ; i < todaySignTime.size() ; i++) { + Map todaySignMap = todaySignTime.get(i); + String bengintime = todaySignMap.get("bengintime"); + String bengintime_across = todaySignMap.get("bengintime_across"); + String endtime = todaySignMap.get("endtime"); + String endtime_across = todaySignMap.get("endtime_across"); + + String signInDateTime = curDate + " " +bengintime+":00"; + if("1".equalsIgnoreCase(bengintime_across)) { + signInDateTime = yesterday + " " +bengintime+":00"; + } + String signOutDateTime = curDate + " " +endtime+":59"; + if("1".equalsIgnoreCase(endtime_across)) { + signOutDateTime = nextday + " " +endtime+":59"; + } + String signSection = signInDateTime+"#"+signOutDateTime; + todayLineButton.add(signSection); + } + } + } + + private void do4YesterdayLine(Map todayLineMap, + List todayLineButton) { + List> yesterdaySignTime = (List>)todayLineMap.get("pre_signTime"); + if(yesterdaySignTime != null && !yesterdaySignTime.isEmpty()){ + String yesterday = LocalDate.parse(curDate).minusDays(1).format(dateFormatter); + String yesyesterday = LocalDate.parse(yesterday).minusDays(1).format(dateFormatter); + for(int i = 0 ; i < yesterdaySignTime.size() ; i++) { + boolean needRecord = false; + Map yesterdaySignMap = yesterdaySignTime.get(i); + String bengintime = yesterdaySignMap.get("bengintime"); + String bengintime_across = yesterdaySignMap.get("bengintime_across"); + String endtime = yesterdaySignMap.get("endtime"); + String endtime_across = yesterdaySignMap.get("endtime_across"); + + String signInDateTime = yesterday + " " +bengintime+":00"; + if("1".equalsIgnoreCase(bengintime_across)) { + signInDateTime = yesyesterday + " " +bengintime+":00"; + } + String signOutDateTime = yesterday + " " +endtime+":59"; + if("1".equalsIgnoreCase(endtime_across)) { + signOutDateTime = curDate + " " +endtime+":59"; + //昨天的只有允许打卡再今天的才记录 + needRecord = true; + } + String signSection = signInDateTime+"#"+signOutDateTime; + if(needRecord){ + todayLineButton.add(signSection); + } + } + } + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/GetOutButtonsCmd.java b/src/com/engine/kq/cmd/attendanceButton/GetOutButtonsCmd.java new file mode 100644 index 0000000..46cecb1 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/GetOutButtonsCmd.java @@ -0,0 +1,232 @@ +package com.engine.kq.cmd.attendanceButton; + +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.KQCardLogBiz; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.biz.KQWorkTime; +import com.engine.kq.entity.KQGroupEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import com.google.common.collect.Maps; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * 获取外勤签到签退按钮 + */ +public class GetOutButtonsCmd extends AbstractCommonCommand> { + + private KQLog kqLog = new KQLog(); + private String curDate = DateUtil.getCurrentDate(); + private Map logMap = Maps.newHashMap(); + private Map workTimeEntityLogMap = Maps.newHashMap(); + + public GetOutButtonsCmd(Map params, User user) { + this.user = user; + this.params = params; + } + /** + * #2599548 + * 概述:满足外勤打卡关联出差、公出流程功能开发需求 + * 检查是否又外勤打卡权限 + * @param userId + * @return + */ + private boolean checkHasOutButton(String userId) { + boolean flag = false; + String sql = ""; + String resourceId = ""; + String startDate = ""; + String startTime = ""; + String endDate = ""; + String endTime = ""; + String fromDateStr = ""; + String endDateStr = ""; + try { + Date cur = new Date(); + String currentDate = DateUtil.getCurrentDate(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + RecordSet rs = new RecordSet(); + //首先判断表里面有没有该人员,没有直接返回,有的话再对比时间 + sql = "select * from kq_flow_split_out where resourceid = ? and belongdate=? "; + rs.executeQuery(sql, userId, currentDate); + while (rs.next()) { + resourceId = rs.getString("resourceid"); + startDate = rs.getString("fromdatedb"); + startTime = rs.getString("fromtimedb"); + endDate = rs.getString("todatedb"); + endTime = rs.getString("totimedb"); + fromDateStr = startDate + " " + startTime; + endDateStr = endDate + " " + endTime; + if (sdf.parse(fromDateStr).before(cur) && sdf.parse(endDateStr).after(cur)) { + flag = true; + } + } + + + //首先判断表里面有没有该人员,没有直接返回,有的话再对比时间 + sql = "select * from kq_flow_split_evection where resourceid = ? and belongdate=? "; + rs.executeQuery(sql, userId, currentDate); + while (rs.next()) { + resourceId = rs.getString("resourceid"); + startDate = rs.getString("fromdatedb"); + startTime = rs.getString("fromtimedb"); + endDate = rs.getString("todatedb"); + endTime = rs.getString("totimedb"); + fromDateStr = startDate + " " + startTime; + endDateStr = endDate + " " + endTime; + + if (sdf.parse(fromDateStr).before(cur) && sdf.parse(endDateStr).after(cur)) { + flag = true; + } + } + + } catch (Exception e) { + writeLog(e); + } + return flag; + } + + @Override + public Map execute(CommandContext commandContext) { + logMap.put("lastname", user.getLastname()); + logMap.put("params", params); + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + + kqLog.info("GetOutButtonsCmd:"+user.getLastname()+"::"+params); + String userId = user.getUID()+""; + //position用的 + String longitude = Util.null2String(params.get("longitude")); + String latitude = Util.null2String(params.get("latitude")); + //wifi用的 + String networkType = Util.null2String(params.get("networkType")); + String mac = Util.null2String(params.get("mac")); + String sid = Util.null2String(params.get("sid")); + + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(user.getUID()+"", curDate); + String userinfo = "#userid#"+user.getUID()+"#getUserSubCompany1#"+user.getUserSubCompany1()+"#getUserSubCompany1#"+user.getUserDepartment() + +"#getJobtitle#"+user.getJobtitle(); + workTimeEntityLogMap.put("resourceid", userinfo); + workTimeEntityLogMap.put("splitDate", curDate); + workTimeEntityLogMap.put("workTimeEntity", workTimeEntity); + String groupid = workTimeEntity.getGroupId(); + logMap.put("groupid", groupid); + String outsidesign = ""; + String outsignapprove = ""; + KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID()+""); + String kqGroupEntityInfo = kqGroupEntity != null ? JSON.toJSONString(kqGroupEntity): ""; + logMap.put("kqGroupEntityInfo", kqGroupEntityInfo); + kqLog.info("GetOutButtonsCmd:"+user.getLastname()+":groupid:"+groupid+":kqGroupEntity:"+(kqGroupEntity != null ? JSON.toJSONString(kqGroupEntity): "")); + if (kqGroupEntity != null) { + outsidesign = kqGroupEntity.getOutsidesign(); + outsignapprove = kqGroupEntity.getOutsignapprove(); + } + + String rangekey = ""; + String rangeid = ""; + String rangename = ""; + boolean isRange = false; + boolean isLocationRange = false; + boolean isWifiRange = false; + + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map locationMap = kqGroupBiz.checkLocationScope(userId,longitude,latitude); + String locationNeedCheck = Util.null2String(locationMap.get("needCheck")); + boolean locationInScope = Boolean.parseBoolean(Util.null2String(locationMap.get("inScope"))); + logMap.put("locationMap", locationMap); + if("1".equalsIgnoreCase(locationNeedCheck)){ + if(locationInScope){ + Map loactionInfo = (Map) locationMap.get("loactionInfo"); + isLocationRange = true; + rangeid = Util.null2String(loactionInfo.get("id")); + rangename = Util.null2String(loactionInfo.get("locationname")); + rangekey = "position"; + }else{ + kqLog.info(user.getLastname()+":办公地点不在考勤范围内:GetOutButtonsCmd:userId:"+userId+":longitude:"+longitude+":latitude:"+latitude); + } + } + //优先返回地点信息 + String wifiNeedCheck = ""; + logMap.put("isLocationRange", isLocationRange); + kqLog.info("GetOutButtonsCmd:"+user.getLastname()+":isLocationRange:"+isLocationRange+":locationMap:"+ JSONObject.toJSONString(locationMap)); + if(!isLocationRange){ + if("wifi".equalsIgnoreCase(networkType)){ + Map wifiMap = kqGroupBiz.checkWifiScope(userId, sid, mac); + logMap.put("wifiMap", wifiMap); + wifiNeedCheck = Util.null2String(wifiMap.get("needCheck")); + boolean wifiInScope = Boolean.parseBoolean(Util.null2String(wifiMap.get("inScope"))); + if("1".equalsIgnoreCase(wifiNeedCheck)){ + if(wifiInScope){ + Map wifiInfo = (Map) wifiMap.get("wifiInfo"); + isWifiRange = true; + rangename = Util.null2String(wifiInfo.get("wifiname")); + rangekey = "wifi"; + }else{ + kqLog.info(user.getLastname()+":wifi不在考勤范围内:GetOutButtonsCmd:userId:"+userId+":sid:"+sid+":mac:"+mac); + } + } + } + } + + isRange = isLocationRange || isWifiRange; + if("1".equalsIgnoreCase(locationNeedCheck) && !isLocationRange){ + retmap.put("failkey", "position"); + }else if("1".equalsIgnoreCase(wifiNeedCheck) && !isWifiRange){ + retmap.put("failkey", "wifi"); + } + + retmap.put("outsidesign", outsidesign); + retmap.put("isrange", isRange ? "1" : "0"); + retmap.put("rangekey", rangekey); + retmap.put("locationid", rangeid); + retmap.put("rangename", rangename); + retmap.put("status", "1"); + + //#2599548 + //概述:满足外勤打卡关联出差、公出流程功能开发需求 + if ("1".equalsIgnoreCase(outsignapprove)) { + retmap.put("outsignapprove", "1");//开启开关,准备拦截 + retmap.put("message", SystemEnv.getHtmlLabelName(545429, user.getLanguage())); + boolean isSubmitBusinessProcessFlag = checkHasOutButton(user.getUID() + ""); + if (isSubmitBusinessProcessFlag) {//已经有公出、或者请假流程,拦截放开 + retmap.put("outsignapprove", "0"); + } + } else { + retmap.put("outsignapprove", "0"); + } + + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + logMap.put("retmap", retmap); + kqLog.info(user.getLastname() + ":GetOutButtonsCmd:retmap:" + retmap); + KQCardLogBiz.logCardInfo(user.getUID() + "", logMap, workTimeEntityLogMap, "outButtons"); + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/GetOutSearchListCmd.java b/src/com/engine/kq/cmd/attendanceButton/GetOutSearchListCmd.java new file mode 100644 index 0000000..18a5293 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/GetOutSearchListCmd.java @@ -0,0 +1,250 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.api.doc.detail.util.DocDownloadCheckUtil; +import com.api.hrm.service.HrmMobileSignInService; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.log.KQLog; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import weaver.conn.RecordSet; +import weaver.crm.Maint.CustomerInfoComInfo; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.mobile.sign.HrmSign; +import weaver.mobile.sign.MobileSign; +import weaver.systeminfo.SystemEnv; + +/** + * 外勤记录 + */ +public class GetOutSearchListCmd extends AbstractCommonCommand> { + private KQLog kqLog = new KQLog(); + private HttpServletRequest request; + private HttpServletResponse response; + + public GetOutSearchListCmd(HttpServletRequest request,Map params, User user, + HttpServletResponse response) { + this.request = request; + this.user = user; + this.params = params; + this.response = response; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + CustomerInfoComInfo customerInfoComInfo = new CustomerInfoComInfo(); + List outLists = new ArrayList<>(); + Map outMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + + HrmMobileSignInService mobileSignInService = new HrmMobileSignInService(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + String typeselectselect =Util.null2String(jsonObj.get("typeselectselect")); + String typeselectfrom =Util.null2String(jsonObj.get("typeselectfrom")); + String typeselectto =Util.null2String(jsonObj.get("typeselectto")); + + if (!typeselectselect.equals("") && !typeselectselect.equals("0") && !typeselectselect.equals("6")) { + fromDate = TimeUtil.getDateByOption(typeselectselect, "0"); + toDate = TimeUtil.getDateByOption(typeselectselect, "1"); + }else{ + fromDate = typeselectfrom; + toDate = typeselectto; + } + //0表示全部,1表示外勤,2表示移动端 + String signtypecondition = Util.null2String(jsonObj.get("signtypecondition")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + int pageIndex = Util.getIntValue(Util.null2String(jsonObj.get("pageIndex")), -1); + int pageSize = Util.getIntValue(Util.null2String(jsonObj.get("pageSize")), -1); + //order表示正序0还是倒序1(desc) + String order = Util.null2String(jsonObj.get("order")); + boolean isDesc = false; + if("1".equalsIgnoreCase(order)){ + isDesc = true; + } + + int count = 0; + int pageCount = 0; + int isHavePre = 0; + int isHaveNext = 0; + + if(resourceId.length()==0){ + resourceId = ""+user.getUID(); + } + + if(!mobileSignInService.hasRight(request, response)) { + retmap.put("status", "-1"); + retmap.put("hasRight", false); + return retmap; + } + + String beginQueryDate = ""; + String endQueryDate = ""; + if(fromDate.length()>0){ + beginQueryDate = fromDate+" 00:00:00"; + } + if(toDate.length()>0){ + endQueryDate = toDate+" 23:59:59"; + } + List paramLists = new ArrayList<>(); + List paramList = null; + String resourceSql = "select id from HrmResource where status in (0,1,2,3,5)"; + if(!"".equals(resourceId)){ + resourceSql += " and id in("+ KQReportBiz.splitParamStr(resourceId)+") "; + for(String bean : resourceId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + String backfields = " uniqueid,id,operater,operate_type,operate_date,operate_time,LONGITUDE,LATITUDE,address,remark,attachment,signtype,crm "; + String fromSql = " "; + String sqlWhere = " where 1=1 "; + String orderby = " order by operate_date "+(isDesc?"desc":"asc")+",operate_time "+(isDesc?"desc":"asc")+" " ; + String descOrderBy = " order by operate_date "+(isDesc?"asc":"desc")+",operate_time "+(isDesc?"asc":"desc")+" " ; + + String hrmSignSql = HrmSign.CreateHrmSignSql4E9(resourceSql, beginQueryDate, endQueryDate); + String mobileSignSql = MobileSign + .CreateMobileSignSql(resourceSql, beginQueryDate, endQueryDate); + String UNIONsql = ""; + if("1".equals(signtypecondition)){ + UNIONsql = hrmSignSql; + }else if("2".equals(signtypecondition)){ + UNIONsql = mobileSignSql; + }else{ + UNIONsql = hrmSignSql + " UNION "+ mobileSignSql; + } + + fromSql = " from ( "+UNIONsql+" ) tmp "; + + String sql = " select count(tmpcol) as c from ( select 1 as tmpcol "+fromSql+sqlWhere+") t"; + rs.executeQuery(sql, paramLists); + 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; + + sql = backfields + fromSql + sqlWhere ; + + 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 if (rs.getDBType().equals("postgresql")) { + sql = " select * from (select " + sql+") t "+orderby; + sql = "select t1.* from (" + sql + ") t1 limit " + pageSize + " offset " + ((pageIndex - 1) * pageSize); + } + else { + 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+ orderby; + } + + rs.executeQuery(sql, resourceId); + kqLog.info("pageIndex:"+pageIndex+":pageSize:"+pageSize+":sql:"+sql); + while (rs.next()){ + String id = rs.getString("id"); + String operate_type = rs.getString("operate_type"); + String operate_date = rs.getString("operate_date"); + String operate_time = rs.getString("operate_time"); + String longitude = rs.getString("longitude"); + String latitude = rs.getString("latitude"); + String address = rs.getString("address"); + String remark = rs.getString("remark"); + String attachment = rs.getString("attachment"); + List attachments = Util.TokenizerString(attachment, ","); + String date = operate_date+" "+operate_time; + outMap = new HashMap<>(); + outMap.put("id", id); + outMap.put("operate_type", operate_type); + outMap.put("date", date); + Map positionMap = new HashMap<>(); + positionMap.put("longitude", longitude); + positionMap.put("latitude", latitude); + positionMap.put("address", address); + outMap.put("position", positionMap); + outMap.put("remark", remark); + List attachmentList = new ArrayList<>(); + if(!attachments.isEmpty()){ + for(String attach : attachments) { + attachmentList.add(DocDownloadCheckUtil.checkPermission(attach,null)); + } + } + outMap.put("attachment", attachmentList); + List crmList = new ArrayList<>(); + String crm = Util.null2String(rs.getString("crm")); + if(!"".equals(crm)){ + List ids = Util.splitString2List(crm, ","); + for(String key : ids) { + crmList.add(customerInfoComInfo.getCustomerInfoname(key)); + } + } + outMap.put("crm", crmList); + outLists.add(outMap); + } + + retmap.put("status", "1"); + retmap.put("datas", outLists); + 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) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + kqLog.info("外勤打卡报错:GetOutSearchListCmd:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/GetOutSignSetting.java b/src/com/engine/kq/cmd/attendanceButton/GetOutSignSetting.java new file mode 100644 index 0000000..483012c --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/GetOutSignSetting.java @@ -0,0 +1,144 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.entity.KQGroupEntity; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * 获取考勤组的基本信息的 + */ +public class GetOutSignSetting extends AbstractCommonCommand> { + + public GetOutSignSetting(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + String remark = Util.null2String(Prop.getInstance().getPropValue("hrm_outsign_setting", "remark")); + String photo = Util.null2String(Prop.getInstance().getPropValue("hrm_outsign_setting", "photo")); + String nearly = Util.null2String(Prop.getInstance().getPropValue("hrm_outsign_setting", "nearly"), "1"); + String poitypes = Util.null2String(Prop.getInstance().getPropValue("hrm_outsign_setting", "poitypes"), "170000"); + String showCompanyName = Util.null2String(Prop.getInstance().getPropValue("hrm_outsign_setting", "showCompanyName")); + if("".equals(poitypes)) + poitypes = "170000"; + if("".equals(nearly)) + nearly = "1"; + if("".equals(showCompanyName)) + showCompanyName = "0"; + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String outsignapprove = ""; + KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID()+""); + if (kqGroupEntity != null) { + outsignapprove = kqGroupEntity.getOutsignapprove(); + } + //#2599548 + //概述:满足外勤打卡关联出差、公出流程功能开发需求 + if ("1".equalsIgnoreCase(outsignapprove)) { + retmap.put("outsignapprove", "1");//开启开关,准备拦截 + retmap.put("message", SystemEnv.getHtmlLabelName(545429, user.getLanguage())); + boolean isSubmitBusinessProcessFlag = checkHasOutButton(user.getUID() + ""); + if (isSubmitBusinessProcessFlag) {//已经有公出、或者请假流程,拦截放开 + retmap.put("outsignapprove", "0"); + } + } else { + retmap.put("outsignapprove", "0"); + } + retmap.put("status", "1"); + retmap.put("remark", remark); + retmap.put("photo", photo); + retmap.put("nearly", nearly); + retmap.put("showCompanyName", showCompanyName); + retmap.put("poitypes", poitypes); + }catch (Exception ex){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + + ex.printStackTrace(); + writeLog(ex); + } + return retmap; + } + /** + * #2599548 + * 概述:满足外勤打卡关联出差、公出流程功能开发需求 + * 检查是否又外勤打卡权限 + * @param userId + * @return + */ + private boolean checkHasOutButton(String userId) { + boolean flag = false; + String sql = ""; + String resourceId = ""; + String startDate = ""; + String startTime = ""; + String endDate = ""; + String endTime = ""; + String fromDateStr = ""; + String endDateStr = ""; + try { + Date cur = new Date(); + String currentDate = DateUtil.getCurrentDate(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + RecordSet rs = new RecordSet(); + //首先判断表里面有没有该人员,没有直接返回,有的话再对比时间 + sql = "select * from kq_flow_split_out where resourceid = ? and belongdate=? "; + rs.executeQuery(sql, userId, currentDate); + while (rs.next()) { + resourceId = rs.getString("resourceid"); + startDate = rs.getString("fromdatedb"); + startTime = rs.getString("fromtimedb"); + endDate = rs.getString("todatedb"); + endTime = rs.getString("totimedb"); + fromDateStr = startDate + " " + startTime; + endDateStr = endDate + " " + endTime; + if (sdf.parse(fromDateStr).before(cur) && sdf.parse(endDateStr).after(cur)) { + flag = true; + } + } + + + //首先判断表里面有没有该人员,没有直接返回,有的话再对比时间 + sql = "select * from kq_flow_split_evection where resourceid = ? and belongdate=? "; + rs.executeQuery(sql, userId, currentDate); + while (rs.next()) { + resourceId = rs.getString("resourceid"); + startDate = rs.getString("fromdatedb"); + startTime = rs.getString("fromtimedb"); + endDate = rs.getString("todatedb"); + endTime = rs.getString("totimedb"); + fromDateStr = startDate + " " + startTime; + endDateStr = endDate + " " + endTime; + + if (sdf.parse(fromDateStr).before(cur) && sdf.parse(endDateStr).after(cur)) { + flag = true; + } + } + + } catch (Exception e) { + writeLog(e); + } + return flag; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/attendanceButton/GetUserLastMapCmd.java b/src/com/engine/kq/cmd/attendanceButton/GetUserLastMapCmd.java new file mode 100644 index 0000000..f73a800 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/GetUserLastMapCmd.java @@ -0,0 +1,53 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.log.KQLog; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取用户最后一次选择的地图 + */ +public class GetUserLastMapCmd extends AbstractCommonCommand> { + public KQLog kqLog = new KQLog(); + + public GetUserLastMapCmd(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 userid = user.getUID()+""; + + String user_last_map = GetButtonBaseInfoCmd.get_user_last_map(userid); + if(user_last_map.length() > 0){ + retmap.put("user_last_map", user_last_map); + } + + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + kqLog.info(user.getLastname()+":GetUserLastMapCmd:retmap:"+retmap); + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/PunchButton4E.java b/src/com/engine/kq/cmd/attendanceButton/PunchButton4E.java new file mode 100644 index 0000000..e606156 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/PunchButton4E.java @@ -0,0 +1,287 @@ +package com.engine.kq.cmd.attendanceButton; + +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.log.KQLog; +import com.engine.kq.timer.KQTaskBean; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.util.face.hrmrestful.service.KqPunchButton4EWebServiceManager; +import com.engine.kq.wfset.util.SplitActionUtil; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.dateformat.DateTransformer; +import weaver.dateformat.TimeZoneVar; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 考勤的 签到签退 + */ +public class PunchButton4E extends AbstractCommonCommand> { + public KQLog kqLog = new KQLog(); + private HttpServletRequest request; + private static KqPunchButton4EWebServiceManager manager= new KqPunchButton4EWebServiceManager() ; + public PunchButton4E(HttpServletRequest request,Map params, User user) { + this.request = request; + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + insertSign(retmap); + + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + kqLog.info(user.getLastname()+":PunchButton4E:retmap:"+retmap); + + return retmap; + } + + + public void insertSign(Map retmap) throws Exception{ + try { + // 需要传ip--我们有ip限制 + // 需要传mac地址,我们有mac地址匹配 + // 需要传打卡地址,系统要显示 + kqLog.info("params:::"+JSON.toJSONString(params)); + String accessToken = Util.null2String(params.get("access_token")); + String userid = Util.null2String(params.get("userid")); + User user = new User(Util.getIntValue(userid, 1)); + String type = Util.null2String(params.get("type")); + String longitude = Util.null2String(params.get("longitude")); + String latitude = Util.null2String(params.get("latitude")); + String checkAddress = Util.null2String(params.get("checkAddress")); // 打卡地址 + String clientTypeNew = Util.null2String(params.get("client_type_new")); // 是否来自鸿蒙系统; 5代表来自鸿蒙 + String showaddress =checkAddress; + if("".equals(userid)) { + retmap.put("errcode", "-1"); + retmap.put("errmsg", SystemEnv.getHtmlLabelName(129699,user.getLanguage())); + kqLog.info("punchButton4E:data:"+JSONObject.toJSONString(retmap)); + return; + } + if("".equals(longitude) || "".equals(latitude) || "".equals(checkAddress)) { + retmap.put("errcode", "-1"); + retmap.put("errmsg", SystemEnv.getHtmlLabelName(504565,user.getLanguage())); + kqLog.info("punchButton4E:data:"+JSONObject.toJSONString(retmap)); + return; + } + + String mac = Util.null2String(params.get("wifiId")); // wifiId就是Mac地址 + String wifiName = Util.null2String(params.get("wifiName")); +// String mac = Util.null2String(params.get("mac")); + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + LocalTime localTime = LocalTime.now(); + String signTime =localTime.format(dateTimeFormatter); + String signDate = LocalDate.now().format(dateFormatter); + String belongdate = getBelongDate(user, DateUtil.getCurrentDate(), signDate+" "+signTime); + +// manager.checkToken(Util.null2String(request.getParameter(Prop.getPropValue("QC1008221", "tokenName"))).trim(), +// Util.null2String(request.getParameter(Prop.getPropValue("QC1008221", "randomName"))).trim()); + + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map locationMap = kqGroupBiz.checkLocationScope(userid+"",longitude,latitude); + kqLog.info("locationMap:::"+JSON.toJSONString(locationMap)); + + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupMemberComInfo.setIsFormat(true); + KQLoactionComInfo kqLoactionComInfo = new KQLoactionComInfo(); + String groupId = kqGroupMemberComInfo.getKQGroupId(userid); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + String locationshowaddress = kqGroupComInfo.getLocationshowaddress(groupId); + if(locationshowaddress.equals("1")){//记录统一地址 + Map loactionInfo = (Map) locationMap.get("loactionInfo"); + if(loactionInfo != null) { + String locationid = Util.null2String(loactionInfo.get("id"));//办公地点id + if(locationid.length()>0){//如果开启统一显示,就用配置的地址 + checkAddress = kqLoactionComInfo.getLocationname(locationid); + } + } + } + + String timeZone = Util.null2String(TimeZoneVar.getTimeZone(),""); + //处理多时区 + String timeZoneConversion = Util.null2String(new weaver.general.BaseBean().getPropValue("weaver_timezone_conversion","timeZoneConversion")).trim(); + if("1".equals(timeZoneConversion)) { + DateTransformer dateTransformer=new DateTransformer(); + String[] zone_localTime = dateTransformer.getLocaleDateAndTime(signDate,signTime); + if(zone_localTime != null && zone_localTime.length == 2){ + signDate = zone_localTime[0]; + signTime = zone_localTime[1]; + } + } + + String signType = "CHECKIN".equalsIgnoreCase(type) ? "1" : "2"; + String clientAddress = Util.getIpAddr(request); + boolean isInIp = checkIsInIp(request, userid); + if(!isInIp){ + retmap.put("errcode", "-1"); + retmap.put("errmsg", SystemEnv.getHtmlLabelName(20157,user.getLanguage())); + kqLog.info("punchButton4E:data:"+JSONObject.toJSONString(retmap)); + return; + } + String isInCom = "1"; + + //记录下是来自于小e的打卡 + String signfrom = "xiaoe"; + + boolean needLocationRange = false; + boolean needWifiRange = false; + boolean isLocationRange = false; + boolean isWifiRange = false; + + String locationNeedCheck = Util.null2String(locationMap.get("needCheck")); + boolean locationInScope = Boolean.parseBoolean(Util.null2String(locationMap.get("inScope"))); + if("1".equalsIgnoreCase(locationNeedCheck)){ + needLocationRange = true; + if(locationInScope){ + isLocationRange = true; + } + } + String wifiNeedCheck = ""; + Map wifiMap = kqGroupBiz.checkWifiScope(userid+"", wifiName, mac); + kqLog.info("wifiMap:::"+JSON.toJSONString(wifiMap)); + wifiNeedCheck = Util.null2String(wifiMap.get("needCheck")); + boolean wifiInScope = Boolean.parseBoolean(Util.null2String(wifiMap.get("inScope"))); + if("1".equalsIgnoreCase(wifiNeedCheck)){ + needWifiRange = true; + if(wifiInScope){ + isWifiRange = true; + } + } + if(needLocationRange){ + if(isLocationRange){ + }else{ + if(needWifiRange && !"".equals(mac)){ + if(isWifiRange){ + }else{ + //地理位置开启,而且不在范围内,且开启wifi验证,不在范围内 + retmap.put("errmsg", SystemEnv.getHtmlLabelName(507524, user.getLanguage())); + isInCom = "0"; + } + }else { + //地理位置开启,而且不在范围内,且未开启wifi验证 + retmap.put("errmsg", SystemEnv.getHtmlLabelName(500510, user.getLanguage())); + isInCom = "0"; + } + } + }else{ + if(needWifiRange) { + if (isWifiRange) { + } else { + //地理位置未开启,且开启wifi验证,不在范围内 + retmap.put("errmsg", SystemEnv.getHtmlLabelName(507524, user.getLanguage())); + isInCom = "0"; + } + } + } + if("5".equals(clientTypeNew)) { + signfrom = "huawei"; + } + + RecordSet rs = new RecordSet(); + String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo,showaddress) "+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + boolean isOk = rs.executeUpdate(punchSql,userid,1,signType,signDate,signTime,clientAddress,isInCom, + timeZone,belongdate,signfrom,longitude,latitude,checkAddress,null,showaddress); + if(!isOk){ + retmap.put("errcode", "-1"); + retmap.put("errmsg", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + return; + } + kqLog.info(user.getLastname()+":punchButton4E:punchSql:"+punchSql+":isOk:"+isOk); + + //打卡提醒处理 + String remindSql = "insert into hrmschedulesign_remind(userId,signType,signDate,signTime,belongdate) values(?,?,?,?,?)"; + isOk = rs.executeUpdate(remindSql, userid, signType, signDate, signTime, belongdate); + kqLog.info(user.getLastname()+":punchButton4E:remindSql:"+remindSql+":isOk:"+isOk); + + //同步更新考勤数据到考勤报表 + new KQFormatBiz().formatDate(""+userid,(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate)); + //点击签退的时候,可能存在加班数据生成的情况 + List tasks = new ArrayList<>(); + List after_tasks = new ArrayList<>(); + SplitActionUtil.pushOverTimeTasks(belongdate, belongdate, userid,tasks); + if(!tasks.isEmpty()){ + for(KQTaskBean kqTaskBean : tasks){ + after_tasks.add(kqTaskBean); + } + } + if(retmap.isEmpty()) { + retmap.put("errcode","1"); + retmap.put("errmsg",SystemEnv.getHtmlLabelName(512596, Util.getIntValue(user.getLanguage()))); + } else { + retmap.put("errcode","-1"); + } + } catch (Exception e){ + this.writeLog(e); + retmap.put("errcode","-1") ; + retmap.put("errmsg","系统错误:"+e.getMessage()) ; + } + + kqLog.info("punchButton4E:data:"+JSONObject.toJSONString(retmap)); + } + + private boolean checkIsInIp(HttpServletRequest request, String userId) { +// if("1".equalsIgnoreCase(ismobile)){ +// return true; +// } + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + String clientAddress = Util.getIpAddr(request); + kqLog.info("punchButton4E:clientAddress:"+clientAddress); + return kqGroupBiz.getIsInScopeV4V6(userId, clientAddress,"1"); + } + + /** + * 归属日期 + * @param user + * @param curDate + * @param signDateTime + * @return + */ + private String getBelongDate(User user, String curDate, String signDateTime) { + String belongDate = curDate; + Map todayLineMap = KQDurationCalculatorUtil.getWorkButton(user, curDate,true); + if(todayLineMap != null) { + List> preInfo = (ArrayList>)todayLineMap.get("pre_signTime"); + if(preInfo != null) { + for(Map entry : preInfo) { + String pre_endtime_across = entry.get("endtime_across"); + String pre_endtime = entry.get("endtime"); + String signEndInfo = "1".equals(pre_endtime_across) ? (curDate+" "+pre_endtime+":00") : (DateUtil.addDate(curDate,-1)+" "+pre_endtime+":00"); + String signOutDateTime = signDateTime; + if(signOutDateTime.compareTo(signEndInfo) < 0) { + belongDate = DateUtil.addDate(curDate, -1); + } + } + } + } + return belongDate; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/PunchButtonCmd.java b/src/com/engine/kq/cmd/attendanceButton/PunchButtonCmd.java new file mode 100644 index 0000000..fe999c7 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/PunchButtonCmd.java @@ -0,0 +1,658 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.cloudstore.dev.api.util.EMManager; +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.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.entity.KQGroupEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.timer.KQQueue; +import com.engine.kq.timer.KQTaskBean; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.google.common.collect.Maps; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.EncodingUtils; +import weaver.conn.RecordSet; +import weaver.dateformat.DateTransformer; +import weaver.dateformat.TimeZoneVar; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.Map.Entry; + +/** + * 考勤的 签到签退 + */ +public class PunchButtonCmd extends AbstractCommonCommand> { + public KQLog kqLog = new KQLog(); + private HttpServletRequest request; + private Map logMap = Maps.newHashMap(); + private Map workTimeEntityLogMap = Maps.newHashMap(); + + public PunchButtonCmd(HttpServletRequest request,Map params, User user) { + this.request = request; + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + insertSign(retmap); + + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + kqLog.info(user.getLastname()+":PunchButtonCmd:retmap:"+retmap); + KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "punchButton"); + + return retmap; + } + + /** + * 检验ip是否在考勤组设置的范围要求内 + * @param ismobile + */ + private boolean checkIsInIp(String ismobile) { +// if("1".equalsIgnoreCase(ismobile)){ +// return true; +// } + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + String clientAddress = Util.getIpAddr(request); + kqLog.info("PunchButtonCmd:clientAddress:"+clientAddress); + return kqGroupBiz.getIsInScopeV4V6(user.getUID()+"", clientAddress,ismobile); + } + + public void insertSign(Map retmap) throws Exception{ + logMap.put("lastname", user.getLastname()); + logMap.put("params", params); + kqLog.info(user.getLastname()+":PunchButtonCmd:params:"+params); + RecordSet rs = new RecordSet(); + String deviceInfo = Util.null2String(params.get("deviceInfo")); + JSONObject jsonObject = null; + if(deviceInfo.length() > 0){ + jsonObject = JSON.parseObject(deviceInfo); + JSONObject jsonObject1 = new JSONObject(); + Set> jsonSet = jsonObject.entrySet(); + for(Entry js : jsonSet){ + String key = js.getKey(); + String value = Util.null2String(js.getValue()); + jsonObject1.put(key, value); + } + if(!jsonObject1.isEmpty()){ + deviceInfo = jsonObject1.toJSONString(); + } + } + //应上班 工作时间点 + String time = Util.null2String(params.get("time")); + //应上班 工作时间 带日期 + String datetime = Util.null2String(params.get("datetime")); + //允许打卡时段 带日期 + String signSectionTime = Util.null2String(params.get("signSectionTime")); + //上传照片 + String attachment = Util.null2String(params.get("fileids")); + + //打卡所属worksection的对应的点 + String type = Util.null2String(params.get("type")); + //所属打卡日期 + String belongdate = Util.null2String(params.get("belongdate")); + belongdate = belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate; + String islastsign = Util.null2String(params.get("islastsign")); + String isfirstsign = Util.null2String(params.get("isfirstsign")); + + String workmins = Util.null2String(params.get("workmins")); + //针对非工作时段 签退的时候记录的签到数据 用于计算加班 + String signInTime4Out = Util.null2String(params.get("signInTime4Out")); + //允许打卡的范围 + String signsection = Util.null2String(params.get("signSection")); + + //手机打卡部分 + String longitude = Util.null2String(params.get("longitude")); + String latitude = Util.null2String(params.get("latitude")); + String signData = Util.null2String(params.get("signData")); + double d_longitude = Util.getDoubleValue(longitude); + double d_latitude = Util.getDoubleValue(latitude); + List encrypted = new ArrayList<>(Arrays.asList(Util.null2String(params.get("encryptObj")).split(","))); + + //wifi用的 + String mac = Util.null2String(params.get("mac")); + String sid = Util.null2String(params.get("sid")); + String addr = Util.null2String(params.get("position")); + String showaddress =addr; + String ismobile = Util.null2String(params.get("ismobile")); + //区分是来自于钉钉还是EM7 + String browser = Util.null2String(params.get("browser")); + String mayVirtualLocation = Util.null2s(Util.null2String(params.get("mayVirtualLocation")), "0"); // 是否疑似虚拟定位: 1代表是虚拟定位 + //自由班制处理 + String isfree = Util.null2String(Util.null2String(params.get("isfree")),"0"); + + //上班打卡 允许最晚打卡时间 + String signSectionEndTime = Util.null2String(params.get("signSectionEndTime")); + //下班打卡 允许最早打卡时间 + String signSectionBeginTime = Util.null2String(params.get("signSectionBeginTime")); + + String locationshowaddress = Util.null2String(params.get("locationshowaddress")); + if(locationshowaddress.equals("1")){//记录统一地址 + String locationid = Util.null2String(params.get("locationid"));//办公地点id + if(locationid.length()>0){//如果开启统一显示,就用配置的地址 + KQLoactionComInfo kqLoactionComInfo = new KQLoactionComInfo(); + addr = kqLoactionComInfo.getLocationname(locationid); + } + } + + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + LocalTime localTime = LocalTime.now(); + String signTime =localTime.format(dateTimeFormatter); + String signDate = LocalDate.now().format(dateFormatter); + + String timeZone = Util.null2String(TimeZoneVar.getTimeZone(),""); + //处理多时区 + String timeZoneConversion = Util.null2String(new weaver.general.BaseBean().getPropValue("weaver_timezone_conversion","timeZoneConversion")).trim(); + logMap.put("timeZoneConversion", timeZoneConversion); + if("1".equals(timeZoneConversion)) { + DateTransformer dateTransformer=new DateTransformer(); + String[] zone_localTime = dateTransformer.getLocaleDateAndTime(signDate,signTime); + kqLog.info(user.getLastname()+":TimeZoneVar.getTimeZone():"+TimeZoneVar.getTimeZone()+":zone_localTime:"+JSON.toJSONString(zone_localTime)); + if(zone_localTime != null && zone_localTime.length == 2){ + signDate = zone_localTime[0]; + signTime = zone_localTime[1]; + } + } + + int userId = user.getUID(); + String userType = user.getLogintype(); + String signType = "on".equalsIgnoreCase(type) ? "1" : "2"; + String clientAddress = Util.getIpAddr(request); + boolean isInIp = checkIsInIp(ismobile); + logMap.put("clientAddress", clientAddress); + + if(!isInIp){ + retmap.put("message", SystemEnv.getHtmlLabelName(20157,user.getLanguage())); + retmap.put("isInIp", "0"); + } + String isInCom = isInIp ? "1" : "0"; + + //是否是考勤例外人员 + boolean isExclude = false; + + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(user.getUID()+"", signDate); + String userinfo = "#userid#"+user.getUID()+"#getUserSubCompany1#"+user.getUserSubCompany1()+"#getUserSubCompany1#"+user.getUserDepartment() + +"#getJobtitle#"+user.getJobtitle(); + workTimeEntityLogMap.put("resourceid", userinfo); + workTimeEntityLogMap.put("splitDate", signDate); + workTimeEntityLogMap.put("workTimeEntity", workTimeEntity); + String groupid = workTimeEntity.getGroupId(); + logMap.put("groupid", groupid); + KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID()+""); + String kqGroupEntityInfo = kqGroupEntity != null ? JSON.toJSONString(kqGroupEntity): ""; + logMap.put("kqGroupEntityInfo", kqGroupEntityInfo); + if (kqGroupEntity != null && ("," + kqGroupEntity.getExcludeid() + ",").indexOf("," + user.getUID() + ",")>-1) {//排除人员无需计算考勤时间 + isExclude = true; + } + if(groupid.length()==0){ + groupid="0"; + } + if(encrypted.size()==3) { + // 前端使用组件加密有可能失败,所以兜底加密,将经纬度,时间戳,人员id合并一起md5加密 + String text ="wea"+ userId + groupid; + + kqLog.writeLog(user.getLastname() + "PunchButtonCmd>text=" + text + ";ismobile=" + ismobile); + String md5Text = DigestUtils.md5Hex(text) + "ver"; + kqLog.writeLog("PunchButtonCmd>md5Text=" + md5Text + ";signData=" + signData); + if (!md5Text.equals(encrypted.get(2))) { + kqLog.writeLog("checkSign:md5加密值不一致, text:" + text + ", encrypted2: " + encrypted.get(2)); + retmap.put("status", "0"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + return; + } + + if (Math.abs(System.currentTimeMillis() - Long.parseLong(encrypted.get(0))) > 30 * 60 * 1000) { + kqLog.writeLog("checkSign:相差5分钟,userId:" + userId + ", timeMillis:{}" + encrypted.get(0)); + retmap.put("status", "0"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + return; + } + if (StringUtils.isNumeric(encrypted.get(1)) && !Objects.equals("" + userId, encrypted.get(1))) { + kqLog.writeLog("checkSign:人员不一致, userId:" + userId + ", employeeId:" + encrypted.get(1)); + retmap.put("status", "0"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + return; + } + } else { + retmap.put("status", "0"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + return ; + } + WorkTimeEntity belong_workTimeEntity = kqWorkTime.getWorkTime(user.getUID()+"", belongdate); + int signoutOnlyoff = null!=belong_workTimeEntity?belong_workTimeEntity.getSignoutOnlyoff():0; + + String[] signsections = signsection.split("#"); + if(!"1".equalsIgnoreCase(isfree)){ + if(signsections != null && signsections.length == 2 && signoutOnlyoff != 1){ + //判断是未签到直接签退 + String signedMsg = signedMsg(userId+"", signType, user,signsections,signSectionBeginTime,signSectionEndTime); + if(signedMsg.length() > 0){ + retmap.put("status", "1"); + retmap.put("message", signedMsg); + isInCom = "0"; + } + } + } + + String datetime_timezone = signDate+" "+signTime; + LocalDateTime nowDateTime = LocalDateTime.parse(datetime_timezone,fullFormatter); + kqLog.info("timeZone:"+timeZone+":signDate:"+signDate+":signTime:"+signTime+":nowDateTime:"+nowDateTime); + + if("1".equalsIgnoreCase(signType) && signSectionTime.length() > 0 ){ + LocalDateTime startWorkDateTime = LocalDateTime.parse(signSectionTime,fullFormatter); + if(nowDateTime.isBefore(startWorkDateTime)){ + Duration duration = Duration.between(nowDateTime, startWorkDateTime); + retmap.put("status", "1"); + retmap.put("message", ""+ SystemEnv.getHtmlLabelName(10005326,weaver.general.ThreadVarLanguage.getLang())+""+duration.toMinutes()+""+ SystemEnv.getHtmlLabelName(15049,weaver.general.ThreadVarLanguage.getLang())+""); + isInCom = "0"; + } + + }else if("2".equalsIgnoreCase(signType) && signSectionTime.length() > 0 ){ + LocalDateTime endWorkDateTime = LocalDateTime.parse(signSectionTime,fullFormatter); + if(nowDateTime.isAfter(endWorkDateTime)){ + Duration duration = Duration.between(endWorkDateTime, nowDateTime); + retmap.put("status", "1"); + retmap.put("message", ""+ SystemEnv.getHtmlLabelName(10005327,weaver.general.ThreadVarLanguage.getLang())+""+duration.toMinutes()+""+ SystemEnv.getHtmlLabelName(15049,weaver.general.ThreadVarLanguage.getLang())+""); + isInCom = "0"; + } + } + + //记录下是来自于E9的pc端签到 + String signfrom = "e9pc"; + if("1".equalsIgnoreCase(ismobile)){ + signfrom = "e9mobile"; + boolean needLocationRange = false; + boolean needWifiRange = false; + boolean isLocationRange = false; + boolean isWifiRange = false; + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map locationMap = kqGroupBiz.checkLocationScope(userId+"",longitude,latitude); + logMap.put("locationMap", locationMap); + String locationNeedCheck = Util.null2String(locationMap.get("needCheck")); + boolean locationInScope = Boolean.parseBoolean(Util.null2String(locationMap.get("inScope"))); + if("1".equalsIgnoreCase(locationNeedCheck)){ + needLocationRange = true; + if(locationInScope){ + isLocationRange = true; + } + } + String wifiNeedCheck = ""; + Map wifiMap = kqGroupBiz.checkWifiScope(userId+"", sid, mac); + logMap.put("wifiMap", wifiMap); + wifiNeedCheck = Util.null2String(wifiMap.get("needCheck")); + boolean wifiInScope = Boolean.parseBoolean(Util.null2String(wifiMap.get("inScope"))); + if("1".equalsIgnoreCase(wifiNeedCheck)){ + needWifiRange = true; + if(wifiInScope){ + isWifiRange = true; + } + } + if(needLocationRange){ + if(isLocationRange){ + }else{ + if(needWifiRange){ + if(isWifiRange){ + }else{ + //地理位置开启,而且不在范围内,且开启wifi验证,不在范围内 + retmap.put("message", SystemEnv.getHtmlLabelName(507524, user.getLanguage())); + isInCom = "0"; + } + }else { + //地理位置开启,而且不在范围内,且未开启wifi验证 + retmap.put("message", SystemEnv.getHtmlLabelName(500510, user.getLanguage())); + isInCom = "0"; + } + } + }else{ + if(needWifiRange) { + if (isWifiRange) { + } else { + //地理位置未开启,且开启wifi验证,不在范围内 + retmap.put("message", SystemEnv.getHtmlLabelName(507524, user.getLanguage())); + isInCom = "0"; + } + } + } + + if("DingTalk".equalsIgnoreCase(browser)){ + signfrom = "DingTalk"; + }else if("Wechat".equalsIgnoreCase(browser)){ + signfrom = "Wechat"; + String weChat_deviceid = Util.null2String(request.getSession().getAttribute(EMManager.DeviceId)); + logMap.put("weChat_deviceid", weChat_deviceid); + kqLog.info("EMManager.DeviceId:"+EMManager.DeviceId+":weChat_deviceid:"+weChat_deviceid); + if(weChat_deviceid.length() > 0){ + //微信打卡的设备号需要单独处理 + if(jsonObject != null){ + jsonObject.put("deviceId", weChat_deviceid); + }else{ + jsonObject = new JSONObject(); + jsonObject.put("deviceId", weChat_deviceid); + } + if(!jsonObject.isEmpty()){ + deviceInfo = jsonObject.toJSONString(); + } + } + } + } + String signStatus = ""; + + if(!"1".equalsIgnoreCase(isfree) && datetime.length() > 0){ + signStatus = getSignStatus(signType,datetime,user.getUID()+"",belongdate,nowDateTime); + logMap.put("signStatus", signStatus); + } + + if(isExclude){ + signStatus = ButtonStatusEnum.NORMAL.getStatusCode(); + } + deviceInfo = deviceInfo.replaceAll("\\?", ""); + deviceInfo = EncodingUtils.toUNICODE(deviceInfo); + if(deviceInfo.length() > 0) { + String clientTypeNew = Util.null2String(jsonObject.get("newClientType")); // 是否来自鸿蒙系统; 5代表来自鸿蒙 + if("HarmonyOS".equalsIgnoreCase(clientTypeNew)) { + signfrom = "huawei"; + } + } + String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo,showaddress,attachment,mayVirtualLocation) "+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + boolean isOk = rs.executeUpdate(punchSql,userId,userType,signType,signDate,signTime,clientAddress,isInCom, + timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo,showaddress,attachment,mayVirtualLocation); + if(!isOk){ + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + return ; + } + logMap.put("punchSql", punchSql); + logMap.put("punchSql_isOk", isOk); + kqLog.info(user.getLastname()+":PunchButtonCmd:punchSql:"+punchSql+":isOk:"+isOk); + + //打卡提醒处理 + String remindSql = "insert into hrmschedulesign_remind(userId,signType,signDate,signTime,belongdate) values(?,?,?,?,?)"; + isOk = rs.executeUpdate(remindSql, userId,signType,signDate,signTime,belongdate); + kqLog.info(user.getLastname()+":PunchButtonCmd:remindSql:"+remindSql+":isOk:"+isOk); + + //同步更新考勤数据到考勤报表 + boolean isFormat = false; + if ("1".equals(isfree)) { + //判断下,如果是弹性跨天打卡,当前时间小于考勤开始时间,那就计算下昨天的考勤数据,不然就计算今天的 + boolean isFreezeAcross = KQSettingsBiz.is_freeAcross(); + String nowdate = DateUtil.getCurrentDate(); + String signstart = Util.null2String(new KQWorkTime().getWorkTime(String.valueOf(user.getUID()),nowdate).getSignStart())+":00"; + if (isFreezeAcross && (LocalTime.parse(signTime, dateTimeFormatter).isBefore(LocalTime.parse(signstart, dateTimeFormatter)))) { + new KQFormatBiz().formatDate(""+userId,(belongdate.length() == 0 ? DateUtil.addDate(DateUtil.getCurrentDate(),-1) : DateUtil.addDate(belongdate,-1))); + isFormat = true; + } + } + if (!isFormat) { + new KQFormatBiz().formatDate(""+userId,(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate)); + } + //点击签退的时候,可能存在加班数据生成的情况 + if("2".equalsIgnoreCase(signType)){ + if("1".equalsIgnoreCase(islastsign)){ + List tasks = new ArrayList<>(); + List after_tasks = new ArrayList<>(); + SplitActionUtil.pushOverTimeTasks(belongdate, belongdate, ""+userId,tasks); + if(!tasks.isEmpty()){ + for(KQTaskBean kqTaskBean : tasks){ + after_tasks.add(kqTaskBean); + } + } + logMap.put("after_tasks", after_tasks); + if(!after_tasks.isEmpty()){ + KQQueue.writeTasks(after_tasks); + } + } + } + if("1".equalsIgnoreCase(signType)){ + if("1".equalsIgnoreCase(isfirstsign)){ + List tasks = new ArrayList<>(); + List before_tasks = new ArrayList<>(); + SplitActionUtil.pushOverTimeTasks(belongdate, belongdate, ""+userId,tasks); + if(!tasks.isEmpty()){ + for(KQTaskBean kqTaskBean : tasks){ + kqTaskBean.setTasktype("punchcard"); + before_tasks.add(kqTaskBean); + } + } + logMap.put("before_tasks", before_tasks); + if(!before_tasks.isEmpty()){ + KQQueue.writeTasks(before_tasks); + } + } + } + + String reSignStatus = reSignStatus(user.getUID()+"",signType,nowDateTime,belongdate); + if(Util.null2String(reSignStatus,"").length() > 0){ + signStatus = reSignStatus; + } + + retmap.put("status", "1"); + retmap.put("signdate", signDate); + retmap.put("signtime", signTime); + retmap.put("kqstatus", signStatus); + + if(!"1".equalsIgnoreCase(signStatus) && !"2".equalsIgnoreCase(signStatus)){ + if("".equalsIgnoreCase(Util.null2String(retmap.get("message")))){ + retmap.put("success", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(512596, Util.getIntValue(user.getLanguage()))); + } + } + logMap.put("retmap", retmap); + } + + public String reSignStatus(String userid, String signType, LocalDateTime nowDateTime, + String workdate) { + String signStatus = ""; + + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(userid, workdate,false); + if(shiftInfoBean == null){ + return signStatus; + } + int restShift = shiftInfoBean.getRestShift(); + if(1 == restShift){ + return "-1"; + } + Map shifRuleMap = Maps.newHashMap(); + KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean,userid,shifRuleMap); + KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo(); + if(!shifRuleMap.isEmpty()) { + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String datetime = ""; + if (shifRuleMap.containsKey("shift_beginworktime")) { + String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime")); + if (shift_beginworktime.length() > 0) { + int shift_beginworktime_index = -1; + shift_beginworktime_index = arrayComInfo.getArrayindexByTimes(shift_beginworktime); + datetime = workdate+" "+shift_beginworktime+":00"; + if(shift_beginworktime_index >= 1440){ + //跨天了 + datetime = DateUtil.addDate(workdate, 1)+" "+arrayComInfo.turn48to24Time(shift_beginworktime)+":00"; + } + } + } + if (shifRuleMap.containsKey("shift_endworktime")) { + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if (shift_endworktime.length() > 0) { + int shift_endworktime_index = -1; + shift_endworktime_index = arrayComInfo.getArrayindexByTimes(shift_endworktime); + datetime = workdate+" "+shift_endworktime+":00"; + if(shift_endworktime_index >= 1440) { + //跨天了 + datetime = DateUtil.addDate(workdate, 1)+" "+arrayComInfo.turn48to24Time(shift_endworktime)+":00"; + } + } + } + + if (datetime.length() > 0) { + if("1".equalsIgnoreCase(signType)) { + LocalDateTime startWorkDateTime = LocalDateTime.parse(datetime, fullFormatter); + //打卡时间比上班时间晚,迟到了 + if (nowDateTime.isAfter(startWorkDateTime)) { + signStatus = ButtonStatusEnum.BELATE.getStatusCode(); + } else { + signStatus = ButtonStatusEnum.NORMAL.getStatusCode(); + } + } else if ("2".equalsIgnoreCase(signType)) { + LocalDateTime endWorkDateTime = LocalDateTime.parse(datetime, fullFormatter); + //签退的话 + if (nowDateTime.isBefore(endWorkDateTime)) { + signStatus = ButtonStatusEnum.LEAVEERALY.getStatusCode(); + } else { + signStatus = ButtonStatusEnum.NORMAL.getStatusCode(); + } + } else { + writeLog(user.getLastname() + nowDateTime + ":竟然没有传:" + signType); + return ""; + } + } + } + return signStatus; + } + + /** + * 上班前打卡目前是 视作前一天的跨天加班 + * @param resourceid + * @param pre_splitDate + * @param signtime + * @param pre_bengintime + * @param signdate + */ + public void doBeforeAcrossOvertime(String resourceid,String pre_splitDate,String signtime,String pre_bengintime,String signdate) { + + KQTaskBean kqTaskBean = new KQTaskBean(); + kqTaskBean.setResourceId(resourceid); + kqTaskBean.setTaskDate(pre_splitDate); + kqTaskBean.setLastWorkTime(signtime); + if(pre_bengintime.length() == 5){ + kqTaskBean.setTaskSignTime(pre_bengintime+":00"); + }else{ + kqTaskBean.setTaskSignTime(pre_bengintime); + } + kqTaskBean.setSignDate(signdate); + kqTaskBean.setSignEndDate(signdate); + kqTaskBean.setTimesource("before"); + KQQueue.writeTask(kqTaskBean); + } + + /** + * 校验是否已经签到过 + * @param userid + * @param signtype + * @param curUser + * @param signsections + * @param signSectionBeginTime 下班打卡 允许最早打卡时间 + * @param signSectionEndTime 上班打卡 允许最晚打卡时间 + * @return + */ + public String signedMsg(String userid, String signtype, User curUser, String[] signsections, + String signSectionBeginTime, String signSectionEndTime) throws Exception{ + String signedMsg = ""; + RecordSet rs = new RecordSet(); + boolean hasSigned = false; + String onSignSectionTime = signsections[0]; + String offSignSectionTime = signsections[1]; + if(onSignSectionTime.length() > 0 && offSignSectionTime.length() > 0){ + String hasSign = "select 1 from hrmschedulesign where 1 = 1 and isInCom = '1' and userid = ? "; + + StringBuffer sql = new StringBuffer(); + if(rs.getDBType().equals("oracle")||rs.getDBType().equals("postgresql")){ + sql.append(" AND trim(signDate)||' '||trim(signTime)>=? "); + sql.append(" AND trim(signDate)||' '||trim(signTime)<=? "); + }else if(rs.getDBType().equals("mysql")){ + sql.append(" AND concat(signDate,' ',signTime)>=? "); + sql.append(" AND concat(signDate,' ',signTime)<=? "); + }else{ + sql.append(" AND signDate+' '+signTime>=? "); + sql.append(" AND signDate+' '+signTime<=? "); + } + hasSign += sql.toString(); + rs.executeQuery(hasSign, userid,onSignSectionTime,offSignSectionTime); + if(rs.next()){ + hasSigned = true; + } + if("1".equalsIgnoreCase(signtype)){ + if(signSectionBeginTime.length() > 0 || signSectionEndTime.length() > 0){ + }else{ + if(hasSigned){ + signedMsg = SystemEnv.getHtmlLabelName(129706, curUser.getLanguage()); + } + } + }else if("2".equalsIgnoreCase(signtype)){ + if(signSectionBeginTime.length() > 0 || signSectionEndTime.length() > 0){ + }else{ + if(!hasSigned){ + signedMsg = SystemEnv.getHtmlLabelName(501301, curUser.getLanguage()); + } + } + } + } + return signedMsg; + } + /** + * 在签到签退的时候先根据打卡数据 + * 粗步 得到打卡状态 正常,迟到,早退 + * @return + */ + public String getSignStatus(String signType, String datetime, String userid, String workdate, + LocalDateTime nowDateTime) { + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String signStatus = ""; + + //签到的话 + if("1".equalsIgnoreCase(signType)){ + LocalDateTime startWorkDateTime = LocalDateTime.parse(datetime,fullFormatter); + //打卡时间比上班时间晚,迟到了 + if(nowDateTime.isAfter(startWorkDateTime)){ + signStatus = ButtonStatusEnum.BELATE.getStatusCode(); + }else{ + signStatus = ButtonStatusEnum.NORMAL.getStatusCode(); + } + }else if("2".equalsIgnoreCase(signType)){ + LocalDateTime endWorkDateTime = LocalDateTime.parse(datetime,fullFormatter); + //签退的话 + if(nowDateTime.isBefore(endWorkDateTime)){ + signStatus = ButtonStatusEnum.LEAVEERALY.getStatusCode(); + }else{ + signStatus = ButtonStatusEnum.NORMAL.getStatusCode(); + } + }else{ + writeLog(user.getLastname()+nowDateTime+":竟然没有传:"+signType); + return ""; + } + return signStatus; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/PunchOutButtonCmd.java b/src/com/engine/kq/cmd/attendanceButton/PunchOutButtonCmd.java new file mode 100644 index 0000000..8e4d2d7 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/PunchOutButtonCmd.java @@ -0,0 +1,405 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.cloudstore.dev.api.util.EMManager; +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.entity.KQGroupEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.google.common.collect.Maps; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang.StringUtils; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.EncodingUtils; +import weaver.conn.RecordSet; +import weaver.dateformat.DateTransformer; +import weaver.dateformat.TimeZoneVar; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.Map.Entry; + +/** + * 外勤签到签退 + */ +public class PunchOutButtonCmd extends AbstractCommonCommand> { + private HttpServletRequest request; + public KQLog kqLog = new KQLog(); + private Map logMap = Maps.newHashMap(); + private Map workTimeEntityLogMap = Maps.newHashMap(); + + public PunchOutButtonCmd(HttpServletRequest request,Map params, User user) { + this.request = request; + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + + insertSign(retmap); + + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "punchOutButton"); + return retmap; + } + /** + * #2599548 + * 概述:满足外勤打卡关联出差、公出流程功能开发需求 + * 检查是否又外勤打卡权限 + * @param userId + * @return + */ + private boolean checkHasOutButton(String userId,String nowdatetime) { + boolean flag = false; + String sql = ""; + String resourceId = ""; + String startDate = ""; + String startTime = ""; + String endDate = ""; + String endTime = ""; + String fromDateStr = ""; + String endDateStr = ""; + try { +// Date cur = new Date(); + String currentDate = DateUtil.getCurrentDate(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date cur = !"".equals(StringUtil.vString(nowdatetime))?sdf.parse(nowdatetime):new Date(); + RecordSet rs = new RecordSet(); + //首先判断表里面有没有该人员,没有直接返回,有的话再对比时间 + sql = "select * from kq_flow_split_out where resourceid = ? and belongdate=? "; + rs.executeQuery(sql, userId, currentDate); + while (rs.next()) { + resourceId = rs.getString("resourceid"); + startDate = rs.getString("fromdatedb"); + startTime = rs.getString("fromtimedb"); + endDate = rs.getString("todatedb"); + endTime = rs.getString("totimedb"); + fromDateStr = startDate + " " + startTime; + endDateStr = endDate + " " + endTime; + if (sdf.parse(fromDateStr).before(cur) && sdf.parse(endDateStr).after(cur)) { + flag = true; + } + } + + + //首先判断表里面有没有该人员,没有直接返回,有的话再对比时间 + sql = "select * from kq_flow_split_evection where resourceid = ? and belongdate=? "; + rs.executeQuery(sql, userId, currentDate); + while (rs.next()) { + resourceId = rs.getString("resourceid"); + startDate = rs.getString("fromdatedb"); + startTime = rs.getString("fromtimedb"); + endDate = rs.getString("todatedb"); + endTime = rs.getString("totimedb"); + fromDateStr = startDate + " " + startTime; + endDateStr = endDate + " " + endTime; + + if (sdf.parse(fromDateStr).before(cur) && sdf.parse(endDateStr).after(cur)) { + flag = true; + } + } + + } catch (Exception e) { + writeLog(e); + } + return flag; + } + + /** + * 检验ip是否在考勤组设置的范围要求内 + */ + private boolean checkIsInIp() { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + String clientAddress = Util.getIpAddr(request); + return kqGroupBiz.getIsInScope(user.getUID()+"", clientAddress); + } + + private void insertSign(Map retmap) { + logMap.put("lastname", user.getLastname()); + logMap.put("params", params); +// signSection: 2019-03-20 08:30#2019-03-20 18:30 + + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String serialid = Util.null2String(params.get("serialid")); + //应上班 工作时间点 + String time = Util.null2String(params.get("time")); + //应上班 工作时间 带日期 + String datetime = Util.null2String(params.get("datetime")); + //允许打卡时段 带日期 + String signSectionTime = Util.null2String(params.get("signSectionTime")); + //打卡所属worksection的对应的点 + String type = Util.null2String(params.get("type")); + //所属打卡日期 + String belongdate = Util.null2String(params.get("belongdate")); + boolean belongdateIsNull = belongdate.length()==0; + String islastsign = Util.null2String(params.get("islastsign")); + + String isPunchOpen = Util.null2String(params.get("isPunchOpen")); + + String workmins = Util.null2String(params.get("workmins")); + //针对非工作时段 签退的时候记录的签到数据 用于计算加班 + String signInTime4Out = Util.null2String(params.get("signInTime4Out")); + //允许打卡的范围 + String signsection = Util.null2String(params.get("signSection")); + + //手机打卡部分 + String longitude = Util.null2String(params.get("longitude")); + String latitude = Util.null2String(params.get("latitude")); + double d_longitude = Util.getDoubleValue(longitude); + double d_latitude = Util.getDoubleValue(latitude); + + String address = Util.null2String(params.get("address")); + String showaddress = address; + String ismobile = Util.null2String(params.get("ismobile")); + String remark = Util.null2String(params.get("remark")); + String attachment = Util.null2String(params.get("fileids")); + //区分是来自于钉钉还是EM7 + String browser = Util.null2String(params.get("browser")); + String mayVirtualLocation = Util.null2s(Util.null2String(params.get("mayVirtualLocation")), "0"); // 是否疑似虚拟定位: 1代表是虚拟定位 + //客户 + String crm = Util.null2String(params.get("crm")); + List encrypted = new ArrayList<>(Arrays.asList(Util.null2String(params.get("encryptObj")).split(","))); + //是否开启外勤签到转考勤 + String outsidesign = ""; + String outsignapprove = ""; + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID()+""); + String kqGroupEntityInfo = kqGroupEntity != null ? JSON.toJSONString(kqGroupEntity): ""; + logMap.put("kqGroupEntityInfo", kqGroupEntityInfo); + if (kqGroupEntity != null) { + outsidesign = kqGroupEntity.getOutsidesign(); + outsignapprove = kqGroupEntity.getOutsignapprove(); + } + kqLog.info(user.getLastname()+":params:"+params+":outsidesign:"+outsidesign+";outsignapprove="+outsignapprove); + + + int userId = user.getUID(); + String signfrom = "e9_mobile_out"; + DateTimeFormatter allFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + LocalDateTime localTime = LocalDateTime.now(); + String signTime =localTime.format(dateTimeFormatter); + String signDate = localTime.format(dateFormatter); + + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(user.getUID()+"", signDate); + String userinfo = "#userid#"+user.getUID()+"#getUserSubCompany1#"+user.getUserSubCompany1()+"#getUserSubCompany1#"+user.getUserDepartment() + +"#getJobtitle#"+user.getJobtitle(); + workTimeEntityLogMap.put("resourceid", userinfo); + workTimeEntityLogMap.put("splitDate", signDate); + workTimeEntityLogMap.put("workTimeEntity", workTimeEntity); + + //处理多时区 + String timeZoneConversion = Util.null2String(new weaver.general.BaseBean().getPropValue("weaver_timezone_conversion","timeZoneConversion")).trim(); + logMap.put("timeZoneConversion", timeZoneConversion); + if("1".equals(timeZoneConversion)) { + DateTransformer dateTransformer=new DateTransformer(); + String[] zone_localTime = dateTransformer.getLocaleDateAndTime(signDate,signTime); + if(zone_localTime != null && zone_localTime.length == 2){ + signDate = zone_localTime[0]; + signTime = zone_localTime[1]; + } + } + + //#2599548 + //概述:满足外勤打卡关联出差、公出流程功能开发需求 + if("1".equalsIgnoreCase(outsignapprove)) { + String nowdatetime = signDate+" "+signTime.substring(0,5); + kqLog.info(user.getLastname()+":outsidesign:"+outsidesign+";outsignapprove="+outsignapprove+":nowdatetime:"+nowdatetime); + boolean isSubmitBusinessProcessFlag = checkHasOutButton(user.getUID() + "",nowdatetime); + if (!isSubmitBusinessProcessFlag) { + retmap.put("status", "-1"); + retmap.put("outsignapprove", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(545474, user.getLanguage())); + return; + } + } + + String timeZone = Util.null2String(TimeZoneVar.getTimeZone(),""); + String signData = Util.null2String(params.get("signData")); + String groupid = workTimeEntity.getGroupId(); + if(groupid.length()==0){ + groupid="0"; + } + if(encrypted.size()==3) { + // 前端使用组件加密有可能失败,所以兜底加密,将经纬度,时间戳,人员id合并一起md5加密 + String text ="wea"+ userId + groupid; + + kqLog.writeLog(user.getLastname() + "PunchButtonCmd>text=" + text + ";ismobile=" + ismobile); + String md5Text = DigestUtils.md5Hex(text) + "ver"; + kqLog.writeLog("PunchOutButtonCmd>md5Text=" + md5Text + ";signData=" + signData); + if (!md5Text.equals(encrypted.get(2))) { + kqLog.writeLog("checkSign:md5加密值不一致, text:" + text + ", encrypted2: " + encrypted.get(2)); + retmap.put("status", "0"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + return; + } + + if (Math.abs(System.currentTimeMillis() - Long.parseLong(encrypted.get(0))) > 30 * 60 * 1000) { + kqLog.writeLog("checkSign:相差5分钟,userId:" + userId + ", timeMillis:{}" + encrypted.get(0)); + retmap.put("status", "0"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + return; + } + if (StringUtils.isNumeric(encrypted.get(1)) && !Objects.equals("" + userId, encrypted.get(1))) { + kqLog.writeLog("checkSign:人员不一致, userId:" + userId + ", employeeId:" + encrypted.get(1)); + retmap.put("status", "0"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + return; + } + } else { + retmap.put("status", "0"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + return ; + } + String mobile_sign_sql = "insert into mobile_sign(operater,operate_type,operate_date,operate_time,longitude,latitude,address,remark,attachment,crm,timezone) " + + " values(?,?,?,?,?,?,?,?,?,?,?) "; + rs1.executeUpdate(mobile_sign_sql, userId,signfrom,signDate,signTime,longitude,latitude,address,remark,attachment,crm,timeZone); + + logMap.put("outsidesign", outsidesign); + if("1".equalsIgnoreCase(outsidesign)){ + + JSONObject jsonObject = null; + String deviceInfo = Util.null2String(params.get("deviceInfo")); + if(deviceInfo.length() > 0){ + jsonObject = JSON.parseObject(deviceInfo); + JSONObject jsonObject1 = new JSONObject(); + Set> jsonSet = jsonObject.entrySet(); + for(Entry js : jsonSet){ + String key = js.getKey(); + String value = Util.null2String(js.getValue()); + jsonObject1.put(key, value); + } + if(!jsonObject1.isEmpty()){ + deviceInfo = jsonObject1.toJSONString(); + } + } + + if("DingTalk".equalsIgnoreCase(browser)){ + signfrom = "DingTalk_out"; + }else if("Wechat".equalsIgnoreCase(browser)){ + signfrom = "Wechat_out"; + String weChat_deviceid = Util.null2String(request.getSession().getAttribute(EMManager.DeviceId)); + kqLog.info("EMManager.DeviceId:"+EMManager.DeviceId+":weChat_deviceid:"+weChat_deviceid); + logMap.put("weChat_deviceid", weChat_deviceid); + + if(weChat_deviceid.length() > 0){ + //微信打卡的设备号需要单独处理 + if(jsonObject != null){ + jsonObject.put("deviceId", weChat_deviceid); + }else{ + jsonObject = new JSONObject(); + jsonObject.put("deviceId", weChat_deviceid); + } + if(!jsonObject.isEmpty()){ + deviceInfo = jsonObject.toJSONString(); + } + } + } + //自由班制处理 + String isfree = Util.null2String(params.get("isfree")); + + String userType = user.getLogintype(); + String signType = "on".equalsIgnoreCase(type) ? "1" : "2"; + String clientAddress = Util.getIpAddr(request); + boolean isInIp = true; + + String isInCom = isInIp ? "1" : "0"; + + String datetime_timezone = signDate+" "+signTime; + LocalDateTime nowDateTime = LocalDateTime.parse(datetime_timezone,allFormatter); + kqLog.info("timeZone:"+timeZone+":signDate:"+signDate+":signTime:"+signTime+":nowDateTime:"+nowDateTime); + + boolean isInScope = true; + if(signsection != null && signsection.length() > 0){ + List signsectionList = Util.TokenizerString(signsection, ","); + for(int i = 0 ; i < signsectionList.size() ; i++){ + String signsections = Util.null2String(signsectionList.get(i)); + String[] signsection_arr = signsections.split("#"); + if(signsection_arr != null && signsection_arr.length == 2){ + String canStart = signsection_arr[0]; + String canEnd = signsection_arr[1]; + LocalDateTime startSignDateTime = LocalDateTime.parse(canStart,allFormatter); + LocalDateTime endSignDateTime = LocalDateTime.parse(canEnd,allFormatter); + if(nowDateTime.isBefore(startSignDateTime) || nowDateTime.isAfter(endSignDateTime)){ + isInScope = false; + }else{ + isInScope = true; + break; + } + } + } + } + if(!isInScope){ + //外勤的不在范围内也不管,全部计入考勤表 +// retmap.put("status", "1"); +// retmap.put("message", SystemEnv.getHtmlLabelName(503597 , user.getLanguage())); +// return ; + } + if(belongdate.length() == 0){ + belongdate = signDate; + } + deviceInfo = deviceInfo.replaceAll("\\?", ""); + deviceInfo = EncodingUtils.toUNICODE(deviceInfo); + if(deviceInfo.length() > 0) { + String clientTypeNew = Util.null2String(jsonObject.get("newClientType")); // 是否来自鸿蒙系统; 5代表来自鸿蒙 + if("HarmonyOS".equalsIgnoreCase(clientTypeNew)) { + signfrom = "huawei"; + } + } + String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo,showaddress,attachment,mayVirtualLocation) "+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + boolean isok = rs.executeUpdate(punchSql,userId,userType,signType,signDate,signTime,clientAddress,isInCom, + timeZone,belongdate,signfrom,longitude,latitude,address,deviceInfo,showaddress,attachment,mayVirtualLocation); + + logMap.put("punchSql", punchSql); + logMap.put("punchSql_isok", isok); + //同步更新考勤数据到考勤报表 + if(belongdateIsNull){ + //外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤 + kqLog.info("PunchOutButtonCmd:userId:"+userId+":belongdate:"+DateUtil.getYesterday()); + new KQFormatBiz().formatDate(""+userId,DateUtil.getYesterday()); + } + kqLog.info("PunchOutButtonCmd:userId:"+userId+":belongdate:"+(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate)); + if(belongdate.length()==0){ + //外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤 + new KQFormatBiz().formatDate(""+userId,DateUtil.getYesterday()); + } + new KQFormatBiz().formatDate(""+userId,(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate)); + //外勤签到转的考勤 处理加班规则 + SplitActionUtil.pushOverTimeTasksAll(belongdate,belongdate,""+userId); + } + retmap.put("status", "1"); + retmap.put("signdate", signDate); + retmap.put("signtime", signTime); + logMap.put("retmap", retmap); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/ResetSerialCmd.java b/src/com/engine/kq/cmd/attendanceButton/ResetSerialCmd.java new file mode 100644 index 0000000..548b67e --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/ResetSerialCmd.java @@ -0,0 +1,68 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQFormatBiz; +import com.engine.kq.biz.KQShiftScheduleComInfo; +import com.engine.kq.log.KQLog; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * 自己调整班次 + */ +public class ResetSerialCmd extends AbstractCommonCommand> { + private KQLog kqLog = new KQLog(); + + public ResetSerialCmd(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 serialid = Util.null2String(params.get("serialid")); + String groupid = Util.null2String(params.get("groupid")); + String setDate = Util.null2String(params.get("setDate")); + + String userid = user.getUID()+""; + kqLog.info("ResetSerialCmd user:"+user.getLastname()+":serialid:"+serialid+":groupid:"+groupid); + String curDate = DateUtil.getCurrentDate(); + if(setDate.length() > 0){ + curDate = setDate; + } + KQShiftScheduleComInfo kqShiftScheduleComInfo = new KQShiftScheduleComInfo(); + sql = "update kq_shiftschedule set isdelete = 1 where resourceid =? and kqdate>=? and kqdate<=? "; + rs.executeUpdate(sql,userid,curDate,curDate); + + sql = "insert into kq_shiftschedule (kqdate,serialid,resourceid,groupid) values(?,?,?,?)"; + rs.executeUpdate(sql, curDate,serialid,userid,groupid); + kqShiftScheduleComInfo.removeCache(); + new KQFormatBiz().formatDate(""+userid,curDate); + + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/ResetUserMapCmd.java b/src/com/engine/kq/cmd/attendanceButton/ResetUserMapCmd.java new file mode 100644 index 0000000..80845ce --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/ResetUserMapCmd.java @@ -0,0 +1,53 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.log.KQLog; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 切换地图 + */ +public class ResetUserMapCmd extends AbstractCommonCommand> { + private KQLog kqLog = new KQLog(); + + public ResetUserMapCmd(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 user_last_map = Util.null2String(params.get("user_last_map")); + String userid = user.getUID()+""; + kqLog.info("ResetUserMapCmd user:"+user.getLastname()+":user_last_map:"+user_last_map); + sql = "delete from user_last_map where userid =? "; + rs.executeUpdate(sql,userid); + + sql = "insert into user_last_map (userid,last_map) values(?,?)"; + rs.executeUpdate(sql, userid,user_last_map); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/SaveAutoEMSetCmd.java b/src/com/engine/kq/cmd/attendanceButton/SaveAutoEMSetCmd.java new file mode 100644 index 0000000..971936d --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/SaveAutoEMSetCmd.java @@ -0,0 +1,77 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQAutoCheckComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.log.KQLog; +import java.util.HashMap; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 保存EM端自动打卡设置界面 + */ +public class SaveAutoEMSetCmd extends AbstractCommonCommand> { + private KQLog kqLog = new KQLog(); + private HttpServletRequest request; + private HttpServletResponse response; + + public SaveAutoEMSetCmd(Map params, User user) { + this.request = request; + this.user = user; + this.params = params; + this.response = response; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + String auto_checkin = Util.null2s(Util.null2String(params.get("auto_checkin")),"0"); + String auto_checkout = Util.null2s(Util.null2String(params.get("auto_checkout")),"0"); + String resourceId = ""+user.getUID(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String curDate = DateUtil.getCurrentDate(); + String groupid = kqGroupMemberComInfo.getKQGroupId(user.getUID()+"",curDate); + RecordSet rs = new RecordSet(); + String delSql = "delete from kq_autocheck_set where resourceid=? "; + boolean isDel = rs.executeUpdate(delSql, resourceId); + if(isDel){ + String sql = "insert into kq_autocheck_set(resourceid,auto_checkin,auto_checkout,groupid) values(?,?,?,?)"; + boolean isok = rs.executeUpdate(sql, resourceId,auto_checkin,auto_checkout,groupid); + if(isok){ + retmap.put("status", "1"); + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + KQAutoCheckComInfo kqAutoCheckComInfo = new KQAutoCheckComInfo(); + kqAutoCheckComInfo.removeCache(); + + return retmap; + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceButton/SaveExtraMapConfigCmd.java b/src/com/engine/kq/cmd/attendanceButton/SaveExtraMapConfigCmd.java new file mode 100644 index 0000000..69cbc7d --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/SaveExtraMapConfigCmd.java @@ -0,0 +1,53 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.alibaba.fastjson.JSON; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.log.KQLog; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; +import java.util.HashMap; +import java.util.Map; + +/** + */ +public class SaveExtraMapConfigCmd extends AbstractCommonCommand> { + public KQLog kqLog = new KQLog(); + + public SaveExtraMapConfigCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + kqLog.info("params:::::::::"+ JSON.toJSON(params)); + Map retmap = new HashMap(); + try { + RecordSet rs = new RecordSet(); + String mapKey = "extramapconfig"; + String mapKeyValue = Util.null2String(params.get("inputText")); + rs.executeQuery("select main_val from kq_settings where main_key=?", mapKey); + int count = rs.getCounts(); + if(count > 0) { + rs.executeUpdate("update kq_settings set main_val=? where main_key=?", mapKeyValue, mapKey); + } else { + rs.executeUpdate("insert into kq_settings(main_key, main_val) values(?,?)",mapKey, mapKeyValue); + } + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/attendanceButton/SaveOutSignSettingCmd.java b/src/com/engine/kq/cmd/attendanceButton/SaveOutSignSettingCmd.java new file mode 100644 index 0000000..ee2655d --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceButton/SaveOutSignSettingCmd.java @@ -0,0 +1,60 @@ +package com.engine.kq.cmd.attendanceButton; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.entity.KQGroupEntity; +import com.engine.portal.biz.constants.ModuleConstants; +import com.engine.portal.biz.nonstandardfunction.SysModuleInfoBiz; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * 获取考勤组的基本信息的 + */ +public class SaveOutSignSettingCmd extends AbstractCommonCommand> { + + public SaveOutSignSettingCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + String remark = Util.null2String(params.get("remark")); + String photo = Util.null2String(params.get("photo")); + String nearly = Util.null2String(params.get("nearly")); + + Prop.setPropValueForAdd("hrm_outsign_setting", "remark", remark); + Prop.setPropValueForAdd("hrm_outsign_setting", "photo", photo); + Prop.setPropValueForAdd("hrm_outsign_setting", "nearly", nearly); + + retmap.put("status", "1"); + }catch (Exception ex){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + + ex.printStackTrace(); + writeLog(ex); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/AttendanceUtil.java b/src/com/engine/kq/cmd/attendanceEvent/AttendanceUtil.java new file mode 100644 index 0000000..24c87c4 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/AttendanceUtil.java @@ -0,0 +1,102 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.kq.biz.KQBalanceOfLeaveBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQSettingsBiz; +import com.engine.kq.biz.KQUnitBiz; +import com.engine.kq.util.KQDurationCalculatorUtil; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +import weaver.conn.RecordSet; +import weaver.general.Util; + +public class AttendanceUtil { + + /** + * 获取冻结数据 + * + * @param newLeaveType + * @param resourceId + */ + public static double getFreezeDuration(String newLeaveType, String resourceId, String fromDate, String toDate) { + + double d_duration = 0.0; + //以防止出现精度问题 + BigDecimal big_d_duration = new BigDecimal(Double.toString(d_duration)); + RecordSet rs = new RecordSet(); + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String minimumUnit = kqLeaveRulesComInfo.getMinimumUnit(newLeaveType); + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newLeaveType), 0.0); + try { + + List yearList = new ArrayList<>(); + //是查询所有有效的假期余额还是仅仅查询指定日期当年的 + if(KQSettingsBiz.is_balanceofleave()){//开启开关 + String allRestAmount = KQBalanceOfLeaveBiz.getRestAmount("" + resourceId, newLeaveType, fromDate, true); + String currentRestAmount = KQBalanceOfLeaveBiz.getRestAmount("" + resourceId, newLeaveType, fromDate,false); + double beforeRestAmount = Util.getDoubleValue(allRestAmount, 0) - Util.getDoubleValue(currentRestAmount, + 0); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Calendar startCal = Calendar.getInstance(); + startCal.setTime(sdf.parse(fromDate)); + int startYear = startCal.get(Calendar.YEAR); + int lastYear=startYear-1; + Calendar endCal = Calendar.getInstance(); + endCal.setTime(sdf.parse(toDate)); + int endYear = endCal.get(Calendar.YEAR); + if( beforeRestAmount>0){ + yearList.add(String.valueOf(lastYear)); + } + if (startYear != endYear) { + // 生成连续年份序列 + for (int year = startYear; year <= endYear; year++) { + yearList.add(String.valueOf(year)); + } + } else { + // 同年直接添加 + yearList.add(String.valueOf(startYear)); + + } + } + + String getFreezeSql = "select a.* from KQ_ATT_VACATION a left join workflow_requestbase b on a" + + ".requestid=b" + + ".requestid where a.status=1 and b.requestid > 0 "; + if (resourceId.length() > 0 && newLeaveType.length() > 0) { + getFreezeSql += " and a.resourceId=" + resourceId + " and a.newLeaveType=" + newLeaveType; + rs.execute(getFreezeSql); + while (rs.next()) { + String duration = rs.getString("duration"); + String belongdate = rs.getString("fromDate"); + String belongYear = rs.getString("year"); + // 新增年份过滤逻辑 + if(!yearList.isEmpty() &&!yearList.contains(belongYear)) { + continue; // 不属于目标年份则跳过 + } + double value = Util.getDoubleValue(duration, 0.0); + String durationrule = rs.getString("durationrule"); + if (KQUnitBiz.isLeaveHour(minimumUnit)) {//按小时 + if (!KQUnitBiz.isLeaveHour(durationrule)) { + if (proportion > 0) value = value * proportion; + } + } else {//按天 + if (KQUnitBiz.isLeaveHour(durationrule)) { + if (proportion > 0) value = value / proportion; + } + } + BigDecimal big_value = new BigDecimal(KQDurationCalculatorUtil.getDurationRound5(value + "")); + big_d_duration = big_d_duration.add(big_value); + } + } + } catch (Exception e) { + throw new IllegalArgumentException("日期格式错误"); + } + return Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(big_d_duration.doubleValue() + "")); + } +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/CheckCardCmd.java b/src/com/engine/kq/cmd/attendanceEvent/CheckCardCmd.java new file mode 100644 index 0000000..300eaf4 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/CheckCardCmd.java @@ -0,0 +1,65 @@ +package com.engine.kq.cmd.attendanceEvent; + +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.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 补卡流程提交校验 + */ +public class CheckCardCmd extends AbstractCommonCommand> { + + public CheckCardCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + try{ + String attid = Util.null2String(params.get("attid")); + String checkRuleData2json = Util.null2String(params.get("checkRuleData2json")); + int workflowid = Util.getIntValue(Util.null2String(params.get("workflowid"))); + int nodeid = Util.getIntValue(Util.null2String(params.get("nodeid"))); + int requestid = Util.getIntValue(Util.null2String(params.get("requestid"))); + int nodetype = Util.getIntValue(Util.null2String(params.get("nodetype"))); + int currentnodetype = Util.getIntValue(Util.null2String(params.get("currentnodetype"))); + new KQLog().info("checkRuleData2json:"+checkRuleData2json); + JSONObject checkRuleData2jsonObject = (JSONObject) JSON.parse(checkRuleData2json); + if(!checkRuleData2jsonObject.isEmpty()){ + CheckRuleUtil checkDuplicateUtil = new CheckRuleUtil(); + Set> checkRuleDataSet = checkRuleData2jsonObject.entrySet(); + checkDuplicateUtil.checkRule(checkRuleDataSet,retmap,user,""+ KqSplitFlowTypeEnum.CARD.getFlowtype(), + requestid,currentnodetype,attid); + } + if(retmap.isEmpty()){ + retmap.put("status", "1"); + } + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/CheckEvectionCmd.java b/src/com/engine/kq/cmd/attendanceEvent/CheckEvectionCmd.java new file mode 100644 index 0000000..3870286 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/CheckEvectionCmd.java @@ -0,0 +1,65 @@ +package com.engine.kq.cmd.attendanceEvent; + +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.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 请假校验事件 + */ +public class CheckEvectionCmd extends AbstractCommonCommand> { + + public CheckEvectionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + try{ + String attid = Util.null2String(params.get("attid")); + String checkRuleData2json = Util.null2String(params.get("checkRuleData2json")); + int workflowid = Util.getIntValue(Util.null2String(params.get("workflowid"))); + int nodeid = Util.getIntValue(Util.null2String(params.get("nodeid"))); + int requestid = Util.getIntValue(Util.null2String(params.get("requestid"))); + int nodetype = Util.getIntValue(Util.null2String(params.get("nodetype"))); + int currentnodetype = Util.getIntValue(Util.null2String(params.get("currentnodetype"))); + new KQLog().info("checkRuleData2json:"+checkRuleData2json); + JSONObject checkRuleData2jsonObject = (JSONObject) JSON.parse(checkRuleData2json); + if(!checkRuleData2jsonObject.isEmpty()){ + CheckRuleUtil checkDuplicateUtil = new CheckRuleUtil(); + Set> checkRuleDataSet = checkRuleData2jsonObject.entrySet(); + checkDuplicateUtil.checkRule(checkRuleDataSet,retmap,user,""+ KqSplitFlowTypeEnum.EVECTION.getFlowtype(), + requestid,currentnodetype,attid); + } + if(retmap.isEmpty()){ + retmap.put("status", "1"); + } + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/CheckLeaveBackCmd.java b/src/com/engine/kq/cmd/attendanceEvent/CheckLeaveBackCmd.java new file mode 100644 index 0000000..2eda6ba --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/CheckLeaveBackCmd.java @@ -0,0 +1,305 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +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.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.biz.chain.duration.WorkHalfUnitSplitChain; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.util.KQFlowUtil; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.engine.kq.wfset.util.SplitSelectSet; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.collections.MapUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 销假校验事件 + */ +public class CheckLeaveBackCmd extends AbstractCommonCommand> { + + public CheckLeaveBackCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + String resMap = Util.null2String(params.get("resMap")); + int workflowid = Util.getIntValue(Util.null2String(params.get("workflowid"))); + int nodeid = Util.getIntValue(Util.null2String(params.get("nodeid"))); + int leaverequestid = Util.getIntValue(Util.null2String(params.get("leaverequestid"))); + int resourceId = Util.getIntValue(Util.null2String(params.get("resourceId"))); + String repeatType = Util.null2String(params.get("repeatType")); + JSONArray jsonArray = (JSONArray)JSON.parse(resMap); + if(leaverequestid <= 0){ + //未选择请假流程 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(10000802,weaver.general.Util.getIntValue(user.getLanguage()))); + return retmap; + } + if(resourceId <= 0){ + //未选择销假人 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(10000802,weaver.general.Util.getIntValue(user.getLanguage()))); + return retmap; + } + if(jsonArray != null && !jsonArray.isEmpty()){ + Map leavebackMap = new HashMap<>(); + //获取销假的数据 + getLeaveBacks(leaverequestid,leavebackMap,kqTimesArrayComInfo,resourceId,repeatType); + + KQFlowUtil kqFlowUtil = new KQFlowUtil(); + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + for(int i = 0 ; i < jsonArray.size() ; i++){ + JSONObject jsonObject = (JSONObject) jsonArray.get(i); + String leavefromDate = Util.null2String(jsonObject.get("leavefromDate")); + String leavefromTime = Util.null2String(jsonObject.get("leavefromTime")); + String leavetoDate = Util.null2String(jsonObject.get("leavetoDate")); + String leavetoTime = Util.null2String(jsonObject.get("leavetoTime")); + String leaveDuration = Util.null2String(jsonObject.get("leaveDuration")); + String newLeaveType = Util.null2String(jsonObject.get("newLeaveType")); + + String fromDate = Util.null2String(jsonObject.get("fromDate")); + String fromTime = Util.null2String(jsonObject.get("fromTime")); + String toDate = Util.null2String(jsonObject.get("toDate")); + String toTime = Util.null2String(jsonObject.get("toTime")); + String duration = Util.null2String(jsonObject.get("duration")); + boolean is_half_select = false; + int minimumUnit = KQLeaveRulesBiz.getMinimumUnit(newLeaveType); + int timeselection = KQLeaveRulesBiz.getTimeselection(newLeaveType); + if(timeselection == 1){ + //下拉框 + if(minimumUnit == 2){ + is_half_select = true; + } + } + Map repeatMap = kqFlowUtil.resetTimeWhenRepeat(newLeaveType,repeatType); + if(MapUtils.isNotEmpty(repeatMap) && repeatMap.containsKey("fromTime") && repeatMap.containsKey("toTime")){ + leavefromTime = Util.null2s(repeatMap.get("fromTime"),leavefromTime); + leavetoTime = Util.null2s(repeatMap.get("toTime"),leavetoTime); + fromTime = Util.null2s(repeatMap.get("fromTime"),fromTime); + toTime = Util.null2s(repeatMap.get("toTime"),toTime); + } + + String repeatTime = ""; + if(leavefromDate.length() == 0 || leavefromTime.length() ==0 || + leavetoDate.length() == 0 || leavetoTime.length() == 0){ + //请假信息有误 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(10000802,weaver.general.Util.getIntValue(user.getLanguage()))); + return retmap; + } + + if(fromDate.length() == 0 || fromTime.length() ==0 || + toDate.length() == 0 || toTime.length() == 0){ + //销假信息有误 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(10000803,weaver.general.Util.getIntValue(user.getLanguage()))); + return retmap; + } + if(newLeaveType.length() > 0){ + repeatTime = kqLeaveRulesComInfo.getRepeatTime(newLeaveType); + if("1".equals(repeatTime)){ + if(!fromTime.equals(leavefromTime) || !toTime.equals(leavetoTime)){ + //销假信息有误 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(548150,weaver.general.Util.getIntValue(user.getLanguage()))); + return retmap; + } + } + } + + LocalDateTime leaveFromDateTime = LocalDateTime.parse(leavefromDate+" "+leavefromTime,datetimeFormatter); + LocalDateTime leaveToDateTime = LocalDateTime.parse(leavetoDate+" "+leavetoTime,datetimeFormatter); + + LocalDateTime fromDateTime = LocalDateTime.parse(fromDate+" "+fromTime,datetimeFormatter); + LocalDateTime toDateTime = LocalDateTime.parse(toDate+" "+toTime,datetimeFormatter); + + //销假区间要在请假区间内 + if((fromDateTime.isAfter(leaveFromDateTime) || fromDateTime.isEqual(leaveFromDateTime)) && + (fromDateTime.isBefore(leaveToDateTime) || fromDateTime.isEqual(leaveToDateTime)) && + (toDateTime.isAfter(leaveFromDateTime) || toDateTime.isEqual(leaveFromDateTime)) && + (toDateTime.isBefore(leaveToDateTime) || toDateTime.isEqual(leaveToDateTime))){ + //这是满足条件的 + }else{ + //不在请假区间的 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(505782, user.getLanguage())); + return retmap; + } + //拆分销假流程 + List> splitLists = SplitActionUtil.getSplitList(fromDate,toDate,fromTime,toTime); + if("1".equals(repeatTime)){ + splitLists = SplitActionUtil.getSplitListRepeat(fromDate,toDate,fromTime,toTime); + } + if(is_half_select){ + if("1".equals(repeatTime)){ + splitLists = SplitActionUtil.getSplitHalfDayListRepeat(fromDate,toDate,fromTime,toTime); + }else{ + splitLists = SplitActionUtil.getSplitHalfDayList(fromDate,toDate,fromTime,toTime); + } + } + String leaveBackDesc = fromDate+" "+fromTime+" - "+toDate+" "+toTime; + + boolean isDup = checkDuplicateBack(leavebackMap,splitLists,kqTimesArrayComInfo,retmap,leaveBackDesc,is_half_select,resourceId); + if(!isDup){ + return retmap; + } + + } + } + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + /** + * 获取消过假的数据 + */ + private void getLeaveBacks(int leaverequestid, Map leavebackMap, + KQTimesArrayComInfo kqTimesArrayComInfo, int resourceId, String repeatType) { + + KQFlowUtil kqFlowUtil = new KQFlowUtil(); + RecordSet rs = new RecordSet(); + int[] initArrays = kqTimesArrayComInfo.getInitArr(); + String getLeaveBackSql = "select * from "+ KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" where leavebackrequestid=? and resourceId=? "; + rs.executeQuery(getLeaveBackSql, leaverequestid,resourceId); + while(rs.next()){ + String fromdate = rs.getString("fromdate"); + String fromtime = rs.getString("fromtime"); + String todate = rs.getString("todate"); + String totime = rs.getString("totime"); + String newLeaveType = rs.getString("newleavetype"); + Map repeatMap = kqFlowUtil.resetTimeWhenRepeat(newLeaveType,repeatType); + if(MapUtils.isNotEmpty(repeatMap) && repeatMap.containsKey("fromTime") && repeatMap.containsKey("toTime")){ + fromtime = Util.null2s(repeatMap.get("fromTime"),fromtime); + totime = Util.null2s(repeatMap.get("toTime"),totime); + } + + //拆分的销假中间表里,开始时间少1分钟,结束时间多1分钟 + int fromIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime); + fromIndex = fromIndex + 1; + int toIndex = kqTimesArrayComInfo.getArrayindexByTimes(totime); + toIndex = toIndex - 1; + if(fromIndex > toIndex){ + continue; + } + if(leavebackMap.get(fromdate) != null){ + int[] initArraysTmp = leavebackMap.get(fromdate); + Arrays.fill(initArraysTmp, fromIndex, toIndex,1); + }else{ + int[] initArras = new int[2048]; + initArras = initArrays.clone(); + Arrays.fill(initArras, fromIndex, toIndex,1); + leavebackMap.put(fromdate, initArras); + } + } + } + + /** + * 校验是否重复销假 同一部分 + * @param leavebackMap 已经销过的假集合 + * @param splitLists 拆分的销假流程 + * @param kqTimesArrayComInfo + * @param retmap + * @param leaveBackDesc + * @param is_half_select + * @param resourceId + */ + private boolean checkDuplicateBack(Map leavebackMap, + List> splitLists, + KQTimesArrayComInfo kqTimesArrayComInfo, Map retmap, + String leaveBackDesc, boolean is_half_select, int resourceId) { + + int splitCount = splitLists.size(); + for (int i = 0; i < splitCount; i++) { + Map splitMap = splitLists.get(i); + String splitDate = Util.null2String(splitMap.get("splitDate")); + String splitFromTime = Util.null2String(splitMap.get("fromTime")); + String splitToTime = Util.null2String(splitMap.get("toTime")); + if(is_half_select){ + int foreOrAfter = Util.getIntValue(Util.null2String(splitMap.get("foreOrAfter"))); +// 下拉框选择 + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil + .getWorkTime(resourceId+"", splitDate,false); + if(shiftInfoBean != null) { + if (!shiftInfoBean.isIsfree()) { + List halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + if(halfWorkIndex != null && !halfWorkIndex.isEmpty()){ + int[] halfWorkIndexs = halfWorkIndex.get(0); + int firstTimeIndex = halfWorkIndexs[0];//当天班次的最早时间 这个时间肯定不可能跨天的 + int middleTimeIndex = halfWorkIndexs[1];//当天班次的中间时间 这个时间可能会跨天 + int lastTimeIndex = halfWorkIndexs[2];//当天班次的最晚时间 这个时间也可能会跨天 + switch (foreOrAfter){ + case WorkHalfUnitSplitChain.fore_fore_index: + splitFromTime = kqTimesArrayComInfo.getTimesByArrayindex(firstTimeIndex); + splitToTime = kqTimesArrayComInfo.getTimesByArrayindex(middleTimeIndex); + break; + case WorkHalfUnitSplitChain.fore_after_index: + splitFromTime = kqTimesArrayComInfo.getTimesByArrayindex(firstTimeIndex); + splitToTime = kqTimesArrayComInfo.getTimesByArrayindex(lastTimeIndex); + break; + case WorkHalfUnitSplitChain.after_fore_index: + break; + case WorkHalfUnitSplitChain.after_after_index: + splitFromTime = kqTimesArrayComInfo.getTimesByArrayindex(middleTimeIndex); + splitToTime = kqTimesArrayComInfo.getTimesByArrayindex(lastTimeIndex); + break; + default: + break; + } + } + } + } + } + if(leavebackMap.get(splitDate) != null){ + int backstartIndex = kqTimesArrayComInfo.getArrayindexByTimes(splitFromTime); + int backendIndex = kqTimesArrayComInfo.getArrayindexByTimes(splitToTime); + + int[] initArrays4Date = leavebackMap.get(splitDate); + //1、指定日期下已消的时长 + int backCnt = kqTimesArrayComInfo.getCnt(initArrays4Date, 0, 2048, 1); + //2、用本次销假的数据去覆盖 + Arrays.fill(initArrays4Date, backstartIndex,backendIndex,-1); + int backCntNew = kqTimesArrayComInfo.getCnt(initArrays4Date, 0, 2048, 1); + //3、如果原有的已消时长变了,说明被覆盖了 + if(backCnt != backCntNew){ + retmap.put("status", "-1"); + retmap.put("message", leaveBackDesc+SystemEnv.getHtmlLabelName(505783, user.getLanguage())); + return false; + } + } + } + return true; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/CheckLeaveCmd.java b/src/com/engine/kq/cmd/attendanceEvent/CheckLeaveCmd.java new file mode 100644 index 0000000..c140800 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/CheckLeaveCmd.java @@ -0,0 +1,656 @@ +package com.engine.kq.cmd.attendanceEvent; + +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.enums.DurationTypeEnum; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.google.common.collect.Lists; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.math.BigDecimal; +import java.util.*; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +/** + * 请假校验事件 + */ +public class CheckLeaveCmd extends AbstractCommonCommand> { + + private static KQLog logger = new KQLog();//用于记录日志信息 + + public CheckLeaveCmd(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 = ""; + String balanceOfLeave = ""; + try { + String attid = Util.null2String(params.get("attid")); + String resMap = Util.null2String(params.get("resMap")); + String checkDurationData2json = Util.null2String(params.get("checkDurationData2json")); + String checkRuleData2json = Util.null2String(params.get("checkRuleData2json")); + String restData2json = Util.null2String(params.get("checkData2json")); + int workflowid = Util.getIntValue(Util.null2String(params.get("workflowid"))); + int nodeid = Util.getIntValue(Util.null2String(params.get("nodeid"))); + int requestid = Util.getIntValue(Util.null2String(params.get("requestid"))); + int nodetype = Util.getIntValue(Util.null2String(params.get("nodetype"))); + int currentnodetype = Util.getIntValue(Util.null2String(params.get("currentnodetype"))); + new KQLog().info("检测每次提交的时候,页面上的时长是多少 checkDurationData2json:" + checkDurationData2json); + double min_duration = -1; + //正式系统需要的 + String isFormal = Util.null2String(new BaseBean().getPropValue("kq_flow_formal", "isFormal"), "0"); + if ("1".equalsIgnoreCase(isFormal)) { +// 正式系统才有这个30分钟的控制 + min_duration = Util.getDoubleValue(Util.null2String(params.get("min_duration")), -1); + } + List condition_list = Lists.newArrayList(); + new KQLog().info("resMap:" + resMap); + new KQLog().info("checkRuleData2json:" + checkRuleData2json); + logger.info("restData2json:" + restData2json); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + JSONObject resObject = (JSONObject) JSON.parse(resMap); + if (!resObject.isEmpty()) { + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String allow_negative = Util.null2String(kqSettingsComInfo.getMain_val("allow_negative"),"0"); + boolean allow_negative_flag = "1".equals(allow_negative); + Set> tmp_set = resObject.entrySet(); + for (Entry entry : tmp_set) { + String resourceId = entry.getKey(); + JSONObject leavetypeObject = (JSONObject) entry.getValue(); +// List resList = new ArrayList<>(); + if (!leavetypeObject.isEmpty()) { + //带薪假存在不同释放规则,这里需要单独根据请假类型+日期 处理不同有效期和释放规则的请假 + Map balanceMap = new HashMap<>(); + //记录每一个类型的 带薪假余额的汇总list + Map> allbalanceMap = new HashMap<>(); + //相同请假类型的 请假时长总和记录下 + Map durationMap = new HashMap<>(); + Map d_durationMap = new HashMap<>(); + Set> keave_set = leavetypeObject.entrySet(); + for (Entry typeEntry : keave_set) { + String year_newLeaveType = typeEntry.getKey(); + String[] year_newLeaveTypes = year_newLeaveType.split("_"); + String newLeaveType = ""; + String date = ""; + if (year_newLeaveTypes.length != 5) { + continue; + } + date = year_newLeaveTypes[0]; + if (date.length() == 0) { + date = DateUtil.getCurrentDate(); + } + newLeaveType = year_newLeaveTypes[1]; + String fromTime = year_newLeaveTypes[2]; + String toDate = year_newLeaveTypes[3]; + String toTime = year_newLeaveTypes[4]; + String leaveDays = Util.null2String(typeEntry.getValue()); + boolean balanceEnable = KQLeaveRulesBiz.getBalanceEnable(newLeaveType); + String scheLeaveids = KQLeaveRulesBiz.getLeaveids(newLeaveType);//获取假期类型对应的优先级别id + scheLeaveids = KQLeaveRulesBiz.getusedLeaveids(scheLeaveids, resourceId);//分析这些假期id是否都启用 + if (!("-1").equals(scheLeaveids)) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + if (scheLeaveids.indexOf(",") > 0) { + String[] splitLeaveids = scheLeaveids.split(","); + for (String v : splitLeaveids) { + if (KQLeaveRulesBiz.getBalanceEnable(v)) { + balanceOfLeave = KQBalanceOfLeaveBiz.getRestAmount(resourceId, v, date); + if (isFreezeNodeId(workflowid, nodeid)) { + double d_duration = AttendanceUtil.getFreezeDuration(v, resourceId, + date,toDate); + if (d_duration > 0) { + //以防止出现精度问题 + BigDecimal p1 = new BigDecimal(balanceOfLeave); + BigDecimal p2 = new BigDecimal(Double.toString(d_duration)); + //考虑下冻结的数据 + balanceOfLeave = p1.subtract(p2).toString(); + } + } + if (Util.getDoubleValue(balanceOfLeave, 0.0) > 0.0) { + retmap.put("status", "-1"); + retmap.put("message", resourceComInfo.getLastname(resourceId) + SystemEnv.getHtmlLabelName(18946, user.getLanguage()) + kqLeaveRulesComInfo.getLeaveName(v) + SystemEnv.getHtmlLabelName(547711, user.getLanguage()).replace("${name}", kqLeaveRulesComInfo.getLeaveName(newLeaveType))); + return retmap; + } + } + } + } else { + if (KQLeaveRulesBiz.getBalanceEnable(scheLeaveids)) { + balanceOfLeave = KQBalanceOfLeaveBiz.getRestAmount(resourceId, scheLeaveids, date); + if (isFreezeNodeId(workflowid, nodeid)) { + double d_duration = AttendanceUtil.getFreezeDuration(scheLeaveids, + resourceId,date,toDate); + if (d_duration > 0) { + //以防止出现精度问题 + BigDecimal p1 = new BigDecimal(balanceOfLeave); + BigDecimal p2 = new BigDecimal(Double.toString(d_duration)); + //考虑下冻结的数据 + balanceOfLeave = p1.subtract(p2).toString(); + } + } + if (Util.getDoubleValue(balanceOfLeave, 0.0) > 0.0) { + retmap.put("status", "-1"); + retmap.put("message", resourceComInfo.getLastname(resourceId) + SystemEnv.getHtmlLabelName(18946, user.getLanguage()) + kqLeaveRulesComInfo.getLeaveName(scheLeaveids) + SystemEnv.getHtmlLabelName(547711, user.getLanguage()).replace("${name}", kqLeaveRulesComInfo.getLeaveName(newLeaveType))); + return retmap; + } + } + } + } + if (balanceEnable) { + if ("1".equalsIgnoreCase(isFormal)) { + balanceOfLeave = KQBalanceOfLeaveBiz.getRestAmount(resourceId, newLeaveType, DateUtil.getCurrentDate()); + } else { + balanceOfLeave = KQBalanceOfLeaveBiz.getRestAmount(resourceId, newLeaveType, date); + } + double balanceOfLeaveDays = Util.getDoubleValue(balanceOfLeave); + double d_duration=0.0; + if (isFreezeNodeId(workflowid, nodeid)) { + d_duration = AttendanceUtil.getFreezeDuration(newLeaveType, resourceId,date,toDate); + if (d_duration > 0) { + //以防止出现精度问题 + BigDecimal p1 = new BigDecimal(Double.toString(balanceOfLeaveDays)); + BigDecimal p2 = new BigDecimal(Double.toString(d_duration)); + //考虑下冻结的数据 + String tmp_balanceOfLeaveDays = p1.subtract(p2).toString(); + balanceOfLeaveDays = Util.getDoubleValue(tmp_balanceOfLeaveDays); + } + } + if (balanceMap.containsKey(newLeaveType)) { + //如果请假类型相同,记录下最大的那个假期余额 + String curBalance = balanceMap.get(newLeaveType); + if (Util.getDoubleValue(balanceOfLeave, 0.0) > Util.getDoubleValue(curBalance, 0.0)) { + balanceMap.put(newLeaveType, balanceOfLeave); + } + String curleaveDays = durationMap.get(newLeaveType); + durationMap.put(newLeaveType, Util.null2String( + Util.getDoubleValue(curleaveDays, 0.0) + Util.getDoubleValue(leaveDays, 0.0))); + Double d_duration_d = d_durationMap.get(newLeaveType); + d_durationMap.put(newLeaveType, d_duration_d + d_duration); + + List allbalanceList = allbalanceMap.get(newLeaveType); + allbalanceList.add(balanceOfLeave); + } else { + balanceMap.put(newLeaveType, balanceOfLeave); + durationMap.put(newLeaveType, leaveDays); + d_durationMap.put(newLeaveType, d_duration); + + List allbalanceList = new ArrayList<>(); + allbalanceList.add(balanceOfLeave); + allbalanceMap.put(newLeaveType, allbalanceList); + } + + double leaveDays_Double = Util.getDoubleValue(leaveDays); + if (!allow_negative_flag && balanceOfLeaveDays <= 0) { + //可请 带薪假时长为0 不能提交 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(390298, user.getLanguage())); + return retmap; + } + if (!allow_negative_flag && leaveDays_Double > balanceOfLeaveDays) { + //请假天数大于带薪假时长 不能提交 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(390299, user.getLanguage())); + return retmap; + } + } + } + if (!balanceMap.isEmpty()) { + for (Entry me : balanceMap.entrySet()) { + String key = me.getKey(); + double max_balance = Util.getDoubleValue(me.getValue(), 0.0); + double totalLeavedays = Util.getDoubleValue(durationMap.get(key), 0.0); + if (!allow_negative_flag && totalLeavedays > max_balance) { + //请假天数大于带薪假时长 不能提交 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(390299, user.getLanguage())); + return retmap; + } + + if (isFreezeNodeId(workflowid, nodeid)) { + double d_duration = d_durationMap.get(key); + if (d_duration > 0) { + List allbalanceList = allbalanceMap.get(key); + for (String tmp : allbalanceList) { + //以防止出现精度问题 + BigDecimal p1 = new BigDecimal(tmp); + BigDecimal p2 = new BigDecimal(Double.toString(d_duration)); + //考虑下冻结的数据 + String tmp_balanceOfLeaveDays = p1.subtract(p2).toString(); + double tmp_max_balance = Util.getDoubleValue(tmp_balanceOfLeaveDays); + if (!allow_negative_flag && totalLeavedays > tmp_max_balance) { + //请假天数大于带薪假时长 不能提交 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(390299, user.getLanguage())); + return retmap; + } + } + } + } + } + } + } + } + if (min_duration >= 0 && min_duration < 30.0) { + //请假不能小于30分钟 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(126255, user.getLanguage())); + return retmap; + } + } + + //restData2json[0] = _field_resourceId_val+"_"+_field_fromDate_val+"_"+_field_fromTime_val+"_"+_field_toDate_val+"_"+_field_toTime_val+"_"+_field_newLeaveType_val+"_"+_field_duration_val; + //{"0":"4_2024-09-09_09:00_2024-09-10_18:00_13_时长","1":"4_2024-09-09_09:00_2024-09-10_18:00_13_时长"} + JSONObject restObject = (JSONObject) JSON.parse(restData2json); + if (!restObject.isEmpty()) { + Set> restSet = restObject.entrySet(); + if(null != restSet && restSet.size()>0){ + Map checkRestMap = new HashMap<>(); + Map userTypeMap = new HashMap<>(); + for (Entry entry : restSet) { + String restValue = Util.null2String(entry.getValue()); + String[] duplicateValues = restValue.split("_",-1); + if (duplicateValues.length == 7) { + String resourceId = duplicateValues[0]; + String fromDate = duplicateValues[1]; + String fromTime = duplicateValues[2]; + String toDate = duplicateValues[3]; + String toTime = duplicateValues[4]; + String newLeaveType = duplicateValues[5]; + String leaveDays = duplicateValues[6]; + if (fromDate.length() == 0 || fromTime.length() == 0 || toDate.length() == 0 || toTime.length() == 0) { + continue; + } + if (fromDate.length() == 0) { + fromDate = DateUtil.getCurrentDate(); + } + boolean balanceEnable = KQLeaveRulesBiz.getBalanceEnable(newLeaveType); + if(balanceEnable){ + double leaveDays_Double = Util.getDoubleValue(leaveDays); + //单条请假数据校验 + Map objectMap = checkRestBalance(newLeaveType, resourceId, Util.null2String(Util.getIntValue(fromDate.substring(0, 4)) - 1), + fromDate, fromTime, toDate, toTime, leaveDays_Double); + logger.info("1.ruleId:"+newLeaveType+":resourceId:"+resourceId+":objectMap:"+JSONObject.toJSONString(objectMap)); + if(null != objectMap && "false".equals(objectMap.get("flag"))){ + retmap.put("status", "-1"); + retmap.put("message", objectMap.get("checkMsg")); + return retmap; + } + + /* + 需要考虑下请假明细表单,同一个人多行育儿假明细的情况,这样校验会很复杂,原因如下 + 1、比如上一年剩余1天,有效期是2024-06-30,今天剩余3天,合计剩余4天 + 2、申请育儿假,06-30至07-01=2天,那么应该是允许提交的 + 3、但是如果明细表单,多条明细如2条明细都是06-30至07-01,那么应该是不允许提交的,因为2条明细那么上一年应该扣2天,但是实际上上一年只允许扣1天 + 4、由于一条一条的校验是正常的,所以多条明细需要将有效期前后的请假天数汇总,再两头校验 + */ + String key = resourceId+"_"+newLeaveType; + if(null != objectMap && "true".equals(objectMap.get("flag")) && "1".equals(objectMap.get("isParental"))){ + if (userTypeMap.containsKey(key)) { + String curleaveDays0 = checkRestMap.get(key+"|last"); + checkRestMap.put(key+"|last", Util.null2String( + Util.getDoubleValue(curleaveDays0, 0.0) + Util.getDoubleValue(objectMap.get("last_leaveday"), 0.0))); + String curleaveDays = checkRestMap.get(key+"|this"); + checkRestMap.put(key+"|this", Util.null2String( + Util.getDoubleValue(curleaveDays, 0.0) + Util.getDoubleValue(objectMap.get("this_leaveday"), 0.0))); + } else { + userTypeMap.put(key,fromDate); + checkRestMap.put(key+"|last", Util.null2String(Util.getDoubleValue(objectMap.get("last_leaveday")))); + checkRestMap.put(key+"|this", Util.null2String(Util.getDoubleValue(objectMap.get("this_leaveday")))); + } + } + } + } + } + logger.info("userTypeMap:"+JSONObject.toJSONString(userTypeMap)+":checkRestMap:"+JSONObject.toJSONString(checkRestMap)); + for(Entry entry : userTypeMap.entrySet()){ + String key = Util.null2String(entry.getKey());//4_13|last + String[] keys = key.split("_");//4_13|last + String resourceId = keys[0]; + String ruleid = keys[1]; + String fromDate = Util.null2String(entry.getValue()); + double last_leaveday = Util.getDoubleValue(checkRestMap.get(key+"|last"), 0.0); + double this_leaveday = Util.getDoubleValue(checkRestMap.get(key+"|this"), 0.0); + Map objectMap = checkRestBalanceSum(ruleid, resourceId, fromDate, last_leaveday, this_leaveday); + logger.info("2.ruleId:"+ruleid+":resourceId:"+resourceId+":fromDate:"+fromDate+":last_leaveday:"+last_leaveday + +":this_leaveday:"+this_leaveday+":objectMap:"+JSONObject.toJSONString(objectMap)); + if(null != objectMap && "false".equals(objectMap.get("flag"))){ + retmap.put("status", "-1"); + retmap.put("message", objectMap.get("checkMsg")); + return retmap; + } + } + } + } + + + JSONObject checkRuleData2jsonObject = (JSONObject) JSON.parse(checkRuleData2json); + if (!checkRuleData2jsonObject.isEmpty()) { + CheckRuleUtil checkDuplicateUtil = new CheckRuleUtil(); + Set> checkRuleDataSet = checkRuleData2jsonObject.entrySet(); + boolean repatTimeOk = checkRepeatTime(checkRuleDataSet); + if (!repatTimeOk) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(15273, user.getLanguage())); + return retmap; + } + checkDuplicateUtil.checkRule(checkRuleDataSet, retmap, user, "" + KqSplitFlowTypeEnum.LEAVE.getFlowtype(), requestid, currentnodetype, attid); + } + if (retmap.isEmpty()) { + retmap.put("status", "1"); + } + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + public Map checkRestBalance(String ruleId,String resourceId,String belongYear,String fromDate,String fromTime, + String toDate,String toTime,double leaveDays_Double){ + Map retmap = new HashMap(); + String flag = "true"; + String checkMsg = ""; + String isParental = "0";//0表示不是育儿假,1表示是育儿假(蔡总要求暂时只开发育儿假) + logger.info("ruleId:"+ruleId+":resourceId:"+resourceId+":belongYear:"+belongYear+":fromDate:"+fromDate+":fromTime:"+fromTime + +":toDate:"+toDate+":toTime:"+toTime+":leaveDays_Double:"+leaveDays_Double); + //育儿假 + if (KQLeaveRulesBiz.isLeaveOfParental(ruleId)) { + isParental = "1"; + try { + boolean status = false; + //人力资源缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + //分部ID + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + //假期规则缓存类 + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //有效期规则:0-不限制、1-按自然年失效、2-按入职日期起12个月、3-自定义次年失效日期、4-按天数失效、5-按季度失效、6-按月数失效 + String rulesDetailId = detailComInfo.getId(ruleId, subcompanyId, departmentId, resourceId); + int validityRule = Util.getIntValue(detailComInfo.getValidityRule(ruleId, subcompanyId, departmentId, resourceId), 0); + + String laststart = ""; + String lastend = ""; + //自定义有效天数([validityRule=4]时有效) + if (validityRule == 0) { + //不限制有效期,默认永久有效(永久有效时有效日期默认为2222-12-31) + retmap.put("flag","true"); + } else { + int yearsOld = StringUtil.parseToInt(detailComInfo.getYearsOld(ruleId, subcompanyId, departmentId, resourceId), 0); + String isprovince = Util.null2s(detailComInfo.getIsProvince(ruleId, subcompanyId, departmentId, resourceId), "1"); + if(isprovince.equals("2")){ + Map params = new HashMap<>(); + KQBalanceOfLeaveBiz.getChildrenProvinceId(rulesDetailId,resourceComInfo.getLocationid(resourceId),params); + yearsOld = Util.getIntValue(Util.null2String(params.get("yearsOld"))); + } + ArrayList listDates = KQBalanceOfLeaveBiz.getParentalLeaveDate(resourceId); +// List collect = listDates.stream().sorted().collect(Collectors.toList()); + for (int i = 0; i < listDates.size(); i++) { + String dateOfBirth = listDates.get(i); + String baseAmountReleaseDate = belongYear + dateOfBirth.substring(4); + int ageLimit = KQBalanceOfLeaveBiz.getAgeLimit(dateOfBirth, baseAmountReleaseDate); + if (ageLimit >= 0 && ageLimit <= yearsOld-1) { + String expirationDate = (Util.getIntValue(belongYear) + 1) + dateOfBirth.substring(4); + if (expirationDate.compareTo(fromDate) > 0) { + laststart = belongYear+ dateOfBirth.substring(4); + lastend = DateUtil.addDate(expirationDate, -1); + status = true; + break; + } else { + status = false; + } + } + } + logger.info("ruleId:"+ruleId+":resourceId:"+resourceId+":laststart:"+laststart+":lastend:"+lastend+":fromDate:"+fromDate+":toDate:"+toDate + +":listDates:"+JSONObject.toJSONString(listDates)); + if("".equals(laststart) || "".equals(lastend)){ + retmap.put("flag","true"); + return retmap; + } + + String allRestAmount = KQBalanceOfLeaveBiz.getRestAmount("" + resourceId, ruleId, fromDate, true); + //【本年剩余】的假期余额 + String currentRestAmount = KQBalanceOfLeaveBiz.getRestAmount("" + resourceId, ruleId, fromDate,false); + //【去年剩余】的假期余额 + String lastRestAmount = String.format("%.2f", Util.getDoubleValue(allRestAmount, 0) - Util.getDoubleValue(currentRestAmount, 0)); + //【去年】应该扣的天数 + double last_tempDays = 0; + //【本年】应该扣的天数 + double this_tempDays = 0; + logger.info("ruleId:"+ruleId+":resourceId:"+resourceId+":allRestAmount:"+allRestAmount+":currentRestAmount:"+currentRestAmount+":lastRestAmount:"+lastRestAmount + +":last_tempDays:"+last_tempDays+":this_tempDays:"+this_tempDays); + retmap.put("last_leaveday",Util.null2String(last_tempDays)); + retmap.put("this_leaveday",Util.null2String(this_tempDays)); + if(laststart.compareTo(fromDate)<=0 && fromDate.compareTo(lastend)<=0){// laststart<=请假开始日期<=lastend + if(toDate.compareTo(lastend)<=0){ + if(leaveDays_Double<=Util.getDoubleValue(lastRestAmount)){ + retmap.put("flag","true"); + }else{ + retmap.put("flag","false"); + retmap.put("checkMsg",SystemEnv.getHtmlLabelName(548010, user.getLanguage())); + } + retmap.put("last_leaveday",Util.null2String(leaveDays_Double)); + retmap.put("this_leaveday",Util.null2String(this_tempDays)); + retmap.put("isParental",isParental); + return retmap; + }else if(toDate.compareTo(lastend)>0){//当请假时间跨有效期 + //【去年】应该扣的天数 + last_tempDays = Util.getDoubleValue(getLeaveDays(resourceId,ruleId,fromDate,fromTime,lastend,"23:59")); + last_tempDays = last_tempDays<0?0:last_tempDays; + //【本年】应该扣的天数 + this_tempDays = leaveDays_Double - last_tempDays; + this_tempDays = this_tempDays<0?0:this_tempDays; + if(last_tempDays>Util.getDoubleValue(lastRestAmount)){ + flag = "false"; + checkMsg = SystemEnv.getHtmlLabelName(548010, user.getLanguage()); + }else{ + if(this_tempDays>Util.getDoubleValue(currentRestAmount)){ + flag = "false"; + checkMsg = SystemEnv.getHtmlLabelName(548011, user.getLanguage()); + }else{ + flag = "true"; + } + } + retmap.put("last_leaveday",Util.null2String(last_tempDays)); + retmap.put("this_leaveday",Util.null2String(this_tempDays)); + retmap.put("isParental",isParental); + retmap.put("flag",flag); + retmap.put("checkMsg",checkMsg); + return retmap; + } + }else if(lastend.compareTo(fromDate)<0){// lastend<=请假开始日期 + if(leaveDays_Double<=Util.getDoubleValue(currentRestAmount)){ + flag = "true"; + }else{ + flag = "false"; + checkMsg = SystemEnv.getHtmlLabelName(548011, user.getLanguage()); + } + retmap.put("last_leaveday",Util.null2String(last_tempDays)); + retmap.put("this_leaveday",Util.null2String(leaveDays_Double)); + retmap.put("isParental",isParental); + retmap.put("flag",flag); + retmap.put("checkMsg",checkMsg); + return retmap; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + retmap.put("isParental",isParental); + retmap.put("flag",flag); + retmap.put("checkMsg",checkMsg); + + return retmap; + } + + public Map checkRestBalanceSum(String ruleId,String resourceId,String fromDate,double last_tempDays,double this_tempDays){ + Map retmap = new HashMap(); + String flag = "true"; + String checkMsg = ""; + //育儿假 + if (KQLeaveRulesBiz.isLeaveOfParental(ruleId)) { + try { + boolean status = false; + //人力资源缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + //分部ID + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + //假期规则缓存类 + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //有效期规则:0-不限制、1-按自然年失效、2-按入职日期起12个月、3-自定义次年失效日期、4-按天数失效、5-按季度失效、6-按月数失效 + String rulesDetailId = detailComInfo.getId(ruleId, subcompanyId, departmentId, resourceId); + int validityRule = Util.getIntValue(detailComInfo.getValidityRule(ruleId, subcompanyId, departmentId, resourceId), 0); + + String allRestAmount = KQBalanceOfLeaveBiz.getRestAmount("" + resourceId, ruleId, fromDate, true); + //【本年剩余】的假期余额 + String currentRestAmount = KQBalanceOfLeaveBiz.getRestAmount("" + resourceId, ruleId, fromDate,false); + //【去年剩余】的假期余额 + String lastRestAmount = String.format("%.2f", Util.getDoubleValue(allRestAmount, 0) - Util.getDoubleValue(currentRestAmount, 0)); + //【去年】应该扣的天数 + last_tempDays = last_tempDays<0?0:last_tempDays; + //【本年】应该扣的天数 + this_tempDays = this_tempDays<0?0:this_tempDays; + logger.info("Sum::ruleId:"+ruleId+":resourceId:"+resourceId+":allRestAmount:"+allRestAmount+":currentRestAmount:"+currentRestAmount+":lastRestAmount:"+lastRestAmount + +":last_tempDays:"+last_tempDays+":this_tempDays:"+this_tempDays); + if(last_tempDays>Util.getDoubleValue(lastRestAmount)){ + flag = "false"; + checkMsg = SystemEnv.getHtmlLabelName(548010, user.getLanguage()); + }else{ + if(this_tempDays>Util.getDoubleValue(currentRestAmount)){ + flag = "false"; + checkMsg = SystemEnv.getHtmlLabelName(548011, user.getLanguage()); + }else{ + flag = "true"; + } + } + retmap.put("flag",flag); + retmap.put("checkMsg",checkMsg); + return retmap; + + } catch (Exception e) { + e.printStackTrace(); + } + } + retmap.put("flag",flag); + retmap.put("checkMsg",checkMsg); + + return retmap; + } + + public String getLeaveDays(String resourceId,String newLeaveType,String fromDate,String fromTime,String toDate,String toTime){ + Map retmap = new HashMap(); + String durationrule = Util.null2String(KQLeaveRulesBiz.getMinimumUnit(newLeaveType)); + String computingMode = Util.null2String(KQLeaveRulesBiz.getComputingMode(newLeaveType)); + + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceId). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime). + newLeaveTypeParam(newLeaveType).durationRuleParam(durationrule). + computingModeParam(computingMode).durationTypeEnumParam(DurationTypeEnum.LEAVE).build(); + + Map durationMap = kqDurationCalculatorUtil.getWorkDuration(); + +// retmap.put("duration", Util.null2String(durationMap.get("duration"))); +// retmap.put("min_duration", Util.null2String(durationMap.get("min_duration"))); + return Util.null2String(durationMap.get("duration")); + } + + private boolean checkRepeatTime(Set> checkRuleDataSet) { + + boolean checkRepeatTime = true; + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + for (Entry entry : checkRuleDataSet) { + String duplicateValue = Util.null2String(entry.getValue()); + String[] duplicateValues = duplicateValue.split("_", -1); + if (duplicateValues.length >= 5) { + String fromDate = duplicateValues[1]; + String fromTime = duplicateValues[2]; + String toDate = duplicateValues[3]; + String toTime = duplicateValues[4]; + if (fromDate.length() == 0 || fromTime.length() == 0 || toDate.length() == 0 || toTime.length() == 0) { + continue; + } + + String repeatTime = "0"; + if (duplicateValues.length == 6) { + String newLeaveType = duplicateValues[5]; + if (newLeaveType.length() > 0) { + repeatTime = Util.null2String(kqLeaveRulesComInfo.getRepeatTime(newLeaveType)); + } + } + if ("1".equals(repeatTime)) { + if (fromTime.compareTo(toTime) > 0) { + checkRepeatTime = false; + } + } + } + } + return checkRepeatTime; + } + + /** + * 只在创建节点做冻结审批的判断 + * + * @param workflowid + * @param nodeid + * @return + */ + public boolean isFreezeNodeId(int workflowid, int nodeid) { + boolean hasFreezeNodeId = hasFreezeNodeId(workflowid); + boolean isStartNodeId = getWFStartNodeId(workflowid) == nodeid; + return isStartNodeId && hasFreezeNodeId; + } + + /** + * 获取指定流程的创建节点id + * + * @param workflowid + * @return + */ + public int getWFStartNodeId(int workflowid) { + RecordSet rs = new RecordSet(); + StringBuffer sql = new StringBuffer("select a.nodeid from workflow_flownode a left join workflow_nodebase b on a.nodeid = b.id") + .append(" where a.workflowId = ").append(workflowid).append(" and (b.isFreeNode != '1' OR b.isFreeNode IS null) and b.isstart =1 "); + rs.executeSql(sql.toString()); + return rs.next() ? rs.getInt("nodeid") : -1; + + } + + /** + * 判断流程是否配置了冻结action + * + * @param workflowid + * @return + */ + public boolean hasFreezeNodeId(int workflowid) { + RecordSet rs = new RecordSet(); + StringBuffer sql = new StringBuffer(" select field006 from kq_att_proc_action where field001 in (select id from kq_att_proc_set where field001 = ").append(workflowid).append(") and field002 = 'KqFreezeVacationAction' "); + rs.executeSql(sql.toString()); + return rs.next() ? true : false; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/CheckOutCmd.java b/src/com/engine/kq/cmd/attendanceEvent/CheckOutCmd.java new file mode 100644 index 0000000..4f20382 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/CheckOutCmd.java @@ -0,0 +1,65 @@ +package com.engine.kq.cmd.attendanceEvent; + +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.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 请假校验事件 + */ +public class CheckOutCmd extends AbstractCommonCommand> { + + public CheckOutCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + try{ + String attid = Util.null2String(params.get("attid")); + String checkRuleData2json = Util.null2String(params.get("checkRuleData2json")); + int workflowid = Util.getIntValue(Util.null2String(params.get("workflowid"))); + int nodeid = Util.getIntValue(Util.null2String(params.get("nodeid"))); + int requestid = Util.getIntValue(Util.null2String(params.get("requestid"))); + int nodetype = Util.getIntValue(Util.null2String(params.get("nodetype"))); + int currentnodetype = Util.getIntValue(Util.null2String(params.get("currentnodetype"))); + new KQLog().info("checkRuleData2json:"+checkRuleData2json); + JSONObject checkRuleData2jsonObject = (JSONObject) JSON.parse(checkRuleData2json); + if(!checkRuleData2jsonObject.isEmpty()){ + CheckRuleUtil checkDuplicateUtil = new CheckRuleUtil(); + Set> checkRuleDataSet = checkRuleData2jsonObject.entrySet(); + checkDuplicateUtil.checkRule(checkRuleDataSet,retmap,user,""+ KqSplitFlowTypeEnum.OUT.getFlowtype(), + requestid,currentnodetype,attid); + } + if(retmap.isEmpty()){ + retmap.put("status", "1"); + } + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/CheckOvertimeCmd.java b/src/com/engine/kq/cmd/attendanceEvent/CheckOvertimeCmd.java new file mode 100644 index 0000000..00ff0d1 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/CheckOvertimeCmd.java @@ -0,0 +1,67 @@ +package com.engine.kq.cmd.attendanceEvent; + +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.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 加班流程提交校验 + */ +public class CheckOvertimeCmd extends AbstractCommonCommand> { + + public CheckOvertimeCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + try{ + String attid = Util.null2String(params.get("attid")); + String checkDurationData2json = Util.null2String(params.get("checkDurationData2json")); + String checkRuleData2json = Util.null2String(params.get("checkRuleData2json")); + int workflowid = Util.getIntValue(Util.null2String(params.get("workflowid"))); + int nodeid = Util.getIntValue(Util.null2String(params.get("nodeid"))); + int requestid = Util.getIntValue(Util.null2String(params.get("requestid"))); + int nodetype = Util.getIntValue(Util.null2String(params.get("nodetype"))); + int currentnodetype = Util.getIntValue(Util.null2String(params.get("currentnodetype"))); + new KQLog().info("checkRuleData2json:"+checkRuleData2json); + new KQLog().info("检测每次提交的时候,页面上的时长是多少 checkDurationData2json:"+checkDurationData2json); + JSONObject checkRuleData2jsonObject = (JSONObject) JSON.parse(checkRuleData2json); + if(!checkRuleData2jsonObject.isEmpty()){ + CheckRuleUtil checkDuplicateUtil = new CheckRuleUtil(); + Set> checkRuleDataSet = checkRuleData2jsonObject.entrySet(); + checkDuplicateUtil.checkRule(checkRuleDataSet,retmap,user,""+ KqSplitFlowTypeEnum.OVERTIME.getFlowtype(), + requestid,currentnodetype,attid); + } + if(retmap.isEmpty()){ + retmap.put("status", "1"); + } + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/CheckProcessChangeCmd.java b/src/com/engine/kq/cmd/attendanceEvent/CheckProcessChangeCmd.java new file mode 100644 index 0000000..611ec75 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/CheckProcessChangeCmd.java @@ -0,0 +1,154 @@ +package com.engine.kq.cmd.attendanceEvent; + +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.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.KQFlowProcessChangeUtil; +import com.google.common.collect.Maps; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.Map.Entry; + +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 考勤变更流程提交校验事件 + */ +public class CheckProcessChangeCmd extends AbstractCommonCommand> { + + public CheckProcessChangeCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + String resMap = Util.null2String(params.get("resMap")); + int workflowid = Util.getIntValue(Util.null2String(params.get("workflowid"))); + int nodeid = Util.getIntValue(Util.null2String(params.get("nodeid"))); + String resourceId = Util.null2String(params.get("resourceid")); + String requestid = Util.null2String(params.get("requestid")); + String changerequestid = Util.null2String(params.get("changerequestid")); + String changetype = Util.null2String(params.get("changetype")); + String attid = Util.null2String(params.get("attid")); + String checkRuleData2json = Util.null2String(params.get("checkRuleData2json")); + String checkLeaveRuleData2json = Util.null2String(params.get("checkLeaveRuleData2json")); + int currentnodetype = Util.getIntValue(Util.null2String(params.get("currentnodetype"))); + List splitBeans = new ArrayList(); + new KQLog().info("checkRuleData2json:"+checkRuleData2json); + new KQLog().info("checkLeaveRuleData2json:"+checkLeaveRuleData2json); + if(resourceId.length() == 0 || requestid.length() == 0 || changetype.length() == 0){ + retmap.put("status", "2"); + retmap.put("message", SystemEnv.getHtmlLabelName(513781,user.getLanguage())); + return retmap; + } + + JSONObject checkRuleData2jsonObject = (JSONObject) JSON.parse(checkRuleData2json); + if(!checkRuleData2jsonObject.isEmpty()){ + Set> checkRuleDataSet = checkRuleData2jsonObject.entrySet(); + + for (Entry entry : checkRuleDataSet) { + String duplicateValue = Util.null2String(entry.getValue()); + String[] duplicateValues = duplicateValue.split("_",-1); + if(duplicateValues.length == 10){ + String fromDate = duplicateValues[1]; + String fromTime = duplicateValues[2]; + String toDate = duplicateValues[3]; + String toTime = duplicateValues[4]; + String attendancefromDate = duplicateValues[6]; + String attendancefromTime = duplicateValues[7]; + String attendancetoDate = duplicateValues[8]; + String attendancetoTime = duplicateValues[9]; + boolean canProcessChange = KQFlowProcessChangeUtil.canProcessChange(resourceId,changerequestid,attendancefromDate,attendancefromTime,attendancetoDate,attendancetoTime); + if(!canProcessChange){ + retmap.put("status", "2"); + retmap.put("message", ""+ SystemEnv.getHtmlLabelName(10005328,weaver.general.ThreadVarLanguage.getLang())+","+ SystemEnv.getHtmlLabelName(383337,weaver.general.ThreadVarLanguage.getLang())+""); + return retmap; + } + } + } + + if("0".equalsIgnoreCase(changetype)){ + //撤销的话就不需要校验重复了 + CheckRuleUtil checkDuplicateUtil = new CheckRuleUtil(); + checkDuplicateUtil.checkRule(checkRuleDataSet,retmap,user,""+ KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype(), + Util.getIntValue(requestid),currentnodetype,attid); + // 请假的话验证请假时长是否大于剩余时长,如果可以提交,还需要默认冻结掉 + if(retmap.isEmpty()) { + JSONObject checkLeaveRuleData2jsonObject = (JSONObject) JSON.parse(checkLeaveRuleData2json); + KQFlowProcessChangeUtil kqFlowProcessChangeUtil = new KQFlowProcessChangeUtil(user); + if (!checkLeaveRuleData2jsonObject.isEmpty()) { + Set> checkLeaveRuleDataSet = checkLeaveRuleData2jsonObject.entrySet(); + SplitBean splitBean = null; + for (Entry entry : checkLeaveRuleDataSet) { + String duplicateValue = Util.null2String(entry.getValue()); + String[] duplicateValues = duplicateValue.split("_", -1); + String fromDate = duplicateValues[1]; + String fromTime = duplicateValues[2]; + String toDate = duplicateValues[3]; + String toTime = duplicateValues[4]; + String duration = duplicateValues[6]; + String leaveDuration = duplicateValues[7]; + kqFlowProcessChangeUtil.canLeaveFlowProcessChange(resourceId, changerequestid, retmap, fromDate, duration, workflowid, nodeid, leaveDuration, attid); + if (!"".equals(Util.null2String(retmap.get("status")))) { + break; + } +// splitBean = new SplitBean(); +// splitBean.setRequestId(requestid); +// splitBean.setWorkflowId("" + workflowid); +// splitBean.setDataId("0"); +// splitBean.setDetailId("0"); +// splitBean.setResourceId(resourceId); +// splitBean.setFromDate(fromDate); +// splitBean.setFromTime(fromTime); +// splitBean.setToDate(toDate); +// splitBean.setToTime(toTime); +// splitBean.setDuration(duration); +// String newLeaveType = Util.null2String(retmap.get("newLeaveType")); +// splitBean.setNewLeaveType(newLeaveType); +// String durationrule = Util.null2String(retmap.get("durationrule")); +// splitBean.setDurationrule(durationrule); +// splitBeans.add(splitBean); + } + } + } + } + } + if("".equals(Util.null2String(retmap.get("status")))){ + retmap.put("status", "1"); + // 如果是请假变更的话,直接冻结 +// if("0".equalsIgnoreCase(changetype)){ +// KQFlowProcessChangeUtil kqFlowProcessChangeUtil = new KQFlowProcessChangeUtil(user); +// kqFlowProcessChangeUtil.doLeaveFlowFreeze(splitBeans,retmap); +// } + } + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/CheckRuleUtil.java b/src/com/engine/kq/cmd/attendanceEvent/CheckRuleUtil.java new file mode 100644 index 0000000..4d65906 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/CheckRuleUtil.java @@ -0,0 +1,1451 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQAttFlowSetBiz; +import com.engine.kq.biz.KQAttProcSetComInfo; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQTransMethod; +import com.engine.kq.wfset.util.SplitSelectSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.workflow.workflow.WorkflowRequestComInfo; + +public class CheckRuleUtil { + public String[] ori_str = new String[]{"#requestname_link#","#requestname#"}; + public String[] ori_count_str = new String[]{"#num_type#","#num_count#"}; + private KQLog kqLog = new KQLog(); + + private String processLeaveRquestid = ""; + + public void checkRule(Set> checkRuleDataSet, + Map retmap, User user, String kqtype, int requestid,int nodetype,String attid) { + try{ + + if(attid.length() == 0 || Util.getIntValue(attid) < 0 || kqtype.length() == 0 || Util.getIntValue(kqtype) < 0){ + return ; + } + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + String workflowid = ""; + String wf_sql = "select * from kq_att_proc_set where id = ?"; + rs.executeQuery(wf_sql, attid); + if(rs.next()){ + workflowid = rs.getString("field001"); + } + + String sql = "select * from kq_att_checkrule_set where attid=? "; + rs.executeQuery(sql, attid); + while (rs.next()){ + if(!retmap.isEmpty() && retmap.containsKey("status")){ + if("-1".equalsIgnoreCase(Util.null2String(retmap.get("status")))){ + return; + } + } + String ruleid = rs.getString("ruleid"); + String rule_type_uuid = rs.getString("rule_type_uuid"); + String type_sql = "select * from kq_att_checkrule_type where uuid=? and att_type=? "; + rs1.executeQuery(type_sql, rule_type_uuid,kqtype); + if(rs1.next()){ + String rule_table = rs1.getString("rule_table"); + if("kq_att_duplicate_rule".equalsIgnoreCase(rule_table)){ + //如果是重复校验,走重复校验的逻辑 + String table_sql = "select * from "+rule_table+" where id=? "; + rs2.executeQuery(table_sql, ruleid); + if(rs2.next()){ + check_duplicate_rule(checkRuleDataSet,retmap, user, kqtype, requestid,nodetype,workflowid,rs2); + } + }else if("kq_att_frequency_rule".equalsIgnoreCase(rule_table)){ + //如果是次数校验,走次数校验的逻辑 + String table_sql = "select * from "+rule_table+" where id=? "; + rs2.executeQuery(table_sql, ruleid); + if(rs2.next()){ + check_frequency_rule(checkRuleDataSet,retmap, user, kqtype, requestid,nodetype,attid,rs2); + } + } + } + } + }catch (Exception e){ + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + } + + /** + * 补卡流程,有两种控制: + * 重复校验只需要控制打卡日期时间是否重复了 + * 次数校验需要控制,每日,每周,每月可提交的补卡次数 + * 当前是次数校验 + * @param checkRuleDataSet + * @param retmap + * @param user + * @param kqtype + * @param requestid + * @param nodetype + * @param attid + * @param rs2 + */ + private void check_frequency_rule(Set> checkRuleDataSet, Map retmap, User user, String kqtype, int requestid, int nodetype, String attid, + RecordSet rs2) throws Exception{ + ResourceComInfo rci = new ResourceComInfo(); +// 校验类型 + String frequency_rule = rs2.getString("frequency_rule"); + String frequency_rule_content = new KQTransMethod().getFrequencyContent(frequency_rule,user.getLanguage()); +// 校验次数 + String frequency_rule_count = rs2.getString("frequency_rule_count"); + if(frequency_rule_count.length() == 0 || Util.getIntValue(frequency_rule_count) <= 0){ + return ; + } +// 校验强度 + String frequency_level = rs2.getString("frequency_level"); + if("2".equalsIgnoreCase(frequency_level)){ + //不校验 + return ; + } +// 提示语句 + String frequency_message = Util.null2String(rs2.getString("frequency_message")); + + RecordSet rs = new RecordSet(); + KQAttFlowSetBiz kqAttFlowSetBiz = new KQAttFlowSetBiz(); + Map daterangeMap = Maps.newConcurrentMap(); + List> dataList = Lists.newArrayList(); + for (Entry entry : checkRuleDataSet) { + String duplicateValue = Util.null2String(entry.getValue()); + String[] duplicateValues = duplicateValue.split("_",-1); + if (duplicateValues.length == 3) { + Map dataMap = Maps.newConcurrentMap(); + String resourceId = duplicateValues[0]; + String signdate = duplicateValues[1]; + if(resourceId.length() == 0 || signdate.length() == 0){ + continue; + } + String dateRange = getDateRangeByFrequency_rule(frequency_rule,signdate)+"_"+resourceId; + if(daterangeMap.containsKey(dateRange)){ + int tmp = Util.getIntValue(Util.null2s(daterangeMap.get(dateRange),"1")); + daterangeMap.put(dateRange, ""+(1+tmp)); + }else{ + daterangeMap.put(dateRange, "1"); + } + dataMap.put("resourceId", resourceId); + dataMap.put("signdate", signdate); + dataMap.put("dateRange", dateRange); + dataList.add(dataMap); + } + } + + if(!daterangeMap.isEmpty()){ + for(Entry me : daterangeMap.entrySet()){ + String key = me.getKey(); + String resourceId = key.split("_")[2]; + int tmp = Util.getIntValue(Util.null2s(daterangeMap.get(key),"1")); + if(tmp > Util.getIntValue(frequency_rule_count)){ + retmap.put("status", "-1"); + if("1".equalsIgnoreCase(frequency_level)){ + //弱控 + retmap.put("status", "-2"); + } + String[] replace_str = new String[]{frequency_rule_content,frequency_rule_count}; + frequency_message = StringUtils.replaceEach(frequency_message, ori_count_str,replace_str); + retmap.put("message", rci.getLastname(resourceId)+frequency_message); + return ; + } + } + } + for(Map mapData : dataList){ + String resourceId = mapData.get("resourceId"); + String signdate = mapData.get("signdate"); + String dateRange = mapData.get("dateRange"); + String custome_sql = ""; + if(dateRange.length() > 0 && dateRange.split("_").length == 3){ + String daterange_start = dateRange.split("_")[0]; + String daterange_end = dateRange.split("_")[1]; + if(daterange_start.length() > 0 && daterange_end.length() > 0){ + custome_sql = " detail_signdate between '"+daterange_start+"' and '"+daterange_end+"'"; + } + } + if(custome_sql.length() == 0){ + continue; + } + Map params = Maps.newHashMap(); + params.put("typeselect", "6"); + params.put("tabKey", "3"); + params.put("kqtype", kqtype); + params.put("isMyKQ", "1"); + params.put("custome_sql", custome_sql); + params.put("resourceId", resourceId); + params.put("not_start_node", "1"); + if(requestid > 0){ + params.put("not_requestId", requestid); + } + params.put("isNoAccount", "1"); + Map sqlMap = kqAttFlowSetBiz.getFLowSql(params,user); + String backfields = " * "; +// String backfields = " count(requestid) as cnt_request "; + String fromSql = Util.null2String(sqlMap.get("from")); + String sqlWhere = Util.null2String(sqlMap.get("where")); + String allSql = "select "+ backfields + fromSql+sqlWhere; + kqLog.info("check_frequency_rule:allSql:"+allSql); + int request_count = 0; + Map tmpdatas = new HashMap<>(); + rs.executeQuery(allSql); + while (rs.next()){ + String detail_signdate = Util.null2String(rs.getString("detail_signdate")); + String detail_signtype = Util.null2String(rs.getString("detail_signtype")); + String detail_signtime = Util.null2String(rs.getString("detail_signtime")); + String detail_requestid = Util.null2String(rs.getString("requestid")); + String key = detail_requestid+"#"+detail_signdate+"#"+detail_signtime+"#"+detail_signtype; + if(tmpdatas.get(key)!=null){ + continue; + }else{ + request_count ++; + tmpdatas.put(key,1); + } + } + + int cur_flow_count = 0; + if(daterangeMap.containsKey((dateRange))){ + cur_flow_count = Util.getIntValue(Util.null2s(daterangeMap.get(dateRange),"0")); + } + kqLog.info("check_frequency_rule:request_count:"+request_count+":cur_flow_count:"+cur_flow_count); + + if((request_count+cur_flow_count) > Util.getIntValue(frequency_rule_count)){ + retmap.put("status", "-1"); + if("1".equalsIgnoreCase(frequency_level)){ + //弱控 + retmap.put("status", "-2"); + } + String[] replace_str = new String[]{frequency_rule_content,frequency_rule_count}; + frequency_message = StringUtils.replaceEach(frequency_message, ori_count_str,replace_str); + retmap.put("message", rci.getLastname(resourceId)+frequency_message); + return; + } + +// if(rs.next()){ +// int request_count = Util.getIntValue(rs.getString("cnt_request")); +// int cur_flow_count = 0; +// if(daterangeMap.containsKey(dateRange)){ +// cur_flow_count = Util.getIntValue(Util.null2s(daterangeMap.get(dateRange),"0")); +// } +// +// if((request_count+cur_flow_count) > Util.getIntValue(frequency_rule_count)){ +// retmap.put("status", "-1"); +// if("1".equalsIgnoreCase(frequency_level)){ +// //弱控 +// retmap.put("status", "-2"); +// } +// String[] replace_str = new String[]{frequency_rule_content,frequency_rule_count}; +// frequency_message = StringUtils.replaceEach(frequency_message, ori_count_str,replace_str); +// retmap.put("message", frequency_message); +// return; +// } +// } + } + + } + + /** + * 根据校验规则 和当前得到 + * @param frequency_rule + * @param signdate + */ + public String getDateRangeByFrequency_rule(String frequency_rule, String signdate) { + String daterange_start = ""; + String daterange_end = ""; + if("0".equalsIgnoreCase(frequency_rule)){ + //每日 + daterange_start = signdate; + daterange_end = signdate; + }else if("1".equalsIgnoreCase(frequency_rule)){ + //每周 + daterange_start = DateUtil.getFirstDayOfWeek(signdate); + daterange_end = DateUtil.getLastDayOfWeek(signdate); + }else if("2".equalsIgnoreCase(frequency_rule)){ + //每月 + daterange_start = DateUtil.getFirstDayOfMonth(signdate); + daterange_end = DateUtil.getLastDayOfMonth(signdate); + }else if("3".equalsIgnoreCase(frequency_rule)){ + //每季度 + daterange_start = DateUtil.getFirstDayOfQuarter(signdate); + daterange_end = DateUtil.getLastDayOfQuarter(signdate); + }else if("4".equalsIgnoreCase(frequency_rule)){ + //每年 + daterange_start = DateUtil.getFirstDayOfYear(signdate); + daterange_end = DateUtil.getLastDayOfYear(signdate); + } + String key = daterange_start+"_"+daterange_end; + + return key; + } + + /** + * 重复校验的处理 + * @param checkRuleDataSet + * @param retmap + * @param user + * @param kqtype + * @param requestid + * @param nodetype + * @param workflowid + * @param rs2 + */ + private void check_duplicate_rule(Set> checkRuleDataSet, + Map retmap, User user, String kqtype, int requestid, int nodetype, + String workflowid, RecordSet rs2) throws Exception{ + List wfids = Lists.newArrayList(); +// 校验类型 + String duplicate_rule = rs2.getString("duplicate_rule"); +// 校验强度 + String duplicate_level = rs2.getString("duplicate_level"); + if("2".equalsIgnoreCase(duplicate_level)){ + //不校验 + return ; + } +// 提示语句 + String duplicate_message = Util.null2String(rs2.getString("duplicate_message"),SystemEnv.getHtmlLabelName(516397, Util.getIntValue(user.getLanguage()))); + + //补卡流程只需要有自己流程比较,不会和其他流程相互比较的 + if("0".equalsIgnoreCase(duplicate_rule)){ + //同流程 + wfids.add(workflowid); + }else if("1".equalsIgnoreCase(duplicate_rule)){ + //各个流程之间 +// 需校验流程路径 + String duplicate_wfids = rs2.getString("duplicate_wfids"); + if(duplicate_wfids.length() > 0){ + String[] duplicate_wfidArr = duplicate_wfids.split(","); + for(String wfid : duplicate_wfidArr){ + wfids.add(wfid); + } + } + }else{ + wfids.add(workflowid); + } + kqLog.info("check_duplicate_rule:wfids:"+wfids+":duplicate_rule:"+duplicate_rule+":duplicate_level:"+duplicate_level); + + boolean isCard = false; + boolean isEvection = false; + boolean isProcess = false; + if(kqtype.equalsIgnoreCase(""+KqSplitFlowTypeEnum.CARD.getFlowtype())){ + isCard = true; + }else if(kqtype.equalsIgnoreCase(""+KqSplitFlowTypeEnum.EVECTION.getFlowtype())){ + isEvection = true; + }else if(kqtype.equalsIgnoreCase(""+KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype())){ + isProcess = true; + }else{ + } + if(isCard){ + doWhenisDuplicateCard(checkRuleDataSet,requestid,wfids,user,duplicate_message,retmap); + }else if(isEvection){ + doWhenisDuplicateEvection(checkRuleDataSet,requestid,wfids,user,duplicate_message,retmap); + }else if(isProcess){ + doWhenisDuplicateProcess(checkRuleDataSet,requestid,wfids,user,duplicate_message,retmap); + }else{ + doWhenisCommonDuplicate(checkRuleDataSet,requestid,wfids,user,duplicate_message,retmap); + } + if("1".equalsIgnoreCase(duplicate_level)){ + //弱控 + if(!retmap.isEmpty()){ + retmap.put("status", "-2"); + } + } + } + + /** + * 考勤变更流程,因为有字段不同,需要单独处理 + * @param checkRuleDataSet + * @param requestid + * @param wfids + * @param user + * @param duplicate_message + * @param retmap + */ + private void doWhenisDuplicateProcess(Set> checkRuleDataSet, int requestid, + List wfids, User user, String duplicate_message, + Map retmap) throws Exception{ + String process_changerequestid = ""; + String process_resourceId = ""; + String process_tablename = ""; + Map wftypeMap = Maps.newHashMap(); + RecordSet rs = new RecordSet(); + Map> mapSqls = Maps.newHashMap(); + Map>> duplicateMaps = Maps.newHashMap(); + for (Entry entry : checkRuleDataSet) { + String duplicateValue = Util.null2String(entry.getValue()); + String[] duplicateValues = duplicateValue.split("_",-1); + if(duplicateValues.length == 10){ + String resourceId = duplicateValues[0]; + String fromDate = duplicateValues[1]; + String fromTime = duplicateValues[2]; + String toDate = duplicateValues[3]; + String toTime = duplicateValues[4]; + String changerequestid = duplicateValues[5]; + String attendancefromDate = duplicateValues[6]; + String attendancefromTime = duplicateValues[7]; + String attendancetoDate = duplicateValues[8]; + String attendancetoTime = duplicateValues[9]; + if(fromDate.length() == 0 || fromTime.length() == 0 || toDate.length() == 0 || toTime.length() == 0){ + continue; + } + + process_changerequestid = changerequestid; + process_resourceId = resourceId; + long fromdatetime_long = DateUtil.getCalendar(fromDate+" "+fromTime).getTimeInMillis(); + long todatetime_long = DateUtil.getCalendar(toDate+" "+toTime).getTimeInMillis(); + if(attendancetoDate.length() == 0 || attendancefromTime.length() == 0 || attendancetoDate.length() == 0 || attendancetoTime.length() == 0){ + continue; + } + long attendance_fromdatetime_long = DateUtil.getCalendar(attendancefromDate+" "+attendancefromTime).getTimeInMillis(); + long attendance_todatetime_long = DateUtil.getCalendar(attendancetoDate+" "+attendancetoTime).getTimeInMillis(); + + buildMap4Process(duplicateMaps,resourceId,fromdatetime_long,todatetime_long,attendance_fromdatetime_long,attendance_todatetime_long); + + for(String wfid : wfids){ + Map params = Maps.newHashMap(); + buildSql(mapSqls, user, wfid, fromDate, toDate, resourceId, requestid,params,wftypeMap); + } + } + } + + //如果变更明细里原数据和变更数据完全一致也需要记录下 + List same_processList = Lists.newArrayList(); + //变更流程的明细数量是不是和被变更流程的明细数量一致 + boolean isSameProcess = false; + if(!duplicateMaps.isEmpty() && process_changerequestid.length() > 0){ + Map otherparams = Maps.newHashMap(); + otherparams.put("resourceId", process_resourceId); + otherparams.put("requestid", process_changerequestid); + GetProcessChangeTypeCmd processChangeTypeCmd = new GetProcessChangeTypeCmd(otherparams, user); + Map retmaps = processChangeTypeCmd.execute(null); + if(retmaps != null && !retmaps.isEmpty()){ + if(retmaps.containsKey("process_type") && retmaps.containsKey("process_tablename")){ + process_tablename = Util.null2String(retmaps.get("process_tablename")); + } + } + + List processList = Lists.newArrayList(); + String process_sql = "select * from "+process_tablename+" where requestid=? and resourceid=? and status=0 "; + rs.executeQuery(process_sql, process_changerequestid,process_resourceId); + //这种情况就是变更流程只是变更了一部分流程数据的话,需要考虑一种特殊情况就是 + //当前被变更的流程和当前变更流程明细之间存在冲突的可能 + while (rs.next()){ + String fromdatedb = rs.getString("fromdatedb"); + String fromtimedb = rs.getString("fromtimedb"); + String todatedb = rs.getString("todatedb"); + String totimedb = rs.getString("totimedb"); + long fromdatetime_long = DateUtil.getCalendar(fromdatedb+" "+fromtimedb).getTimeInMillis(); + long todatetime_long = DateUtil.getCalendar(todatedb+" "+totimedb).getTimeInMillis(); + String key = fromdatetime_long+"_"+todatetime_long; + if(!processList.contains(key)){ + processList.add(key); + } + } + for(Entry>> me : duplicateMaps.entrySet()){ + boolean is_process_less = false; + List> values = me.getValue(); + if(processList.size() != values.size()){ + is_process_less = true; + }else{ + isSameProcess = true; + } + //针对当前流程本身,如果是明细表,多条明细之间也需要校验 + for(int i = 0 ; i < values.size() ; i++){ + long fromdatetime_long = StringUtil.parseToLong(values.get(i).get("fromdatetime_long")); + long todatetime_long = StringUtil.parseToLong(values.get(i).get("todatetime_long")); + long attendance_fromdatetime_long = StringUtil.parseToLong(values.get(i).get("attendance_fromdatetime_long")); + long attendance_todatetime_long = StringUtil.parseToLong(values.get(i).get("attendance_todatetime_long")); + + if(is_process_less){ + String tmp_key = fromdatetime_long+"_"+todatetime_long; + if(fromdatetime_long == attendance_fromdatetime_long && todatetime_long == attendance_todatetime_long){ + //如果变更时间和原时间完全一致,不作处理 + same_processList.add(tmp_key); + }else{ + if(processList.contains(tmp_key)){ + retmap.put("status", "-1"); + String e_duplicate_message= duplicate_message; + String mobile_duplicate_message= duplicate_message; + String[] replace_str = new String[]{new KQTransMethod().getWorkFlowUrl(process_changerequestid),new WorkflowRequestComInfo().getRequestName(process_changerequestid)}; + String[] mobile_replace_str = new String[]{new KQTransMethod().getWorkFlowUrl4mobile(process_changerequestid),new WorkflowRequestComInfo().getRequestName(process_changerequestid)}; + String[] e_replace_str = new String[]{new WorkflowRequestComInfo().getRequestName(process_changerequestid),new WorkflowRequestComInfo().getRequestName(process_changerequestid)}; + mobile_duplicate_message = StringUtils.replaceEach(mobile_duplicate_message, ori_str,mobile_replace_str); + duplicate_message = StringUtils.replaceEach(duplicate_message, ori_str,replace_str); + e_duplicate_message = StringUtils.replaceEach(e_duplicate_message, ori_str,e_replace_str); + retmap.put("message", duplicate_message); + retmap.put("mobile_message", mobile_duplicate_message); + //给小e用的 + retmap.put("e_message", e_duplicate_message); + return; + } + } + } + if(values.size() > 1){ + for(int j = i+1 ; j < values.size() ;j++){ + long j_fromdatetime_long = StringUtil.parseToLong(values.get(j).get("fromdatetime_long")); + long j_todatetime_long = StringUtil.parseToLong(values.get(j).get("todatetime_long")); + if(todatetime_long <= j_fromdatetime_long || fromdatetime_long >= j_todatetime_long){ + //这样表示流程不交叉 + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(516400,user.getLanguage())); + return; + } + } + } + } + } + } + + kqLog.info("doWhenisDuplicateProcess:mapSqls:"+mapSqls); + boolean isLeave = false; + boolean isProcess = false; + if(retmap.isEmpty() && !mapSqls.isEmpty()){ + RecordSet rs1 = new RecordSet(); + for(Entry> me : mapSqls.entrySet()){ + String resourceId = me.getKey(); + if(duplicateMaps.containsKey(resourceId)){ + List values = me.getValue(); + for(int i = 0 ; i specialMap = getSpecialMap(tmp_wftype,related_requestid,rs,resourceId, user,flow_fromDate,flow_fromTime,flow_toDate,flow_toTime); + if(specialMap != null && !specialMap.isEmpty()){ + isLeave = Util.null2String(specialMap.get("isLeave")).equalsIgnoreCase("1"); + isProcess = Util.null2String(specialMap.get("isProcess")).equalsIgnoreCase("1"); + if(!isLeave){ + flow_fromDate = Util.null2String(specialMap.get("fromdatedb")); + flow_fromTime = Util.null2String(specialMap.get("fromtimedb")); + flow_toDate = Util.null2String(specialMap.get("todatedb")); + flow_toTime = Util.null2String(specialMap.get("totimedb")); + related_requestid = Util.null2String(specialMap.get("related_requestid")); + } + if(isProcess){ + if(process_changerequestid.equalsIgnoreCase(related_requestid)){ + if(isSameProcess){ + continue; + }else{ + if(flow_fromDate.length() > 0 && flow_fromTime.length() > 0 && flow_toDate.length() > 0 && flow_toTime.length() > 0) { + long todatetime_long = DateUtil.getCalendar(flow_toDate+" "+flow_toTime).getTimeInMillis(); + long fromdatetime_long = DateUtil.getCalendar(flow_fromDate+" "+flow_fromTime).getTimeInMillis(); + String tmp_key = fromdatetime_long+"_"+todatetime_long; + if(!same_processList.isEmpty()){ + if(same_processList.contains(tmp_key)){ + continue; + } + } + } + } + } + } + } + if(flow_fromDate.length() > 0 && flow_fromTime.length() > 0 && flow_toDate.length() > 0 && flow_toTime.length() > 0){ + long flow_fromdatetime_long = DateUtil.getCalendar(flow_fromDate+" "+flow_fromTime).getTimeInMillis(); + long flow_todatetime_long = DateUtil.getCalendar(flow_toDate+" "+flow_toTime).getTimeInMillis(); + List> duplicateVals = duplicateMaps.get(resourceId); + checkDuplicateFlow(duplicateVals,retmap,flow_fromdatetime_long,flow_todatetime_long,duplicate_message,related_requestid, + isLeave,resourceId); + if(!retmap.isEmpty()){ + return ; + } + } + } + } + } + } + } + } + + /** + * 出差流程,因为有陪同人的概念,需要特殊处理 + * @param checkRuleDataSet + * @param requestid + * @param wfids + * @param user + * @param duplicate_message + * @param retmap + */ + private void doWhenisDuplicateEvection(Set> checkRuleDataSet, int requestid, + List wfids, User user, String duplicate_message, + Map retmap) throws Exception{ + Map wftypeMap = Maps.newHashMap(); + RecordSet rs = new RecordSet(); + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + Map> mapSqls = Maps.newHashMap(); + Map>> duplicateMaps = Maps.newHashMap(); + List> duplicateLists = Lists.newArrayList(); + List sqls = Lists.newArrayList(); + KQAttFlowSetBiz kqAttFlowSetBiz = new KQAttFlowSetBiz(); + for (Entry entry : checkRuleDataSet) { + String duplicateValue = Util.null2String(entry.getValue()); + String[] duplicateValues = duplicateValue.split("_",-1); + if(duplicateValues.length == 6){ + String resourceId = duplicateValues[0]; + String fromDate = duplicateValues[1]; + String fromTime = duplicateValues[2]; + String toDate = duplicateValues[3]; + String toTime = duplicateValues[4]; + String companion = duplicateValues[5]; + if(fromDate.length() == 0 || fromTime.length() == 0 || toDate.length() == 0 || toTime.length() == 0){ + continue; + } + long fromdatetime_long = DateUtil.getCalendar(fromDate+" "+fromTime).getTimeInMillis(); + long todatetime_long = DateUtil.getCalendar(toDate+" "+toTime).getTimeInMillis(); + + buildMap(duplicateMaps,resourceId,fromdatetime_long,todatetime_long); + + if(companion.length() > 0) { + Map duplicateMap = Maps.newConcurrentMap(); + duplicateMap.put("fromdatetime_long", ""+fromdatetime_long); + duplicateMap.put("todatetime_long", ""+todatetime_long); + String[] companions = companion.split(","); + for (int i = 0; i < companions.length; i++) { + if(resourceId.equalsIgnoreCase(companions[i])){ + continue; + } + if(!duplicateMaps.containsKey(companions[i])){ + duplicateLists = Lists.newArrayList(); + duplicateLists.add(duplicateMap); + duplicateMaps.put(companions[i], duplicateLists); + }else{ + List> tmpList = duplicateMaps.get(companions[i]); + tmpList.add(duplicateMap); + } + } + } + for(String wfid : wfids){ + String tmp_wftype = kqAttProcSetComInfo.getkqType(wfid); + Map params = Maps.newHashMap(); + + buildSql(mapSqls, user, wfid, fromDate, toDate, resourceId, requestid,params,wftypeMap); + + if(companion.length() > 0){ + String[] companions = companion.split(","); + for(int i = 0 ; i < companions.length ; i++){ + if(tmp_wftype.equalsIgnoreCase(KqSplitFlowTypeEnum.EVECTION.getFlowtype()+"")){ + if (rs.getDBType().equalsIgnoreCase("oracle")||rs.getDBType().equalsIgnoreCase("postgresql")) { + params.put("custome_sql", " resourceId='"+companions[i]+"' or ','||to_char(companion)||',' like '%," + companions[i] + ",%' "); + } else if (rs.getDBType().equalsIgnoreCase("mysql")) { + params.put("custome_sql", " resourceId='"+companions[i]+"' or CONCAT(CONCAT(',',companion),',') like '%," + companions[i] + ",%' "); + } else { + params.put("custome_sql", " resourceId='"+companions[i]+"' or ','+cast(companion as varchar(max))+',' like '%," + companions[i] + ",%' "); + } + }else{ + params.put("resourceId", companions[i]); + } + params.put("isNoAccount", "1"); + Map companion_sqlMap = kqAttFlowSetBiz.getFLowSql(params,user); + String companion_backfields = " * "; + String companion_fromSql = Util.null2String(companion_sqlMap.get("from")); + String companion_sqlWhere = Util.null2String(companion_sqlMap.get("where")); + String companion_allSql = "select "+ companion_backfields + companion_fromSql+companion_sqlWhere; + wftypeMap.put(companion_allSql,tmp_wftype); + if(!mapSqls.containsKey(companions[i])){ + //存一下sql对应的考勤流程类型 + sqls = Lists.newArrayList(); + sqls.add(companion_allSql); + mapSqls.put(companions[i],sqls); + }else{ + List tmp_sqls = mapSqls.get(companions[i]); + tmp_sqls.add(companion_allSql); + } + } + } + } + } + } + + if(!duplicateMaps.isEmpty()){ + for(Entry>> me : duplicateMaps.entrySet()){ + List> values = me.getValue(); + if(values.size() > 1){ + //针对当前流程本身,如果是明细表,多条明细之间也需要校验 + for(int i = 0 ; i < values.size() ; i++){ + long fromdatetime_long = StringUtil.parseToLong(values.get(i).get("fromdatetime_long")); + long todatetime_long = StringUtil.parseToLong(values.get(i).get("todatetime_long")); + for(int j = i+1 ; j < values.size() ;j++){ + long j_fromdatetime_long = StringUtil.parseToLong(values.get(j).get("fromdatetime_long")); + long j_todatetime_long = StringUtil.parseToLong(values.get(j).get("todatetime_long")); + if(todatetime_long <= j_fromdatetime_long || fromdatetime_long >= j_todatetime_long){ + //这样表示流程不交叉 + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(516400,user.getLanguage())); + return; + } + } + } + } + } + } + + kqLog.info("doWhenisDuplicateEvection:mapSqls:"+mapSqls); + boolean isLeave = false; + if(retmap.isEmpty() && !mapSqls.isEmpty()){ + for(Entry> me : mapSqls.entrySet()){ + String resourceId = me.getKey(); + if(duplicateMaps.containsKey(resourceId)){ + List values = me.getValue(); + for(int i = 0 ; i specialMap = getSpecialMap(tmp_wftype,related_requestid,rs,resourceId, user, + flow_fromDate, flow_fromTime, flow_toDate, flow_toTime); + kqLog.info("1.requestid:"+requestid+":resourceId:"+resourceId+":tmp_wftype:"+tmp_wftype+":related_requestid:"+related_requestid + +":flow_fromDate:"+flow_fromDate+":flow_fromTime:"+flow_fromTime + +":flow_toDate:"+flow_toDate+":flow_toTime:"+flow_toTime); + if(specialMap != null && !specialMap.isEmpty()){ + isLeave = Util.null2String(specialMap.get("isLeave")).equalsIgnoreCase("1"); + if(isLeave){ + String repeatType = Util.null2String(rs.getString("repeat_type")); + if(repeatType.length() > 0){ + continue; + } + String newLeaveType = rs.getString("newLeaveType"); + String repeatTime = Util.null2String(kqLeaveRulesComInfo.getRepeatTime(newLeaveType)); + if("1".equals(repeatTime)){ + continue; + } + } + if(!isLeave){ + flow_fromDate = Util.null2String(specialMap.get("fromdatedb")); + flow_fromTime = Util.null2String(specialMap.get("fromtimedb")); + flow_toDate = Util.null2String(specialMap.get("todatedb")); + flow_toTime = Util.null2String(specialMap.get("totimedb")); + related_requestid = Util.null2String(specialMap.get("related_requestid")); + } + } + kqLog.info("2.requestid:"+requestid+":resourceId:"+resourceId+":tmp_wftype:"+tmp_wftype+":related_requestid:"+related_requestid + +":flow_fromDate:"+flow_fromDate+":flow_fromTime:"+flow_fromTime + +":flow_toDate:"+flow_toDate+":flow_toTime:"+flow_toTime); + if(flow_fromDate.length() > 0 && flow_fromTime.length() > 0 && flow_toDate.length() > 0 && flow_toTime.length() > 0){ + long flow_fromdatetime_long = DateUtil.getCalendar(flow_fromDate+" "+flow_fromTime).getTimeInMillis(); + long flow_todatetime_long = DateUtil.getCalendar(flow_toDate+" "+flow_toTime).getTimeInMillis(); + List> duplicateVals = duplicateMaps.get(resourceId); + checkDuplicateFlow(duplicateVals,retmap,flow_fromdatetime_long,flow_todatetime_long,duplicate_message,related_requestid, + isLeave, resourceId); + if(!retmap.isEmpty()){ + return ; + } + } + } + } + } + } + } + } + + /** + * 遍历循环考勤变更表,直到找到最后被变更的流程数据 + * @param related_requestid 每次变更后的requestid + * @param tablename + * @param loopLevel + * @param resourceId + * @param ori_related_requestid 最原始的考勤流程requestid + * @param flow_fromDate + * @param flow_fromTime + * @param flow_toDate + * @param flow_toTime + * @return + */ + public Map getProcessChange(String related_requestid, String tablename, + int loopLevel, String resourceId, String ori_related_requestid, + String flow_fromDate, String flow_fromTime, String flow_toDate, String flow_toTime) { + RecordSet rs = new RecordSet(); + String sql = "select distinct leavebackrequestid,status,fromdatedb,fromtimedb,todatedb,totimedb from "+tablename+" " + + "where requestid=? and resourceId=? and fromdatedb=? and fromtimedb=? and todatedb=? and totimedb=? "; + + if(loopLevel == 1){ + //只有第一次的时候,可以得到原始变更开始日期时间,结束日期时间 + rs.executeQuery(sql, related_requestid,resourceId,flow_fromDate,flow_fromTime,flow_toDate,flow_toTime); + }else { + //后面递归的时候,从中间表里就得不到之前的原始变更开始日期时间,结束日期时间了 + sql = "select distinct leavebackrequestid,status,fromdatedb,fromtimedb,todatedb,totimedb from "+tablename+" " + + "where requestid=? and resourceId=? "; + kqLog.info("getProcessChange.2.related_requestid:"+related_requestid+":resourceId:"+resourceId); + rs.executeQuery(sql, related_requestid,resourceId); + } + if(rs.next()){ + String leavebackrequestid = Util.null2String(rs.getString("leavebackrequestid")); + String fromdatedb = Util.null2String(rs.getString("fromdatedb")); + String fromtimedb = Util.null2String(rs.getString("fromtimedb")); + String todatedb = Util.null2String(rs.getString("todatedb")); + String totimedb = Util.null2String(rs.getString("totimedb")); + String status = Util.null2String(rs.getString("status")); + kqLog.info("getProcessChange.3.leavebackrequestid:"+leavebackrequestid+":status:"+status + +":fromdatedb:"+fromdatedb+":fromtimedb:"+fromtimedb + +":todatedb:"+todatedb+":totimedb:"+totimedb); + if("1".equalsIgnoreCase(status)){ + if(leavebackrequestid.length() > 0 && leavebackrequestid.indexOf(",") > -1){ + leavebackrequestid = leavebackrequestid.substring(1); + } + //如果递归超过50次,说明这个流程至少变更了50次,那就放过他 + if (loopLevel > 50){ + return null; + } + loopLevel++; + return getProcessChange(leavebackrequestid, tablename,loopLevel, resourceId,ori_related_requestid, + fromdatedb, fromtimedb, todatedb, totimedb); + }else { + Map new_datetimeMap = Maps.newHashMap(); +// if(leavebackrequestid.length() > 0){ + if(leavebackrequestid.indexOf(",") > -1){ + leavebackrequestid = leavebackrequestid.substring(1); + } +// if(leavebackrequestid.equalsIgnoreCase(ori_related_requestid)){ +// new_datetimeMap.put("fromdatedb", ""); +// new_datetimeMap.put("fromtimedb", ""); +// new_datetimeMap.put("todatedb", ""); +// new_datetimeMap.put("totimedb", ""); +// return new_datetimeMap; +// } + kqLog.info("getProcessChange.5.resourceId:"+resourceId + +":fromdatedb:"+fromdatedb+":fromtimedb:"+fromtimedb + +":todatedb:"+todatedb+":totimedb:"+totimedb); + new_datetimeMap.put("fromdatedb", fromdatedb); + new_datetimeMap.put("fromtimedb", fromtimedb); + new_datetimeMap.put("todatedb", todatedb); + new_datetimeMap.put("totimedb", totimedb); + new_datetimeMap.put("related_requestid", related_requestid); +// } + return new_datetimeMap; + } + }else{ + if(loopLevel > 1){ + //如果变更表里有数据,最后又没查询到了,表示被撤销了 + Map new_datetimeMap = Maps.newHashMap(); + new_datetimeMap.put("fromdatedb", ""); + new_datetimeMap.put("fromtimedb", ""); + new_datetimeMap.put("todatedb", ""); + new_datetimeMap.put("totimedb", ""); + return new_datetimeMap; + } + } + return Maps.newHashMap(); + } + + /** + * 非补卡,出差流程,即需要开始日期时间 结束日期时间的流程 + * @param checkRuleDataSet + * @param requestid + * @param wfids + * @param user + * @param duplicate_message + * @param retmap + */ + public void doWhenisCommonDuplicate(Set> checkRuleDataSet, int requestid, + List wfids, User user, String duplicate_message, + Map retmap) throws Exception{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + Map wftypeMap = Maps.newHashMap(); + RecordSet rs = new RecordSet(); + Map> mapSqls = Maps.newHashMap(); + Map>> duplicateMaps = Maps.newHashMap(); + for (Entry entry : checkRuleDataSet) { + String duplicateValue = Util.null2String(entry.getValue()); + String[] duplicateValues = duplicateValue.split("_",-1); + if(duplicateValues.length >= 5){ + String resourceId = duplicateValues[0]; + String fromDate = duplicateValues[1]; + String fromTime = duplicateValues[2]; + String toDate = duplicateValues[3]; + String toTime = duplicateValues[4]; + if(fromDate.length() == 0 || fromTime.length() == 0 || toDate.length() == 0 || toTime.length() == 0){ + continue; + } + + String repeatTime = "0"; + if(duplicateValues.length == 6){ + String newLeaveType = duplicateValues[5]; + if(newLeaveType.length() > 0){ + repeatTime = Util.null2String(kqLeaveRulesComInfo.getRepeatTime(newLeaveType)); + } + } + if("1".equals(repeatTime)){ + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate localToDate = LocalDate.parse(toDate); + long betweenDays = localToDate.toEpochDay() - localFromDate.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + LocalDate curLocalDate = localFromDate.plusDays(i); + String date = curLocalDate.format(dateFormatter); + long fromdatetime_long = DateUtil.getCalendar(date+" "+fromTime).getTimeInMillis(); + long todatetime_long = DateUtil.getCalendar(date+" "+toTime).getTimeInMillis(); + buildMap(duplicateMaps, resourceId, fromdatetime_long, todatetime_long); + + for(String wfid : wfids){ + Map params = Maps.newHashMap(); + buildSql(mapSqls, user, wfid, date, date, resourceId, requestid, params, wftypeMap); + } + } + + }else{ + long fromdatetime_long = DateUtil.getCalendar(fromDate+" "+fromTime).getTimeInMillis(); + long todatetime_long = DateUtil.getCalendar(toDate+" "+toTime).getTimeInMillis(); + buildMap(duplicateMaps, resourceId, fromdatetime_long, todatetime_long); + + for(String wfid : wfids){ + Map params = Maps.newHashMap(); + buildSql(mapSqls, user, wfid, fromDate, toDate, resourceId, requestid, params, wftypeMap); + } + } + } + } + + if(!duplicateMaps.isEmpty()){ + for(Entry>> me : duplicateMaps.entrySet()){ + List> values = me.getValue(); + if(values.size() > 1){ + //针对当前流程本身,如果是明细表,多条明细之间也需要校验 + for(int i = 0 ; i < values.size() ; i++){ + long fromdatetime_long = StringUtil.parseToLong(values.get(i).get("fromdatetime_long")); + long todatetime_long = StringUtil.parseToLong(values.get(i).get("todatetime_long")); + for(int j = i+1 ; j < values.size() ;j++){ + long j_fromdatetime_long = StringUtil.parseToLong(values.get(j).get("fromdatetime_long")); + long j_todatetime_long = StringUtil.parseToLong(values.get(j).get("todatetime_long")); + if(todatetime_long <= j_fromdatetime_long || fromdatetime_long >= j_todatetime_long){ + //这样表示流程不交叉 + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(516400,user.getLanguage())); + return; + } + } + } + } + } + } + boolean isLeave = false; + if(retmap.isEmpty() && !mapSqls.isEmpty()){ + RecordSet rs1 = new RecordSet(); + for(Entry> me : mapSqls.entrySet()){ + String resourceId = me.getKey(); + if(duplicateMaps.containsKey(resourceId)){ + List values = me.getValue(); + for(int i = 0 ; i specialMap = getSpecialMap(tmp_wftype,related_requestid,rs,resourceId, user, + flow_fromDate, flow_fromTime, flow_toDate, flow_toTime); + if(specialMap != null && !specialMap.isEmpty()){ + isLeave = Util.null2String(specialMap.get("isLeave")).equalsIgnoreCase("1"); + if(!isLeave){ + flow_fromDate = Util.null2String(specialMap.get("fromdatedb")); + flow_fromTime = Util.null2String(specialMap.get("fromtimedb")); + flow_toDate = Util.null2String(specialMap.get("todatedb")); + flow_toTime = Util.null2String(specialMap.get("totimedb")); + related_requestid = Util.null2String(specialMap.get("related_requestid")); + } + if(isLeave){ + String flow_newLeaveType = Util.null2String(rs.getString(newLeaveType_field)); + if(flow_newLeaveType.length() > 0){ + repeatTime = kqLeaveRulesComInfo.getRepeatTime(flow_newLeaveType); + } + } + } + if(flow_fromDate.length() > 0 && flow_fromTime.length() > 0 && flow_toDate.length() > 0 && flow_toTime.length() > 0){ + List> duplicateVals = duplicateMaps.get(resourceId); + if("1".equals(repeatTime)){ + //被校验的流程是重复时段的话 + LocalDate localFromDate = LocalDate.parse(flow_fromDate); + LocalDate localToDate = LocalDate.parse(flow_toDate); + long betweenDays = localToDate.toEpochDay() - localFromDate.toEpochDay(); + for (int j = 0; j <= betweenDays; j++) { + LocalDate curLocalDate = localFromDate.plusDays(j); + String date = curLocalDate.format(dateFormatter); + long flow_fromdatetime_long = DateUtil.getCalendar(date+" "+flow_fromTime).getTimeInMillis(); + long flow_todatetime_long = DateUtil.getCalendar(date+" "+flow_toTime).getTimeInMillis(); + checkDuplicateFlow(duplicateVals,retmap,flow_fromdatetime_long,flow_todatetime_long,duplicate_message,related_requestid,isLeave, + resourceId); + if(!retmap.isEmpty()){ + return ; + } + } + }else{ + long flow_fromdatetime_long = DateUtil.getCalendar(flow_fromDate+" "+flow_fromTime).getTimeInMillis(); + long flow_todatetime_long = DateUtil.getCalendar(flow_toDate+" "+flow_toTime).getTimeInMillis(); + checkDuplicateFlow(duplicateVals,retmap,flow_fromdatetime_long,flow_todatetime_long,duplicate_message,related_requestid,isLeave, + resourceId); + if(!retmap.isEmpty()){ + return ; + } + } + } + } + } + } + } + } + } + + public boolean getLeaveBack(String related_requestid, long fromdatetime_long, + long todatetime_long, String resourceId) { + RecordSet rs = new RecordSet(); + processLeaveRquestid = related_requestid; + List all_long = Lists.newArrayList(); + String sql = "select * from kq_flow_split_leave where status=1 and requestid=? and resourceId=? \n "; + rs.executeQuery(sql, related_requestid,resourceId); + int countsLeave = rs.getCounts(); + if(countsLeave>0) { + return true; + } + boolean isInLeaveBack = false; + sql = "select distinct fromDatedb,fromTimedb,toDatedb,toTimedb from kq_flow_split_leaveback where leavebackrequestid=? and resourceId=? order by fromDatedb,fromTimedb,toDatedb,toTimedb\n "; + rs.executeQuery(sql, related_requestid,resourceId); + int counts = rs.getCounts(); + boolean isProcess = false; + if(counts <= 0) { + sql = "select distinct fromDatedb,fromTimedb,toDatedb,toTimedb,requestid from kq_flow_split_leave where leavebackrequestid=? and resourceId=? and status=0 order by fromDatedb,fromTimedb,toDatedb,toTimedb,requestid\n "; + rs.executeQuery(sql, related_requestid,resourceId); + isProcess = true; + } + while (rs.next()){ + String flow_fromDate = rs.getString("fromDatedb"); + String flow_fromTime = rs.getString("fromTimedb"); + String flow_toDate = rs.getString("toDatedb"); + String flow_toTime = rs.getString("toTimedb"); + if(isProcess) { + processLeaveRquestid = rs.getString("requestid"); + } + long flow_fromdatetime_long = DateUtil.getCalendar(flow_fromDate+" "+flow_fromTime).getTimeInMillis(); + long flow_todatetime_long = DateUtil.getCalendar(flow_toDate+" "+flow_toTime).getTimeInMillis(); + if(!all_long.contains(flow_fromdatetime_long)){ + all_long.add(flow_fromdatetime_long); + }else{ + all_long.remove(flow_fromdatetime_long); + } + if(!all_long.contains(flow_todatetime_long)){ + all_long.add(flow_todatetime_long); + }else{ + all_long.remove(flow_todatetime_long); + } + } + for(int i = 0 ; i < all_long.size() ;){ + long flow_fromdatetime_long = all_long.get(i); + long flow_todatetime_long = all_long.get(i+1); + if(isProcess) { // 请假变更,没有交叉就允许提交 + if(todatetime_long <= flow_fromdatetime_long || fromdatetime_long >= flow_todatetime_long){ + isInLeaveBack = true; + break; + } + } else { + //如果当前重复的区间刚好在销假区间内 + if (fromdatetime_long >= flow_fromdatetime_long && fromdatetime_long <= flow_todatetime_long + && todatetime_long >= flow_fromdatetime_long && todatetime_long <= flow_todatetime_long) { + isInLeaveBack = true; + break; + } + } + i = i +2; + } + return isInLeaveBack; + } + + /** + * 补卡流程,有两种控制: + * 重复校验只需要控制打卡日期时间是否重复了 + * 次数校验需要控制,每日,每周,每月可提交的补卡次数 + * 当前是重复校验 + * @param checkRuleDataSet + * @param requestid + * @param wfids + * @param user + */ + public void doWhenisDuplicateCard(Set> checkRuleDataSet, int requestid, + List wfids, User user, String duplicate_message, + Map retmap) throws Exception{ + RecordSet rs = new RecordSet(); + ResourceComInfo rci = new ResourceComInfo(); + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + Map> mapSqls = Maps.newHashMap(); + Map> duplicateMaps = Maps.newHashMap(); + List duplicateLists = Lists.newArrayList(); + List sqls = Lists.newArrayList(); + KQAttFlowSetBiz kqAttFlowSetBiz = new KQAttFlowSetBiz(); + for (Entry entry : checkRuleDataSet) { + String duplicateValue = Util.null2String(entry.getValue()); + String[] duplicateValues = duplicateValue.split("_",-1); + if(duplicateValues.length == 3){ + String resourceId = duplicateValues[0]; + String signdate = duplicateValues[1]; + String signtime = duplicateValues[2]; + if(resourceId.length() == 0 || signdate.length() == 0 || signtime.length() == 0){ + continue; + } + + String signdate_time = signdate+"_"+signtime; + if(duplicateMaps.containsKey(resourceId)){ + List tmp_duplicateLists =duplicateMaps.get(resourceId); + if(tmp_duplicateLists.contains(signdate_time)){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(516400,user.getLanguage())); + return; + } + }else{ + duplicateLists = Lists.newArrayList(); + duplicateLists.add(signdate_time); + duplicateMaps.put(resourceId, duplicateLists); + } + for(String wfid : wfids){ + Map params = Maps.newHashMap(); + params.put("typeselect", "6"); + params.put("tabKey", "3"); + params.put("kqtype", kqAttProcSetComInfo.getkqType(wfid)); + params.put("isMyKQ", "1"); + params.put("workflowid", wfid); + params.put("custome_sql", " detail_signdate='"+signdate+"' and detail_signtime='"+signtime+"' "); + params.put("resourceId", resourceId); + params.put("not_start_node", "1"); + if(requestid > 0){ + params.put("not_requestId", requestid); + } + params.put("isNoAccount", "1"); + Map sqlMap = kqAttFlowSetBiz.getFLowSql(params,user); + String backfields = " * "; + String fromSql = Util.null2String(sqlMap.get("from")); + String sqlWhere = Util.null2String(sqlMap.get("where")); + String allSql = "select "+ backfields + fromSql+sqlWhere; + rs.executeQuery(allSql); + kqLog.info("doWhenisDuplicateCard:allSql:"+allSql); + if(rs.next()){ + String mobile_duplicate_message= duplicate_message; + String related_requestid = rs.getString("requestid"); + String e_duplicate_message= duplicate_message; + String[] replace_str = new String[]{new KQTransMethod().getWorkFlowUrl(related_requestid),new WorkflowRequestComInfo().getRequestName(related_requestid)}; + String[] mobile_replace_str = new String[]{new KQTransMethod().getWorkFlowUrl4mobile(related_requestid),new WorkflowRequestComInfo().getRequestName(related_requestid)}; + String[] e_replace_str = new String[]{new WorkflowRequestComInfo().getRequestName(related_requestid),new WorkflowRequestComInfo().getRequestName(related_requestid)}; + mobile_duplicate_message = StringUtils.replaceEach(mobile_duplicate_message, ori_str,mobile_replace_str); + duplicate_message = StringUtils.replaceEach(duplicate_message, ori_str,replace_str); + e_duplicate_message = StringUtils.replaceEach(e_duplicate_message, ori_str,e_replace_str); + retmap.put("status", "-1"); + retmap.put("message", rci.getLastname(resourceId)+duplicate_message); + retmap.put("mobile_message", rci.getLastname(resourceId)+mobile_duplicate_message); + //给小e用的 + retmap.put("e_message", rci.getLastname(resourceId)+e_duplicate_message); + return; + } + if(mapSqls.containsKey(resourceId)){ + List tmp_sqls = mapSqls.get(resourceId); + tmp_sqls.add(allSql); + }else{ + sqls = Lists.newArrayList(); + sqls.add(allSql); + mapSqls.put(resourceId,sqls); + } + } + } + } + } + + /** + * 根据规则组装查询sql + * @param mapSqls + * @param user + * @param wfid + * @param fromDate + * @param toDate + * @param resourceId + * @param requestid + * @param params + */ + public void buildSql(Map> mapSqls, User user, String wfid, String fromDate, + String toDate, String resourceId, int requestid, + Map params,Map wftypeMap){ + RecordSet rs = new RecordSet(); + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + KQAttFlowSetBiz kqAttFlowSetBiz = new KQAttFlowSetBiz(); + List sqls = Lists.newArrayList(); + String tmp_wftype = kqAttProcSetComInfo.getkqType(wfid); + params.put("typeselect", "6"); + params.put("tabKey", "3"); + params.put("kqtype", tmp_wftype); + params.put("isMyKQ", "1"); + params.put("resourceId", resourceId); + if(tmp_wftype.equalsIgnoreCase(KqSplitFlowTypeEnum.EVECTION.getFlowtype()+"")){ + params.put("fromDate", fromDate); + params.put("toDate", toDate); + if (rs.getDBType().equalsIgnoreCase("oracle")||rs.getDBType().equalsIgnoreCase("postgresql")) { + params.put("custome_sql", " (resourceId='"+resourceId+"' or ','||to_char(companion)||',' like '%," + resourceId + ",%') "); + } else if (rs.getDBType().equalsIgnoreCase("mysql")) { + params.put("custome_sql", " (resourceId='"+resourceId+"' or CONCAT(CONCAT(',',companion),',') like '%," + resourceId + ",%') "); + } else { + params.put("custome_sql", " (resourceId='"+resourceId+"' or ','+cast(companion as varchar(max))+',' like '%," + resourceId + ",%') "); + } + params.put("resourceId", ""); + }else if(tmp_wftype.equalsIgnoreCase(KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype()+"")){ + params.put("custome_sql", " ( detail_fromDate between '"+fromDate+"' and '"+toDate+"' or detail_toDate between '"+fromDate+"' and '"+toDate+"' " + + " or '"+fromDate+"' between detail_fromDate and detail_toDate or '"+toDate+"' between detail_fromDate and detail_toDate) " + +" "); + }else{ + params.put("fromDate", fromDate); + params.put("toDate", toDate); + } + params.put("not_start_node", "1"); + params.put("workflowid", wfid); + if(requestid > 0){ + params.put("not_requestId", requestid); + } + params.put("isNoAccount", "1"); + Map sqlMap = kqAttFlowSetBiz.getFLowSql(params,user); + String backfields = " * "; + String fromSql = Util.null2String(sqlMap.get("from")); + String sqlWhere = Util.null2String(sqlMap.get("where")); + String allSql = "select "+ backfields + fromSql+sqlWhere; + kqLog.info("requestid:"+requestid+":allSql:"+allSql); + //存一下sql对应的考勤流程类型 + wftypeMap.put(allSql,tmp_wftype); + if(mapSqls.containsKey(resourceId)){ + List tmp_sqls = mapSqls.get(resourceId); + tmp_sqls.add(allSql); + }else{ + sqls = Lists.newArrayList(); + sqls.add(allSql); + mapSqls.put(resourceId,sqls); + } + } + + /** + * 组装人员和开始结束日期时间的map集合 + * @param duplicateMaps + * @param resourceId + * @param fromdatetime_long + * @param todatetime_long + */ + public void buildMap(Map>> duplicateMaps, String resourceId, + long fromdatetime_long, long todatetime_long) { + Map duplicateMap = Maps.newConcurrentMap(); + List> duplicateLists = Lists.newArrayList(); + duplicateMap.put("fromdatetime_long", ""+fromdatetime_long); + duplicateMap.put("todatetime_long", ""+todatetime_long); + if(duplicateMaps.containsKey(resourceId)){ + List> tmp_duplicateLists =duplicateMaps.get(resourceId); + tmp_duplicateLists.add(duplicateMap); + }else{ + duplicateLists = Lists.newArrayList(); + duplicateLists.add(duplicateMap); + duplicateMaps.put(resourceId, duplicateLists); + } + } + + /** + * 组装人员和开始结束日期时间的map集合 + * @param duplicateMaps + * @param resourceId + * @param fromdatetime_long + * @param todatetime_long + * @param attendance_fromdatetime_long + * @param attendance_todatetime_long + */ + public void buildMap4Process(Map>> duplicateMaps, + String resourceId, + long fromdatetime_long, long todatetime_long, long attendance_fromdatetime_long, + long attendance_todatetime_long) { + Map duplicateMap = Maps.newConcurrentMap(); + List> duplicateLists = Lists.newArrayList(); + duplicateMap.put("fromdatetime_long", ""+fromdatetime_long); + duplicateMap.put("todatetime_long", ""+todatetime_long); + duplicateMap.put("attendance_fromdatetime_long", ""+attendance_fromdatetime_long); + duplicateMap.put("attendance_todatetime_long", ""+attendance_todatetime_long); + if(duplicateMaps.containsKey(resourceId)){ + List> tmp_duplicateLists =duplicateMaps.get(resourceId); + tmp_duplicateLists.add(duplicateMap); + }else{ + duplicateLists = Lists.newArrayList(); + duplicateLists.add(duplicateMap); + duplicateMaps.put(resourceId, duplicateLists); + } + } + + public void checkDuplicateFlow(List> duplicateVals, + Map retmap, long flow_fromdatetime_long, long flow_todatetime_long, + String duplicate_message, String related_requestid, boolean isLeave, + String resourceId) { + + for(int j = 0 ; j < duplicateVals.size() ;j++){ + Map duplicateMap = duplicateVals.get(j); + long fromdatetime_long = StringUtil.parseToLong(duplicateMap.get("fromdatetime_long")); + long todatetime_long = StringUtil.parseToLong(duplicateMap.get("todatetime_long")); + if(duplicateMap.containsKey("attendance_fromdatetime_long") && duplicateMap.containsKey("attendance_todatetime_long")){ + //考勤变更流程独有的 + long attendance_fromdatetime_long = StringUtil.parseToLong(duplicateMap.get("attendance_fromdatetime_long")); + long attendance_todatetime_long = StringUtil.parseToLong(duplicateMap.get("attendance_todatetime_long")); + //这样说明重复的流程刚好是被变更的这条数据 + if(flow_fromdatetime_long == attendance_fromdatetime_long && flow_todatetime_long == attendance_todatetime_long){ + continue; + } + } + + if(todatetime_long <= flow_fromdatetime_long || fromdatetime_long >= flow_todatetime_long){ + //这样表示流程不交叉 + }else{ + if(isLeave){ + long back_fromdatetime_long = fromdatetime_long; + long back_todatetime_long = todatetime_long; + if(fromdatetime_long < flow_fromdatetime_long){ + back_fromdatetime_long = flow_fromdatetime_long; + } + if(todatetime_long > flow_todatetime_long){ + back_todatetime_long = flow_todatetime_long; + } + boolean isInLeaveBack = getLeaveBack(related_requestid,back_fromdatetime_long,back_todatetime_long,resourceId); + if(isInLeaveBack){ + continue; + } + } + + if(null == processLeaveRquestid || Util.null2String(processLeaveRquestid).length()==0){ + processLeaveRquestid = related_requestid; + } + retmap.put("status", "-1"); + String mobile_duplicate_message= duplicate_message; + String e_duplicate_message= duplicate_message; + String[] replace_str = new String[]{new KQTransMethod().getWorkFlowUrl(processLeaveRquestid),new WorkflowRequestComInfo().getRequestName(processLeaveRquestid)}; + String[] mobile_replace_str = new String[]{new KQTransMethod().getWorkFlowUrl4mobile(processLeaveRquestid),new WorkflowRequestComInfo().getRequestName(processLeaveRquestid)}; + String[] e_replace_str = new String[]{new WorkflowRequestComInfo().getRequestName(processLeaveRquestid),new WorkflowRequestComInfo().getRequestName(processLeaveRquestid)}; + mobile_duplicate_message = StringUtils.replaceEach(mobile_duplicate_message, ori_str,mobile_replace_str); + duplicate_message = StringUtils.replaceEach(duplicate_message, ori_str,replace_str); + e_duplicate_message = StringUtils.replaceEach(e_duplicate_message, ori_str,e_replace_str); + retmap.put("message", duplicate_message); + retmap.put("mobile_message", mobile_duplicate_message); + //给小e用的 + retmap.put("e_message", e_duplicate_message); + return; + } + } + } + + /** + * 出差,公出流程会受到归档后的变更流程影响 + * 请假流程会受到归档后的销假流程影响 + * @param tmp_wftype + * @param related_requestid + * @param rs + * @param resourceId + * @param user + * @param flow_fromDate + * @param flow_fromTime + * @param flow_toDate + * @param flow_toTime + */ + public Map getSpecialMap(String tmp_wftype, + String related_requestid, RecordSet rs, String resourceId, User user, + String flow_fromDate, String flow_fromTime, String flow_toDate, String flow_toTime) { + Map specialMap = Maps.newHashMap(); + + if(tmp_wftype.equalsIgnoreCase(KqSplitFlowTypeEnum.EVECTION.getFlowtype()+"")){ + specialMap = getProcessChange(related_requestid,KqSplitFlowTypeEnum.EVECTION.getTablename(),1,resourceId,related_requestid,flow_fromDate,flow_fromTime,flow_toDate,flow_toTime); + }else if(tmp_wftype.equalsIgnoreCase(KqSplitFlowTypeEnum.OUT.getFlowtype()+"")){ + specialMap = getProcessChange(related_requestid,KqSplitFlowTypeEnum.OUT.getTablename(),1,resourceId,related_requestid, + flow_fromDate, flow_fromTime, flow_toDate, flow_toTime); + }else if(tmp_wftype.equalsIgnoreCase(KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype()+"")){ + String changerequestid = rs.getString("changerequestid"); + Map params = Maps.newHashMap(); + params.put("resourceId", resourceId); + params.put("requestid", changerequestid); + params.put("isAll", "1"); + GetProcessChangeTypeCmd processChangeTypeCmd = new GetProcessChangeTypeCmd(params, user); + Map retmaps = processChangeTypeCmd.execute(null); + if(retmaps != null && !retmaps.isEmpty()){ + if(retmaps.containsKey("process_tablename")){ + String process_tablename = Util.null2String(retmaps.get("process_tablename")); + if(process_tablename != null && process_tablename.length() > 0){ + specialMap = getProcessChange(related_requestid,process_tablename,1,resourceId,related_requestid, + flow_fromDate, flow_fromTime, flow_toDate, flow_toTime); + if(!specialMap.isEmpty()){ + specialMap.put("isProcess", "1"); + } + } + } + } + }else if(tmp_wftype.equalsIgnoreCase(KqSplitFlowTypeEnum.LEAVE.getFlowtype()+"")) { + specialMap.put("isLeave", "1"); + } + return specialMap; + } +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/CheckRuleUtil4E.java b/src/com/engine/kq/cmd/attendanceEvent/CheckRuleUtil4E.java new file mode 100644 index 0000000..602e0b7 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/CheckRuleUtil4E.java @@ -0,0 +1,56 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.kq.biz.KQAttProcSetComInfo; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import java.util.AbstractMap.SimpleEntry; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import weaver.general.Util; +import weaver.hrm.User; + +/** + * 给小e单独做的重复校验的接口接口 + */ +public class CheckRuleUtil4E { + private KQLog kqLog = new KQLog(); + + public Map checkDuplicate(Map params){ + String workflowid = Util.null2String(params.get("workflowid")); + String userid = Util.null2String(params.get("userid")); + String fromdate = Util.null2String(params.get("fromdate")); + String fromtime = Util.null2String(params.get("fromtime")); + String todate = Util.null2String(params.get("todate")); + String totime = Util.null2String(params.get("totime")); + kqLog.info("checkDuplicate params:"+params); + Map retmap = Maps.newHashMap(); + User user = new User(Util.getIntValue(userid)); + if(workflowid.length() > 0 && userid.length() > 0 && fromdate.length() > 0 && fromtime.length() > 0 + && todate.length() > 0 && totime.length() > 0){ + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + String kqtype = kqAttProcSetComInfo.getkqType(workflowid); + String attid = kqAttProcSetComInfo.getAttid(workflowid); + CheckRuleUtil checkDuplicateUtil = new CheckRuleUtil(); + Set> checkRuleDataSet = Sets.newHashSet(); + if(kqtype.equalsIgnoreCase(""+KqSplitFlowTypeEnum.LEAVE.getFlowtype())){ + String checkRuleData2json = userid+"_"+fromdate+"_"+fromtime+"_"+todate+"_"+totime; + Map.Entry me = new SimpleEntry("1",checkRuleData2json); + checkRuleDataSet.add(me); + checkDuplicateUtil.checkRule(checkRuleDataSet,retmap,user, kqtype,0,0,attid); + }else if(kqtype.equalsIgnoreCase(""+KqSplitFlowTypeEnum.EVECTION.getFlowtype())){ + String checkRuleData2json = userid+"_"+fromdate+"_"+fromtime+"_"+todate+"_"+totime+"_"; + Map.Entry me = new SimpleEntry("1",checkRuleData2json); + checkRuleDataSet.add(me); + checkDuplicateUtil.checkRule(checkRuleDataSet,retmap,user, kqtype,0,0,attid); + } + } + if(retmap.isEmpty()){ + retmap.put("status", "1"); + } + + return retmap; + } +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/CheckShiftCmd.java b/src/com/engine/kq/cmd/attendanceEvent/CheckShiftCmd.java new file mode 100644 index 0000000..02655c0 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/CheckShiftCmd.java @@ -0,0 +1,116 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +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.KQGroupMemberComInfo; +import com.engine.kq.entity.KQGroupEntity; +import java.time.LocalDate; +import java.util.HashMap; +import java.util.Map; + +import com.engine.kq.log.KQLog; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +/** + * 排班校验事件 + */ +public class CheckShiftCmd extends AbstractCommonCommand> { + private KQLog kqLog = new KQLog(); + public CheckShiftCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + kqLog.info("params:::::"+JSON.toJSONString(params)); + String sql = ""; + try{ + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String data = Util.null2String(params.get("data")); + String isBindGroup = Util.null2String(params.get("isBindGroup")); + if("1".equals(isBindGroup)) { + retmap.put("status", "1"); + return retmap; + } + JSONArray dataArray = (JSONArray) JSON.parse(data); + for(int i = 0 ; i < dataArray.size() ; i++){ + JSONObject dataObject = (JSONObject)dataArray.get(i); + String resourceId = Util.null2String(dataObject.get("resourceId")); + String fromDate = Util.null2String(dataObject.get("fromDate")); + String toDate = Util.null2String(dataObject.get("toDate")); + String shift = Util.null2String(dataObject.get("shift")); + if(fromDate.length() ==0 || toDate.length() == 0){ + retmap.put("status", "2"); + retmap.put("message", SystemEnv.getHtmlLabelName(528117,user.getLanguage())); + return retmap; + } + LocalDate nowDate = LocalDate.now(); + LocalDate fromlocalDate = LocalDate.parse(fromDate); + LocalDate tolocalDate = LocalDate.parse(toDate); + if(fromlocalDate.isAfter(tolocalDate)){ + retmap.put("status", "2"); + retmap.put("message", SystemEnv.getHtmlLabelName(15273,user.getLanguage())); + return retmap; + } + KQGroupEntity kQGroupEntity = getGroupInfo(resourceId,fromDate); + if(kQGroupEntity == null){ + retmap.put("status", "2"); + retmap.put("message", resourceComInfo.getLastname(resourceId)+SystemEnv.getHtmlLabelName(390220,user.getLanguage())); + return retmap; + } + String kqtype = kQGroupEntity.getKqtype(); + if (!"2".equalsIgnoreCase(kqtype)) { + retmap.put("status", "2"); + retmap.put("message", resourceComInfo.getLastname(resourceId)+SystemEnv.getHtmlLabelName(10000804, Util.getIntValue(user.getLanguage()))); + return retmap; + }else{ + String serialids = kQGroupEntity.getSerialids(); + if(!"-1".equalsIgnoreCase(shift) && !serialids.contains(shift)){ + //如果这个人所在的考勤组里没有要排的班次,则不让排 + retmap.put("status", "2"); + retmap.put("message", resourceComInfo.getLastname(resourceId)+SystemEnv.getHtmlLabelName(390745, Util.getIntValue(user.getLanguage()))); + return retmap; + } + + } + } + + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + /** + * 根据用户得到考勤组信息 + * @param resourceId + * @param fromDate + */ + private KQGroupEntity getGroupInfo(String resourceId,String fromDate) { + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQGroupEntity kQGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(resourceId,fromDate,true); + + return kQGroupEntity; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetAttendanceCardCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetAttendanceCardCmd.java new file mode 100644 index 0000000..b289a33 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/GetAttendanceCardCmd.java @@ -0,0 +1,209 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; + +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +/** + * 获取补卡信息 + */ +public class GetAttendanceCardCmd extends AbstractCommonCommand> { + + public GetAttendanceCardCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + try{ + ResourceComInfo rci = new ResourceComInfo(); + String resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String resourceIds = Util.null2String(params.get("resourceIds")); + String allResourceId = resourceId; + if(!"".equals(resourceIds)) { + allResourceId += ","+resourceIds; + } + String[] userIdList = allResourceId.split(","); + + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate fromLocalDate = LocalDate.parse(fromDate); + LocalDate toLocalDate = LocalDate.parse(toDate); + + if(fromLocalDate.isAfter(toLocalDate)){ + retmap.put("status", "-1"); + return retmap; + } + + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + + List> cardList = new ArrayList<>(); + Map cardMap = new HashMap<>(); + + KQReportBiz kqReportBiz = new KQReportBiz(); + List uniqueList = new ArrayList<>(); + for(String userId : userIdList) { + if(uniqueList.contains(userId)) { + continue; + } + uniqueList.add(userId); + List reporsts = kqReportBiz.getKqDateInfo(userId, fromDate, toDate, false); + for (int i = 0; i < reporsts.size(); i++) { + Map kqdateMap = (Map) reporsts.get(i); + String kqdate = Util.null2String(kqdateMap.get("kqdate")); + List checkInfoList = (List) kqdateMap.get("checkInfo"); + //每一个工作时段里的考勤状态 + for (int j = 0; j < checkInfoList.size(); j++) { + Map data = (Map) checkInfoList.get(j); + String status = Util.null2String(data.get("status")); + String workbegindate = Util.null2String(data.get("workbegindate")); + String workenddate = Util.null2String(data.get("workenddate")); + String signintime = Util.null2String(data.get("signintime")); + String signouttime = Util.null2String(data.get("signouttime")); + String workbegintime = Util.null2String(data.get("workbegintime")); + String workendtime = Util.null2String(data.get("workendtime")); + String start = Util.null2String(data.get("start")); + String end = Util.null2String(data.get("end")); + + int workbegintime_index = kqTimesArrayComInfo.getArrayindexByTimes(workbegintime); + int workbegintime_index_n = workbegintime_index > KQTimesArrayComInfo.getOneDayArraySize() ? workbegintime_index - KQTimesArrayComInfo.getOneDayArraySize() : workbegintime_index; + workbegintime = kqTimesArrayComInfo.getTimesByArrayindex(workbegintime_index_n); + + int workendtime_index = kqTimesArrayComInfo.getArrayindexByTimes(workendtime); + int workendtime_index_n = workendtime_index > KQTimesArrayComInfo.getOneDayArraySize() ? workendtime_index - KQTimesArrayComInfo.getOneDayArraySize() : workendtime_index; + workendtime = kqTimesArrayComInfo.getTimesByArrayindex(workendtime_index_n); + String scheduletime = workbegintime + "-" + workendtime; + + String[] status_s = status.split(","); + if (status_s != null && status.length() > 0) { + for (int s = 0; s < status_s.length; s++) { + String tmp_status = status_s[s]; + cardMap = new HashMap<>(); + if (ButtonStatusEnum.BELATE.getStatusCode().equalsIgnoreCase(tmp_status)) { + //迟到 + cardMap = new HashMap<>(); + cardMap.put("userid", userId); + cardMap.put("lastname", rci.getLastname(userId)); + cardMap.put("signdate", workbegindate); + cardMap.put("scheduletime", scheduletime); + cardMap.put("atteStatus", SystemEnv.getHtmlLabelName(10000805, Util.getIntValue(user.getLanguage())) + signintime); + //下拉框0是签到,1是签退 + cardMap.put("signtype", "0"); + cardMap.put("signtime", workbegintime); + cardList.add(cardMap); + } + if (ButtonStatusEnum.LEAVEERALY.getStatusCode().equalsIgnoreCase(tmp_status)) { + //早退 + cardMap = new HashMap<>(); + cardMap.put("userid", userId); + cardMap.put("lastname", rci.getLastname(userId)); + cardMap.put("signdate", workenddate); + cardMap.put("scheduletime", scheduletime); + cardMap.put("atteStatus", SystemEnv.getHtmlLabelName(10000806, Util.getIntValue(user.getLanguage())) + signouttime); + //下拉框0是签到,1是签退 + cardMap.put("signtype", "1"); + cardMap.put("signtime", workendtime); + cardList.add(cardMap); + } + if (ButtonStatusEnum.ABSENT.getStatusCode().equalsIgnoreCase(tmp_status)) { + //旷工 + + if (!start.equals("1")) { + cardMap = new HashMap<>(); + cardMap.put("userid", userId); + cardMap.put("lastname", rci.getLastname(userId)); + cardMap.put("signdate", workbegindate); + cardMap.put("scheduletime", scheduletime); + String atteStatus0 = SystemEnv.getHtmlLabelName(20085, Util.getIntValue(user.getLanguage())); + if (signintime.length() > 0) { + atteStatus0 += SystemEnv.getHtmlLabelName(10000807, Util.getIntValue(user.getLanguage())) + signintime; + } + + cardMap.put("atteStatus", atteStatus0); + //下拉框0是上班,1是下班 + cardMap.put("signtype", "0"); + cardMap.put("signtime", workbegintime); + cardList.add(cardMap); + } + if (!end.equals("1")) { + cardMap = new HashMap<>(); + cardMap.put("userid", userId); + cardMap.put("lastname", rci.getLastname(userId)); + cardMap.put("signdate", workenddate); + cardMap.put("scheduletime", scheduletime); + String atteStatus1 = SystemEnv.getHtmlLabelName(20085, Util.getIntValue(user.getLanguage())); + if (signouttime.length() > 0) { + atteStatus1 += SystemEnv.getHtmlLabelName(10000808, Util.getIntValue(user.getLanguage())) + signouttime; + } + cardMap.put("atteStatus", atteStatus1); + //下拉框0是上班,1是下班 + cardMap.put("signtype", "1"); + cardMap.put("signtime", workendtime); + cardList.add(cardMap); + } + } + if (ButtonStatusEnum.NOSIGN.getStatusCode().equalsIgnoreCase(tmp_status)) { + //漏签 + cardMap = new HashMap<>(); + cardMap.put("userid", userId); + cardMap.put("lastname", rci.getLastname(userId)); + cardMap.put("signdate", workenddate); + cardMap.put("scheduletime", scheduletime); + cardMap.put("atteStatus", SystemEnv.getHtmlLabelName(20086, Util.getIntValue(user.getLanguage()))); + //下拉框0是上班,1是下班 + cardMap.put("signtype", "1"); + cardMap.put("signtime", workendtime); + cardList.add(cardMap); + } + if (ButtonStatusEnum.NOSIGN_ON.getStatusCode().equalsIgnoreCase(tmp_status)) { + //上班漏签 + cardMap = new HashMap<>(); + cardMap.put("userid", userId); + cardMap.put("lastname", rci.getLastname(userId)); + cardMap.put("signdate", workbegindate); + cardMap.put("scheduletime", scheduletime); + cardMap.put("atteStatus", SystemEnv.getHtmlLabelName(20086, Util.getIntValue(user.getLanguage()))); + //下拉框0是上班,1是下班 + cardMap.put("signtype", "0"); + cardMap.put("signtime", workbegintime); + cardList.add(cardMap); + } + } + } + } + } + } + + retmap.put("cardlist", cardList); + retmap.put("status", "1"); + + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetEvectionWorkDurationCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetEvectionWorkDurationCmd.java new file mode 100644 index 0000000..d6751a2 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/GetEvectionWorkDurationCmd.java @@ -0,0 +1,75 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.biz.KQTravelRulesBiz; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +/** + * 出差用的时长计算 + */ +public class GetEvectionWorkDurationCmd extends AbstractCommonCommand> { + + public GetEvectionWorkDurationCmd(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 resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String fromTime = Util.null2String(params.get("fromTime")); + String toTime = Util.null2String(params.get("toTime")); + String timestamp = Util.null2String(params.get("timestamp")); + + String durationrule = Util.null2String(KQTravelRulesBiz.getMinimumUnit()); + String computingMode = Util.null2String(KQTravelRulesBiz.getComputingMode()); + ResourceComInfo rci = new ResourceComInfo(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupid = kqGroupMemberComInfo.getKQGroupId(resourceId,fromDate); + if(resourceId.length() > 0 && groupid.length() == 0){ + retmap.put("status", "-1"); + retmap.put("message", rci.getLastname(resourceId)+","+fromDate+""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005329,weaver.general.ThreadVarLanguage.getLang())+""); + return retmap; + } + + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceId). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime). + durationRuleParam(durationrule).computingModeParam(computingMode). + durationTypeEnumParam(DurationTypeEnum.EVECTION).build(); + + Map durationMap = kqDurationCalculatorUtil.getWorkDuration(); + + retmap.put("duration", Util.null2String(durationMap.get("duration"))); + retmap.put("timestamp", timestamp); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetLeaveBackDurationCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetLeaveBackDurationCmd.java new file mode 100644 index 0000000..939e457 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/GetLeaveBackDurationCmd.java @@ -0,0 +1,57 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 销假时长计算 + */ +public class GetLeaveBackDurationCmd extends AbstractCommonCommand> { + + public GetLeaveBackDurationCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + try{ + String resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String fromTime = Util.null2String(params.get("fromTime")); + String toTime = Util.null2String(params.get("toTime")); + + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceId). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).build(); + + Map durationMap = kqDurationCalculatorUtil.getWorkDuration(); + + retmap.put("days", Util.null2String(durationMap.get("days"))); + retmap.put("hours", Util.null2String(durationMap.get("hours"))); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetLeaveBackInfoCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetLeaveBackInfoCmd.java new file mode 100644 index 0000000..c0023c8 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/GetLeaveBackInfoCmd.java @@ -0,0 +1,181 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.biz.KQSettingsBiz; +import com.engine.kq.enums.KqSplitFlowTypeEnum; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取销假信息 + */ +public class GetLeaveBackInfoCmd extends AbstractCommonCommand> { + + public GetLeaveBackInfoCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + try { + String resourceId = Util.null2String(params.get("resourceId")); + String requestid = Util.null2String(params.get("requestid")); + if (resourceId.length() == 0 || requestid.length() == 0) { + retmap.put("status", "2"); + retmap.put("message", SystemEnv.getHtmlLabelName(390802, user.getLanguage())); + return retmap; + } + + getRequestInfo(requestid, resourceId, retmap,true); + + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + public void getRequestInfo(String requestid, String resourceId, + Map retmap,boolean flag) { + + String leaveback_clear = "0"; + boolean is_leaveback_clear = KQSettingsBiz.is_leaveback_clear(); + if (is_leaveback_clear) { + leaveback_clear = "1"; + } + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + List backList = new ArrayList<>(); + Map backMap = new HashMap<>(); + Map splitMap = new HashMap<>(); + + RecordSet rs = new RecordSet(); + + // 如果销假中间表中有数据,说明是销假流程,并不是变更流程 + boolean isLeaveFlow = false; + String sql = "select * from kq_flow_split_leaveback where leavebackrequestid in("+requestid+")"; + rs.executeQuery(sql); + if(rs.next()) { + isLeaveFlow = true; + } + + String requestSql = "select usedetail,newleavetype,fromdatedb,fromtimedb,todatedb,totimedb,durationdb,durationrule,detailid,dataid,max(leavebackrequestid) as leavebackrequestid,max(repeat_type) as repeat_type,max(repeat_late) as repeat_late,max(repeat_early) as repeat_early " + + " from " + KqSplitFlowTypeEnum.LEAVE.getTablename() + " where 1=1 and status = 0 and requestid=? and resourceid=? " + + " group by usedetail,newleavetype,fromdatedb,fromtimedb,todatedb,totimedb,durationdb,durationrule,detailid,dataid,leavebackrequestid,repeat_type, repeat_late, repeat_early "; + rs.executeQuery(requestSql, requestid, resourceId); + while (rs.next()) { + String usedetail = rs.getString("usedetail"); + String newleavetype = rs.getString("newleavetype"); + String fromdatedb = rs.getString("fromdatedb"); + String fromtimedb = rs.getString("fromtimedb"); + String todatedb = rs.getString("todatedb"); + String totimedb = rs.getString("totimedb"); + String durationdb = rs.getString("durationdb"); + String durationrule = rs.getString("durationrule"); + String leavebackrequestid = Util.null2String(rs.getString("leavebackrequestid")); + + if(!"".equals(leavebackrequestid) && !isLeaveFlow) { + retmap.put("status", "2"); + retmap.put("message", SystemEnv.getHtmlLabelName(547781, user.getLanguage())); + return; + } + String repeat_type = rs.getString("repeat_type"); + String repeat_late = rs.getString("repeat_late"); + String repeat_early = rs.getString("repeat_early"); + + splitMap = new HashMap<>(); + splitMap.put("fromdatedb", fromdatedb); + splitMap.put("fromtimedb", fromtimedb); + splitMap.put("todatedb", todatedb); + splitMap.put("totimedb", totimedb); + splitMap.put("newleavetype", newleavetype); + splitMap.put("durationdb", durationdb); + splitMap.put("re_duration", durationdb); + splitMap.put("repeatType", repeat_type); + splitMap.put("repeat_late", repeat_late); + splitMap.put("repeat_early", repeat_early); + + Map params = new HashMap<>(); + params.put("newLeaveType", newleavetype); + params.put("resourceId", resourceId); + params.put("fromDate", fromdatedb); + params.put("toDate", todatedb); + params.put("fromTime", fromtimedb); + params.put("toTime", totimedb); + // if(!"1".equalsIgnoreCase(leaveback_clear)){ + // GetLeaveWorkDurationCmd getLeaveWorkDurationCmd = new GetLeaveWorkDurationCmd(params, user); + // Map leave_retmap = getLeaveWorkDurationCmd.execute(null); + // if(leave_retmap != null){ + // String duration = Util.null2String(leave_retmap.get("duration")); + //重新计算得到按照当前班次计算得到的时长 + // splitMap.put("re_duration",duration); + // } + // } + if (durationrule.length() > 0) { + if ("2".equalsIgnoreCase(durationrule)) { + if (splitMap.get("half_changeType") != null) { + String tmp_leave = Util.null2String(splitMap.get("half_changeType")); + tmp_leave += "," + newleavetype; + } else { + splitMap.put("half_changeType", newleavetype); + } + } + if ("4".equalsIgnoreCase(durationrule)) { + if (splitMap.get("whole_changeType") != null) { + String tmp_leave = Util.null2String(splitMap.get("whole_changeType")); + tmp_leave += "," + newleavetype; + } else { + splitMap.put("whole_changeType", newleavetype); + } + + } + } + + String key = ""; + if ("1".equalsIgnoreCase(usedetail)) { + key = "detail_" + rs.getString("detailid"); + } else { + key = "main_" + rs.getString("dataid"); + } + if (!backMap.containsKey(key)) { + backList.add(splitMap); + backMap.put(key, backList); + } + } + + if (backList.isEmpty() && flag) { + new KQReportBiz().reflow(requestid); + getRequestInfo(requestid, resourceId, retmap,false);//加个布尔判断以防死循环 + } + + + if (backList.isEmpty()) { + retmap.put("status", "2"); + retmap.put("message", SystemEnv.getHtmlLabelName(505779, user.getLanguage())); + } else { + retmap.put("backList", backList); + retmap.put("status", "1"); + } + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetLeaveWorkDurationCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetLeaveWorkDurationCmd.java new file mode 100644 index 0000000..0958ca4 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/GetLeaveWorkDurationCmd.java @@ -0,0 +1,141 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.KQRepeatBean; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQRepeatLengthContext; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +/** + * 请假用的时长计算 + */ +public class GetLeaveWorkDurationCmd extends AbstractCommonCommand> { + + public GetLeaveWorkDurationCmd(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 newLeaveType = Util.null2String(params.get("newLeaveType")); + String resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String fromTime = Util.null2String(params.get("fromTime")); + String toTime = Util.null2String(params.get("toTime")); + String requestid = Util.null2String(params.get("requestid")); + String timestamp = Util.null2String(params.get("timestamp")); + if(requestid.length() > 0){ + //销假流程里的请假时长计算才会有这个 + GetLeaveBackInfoCmd getLeaveBackInfoCmd = new GetLeaveBackInfoCmd(params,user); + Map backmap = getLeaveBackInfoCmd.execute(null); + if(MapUtils.isNotEmpty(backmap)){ + if(backmap.containsKey("backList")){ + List backList = (List) backmap.get("backList"); + if(CollectionUtils.isNotEmpty(backList)){ + Map backListMap = (Map) backList.get(0); + if(backListMap.containsKey("repeatType")){ + String repeatType = Util.null2String(backListMap.get("repeatType")); + String repeat_late = Util.null2String(backListMap.get("repeat_late")); + String repeat_early = Util.null2String(backListMap.get("repeat_early")); + params.put("repeatType",repeatType); + params.put("repeatEarly",repeat_early); + params.put("repeatLate",repeat_late); + } + } + } + } + } + + ResourceComInfo rci = new ResourceComInfo(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupid = kqGroupMemberComInfo.getKQGroupId(resourceId,fromDate); + if(resourceId.length() > 0 && groupid.length() == 0){ + retmap.put("status", "-1"); + retmap.put("message", rci.getLastname(resourceId)+","+fromDate+""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005329,weaver.general.ThreadVarLanguage.getLang())+""); + return retmap; + } + String repeatLate = Util.null2String(params.get("repeatLate")); + String repeatEarly = Util.null2String(params.get("repeatEarly")); + String repeatType = Util.null2String(params.get("repeatType")); + if("0".equals(repeatType) || "1".equals(repeatType) || "2".equals(repeatType)){ + if(fromTime.length() == 0){ + fromTime = "00:00"; + } + if(toTime.length() == 0){ + toTime = "23:59"; + } + KQRepeatBean kqRepeatBean = new KQRepeatBean(); + kqRepeatBean.setRepeatType(repeatType); + + if("0".equals(repeatType)){ + if(StringUtils.isNotEmpty(repeatLate)){ + kqRepeatBean.setRepeatLate(new Double(Double.valueOf(repeatLate)).longValue()); + } + } + if("1".equals(repeatType)){ + if(StringUtils.isNotEmpty(repeatEarly)){ + kqRepeatBean.setRepeatEarly(new Double(Double.valueOf(repeatEarly)).longValue()); + } + } + if( "2".equals(repeatType)){ + if(StringUtils.isNotEmpty(repeatLate)){ + kqRepeatBean.setRepeatLate(new Double(Double.valueOf(repeatLate)).longValue()); + } + if(StringUtils.isNotEmpty(repeatEarly)){ + kqRepeatBean.setRepeatEarly(new Double(Double.valueOf(repeatEarly)).longValue()); + } + } + KQRepeatLengthContext.setRepeatBean(kqRepeatBean); + } + + String durationrule = Util.null2String(KQLeaveRulesBiz.getMinimumUnit(newLeaveType)); + String computingMode = Util.null2String(KQLeaveRulesBiz.getComputingMode(newLeaveType)); + + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceId). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime). + newLeaveTypeParam(newLeaveType).durationRuleParam(durationrule). + computingModeParam(computingMode).durationTypeEnumParam(DurationTypeEnum.LEAVE).build(); + + Map durationMap = kqDurationCalculatorUtil.getWorkDuration(); + + retmap.put("duration", Util.null2String(durationMap.get("duration"))); + retmap.put("min_duration", Util.null2String(durationMap.get("min_duration"))); + retmap.put("timestamp", timestamp); + retmap.put("repeatType", repeatType); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + KQRepeatLengthContext.removeRepeatBean(); + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetOutWorkDurationCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetOutWorkDurationCmd.java new file mode 100644 index 0000000..367bf99 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/GetOutWorkDurationCmd.java @@ -0,0 +1,76 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQExitRulesBiz; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +/** + * 公出用的时长计算 + */ +public class GetOutWorkDurationCmd extends AbstractCommonCommand> { + + public GetOutWorkDurationCmd(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 resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String fromTime = Util.null2String(params.get("fromTime")); + String toTime = Util.null2String(params.get("toTime")); + String timestamp = Util.null2String(params.get("timestamp")); + + String durationrule = Util.null2String(KQExitRulesBiz.getMinimumUnit()); + String computingMode = Util.null2String(KQExitRulesBiz.getComputingMode()); + ResourceComInfo rci = new ResourceComInfo(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupid = kqGroupMemberComInfo.getKQGroupId(resourceId,fromDate); + if(resourceId.length() > 0 && groupid.length() == 0){ + retmap.put("status", "-1"); + retmap.put("message", rci.getLastname(resourceId)+","+fromDate+""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005329,weaver.general.ThreadVarLanguage.getLang())+""); + return retmap; + } + + + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceId). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime). + durationRuleParam(durationrule).computingModeParam(computingMode). + durationTypeEnumParam(DurationTypeEnum.OUT).build(); + + Map durationMap = kqDurationCalculatorUtil.getWorkDuration(); + + retmap.put("duration", Util.null2String(durationMap.get("duration"))); + retmap.put("timestamp", timestamp); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetOverTimeWorkDurationCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetOverTimeWorkDurationCmd.java new file mode 100644 index 0000000..516ada2 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/GetOverTimeWorkDurationCmd.java @@ -0,0 +1,91 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQWorkTime; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +/** + * 加班用的时长计算 + */ +public class GetOverTimeWorkDurationCmd extends AbstractCommonCommand> { + + public GetOverTimeWorkDurationCmd(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 resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String fromTime = Util.null2String(params.get("fromTime")); + String toTime = Util.null2String(params.get("toTime")); + String overtime_type = Util.null2String(params.get("overtime_type")); + String timestamp = Util.null2String(params.get("timestamp")); + + int minimumUnit = KQOvertimeRulesBiz.getMinimumUnit(); + // + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity kqWorkTimeEntity = kqWorkTime.getWorkTime(resourceId,fromDate); + if(kqWorkTimeEntity != null){ + String kqType = Util.null2String(kqWorkTimeEntity.getKQType()); + if("3".equalsIgnoreCase(kqType)){ + writeLog("自由班制不计算加班"); + retmap.put("status", "1"); + retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005330,weaver.general.ThreadVarLanguage.getLang())+""); + return retmap; + } + } + ResourceComInfo rci = new ResourceComInfo(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupid = kqGroupMemberComInfo.getKQGroupId(resourceId,fromDate); + if(resourceId.length() > 0 && groupid.length() == 0){ + retmap.put("status", "-1"); + retmap.put("message", rci.getLastname(resourceId)+","+fromDate+""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005329,weaver.general.ThreadVarLanguage.getLang())+""); + return retmap; + } + + + //加班默认是工作日加班 + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceId). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).computingModeParam("1"). + durationRuleParam(minimumUnit+"").durationTypeEnumParam(DurationTypeEnum.OVERTIME). + overtime_typeParam(overtime_type).build(); + + Map durationMap = kqDurationCalculatorUtil.getWorkDuration(); + + retmap.put("duration", Util.null2String(durationMap.get("duration"))); + retmap.put("timestamp", timestamp); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetProcessChangeInfoCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetProcessChangeInfoCmd.java new file mode 100644 index 0000000..5d311dd --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/GetProcessChangeInfoCmd.java @@ -0,0 +1,272 @@ +package com.engine.kq.cmd.attendanceEvent; + +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.enums.KqSplitFlowTypeEnum; +import com.engine.kq.wfset.util.SplitSelectSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取考勤变更流程信息 + */ +public class GetProcessChangeInfoCmd extends AbstractCommonCommand> { + + public GetProcessChangeInfoCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + String resourceId = Util.null2String(params.get("resourceId")); + String requestid = Util.null2String(params.get("requestid")); + String changetype = Util.null2String(params.get("changetype")); + if(resourceId.length() == 0 || requestid.length() == 0 || changetype.length() == 0){ + retmap.put("status", "2"); + retmap.put("message", SystemEnv.getHtmlLabelName(513781,user.getLanguage())); + return retmap; + } + + List backList = new ArrayList<>(); + params.put("nonHalfWhole", "1"); + GetProcessChangeTypeCmd processChangeTypeCmd = new GetProcessChangeTypeCmd(params, user); + Map retmaps = processChangeTypeCmd.execute(commandContext); + int kqtype = -1; + if(!retmaps.isEmpty()){ + if(retmaps.containsKey("process_type") && retmaps.containsKey("process_tablename")){ + int process_type = Util.getIntValue(Util.null2String(retmaps.get("process_type"))); + String process_tablename = Util.null2String(retmaps.get("process_tablename")); + getRequestInfoByTable(requestid, resourceId,changetype,process_tablename,backList); + if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == process_type){ + retmap.put("kqtype", "evection"); + do4HalfWholeInfo(retmap,KqSplitFlowTypeEnum.EVECTION); + }else if(KqSplitFlowTypeEnum.OUT.getFlowtype() == process_type){ + retmap.put("kqtype", "out"); + do4HalfWholeInfo(retmap,KqSplitFlowTypeEnum.OUT); + }else if(KqSplitFlowTypeEnum.LEAVE.getFlowtype() == process_type){ + if("0".equals(changetype)) { + String sql = "select requestid,workflowid,currentnodetype from workflow_requestbase where requestid = '" + requestid + "'"; + RecordSet rs = new RecordSet(); + rs.executeQuery(sql); + String workflowid = ""; + if (rs.next()) { + workflowid = rs.getString("workflowid"); + } + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? "; + rs.executeQuery(proc_set_sql, workflowid); + if (rs.next()) { + int flowSetType = Util.getIntValue(rs.getString("field006")); + if (flowSetType == 8) { + retmap.put("status", "2"); + retmap.put("message", SystemEnv.getHtmlLabelName(546991, user.getLanguage())); + return retmap; + } + } + } + retmap.put("kqtype", "leave"); + retmap.put("newleaveType", Util.null2String(retmaps.get("newleaveType"))); + do4HalfWholeInfo(retmap,KqSplitFlowTypeEnum.LEAVE); + } + } + } + + if(backList.isEmpty()){ + //add + String workflowid = ""; + String currentnodetype = ""; + RecordSet rs2 = new RecordSet(); + String sql = "select requestid,workflowid,currentnodetype from workflow_requestbase where requestid = '"+requestid+"'"; + rs2.executeQuery(sql); + if(rs2.next()){ + workflowid = Util.null2String(rs2.getString("workflowid")); + currentnodetype = Util.null2String(rs2.getString("currentnodetype")); + } + RecordSet rs = new RecordSet(); + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? "; + rs.executeQuery(proc_set_sql, workflowid); + if(rs.next()) { + kqtype = Util.getIntValue(rs.getString("field006")); + } + //end + new RecordSet().writeLog("kqtyp="+kqtype); + if(kqtype == KqSplitFlowTypeEnum.OVERTIME.getFlowtype()){ + retmap.put("status", "2"); + retmap.put("message", SystemEnv.getHtmlLabelName(546909,user.getLanguage())); + }else{ + retmap.put("status", "2"); + retmap.put("message", SystemEnv.getHtmlLabelName(514170,user.getLanguage())); + } + + }else{ + retmap.put("backList", backList); + retmap.put("status", "1"); + } + + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + /** + * 半天和整天信息回显 + * @param retmap + * @param splitFlowTypeEnum + */ + public void do4HalfWholeInfo(Map retmap, + KqSplitFlowTypeEnum splitFlowTypeEnum) { + boolean isHalf = false; + boolean isWhole = false; + String halfFromSel = "[]"; + String halfToSel = "[]"; + String wholeFromSel = "[]"; + String wholeToSel = "[]"; + + String forenoon_start = SplitSelectSet.forenoon_start; + String forenoon_end = SplitSelectSet.forenoon_end; + String afternoon_start = SplitSelectSet.afternoon_start; + String afternoon_end = SplitSelectSet.afternoon_end; + String daylong_start = SplitSelectSet.daylong_start; + String daylong_end = SplitSelectSet.daylong_end; + + String minimumUnit = KQTravelRulesBiz.getMinimumUnit(); + String timeselection = KQTravelRulesBiz.getTimeselection(); + String leaveRuleId = "0"; + if(splitFlowTypeEnum == KqSplitFlowTypeEnum.LEAVE) { + leaveRuleId = Util.null2String(retmap.get("newleaveType")); + minimumUnit = ""+KQLeaveRulesBiz.getMinimumUnit(leaveRuleId); + timeselection = ""+KQLeaveRulesBiz.getTimeselection(leaveRuleId); + } + + if(splitFlowTypeEnum == KqSplitFlowTypeEnum.OUT){ + minimumUnit = KQExitRulesBiz.getMinimumUnit(); + timeselection = KQExitRulesBiz.getTimeselection(); + } + if(!"2".equalsIgnoreCase(timeselection)){ + KQTimeSelectionComInfo kqTimeSelectionComInfo = new KQTimeSelectionComInfo(); + String selectiontype = splitFlowTypeEnum.getFlowtype()+""; + Map map = kqTimeSelectionComInfo.getTimeselections(selectiontype,leaveRuleId,minimumUnit); + String am = SystemEnv.getHtmlLabelName(16689, user.getLanguage()); + String pm = SystemEnv.getHtmlLabelName(16690, user.getLanguage()); + if(!map.isEmpty()){ + am = Util.null2String(map.get("half_on")); + pm = Util.null2String(map.get("half_off")); + if(am.length() == 0){ + am = SystemEnv.getHtmlLabelName(16689, user.getLanguage()); + } + if(pm.length() == 0){ + pm = SystemEnv.getHtmlLabelName(16690, user.getLanguage()); + } + } + + halfFromSel = "[{key:'"+forenoon_start+"',showname:'"+am+"'},{key:'"+forenoon_end+"',showname:'"+pm+"'}]"; + halfToSel = "[{key:'"+afternoon_start+"',showname:'"+am+"'},{key:'"+afternoon_end+"',showname:'"+pm+"'}]"; + if("2".equalsIgnoreCase(minimumUnit)){ + isHalf = true; + } + } + wholeFromSel = "[{key:'"+daylong_start+"',showname:'"+SystemEnv.getHtmlLabelName(390728, user.getLanguage())+"'}]"; + wholeToSel = "[{key:'"+daylong_end+"',showname:'"+SystemEnv.getHtmlLabelName(390728, user.getLanguage())+"'}]"; + if("4".equalsIgnoreCase(minimumUnit)){ + isWhole = true; + } + retmap.put("isHalf", isHalf?"1":"0"); + retmap.put("isWhole", isWhole?"1":"0"); + retmap.put("halfFromSel", halfFromSel); + retmap.put("halfToSel", halfToSel); + retmap.put("wholeFromSel", wholeFromSel); + retmap.put("wholeToSel", wholeToSel); + } + + public void getRequestInfoByTable(String requestid, String resourceId, String changetype,String tablename,List backList) { + Map backMap = new HashMap<>(); + Map splitMap = new HashMap<>(); + + RecordSet rs = new RecordSet(); + // String requestSql = "select * from "+ tablename+" where 1=1 and status = 0 and requestid=? and resourceid=? order by belongdate,fromdate "; + String requestSql = "select usedetail,fromdatedb,fromtimedb,todatedb,totimedb,durationdb,durationrule,detailid,dataid " + + " from "+ tablename +" where 1=1 and status = 0 and requestid=? and resourceid=? " + + " group by usedetail,fromdatedb,fromtimedb,todatedb,totimedb,durationdb,durationrule,detailid,dataid "; + rs.executeQuery(requestSql, requestid,resourceId); + while(rs.next()){ + String usedetail = rs.getString("usedetail"); + String fromdatedb = rs.getString("fromdatedb"); + String fromtimedb = rs.getString("fromtimedb"); + String todatedb = rs.getString("todatedb"); + String totimedb = rs.getString("totimedb"); + String durationdb = rs.getString("durationdb"); + String durationrule = rs.getString("durationrule"); + splitMap = new HashMap<>(); + splitMap.put("fromdatedb", fromdatedb); + splitMap.put("fromtimedb", fromtimedb); + splitMap.put("todatedb", todatedb); + splitMap.put("totimedb", totimedb); + splitMap.put("durationdb", durationdb); + splitMap.put("re_duration",durationdb); + + Map params = new HashMap<>(); + params.put("resourceId",resourceId); + params.put("fromDate",fromdatedb); + params.put("toDate",todatedb); + params.put("fromTime",fromtimedb); + params.put("toTime",totimedb); + + if(tablename.equalsIgnoreCase(KqSplitFlowTypeEnum.EVECTION.getTablename())){ + GetEvectionWorkDurationCmd getEvectionWorkDurationCmd = new GetEvectionWorkDurationCmd(params, user); + Map evection_retmap = getEvectionWorkDurationCmd.execute(null); + if(evection_retmap != null){ + String duration = Util.null2String(evection_retmap.get("duration")); + //重新计算得到按照当前班次计算得到的时长 + splitMap.put("re_duration",duration); + } + + }else if(tablename.equalsIgnoreCase(KqSplitFlowTypeEnum.OUT.getTablename())){ + GetOutWorkDurationCmd getOutWorkDurationCmd = new GetOutWorkDurationCmd(params, user); + Map out_retmap = getOutWorkDurationCmd.execute(null); + if(out_retmap != null){ + String duration = Util.null2String(out_retmap.get("duration")); + //重新计算得到按照当前班次计算得到的时长 + splitMap.put("re_duration",duration); + } + }else if(tablename.equalsIgnoreCase(KqSplitFlowTypeEnum.LEAVE.getTablename())){ + GetLeaveWorkDurationCmd getLeaveWorkDurationCmd = new GetLeaveWorkDurationCmd(params, user); + Map leave_retmap = getLeaveWorkDurationCmd.execute(null); + if(leave_retmap != null){ + String duration = Util.null2String(leave_retmap.get("duration")); + //重新计算得到按照当前班次计算得到的时长 + splitMap.put("re_duration",duration); + } + } + + String key = ""; + if("1".equalsIgnoreCase(usedetail)){ + key = "detail_"+rs.getString("detailid"); + }else{ + key = "main_"+rs.getString("dataid"); + } + if(!backMap.containsKey(key)){ + backList.add(splitMap); + backMap.put(key, backList); + } + } + + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetProcessChangeTypeCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetProcessChangeTypeCmd.java new file mode 100644 index 0000000..cc4ca09 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/GetProcessChangeTypeCmd.java @@ -0,0 +1,80 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.google.common.collect.Lists; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取考勤变更流程类型,是出差还是请假还是其他 + */ +public class GetProcessChangeTypeCmd extends AbstractCommonCommand> { + + public GetProcessChangeTypeCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + String resourceId = Util.null2String(params.get("resourceId")); + String requestid = Util.null2String(params.get("requestid")); + boolean isAll = "1".equalsIgnoreCase(Util.null2String(params.get("isAll"))); + //1表示不需要再去获取一遍半天全天的数据 + boolean nonHalfWhole = "1".equalsIgnoreCase(Util.null2String(params.get("nonHalfWhole"))); + RecordSet rs = new RecordSet(); + List tables = Lists.newArrayList(); + tables.add(KqSplitFlowTypeEnum.EVECTION); + tables.add(KqSplitFlowTypeEnum.OUT); + tables.add(KqSplitFlowTypeEnum.LEAVE); + + for(KqSplitFlowTypeEnum tablenameEnum : tables){ + if(KqSplitFlowTypeEnum.LEAVE.getFlowtype() == tablenameEnum.getFlowtype()){ + isAll = false; + } + String requestSql = "select * from "+ tablenameEnum.getTablename()+" where 1=1 "+(isAll?"":" and (status is null or status<>1)")+" and requestid=? and resourceid=? order by belongdate,fromdate "; + rs.executeQuery(requestSql,requestid,resourceId); + if(rs.next()){ + retmap.put("process_type", tablenameEnum.getFlowtype()); + retmap.put("process_tablename", tablenameEnum.getTablename()); + if(KqSplitFlowTypeEnum.LEAVE.getFlowtype() == tablenameEnum.getFlowtype()) { + retmap.put("newleaveType", rs.getString("newleavetype")); // 请假类型Id + retmap.put("durationrule", rs.getString("durationrule")); + new GetProcessChangeInfoCmd(params,user).do4HalfWholeInfo(retmap,KqSplitFlowTypeEnum.LEAVE); + } + if(!nonHalfWhole){ + if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == tablenameEnum.getFlowtype()){ + new GetProcessChangeInfoCmd(params,user).do4HalfWholeInfo(retmap,KqSplitFlowTypeEnum.EVECTION); + }else if(KqSplitFlowTypeEnum.OUT.getFlowtype() == tablenameEnum.getFlowtype()){ + new GetProcessChangeInfoCmd(params,user).do4HalfWholeInfo(retmap,KqSplitFlowTypeEnum.OUT); + } + } + break; + } + } + retmap.put("status", "1"); + + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetProcessChangeWorkDurationCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetProcessChangeWorkDurationCmd.java new file mode 100644 index 0000000..64d7223 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/GetProcessChangeWorkDurationCmd.java @@ -0,0 +1,68 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQExitRulesBiz; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +/** + * 考勤流程变更用的时长计算 + */ +public class GetProcessChangeWorkDurationCmd extends AbstractCommonCommand> { + + public GetProcessChangeWorkDurationCmd(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{ + GetProcessChangeTypeCmd processChangeTypeCmd = new GetProcessChangeTypeCmd(params, user); + params.put("isAll", "1"); + Map retmaps = processChangeTypeCmd.execute(commandContext); + if(!retmaps.isEmpty()){ + if(retmaps.containsKey("process_type") && retmaps.containsKey("process_tablename")){ + int process_type = Util.getIntValue(Util.null2String(retmaps.get("process_type"))); + if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == process_type){ + GetEvectionWorkDurationCmd getEvectionWorkDurationCmd = new GetEvectionWorkDurationCmd(params, user); + return getEvectionWorkDurationCmd.execute(commandContext); + }else if(KqSplitFlowTypeEnum.OUT.getFlowtype() == process_type){ + GetOutWorkDurationCmd getOutWorkDurationCmd = new GetOutWorkDurationCmd(params, user); + return getOutWorkDurationCmd.execute(commandContext); + }else if(KqSplitFlowTypeEnum.LEAVE.getFlowtype() == process_type) { + params.put("newLeaveType", retmaps.get("newleaveType")); + GetLeaveWorkDurationCmd getLeaveWorkDurationCmd = new GetLeaveWorkDurationCmd(params, user); + return getLeaveWorkDurationCmd.execute(commandContext); + } + } + } + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetVacationInfoCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetVacationInfoCmd.java new file mode 100644 index 0000000..70896e2 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/GetVacationInfoCmd.java @@ -0,0 +1,159 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQBalanceOfLeaveBiz; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQUnitBiz; +import com.engine.kq.wfset.util.SplitSelectSet; +import java.util.HashMap; +import java.util.Map; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +public class GetVacationInfoCmd extends AbstractCommonCommand> { + + public GetVacationInfoCmd(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 = ""; + String balanceOfLeave = ""; + try{ + //正式系统需要的 + String isFormal = Util.null2String(new BaseBean().getPropValue("kq_flow_formal", "isFormal"),"0"); + String newLeaveType = Util.null2String(params.get("newLeaveType")); + String resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String fromTime = Util.null2String(params.get("fromTime")); + String toTime = Util.null2String(params.get("toTime")); + boolean balanceEnable = KQLeaveRulesBiz.getBalanceEnable(newLeaveType); + KQLeaveRulesComInfo leaveRulesComInfo = new KQLeaveRulesComInfo(); + boolean needClear = needClear(newLeaveType,leaveRulesComInfo,fromTime,toTime); + if(balanceEnable){ + if(fromDate.length() == 0){ + fromDate = DateUtil.getCurrentDate(); + } + if("1".equalsIgnoreCase(isFormal)){ + fromDate = DateUtil.getCurrentDate(); + } + if(toDate.length() == 0){ + toDate = fromDate; + } + balanceOfLeave = KQBalanceOfLeaveBiz.getRestAmount(resourceId, newLeaveType, fromDate); + String minimumUnit = leaveRulesComInfo.getMinimumUnit(newLeaveType); + + String minimumUnitName = KQLeaveRulesBiz.getMinimumUnitName(minimumUnit,user.getLanguage()); + String approvalInfo = ""; + double d_duration = AttendanceUtil.getFreezeDuration(newLeaveType,resourceId,fromDate,toDate); + if(d_duration > 0){ + approvalInfo = "("+SystemEnv.getHtmlLabelName(19134, user.getLanguage())+d_duration+minimumUnitName+")"; + } + retmap.put("vacationInfo",SystemEnv.getHtmlLabelName(10000809,weaver.general.Util.getIntValue(user.getLanguage()))+balanceOfLeave+minimumUnitName+approvalInfo); + if(show_split_balance()){ + String vacationInfo = ""; + String allRestAmount = KQBalanceOfLeaveBiz.getRestAmount("" + resourceId, newLeaveType, fromDate, true); + String currentRestAmount = KQBalanceOfLeaveBiz.getRestAmount("" + resourceId, newLeaveType, fromDate,false); + String beforeRestAmount = String.format("%.2f", Util.getDoubleValue(allRestAmount, 0) - Util.getDoubleValue(currentRestAmount, 0)); + String before_title = KQUnitBiz.isLeaveHour(minimumUnit) ? SystemEnv.getHtmlLabelName(513286, user.getLanguage()) : SystemEnv.getHtmlLabelName(513287, user.getLanguage()); + String current_title = KQUnitBiz.isLeaveHour(minimumUnit) ? SystemEnv.getHtmlLabelName(504395, user.getLanguage()) : SystemEnv.getHtmlLabelName(504394, user.getLanguage()); + String all_title = KQUnitBiz.isLeaveHour(minimumUnit) ? SystemEnv.getHtmlLabelName(513288, user.getLanguage()) : SystemEnv.getHtmlLabelName(513289, user.getLanguage()); + vacationInfo += before_title+":"+beforeRestAmount+"
"; + vacationInfo += current_title+":"+currentRestAmount+"
"; + vacationInfo += all_title+":"+allRestAmount+approvalInfo+"
"; + retmap.put("vacationInfo",vacationInfo); + } + retmap.put("status", "1"); + }else{ + //没有休假信息的 + retmap.put("status", "2"); + } + if(needClear){ + retmap.put("needClear", "1"); + }else{ + retmap.put("needClear", "0"); + } + + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + public boolean needClear(String newLeaveType, + KQLeaveRulesComInfo leaveRulesComInfo, String fromTime, String toTime) { + boolean needClear = false; + String minimumUnit = leaveRulesComInfo.getMinimumUnit(newLeaveType); + String timeselection = leaveRulesComInfo.getTimeSelection(newLeaveType); + + if(!"2".equalsIgnoreCase(timeselection)){ + if("2".equalsIgnoreCase(minimumUnit)){ + if(fromTime.equalsIgnoreCase(SplitSelectSet.forenoon_start) || fromTime.equalsIgnoreCase(SplitSelectSet.forenoon_end)){ + //表示不清空 + }else{ + needClear = true; + } + if(!needClear){ + if(toTime.equalsIgnoreCase(SplitSelectSet.afternoon_start) || toTime.equalsIgnoreCase(SplitSelectSet.afternoon_end)){ + //表示不清空 + }else{ + needClear = true; + } + } + }else if("4".equalsIgnoreCase(minimumUnit)){ + if(fromTime.equalsIgnoreCase(SplitSelectSet.daylong_start)){ + //表示不清空 + }else{ + needClear = true; + } + if(!needClear){ + if(toTime.equalsIgnoreCase(SplitSelectSet.daylong_end)){ + //表示不清空 + }else{ + needClear = true; + } + } + } + } + return needClear; + } + + + /** + * 是否显示昨日失效的考勤按钮 + * @return + */ + public boolean show_split_balance() { + boolean show_split_balance = true; + RecordSet rs = new RecordSet(); + String settingSql = "select * from KQ_SETTINGS where main_key='show_split_balance'"; + rs.executeQuery(settingSql); + if(rs.next()){ + String main_val = rs.getString("main_val"); + if(!"1".equalsIgnoreCase(main_val)){ + show_split_balance = false; + } + } + return show_split_balance; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetWorkDurationCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetWorkDurationCmd.java new file mode 100644 index 0000000..1951623 --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/GetWorkDurationCmd.java @@ -0,0 +1,56 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 普通用的时长计算 + */ +public class GetWorkDurationCmd extends AbstractCommonCommand> { + + public GetWorkDurationCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + try{ + String resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String fromTime = Util.null2String(params.get("fromTime")); + String toTime = Util.null2String(params.get("toTime")); + + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceId). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).build(); + + Map durationMap = kqDurationCalculatorUtil.getWorkDuration(); + + retmap.put("days", Util.null2String(durationMap.get("days"))); + retmap.put("hours", Util.null2String(durationMap.get("hours"))); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/balanceofleave/BatchProcessingCmd.java b/src/com/engine/kq/cmd/balanceofleave/BatchProcessingCmd.java new file mode 100644 index 0000000..e25c6e5 --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleave/BatchProcessingCmd.java @@ -0,0 +1,152 @@ +package com.engine.kq.cmd.balanceofleave; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.*; +import com.engine.common.entity.BizLogContext; +import com.engine.common.util.LogUtil; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQBalanceOfLeaveBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQLeaveRulesDetailComInfo; +import com.engine.kq.entity.KQBalanceOfLeaveEntity; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.time.LocalDate; +import java.time.Period; +import java.util.*; + +/** + * 假期余额--批处理 + */ +public class BatchProcessingCmd extends AbstractCommonCommand> { + + public BatchProcessingCmd(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(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有新建权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + /**前端返回的查询条件:*/ + /*假期类型的ID*/ + String ruleId = Util.null2String(params.get("ruleId")); + + /*左侧点击的机构类型:0-总部、1-分部、2-部门*/ + int organizationType = Util.getIntValue((String) params.get("organizationType"), 0); + + /*左侧点击的机构的ID(例如:机构类型为分部时为分部ID)*/ + String organizationId = Util.null2String(params.get("organizationId")); + + /*搜索条件中的年份*/ + String searchYearSelect = Util.null2String(params.get("searchYearSelect"));//日期控件的选择值 + String searchYear = Util.null2String(params.get("searchYear"));//年份 + if (searchYearSelect.equals("5") || searchYearSelect.equals("8")) { + searchYear = TimeUtil.getDateByOption(searchYearSelect, "0").substring(0, 4); + } + /*搜索条件中的人员姓名*/ + String hrmResourceId = Util.null2String(params.get("hrmResourceId")); + //机构ID以及所有下级机构的ID + String organizationIds = ""; + if (organizationType == 1) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + organizationIds = subCompanyComInfo.getAllChildSubcompanyId(organizationId, organizationIds); + } else if (organizationType == 2) { + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + organizationIds = departmentComInfo.getAllChildDepartId(organizationId, organizationIds); + } + if (organizationIds.equals("")) { + organizationIds = organizationId; + } else { + organizationIds = organizationId + organizationIds.trim(); + } + if (!hrmResourceId.equals("")) { + organizationType = 3; + organizationIds = hrmResourceId; + } + + if (ruleId.equals("")) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(500956, user.getLanguage())); + return resultMap; + } + if (searchYear.equals("")) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(500957, user.getLanguage())); + return resultMap; + } + + if (organizationType != 0 && organizationIds.equals("")) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage())); + return resultMap; + } + + boolean flag = KQBalanceOfLeaveBiz.createData(ruleId, searchYear, organizationType, organizationIds, "" + user.getUID(), true); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(500961, user.getLanguage())); + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(500959, user.getLanguage())); + } + + //获取当前日期,当前时间 + Calendar today = Calendar.getInstance(); + //当前日期 + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + //当前时间 + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + //记录日志 + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setDateObject(new Date()); + bizLogContext.setDate(currentDate); + bizLogContext.setTime(currentTime); + bizLogContext.setUserid(user.getUID()); + bizLogContext.setUsertype(Util.getIntValue(user.getLogintype(),7)); + bizLogContext.setTargetId(""); + bizLogContext.setTargetName(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(15839,weaver.general.ThreadVarLanguage.getLang())+""); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_BALANCEOFLEAVE);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_BALANCEOFLEAVE);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + bizLogContext.setClientIp((String) params.get(ParamConstant.PARAM_IP)); + bizLogContext.setDeviceType(BizLogDeviceType.PC); + bizLogContext.setOperateType(BizLogOperateType.UPDATE); + bizLogContext.setOperateAuditType(BizLogOperateAuditType.INFO); + + LogUtil.writeBizLog(bizLogContext); + } catch (Exception e) { + writeLog(e); + resultMap.put("sign", "-1"); + resultMap.put("message",e.getMessage()); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleave/GetImportFormCmd.java b/src/com/engine/kq/cmd/balanceofleave/GetImportFormCmd.java new file mode 100644 index 0000000..6ae7133 --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleave/GetImportFormCmd.java @@ -0,0 +1,182 @@ +package com.engine.kq.cmd.balanceofleave; + +import com.api.browser.bean.SearchConditionItem; +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.kq.util.ImportProcessUtil; +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.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 假期余额--获取导入的表单 + */ +public class GetImportFormCmd extends AbstractCommonCommand> { + + public GetImportFormCmd(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(); + + /*假期规则的ID*/ + String ruleId = Util.null2String(params.get("ruleId")); + /*所属机构类型:0-总部、1-分部、2-部门*/ + int organizationType = Util.getIntValue((String) params.get("organizationType"), 0); + /*所属机构的ID(机构类型为分部时为分部ID)*/ + String organizationId = Util.null2String(params.get("organizationId")); + /*搜索条件中的年份*/ + String searchYearSelect = Util.null2String(params.get("searchYearSelect"));//日期控件的选择值 + String searchYear = Util.null2String(params.get("searchYear"));//年份 + if (searchYearSelect.equals("5") || searchYearSelect.equals("8")) { + searchYear = TimeUtil.getDateByOption(searchYearSelect, "0").substring(0, 4); + } + /*搜索条件中的人员姓名*/ + String hrmResourceId = Util.null2String(params.get("hrmResourceId")); + //机构ID以及所有下级机构的ID + String organizationIds = ""; + try { + if (organizationType == 1) { + organizationIds = SubCompanyComInfo.getAllChildSubcompanyId(organizationId, organizationIds); + } else if (organizationType == 2) { + organizationIds = DepartmentComInfo.getAllChildDepartId(organizationId, organizationIds); + } + if (organizationIds.equals("")) { + organizationIds = organizationId; + } else { + organizationIds = organizationId + organizationIds.trim(); + } + if (!hrmResourceId.equals("")) { + organizationType = 3; + organizationIds = hrmResourceId; + } + + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + //是否开启了人力资源模块的管理分权 + boolean isUseHrmManageDetach = manageDetachComInfo.isUseHrmManageDetach(); + //如果开启了分权 + if (isUseHrmManageDetach) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + String allRightSubComIds = subCompanyComInfo.getRightSubCompany(user.getUID(), "KQLeaveRulesEdit:Edit", 1); + if (organizationType == 0) { + organizationType = 1; + organizationIds = allRightSubComIds; + } else if (organizationType == 1) { + if (("," + allRightSubComIds + ",").contains("," + organizationId + ",")) { + organizationIds = organizationId; + } else { + organizationIds = allRightSubComIds; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + /*生成模板文件*/ + ImportProcessUtil importProcessUtil = new ImportProcessUtil(); + importProcessUtil.createTempletOfLeave(ruleId, searchYear, "" + organizationType, organizationIds,user); + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + SearchConditionItem searchConditionItem = null; + + //下载模板文件 + ConditionFactory conditionFactory = new ConditionFactory(user); + searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, 389495, "templet"); + searchConditionItem.setValue("/hrm/import/templet/KQBalanceOfLeave.xls"); + itemList.add(searchConditionItem); + + //Excel文件 + searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, 16630, "excelfile"); + itemList.add(searchConditionItem); + + groupItem.put("title", SystemEnv.getHtmlLabelName(384128, user.getLanguage()));//基本信息 + groupItem.put("defaultshow", true); + groupItem.put("items", itemList); + groupList.add(groupItem); + + Map itemMap = null; + itemList = new ArrayList(); + groupItem = new HashMap(); + + /**请先下载模板*/ + itemMap = new HashMap(); + itemMap.put("index", 0); + itemMap.put("value", SystemEnv.getHtmlLabelName(383083, user.getLanguage())); + itemMap.put("link", "/hrm/import/templet/KQBalanceOfLeave.xls"); + itemList.add(itemMap); + + /**导入模板中,列的位置不可改变,也不可增加列或者减少列*/ + itemMap = new HashMap(); + itemMap.put("index", 1); + itemMap.put("value", SystemEnv.getHtmlLabelName(389749, user.getLanguage())); + itemList.add(itemMap); + + /**导入模板中,ID列和姓名列的数据属自动生成,且一一对应,不允许更改*/ + itemMap = new HashMap(); + itemMap.put("index", 2); + itemMap.put("value", SystemEnv.getHtmlLabelName(389750, user.getLanguage())); + itemList.add(itemMap); + + /**导入模板中,余额数据不填写则视为0*/ + itemMap = new HashMap(); + itemMap.put("index", 3); + itemMap.put("value", SystemEnv.getHtmlLabelName(389751, user.getLanguage())); + itemList.add(itemMap); + + /**当假期类型为调休时,导入模板中的数据均为新增*/ + itemMap = new HashMap(); + itemMap.put("index", 4); + itemMap.put("value", SystemEnv.getHtmlLabelName(509971, user.getLanguage())); + itemList.add(itemMap); + + /**当假期类型为调休时,模板中的年份格式为yyyy,例如2019*/ + itemMap = new HashMap(); + itemMap.put("index", 5); + itemMap.put("value", SystemEnv.getHtmlLabelName(509972, user.getLanguage())); + itemList.add(itemMap); + + /**当假期类型为调休时,模板中的月份格式为MM,例如08*/ + itemMap = new HashMap(); + itemMap.put("index", 6); + itemMap.put("value", SystemEnv.getHtmlLabelName(509973, user.getLanguage())); + itemList.add(itemMap); + + /**当假期类型为调休时,模板中的加班日期和失效日期的格式均为yyyy-MM-dd,例如2019-08-01*/ + itemMap = new HashMap(); + itemMap.put("index", 7); + itemMap.put("value", SystemEnv.getHtmlLabelName(509974, user.getLanguage())); + itemList.add(itemMap); + + groupItem.put("title", SystemEnv.getHtmlLabelName(33803, user.getLanguage())); + groupItem.put("defaultshow", true); + groupItem.put("items", itemList); + groupList.add(groupItem); + + resultMap.put("condition", groupList); + resultMap.put("status", "1"); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleave/GetRightMenuCmd.java b/src/com/engine/kq/cmd/balanceofleave/GetRightMenuCmd.java new file mode 100644 index 0000000..c46c8c3 --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleave/GetRightMenuCmd.java @@ -0,0 +1,73 @@ +package com.engine.kq.cmd.balanceofleave; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 员工假期假期余额--获取右键菜单 + */ +public class GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(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(); + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + int languageId = user.getLanguage();//用户选择的语言 + RightMenu rightMenu = null; + + String ruleId = Util.null2String(params.get("ruleId"));//假期类型的ID + //判断是否是调休 + boolean isTiaoXiu = KQLeaveRulesBiz.isTiaoXiu(ruleId); + /** + * 具有【假期规则维护权限】 + */ + boolean canAdd = HrmUserVarify.checkUserRight("KQLeaveRulesAdd:Add", user);//是否具有新建权限 + if (canAdd) { + if(!isTiaoXiu){ + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Save, "save", true);//保存 + rightMenuList.add(rightMenu); + } + + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Import, "importExcel", true);//导入 + rightMenuList.add(rightMenu); + + if(!isTiaoXiu){ + rightMenu = new RightMenu(languageId, RightMenuType.BTN_BatchEditing, "batchEditing", true);//批处理 + rightMenuList.add(rightMenu); + } + + rightMenu = new RightMenu(languageId, RightMenuType.BTN_EXPORTEXCEL, "exportExcel", true);//导出Excel + rightMenuList.add(rightMenu); + + rightMenu = new RightMenu(languageId, RightMenuType.BTN_log, "log", false);//日志 + rightMenuList.add(rightMenu); + } + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleave/GetSearchConditionCmd.java b/src/com/engine/kq/cmd/balanceofleave/GetSearchConditionCmd.java new file mode 100644 index 0000000..ad7d86f --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleave/GetSearchConditionCmd.java @@ -0,0 +1,103 @@ +package com.engine.kq.cmd.balanceofleave; + +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.SelectOption; +import com.api.hrm.bean.WeaRadioGroup; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 假期余额--高级搜索条件 + */ +public class GetSearchConditionCmd extends AbstractCommonCommand> { + + public GetSearchConditionCmd(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(); + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + groupItem.put("title", SystemEnv.getHtmlLabelName(1889, user.getLanguage())); + groupItem.put("defaultshow", true); + + itemList.add(getAdvanceDate(SystemEnv.getHtmlLabelName(15933, user.getLanguage()).replace(":", ""), user,"searchYear","searchYearSelect")); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("hrmResourceId");//人员 + hrmFieldBean.setFieldlabel("413"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("17"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("conditions", groupList); + + return resultMap; + } + + /** + * @param label + * @param user + * @param domkey + * @param dateselect + * @return + */ + public WeaRadioGroup getAdvanceDate(String label, User user, String domkey, String dateselect) { + List option = new ArrayList(); + Map selectLinks = new HashMap(); + List domkeylist = new ArrayList(); + Map map = new HashMap(); + + WeaRadioGroup wrg = new WeaRadioGroup(); + wrg.setLabel(label); + + option.add(new SelectOption("5", SystemEnv.getHtmlLabelName(15384, user.getLanguage()), true)); + option.add(new SelectOption("8", SystemEnv.getHtmlLabelName(81716, user.getLanguage()))); + option.add(new SelectOption("6", SystemEnv.getHtmlLabelName(385642,weaver.general.Util.getIntValue(user.getLanguage())))); + wrg.setOptions(option); + + domkeylist.add(dateselect); + wrg.setDomkey(domkeylist); + + selectLinks.put("conditionType", "DATEPICKER"); + selectLinks.put("viewAttr", 3); + selectLinks.put("format", "YYYY"); + domkeylist = new ArrayList(); + domkeylist.add(domkey); + selectLinks.put("domkey", domkeylist); + map.put("6", selectLinks); + wrg.setSelectLinkageDatas(map); + + wrg.setLabelcol(5); + wrg.setFieldcol(19); + return wrg; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleave/GetSearchListCmd.java b/src/com/engine/kq/cmd/balanceofleave/GetSearchListCmd.java new file mode 100644 index 0000000..beb5dc7 --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleave/GetSearchListCmd.java @@ -0,0 +1,323 @@ +package com.engine.kq.cmd.balanceofleave; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQSettingsComInfo; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.PageIdConst; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.common.Tools; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * 假期余额列表 + */ +public class GetSearchListCmd extends AbstractCommonCommand> { + + 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(); + try { + + String rightLevel = HrmUserVarify.getRightLevel("KQLeaveRulesEdit:Edit", user); + int departmentID = user.getUserDepartment(); + int subcompanyID = user.getUserSubCompany1(); + + /*左侧组织结构树点击的节点类型:0-总部、1-分部、2-部门*/ + int organizationType = Util.getIntValue((String) params.get("organizationType"), 0); + /*左侧组织结构树点击的节点Id(节点类型为分部时为分部ID)*/ + String organizationId = Util.null2String(params.get("organizationId")); + /*假期类型的ID(对应的是数据库kq_LeaveRules表中的主键ID)*/ + String ruleId = Util.null2String(params.get("ruleId")); + /*搜索条件中的年份*/ + String searchYearSelect = Util.null2String(params.get("searchYearSelect"));//日期控件的选择值 + String searchYear = Util.null2String(params.get("searchYear"));//年份 + if (searchYearSelect.equals("5") || searchYearSelect.equals("8")) { + searchYear = TimeUtil.getDateByOption(searchYearSelect, "0").substring(0, 4); + } + /*搜索条件中的人员姓名*/ + String hrmResourceId = Util.null2String(params.get("hrmResourceId")); + //机构ID以及所有下级机构的ID + String organizationIds = ""; + if (organizationType == 1) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + organizationIds = subCompanyComInfo.getAllChildSubcompanyId(organizationId, organizationIds); + } else if (organizationType == 2) { + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + organizationIds = departmentComInfo.getAllChildDepartId(organizationId, organizationIds); + } + if (organizationIds.equals("")) { + organizationIds = organizationId; + } else { + organizationIds = organizationId + organizationIds.trim(); + } + if (!hrmResourceId.equals("")) { + organizationType = 3; + organizationIds = hrmResourceId; + } + + if (ruleId.equals("") || searchYear.equals("") || (organizationType != 0 && organizationIds.equals(""))) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));//参数有误 + return resultMap; + } + //当前日期 + String currentDate = DateUtil.getCurrentDate(); + + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String allow_negative = Util.null2String(kqSettingsComInfo.getMain_val("allow_negative"),"0"); + boolean allow_negative_flag = "1".equals(allow_negative); + + /**********************************************************************************************************/ + + /*获取假期类型的相关设置*/ + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + + /*假期类型名称*/ + String leaveName = Util.formatMultiLang(rulesComInfo.getLeaveName(ruleId), "" + user.getLanguage()); + + /*假期类型的最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假*/ + int minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(ruleId), 1); + + /*假期类型的单位是天还是小时*/ + String unitName = rulesComInfo.getUnitNameNew(ruleId, user.getLanguage());//单位名称,天/小时 + + /**********************************************************************************************************/ + + /*判断该假期类型是否属于 法定年假+福利年假 的类型(暂不支持一个请假类型下既存在"按入职时长+工龄自动发放"的余额发放方式,又存在其他发放方式)*/ + boolean isMixMode = KQLeaveRulesBiz.isMixMode(ruleId); + + /**********************************************************************************************************/ + + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + //是否开启了人力资源模块的管理分权 + boolean isUseHrmManageDetach = manageDetachComInfo.isUseHrmManageDetach(); + + /**********************************************************************************************************/ + + /*判断该假期类型是否属于 调休 的类型(暂不支持一个请假类型下既存在"加班时长自动计入余额"的余额发放方式,又存在其他发放方式)*/ + boolean isTiaoXiu = KQLeaveRulesBiz.isTiaoXiu(ruleId); + + RecordSet recordSet = new RecordSet(); + + /*如果属于调休,则页面展示与其他假期类型有所不同*/ + if (isTiaoXiu) { + String sql_b = ""; + String sql_c = ""; + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") + || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql_b = "select resourceId,sum(tiaoxiuamount) alltiaoxiuamountB,sum(extraAmount) allExtraAmountB,sum(baseAmount) allBaseAmountB,sum(usedAmount) allUsedAmountB from KQ_BalanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and belongYear='" + searchYear + "' and (expirationDate is null or expirationDate='' or expirationDate>='" + currentDate + "') group by resourceId,leaveRulesId,belongYear "; + sql_c = "select resourceId,sum(tiaoxiuamount) alltiaoxiuamountC,sum(extraAmount) allExtraAmountC,sum(baseAmount) allBaseAmountC,sum(usedAmount) allUsedAmountC from KQ_BalanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and belongYear='" + searchYear + "' and (expirationDate is not null and expirationDate<>'' and expirationDate<'" + currentDate + "') group by resourceId,leaveRulesId,belongYear "; + } else { + sql_b = "select resourceId,sum(tiaoxiuamount) alltiaoxiuamountB,sum(extraAmount) allExtraAmountB,sum(baseAmount) allBaseAmountB,sum(usedAmount) allUsedAmountB from KQ_BalanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and belongYear='" + searchYear + "' and (expirationDate is null or expirationDate>='" + currentDate + "') group by resourceId,leaveRulesId,belongYear "; + sql_c = "select resourceId,sum(tiaoxiuamount) alltiaoxiuamountC,sum(extraAmount) allExtraAmountC,sum(baseAmount) allBaseAmountC,sum(usedAmount) allUsedAmountC from KQ_BalanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and belongYear='" + searchYear + "' and (expirationDate is not null and expirationDate<'" + currentDate + "') group by resourceId,leaveRulesId,belongYear "; + } + String backFields = " a.id,a.dspOrder,a.lastName,a.workcode,a.subCompanyId1,a.departmentId,a.companyStartDate,a.workStartDate,a.id resourceId," + ruleId + " as leaveRulesId,0 as allTotalAmount,0 as allUsedAmount,0 as allInvalidAmount,0 as allRestAmount,0 as detailShow," + + "b.allBaseAmountB,b.alltiaoxiuamountB,b.allExtraAmountB,b.allUsedAmountB,c.alltiaoxiuamountC,c.allBaseAmountC,c.allExtraAmountC,c.allUsedAmountC "; + String sqlFrom = " from HrmResource a left join (" + sql_b + ") b on a.id=b.resourceId left join (" + sql_c + ") c on a.id=c.resourceId "; + String sqlWhere = " where 1=1 and a.status in (0,1,2,3) "; + String orderBy = " dspOrder,a.id "; + if (organizationType == 1) { + sqlWhere += " and a.subCompanyId1 in (" + organizationIds + ") "; + } else if (organizationType == 2) { + sqlWhere += " and a.departmentId in (" + organizationIds + ") "; + } else if (organizationType == 3) { + sqlWhere += " and ("+ Tools.getOracleSQLIn(organizationIds,"a.id")+")"; + } + //如果开启了分权 + if (isUseHrmManageDetach) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + String allRightSubComIds = subCompanyComInfo.getRightSubCompany(user.getUID(),"KQLeaveRulesEdit:Edit",0); + sqlWhere += " and " + Util.getSubINClause(allRightSubComIds, "a.subCompanyId1", "in"); + }else{ + if (rightLevel.equals("2")) { + // 总部级别的,什么也不返回 + } else if (rightLevel.equals("1")) { // 分部级别的 + sqlWhere += " and a.subCompanyId1=" + subcompanyID; + } else if (rightLevel.equals("0")) { // 部门级别 + sqlWhere += " and a.departmentId=" + departmentID; + } + } + String pageUid = "48d04076-d276-991b-c3b0-860559f71659"; + String tableString = "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "
"; + String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionKey, tableString); + resultMap.put("sessionkey", sessionKey); + resultMap.put("ischeck", allow_negative); + + return resultMap; + } + + // qc no.2788237 满足育儿假变更改造开发 + boolean leaveOfParental = KQLeaveRulesBiz.isLeaveOfParentalNum(ruleId); + if (leaveOfParental) { + String sql_b = ""; + String sql_c = ""; + // 需要修改一下sql + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") + || recordSet.getDBType().equalsIgnoreCase("mysql")) { + + sql_b = "select resourceId,sum(tiaoxiuamount) alltiaoxiuamountB,sum(extraAmount) allExtraAmountB,sum(baseAmount) allBaseAmountB,sum(usedAmount) allUsedAmountB from KQ_BalanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and belongYear='" + searchYear + "' and (expirationDate is null or expirationDate='' or expirationDate>='" + currentDate + "') group by resourceId,leaveRulesId,belongYear "; + sql_c = "select resourceId,sum(tiaoxiuamount) alltiaoxiuamountC,sum(extraAmount) allExtraAmountC,sum(baseAmount) allBaseAmountC,sum(usedAmount) allUsedAmountC from KQ_BalanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and belongYear='" + searchYear + "' and (expirationDate is not null and expirationDate<>'' and expirationDate<'" + currentDate + "') group by resourceId,leaveRulesId,belongYear "; + } else { + sql_b = "select resourceId,sum(tiaoxiuamount) alltiaoxiuamountB,sum(extraAmount) allExtraAmountB,sum(baseAmount) allBaseAmountB,sum(usedAmount) allUsedAmountB from KQ_BalanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and belongYear='" + searchYear + "' and (expirationDate is null or expirationDate>='" + currentDate + "') group by resourceId,leaveRulesId,belongYear "; + sql_c = "select resourceId,sum(tiaoxiuamount) alltiaoxiuamountC,sum(extraAmount) allExtraAmountC,sum(baseAmount) allBaseAmountC,sum(usedAmount) allUsedAmountC from KQ_BalanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId=" + ruleId + " and belongYear='" + searchYear + "' and (expirationDate is not null and expirationDate<'" + currentDate + "') group by resourceId,leaveRulesId,belongYear "; + } + String backFields = " a.id,a.dspOrder,a.lastName,a.subCompanyId1,a.departmentId,a.companyStartDate,a.workStartDate,a.id resourceId," + ruleId + " as leaveRulesId,0 as allTotalAmount,0 as allBaseBeanAmount,0 as allExtraAmount,0 as allUsedAmount,0 as allInvalidAmount,0 as allRestAmount,0 as detailShow," + + "b.allBaseAmountB,b.alltiaoxiuamountB,b.allExtraAmountB,b.allUsedAmountB,c.alltiaoxiuamountC,c.allBaseAmountC,c.allExtraAmountC,c.allUsedAmountC "; + String sqlFrom = " from HrmResource a left join (" + sql_b + ") b on a.id=b.resourceId left join (" + sql_c + ") c on a.id=c.resourceId "; + String sqlWhere = " where 1=1 and a.status in (0,1,2,3) "; + String orderBy = " dspOrder,a.id "; + if (organizationType == 1) { + sqlWhere += " and a.subCompanyId1 in (" + organizationIds + ") "; + } else if (organizationType == 2) { + sqlWhere += " and a.departmentId in (" + organizationIds + ") "; + } else if (organizationType == 3) { + sqlWhere += " and ("+ Tools.getOracleSQLIn(organizationIds,"a.id")+")"; + } + //如果开启了分权 + if (isUseHrmManageDetach) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + String allRightSubComIds = subCompanyComInfo.getRightSubCompany(user.getUID(),"KQLeaveRulesEdit:Edit",0); + sqlWhere += " and " + Util.getSubINClause(allRightSubComIds, "a.subCompanyId1", "in"); + } + String pageUid = "48d04076-d276-991b-c3b0-860559f71659"; + String tableString = "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "
"; + String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionKey, tableString); + resultMap.put("sessionkey", sessionKey); + resultMap.put("ischeck", allow_negative); + return resultMap; + } + + /**********************************************************************************************************/ + + String backFields = " a.id,a.dspOrder,a.lastName,a.workcode,a.subcompanyId1,a.departmentId,a.companyStartDate,a.workStartDate,a.id resourceId," + ruleId + " as leaveRulesId,b.baseAmount,b.usedAmount,b.extraAmount,b.status," + + "b.baseAmount2,b.usedAmount2,b.extraAmount2,b.belongYear,b.id canUseAmount2,b.id canUseAmount,b.id restAmount,b.id restAmount2 "; + String sqlFrom = " from HrmResource a left join kq_balanceOfLeave b on a.id=b.resourceId and leaveRulesId=" + ruleId + " and belongYear='" + searchYear + "' "; + String sqlWhere = " where 1=1 and a.status in (0,1,2,3) and (isDelete is null or isDelete<>1) "; + String orderBy = " dspOrder,a.id "; + if (organizationType == 1) { + sqlWhere += " and a.subcompanyId1 in (" + organizationIds + ")"; + } else if (organizationType == 2) { + sqlWhere += " and a.departmentId in (" + organizationIds + ")"; + } else if (organizationType == 3) { + sqlWhere += " and ("+ Tools.getOracleSQLIn(organizationIds,"a.id")+")"; + } + //如果开启了分权 + if (isUseHrmManageDetach) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + String allRightSubComIds = subCompanyComInfo.getRightSubCompany(user.getUID(),"KQLeaveRulesEdit:Edit",0); + sqlWhere += " and " + Util.getSubINClause(allRightSubComIds, "a.subCompanyId1", "in"); + }else{ + if (rightLevel.equals("2")) { + // 总部级别的,什么也不返回 + } else if (rightLevel.equals("1")) { // 分部级别的 + sqlWhere += " and a.subCompanyId1=" + subcompanyID; + } else if (rightLevel.equals("0")) { // 部门级别 + sqlWhere += " and a.departmentId=" + departmentID; + } + } + String pageUid = "7907a963-04f3-62fc-7263-9486830dc6ad"; + String tableString = "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " "; + if (!isMixMode) { + tableString += "" + + " " + + " " + + " " + + " " + + " " + + " "; + } else { + tableString += "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " "; + } + tableString += "" + + " " + + "
"; + String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionKey, tableString); + resultMap.put("sessionkey", sessionKey); + resultMap.put("ischeck", allow_negative); + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleave/GetTabCmd.java b/src/com/engine/kq/cmd/balanceofleave/GetTabCmd.java new file mode 100644 index 0000000..72adf9e --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleave/GetTabCmd.java @@ -0,0 +1,66 @@ +package com.engine.kq.cmd.balanceofleave; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; + +import java.util.*; + +/** + * 假期余额--获取页签 + */ +public class GetTabCmd extends AbstractCommonCommand> { + + public GetTabCmd(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(); + Map valueMap = new LinkedHashMap();//假期规则集合 + Map tabMap = new HashMap(); + List> tabList = new ArrayList>(); + + + /** + * 加载TAB页签: + * 只加载已启用并且已经开启了假期余额的假期规则 + */ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + kqLeaveRulesComInfo.setTofirstRow(); + while (kqLeaveRulesComInfo.next()) { + if (!kqLeaveRulesComInfo.getBalanceEnable().equals("1") || kqLeaveRulesComInfo.getIsEnable().equals("0")) { + continue; + } + valueMap.put(Util.formatMultiLang(kqLeaveRulesComInfo.getLeaveName(), "" + user.getLanguage()), kqLeaveRulesComInfo.getId()); + } + + /** + * 拼装前端TAB页签需要的数据 + */ + int index = 0; + for (Map.Entry entry : valueMap.entrySet()) { + tabMap = new HashMap(); + tabMap.put("key", index); + tabMap.put("id", entry.getValue().toString()); + tabMap.put("title", entry.getKey()); + tabList.add(tabMap); + index++; + } + resultMap.put("tab", tabList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleave/SaveBalanceOfLeaveCmd.java b/src/com/engine/kq/cmd/balanceofleave/SaveBalanceOfLeaveCmd.java new file mode 100644 index 0000000..16c5b14 --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleave/SaveBalanceOfLeaveCmd.java @@ -0,0 +1,293 @@ +package com.engine.kq.cmd.balanceofleave; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQLeaveRulesDetailComInfo; +import com.engine.kq.biz.KQUsageHistoryBiz; +import com.engine.kq.entity.KQUsageHistoryEntity; +import com.engine.kq.jucailin.util.KQDateUtil; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +/** + * 假期余额--保存 + */ +public class SaveBalanceOfLeaveCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public SaveBalanceOfLeaveCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有新建权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + //假期类型的ID + String leaveRulesId = Util.null2String(params.get("ruleId")); + //搜索条件中的年份 + String searchYearSelect = Util.null2String(params.get("searchYearSelect"));//日期控件的选择值 + String searchYear = Util.null2String(params.get("searchYear"));//年份 + if (searchYearSelect.equals("5") || searchYearSelect.equals("8")) { + searchYear = TimeUtil.getDateByOption(searchYearSelect, "0").substring(0, 4); + } + //人员和余额数据(JSON字符串) + String datas = Util.null2String(params.get("datas")); + //获取当前日期,当前时间 + Calendar today = Calendar.getInstance(); + //当前日期 + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + //当前时间 + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + //人力资源缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + //获取假期类型的缓存类 + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + //请假最小单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假 + String minimumUnit = kqLeaveRulesComInfo.getMinimumUnit(leaveRulesId); + //获取假期规则的缓存类 + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + + /**********************************************************************************************************/ + + String insertOrUpdate = ""; + KQUsageHistoryEntity usageHistoryEntity = new KQUsageHistoryEntity();//员工假期余额变更记录实体类 + List usageHistoryEntityList = new ArrayList();//员工假期余额变更记录集合 + + String oldBaseAmount = "0"; + String oldUsedAmount = "0"; + String oldExtraAmount = "0"; + String oldBaseAmount2 = "0"; + String oldUsedAmount2 = "0"; + String oldExtraAmount2 = "0"; + + String newBaseAmount = "0"; + String newUsedAmount = "0"; + String newExtraAmount = "0"; + String newBaseAmount2 = "0"; + String newUsedAmount2 = "0"; + String newExtraAmount2 = "0"; + + //哪些人已经在数据库中有记录了 + RecordSet recordSet = new RecordSet(); + RecordSet tmpSet = new RecordSet(); + String searchSql = "select * from kq_BalanceOfLeave where leaveRulesId=? and resourceId=? and belongYear=? order by id"; + + //修改了哪些人的假期余额 + List resourceIdList = new ArrayList(); + JSONArray dataArr = JSONArray.parseArray(datas); + for (int i = 0; i < dataArr.size(); i++) { + JSONObject jsonObject = dataArr.getJSONObject(i); + String resourceId = jsonObject.getString("randomFieldId"); + if (resourceId.equals("")) { + continue; + } + if (!resourceIdList.contains(resourceId)) { + resourceIdList.add(resourceId); + } + } + //记录右键操作日志 + if (resourceIdList.size() > 0) { + String resourceIdStr = String.join(",", resourceIdList); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_BALANCEOFLEAVE);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_BALANCEOFLEAVE);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_balanceOfleave where resourceId in (" + resourceIdStr + ") and leaveRulesId=" + leaveRulesId; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4Balance"); + logger.setMethodOtherParams("column:resourceId+column:leaveRulesId"); + logger.before(bizLogContext); + } + + java.sql.Timestamp date = KQDateUtil.getUpdateTimeStamp(); + boolean flag = true;//记录SQL操作是否成功 + String updateSql = "update kq_BalanceOfLeave set baseAmount=?,extraAmount=?,usedAmount=?,baseAmount2=?,extraAmount2=?,usedAmount2=?,update_time=? where leaveRulesId=? and resourceId=? and belongYear=?"; + String insertSql = "insert into kq_BalanceOfLeave(baseAmount,extraAmount,usedAmount,baseAmount2,extraAmount2,usedAmount2,leaveRulesId,resourceId,belongYear,create_time,update_time,creator) values(?,?,?,?,?,?,?,?,?,?,?,?) "; + String delSql = "delete from kq_BalanceOfLeave where leaveRulesId=? and resourceId=? and belongYear=? and id !=? "; +// List existdata = new ArrayList(); + if (recordSet.getDBType().equals("postgresql")) { + updateSql = "update kq_BalanceOfLeave set baseAmount=?,extraAmount=?,usedAmount=?,baseAmount2=?,extraAmount2=?,usedAmount2=?,update_time=?::timestamp where leaveRulesId=? and resourceId=? and belongYear=?"; + insertSql = "insert into kq_BalanceOfLeave(baseAmount,extraAmount,usedAmount,baseAmount2,extraAmount2,usedAmount2,leaveRulesId,resourceId,belongYear,create_time,update_time,creator) values(?,?,?,?,?,?,?,?,?,?::timestamp,?::timestamp,?) "; + } + Map existmap = new HashMap(); + JSONArray jsonArray = JSONArray.parseArray(datas); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + String resourceId = jsonObject.getString("randomFieldId"); + String baseAmount = "" + Util.getDoubleValue(jsonObject.getString("baseAmountspan"), 0); + String extraAmount = "" + Util.getDoubleValue(jsonObject.getString("extraAmountspan"), 0); + String usedAmount = "" + Util.getDoubleValue(jsonObject.getString("usedAmountspan"), 0); + String baseAmount2 = "" + Util.getDoubleValue(jsonObject.getString("baseAmount2span"), 0); + String extraAmount2 = "" + Util.getDoubleValue(jsonObject.getString("extraAmount2span"), 0); + String usedAmount2 = "" + Util.getDoubleValue(jsonObject.getString("usedAmount2span"), 0); + //获取人员相关信息 + if (resourceId.equals("")) { + continue; + } + String lastName = resourceComInfo.getLastname(resourceId); + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + /*目前没有为该人员所在分部或者总部设置任何假期规则,不允许保存*/ + if (Util.getIntValue(detailComInfo.getId(leaveRulesId, subcompanyId,departmentId, resourceId), 0) <= 0) { + resultMap.put("sign", "-1"); + resultMap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10004211,weaver.general.ThreadVarLanguage.getLang())+"" + lastName + ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005331,weaver.general.ThreadVarLanguage.getLang())+"");//保存失败 + return resultMap; + } + + //最近有遇到一些假期余额人员重复的问题,单独优化下,重复垃圾数据,保留id小的 + //加下面的逻辑是因为当有重复的垃圾数据时,前端传过来的数据也是重复,即使遍历的第一次有删除多余的垃圾,后面的重复数据会覆盖掉前面的id小的数据 + String key = resourceId+"#"+leaveRulesId+"#"+searchYear; + if(existmap!=null && existmap.containsKey(key)){ + continue; + }else{ + existmap.put(key,key); + } + + //在数据库里是否已经存在记录了 + recordSet.executeQuery(searchSql, leaveRulesId, resourceId, searchYear); + int datacount = recordSet.getCounts(); + if (recordSet.next()) { + String tmpid = Util.null2String(recordSet.getString("id")); + if(datacount>1){//最近有遇到一些假期余额人员重复的问题,单独优化下 + tmpSet.executeUpdate(delSql, leaveRulesId, resourceId, searchYear,tmpid); + } + oldBaseAmount = "" + Util.getDoubleValue(recordSet.getString("baseAmount"), 0); + oldExtraAmount = "" + Util.getDoubleValue(recordSet.getString("extraAmount"), 0); + oldUsedAmount = "" + Util.getDoubleValue(recordSet.getString("usedAmount"), 0); + oldBaseAmount2 = "" + Util.getDoubleValue(recordSet.getString("baseAmount2"), 0); + oldExtraAmount2 = "" + Util.getDoubleValue(recordSet.getString("extraAmount2"), 0); + oldUsedAmount2 = "" + Util.getDoubleValue(recordSet.getString("usedAmount2"), 0); + + newBaseAmount = baseAmount == null ? oldBaseAmount : baseAmount; + newExtraAmount = extraAmount == null ? oldExtraAmount : extraAmount; + newUsedAmount = usedAmount == null ? oldUsedAmount : usedAmount; + newBaseAmount2 = baseAmount2 == null ? oldBaseAmount2 : baseAmount2; + newExtraAmount2 = extraAmount2 == null ? oldExtraAmount2 : extraAmount2; + newUsedAmount2 = usedAmount2 == null ? oldUsedAmount2 : usedAmount2; + + if (oldBaseAmount.equals(newBaseAmount) && oldExtraAmount.equals(newExtraAmount) && oldUsedAmount.equals(newUsedAmount) + && oldBaseAmount2.equals(newBaseAmount2) && oldExtraAmount2.equals(newExtraAmount2) && oldUsedAmount2.equals(newUsedAmount2)) { + continue; + } + + /*更新员工假期余额 start*/ + flag = recordSet.executeUpdate(updateSql, newBaseAmount, newExtraAmount, newUsedAmount, newBaseAmount2, newExtraAmount2, newUsedAmount2,date, leaveRulesId, resourceId, searchYear); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + /*更新员工假期余额 end*/ + } else { + oldBaseAmount = "0"; + oldExtraAmount = "0"; + oldUsedAmount = "0"; + oldBaseAmount2 = "0"; + oldExtraAmount2 = "0"; + oldUsedAmount2 = "0"; + + newBaseAmount = baseAmount == null ? "0" : baseAmount; + newExtraAmount = extraAmount == null ? "0" : extraAmount; + newUsedAmount = usedAmount == null ? "0" : usedAmount; + newBaseAmount2 = baseAmount2 == null ? "0" : baseAmount2; + newExtraAmount2 = extraAmount2 == null ? "0" : extraAmount2; + newUsedAmount2 = usedAmount2 == null ? "0" : usedAmount2; + + /*新增员工假期余额 start*/ + flag = recordSet.executeUpdate(insertSql, newBaseAmount, newExtraAmount, newUsedAmount, newBaseAmount2, newExtraAmount2, newUsedAmount2, leaveRulesId, resourceId, searchYear,date,date,Util.getIntValue(resourceId)); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + /*新增员工假期余额 end*/ + } + + /*员工假期余额变更记录 start*/ + usageHistoryEntity = new KQUsageHistoryEntity(); + usageHistoryEntity.setLeaveRulesId(leaveRulesId); + usageHistoryEntity.setRelatedId(resourceId); + usageHistoryEntity.setOperator("" + user.getUID()); + usageHistoryEntity.setOperateDate(currentDate); + usageHistoryEntity.setOperateTime(currentTime); + usageHistoryEntity.setOperateType("5"); + usageHistoryEntity.setBelongYear(searchYear); + usageHistoryEntity.setOldBaseAmount(oldBaseAmount); + usageHistoryEntity.setNewBaseAmount(newBaseAmount); + usageHistoryEntity.setOldExtraAmount(oldExtraAmount); + usageHistoryEntity.setNewExtraAmount(newExtraAmount); + usageHistoryEntity.setOldUsedAmount(oldUsedAmount); + usageHistoryEntity.setNewUsedAmount(newUsedAmount); + usageHistoryEntity.setOldBaseAmount2(oldBaseAmount2); + usageHistoryEntity.setNewBaseAmount2(newBaseAmount2); + usageHistoryEntity.setOldExtraAmount2(oldExtraAmount2); + usageHistoryEntity.setNewExtraAmount2(newExtraAmount2); + usageHistoryEntity.setOldUsedAmount2(oldUsedAmount2); + usageHistoryEntity.setNewUsedAmount2(newUsedAmount2); + usageHistoryEntity.setOldMinimumUnit(minimumUnit); + usageHistoryEntity.setNewMinimumUnit(minimumUnit); + usageHistoryEntity.setInsertOrUpdate(insertOrUpdate); + + usageHistoryEntityList.add(usageHistoryEntity); + } + + //记录使用记录 + if (usageHistoryEntityList.size() > 0) { + KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz(); + flag = usageHistoryBiz.save(usageHistoryEntityList); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/balanceofleave/SaveImportCmd.java b/src/com/engine/kq/cmd/balanceofleave/SaveImportCmd.java new file mode 100644 index 0000000..043f25f --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleave/SaveImportCmd.java @@ -0,0 +1,69 @@ +package com.engine.kq.cmd.balanceofleave; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.util.ImportProcessUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 假期余额--保存Excel导入 + */ +public class SaveImportCmd extends AbstractCommonCommand> { + + private HttpServletRequest request; + + public SaveImportCmd(Map params, User user, HttpServletRequest request) { + this.user = user; + this.params = params; + this.request = request; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有新建权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + List errorInfoList = new ArrayList(); + ImportProcessUtil importProcessUtil = new ImportProcessUtil(); + List errorInfo = importProcessUtil.importXls(params, user, request); + if (errorInfo != null && !errorInfo.isEmpty()) { + Map error = null; + for (int i = 0; i < errorInfo.size(); i++) { + error = new HashMap(); + error.put("message", Util.null2String(errorInfo.get(i))); + errorInfoList.add(error); + } + } + resultMap.put("errorInfo", errorInfoList); + resultMap.put("status", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(24645, user.getLanguage())); + } catch (Exception e) { + writeLog(e); + writeLog("导入员工假期余额数据失败:" + e.getMessage()); + resultMap.put("status", "-1"); + resultMap.put("message", e.getMessage()); + } + resultMap.put("pId", request.getSession(true).getAttribute("KQBalanceOfLeavePId")); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleavedetail/DeleteBalanceCmd.java b/src/com/engine/kq/cmd/balanceofleavedetail/DeleteBalanceCmd.java new file mode 100644 index 0000000..85ba4d2 --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleavedetail/DeleteBalanceCmd.java @@ -0,0 +1,162 @@ +package com.engine.kq.cmd.balanceofleavedetail; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQUsageHistoryBiz; +import com.engine.kq.entity.KQUsageHistoryEntity; +import com.engine.kq.jucailin.util.KQDateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +/** + * 删除 + */ +public class DeleteBalanceCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public DeleteBalanceCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String ids = Util.null2String(params.get("ids")); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_BALANCEOFLEAVE);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_BALANCEOFLEAVE);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from KQ_BalanceOfLeave where (isDelete is null or isDelete<>1) and id in (" + ids + ")"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4BalanceDetail", "column:resourceId+column:belongYear+column:belongMonth+column:childId+" + user.getLanguage()); + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有新建权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + //获取当前日期,当前时间 + Calendar today = Calendar.getInstance(); + //当前日期 + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + //当前时间 + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + double restAmount = 0; + String resourceId = ""; + String leaveRulesId = ""; + String belongYear = ""; + String ids = Util.null2String(params.get("ids")); + String searchSql = "select * from KQ_BalanceOfLeave where id in (" + ids + ")"; + + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + KQUsageHistoryBiz kqUsageHistoryBiz = new KQUsageHistoryBiz(); + KQUsageHistoryEntity entity = new KQUsageHistoryEntity(); + List entities = new ArrayList(); + + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(searchSql); + while (recordSet.next()) { + String expirationDate = recordSet.getString("expirationDate"); + String id = recordSet.getString("id"); + if (expirationDate != null && !"".equals(expirationDate) && expirationDate.compareTo(currentDate) < 0) { + continue; + } + + resourceId = recordSet.getString("resourceId"); + leaveRulesId = recordSet.getString("leaveRulesId"); + belongYear = recordSet.getString("belongYear"); + boolean leaveOfParental = KQLeaveRulesBiz.isLeaveOfParentalNum(leaveRulesId); + double oldBaseAmount = Util.getDoubleValue(recordSet.getString("baseAmount"), 0); + double oldExtraAmount = Util.getDoubleValue(recordSet.getString("extraAmount"), 0); + double oldUsedAmount = Util.getDoubleValue(recordSet.getString("usedAmount"), 0); + restAmount += oldBaseAmount + oldExtraAmount - oldUsedAmount; + + String miniumUnit = rulesComInfo.getMinimumUnit(leaveRulesId); + + entity = new KQUsageHistoryEntity(); + entity.setRelatedId(resourceId); + entity.setLeaveRulesId(leaveRulesId); + entity.setBelongYear(leaveRulesId); + entity.setBelongYear(belongYear); + entity.setOperator("" + user.getUID()); + entity.setOperateDate(currentDate); + entity.setOperateTime(currentTime); + entity.setOperateType("5"); + entity.setOldMinimumUnit(miniumUnit); + entity.setNewMinimumUnit(miniumUnit); + if(leaveOfParental){ + entity.setOldBaseAmount(String.format("%.2f", oldBaseAmount)); + entity.setOldExtraAmount(String.format("%.2f", oldExtraAmount)); + entity.setOldUsedAmount(String.format("%.2f", oldUsedAmount)); + entity.setNewBaseAmount("0"); + entity.setNewExtraAmount("0"); + entity.setNewUsedAmount("0"); + }else{ + entity.setOldExtraAmount(String.format("%.2f", restAmount)); + entity.setNewExtraAmount("0"); + } + + entity.setInsertOrUpdate("update"); + entity.setBalanceOfLeaveId(id); + entities.add(entity); + } + + + + String sql = "update kq_balanceofleave set isDelete=1,update_time=? where id in (" + ids + ")"; + if (recordSet.getDBType().equals("postgresql")) { + sql = "update kq_balanceofleave set isDelete=1,update_time=?::timestamp where id in (" + ids + ")"; + } + boolean flag = recordSet.executeUpdate(sql,KQDateUtil.getUpdateTimeStamp()); + if (flag) { + kqUsageHistoryBiz.save(entities); + + resultMap.put("status", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(20461, user.getLanguage())); + } else { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(20462, user.getLanguage())); + } + } catch (Exception e) { + writeLog(e); + resultMap.put("status", "-1"); + resultMap.put("message", e.getMessage()); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleavedetail/EditBalanceCmd.java b/src/com/engine/kq/cmd/balanceofleavedetail/EditBalanceCmd.java new file mode 100644 index 0000000..8a4041c --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleavedetail/EditBalanceCmd.java @@ -0,0 +1,207 @@ +package com.engine.kq.cmd.balanceofleavedetail; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQUsageHistoryBiz; +import com.engine.kq.entity.KQUsageHistoryEntity; +import com.engine.kq.jucailin.util.KQDateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; + +/** + * 修改 + */ +public class EditBalanceCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public EditBalanceCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String id = Util.null2String(params.get("id")); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_BALANCEOFLEAVE);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_BALANCEOFLEAVE);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from KQ_BalanceOfLeave where (isDelete is null or isDelete<>1) and id =" + id; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4BalanceDetail", "column:resourceId+column:belongYear+column:belongMonth+column:childId+" + user.getLanguage()); + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + //获取当前日期,当前时间 + Calendar today = Calendar.getInstance(); + //当前日期 + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + //当前时间 + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + + String id = Util.null2String(params.get("id")); + String overtimeType = Util.null2String(params.get("overtimeType")); + String totalAmount = Util.null2String(params.get("totalAmount"));//总数 + String baseAmount = Util.null2String(params.get("baseAmount")); + String extraAmount = Util.null2String(params.get("extraAmount")); + double _baseAmount = Util.getDoubleValue(baseAmount, 0.00); + double _extraAmount = Util.getDoubleValue(extraAmount, 0.00); + String usedAmount = Util.null2String(params.get("usedAmount")); + String tiaoxiuAmount = Util.null2String(params.get("tiaoxiuamount")); + String effectiveDate = Util.null2String(params.get("effectiveDate")); + String expirationDate = Util.null2String(params.get("expirationDate")); + + double _totalAmount = Util.getDoubleValue(totalAmount, 0.00); + double _usedAmount = Util.getDoubleValue(usedAmount, 0.00); + double _tiaoxiuAmount = Util.getDoubleValue(tiaoxiuAmount, 0.00); + BigDecimal _tiaoxiuamount = new BigDecimal(Util.getDoubleValue(tiaoxiuAmount, 0.00)).setScale(2,RoundingMode.HALF_UP); + + String oldBaseAmount = ""; + String oldExtraAmount = ""; + String oldUsedAmount = ""; + + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + + + + List entities = new ArrayList(); + KQUsageHistoryEntity entity = new KQUsageHistoryEntity(); + entity.setInsertOrUpdate("update"); + entity.setWfRequestId("0"); + entity.setNewUsedAmount(usedAmount); + String ruleId = ""; + String searchSql = "select * from KQ_BalanceOfLeave where id=? "; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(searchSql, id); + if (recordSet.next()) { + String resourceId = recordSet.getString("resourceId"); + String leaveRulesId = recordSet.getString("leaveRulesId"); + ruleId = leaveRulesId; + boolean leaveOfParental = KQLeaveRulesBiz.isLeaveOfParentalNum(ruleId); + String miniumUnit = rulesComInfo.getMinimumUnit(leaveRulesId); + String belongYear = recordSet.getString("belongYear"); + oldBaseAmount = Util.null2s(recordSet.getString("baseAmount"), "0.00"); + oldExtraAmount = Util.null2s(recordSet.getString("extraAmount"), "0.00"); + oldUsedAmount = Util.null2s(recordSet.getString("usedAmount"),"0.00"); + if (leaveOfParental){ + entity.setOldBaseAmount(oldBaseAmount); + entity.setNewBaseAmount(baseAmount); + entity.setNewExtraAmount(extraAmount); + entity.setNewUsedAmount(usedAmount); + }else{ + entity.setNewExtraAmount(totalAmount); + } + entity.setRelatedId(resourceId); + entity.setLeaveRulesId(leaveRulesId); + entity.setOperator("" + user.getUID()); + entity.setOperateDate(currentDate); + entity.setOperateTime(currentTime); + entity.setOperateType("5"); + entity.setOldMinimumUnit(miniumUnit); + entity.setNewMinimumUnit(miniumUnit); + entity.setBelongYear(belongYear); + entity.setOldExtraAmount(oldExtraAmount); + entity.setOldUsedAmount(oldUsedAmount); + entity.setBalanceOfLeaveId(id); + } + entities.add(entity); + + + boolean leaveOfParental = KQLeaveRulesBiz.isLeaveOfParentalNum(ruleId); + if (!leaveOfParental){ + /*已休不能大于总数*/ + if ((_totalAmount+_tiaoxiuAmount) < _usedAmount) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(529202, user.getLanguage())); + return resultMap; + } + /*失效日期不能小于加班日期*/ + if (!"".equals(expirationDate)&& !"".equals(effectiveDate) && expirationDate.compareTo(effectiveDate) < 0) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(508125, user.getLanguage())); + return resultMap; + } + }else { + /*已休不能大于总数*/ + if ((_baseAmount+_extraAmount) < _usedAmount) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546795, user.getLanguage())); + return resultMap; + } + /*失效日期不能小于发放日期*/ + if (!"".equals(expirationDate)&& !"".equals(effectiveDate) && expirationDate.compareTo(effectiveDate) < 0) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546794, user.getLanguage())); + return resultMap; + } + } + + boolean flag =false; + if (leaveOfParental){ + String sql = "update KQ_BalanceOfLeave set baseAmount=?,extraAmount=?,usedAmount=?,effectiveDate=?,expirationDate=?,tiaoxiuamount=0,update_time=? where id=?"; + if (recordSet.getDBType().equals("postgresql")) { + sql = "update KQ_BalanceOfLeave set baseAmount=?,extraAmount=?,usedAmount=?,effectiveDate=?,expirationDate=?,tiaoxiuamount=0,update_time=?::timestamp where id=?"; + } + flag = recordSet.executeUpdate(sql, baseAmount, extraAmount, usedAmount, effectiveDate, expirationDate,KQDateUtil.getUpdateTimeStamp(), id); + if (oldBaseAmount.compareTo(baseAmount) != 0 ||oldExtraAmount.compareTo(extraAmount) != 0|| oldUsedAmount.compareTo(usedAmount) != 0) { + KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz(); + usageHistoryBiz.save(entities); + } + }else { + String sql = "update KQ_BalanceOfLeave set baseAmount=0,extraAmount=?,usedAmount=?,effectiveDate=?,expirationDate=?,tiaoxiuamount=?,update_time=? where id=?"; + if (recordSet.getDBType().equals("postgresql")) { + sql = "update KQ_BalanceOfLeave set baseAmount=0,extraAmount=?,usedAmount=?,effectiveDate=?,expirationDate=?,tiaoxiuamount=?,update_time=?::timestamp where id=?"; + } + flag = recordSet.executeUpdate(sql, totalAmount, usedAmount, effectiveDate, expirationDate,_tiaoxiuamount.toPlainString(),KQDateUtil.getUpdateTimeStamp(), id); + if (oldExtraAmount.compareTo(totalAmount) != 0 || oldUsedAmount.compareTo(usedAmount) != 0) { + KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz(); + usageHistoryBiz.save(entities); + } + } + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage())); + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage())); + } + } catch (Exception e) { + writeLog(e); + resultMap.put("status", "-1"); + resultMap.put("message", e.getMessage()); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleavedetail/GetBalanceFormCmd.java b/src/com/engine/kq/cmd/balanceofleavedetail/GetBalanceFormCmd.java new file mode 100644 index 0000000..21915ae --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleavedetail/GetBalanceFormCmd.java @@ -0,0 +1,387 @@ +package com.engine.kq.cmd.balanceofleavedetail; + +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; + +/** + * 获取加班调休明细的编辑表单 + */ +public class GetBalanceFormCmd extends AbstractCommonCommand> { + + public GetBalanceFormCmd(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(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + /*获取当前日期,当前时间*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + String id = Util.null2String(params.get("id"));//这条明细记录的ID + + String resourceId = "";//人员ID + String leaveRulesId = "";//假期类型的ID + String belongYear = "";//年度 + String belongMonth = "";//期间 + String overtimeType = "";//加班类型 + String baseAmount = "0.00";//基数 + String extraAmount = "0.00";//额外 + String tiaoxiuamount = "0.00";//加班生成调休 + String usedAmount = "0.00";//已休 + String invalidAmount = "0.00";//作废 + String effectiveDate = "";//生效日期 + String expirationDate = "";//失效日期 + String childId = "";//孩子的id + + if (!id.equals("")) { + String sql = "select * from KQ_BalanceOfLeave where (isDelete is null or isDelete<>1) and id=" + id; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + resourceId = recordSet.getString("resourceId"); + leaveRulesId = recordSet.getString("leaveRulesId"); + belongYear = recordSet.getString("belongYear"); + belongMonth = recordSet.getString("belongMonth"); + overtimeType = recordSet.getString("overtimeType"); + baseAmount = recordSet.getString("baseAmount"); + extraAmount = recordSet.getString("extraAmount"); + tiaoxiuamount = recordSet.getString("tiaoxiuamount"); + usedAmount = recordSet.getString("usedAmount"); + effectiveDate = recordSet.getString("effectiveDate"); + expirationDate = recordSet.getString("expirationDate"); + childId = recordSet.getString("childId"); + } + } + + //假期类型的缓存类 + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + String minimumUnit = rulesComInfo.getMinimumUnit(leaveRulesId); + String unitLabel = ""; + if (KQUnitBiz.isLeaveHour(minimumUnit)) { + unitLabel = "389326"; + } else { + unitLabel = "389325"; + } + //人力资源缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + //假期规则的缓存类 + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + int decimalDigit = Util.getIntValue(detailComInfo.getDecimalDigit(leaveRulesId, subcompanyId, departmentId, resourceId), 2); + + BigDecimal _totalAmount = new BigDecimal(Util.getDoubleValue(baseAmount, 0.00) + Util.getDoubleValue(extraAmount, 0)); + BigDecimal _baseAmount = new BigDecimal(Util.getDoubleValue(baseAmount, 0.00)); + BigDecimal _extraAmount = new BigDecimal(Util.getDoubleValue(extraAmount, 0)); + BigDecimal _usedAmount = new BigDecimal(Util.getDoubleValue(usedAmount, 0.00)); + BigDecimal _tiaoxiuamount = new BigDecimal(Util.getDoubleValue(tiaoxiuamount, 0.00)).setScale(2,RoundingMode.HALF_UP); + String _invalidAmount = "0.00"; + String _restAmount = "0.00"; + /*如果还处于有效期内,则失效的天数或者小时数为0*/ + if (expirationDate == null || "".equals(expirationDate) || expirationDate.compareTo(currentDate) >= 0) { + _invalidAmount = "0.00"; + _restAmount = _totalAmount.add(_tiaoxiuamount).subtract(_usedAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + } else { + _invalidAmount = _totalAmount.add(_tiaoxiuamount).subtract(_usedAmount).setScale(decimalDigit, RoundingMode.HALF_UP).toPlainString(); + _restAmount = "0.00"; + } + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("resourceId"); + hrmFieldBean.setFieldlabel("413"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(resourceId); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(1); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("belongYear"); + hrmFieldBean.setFieldlabel("15933"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(belongYear); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(1); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + // qc + boolean leaveOfParental = KQLeaveRulesBiz.isLeaveOfParentalNum(leaveRulesId); + boolean isTiaoXiu = KQLeaveRulesBiz.isTiaoXiu(leaveRulesId); + if(isTiaoXiu){ + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("belongMonth"); + hrmFieldBean.setFieldlabel("887"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(belongMonth); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(1); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("totalAmount"); + hrmFieldBean.setFieldlabel("130286" + "," + unitLabel); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(_totalAmount.setScale(decimalDigit, RoundingMode.HALF_UP).doubleValue()); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("0"); + itemList.add(searchConditionItem); + } + + if(leaveOfParental){ + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("childId"); + hrmFieldBean.setFieldlabel("129878"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(new KQChildrenComInfo().getChildrenName(childId)); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(1); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("birthday"); + hrmFieldBean.setFieldlabel("464"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(new KQChildrenComInfo().getBirthday(childId)); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(1); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("baseAmount"); + hrmFieldBean.setFieldlabel("17638" + "," + unitLabel); // 育儿假基数 + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + // 单独写数据 + hrmFieldBean.setFieldvalue(_baseAmount.setScale(decimalDigit, RoundingMode.HALF_UP).doubleValue()); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("0"); + itemList.add(searchConditionItem); + + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("extraAmount"); + hrmFieldBean.setFieldlabel("130286" + "," + unitLabel); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + // 单独些额外的就好 + hrmFieldBean.setFieldvalue(_extraAmount.setScale(decimalDigit, RoundingMode.HALF_UP).doubleValue()); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("0"); + itemList.add(searchConditionItem); + } + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("usedAmount"); + hrmFieldBean.setFieldlabel("26642" + "," + unitLabel); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(usedAmount); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("0"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("invalidAmount"); + hrmFieldBean.setFieldlabel("389611" + "," + unitLabel); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(_invalidAmount); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(1); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("0"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + if(isTiaoXiu){ + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("tiaoxiuamount"); + hrmFieldBean.setFieldlabel("126739" + "," + unitLabel); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(_tiaoxiuamount); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(1); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("0"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("restAmount"); + hrmFieldBean.setFieldlabel("25723" + "," + unitLabel); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(_restAmount); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(1); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("0"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("effectiveDate"); + if (leaveOfParental) { + hrmFieldBean.setFieldlabel("19548"); + }else { + hrmFieldBean.setFieldlabel("508169"); + } + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(effectiveDate); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(1); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("expirationDate"); + hrmFieldBean.setFieldlabel("19547"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(expirationDate); + hrmFieldBean.setIsFormField(true); + if (leaveOfParental) { + hrmFieldBean.setViewAttr(1); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + } else { + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + } + + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + } catch (Exception e) { + writeLog(e); + resultMap.put("status", "-1"); + resultMap.put("message", e.getMessage()); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleavedetail/GetRightMenuCmd.java b/src/com/engine/kq/cmd/balanceofleavedetail/GetRightMenuCmd.java new file mode 100644 index 0000000..c25ec7f --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleavedetail/GetRightMenuCmd.java @@ -0,0 +1,60 @@ +package com.engine.kq.cmd.balanceofleavedetail; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 获取右键菜单 + */ +public class GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(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(); + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + int languageId = user.getLanguage();//用户选择的语言 + RightMenu rightMenu = null; + + boolean canAdd = HrmUserVarify.checkUserRight("KQLeaveRulesAdd:Add", user);//是否具有新建权限 + boolean canDelete = HrmUserVarify.checkUserRight("KQLeaveRulesDelete:Delete", user);//是否具有删除权限 + boolean canLog = HrmUserVarify.checkUserRight("KQLeaveRules:Log", user);//是否具有查看日志的权限 + if (canAdd) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Import, "importExcel", true);//导入 + rightMenuList.add(rightMenu); + rightMenu = new RightMenu(languageId, RightMenuType.BTN_EXPORTEXCEL, "excel", true);//导出Excel + rightMenuList.add(rightMenu); + } + if(canDelete){ + rightMenu = new RightMenu(languageId, RightMenuType.BTN_BatchDelete, "batchDelete", true, true);//批量删除 + rightMenuList.add(rightMenu); + } + if (canLog) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_log, "log", false);//日志 + rightMenuList.add(rightMenu); + } + rightMenu = new RightMenu(languageId, RightMenuType.BTN_COLUMN, "custom", false); //显示列定制 + rightMenuList.add(rightMenu); + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleavedetail/GetSearchListCmd.java b/src/com/engine/kq/cmd/balanceofleavedetail/GetSearchListCmd.java new file mode 100644 index 0000000..65ca90e --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleavedetail/GetSearchListCmd.java @@ -0,0 +1,135 @@ +package com.engine.kq.cmd.balanceofleavedetail; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.general.PageIdConst; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * 加班生成调休的明细 + */ +public class GetSearchListCmd extends AbstractCommonCommand> { + + 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(); + try { + /*人员ID*/ + String resourceId = Util.null2String(params.get("resourceId")); + /*搜索条件中的年份*/ + String searchYearSelect = Util.null2String(params.get("searchYearSelect"));//日期控件的选择值 + String searchYear = Util.null2String(params.get("searchYear"));//年份 + if (searchYearSelect.equals("5") || searchYearSelect.equals("8")) { + searchYear = TimeUtil.getDateByOption(searchYearSelect, "0").substring(0, 4); + } + //假期类型的ID + String leaveRulesId = Util.null2String(params.get("ruleId")); + //qc + boolean leaveOfParental = KQLeaveRulesBiz.isLeaveOfParentalNum(leaveRulesId); + if (resourceId.equals("") || searchYear.equals("") || leaveRulesId.equals("")) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));//参数有误 + return resultMap; + } + boolean isTiaoXiu = KQLeaveRulesBiz.isTiaoXiu(leaveRulesId); + + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + //调休的单位 + String unitName = rulesComInfo.getUnitName(leaveRulesId, user.getLanguage()); + + /**********************************************************************************************************/ + + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限 + boolean canDelete = HrmUserVarify.checkUserRight("KQLeaveRulesDelete:Delete", user);//是否具有删除权限 + boolean canLog = HrmUserVarify.checkUserRight("KQLeaveRules:Log", user);//是否具有查看日志的权限 + + /**********************************************************************************************************/ + + String backFields = " b.id,a.lastName,b.leaverulesid,b.resourceId,b.childId,b.belongYear,b.belongMonth,b.overtimeType,b.baseAmount,b.extraAmount,b.usedAmount,0 as invalidAmount,0 as restAmount,b.changetype,b.effectiveDate,b.expirationDate,b.tiaoxiuamount,0 as birthday "; + String sqlFrom = " from HrmResource a,KQ_BalanceOfLeave b "; + String sqlWhere = " where 1=1 and a.id=b.resourceId and (isDelete is null or isDelete<>1) "; + String orderBy = " b.belongYear asc,b.expirationDate asc,b.id asc "; + + if (!resourceId.equals("")) { + sqlWhere += " and a.id in (" + resourceId + ")"; + } + if (!searchYear.equals("")) { + sqlWhere += " and b.belongYear='" + searchYear + "' "; + } + if (!leaveRulesId.equals("")) { + sqlWhere += " and b.leaveRulesId=" + leaveRulesId; + } + + String pageUid = "b29847fa-6877-f7bd-f12b-5d3a35183b25"; + String operateString = ""; + operateString = ""; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += ""; + + String tableString = "" + + "" + + "" + + operateString + + " " + + " " + + " "; + if (isTiaoXiu) { + tableString += " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "
"; + } else if (leaveOfParental) { + tableString += " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + } + + String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionKey, tableString); + resultMap.put("sessionkey", sessionKey); + } catch (Exception e) { + writeLog(e); + resultMap.put("status", "-1"); + resultMap.put("message", e.getMessage()); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleaverp/ExportExcelCmd.java b/src/com/engine/kq/cmd/balanceofleaverp/ExportExcelCmd.java new file mode 100644 index 0000000..00ba6c1 --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleaverp/ExportExcelCmd.java @@ -0,0 +1,490 @@ +package com.engine.kq.cmd.balanceofleaverp; + +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.KQTransMethod; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ss.usermodel.*; +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.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.OutputStream; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 员工假期余额报表--将查询结果导出为Excel文件 + */ +public class ExportExcelCmd extends AbstractCommonCommand> { + + private HttpServletRequest request; + private HttpServletResponse response; + + public ExportExcelCmd(Map params, User user, HttpServletRequest request, HttpServletResponse response) { + this.user = user; + this.params = params; + this.request = request; + this.response = response; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + long startTime = System.currentTimeMillis(); + Map resultMap = new HashMap(); + /** + * 展示列 + */ + String displayColumn = Util.null2String(params.get("displayColumn")); + List displayColumnList = Util.TokenizerString(displayColumn, ","); + /** + * 时间范围选择的年份 + * 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")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + /** + * isNoAccount:是否显示无账号人员:true-显示、false-不显示 + */ + String isNoAccount = Util.null2String(params.get("isNoAccount")); + + try { + /** + * 获取考勤报表权限共享设置 + */ + KQReportBiz kqReportBiz = new KQReportBiz(); + String rightStr = kqReportBiz.getReportRight("4", "" + user.getUID(), "a"); + + /** + * 拼凑查询结果Excel文件的表头 + */ + HSSFWorkbook workbook = new HSSFWorkbook(); + HSSFSheet sheet = workbook.createSheet(SystemEnv.getHtmlLabelName(389441, user.getLanguage()));//员工假期余额 + // 设置字体 + Font font = workbook.createFont(); + //设置字体大小 + font.setFontHeightInPoints((short) 14); + //字体加粗 + font.setBold(true); + //设置字体名字 + font.setFontName("宋体"); + //设置样式; + CellStyle style = workbook.createCellStyle(); + //设置底边框; + style.setBorderBottom(BorderStyle.THIN); + //设置底边框颜色; + style.setBottomBorderColor(IndexedColors.BLACK.index); + //设置左边框; + style.setBorderLeft(BorderStyle.THIN); + //设置左边框颜色; + style.setLeftBorderColor(IndexedColors.BLACK.index); + //设置右边框; + style.setBorderRight(BorderStyle.THIN); + //设置右边框颜色; + style.setRightBorderColor(IndexedColors.BLACK.index); + //设置顶边框; + style.setBorderTop(BorderStyle.THIN); + //设置顶边框颜色; + style.setTopBorderColor(IndexedColors.BLACK.index); + //在样式用应用设置的字体; + style.setFont(font); + //设置自动换行; + style.setWrapText(false); + //设置水平对齐的样式为居中对齐; + style.setAlignment(HorizontalAlignment.CENTER); + //设置垂直对齐的样式为居中对齐; + style.setVerticalAlignment(VerticalAlignment.CENTER); + + int index = 0; + HSSFRow headerRow = sheet.createRow(0); + String[] tempArr = new String[]{SystemEnv.getHtmlLabelName(413, user.getLanguage()) + ",lastName", SystemEnv.getHtmlLabelName(141, user.getLanguage()) + ",subcom", SystemEnv.getHtmlLabelName(124, user.getLanguage()) + ",dept", SystemEnv.getHtmlLabelName(6086, user.getLanguage()) + ",jobtitle", SystemEnv.getHtmlLabelName(714, user.getLanguage()) + ",workcode"}; + for (int i = 0; i < tempArr.length; i++) { + String[] fieldInfo = tempArr[i].split(","); + if (fieldInfo[1].equals("lastName") || displayColumnList.indexOf(fieldInfo[1]) > -1) { + headerRow.setHeight((short) 312); + HSSFCell headCell = headerRow.createCell(index); + headCell.setCellValue(fieldInfo[0]); + headCell.setCellStyle(style); + sheet.setColumnWidth((short) index, (short) (6 * 1000)); + index++; + } + } + + /**********************************************************************************************************/ + + /**获取假期类型的相关设置*/ + + /*请假类型的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(); + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"0"); + + Map balanceMap = new HashMap(); + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + /*该假期没有启用,不显示*/ + if (!rulesComInfo.getIsEnable().equals("1")) { + continue; + } + if(("1").equals(leavetype_is_on)) { + boolean flag = KQLeaveRulesBiz.filterSubLeaveRule(Util.null2String(user.getUID()), rulesComInfo.getScopeType(), rulesComInfo.getScopeValue(), Util.null2String(user.getUserSubCompany1()), Util.null2String(user.getUserDepartment())); + if (flag) { + continue; + } + } + /*展示列不展示,不显示*/ + if (displayColumnList.indexOf(rulesComInfo.getId()) < 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*/ + + headerRow.setHeight((short) 312); + HSSFCell headCell = headerRow.createCell(index); + headCell.setCellValue(showName); + headCell.setCellStyle(style); + sheet.setColumnWidth((short) index, (short) (6 * 1000)); + index++; + + /*判断该假期规则是否开启了假期余额,若没有开启,则无需查找该假期的余额,直接遍历下一个假期*/ + if (balanceEnable == 0) { + continue; + } + //如果是调休,获取假期余额的方式有些不同 + if (isTiaoXiu) { + params.put("leaveRulesId", leaveRulesId); + params.put("showAll", "true"); + Map _balanceMap = KQBalanceOfLeaveBiz.getRestAmountMapByDis5(params, user); + balanceMap.putAll(_balanceMap); + continue; + } + // qc 如果是育儿假,获取假期余额的方式有些不同 + boolean isLeaveOfParental = KQLeaveRulesBiz.isLeaveOfParentalNum(leaveRulesId); + if (isLeaveOfParental) { + params.put("leaveRulesId",leaveRulesId); + params.put("showAll","true"); + Map _balanceMap = KQBalanceOfLeaveBiz.getRestAmountMapByDis8(params,user); + balanceMap.putAll(_balanceMap); + continue; + } + + /*查询指定年份指定假期的余额数据,并放入集合中,用于后续拼凑查询结果数据*/ + KQTransMethod transMethod = new KQTransMethod(); + RecordSet recordSet = new RecordSet(); + String sql = "select a.id hrmResourceId,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 if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + sql += " and (loginId is not null and loginId<>'')"; + } else { + sql += " and (loginId is not null)"; + } + } + if(resourceStatus.length()>0){ + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sql += " and a.status = "+resourceStatus+ ""; + }else if (resourceStatus.equals("8")) { + sql += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + //考勤报表共享设置 + if (!rightStr.equals("") && !dataScope.equals("4")) { + sql += rightStr; + } + sql += " order by dspOrder,hrmResourceId "; + recordSet.executeQuery(sql); + 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(); + + index = 0; + String sql = "select * 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() + ")"; + } + } + RecordSet recordSet = new RecordSet(); + if (isNoAccount.equals("false")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") + || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql += " and (a.loginId is not null and a.loginId<>'')"; + }else if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + sql += " and (a.loginId is not null and a.loginId<>'')"; + } else { + sql += " and (a.loginId is not null)"; + } + } + if(resourceStatus.length()>0){ + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sql += " and a.status = "+resourceStatus+ ""; + }else if (resourceStatus.equals("8")) { + sql += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + //考勤报表共享设置 + if (!rightStr.equals("") && !dataScope.equals("4")) { + sql += rightStr; + } + sql += " order by dspOrder,id "; + recordSet.executeQuery(sql); + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径 + String fullPathMainKey = "show_full_path"; + + String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); + String subCompanyNameTmp = ""; + String departmentNameTmp = ""; + + while (recordSet.next()) { + HSSFRow row = sheet.createRow(++index); + + String id = recordSet.getString("id"); + String lastName = recordSet.getString("lastName"); + String departmentId = recordSet.getString("departmentId"); + String subcompanyId = recordSet.getString("subcompanyId1"); + String jobtitleId = recordSet.getString("jobtitle"); + String workcode = recordSet.getString("workcode"); + + int cellIndex = 0; + HSSFCell cell = row.createCell(cellIndex); + cell.setCellValue(Util.formatMultiLang(lastName, "" + user.getLanguage())); + cellIndex++; + if (displayColumnList.indexOf("subcom") > -1) { + cell = row.createCell(cellIndex); + + // 导出时,是否显示全路径 + subCompanyNameTmp = "1".equals(isShowFullPath) ? + SubCompanyComInfo.getSubcompanyRealPath(subcompanyId, "/", "0") : + subCompanyComInfo.getSubCompanyname(subcompanyId); + cell.setCellValue(Util.formatMultiLang(subCompanyNameTmp, "" + user.getLanguage())); + + // cell.setCellValue(Util.formatMultiLang(subCompanyComInfo.getSubcompanyname(subcompanyId), "" + user.getLanguage())); + cellIndex++; + } + if (displayColumnList.indexOf("dept") > -1) { + cell = row.createCell(cellIndex); + + // 导出时,是否显示全路径 + departmentNameTmp = "1".equals(isShowFullPath) ? + departmentComInfo.getDepartmentRealPath(departmentId, "/", "0") : + departmentComInfo.getDepartmentname(departmentId); + cell.setCellValue(Util.formatMultiLang(departmentNameTmp, "" + user.getLanguage())); + + // cell.setCellValue(Util.formatMultiLang(departmentComInfo.getDepartmentname(departmentId), "" + user.getLanguage())); + cellIndex++; + } + if (displayColumnList.indexOf("jobtitle") > -1) { + cell = row.createCell(cellIndex); + cell.setCellValue(Util.formatMultiLang(jobTitlesComInfo.getJobTitlesname(jobtitleId), "" + user.getLanguage())); + cellIndex++; + } + if (displayColumnList.indexOf("workcode") > -1) { + cell = row.createCell(cellIndex); + cell.setCellValue(Util.formatMultiLang(workcode, "" + user.getLanguage())); + cellIndex++; + } + + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + /*展示列不展示,不显示*/ + if (displayColumnList.indexOf(rulesComInfo.getId()) < 0) { + continue; + } + /*该假期没有启用,不显示*/ + if (!rulesComInfo.getIsEnable().equals("1")) { + continue; + } + if(("1").equals(leavetype_is_on)) { + boolean flag = KQLeaveRulesBiz.filterSubLeaveRule(Util.null2String(user.getUID()), rulesComInfo.getScopeType(), rulesComInfo.getScopeValue(), Util.null2String(user.getUserSubCompany1()), Util.null2String(user.getUserDepartment())); + if (flag) { + continue; + } + } + /*该假期没有开启余额限制,显示不限制余额*/ + if (rulesComInfo.getBalanceEnable().equals("0")) { + cell = row.createCell(cellIndex); + cell.setCellValue(SystemEnv.getHtmlLabelName(389731, user.getLanguage())); + cellIndex++; + continue; + } + BigDecimal restAmount = balanceMap.get(id + "_" + rulesComInfo.getId()); + cell = row.createCell(cellIndex); + cell.setCellValue(restAmount != null ? restAmount.setScale(2, RoundingMode.HALF_UP).doubleValue() : 0); + cellIndex++; + } + + } + + String encodedFileName = SystemEnv.getHtmlLabelName(389441, user.getLanguage()); + response.reset(); + response.setContentType("application/vnd.ms-excel;charset=utf-8"); + response.setCharacterEncoding("utf-8"); + String header = request.getHeader("User-Agent").toUpperCase(); + if (header.contains("MSIE") || header.contains("TRIDENT") || header.contains("EDGE")) { + encodedFileName = URLEncoder.encode(encodedFileName, "utf-8"); + encodedFileName = encodedFileName.replace("+", "%20"); //IE下载文件名空格变+号问题 + } else { + encodedFileName = new String(encodedFileName.getBytes("utf-8"), "ISO_8859_1"); + } + writeLog("balanceofleaverp>>>ExportExcelCmd>>>encodedFileName="+encodedFileName); + response.setHeader("Content-disposition", "attachment;filename=" + encodedFileName + "excel.xls"); + response.setContentType("application/msexcel"); + response.setContentType("application/x-msdownload"); + OutputStream responseOutput = response.getOutputStream(); + workbook.write(responseOutput); + responseOutput.flush(); + } catch (Exception e) { + writeLog(e); + } + long endTime = System.currentTimeMillis(); + float seconds = (endTime - startTime) / 1000F; + System.out.println(Float.toString(seconds) + " seconds."); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleaverp/GetChangeTypeCmd.java b/src/com/engine/kq/cmd/balanceofleaverp/GetChangeTypeCmd.java new file mode 100644 index 0000000..2f7fa6b --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleaverp/GetChangeTypeCmd.java @@ -0,0 +1,62 @@ +package com.engine.kq.cmd.balanceofleaverp; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 员工假期余额报表--假期使用记录--获取使用记录类型 + */ +public class GetChangeTypeCmd extends AbstractCommonCommand> { + + public GetChangeTypeCmd(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(); + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("changeType");//类型 + hrmFieldBean.setFieldlabel("63"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("All", SystemEnv.getHtmlLabelName(82857, user.getLanguage()),true)); + optionsList.add(new SearchConditionOption("Reduce", SystemEnv.getHtmlLabelName(390300, user.getLanguage()))); + optionsList.add(new SearchConditionOption("Add", SystemEnv.getHtmlLabelName(390301, user.getLanguage()))); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleaverp/GetDetailPageInfoCmd.java b/src/com/engine/kq/cmd/balanceofleaverp/GetDetailPageInfoCmd.java new file mode 100644 index 0000000..989dcd4 --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleaverp/GetDetailPageInfoCmd.java @@ -0,0 +1,53 @@ +package com.engine.kq.cmd.balanceofleaverp; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +/** + * 假期余额报表--假期使用记录--分页组件 + */ +public class GetDetailPageInfoCmd extends AbstractCommonCommand> { + + public GetDetailPageInfoCmd(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(); + + int resourceId = Util.getIntValue((String) params.get("resourceId"), -1);//人员ID + int ruleId = Util.getIntValue((String) params.get("ruleId"), -1);//假期规则ID + String changeType = Util.null2String(params.get("changeType"));//使用记录还是新增记录 + + int total = 0; + int pageSize = 10; + String sql = "select count(*) total from kq_UsageHistory where leaveRulesId=" + ruleId + " and relatedId=" + resourceId; + if(changeType.equals("Reduce")){ + sql += " and ((newBaseAmount+newExtraAmount-newUsedAmount)-(oldBaseAmount+oldExtraAmount-oldUsedAmount)+(newBaseAmount2+newExtraAmount2-newUsedAmount2)-(oldBaseAmount2+oldExtraAmount2-oldUsedAmount2))<0 "; + }else if(changeType.equals("Add")){ + sql += " and ((newBaseAmount+newExtraAmount-newUsedAmount)-(oldBaseAmount+oldExtraAmount-oldUsedAmount)+(newBaseAmount2+newExtraAmount2-newUsedAmount2)-(oldBaseAmount2+oldExtraAmount2-oldUsedAmount2))>0 "; + } + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + total = recordSet.getInt("total"); + } + resultMap.put("total", total); + resultMap.put("pageSize", pageSize); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleaverp/GetPageInfoCmd.java b/src/com/engine/kq/cmd/balanceofleaverp/GetPageInfoCmd.java new file mode 100644 index 0000000..4b54789 --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleaverp/GetPageInfoCmd.java @@ -0,0 +1,127 @@ +package com.engine.kq.cmd.balanceofleaverp; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportBiz; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.resource.ResourceComInfo; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +/** + * 员工假期余额报表--获取分页信息 + */ +public class GetPageInfoCmd extends AbstractCommonCommand> { + + public GetPageInfoCmd(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(); + /** + * 时间范围选择的年份 + * 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")); + + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + + try { + /** + * 获取考勤报表权限共享设置 + */ + KQReportBiz kqReportBiz = new KQReportBiz(); + String rightStr = kqReportBiz.getReportRight("4", "" + user.getUID(), "a"); + + int total = 0; + int pageSize = 10; + + String sql = "select count(*) total 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() + ")"; + } + } + RecordSet recordSet = new RecordSet(); + 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(resourceStatus.length()>0){ + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sql += " and a.status = "+resourceStatus+ ""; + }else if (resourceStatus.equals("8")) { + sql += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + //考勤报表共享设置 + if (!rightStr.equals("") && !dataScope.equals("4")) { + sql += rightStr; + } + recordSet.executeQuery(sql); + if (recordSet.next()) { + total = recordSet.getInt("total"); + } + resultMap.put("total", total); + resultMap.put("pageSize", pageSize); + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleaverp/GetRightMenuCmd.java b/src/com/engine/kq/cmd/balanceofleaverp/GetRightMenuCmd.java new file mode 100644 index 0000000..959213c --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleaverp/GetRightMenuCmd.java @@ -0,0 +1,45 @@ +package com.engine.kq.cmd.balanceofleaverp; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 员工假期余额报表--获取右键菜单 + */ +public class GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(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(); + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + int languageId = user.getLanguage();//用户选择的语言 + RightMenu rightMenu = null; + + rightMenu = new RightMenu(languageId, RightMenuType.BTN_EXPORTEXCEL, "excel", true);//Excel导出 + rightMenuList.add(rightMenu); + + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleaverp/GetSearchConditionCmd.java b/src/com/engine/kq/cmd/balanceofleaverp/GetSearchConditionCmd.java new file mode 100644 index 0000000..f1e789b --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleaverp/GetSearchConditionCmd.java @@ -0,0 +1,313 @@ +package com.engine.kq.cmd.balanceofleaverp; + +import com.api.browser.bean.BrowserTabBean; +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.bean.SelectOption; +import com.api.hrm.bean.WeaRadioGroup; +import com.api.hrm.util.HrmAdvancedSearchUtil; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +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.google.common.collect.Lists; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.settings.ChgPasswdReminder; +import weaver.hrm.settings.RemindSettings; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 假期余额报表--查询条件 + */ +public class GetSearchConditionCmd extends AbstractCommonCommand> { + + public GetSearchConditionCmd(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(); + + /** + * 数据范围 + * 总部、分部、部门、人员、我的下属(管理员没有我的下属) + * 如果人员是否在考勤报表权限共享设置里,则表示此人拥有权限,否则,没有权限 + */ + boolean hasRight = new KQReportBiz().hasReportRight("4",""+user.getUID()); + boolean kq_personal_reportsearch = KQSettingsBiz.showLeaveTypeSet("kq_personal_reportsearch"); +// String sql = "select * from kq_ReportShare where resourceId=" + user.getUID() + " and reportName=4"; + RecordSet recordSet = new RecordSet(); +// recordSet.executeQuery(sql); +// hasRight = recordSet.getCounts() > 0; + + HrmAdvancedSearchUtil hrmAdvancedSearchUtil = new HrmAdvancedSearchUtil(); + /** + * 展示列 + * 分部、部门、岗位、全部假别、…… + * 有些假别的应用范围为分部,但是同样会在报表上显示出来,不是该假别应用范围内的人会显示“——” + */ + Map optionMap = new HashMap(); + List optionList = new ArrayList(); + List> subOptionList = new ArrayList>(); + + optionMap = new HashMap(); + optionMap.put("key", "subcom"); + optionMap.put("showname", SystemEnv.getHtmlLabelName(33553, user.getLanguage())); + subOptionList.add(optionMap); + + optionMap = new HashMap(); + optionMap.put("key", "dept"); + optionMap.put("showname", SystemEnv.getHtmlLabelName(27511, user.getLanguage())); + subOptionList.add(optionMap); + + optionMap = new HashMap(); + optionMap.put("key", "jobtitle"); + optionMap.put("showname", SystemEnv.getHtmlLabelName(6086, user.getLanguage())); + subOptionList.add(optionMap); + + optionMap = new HashMap(); + optionMap.put("key", "workcode"); + optionMap.put("showname", SystemEnv.getHtmlLabelName(714, user.getLanguage())); + subOptionList.add(optionMap); + optionList.add(subOptionList); + + subOptionList = new ArrayList>(); + optionMap = new HashMap(); + optionMap.put("key", "all"); + optionMap.put("showname", SystemEnv.getHtmlLabelName(390021, user.getLanguage())); + subOptionList.add(optionMap); + + String valueStr = "subcom,dept,jobtitle,workcode"; + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"0"); + + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + if (rulesComInfo.getIsEnable().equals("0")) { + continue; + } + if(("1").equals(leavetype_is_on)) { + boolean flag = KQLeaveRulesBiz.filterSubLeaveRule(Util.null2String(user.getUID()), rulesComInfo.getScopeType(), rulesComInfo.getScopeValue(), Util.null2String(user.getUserSubCompany1()), Util.null2String(user.getUserDepartment())); + if (flag) { + continue; + } + } + optionMap = new HashMap(); + optionMap.put("key", rulesComInfo.getId()); + optionMap.put("showname", Util.formatMultiLang(rulesComInfo.getLeaveName(), "" + user.getLanguage())); + subOptionList.add(optionMap); + valueStr += "," + rulesComInfo.getId(); + } + optionList.add(subOptionList); + resultMap.put("option", optionList); + resultMap.put("value", valueStr); + + /** + * 时间范围 + * 本年、上一年、指定年份 + */ + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + groupItem.put("title", SystemEnv.getHtmlLabelName(1889, user.getLanguage())); + groupItem.put("defaultshow", true); + + WeaRadioGroup weaRadioGroup = new WeaRadioGroup(); + List options = new ArrayList();//WeaRadioGroup组件内的options参数 + List domkey = new ArrayList();//WeaRadioGroup组件内的domkey参数 + Map selectLinkageDatas = new HashMap();//WeaRadioGroup组件内的selectLinkageDatas参数 + Map linkMap = new HashMap();//selectLinkageDatas参数内部Map数据 + + weaRadioGroup.setLabel(SystemEnv.getHtmlLabelName(19482, user.getLanguage())); + + options.add(new SelectOption("5", SystemEnv.getHtmlLabelName(15384, user.getLanguage()), true));//本年 + if(kq_personal_reportsearch) { + if(hasRight) { + options.add(new SelectOption("8", SystemEnv.getHtmlLabelName(81716, user.getLanguage())));//上一年 + options.add(new SelectOption("6", SystemEnv.getHtmlLabelName(32530, user.getLanguage())));//指定年份 + } + } else { + options.add(new SelectOption("8", SystemEnv.getHtmlLabelName(81716, user.getLanguage())));//上一年 + options.add(new SelectOption("6", SystemEnv.getHtmlLabelName(32530, user.getLanguage())));//指定年份 + } + weaRadioGroup.setOptions(options); + + domkey.add("dateScope"); + weaRadioGroup.setDomkey(domkey); + + linkMap.put("conditionType", "DATEPICKER"); + linkMap.put("viewAttr", 3); + linkMap.put("format", "YYYY"); + domkey = new ArrayList(); + domkey.add("selectedYear"); + linkMap.put("domkey", domkey); + selectLinkageDatas.put("6", linkMap); + weaRadioGroup.setSelectLinkageDatas(selectLinkageDatas); + + weaRadioGroup.setLabelcol(4); + weaRadioGroup.setFieldcol(20); + itemList.add(weaRadioGroup); + + /*判断当前登录人员是否有下级*/ + boolean hasSubordinate = false; + String sql = "select count(*) from HrmResource where managerId=" + user.getUID(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + hasSubordinate = recordSet.getInt(1) > 0; + } + + weaRadioGroup = new WeaRadioGroup(); + options = new ArrayList();//WeaRadioGroup组件内的options参数 + domkey = new ArrayList();//WeaRadioGroup组件内的domkey参数 + selectLinkageDatas = new HashMap();//WeaRadioGroup组件内的selectLinkageDatas参数 + + weaRadioGroup.setLabel(SystemEnv.getHtmlLabelName(34216, user.getLanguage()));//数据范围 + + if (hasRight) { + options.add(new SelectOption("0", SystemEnv.getHtmlLabelName(140, user.getLanguage()), hasRight && user.isAdmin()));//总部 + options.add(new SelectOption("1", SystemEnv.getHtmlLabelName(33553, user.getLanguage())));//分部 + options.add(new SelectOption("2", SystemEnv.getHtmlLabelName(27511, user.getLanguage())));//部门 + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("subcomId");//分部 + hrmFieldBean.setFieldlabel("33553"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("194"); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + List browserTabBeanList = searchConditionItem.getBrowserConditionParam().getTabs(); + for (BrowserTabBean browserTabBean : browserTabBeanList) { + if (browserTabBean.getKey().equals("2")) { + browserTabBean.setSelected(true); + } + } + selectLinkageDatas.put("1", searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("deptId");//部门 + hrmFieldBean.setFieldlabel("27511"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("57"); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + browserTabBeanList = searchConditionItem.getBrowserConditionParam().getTabs(); + for (BrowserTabBean browserTabBean : browserTabBeanList) { + if (browserTabBean.getKey().equals("2")) { + browserTabBean.setSelected(true); + } + } + selectLinkageDatas.put("2", searchConditionItem); + } + + options.add(new SelectOption("3", SystemEnv.getHtmlLabelName(30042, user.getLanguage()), (!hasRight || !user.isAdmin())));//人员 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("resourceId");//人员 + hrmFieldBean.setFieldlabel("30042"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("17"); + hrmFieldBean.setViewAttr(hasRight ? 3 : 1); + if (!hasRight || !user.isAdmin()) { + hrmFieldBean.setFieldvalue("" + user.getUID()); + } + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (!hasRight) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + searchConditionItem.setRules("required|string"); + selectLinkageDatas.put("3", searchConditionItem); + + if (!user.isAdmin() && hasSubordinate) { + options.add(new SelectOption("4", SystemEnv.getHtmlLabelName(15089, user.getLanguage())));//我的下属 + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("allLevel");//包含下级下属 + hrmFieldBean.setFieldlabel("389995"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + selectLinkageDatas.put("4", searchConditionItem); + } + + weaRadioGroup.setOptions(options); + weaRadioGroup.setSelectLinkageDatas(selectLinkageDatas); + + domkey.add("dataScope"); + weaRadioGroup.setDomkey(domkey); + + weaRadioGroup.setLabelcol(4); + weaRadioGroup.setFieldcol(20); + itemList.add(weaRadioGroup); + + WeaRadioGroup wrg1 = new WeaRadioGroup(); + + ChgPasswdReminder reminder = new ChgPasswdReminder(); + RemindSettings settings = reminder.getRemindSettings(); + String checkUnJob = Util.null2String(settings.getCheckUnJob(), "0"); + List statusList = Lists.newArrayList(); + if ("1".equals(checkUnJob)) {//启用后,只有有“离职人员查看”权限的用户才能检索非在职人员 + if (HrmUserVarify.checkUserRight("hrm:departureView", user)) { + statusList.add("9,332,false"); + } + } else { + statusList.add("9,332,false"); + } + statusList.add("0,15710,false"); + statusList.add("1,15711,false"); + statusList.add("2,480,false"); + statusList.add("3,15844,false"); + if ("1".equals(checkUnJob)) {//启用后,只有有“离职人员查看”权限的用户才能检索非在职人员 + if (HrmUserVarify.checkUserRight("hrm:departureView", user)) { + statusList.add("4,6094,false"); + statusList.add("5,6091,false"); + statusList.add("6,6092,false"); + statusList.add("7,2245,false"); + } + } else { + statusList.add("4,6094,false"); + statusList.add("5,6091,false"); + statusList.add("6,6092,false"); + statusList.add("7,2245,false"); + } + statusList.add("8,1831,true"); + String[] strOptions = new String[statusList.size()]; + for(int i = 0 ; i < statusList.size() ; i++){ + String statusStr = statusList.get(i); + strOptions[i] = statusStr; + } + + wrg1 = hrmAdvancedSearchUtil.getAdvanceCondition("status","602",strOptions,null,user); + wrg1.setLabelcol(4); + wrg1.setFieldcol(20); + itemList.add(wrg1); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleaverp/GetSearchListCmd.java b/src/com/engine/kq/cmd/balanceofleaverp/GetSearchListCmd.java new file mode 100644 index 0000000..8e35043 --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleaverp/GetSearchListCmd.java @@ -0,0 +1,435 @@ +package com.engine.kq.cmd.balanceofleaverp; + +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldUtil; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +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.systeminfo.SystemEnv; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 员工假期余额报表--获取查询列表 + */ +public class GetSearchListCmd extends AbstractCommonCommand> { + + 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")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + /** + * isNoAccount:是否显示无账号人员:true-显示、false-不显示 + */ + String isNoAccount = Util.null2String(params.get("isNoAccount")); + + try { + /** + * 获取考勤报表权限共享设置 + */ + KQReportBiz kqReportBiz = new KQReportBiz(); + String rightStr = kqReportBiz.getReportRight("4", "" + user.getUID(), "a"); + + /** + * 拼凑查询结果列表的表头 + */ + 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; + + /**********************************************************************************************************/ + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"0"); + + /*获取当前日期*/ + String currentDate = DateUtil.getCurrentDate(); + + Map balanceMap = new HashMap(); + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + if (rulesComInfo.getIsEnable().equals("0")) { + continue;//此假期类型没有启用 + } + // 满足考勤报表显示假期类型按照分部\部门\人员进行先功能开发 + if(("1").equals(leavetype_is_on)) { + boolean flag = KQLeaveRulesBiz.filterSubLeaveRule(Util.null2String(user.getUID()), rulesComInfo.getScopeType(), rulesComInfo.getScopeValue(), Util.null2String(user.getUserSubCompany1()), Util.null2String(user.getUserDepartment())); + if (flag) { + 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; + } + // qc 如果是育儿假,获取假期余额的方式有些不同 + boolean isLeaveOfParental = KQLeaveRulesBiz.isLeaveOfParentalNum(leaveRulesId); + if (isLeaveOfParental) { + params.put("leaveRulesId",leaveRulesId); + params.put("showAll","false"); + Map _balanceMap = KQBalanceOfLeaveBiz.getRestAmountMapByDis8(params,user); + balanceMap.putAll(_balanceMap); + continue; + } + /*查询指定年份指定假期的余额数据,并放入集合中,用于后续拼凑查询结果数据*/ + 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 if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + sql += " and (loginId is not null and loginId<>'')"; + } else { + sql += " and (loginId is not null)"; + } + } + + if(resourceStatus.length()>0){ + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sql += " and a.status = "+resourceStatus+ ""; + }else if (resourceStatus.equals("8")) { + sql += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + //考勤报表共享设置 + 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; + }else if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + pageSql = sql + " limit " +pageSize + " offset " + (currentPage - 1) * 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 if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + sql += " and (a.loginId is not null and a.loginId<>'')"; + } else { + sql += " and (a.loginId is not null)"; + } + } + + if(resourceStatus.length()>0){ + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sql += " and a.status = "+resourceStatus+ ""; + }else if (resourceStatus.equals("8")) { + sql += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + //考勤报表共享设置 + 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; + }else if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + pageSql = sql + " limit " +pageSize + " offset " + (currentPage - 1) * pageSize; + } + recordSet.executeQuery(pageSql); + + // #1473334-概述:满足考勤报分部部门显示及导出时显示全路径 + String fullPathMainKey = "show_full_path"; + + String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); + String departmentNameTmp = ""; + String subCompanyNameTmp = ""; + + 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); + + // 根据开关决定是否显示分部部门全路径 + subCompanyNameTmp = "1".equals(isShowFullPath) ? + SubCompanyComInfo.getSubcompanyRealPath(subcompanyId, "/", "0") : + subCompanyComInfo.getSubCompanyname(subcompanyId); + + departmentNameTmp = "1".equals(isShowFullPath) ? + departmentComInfo.getDepartmentRealPath(departmentId, "/", "0") : + departmentComInfo.getDepartmentname(departmentId); + + dataMap.put("subcom", Util.formatMultiLang(subCompanyNameTmp, "" + user.getLanguage())); + dataMap.put("dept", Util.formatMultiLang(departmentNameTmp, "" + user.getLanguage())); + + // 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(("1").equals(leavetype_is_on)){ + boolean flag = KQLeaveRulesBiz.filterSubLeaveRule(Util.null2String(user.getUID()), rulesComInfo.getScopeType(), rulesComInfo.getScopeValue(), Util.null2String(user.getUserSubCompany1()), Util.null2String(user.getUserDepartment())); + if (flag) { + 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/kq/cmd/balanceofleaverp/GetTabCmd.java b/src/com/engine/kq/cmd/balanceofleaverp/GetTabCmd.java new file mode 100644 index 0000000..e5c9542 --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleaverp/GetTabCmd.java @@ -0,0 +1,83 @@ +package com.engine.kq.cmd.balanceofleaverp; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +/** + * 员工假期余额报表--获取TAB页签 + */ +public class GetTabCmd extends AbstractCommonCommand> { + + public GetTabCmd(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(); + try { + int resourceId = Util.getIntValue((String) params.get("resourceId"), -1);//人员ID + String ruleId = Util.null2String(params.get("ruleId"));//假期规则的ID + if (resourceId == -1) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));//参数有误 + return resultMap; + } + + /** + * 加载TAB页签: + * 1-只加载启用的假期规则 + */ + Map valueMap = new LinkedHashMap();//假期规则集合 + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + kqLeaveRulesComInfo.setTofirstRow(); + while (kqLeaveRulesComInfo.next()) { + if (kqLeaveRulesComInfo.getIsEnable().equals("0")) { + continue; + } + valueMap.put(Util.formatMultiLang(kqLeaveRulesComInfo.getLeaveName(), "" + user.getLanguage()), kqLeaveRulesComInfo.getId()); + } + + /** + * 拼装前端TAB页签需要的数据 + */ + int index = 0; + Map tabMap = new HashMap(); + List> tabList = new ArrayList>(); + for (Map.Entry entry : valueMap.entrySet()) { + tabMap = new HashMap(); + tabMap.put("key", entry.getValue().toString()); + tabMap.put("title", entry.getKey()); + tabList.add(tabMap); + + /** + * 直接点击人员姓名查看假期使用记录时,ruleId是为空的,默认为第一个TAB页签 + */ + if (index == 0 && ruleId.equals("")) { + ruleId = entry.getValue().toString(); + } + index++; + } + resultMap.put("tab", tabList); + resultMap.put("selectedKey", ruleId); + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/balanceofleaverp/GetUsageRecordDetailCmd.java b/src/com/engine/kq/cmd/balanceofleaverp/GetUsageRecordDetailCmd.java new file mode 100644 index 0000000..85d7442 --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleaverp/GetUsageRecordDetailCmd.java @@ -0,0 +1,205 @@ +package com.engine.kq.cmd.balanceofleaverp; + +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.KQTransMethod; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 员工假期余额报表--某假期的详细使用记录 + */ +public class GetUsageRecordDetailCmd extends AbstractCommonCommand> { + + public GetUsageRecordDetailCmd(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(); + try { + String resourceId = Util.null2String(params.get("resourceId"));//人员ID + String ruleId = Util.null2String(params.get("ruleId"));//假期类型的ID(对应的是数据库kq_leaveRules表的主键ID) + String changeType = Util.null2String(params.get("changeType"));//使用记录还是新增记录 + + int pageSize = Util.getIntValue((String) params.get("pageSize"), 10);//每页多少行数据 + int currentPage = Util.getIntValue((String) params.get("currentPage"), 1);//当前是多少页 + + /**********************************************************************************************************/ + + /*获取假期类型的相关设置*/ + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + + /*假期规则名称*/ + String leaveName = Util.formatMultiLang(rulesComInfo.getLeaveName(ruleId), "" + user.getLanguage()); + + /*最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假*/ + int minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(ruleId), -1); + + /*计算请假时长方式:1-按工作日计算请假时长、2-按自然日计算请假时长*/ + int computingMode = Util.getIntValue(rulesComInfo.getComputingMode(ruleId), -1); + + /*启用假期余额:0-不启用、1-启用*/ + int balanceEnable = Util.getIntValue(rulesComInfo.getBalanceEnable(ruleId), 0); + + /*假期规则的请假单位是天还是小时*/ + String unitName = "";//单位名称,天/小时 + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) { + unitName = SystemEnv.getHtmlLabelName(389325, user.getLanguage());//(天) + } else { + unitName = SystemEnv.getHtmlLabelName(389326, user.getLanguage());//(小时) + } + + /*是否是混合模式(法定年假+福利年假)*/ + boolean isMixMode = KQLeaveRulesBiz.isMixMode(ruleId); + + /**********************************************************************************************************/ + + ResourceComInfo resourceComInfo = new ResourceComInfo(); + + /*分部ID*/ + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + + /**********************************************************************************************************/ + + /*获取假期类型下对应的假期规则的相关设置*/ + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + + /*余额发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按工龄+工龄自动发放*/ + int distributionMode = Util.getIntValue(detailComInfo.getDistributionMode(ruleId, subcompanyId,departmentId,resourceId), 1); + + /*释放规则:0-不限制、1-按天释放、2-按月释放*/ + int releaseRule = Util.getIntValue(detailComInfo.getReleaseRule(ruleId, subcompanyId,departmentId,resourceId), 0); + + /**********************************************************************************************************/ + + String balanceOfLeave = KQBalanceOfLeaveBiz.getRestAmount("" + resourceId, "" + ruleId, DateUtil.getCurrentDate()); + String topTips = balanceOfLeave + unitName; + resultMap.put("topTips", topTips); + + RecordSet recordSet = new RecordSet(); + Map dataMap = new HashMap(); + List> dataList = new ArrayList>(); + String sql = "select * from kq_UsageHistory where leaveRulesId=" + ruleId + " and relatedId=" + resourceId; + if(changeType.equals("Reduce")){ + sql += " and ((newBaseAmount+newExtraAmount-newUsedAmount)-(oldBaseAmount+oldExtraAmount-oldUsedAmount)+(newBaseAmount2+newExtraAmount2-newUsedAmount2)-(oldBaseAmount2+oldExtraAmount2-oldUsedAmount2))<0 "; + }else if(changeType.equals("Add")){ + sql += " and ((newBaseAmount+newExtraAmount-newUsedAmount)-(oldBaseAmount+oldExtraAmount-oldUsedAmount)+(newBaseAmount2+newExtraAmount2-newUsedAmount2)-(oldBaseAmount2+oldExtraAmount2-oldUsedAmount2))>0 "; + } + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sql = "select *,ROW_NUMBER() OVER(order by operateDate desc,operateTime desc,id) as rn from kq_UsageHistory where leaveRulesId=" + ruleId + " and relatedId=" + resourceId; + } + if (!recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sql += " order by operateDate desc,operateTime desc,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; + }else if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + pageSql = sql + " limit " + pageSize + " offset " + (currentPage - 1) * pageSize ; + } + recordSet.executeQuery(pageSql); + while (recordSet.next()) { + String id = recordSet.getString("id"); + String wfRequestId = recordSet.getString("wfRequestId"); + String operateDate = recordSet.getString("operateDate"); + String operateTime = recordSet.getString("operateTime"); + String operateType = recordSet.getString("operateType"); + + double oldBaseAmount = Util.getDoubleValue(recordSet.getString("oldBaseAmount"), 0.00); + double newBaseAmount = Util.getDoubleValue(recordSet.getString("newBaseAmount"), 0.00); + double oldExtraAmount = Util.getDoubleValue(recordSet.getString("oldExtraAmount"), 0.00); + double newExtraAmount = Util.getDoubleValue(recordSet.getString("newExtraAmount"), 0.00); + double oldUsedAmount = Util.getDoubleValue(recordSet.getString("oldUsedAmount"), 0.00); + double newUsedAmount = Util.getDoubleValue(recordSet.getString("newUsedAmount"), 0.00); + double oldBaseAmount2 = Util.getDoubleValue(recordSet.getString("oldBaseAmount2"), 0.00); + double newBaseAmount2 = Util.getDoubleValue(recordSet.getString("newBaseAmount2"), 0.00); + double oldExtraAmount2 = Util.getDoubleValue(recordSet.getString("oldExtraAmount2"), 0.00); + double newExtraAmount2 = Util.getDoubleValue(recordSet.getString("newExtraAmount2"), 0.00); + double oldUsedAmount2 = Util.getDoubleValue(recordSet.getString("oldUsedAmount2"), 0.00); + double newUsedAmount2 = Util.getDoubleValue(recordSet.getString("newUsedAmount2"), 0.00); + + int oldMinimumUnit = Util.getIntValue(recordSet.getString("oldMinimumUnit")); + if(oldMinimumUnit<0){//表示是第一条insert的假期数据,oldMinimumUnit字段值是为null + oldMinimumUnit = Util.getIntValue(recordSet.getString("newMinimumUnit")); + } + if (oldMinimumUnit == 1 || oldMinimumUnit == 2 || oldMinimumUnit == 4) { + unitName = SystemEnv.getHtmlLabelName(389325, user.getLanguage());//(天) + } else { + unitName = SystemEnv.getHtmlLabelName(389326, user.getLanguage());//(小时) + } + + /*获取员工假期余额变更的文字描述*/ + String operateDesc = KQUsageHistoryBiz.getDescription(id, user); + + double changeAmount = 0.00; + /*获取员工假期余额变更前后的差值*/ + if (!operateType.equals("0")) { + if (isMixMode) { + changeAmount = (newBaseAmount + newExtraAmount - newUsedAmount) - (oldBaseAmount + oldExtraAmount - oldUsedAmount) + + (newBaseAmount2 + newExtraAmount2 - newUsedAmount2) - (oldBaseAmount2 + oldExtraAmount2 - oldUsedAmount2); + } else { + changeAmount = (newBaseAmount + newExtraAmount - newUsedAmount) - (oldBaseAmount + oldExtraAmount - oldUsedAmount); + } + } + if (changeType.equals("Reduce") && changeAmount >= 0.00) { + continue; + } + if (changeType.equals("Add") && changeAmount <= 0.00) { + continue; + } + if (!wfRequestId.equals("") && !wfRequestId.equals("0")) { + operateDesc = "" + operateDesc + ""; + } + dataMap = new HashMap(); + dataMap.put("operateDate", operateDate); + dataMap.put("operateTime", operateTime); + dataMap.put("operateDesc", operateDesc); + dataMap.put("changeAmount", operateType.equals("0") ? SystemEnv.getHtmlLabelName(10000812, Util.getIntValue(user.getLanguage())) : String.format("%.2f", changeAmount) + unitName); + dataList.add(dataMap); + } + resultMap.put("dataDetail", dataList); + + KQTransMethod kqTransMethod = new KQTransMethod(); + String bottomTips = ""; + if (balanceEnable == 0) { + bottomTips = SystemEnv.getHtmlLabelName(524, user.getLanguage()) + " " + leaveName + " " + SystemEnv.getHtmlLabelName(579, user.getLanguage()) + ":" + kqTransMethod.getComputingModeName("" + computingMode, "" + user.getLanguage()); + } else { + bottomTips = SystemEnv.getHtmlLabelName(524, user.getLanguage()) + " " + leaveName + " " + SystemEnv.getHtmlLabelName(579, user.getLanguage()) + ":" + kqTransMethod.getDistributionModName("" + distributionMode, "" + user.getLanguage()); + boolean isTiaoXiu = KQLeaveRulesBiz.isTiaoXiu(ruleId); + + if (!isTiaoXiu) { + bottomTips += "-" + kqTransMethod.getReleaseRuleName("" + releaseRule, "" + user.getLanguage()); + } + } + resultMap.put("bottomTips", bottomTips); + resultMap.put("balanceEnable", balanceEnable); + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + +} diff --git a/src/com/engine/kq/cmd/group/DelGroupCmd.java b/src/com/engine/kq/cmd/group/DelGroupCmd.java new file mode 100644 index 0000000..beba988 --- /dev/null +++ b/src/com/engine/kq/cmd/group/DelGroupCmd.java @@ -0,0 +1,91 @@ +package com.engine.kq.cmd.group; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class DelGroupCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + public DelGroupCmd(Map params, User user) { + this.user = user; + this.params = params; + + String ids = Util.null2String(params.get("ids"));//考勤组id + this.logger = new SimpleBizLogger(); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_group where id in("+ids+") and (isdelete is null or isdelete <> '1') "; + logger.setMainSql(mainSql,"id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("groupname");//当前targetName对应的列(对应日志中的对象名) + logger.before(bizLogContext); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String ids = Util.null2String(params.get("ids"));//考勤组id + List sqlParams = new ArrayList(); + Object[] objects=DBUtil.transListIn(ids,sqlParams); + sql = "update kq_group set isdelete = 1 where id in ("+objects[0]+") "; + rs.executeUpdate(sql, sqlParams); + + sql = "update kq_groupmember set isdelete = 1 where groupid in ("+objects[0]+") "; + rs.executeUpdate(sql, sqlParams); + + sql = "update kq_shiftschedule set isdelete=1 where groupid in ("+objects[0]+")" ; + rs.executeUpdate(sql, sqlParams); + + sql = "update kq_fixedschedulce set isdelete=1 where groupid in ("+objects[0]+")" ; + rs.executeUpdate(sql, sqlParams); + + new KQGroupMemberComInfo().removeCache(); + new KQGroupComInfo().removeCache(); + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(20461, user.getLanguage())); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/group/ExportExcelCmd.java b/src/com/engine/kq/cmd/group/ExportExcelCmd.java new file mode 100644 index 0000000..2b49a84 --- /dev/null +++ b/src/com/engine/kq/cmd/group/ExportExcelCmd.java @@ -0,0 +1,138 @@ +package com.engine.kq.cmd.group; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.util.ExcelUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.*; + +public class ExportExcelCmd extends AbstractCommonCommand> { + + private HttpServletRequest request; + private HttpServletResponse response; + + public ExportExcelCmd(Map params, HttpServletRequest request, HttpServletResponse response, User user) { + this.user = user; + this.params = params; + this.request = request; + this.response = response; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + KQGroupComInfo KQGroupComInfo = new KQGroupComInfo(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + String groupId = Util.null2String(params.get("groupId")); + + LinkedHashMap workbook = new LinkedHashMap<>(); + List lsSheet = new ArrayList<>(); + Map sheet = null; + List titleList = null; + Map title = null; + List> dataList = null; + List data = null; + + sheet = new HashMap<>(); + sheet.put("sheetName", SystemEnv.getHtmlLabelName(20817, user.getLanguage())); + sheet.put("sheetTitle", SystemEnv.getHtmlLabelName(389949, user.getLanguage()).replace("$groupName$",kqGroupComInfo.getGroupname(groupId))); + titleList = new ArrayList<>(); + + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelName(801, user.getLanguage())); + title.put("width",15*256); + titleList.add(title); + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelName(802, user.getLanguage())); + title.put("width",15*256); + titleList.add(title); + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelName(388714, user.getLanguage())+"("+SystemEnv.getHtmlLabelName(125675, user.getLanguage())+")"); + title.put("width",15*256); + titleList.add(title); + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelName(389220, user.getLanguage())); + title.put("width",50*256); + titleList.add(title); + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelName(389221, user.getLanguage())); + title.put("width",50*256); + titleList.add(title); + + sheet.put("titleList", titleList); + + dataList = new ArrayList<>(); + sql = " select locationname,longitude,latitude,checkscope,address from kq_location where groupid = ? order by id "; + rs.executeQuery(sql, groupId); + while (rs.next()) { + data = new ArrayList<>(); + data.add(rs.getString("longitude")); + data.add(rs.getString("latitude")); + data.add(rs.getString("checkscope")); + data.add(rs.getString("address")); + data.add(rs.getString("locationname")); + dataList.add(data); + } + sheet.put("dataList", dataList); + lsSheet.add(sheet); + + sheet = new HashMap<>(); + sheet.put("sheetName", SystemEnv.getHtmlLabelName(389126, user.getLanguage())); + sheet.put("sheetTitle", SystemEnv.getHtmlLabelName(389952, user.getLanguage()).replace("$groupName$",kqGroupComInfo.getGroupname(groupId))); + titleList = new ArrayList<>(); + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelName(195, user.getLanguage())); + title.put("width",10*256); + titleList.add(title); + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelName(32072, user.getLanguage())); + title.put("width",50*256); + titleList.add(title); + sheet.put("titleList", titleList); + dataList = new ArrayList<>(); + sql = " select wifiname,mac,groupid from kq_wifi where groupid = ? order by id "; + rs.executeQuery(sql, groupId); + while (rs.next()) { + data = new ArrayList<>(); + data.add(rs.getString("wifiname")); + data.add(rs.getString("mac")); + dataList.add(data); + } + sheet.put("dataList", dataList); + lsSheet.add(sheet); + + workbook.put("sheet", lsSheet); + workbook.put("fileName", SystemEnv.getHtmlLabelName(389959, user.getLanguage()).replace("$groupName$",kqGroupComInfo.getGroupname(groupId))); + ExcelUtil ExcelUtil = new ExcelUtil(); + ExcelUtil.export(workbook,request,response); + + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/group/GetAddMemberConditionCmd.java b/src/com/engine/kq/cmd/group/GetAddMemberConditionCmd.java new file mode 100644 index 0000000..5f54eeb --- /dev/null +++ b/src/com/engine/kq/cmd/group/GetAddMemberConditionCmd.java @@ -0,0 +1,102 @@ +package com.engine.kq.cmd.group; + +import com.api.browser.bean.BrowserBean; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class GetAddMemberConditionCmd extends AbstractCommonCommand>{ + + public GetAddMemberConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + List fields = new ArrayList<>(Arrays.asList( + "groupId,515195,3,kqgroup" + )); + + Map retmap = new HashMap(); + List condition = new ArrayList(); + Map groupitem = null; + try { + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + + List items = new ArrayList<>(); + + HrmFieldBean hrmFieldBean = null; + SearchConditionItem searchConditionItem = null; + List options = null; + + groupitem = new HashMap<>(); + groupitem.put("title", ""); + groupitem.put("defaultshow", true); + + for(String f : fields){ + String [] fieldConfig = f.split(","); + String fieldname = fieldConfig[0]; + String fieldlabel = fieldConfig[1]; + String fieldhtmltype = fieldConfig[2]; + String type = fieldConfig[3]; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(fieldname); + hrmFieldBean.setFieldlabel(fieldlabel); + hrmFieldBean.setFieldhtmltype(fieldhtmltype); + hrmFieldBean.setType(type); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + + if(fieldname.equals("sendDate")){ + hrmFieldBean.setIsFormField(false); + } + + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + Map conditionParams = new HashMap<>(); + conditionParams.put("advance", "1"); + Map dataParams = new HashMap<>(); + dataParams.put("advance", "1"); + Map completeParams = new HashMap<>(); + completeParams.put("includeAll", "1"); + searchConditionItem.getBrowserConditionParam().setConditionDataParams(conditionParams); + searchConditionItem.getBrowserConditionParam().setDataParams(dataParams); + searchConditionItem.getBrowserConditionParam().setCompleteParams(completeParams); + searchConditionItem.getBrowserConditionParam().setQuickSearchName("groupname"); + items.add(searchConditionItem); + } + groupitem.put("items", items); + condition.add(groupitem); + retmap.put("condition", condition); + retmap.put("status", "1"); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/group/GetGroupFormCmd.java b/src/com/engine/kq/cmd/group/GetGroupFormCmd.java new file mode 100644 index 0000000..41f226d --- /dev/null +++ b/src/com/engine/kq/cmd/group/GetGroupFormCmd.java @@ -0,0 +1,965 @@ +package com.engine.kq.cmd.group; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.util.PageUidFactory; +import com.engine.kq.util.UtilKQ; +import com.google.common.collect.Maps; +import org.apache.commons.collections.CollectionUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.hrm.settings.ChgPasswdReminder; +import weaver.hrm.settings.RemindSettings; +import weaver.proj.util.SQLUtil; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.*; + +public class GetGroupFormCmd extends AbstractCommonCommand> { + + public GetGroupFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + Map otherparam = null; + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + ChgPasswdReminder reminder=new ChgPasswdReminder(); + RemindSettings settings=reminder.getRemindSettings(); + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + + String id = Util.null2String(params.get("id")); + String subcompanyid = Util.null2String(params.get("subcompanyid"));//所属分部 + String tabKey = Util.null2String(params.get("tabKey")); + Map> fieldGroups= new LinkedHashMap>(); + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + List options = null; + + String groupname = "";//考勤组名称 + String kqtype = "1";//考勤类型 默认固定班制 + String excludeid = "";//考勤组排除人员 + String excludecount = "";//考勤组排除人员是否参与统计 + String serialids = "";//考勤班次 + String overtimeRuleId = "";//加班班次 + String overtimeType = "0";//加班类型 + List lsWeekday = new ArrayList<>();//考勤工作日 + String weekday = ""; + String signstart = "";//考勤开始时间 + String workhour = "";//工作时长 + String signintype = "1";//打卡方式 + String ipscope = "";//应用IP范围 + String ipscope_v4_pc = "";//应用IP范围 v4 pc端 + String ipscope_v4_em = "";//应用IP范围 v4 移动端 + String ipscope_v6_pc = "";//应用IP范围 v6 pc端 + String ipscope_v6_em = "";//应用IP范围 v6 移动端 + String locationcheck = "";//启用办公地点考勤 + //String locationcheckscope = "300";//有效范围 + String wificheck = "";//启用wifi考勤 + String outsidesign = "";//允许外勤打卡 + String outsignapprove = "";//545427 外勤打卡需要审批 + String validity = "";//考勤组有效期 + String validityfromdate = "";//考勤组有效期开始时间 + String validityenddate = "";//考勤组有效期结束时间 + String locationfacecheck = "";//办公地点启用人脸识别拍照打卡 + String locationfacechecktype = "";//办公地点启用人脸识别拍照打卡方式 + String locationshowaddress = "";//有效识别半径内显示同一地址 + String wififacecheck = "";//wifi启用人脸识别拍照打卡 + String wififacechecktype = "";//wifi启用人脸识别拍照打卡方式 + String self_shift = "0";//启用员工自我排班 + String auto_checkin = "0";//允许客户端设置自动考勤 上班卡 + String auto_checkin_before = "30";//允许客户端设置自动考勤 上班卡开始分钟数 + String auto_checkin_after = "30";//允许客户端设置自动考勤 上班卡结束分钟时 + String auto_checkout = "0";//允许客户端设置自动考勤 下班卡 + String auto_checkout_before = "5";//允许客户端设置自动考勤 下班卡 下班卡开始分钟数 + String auto_checkout_after = "60";//允许客户端设置自动考勤 下班卡 下班卡结束分钟时 + String calmethod = "1";//工作时长计算方式 1是打卡时间累加计算 2是打卡时间成对计算 + String abnormalremind = "0";//考勤异常提醒 1是打开 0是关闭 + String isPhotoPunchEnabled = "0";//启用考勤拍照打卡 + + List> replaceDatas = new ArrayList>(); + if(id.length()>0){ + sql = "select * from kq_group where id=?"; + rs.executeQuery(sql,id); + if(rs.next()){ + groupname = Util.null2String(rs.getString("groupname")); + excludeid = Util.null2String(rs.getString("excludeid")); + excludecount = Util.null2String(rs.getString("excludecount")); + subcompanyid = Util.null2String(rs.getString("subcompanyid")); + kqtype = Util.null2String(rs.getString("kqtype")); + serialids=Util.null2String(rs.getString("serialids")); + overtimeType=Util.null2s(rs.getString("overtime_type"),"0"); + weekday = Util.null2String(rs.getString("weekday")); + signstart = Util.null2String(rs.getString("signstart")); + workhour = Util.null2String(rs.getString("workhour")); + signintype = Util.null2String(rs.getString("signintype")); + ipscope = Util.null2String(rs.getString("ipscope")); + ipscope_v4_pc = Util.null2String(rs.getString("ipscope_v4_pc")); + ipscope_v4_em = Util.null2String(rs.getString("ipscope_v4_em")); + ipscope_v6_pc = Util.null2String(rs.getString("ipscope_v6_pc")); + ipscope_v6_em = Util.null2String(rs.getString("ipscope_v6_em")); + locationcheck = Util.null2String(rs.getString("locationcheck")); + //locationcheckscope = Util.null2String(rs.getString("locationcheckscope")); + wificheck = Util.null2String(rs.getString("wificheck")); + outsidesign = Util.null2String(rs.getString("outsidesign")); + outsignapprove = Util.null2String(rs.getString("outsignapprove")); + validity = Util.null2String(rs.getString("validity")); + validityfromdate = Util.null2String(rs.getString("validityfromdate")); + validityenddate = Util.null2String(rs.getString("validityenddate")); + locationfacecheck = Util.null2String(rs.getString("locationfacecheck")); + locationfacechecktype = Util.null2String(rs.getString("locationfacechecktype")); + locationshowaddress = Util.null2String(rs.getString("locationshowaddress")); + wififacecheck = Util.null2String(rs.getString("wififacecheck")); + wififacechecktype = Util.null2String(rs.getString("wififacechecktype")); + self_shift = Util.null2String(rs.getString("self_shift")); + auto_checkin = Util.null2String(rs.getString("auto_checkin"),"0"); + auto_checkin_before = Util.null2String(rs.getString("auto_checkin_before"),"30"); + auto_checkin_after = Util.null2String(rs.getString("auto_checkin_after"),"30"); + auto_checkout = Util.null2String(rs.getString("auto_checkout"),"0"); + auto_checkout_before = Util.null2String(rs.getString("auto_checkout_before"),"5"); + auto_checkout_after = Util.null2String(rs.getString("auto_checkout_after"),"60"); + calmethod = Util.null2s(rs.getString("calmethod"),"1"); + isPhotoPunchEnabled = Util.null2s(rs.getString("isPhotoPunchEnabled"),"0"); + abnormalremind = Util.null2String(rs.getString("abnormalremind")); + } + if("0".equals(overtimeType)){ + String dbtype = rs.getDBType(); + String overSql = "select * from kq_overtimerules where ','+convert(varchar(2000),groupids)+',' like '%," + id + ",%' and (isDelete is null or isDelete!=1) "; + if ("oracle".equalsIgnoreCase(dbtype)) { + overSql = "select * from kq_overtimerules where "+SQLUtil.filteSql(rs.getDBType(), " ','+groupids+',' like '%," + id + ",%' and (isDelete is null or isDelete!=1) "); + }else if("mysql".equalsIgnoreCase(dbtype)){ + overSql = "select * from kq_overtimerules where CONCAT(',',cast(groupids as char),',') like '%,"+id+",%' and (isDelete is null or isDelete!=1) "; + }else if ("postgresql".equalsIgnoreCase(dbtype)) { + overSql = "select * from kq_overtimerules where CONCAT(',',groupids,',') like '%,"+id+",%' and (isDelete is null or isDelete!=1) "; + } + Map map = new HashMap(); + rs.execute(overSql); + if(rs.next()){ + String oId = rs.getString("id"); + overtimeRuleId = oId; + String name = rs.getString("name"); + map.put("id", oId); + map.put("name", name); + replaceDatas.add(map); + } + } + } + + if(tabKey.equals("1")){ + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("groupname"); + hrmFieldBean.setFieldlabel("388700"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(groupname); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("excludeid"); + hrmFieldBean.setFieldlabel("388703"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("17"); + hrmFieldBean.setFieldvalue(excludeid); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("overtime_type"); + hrmFieldBean.setFieldlabel("388881"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("3"); + options = new ArrayList(); + options.add(new SearchConditionOption("0",SystemEnv.getHtmlLabelName(126821, user.getLanguage()),overtimeType.equals("0"))); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(546276, user.getLanguage()),overtimeType.equals("1"))); + hrmFieldBean.setSelectOption(options); + hrmFieldBean.setFieldvalue(overtimeType); + hrmFieldBean.setViewAttr(2); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("overtime_rule_id"); + hrmFieldBean.setFieldlabel("388881"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("kqovertimerule"); + hrmFieldBean.setFieldvalue(overtimeRuleId); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("excludecount"); + hrmFieldBean.setFieldlabel("507794"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(excludecount); + lsField.add(hrmFieldBean); + + //增加有效期设置 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("validity"); + hrmFieldBean.setFieldlabel("15030"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(validity); + lsField.add(hrmFieldBean); + + //考勤异常提醒 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("abnormalremind"); + hrmFieldBean.setFieldlabel("547511"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(abnormalremind); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("validityfromdate"); + hrmFieldBean.setFieldlabel("742"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(validityfromdate); + hrmFieldBean.setRules("required|string"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setIsFormField(true); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("validityenddate"); + hrmFieldBean.setFieldlabel("743"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(validityenddate); + hrmFieldBean.setRules("required|string"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setIsFormField(true); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("self_shift"); + hrmFieldBean.setFieldlabel("517026"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(self_shift); + lsField.add(hrmFieldBean); + + String defaultSubcompanyid = ""; + if(hrmdetachable){ + CheckSubCompanyRight newCheck=new CheckSubCompanyRight(); + int[] subcomids = newCheck.getSubComByUserRightId(user.getUID(),"HrmKQGroup:Add",0); + ManageDetachComInfo detachComInfo = new ManageDetachComInfo(); + if(detachComInfo.isUseHrmManageDetach()){ + defaultSubcompanyid = detachComInfo.getHrmdftsubcomid(); + }else{ + rs.executeProc("SystemSet_Select",""); + if(rs.next()){ + if(subcompanyid.length()==0||subcompanyid.equals("0")){ + defaultSubcompanyid = Util.null2String(rs.getString("dftsubcomid")); + } + } + } + + boolean hasRight = false; + for (int i = 0; subcomids!=null&& i < subcomids.length; i++) { + if((""+subcomids[i]).equals(defaultSubcompanyid)){ + hasRight = true; + break; + } + } + + if(!hasRight){ + defaultSubcompanyid = ""; + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("subcompanyid"); + hrmFieldBean.setFieldlabel("19799"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("169"); + hrmFieldBean.setFieldvalue(subcompanyid.length()==0&&id.length()==0?defaultSubcompanyid:subcompanyid); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|integer"); + lsField.add(hrmFieldBean); + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("kqtype"); + hrmFieldBean.setFieldlabel("388704"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("3"); + hrmFieldBean.setFieldvalue(kqtype); + + options = new ArrayList(); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(500385, user.getLanguage()),kqtype.equals("1"))); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(500386, user.getLanguage()),kqtype.equals("2"))); + options.add(new SearchConditionOption("3",SystemEnv.getHtmlLabelName(500387, user.getLanguage()),kqtype.equals("3"))); + hrmFieldBean.setSelectOption(options); + hrmFieldBean.setViewAttr(id.length()>0?1:2); + lsField.add(hrmFieldBean); + + //固定班制 + retmap.put("fixedSchedulce",getFixedSchedulce()); + //排班制 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("serialids"); + hrmFieldBean.setFieldlabel("389098"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("mkqshift"); + hrmFieldBean.setFieldvalue(serialids); + lsField.add(hrmFieldBean); + retmap.put("shiftSchedulceTable",getShiftSchedulceTable()); + + //自由班制 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("weekday"); + hrmFieldBean.setFieldlabel("389097"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(weekday); + options = new ArrayList(); + for(int i=0;i<7;i++){ + options.add(new SearchConditionOption(""+i,UtilKQ.getWeekDay(i,user.getLanguage()),lsWeekday.contains(i))); + } + hrmFieldBean.setSelectOption(options); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("signstart"); + hrmFieldBean.setFieldlabel("16039"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("19"); + hrmFieldBean.setFieldvalue(signstart); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("workhour"); + hrmFieldBean.setFieldlabel("390053"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(workhour); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|numeric"); + otherparam = new HashMap(); + otherparam.put("min","1"); + otherparam.put("precision",1); + otherparam.put("max","24"); + hrmFieldBean.setOtherparam(otherparam); + lsField.add(hrmFieldBean); + + if(id.length()>0){ +// 编辑的时候只有弹性的显示这个说明 + if(kqtype.equals("3")){ + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("calmethod"); + hrmFieldBean.setFieldlabel("529683"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("3"); + hrmFieldBean.setFieldvalue(calmethod); + + options = new ArrayList(); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(529686, user.getLanguage()),calmethod.equals("1"))); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(529685, user.getLanguage()),calmethod.equals("2"))); + hrmFieldBean.setSelectOption(options); + hrmFieldBean.setViewAttr(3); + lsField.add(hrmFieldBean); + } + }else{ + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("calmethod"); + hrmFieldBean.setFieldlabel("529683"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("3"); + hrmFieldBean.setFieldvalue(calmethod); + + options = new ArrayList(); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(529686, user.getLanguage()),calmethod.equals("1"))); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(529685, user.getLanguage()),calmethod.equals("2"))); + hrmFieldBean.setSelectOption(options); + hrmFieldBean.setViewAttr(3); + lsField.add(hrmFieldBean); + } + + if(id.length()>0){ +// 编辑的时候只有弹性的显示这个说明 + if(kqtype.equals("3")){ + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("desc"); + hrmFieldBean.setFieldlabel("85"); + hrmFieldBean.setFieldhtmltype("8"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(SystemEnv.getHtmlLabelName(520468, Util.getIntValue(user.getLanguage())) + +"
"+SystemEnv.getHtmlLabelName(520469, Util.getIntValue(user.getLanguage())) + +"
"+SystemEnv.getHtmlLabelName(520859, Util.getIntValue(user.getLanguage()))); + hrmFieldBean.setViewAttr(1); + lsField.add(hrmFieldBean); + } + }else{ + //新增的时候需要前端控制显示这个字段 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("desc"); + hrmFieldBean.setFieldlabel("85"); + hrmFieldBean.setFieldhtmltype("8"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(SystemEnv.getHtmlLabelName(520468, Util.getIntValue(user.getLanguage())) + +"
"+SystemEnv.getHtmlLabelName(520469, Util.getIntValue(user.getLanguage())) + +"
"+SystemEnv.getHtmlLabelName(520859, Util.getIntValue(user.getLanguage()))); + hrmFieldBean.setViewAttr(1); + lsField.add(hrmFieldBean); + } + + fieldGroups.put("1361", lsField); + }else if(tabKey.equals("2")){ + //signintype,ipscope,locationcheck,locationcheckscope,wificheck + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("signintype"); + hrmFieldBean.setFieldlabel("388708"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("3"); + hrmFieldBean.setFieldvalue(signintype); + options = new ArrayList(); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(389938, user.getLanguage()),signintype.equals("1"))); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(388710, user.getLanguage()),signintype.equals("2"))); + options.add(new SearchConditionOption("3",SystemEnv.getHtmlLabelName(389939, user.getLanguage()),signintype.equals("3"))); + options.add(new SearchConditionOption("4",SystemEnv.getHtmlLabelName(502765, user.getLanguage()),signintype.equals("4"))); + hrmFieldBean.setSelectOption(options); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("ipscope_v4_pc"); + hrmFieldBean.setFieldlabel("388712"); + hrmFieldBean.setFieldlabelname(SystemEnv.getHtmlLabelName(388712, Util.getIntValue(user.getLanguage()))+"( ipv4 )"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(ipscope_v4_pc); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("ipscope_v4_em"); + hrmFieldBean.setFieldlabel("388712"); + hrmFieldBean.setFieldlabelname(SystemEnv.getHtmlLabelName(388712, Util.getIntValue(user.getLanguage()))+"( ipv4 )"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(ipscope_v4_em); + lsField.add(hrmFieldBean); + +// hrmFieldBean = new HrmFieldBean(); +// hrmFieldBean.setFieldname("ipscope_v6_pc"); +// hrmFieldBean.setFieldlabel("388712"); +// hrmFieldBean.setFieldlabelname(SystemEnv.getHtmlLabelName(388712,weaver.general.Util.getIntValue(user.getLanguage()))+"( ipv6 )"); +// hrmFieldBean.setFieldhtmltype("1"); +// hrmFieldBean.setType("1"); +// hrmFieldBean.setFieldvalue(ipscope_v6_pc); +// lsField.add(hrmFieldBean); +// +// hrmFieldBean = new HrmFieldBean(); +// hrmFieldBean.setFieldname("ipscope_v6_em"); +// hrmFieldBean.setFieldlabel("388712"); +// hrmFieldBean.setFieldlabelname(SystemEnv.getHtmlLabelName(388712,weaver.general.Util.getIntValue(user.getLanguage()))+"( ipv6 )"); +// hrmFieldBean.setFieldhtmltype("1"); +// hrmFieldBean.setType("1"); +// hrmFieldBean.setFieldvalue(ipscope_v6_em); +// lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("outsidesign"); + hrmFieldBean.setFieldlabel("390302"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setTip(SystemEnv.getHtmlLabelNames("545433,545434,545435" ,user.getLanguage())); + hrmFieldBean.setFieldvalue(outsidesign); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("isPhotoPunchEnabled"); + hrmFieldBean.setFieldlabel("547013"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(isPhotoPunchEnabled); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("outsignapprove"); + hrmFieldBean.setFieldlabel("545427"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setTip(SystemEnv.getHtmlLabelName(545466,user.getLanguage())); + hrmFieldBean.setFieldvalue(outsignapprove); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("locationcheck"); + hrmFieldBean.setFieldlabel("388713"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(locationcheck); + lsField.add(hrmFieldBean); + +// hrmFieldBean = new HrmFieldBean(); +// hrmFieldBean.setFieldname("locationcheckscope"); +// hrmFieldBean.setFieldlabel("388714"); +// hrmFieldBean.setFieldhtmltype("5"); +// hrmFieldBean.setType("1"); +// hrmFieldBean.setFieldvalue(locationcheckscope); +// options = new ArrayList(); +// options.add(new SearchConditionOption("50","50"+SystemEnv.getHtmlLabelName(125675, user.getLanguage()),locationcheckscope.equals("50"))); +// options.add(new SearchConditionOption("100","100"+SystemEnv.getHtmlLabelName(125675, user.getLanguage()),locationcheckscope.equals("100"))); +// options.add(new SearchConditionOption("200","200"+SystemEnv.getHtmlLabelName(125675, user.getLanguage()),locationcheckscope.equals("200"))); +// options.add(new SearchConditionOption("300","300"+SystemEnv.getHtmlLabelName(125675, user.getLanguage()),locationcheckscope.equals("300"))); +// options.add(new SearchConditionOption("400","400"+SystemEnv.getHtmlLabelName(125675, user.getLanguage()),locationcheckscope.equals("400"))); +// options.add(new SearchConditionOption("500","500"+SystemEnv.getHtmlLabelName(125675, user.getLanguage()),locationcheckscope.equals("500"))); +// options.add(new SearchConditionOption("600","600"+SystemEnv.getHtmlLabelName(125675, user.getLanguage()),locationcheckscope.equals("600"))); +// options.add(new SearchConditionOption("700","700"+SystemEnv.getHtmlLabelName(125675, user.getLanguage()),locationcheckscope.equals("700"))); +// options.add(new SearchConditionOption("800","800"+SystemEnv.getHtmlLabelName(125675, user.getLanguage()),locationcheckscope.equals("800"))); +// options.add(new SearchConditionOption("900","900"+SystemEnv.getHtmlLabelName(125675, user.getLanguage()),locationcheckscope.equals("900"))); +// options.add(new SearchConditionOption("1000","1000"+SystemEnv.getHtmlLabelName(125675, user.getLanguage()),locationcheckscope.equals("1000"))); +// hrmFieldBean.setSelectOption(options); +// lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("locationfacecheck"); + hrmFieldBean.setFieldlabel("507921"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(locationfacecheck); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("locationfacechecktype"); + hrmFieldBean.setFieldlabel("537091"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(locationfacechecktype); + options = new ArrayList(); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(537092,user.getLanguage()),true)); + if("1".equals(settings.getSecondCL())){ + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(537093,user.getLanguage()))); + } + + hrmFieldBean.setSelectOption(options); + hrmFieldBean.setTip(SystemEnv.getHtmlLabelName(537095,user.getLanguage())); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("locationshowaddress"); + hrmFieldBean.setFieldlabel("507922"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(locationshowaddress); + hrmFieldBean.setTip(SystemEnv.getHtmlLabelName(507990,user.getLanguage())); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("wificheck"); + hrmFieldBean.setFieldlabel("388715"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(wificheck); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("wififacecheck"); + hrmFieldBean.setFieldlabel("507921"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(wififacecheck); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("wififacechecktype"); + hrmFieldBean.setFieldlabel("537091"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(wififacechecktype); + options = new ArrayList(); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(537092,user.getLanguage()))); + if("1".equals(settings.getSecondCL())){ + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(537093,user.getLanguage()))); + } + hrmFieldBean.setSelectOption(options); + hrmFieldBean.setTip(SystemEnv.getHtmlLabelName(537095,user.getLanguage())); + lsField.add(hrmFieldBean); + + if(!"3".equalsIgnoreCase(kqtype)){ + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("auto_checkin"); + hrmFieldBean.setFieldlabel("518736"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(Util.null2s(auto_checkin,"0")); + hrmFieldBean.setTip(SystemEnv.getHtmlLabelName(521383,user.getLanguage())); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("auto_checkin_before"); + hrmFieldBean.setFieldlabel("518737"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(Util.null2s(auto_checkin_before,"30")); + hrmFieldBean.setRules("required|integer"); + otherparam = new HashMap(); + otherparam.put("min","1"); + hrmFieldBean.setOtherparam(otherparam); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("auto_checkin_after"); + hrmFieldBean.setFieldlabel("518737"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(Util.null2s(auto_checkin_after,"30")); + hrmFieldBean.setRules("required|integer"); + otherparam = new HashMap(); + otherparam.put("min","0"); + hrmFieldBean.setOtherparam(otherparam); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("auto_checkout"); + hrmFieldBean.setFieldlabel("518738"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(Util.null2s(auto_checkout,"0")); + hrmFieldBean.setTip(SystemEnv.getHtmlLabelName(521383,user.getLanguage())); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("auto_checkout_before"); + hrmFieldBean.setFieldlabel("518739"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(Util.null2s(auto_checkout_before,"5")); + hrmFieldBean.setRules("required|integer"); + otherparam = new HashMap(); + otherparam.put("min","0"); + hrmFieldBean.setOtherparam(otherparam); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("auto_checkout_after"); + hrmFieldBean.setFieldlabel("518739"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(Util.null2s(auto_checkout_after,"60")); + hrmFieldBean.setRules("required|integer"); + otherparam = new HashMap(); + otherparam.put("min","0"); + hrmFieldBean.setOtherparam(otherparam); + lsField.add(hrmFieldBean); + } + + fieldGroups.put("20331", lsField); + retmap.put("locationSessionKey",getKQLocationList("")); + retmap.put("wifiSessionKey",getKQWifiList("")); + Map helpTipMap = Maps.newHashMap(); + helpTipMap.put("auto_checkin_before", SystemEnv.getHtmlLabelName(521211, user.getLanguage())); + helpTipMap.put("auto_checkout_before", SystemEnv.getHtmlLabelName(521211, user.getLanguage())); + retmap.put("helpTipMap",helpTipMap); + + } + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + Iterator>> iter = fieldGroups.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry> entry = iter.next(); + String grouplabel = entry.getKey(); + List fields = entry.getValue(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("defaultshow", true); + + itemlist = new ArrayList(); + for (int j = 0; j < fields.size(); j++) { + hrmFieldBean = fields.get(j); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if(hrmFieldBean.getFieldname().equals("subcompanyid")){ + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "HrmKQGroup:Add"); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("rightStr", "HrmKQGroup:Add"); + } + if(hrmFieldBean.getFieldname().equals("overtime_rule_id")){ + if(CollectionUtils.isNotEmpty(replaceDatas)){ + searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas); + } + } + if(hrmFieldBean.getFieldname().equals("overtime_type")){ + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(546300, user.getLanguage())); + } + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + retmap.put("formField", grouplist); + retmap.put("status", "1"); + int operatelevel = -1; + if(hrmdetachable){ + if(subcompanyid.length()>0 && !subcompanyid.equalsIgnoreCase("0")){ + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + operatelevel=checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"HrmKQGroup:Add",Util.getIntValue(subcompanyid,-1)); + } + }else{ + operatelevel = 2; + } + + if(user.getUID() == 1 || subcompanyid.length()==0 || subcompanyid.equalsIgnoreCase("0")){ + operatelevel = 2; + } + if(operatelevel > 0){ + retmap.put("canAdd", true); + }else{ + retmap.put("canAdd", false); + } + retmap.put("kqtype", kqtype); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + public String getKQLocationList(String locationname){ + String sessionKey = ""; + String groupId = Util.null2String(params.get("id")); + String backFields = " id,locationname,longitude,latitude,address,checkscope "; + String sqlFrom = " kq_location "; + String sqlWhere = " where groupid= "+groupId; + String orderby = " id " ; + String tableString = ""; + + if (locationname.length() > 0){ + sqlWhere += " and locationname like '%"+locationname+"%' "; + } + + String pageUid = PageUidFactory.getHrmPageUid("KQLocationList"); + + tableString=""+ + ""+ + ""+ + ""+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + ""+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionKey, tableString); + + return sessionKey; + } + + public String getKQWifiList(String wifiname){ + String sessionKey = ""; + String groupId = Util.null2String(params.get("id")); + String backFields = " id,wifiname,mac "; + String sqlFrom = " kq_wifi "; + String sqlWhere = " where groupid= "+groupId; + String orderby = " id " ; + String tableString = ""; + + if (wifiname.length() > 0){ + sqlWhere += " and wifiname like '%"+wifiname+"%' "; + } + + String pageUid = PageUidFactory.getHrmPageUid("KQLocationList"); + + tableString=""+ + ""+ + ""+ + ""+ + " "+ + " "+ + " "+ + ""+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionKey, tableString); + + return sessionKey; + } + + /** + * 固定班制 + * @return + */ + public Map getFixedSchedulce(){ + Map fixedSchedulce = new HashMap<>(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + String groupid = Util.null2String(params.get("id")); + //固定班次 + Map table = new HashMap(); + List columns = new ArrayList(); + Map column = null; + LinkedList> datas = new LinkedList>(); + Map data = null; + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelName(28387, user.getLanguage())); + column.put("dataIndex", "weekday"); + column.put("width", "30%"); + columns.add(column); + + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelName(388984, user.getLanguage())); + column.put("dataIndex", "serialinfo"); + column.put("width", "40%"); + columns.add(column); + + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelName(104, user.getLanguage())); + column.put("dataIndex", "operate"); + column.put("width", "30%"); + columns.add(column); + + if(groupid.length()>0){ + List lsWeeks = new ArrayList<>(); + + sql = " select * from kq_fixedschedulce where groupid = ? order by weekday asc "; + rs.executeQuery(sql,groupid); + while(rs.next()){ + data = new HashMap(); + data.put("id",rs.getString("id")); + data.put("weekday",UtilKQ.getWeekDay(rs.getInt("weekday"),user.getLanguage())); + data.put("serialid",rs.getString("serialid")); + data.put("serialinfo",shiftManagementToolKit.getShiftOnOffWorkSections(rs.getString("serialid"),user.getLanguage())); + datas.add(data); + lsWeeks.add(rs.getInt("weekday")); + } + + //加强性修改 + for(int i=0;i<7;i++){ + if(!lsWeeks.contains(i)){ + data = new HashMap(); + data.put("id",i); + data.put("weekday",UtilKQ.getWeekDay(i,user.getLanguage())); + data.put("serialid",""); + data.put("serialinfo",SystemEnv.getHtmlLabelName(26593, user.getLanguage())); + datas.add(data); + } + } + }else{ + for(int i=0;i<7;i++){ + data = new HashMap(); + data.put("id",i); + data.put("weekday",UtilKQ.getWeekDay(i,user.getLanguage())); + data.put("serialid",""); + data.put("serialinfo",SystemEnv.getHtmlLabelName(26593, user.getLanguage())); + datas.add(data); + } + } + fixedSchedulce.put("columns",columns); + fixedSchedulce.put("datas",datas); + + }catch (Exception e){ + writeLog(e); + } + return fixedSchedulce; + } + + /** + * 排班制 + * @return + */ + public Map getShiftSchedulceTable(){ + Map shiftSchedulce = new HashMap<>(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + String groupid = Util.null2String(params.get("id")); + //排班制 + List columns = new ArrayList(); + Map column = null; + LinkedList> datas = new LinkedList>(); + Map data = null; + + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelName(388722, user.getLanguage())); + column.put("dataIndex", "shiftcyclename"); + column.put("width", "30%"); + columns.add(column); + + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelName(500480, user.getLanguage())); + column.put("dataIndex", "serial"); + column.put("width", "30%"); + columns.add(column); + + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelName(500481, user.getLanguage())); + column.put("dataIndex", "shiftcycleday"); + column.put("width", "20%"); + columns.add(column); + + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelName(30585, user.getLanguage())); + column.put("dataIndex", "operate"); + column.put("width", "20%"); + columns.add(column); + + if(groupid.length()>0){ + sql = " select id,shiftcyclename,shiftcycleserialids,groupid from kq_group_shiftcycle where groupid = ? order by id asc "; + rs.executeQuery(sql,groupid); + while(rs.next()){ + data = new HashMap(); + data.put("id",rs.getString("id")); + data.put("shiftcyclename",rs.getString("shiftcyclename")); + data.put("serial",rs.getString("shiftcycleserialids")); + data.put("shiftcycleday",Util.splitString(Util.null2String(rs.getString("shiftcycleserialids")),",").length); + datas.add(data); + } + } + shiftSchedulce.put("columns",columns); + shiftSchedulce.put("datas",datas); + }catch (Exception e){ + writeLog(e); + } + return shiftSchedulce; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/group/GetGroupMemberConditionCmd.java b/src/com/engine/kq/cmd/group/GetGroupMemberConditionCmd.java new file mode 100644 index 0000000..5430b83 --- /dev/null +++ b/src/com/engine/kq/cmd/group/GetGroupMemberConditionCmd.java @@ -0,0 +1,109 @@ +package com.engine.kq.cmd.group; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.bean.WeaRadioGroup; +import com.api.hrm.util.HrmAdvancedSearchUtil; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.common.service.HrmCommonService; +import com.engine.common.service.impl.HrmCommonServiceImpl; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQReportFieldComInfo; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; +import java.util.Map.Entry; + +public class GetGroupMemberConditionCmd extends AbstractCommonCommand> { + + public GetGroupMemberConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List lsCondition = new ArrayList(); + String[] options = null; + String[] selectLinkageDatas = null; + + try { + //必要的权限判断 + if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + int uid = user.getUID(); + ResourceComInfo rci = new ResourceComInfo(); + String subcompanyid = rci.getSubCompanyID("" + uid); + String departmentid = rci.getDepartmentID("" + uid); + + HrmAdvancedSearchUtil hrmAdvancedSearchUtil = new HrmAdvancedSearchUtil(); + HrmCommonService hrmCommonService = new HrmCommonServiceImpl(); + + WeaRadioGroup radioGroup = null; + //数据范围 + if (hrmCommonService.isManager(user.getUID())) { + options = new String[]{"0,140,true", "1,141,false", "2,124,false", "3,1867,false", "4,15089,false"}; + } else { + options = new String[]{"0,140,true", "1,141,false", "2,124,false", "3,1867,false"}; + } + + selectLinkageDatas = new String[]{"1,subcompanyId,141,3,194", "2,departmentId,124,3,57", "3,resourceId,1867,3,17", "4,allLevel,389995,4,1"}; + if (user.getUID() != 1) { + selectLinkageDatas[0] = "1,subcompanyId,141,3,194," + subcompanyid; + selectLinkageDatas[1] = "2,departmentId,124,3,57," + departmentid; + selectLinkageDatas[2] = "3,resourceId,1867,3,17," + uid; + options[0] = "0,140,false"; + options[3] = "3,1867,true"; + } + radioGroup = hrmAdvancedSearchUtil.getAdvanceCondition("viewScope", "34102", options, selectLinkageDatas, user); + radioGroup.setLabelcol(3); + radioGroup.setFieldcol(20); + lsCondition.add(radioGroup); + + //所属考勤组 + options = new String[]{"0,332,true", "1,514133,false", "2,515133,false"}; + selectLinkageDatas = new String[]{"2,groupId,390221,3,kqgroup"}; + radioGroup = hrmAdvancedSearchUtil.getAdvanceCondition("groupType", "515132", options, selectLinkageDatas, user); + SearchConditionItem condition = (SearchConditionItem)radioGroup.getSelectLinkageDatas().get("2"); + Map conditionParams = new HashMap<>(); + conditionParams.put("advance", "1"); + Map dataParams = new HashMap<>(); + dataParams.put("advance", "1"); + Map completeParams = new HashMap<>(); + completeParams.put("includeAll", "1"); + condition.getBrowserConditionParam().setConditionDataParams(conditionParams); + condition.getBrowserConditionParam().setDataParams(dataParams); + condition.getBrowserConditionParam().setCompleteParams(completeParams); + condition.getBrowserConditionParam().setQuickSearchName("groupname"); + radioGroup.getSelectLinkageDatas().put("2", condition); + lsCondition.add(radioGroup); + + retmap.put("status", "1"); + retmap.put("conditions", lsCondition); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/group/GetGroupMemberListCmd.java b/src/com/engine/kq/cmd/group/GetGroupMemberListCmd.java new file mode 100644 index 0000000..5938756 --- /dev/null +++ b/src/com/engine/kq/cmd/group/GetGroupMemberListCmd.java @@ -0,0 +1,353 @@ +package com.engine.kq.cmd.group; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.util.PageUidFactory; +import com.engine.personalIncomeTax.util.PITUtil; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.companyvirtual.DepartmentVirtualComInfo; +import weaver.hrm.companyvirtual.SubCompanyVirtualComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 获取考勤组管理tab页签 + * + * @author pzy + */ +public class GetGroupMemberListCmd extends AbstractCommonCommand> { + + public GetGroupMemberListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + try { + //必要的权限判断 + if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + //数据范围参数 + String viewScope = Util.null2String(params.get("viewScope")); + String subcompanyId = Util.null2String(params.get("subcompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + String resourceId = Util.null2String(params.get("resourceId")); + String allLevel = Util.null2String(params.get("allLevel")); + //所属考勤组参数 + String groupType = Util.null2String(params.get("groupType")); + String groupId = Util.null2String(params.get("groupId")); + //分页参数 + int pageIndex = Util.getIntValue(Util.null2String(params.get("pageIndex")), 1); + int pageSize = Util.getIntValue(Util.null2String(params.get("pageSize")), 10); + + String orderBySql = ""; + String orderParams = Util.null2String(params.get("orderParams")); + if(!"".equals(orderParams)) { + JSONArray records = JSON.parseArray(orderParams); + List> params = new ArrayList>(); + for (int i = 0; i < records.size(); i++) { + JSONObject r = (JSONObject) records.get(i); + String orderKey = Util.null2String(r.get("orderKey")); + String orderType = Util.null2String(r.get("orderType")); + if ("".equals(orderBySql)) + orderBySql += " order by " + orderKey + " " + orderType; + else + orderBySql += ", " + orderKey + " " + orderType; + } + } + + int total = 0; + + String groupMemberSql = ""; + String sqlWhere = ""; + + ResourceComInfo resourceComInfo = new ResourceComInfo(); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + SubCompanyVirtualComInfo subCompanyVirtualComInfo = new SubCompanyVirtualComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + DepartmentVirtualComInfo departmentVirtualComInfo = new DepartmentVirtualComInfo(); + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + Map groupParams = new HashMap<>(); + + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + if (hrmdetachable) { + int[] arrSubcompanyids = checkSubCompanyRight.getSubComByUserRightId(user.getUID(), "HrmKQGroup:Add"); + String subcompanyids = ""; + if (user.getUID() != 1) { + for (int i = 0; arrSubcompanyids != null && i < arrSubcompanyids.length; i++) { + if (subcompanyids.length() > 0) subcompanyids += ","; + subcompanyids += arrSubcompanyids[i]; + } + if (subcompanyids.length() > 0) { + sqlWhere += " and subcompanyid1 in (" + subcompanyids + ")"; + } else { + sqlWhere += " and 1 = 2 "; + } + } + } + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + }else{ + sqlWhere += " and status in (0,1,2,3) "; + } + + switch (viewScope) { + case "1": + if (subcompanyId.length() > 0) { + sqlWhere += " and " + Util.getSubINClause(subcompanyId, "subcompanyId1", "IN"); + } + break; + case "2": + if (!"".equals(departmentId)) { + sqlWhere += " and " + Util.getSubINClause(departmentId, "departmentid", "IN"); + } + break; + case "3": + if (!"".equals(resourceId)) { + sqlWhere += " and " + Util.getSubINClause(resourceId, "id", "IN"); + } + break; + case "4": + if (allLevel.equals("1")) { + sqlWhere += " and ( managerStr like '%," + user.getUID() + ",%' )"; + } else { + sqlWhere += " and ( managerid = " + user.getUID() + ")"; + } + break; + } + + switch (groupType) { + case "2": + groupParams.put("groupId", groupId); + groupMemberSql = kqGroupBiz.getGroupMemberSql(groupParams); + break; + default: + groupMemberSql = kqGroupBiz.getGroupMemberSql(groupParams); + break; + } + + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + +// List resourceIds = new ArrayList<>(); +// for (String key : groupMemberMap.keySet()) +// resourceIds.add(key); + + String inSqlWhere = " and id in (select resourceid from (" + groupMemberSql + ") t1)";// + Util.getSubINClause(String.join(",", resourceIds), "id", "IN"); + String notInSqlWhere = " and id not in (select resourceid from (" + groupMemberSql + ") t1)";//" and " + Util.getSubINClause(String.join(",", resourceIds), "id", "NOT IN"); + + //数据列定义 + List columns = new ArrayList(); + Map column = new HashMap();//姓名 + column.put("title", SystemEnv.getHtmlLabelName(25034,weaver.general.Util.getIntValue(user.getLanguage()))); + column.put("dataIndex", "lastname"); + column.put("key", "lastname"); + column.put("width", "15%"); + columns.add(column); + + column = new HashMap();//部门 + column.put("title", SystemEnv.getHtmlLabelName(1933,weaver.general.Util.getIntValue(user.getLanguage()))); + column.put("dataIndex", "workcode"); + column.put("key", "workcode"); + column.put("width", "15%"); + columns.add(column); + + column = new HashMap();//部门 + column.put("title", SystemEnv.getHtmlLabelName(124,weaver.general.Util.getIntValue(user.getLanguage()))); + column.put("dataIndex", "departmentid"); + column.put("key", "departmentid"); + column.put("width", "20%"); + columns.add(column); + + column = new HashMap();//分部 + column.put("title", SystemEnv.getHtmlLabelName(141,weaver.general.Util.getIntValue(user.getLanguage()))); + column.put("dataIndex", "subcompanyid1"); + column.put("key", "subcompanyid1"); + column.put("width", "20%"); + columns.add(column); + + column = new HashMap();//所属考勤组 + column.put("title", SystemEnv.getHtmlLabelName(515132,weaver.general.Util.getIntValue(user.getLanguage()))); + column.put("dataIndex", "groups"); + column.put("key", "groups"); + column.put("width", "25%"); + columns.add(column); + + column = new HashMap();//生效考勤组 + column.put("title", SystemEnv.getHtmlLabelName(509551,weaver.general.Util.getIntValue(user.getLanguage()))); + column.put("dataIndex", "activeGroup"); + column.put("key", "activeGroup"); + column.put("width", "20%"); + columns.add(column); + + //数据源 + List dataSource = new ArrayList(); + String backFields = "id, lastname, subcompanyid1, departmentid,workcode, dsporder"; + String fromSql = " hrmresource "; + if(groupType.equals("1")) + sqlWhere += notInSqlWhere; + else if(groupType.equals("2")) + sqlWhere += inSqlWhere; + else{} + + String sql = "select count(1) cnt from " + fromSql + " where 1 = 1 " + sqlWhere; + writeLog("queryGroupMemberList-sql:"+sql); + writeLog("queryGroupMemberList-start:" + new Date().getTime()); + rs.executeQuery(sql); + writeLog("queryGroupMemberList-end:" + new Date().getTime()); + while (rs.next()) { + total = Util.getIntValue(rs.getString("cnt"), 0); + } + + sql = backFields + " from " + fromSql + " where 1 = 1 " + sqlWhere; + String orderBy = ("".equals(orderBySql) ? " order by dsporder" : orderBySql); + 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 if (rs.getDBType().equals("postgresql")) { + sql = " select * from (select " + sql + ") t " + orderBy; + sql = "select t1.* from (" + sql + ") t1 limit " + pageSize + " offset " + ((pageIndex - 1) * pageSize); + } + else { + int s = 1 + (pageSize * (pageIndex - 1)); + int e = pageSize * pageIndex; + sql = "select " + backFields + " from (select ROW_NUMBER() over(" + orderBy + ") as row, " + sql + ") t where t.row between " + s + " and " + e; + } + } else { + sql = " select " + sql + orderBy; + } + writeLog("queryGroupMemberList-sql:"+sql); + writeLog("queryGroupMemberList1-start:" + new Date().getTime()); + rs.executeQuery(sql); + writeLog("queryGroupMemberList1-end:" + new Date().getTime()); + while (rs.next()){ + String id = rs.getString("id"); + String lastname = rs.getString("lastname"); + int subcompanyid1 = rs.getInt("subcompanyid1"); + int departmentid = rs.getInt("departmentid"); + String workcode = Util.null2String(rs.getString("workcode")); + String subcompanyName = (subcompanyid1 < 0 ? subCompanyVirtualComInfo.getSubCompanyname("" + subcompanyid1) : subCompanyComInfo.getSubcompanyname("" + subcompanyid1)); + String departmentName = (departmentid < 0 ? departmentVirtualComInfo.getDepartmentname("" + subcompanyid1) : departmentComInfo.getDepartmentName("" + departmentid)); + + Map data = new HashMap<>(); + data.put("id", id); + data.put("lastname", lastname); + data.put("subcompanyid1", subcompanyid1); + data.put("subcompanyName", subcompanyName); + data.put("departmentid", departmentid); + data.put("departmentName", departmentName); + data.put("workcode", workcode); + data.put("activeGroupId", ""); + data.put("activeGroup", ""); + if(hrmdetachable){ + int subCompanyOperatelevel = checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"HrmKQGroup:Add", subcompanyid1); + data.put("canEdit", subCompanyOperatelevel > 0); + }else + data.put("canEdit", true); + if(groupMemberMap.containsKey(id)){ + List groupIds = groupMemberMap.get(id); + List groupNames = new ArrayList<>(); + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + groupNames.add(kqGroupComInfo.getGroupname(i)); + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(id, DateUtil.getCurrentDate())); + + if (i.equals(currentGroupId)) { + data.put("activeGroupId", i); + data.put("activeGroup", kqGroupComInfo.getGroupname(i)); + } + } + } + data.put("groupIds", groupIds); + data.put("groups", groupNames); + }else { + data.put("groupIds", new ArrayList<>()); + data.put("groups", new ArrayList<>()); + } + +// String kqGroupName = groupname; +// String[] splitStr = Util.splitString(otherPara, "+"); +// String groupid = Util.null2String(splitStr[0]); +// String resourceid = Util.null2String(splitStr[1]); +// String kqdate = Util.null2String(splitStr[2]); +// String strLanguage = Util.null2String(splitStr[3]); +// if(resourceid.length()>0){ +// int language = Util.getIntValue(strLanguage,7); +// if(kqdate.length()==0) { +// kqdate = DateUtil.getCurrentDate(); +// } +// String currentGroupId = Util.null2String(new KQGroupMemberComInfo().getKQGroupId(resourceid,kqdate)); +// if(groupid.equals(currentGroupId)) { +// kqGroupName += "("+ SystemEnv.getHtmlLabelName(509551, language)+")"; +// } +// } +// +// String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(id, "")); +// data.put("activeGroupId", currentGroupId); +// data.put("activeGroup", "".equals(currentGroupId) ? "" : kqGroupComInfo.getGroupname(currentGroupId)); + dataSource.add(data); + } + + retmap.put("columns", columns); + retmap.put("dataSource", dataSource); + retmap.put("pageIndex", pageIndex); + retmap.put("total", total); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/group/GetGroupSearchConditionCmd.java b/src/com/engine/kq/cmd/group/GetGroupSearchConditionCmd.java new file mode 100644 index 0000000..131912b --- /dev/null +++ b/src/com/engine/kq/cmd/group/GetGroupSearchConditionCmd.java @@ -0,0 +1,118 @@ +package com.engine.kq.cmd.group; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; +import java.util.Map.Entry; + +public class GetGroupSearchConditionCmd extends AbstractCommonCommand> { + + public GetGroupSearchConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + Map> fieldGroups= new LinkedHashMap>(); + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + List options = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("groupname"); + hrmFieldBean.setFieldlabel("388700"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("kqtype"); + hrmFieldBean.setFieldlabel("388704"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + + options = new ArrayList(); + options.add(new SearchConditionOption("",SystemEnv.getHtmlLabelName(332, user.getLanguage()),true)); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(388705, user.getLanguage()))); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(388706, user.getLanguage()))); + options.add(new SearchConditionOption("3",SystemEnv.getHtmlLabelName(500387, user.getLanguage()))); + hrmFieldBean.setSelectOption(options); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("resourceId"); + hrmFieldBean.setFieldlabel("388736"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("1"); + lsField.add(hrmFieldBean); + fieldGroups.put("1361", lsField); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("kqDate"); + hrmFieldBean.setFieldlabel("33456"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + lsField.add(hrmFieldBean); + fieldGroups.put("1361", lsField); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + Iterator>> iter = fieldGroups.entrySet().iterator(); + while (iter.hasNext()) { + Entry> entry = iter.next(); + String grouplabel = entry.getKey(); + List fields = entry.getValue(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("defaultshow", true); + + itemlist = new ArrayList(); + for (int j = 0; j < fields.size(); j++) { + hrmFieldBean = fields.get(j); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + + retmap.put("status", "1"); + retmap.put("conditions", grouplist); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/group/GetGroupSearchListCmd.java b/src/com/engine/kq/cmd/group/GetGroupSearchListCmd.java new file mode 100644 index 0000000..3491441 --- /dev/null +++ b/src/com/engine/kq/cmd/group/GetGroupSearchListCmd.java @@ -0,0 +1,171 @@ +package com.engine.kq.cmd.group; + +import com.api.browser.bean.SearchConditionOption; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.util.PageUidFactory; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.common.Tools; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +public class GetGroupSearchListCmd extends AbstractCommonCommand> { + + public GetGroupSearchListCmd(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 { + //必要的权限判断 + if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + int operatelevel = 2; + + String subcompanyId = Util.null2String(params.get("subcompanyid")); + if (subcompanyId.equals("0")) subcompanyId = ""; + String resourceId = Util.null2String(params.get("resourceId")); + String kqDate = Util.null2String(params.get("kqDate")); + String groupname = Util.null2String(params.get("groupname")); + String kqtype = Util.null2String(params.get("kqtype")); + + String backFields = " a.id,a.id as id1,a.id as id2,a.groupname,a.subcompanyid,a.kqtype,a.excludeid,a.signintype,a.ipscope,locationcheck,locationcheckscope,wificheck,isdelete "; + String sqlFrom = " kq_group a"; + String sqlWhere = " (isdelete is null or isdelete <> '1') "; + String orderby = " id "; + String tableString = ""; + + if (subcompanyId.length() == 0 &&hrmdetachable) { + int[] arrSubcompanyids = checkSubCompanyRight.getSubComByUserRightId(user.getUID(), "HrmKQGroup:Add"); + String subcompanyids = ""; + if (user.getUID() != 1) { + for (int i = 0; arrSubcompanyids != null && i < arrSubcompanyids.length; i++) { + if (subcompanyids.length() > 0) subcompanyids += ","; + subcompanyids += arrSubcompanyids[i]; + } + if (subcompanyids.length() > 0) { + sqlWhere += " and subcompanyid in(" + subcompanyids + ")"; + } else { + sqlWhere += " and 1=2 "; + } + } + } + + if (subcompanyId.length() > 0) { + sqlWhere += " and subcompanyId = " + subcompanyId; + } + + if (groupname.length() > 0) { + sqlWhere += " and groupname like '%" + groupname + "%' "; + } + if (kqtype.length() > 0) { + sqlWhere += " and kqtype = " + kqtype; + } + + if (resourceId.length() > 0) { + String groupIds = ""; + if("".equals(kqDate)) { + groupIds = new KQGroupMemberComInfo().getKQGroupIds(resourceId); + } else { + groupIds = new KQGroupMemberComInfo().getKQGroupIds(resourceId, kqDate); + } + sqlWhere += " and id in(" + groupIds + ")"; + } + + String pageUid = PageUidFactory.getHrmPageUid("KQGroupSearchList"); + + + String operateString = ""; + if (hrmdetachable && (user.getUID() != 1)) { + operateString += " "; + } else { + operateString += " "; + } + + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + + operateString += " "; + + operateString += " "; + operateString += ""; + String checkboxpopedomString = " "; + if (hrmdetachable && (user.getUID() != 1)) { + checkboxpopedomString= " "; + } + tableString = "" + + "" + + "" + + checkboxpopedomString + operateString + + "" + + " " + + " " + + (hrmdetachable ? "" : "") + + " " + + " " + + " " + + "" + + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + if(hrmdetachable){ + if(subcompanyId.length()>0 && !subcompanyId.equalsIgnoreCase("0")){ + operatelevel=checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"HrmKQGroup:Add",Util.getIntValue(subcompanyId,-1)); + }else{ + operatelevel = 0; + } + } + if(operatelevel>0){ + retmap.put("canAdd", true); + }else{ + retmap.put("canAdd", false); + } + if(operatelevel>1){ + retmap.put("canDel", true); + }else{ + retmap.put("canDel", false); + } + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/group/GetGroupTreeCmd.java b/src/com/engine/kq/cmd/group/GetGroupTreeCmd.java new file mode 100644 index 0000000..05abcba --- /dev/null +++ b/src/com/engine/kq/cmd/group/GetGroupTreeCmd.java @@ -0,0 +1,110 @@ +package com.engine.kq.cmd.group; + +import com.api.hrm.bean.TreeNode; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 考勤组树型 + */ +public class GetGroupTreeCmd extends AbstractCommonCommand> { + + public GetGroupTreeCmd(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 = ""; + TreeNode root = new TreeNode(); + try { + + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + List groupIdList = null; + if (hrmdetachable) { + int[] arrSubcompanyids = checkSubCompanyRight.getSubComByUserRightId(user.getUID(), "HrmKQGroup:Add"); + String subcompanyids = ""; + if (user.getUID() != 1) { + for (int i = 0; arrSubcompanyids != null && i < arrSubcompanyids.length; i++) { + if (subcompanyids.length() > 0) subcompanyids += ","; + subcompanyids += arrSubcompanyids[i]; + } + groupIdList = getGroupIdList(subcompanyids); + } + } + + //查询左侧树 + String keyword = Util.null2String(params.get("keyword")).trim().toLowerCase(); + root.setId("0"); + root.setName(SystemEnv.getHtmlLabelName(390221,user.getLanguage())); + root.setType("0"); + root.setIcon("icon-coms-LargeArea"); + List groups = new ArrayList(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + while (kqGroupComInfo.next()){ + if(keyword.length()>0 && Util.null2String(kqGroupComInfo.getGroupname()).indexOf(keyword)==-1)continue; + if(Util.null2String(kqGroupComInfo.getIsdelete()).equals("1"))continue; +// if(Util.null2String(kqGroupComInfo.getKqtype()).equals("2"))continue; + TreeNode group = new TreeNode(); + String groupId = kqGroupComInfo.getId(); + if(hrmdetachable && groupIdList != null && !groupIdList.contains(groupId)) { + continue; + } + group.setId(groupId); + group.setName(kqGroupComInfo.getGroupname()); + group.setPid("0"); + group.setType("1"); + group.setCanClick(true); + group.setIcon("icon-coms-LargeArea"); + groups.add(group); + } + root.setIsParent(groups.size()>0); + root.setSubs(groups); + + Map treeObj = new HashMap(); + treeObj.put("rootCompany", root); + + retmap.put("datas", treeObj); + retmap.put("status", "1"); + }catch (Exception e){ + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + + private List getGroupIdList(String subcompanyIds) { + List groupIdList = new ArrayList<>(); + RecordSet rs = new RecordSet(); + String sql = "select id from kq_group a where (isdelete is null or isdelete <> '1') and subcompanyid in("+subcompanyIds+")"; + rs.executeQuery(sql); + while (rs.next()) { + groupIdList.add(rs.getString("id")); + } + return groupIdList; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/group/GetMainTabsCmd.java b/src/com/engine/kq/cmd/group/GetMainTabsCmd.java new file mode 100644 index 0000000..684bb43 --- /dev/null +++ b/src/com/engine/kq/cmd/group/GetMainTabsCmd.java @@ -0,0 +1,65 @@ +package com.engine.kq.cmd.group; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 获取考勤组管理tab页签 + * @author pzy + * + */ +public class GetMainTabsCmd extends AbstractCommonCommand>{ + + public GetMainTabsCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try { + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + List> tabs = new ArrayList>(); + Map tab = null; + + tab = new HashMap(); + tab.put("key", "1"); + tab.put("title", SystemEnv.getHtmlLabelName(390221,user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", "2"); + tab.put("title", SystemEnv.getHtmlLabelName(515128,user.getLanguage())); + tabs.add(tab); + + retmap.put("status", "1"); + retmap.put("tabs", tabs); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/group/GetShiftCycleFormCmd.java b/src/com/engine/kq/cmd/group/GetShiftCycleFormCmd.java new file mode 100644 index 0000000..4c71027 --- /dev/null +++ b/src/com/engine/kq/cmd/group/GetShiftCycleFormCmd.java @@ -0,0 +1,119 @@ +package com.engine.kq.cmd.group; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取考勤组 排班周期列表 + */ +public class GetShiftCycleFormCmd extends AbstractCommonCommand> { + + public GetShiftCycleFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map shiftSchedulce = new HashMap<>(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + String cycleserialid = Util.null2String(params.get("id")); + Map> fieldGroups= new LinkedHashMap>(); + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + List options = null; + Map otherparam = null; + + String shiftcyclename = "";//周期名称 + String shiftcycleday = "";//周期天数 + String shiftcycleserialids = "";//考勤班次 + if(cycleserialid.length()>0){ + sql = "select * from kq_group_shiftcycle where id=?"; + rs.executeQuery(sql,cycleserialid); + if(rs.next()){ + shiftcyclename = Util.null2String(rs.getString("shiftcyclename")); + shiftcycleday = Util.null2String(rs.getString("shiftcycleday")); + shiftcycleserialids = Util.null2String(rs.getString("shiftcycleserialids")); + } + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("shiftcyclename"); + hrmFieldBean.setFieldlabel("388722"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + hrmFieldBean.setFieldvalue(shiftcyclename); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("shiftcycleday"); + hrmFieldBean.setFieldlabel("389201"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(shiftcycleday.length()==0?2:shiftcycleday); + otherparam = new HashMap(); + otherparam.put("min","2"); + otherparam.put("max","31"); + hrmFieldBean.setOtherparam(otherparam); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|integer"); + lsField.add(hrmFieldBean); + fieldGroups.put("389128", lsField); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + Iterator>> iter = fieldGroups.entrySet().iterator(); + while (iter.hasNext()) { + Entry> entry = iter.next(); + String grouplabel = entry.getKey(); + List fields = entry.getValue(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("defaultshow", true); + + itemlist = new ArrayList(); + for (int j = 0; j < fields.size(); j++) { + hrmFieldBean = fields.get(j); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + shiftSchedulce.put("formField", grouplist); + shiftSchedulce.put("shiftcycleserialids",shiftcycleserialids); + }catch (Exception e){ + writeLog(e); + } + return shiftSchedulce; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/group/GetTabsCmd.java b/src/com/engine/kq/cmd/group/GetTabsCmd.java new file mode 100644 index 0000000..44be597 --- /dev/null +++ b/src/com/engine/kq/cmd/group/GetTabsCmd.java @@ -0,0 +1,69 @@ +package com.engine.kq.cmd.group; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取考勤组管理tab页签 + * @author pzy + * + */ +public class GetTabsCmd extends AbstractCommonCommand>{ + + public GetTabsCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try { + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + List> tabs = new ArrayList>(); + Map tab = null; + + tab = new HashMap(); + tab.put("key", "1"); + tab.put("title", SystemEnv.getHtmlLabelName(1361,user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", "2"); + tab.put("title", SystemEnv.getHtmlLabelName(388735,user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", "3"); + tab.put("title", SystemEnv.getHtmlLabelName(388736,user.getLanguage())); + tabs.add(tab); + + retmap.put("status", "1"); + retmap.put("tabs", tabs); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/group/ImportExcelCmd.java b/src/com/engine/kq/cmd/group/ImportExcelCmd.java new file mode 100644 index 0000000..e07fa60 --- /dev/null +++ b/src/com/engine/kq/cmd/group/ImportExcelCmd.java @@ -0,0 +1,128 @@ +package com.engine.kq.cmd.group; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLoactionComInfo; +import com.engine.kq.biz.KQWifiComInfo; +import org.apache.poi.ss.usermodel.*; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ImportExcelCmd extends AbstractCommonCommand> { + + public ImportExcelCmd(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 { + //必要的权限判断 + if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + List lsDatas = null; + List datas = null; + + String groupId = Util.null2String(params.get("groupId")); + String filename = Util.null2String(params.get("filename")); + int startRow = 3; + ImageFileManager manager = new ImageFileManager(); + manager.getImageFileInfoById(Util.getIntValue(filename)); + Workbook workbook = WorkbookFactory.create(manager.getInputStream()); + for (int idx = 0; idx < workbook.getNumberOfSheets(); idx++) { + Sheet sheet = workbook.getSheetAt(idx); + Row row = null; + Cell cell = null; + lsDatas = new ArrayList(); + for (int i = startRow; startRow<=sheet.getLastRowNum() && i <= sheet.getLastRowNum(); i++) { + row = sheet.getRow(i); + if (row == null) { + continue; + } + datas = new ArrayList(); + for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) { + cell = row.getCell((short) cellIndex); + if (cell == null) continue; + datas.add(getCellValue(cell).trim()); + } + datas.add(groupId); + if(Util.null2String(datas.get(0)).length()>0){ + lsDatas.add(datas); + } + } + if (idx == 0) { + sql = "insert into kq_location (longitude,latitude,checkscope,address,locationname,groupid) values (?,?,?,?,?,?) "; + } else { + sql = "insert into kq_wifi (wifiname,mac,groupid) values (?,?,?) "; + } + rs.executeBatchSql(sql, lsDatas); + } + new KQLoactionComInfo().removeCache(); + new KQWifiComInfo().removeCache(); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + /** + * /** + * 获取excel单元格值 + * + * @param cell 要读取的单元格对象 + * @return + */ + public String getCellValue(Cell cell) { + String cellValue = ""; + if (cell == null) + return ""; + switch (cell.getCellType()) { + case BOOLEAN: // 得到Boolean对象的方法 + cellValue = String.valueOf(cell.getBooleanCellValue()); + break; + case NUMERIC: + if (DateUtil.isCellDateFormatted(cell)) {// 先看是否是日期格式 + SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd"); + cellValue = String.valueOf(sft.format(cell.getDateCellValue())); // 读取日期格式 + } else { + cellValue = String.valueOf(new Double(cell.getNumericCellValue())); // 读取数字 + if (cellValue.endsWith(".0")) + cellValue = cellValue.substring(0, cellValue.indexOf(".")); + } + break; + case FORMULA: // 读取公式 + cellValue = cell.getCellFormula(); + break; + case STRING: // 读取String + cellValue = cell.getStringCellValue(); + break; + } + + return cellValue; + } +} diff --git a/src/com/engine/kq/cmd/group/SaveAddMemberCmd.java b/src/com/engine/kq/cmd/group/SaveAddMemberCmd.java new file mode 100644 index 0000000..16689a6 --- /dev/null +++ b/src/com/engine/kq/cmd/group/SaveAddMemberCmd.java @@ -0,0 +1,120 @@ +package com.engine.kq.cmd.group; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.common.DateUtil; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.Reminder.KQAutoCardTask; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +/** + * 获取考勤组管理tab页签 + * + * @author pzy + */ +public class SaveAddMemberCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + public SaveAddMemberCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + try { + if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String ids = Util.null2String(params.get("ids")); + String groupId = Util.null2String(params.get("groupId")); + String validateFromDate = KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE; + String validateToDate = KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE; + String sql = "INSERT INTO kq_groupmember (groupid, typevalue, type,validatefrom,validateto) "; + sql += "VALUES (?,?,?,?,?)"; + String type = "1"; + + List list = Util.splitString2List(ids, ","); + List paramList = new ArrayList(); + List param = null; + for(String id : list){ + param = new ArrayList(); + param.add(groupId); + param.add(id); + param.add(type); + param.add(validateFromDate); + param.add(validateToDate); + paramList.add(param); + } + rs.executeBatchSql(sql, paramList); + + //refresh data + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + String kqType = kQGroupComInfo.getKqtype(groupId); + kQGroupComInfo.removeCache(); + new KQGroupMemberComInfo().removeCache(); + if (kqType.equals("1")) new KQFixedSchedulceComInfo().removeCache(); + new KQFormatBiz().formatDateByGroupId(groupId, DateUtil.getCurrentDate()); + + this.boforeLog(groupId); + retmap.put("status", "1"); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + } + return retmap; + } + + private void boforeLog(String id){ + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String mainSql = " select * from kq_group where id= " + id; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("groupname"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_groupmember where groupid="+id; + subLogInfo1.setSubTargetNameColumn("typevalue"); + subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(505654); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + logger.before(logContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + +} diff --git a/src/com/engine/kq/cmd/group/SaveGroupCmd.java b/src/com/engine/kq/cmd/group/SaveGroupCmd.java new file mode 100644 index 0000000..3ba0559 --- /dev/null +++ b/src/com/engine/kq/cmd/group/SaveGroupCmd.java @@ -0,0 +1,618 @@ +package com.engine.kq.cmd.group; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQAutoCheckComInfo; +import com.engine.kq.biz.KQFixedSchedulceComInfo; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.log.KQLog; +import weaver.conn.BatchRecordSet; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.proj.util.SQLUtil; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class SaveGroupCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + SimpleBizLogger.SubLogInfo subLogInfo; + SimpleBizLogger.SubLogInfo subLogInfo1; + public SaveGroupCmd(Map params, User user) { + this.user = user; + this.params = params; + + if (params != null && params.containsKey("data")) { + String datas = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(datas); + String id = Util.null2String(jsonObj.get("id")); + if(id.length()==0) { + id = "-1"; + } + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String mainSql = " select * from kq_group where id= "+id; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("groupname"); + + subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_fixedschedulce where groupid="+id; + subLogInfo1.setSubPrimarykey("id"); + subLogInfo1.setSubTargetNameColumn("weekday"); + subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(505654); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + subLogInfo = logger.getNewSubLogInfo(); + String subSql = " select * from kq_group_shiftcycle where groupid = "+id; + subLogInfo.setSubSql(subSql); + subLogInfo.setSubPrimarykey("id"); + subLogInfo.setSubTargetNameColumn("shiftcyclename"); + subLogInfo.setGroupId("1"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo.setSubGroupNameLabel(389225); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo); + logger.before(logContext); + } + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + KQFixedSchedulceComInfo kqFixedSchedulceComInfo = new KQFixedSchedulceComInfo(); + new KQLog().info("SaveGroupCmd params:"+params); + String datas = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(datas); + String tabKey = Util.null2String(params.get("tabKey"));//分组id + String id = Util.null2String(jsonObj.get("id"));//考勤组id + String groupname = Util.null2String(jsonObj.get("groupname"));//考勤组名称 + String overtimeType = Util.null2String(jsonObj.get("overtime_type"));//加班类型 + String overtimeRuleId = Util.null2String(jsonObj.get("overtime_rule_id"));//加班id + String kqtype = Util.null2String(jsonObj.get("kqtype"));//考勤类型 + String subcompanyid = Util.null2String(jsonObj.get("subcompanyid"));//所属分部 + String excludeid = Util.null2String(jsonObj.get("excludeid"));//考勤组排除人员 + String excludecount = Util.null2String(jsonObj.get("excludecount"));//考勤组排除人员是否参与统计 + String abnormalremind = Util.null2String(jsonObj.get("abnormalremind"));//考勤异常提醒 + String signintype = Util.null2String(jsonObj.get("signintype"));//打卡方式 + String serialids = Util.null2String(jsonObj.get("serialids"));//考勤班次 + String weekday = Util.null2String(jsonObj.get("weekday"));//考勤类型 + String signstart = Util.null2String(jsonObj.get("signstart"));//考勤类型 + String workhour = Util.null2String(jsonObj.get("workhour"));//工作时长 + String ipscope =Util.null2String( jsonObj.get("ipscope"));//应用IP范围 + String calmethod = Util.null2s(Util.null2String(jsonObj.get("calmethod")),"1");//工作时长计算方式 1是打卡时间累加计算 2是打卡时间成对计算 + + String ipscope_v4_pc =Util.null2String( jsonObj.get("ipscope_v4_pc"));//应用IP范围 ipv4 pc端 + String ipscope_v4_em =Util.null2String( jsonObj.get("ipscope_v4_em"));//应用IP范围 ipv4 移动端 + String ipscope_v6_pc =Util.null2String( jsonObj.get("ipscope_v6_pc"));//应用IP范围 ipv6 pc端 + String ipscope_v6_em =Util.null2String( jsonObj.get("ipscope_v6_em"));//应用IP范围 ipv6 移动端 + + String locationcheck = Util.null2String(jsonObj.get("locationcheck"));//启用办公地点考勤 + //String locationcheckscope = Util.null2String(jsonObj.get("locationcheckscope"));//有效范围 + String wificheck = Util.null2String(jsonObj.get("wificheck"));//启用wifi考勤 + String outsidesign = Util.null2String(jsonObj.get("outsidesign"));//允许外勤打卡 + String outsignapprove = Util.null2String(jsonObj.get("outsignapprove"));//外勤打卡需要审批 + String validity = Util.null2String(jsonObj.get("validity"));//考勤组有效期 + String validityfromdate = Util.null2String(jsonObj.get("validityfromdate"));//考勤组有效期开始时间 + String validityenddate = Util.null2String(jsonObj.get("validityenddate"));//考勤组有效期结束时间 + String locationfacecheck = Util.null2String(jsonObj.getString("locationfacecheck"));//办公地点启用人脸识别拍照打卡 + String locationfacechecktype = Util.null2String(jsonObj.getString("locationfacechecktype"));//办公地点启用人脸识别拍照打卡方式 + String locationshowaddress = Util.null2String(jsonObj.getString("locationshowaddress"));//有效识别半径内显示同一地址 + String wififacecheck = Util.null2String(jsonObj.getString("wififacecheck"));//wifi启用人脸识别拍照打卡 + String wififacechecktype = Util.null2String(jsonObj.getString("wififacechecktype"));//wifi启用人脸识别拍照打卡方式 + String self_shift = Util.null2String(jsonObj.getString("self_shift"));//启用员工自我排班 + String auto_checkin = Util.null2String(jsonObj.getString("auto_checkin"));//允许客户端设置自动考勤 上班卡 + String auto_checkout = Util.null2String(jsonObj.getString("auto_checkout"));//允许客户端设置自动考勤 下班卡 + String auto_checkin_before = Util.null2String(jsonObj.getString("auto_checkin_before"));//允许客户端设置自动考勤 上班卡开始分钟数 + String auto_checkin_after = Util.null2String(jsonObj.getString("auto_checkin_after"));//允许客户端设置自动考勤 上班卡结束分钟时 + String auto_checkout_before = Util.null2String(jsonObj.getString("auto_checkout_before"));//允许客户端设置自动考勤 下班卡 下班卡开始分钟数 + String auto_checkout_after = Util.null2String(jsonObj.getString("auto_checkout_after"));//允许客户端设置自动考勤 下班卡 下班卡结束分钟时 + String isPhotoPunchEnabled = Util.null2String(jsonObj.getString("isPhotoPunchEnabled"));//启用考勤拍照打卡 + + if("".equals(id)) { + sql = "select * from kq_group where groupname=? and (isDelete is null or isDelete !=1) "; + rs.executeQuery(sql, groupname); + } else { + sql = "select * from kq_group where groupname=? and id != ? and (isDelete is null or isDelete !=1) "; + rs.executeQuery(sql, groupname, id); + } + if(rs.next()) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(531673, user.getLanguage())); + return retmap; + } + + if("1".equalsIgnoreCase(signintype) || "3".equalsIgnoreCase(signintype)){ + //如果有移动端打卡,但是办公地点和wifi都没开启,也把自动打卡重置 + if(!"1".equalsIgnoreCase(locationcheck) && !"1".equalsIgnoreCase(wificheck)){ + auto_checkin = "0"; + auto_checkout = "0"; + auto_checkin_before = "30"; + auto_checkin_after = "30"; + auto_checkout_before = "5"; + auto_checkout_after = "60"; + } + }else{ + //如果不是移动端打卡,需要把自动打卡重置 + auto_checkin = "0"; + auto_checkout = "0"; + auto_checkin_before = "30"; + auto_checkin_after = "30"; + auto_checkout_before = "5"; + auto_checkout_after = "60"; + } + + List lsParams = new ArrayList<>(); + if(tabKey.equals("1")){ + if(id.length()>0) { + sql = " update kq_group set groupname=?,subcompanyid=?,excludeid=?,excludecount=?,abnormalremind=?,kqtype=?," + + " serialids=?,weekday=?,signstart=?,workhour=?,validity=?,validityfromdate=?,validityenddate=?,self_shift=?,calmethod=?,overtime_type=? " + + " where id=? "; + lsParams.add(groupname.length()==0?null:groupname); + lsParams.add(subcompanyid.length()==0?null:subcompanyid); + lsParams.add(excludeid.length()==0?null:excludeid); + lsParams.add(excludecount.length()==0?null:excludecount); + lsParams.add(abnormalremind.length()==0?null:abnormalremind); + lsParams.add(kqtype.length()==0?null:kqtype); + lsParams.add(serialids.length()==0?null:serialids); + lsParams.add(weekday.length()==0?null:weekday); + lsParams.add(signstart.length()==0?null:signstart); + lsParams.add(workhour.length()==0?null:workhour); + lsParams.add(validity.length()==0?null:validity); + lsParams.add(validityfromdate.length()==0?null:validityfromdate); + lsParams.add(validityenddate.length()==0?null:validityenddate); + lsParams.add(self_shift.length()==0?0:self_shift); + lsParams.add(calmethod.length()==0?"1":calmethod); + lsParams.add(overtimeType.length()==0?"0":overtimeType); + lsParams.add(id); + rs.executeUpdate(sql,lsParams); + if(kqtype.equals("2")){ + this.saveKqTypeInfo(); + } + + }else { + sql = " insert into kq_group (" + + " groupname,subcompanyid,excludeid,excludecount,abnormalremind,kqtype,serialids," + + " weekday,signstart,workhour,signintype,validity,validityfromdate,validityenddate,locationcheckscope,calmethod,overtime_type,self_shift) " + + " values(?,?,?,?,?,?,?, ?,?,?,1,?,?,?,300,?,?,?)"; + lsParams.add(groupname.length()==0?null:groupname); + lsParams.add(subcompanyid.length()==0?null:subcompanyid); + lsParams.add(excludeid.length()==0?null:excludeid); + lsParams.add(excludecount.length()==0?null:excludecount); + lsParams.add(abnormalremind.length()==0?null:abnormalremind); + lsParams.add(kqtype.length()==0?null:kqtype); + lsParams.add(serialids.length()==0?null:serialids); + + lsParams.add(weekday.length()==0?null:weekday); + lsParams.add(signstart.length()==0?null:signstart); + lsParams.add(workhour.length()==0?null:workhour); + lsParams.add(validity.length()==0?null:validity); + lsParams.add(validityfromdate.length()==0?null:validityfromdate); + lsParams.add(validityenddate.length()==0?null:validityenddate); + lsParams.add(calmethod.length()==0?"1":calmethod); + lsParams.add(overtimeType.length()==0?"0":overtimeType); + lsParams.add(self_shift.length()==0?"0":self_shift); + rs.executeUpdate(sql,lsParams); + + rs.executeQuery("select max(id) from kq_group") ; + if(rs.next()){ + id = rs.getString(1); + } + } + params.put("id",id); + this.saveKqTypeInfo(); + + updateOverByGroupId(id,overtimeRuleId,overtimeType); + }else if(tabKey.equals("2")){ + sql = " update kq_group set signintype=?, ipscope_v4_pc=?,ipscope_v4_em=?,ipscope_v6_pc=?,ipscope_v6_em=?,locationcheck=?,wificheck=?,outsidesign=?,outsignapprove=?, " +//locationcheckscope=?, + " locationfacecheck=?,locationfacechecktype=?,locationshowaddress=?,wififacecheck=?,wififacechecktype=?,auto_checkin=?,auto_checkout=?," + + " auto_checkin_before=?,auto_checkin_after=?,auto_checkout_before=?,auto_checkout_after=?,isPhotoPunchEnabled=? where id=? "; + lsParams.add(signintype.length()==0?null:signintype); + lsParams.add(ipscope_v4_pc.length()==0?null:ipscope_v4_pc); + lsParams.add(ipscope_v4_em.length()==0?null:ipscope_v4_em); + lsParams.add(ipscope_v6_pc.length()==0?null:ipscope_v6_pc); + lsParams.add(ipscope_v6_em.length()==0?null:ipscope_v6_em); + lsParams.add(locationcheck.length()==0?null:locationcheck); + //lsParams.add(locationcheckscope.length()==0?null:locationcheckscope); + lsParams.add(wificheck.length()==0?null:wificheck); + lsParams.add(outsidesign.length()==0?null:outsidesign); + lsParams.add(outsignapprove.length()==0?null:outsignapprove); + lsParams.add(locationfacecheck.length()==0?null:locationfacecheck); + lsParams.add(locationfacechecktype.length()==0?null:locationfacechecktype); + lsParams.add(locationshowaddress.length()==0?null:locationshowaddress); + lsParams.add(wififacecheck.length()==0?null:wififacecheck); + lsParams.add(wififacechecktype.length()==0?null:wififacechecktype); + lsParams.add(auto_checkin.length()==0?0:auto_checkin); + lsParams.add(auto_checkout.length()==0?0:auto_checkout); + lsParams.add(auto_checkin_before.length()==0?30:auto_checkin_before); + lsParams.add(auto_checkin_after.length()==0?30:auto_checkin_after); + lsParams.add(auto_checkout_before.length()==0?5:auto_checkout_before); + lsParams.add(auto_checkout_after.length()==0?60:auto_checkout_after); + lsParams.add(isPhotoPunchEnabled.length()==0?0:isPhotoPunchEnabled); + String ori_auto_checkin = kQGroupComInfo.getAuto_checkin(id); + String ori_auto_checkout = kQGroupComInfo.getAuto_checkout(id); + + //关于自动打卡开启或者关闭后的一些逻辑处理 + group_auto_check(id,auto_checkin,auto_checkout,ori_auto_checkin,ori_auto_checkout,retmap,kQGroupComInfo,locationcheck,wificheck,locationfacecheck,wififacecheck); + if(!retmap.isEmpty()){ + return retmap; + } + + lsParams.add(id); + rs.executeUpdate(sql,lsParams); + } + + kQGroupComInfo.removeCache(); + if(kqtype.equals("1")){ + kqFixedSchedulceComInfo.removeCache(); + } + + String mainSql = " select * from kq_group where id= "+id; + logger.setMainSql(mainSql);//主表sql + + String subSql1 = "select * from kq_fixedschedulce where groupid= "+id; + subLogInfo1.setSubSql(subSql1); + + String subSql = " select * from kq_group_shiftcycle where groupid = "+id; + subLogInfo.setSubSql(subSql); + + retmap.put("id", id); + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(18758, user.getLanguage())); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + /** + * 更新加班规则 + */ + private void updateOverByGroupId(String id, String overtimeRuleId, String overtimeType) { + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + + if(id.length() > 0){ + //更新的情况 + //先根据考勤规则id查询一下原加班规则 + String dbtype = rs.getDBType(); + String overSql = "select * from kq_overtimerules where ','+convert(varchar(2000),groupids)+',' like ? and (isDelete is null or isDelete!=1) "; + if ("oracle".equalsIgnoreCase(dbtype)) { + overSql = "select * from kq_overtimerules where "+ SQLUtil.filteSql(rs.getDBType(), " ','+groupids+',' like ? and (isDelete is null or isDelete!=1) "); + }else if("mysql".equalsIgnoreCase(dbtype)){ + overSql = "select * from kq_overtimerules where CONCAT(',',cast(groupids as char),',') like ? and (isDelete is null or isDelete!=1) "; + }else if ("postgresql".equalsIgnoreCase(dbtype)) { + overSql = "select * from kq_overtimerules where CONCAT(',',groupids,',') like ? and (isDelete is null or isDelete!=1) "; + } + rs.executeQuery(overSql,"%,"+id+",%"); + String preOverId = ""; + String overGroupIds = ""; + if(rs.next()) { + preOverId = rs.getString("id"); + String groupids = rs.getString("groupids"); + if(groupids.length() > 0){ + String[] groupidsArr = groupids.split(","); + if(groupidsArr.length > 0){ + for (int i = 0; i < groupidsArr.length; i++) { + String gId = groupidsArr[i]; + if(gId.equals(id)){ + continue; + } + if(overGroupIds.length() == 0){ + overGroupIds = gId; + }else{ + overGroupIds += ","+gId; + } + } + } + } + } + //先把原加班规则里的当前考勤规则剔除掉 + if(preOverId.length() > 0){ + String updateOverSql = "update kq_overtimerules set groupids=? where id = ?"; + rs1.executeUpdate(updateOverSql,overGroupIds,preOverId); + } + }else{ + //新增的情况 + } + //再根据传入的新的加班规则查一下有的考勤规则id + if("0".equals(overtimeType)){ + //只有是考勤组关联加班规则的时候才有这个逻辑 + if(overtimeRuleId.length() > 0){ + String getSql = "select * from kq_overtimerules where id=?"; + rs.executeQuery(getSql,overtimeRuleId); + if(rs.next()){ + String groupids = Util.null2s(rs.getString("groupids"),""); + if(groupids.length() > 0){ + groupids += ","+id; + }else { + groupids = id; + } + String updateOverSql = "update kq_overtimerules set groupids=? where id = ?"; + rs1.executeUpdate(updateOverSql,groupids,overtimeRuleId); + } + } + } + } + + /** + * 关于自动打卡开启或者关闭后的一些逻辑处理 + * @param id + * @param auto_checkin + * @param auto_checkout + * @param ori_auto_checkin + * @param ori_auto_checkout + * @param retmap + * @param kQGroupComInfo + * @param locationcheck + * @param wificheck + */ + public void group_auto_check(String id, String auto_checkin, String auto_checkout, + String ori_auto_checkin, String ori_auto_checkout, + Map retmap, KQGroupComInfo kQGroupComInfo, String locationcheck, + String wificheck, String locationfacecheck, String wififacecheck) { + KQAutoCheckComInfo kqAutoCheckComInfo = new KQAutoCheckComInfo(); + RecordSet rs = new RecordSet(); + + if(!"1".equalsIgnoreCase(auto_checkin) && !"1".equalsIgnoreCase(auto_checkout)){ + //如果自动打卡 都关闭了,那么自定义设置的也需要被清空 + String del_cus_autoset = "delete from kq_autocheck_set where groupid = ? "; + rs.executeUpdate(del_cus_autoset,id); + kqAutoCheckComInfo.removeCache(); + }else{ + String tmp_kqtype = kQGroupComInfo.getKqtype(id); + if("3".equalsIgnoreCase(tmp_kqtype)){ + //如果是弹性工作制 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(519990,user.getLanguage())); + } + boolean has_location_list = has_location_list(id); + boolean has_wifi_list = has_wifi_list(id); + if("1".equalsIgnoreCase(locationcheck)){ + //地理位置的开关开启了 + if("1".equalsIgnoreCase(wificheck)){ + //wifi的开关开启了 + if(!has_location_list && !has_wifi_list){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(519989,user.getLanguage())); + } + if("1".equalsIgnoreCase(wififacecheck)){ + //如果开启了人脸打卡 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(521384,user.getLanguage())); + } + }else{ + if(!has_location_list){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(519989,user.getLanguage())); + } + } + if("1".equalsIgnoreCase(locationfacecheck)){ + //如果开启了人脸打卡 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(521384,user.getLanguage())); + } + }else{ + //地理位置没开启 + if("1".equalsIgnoreCase(wificheck)){ + //wifi的开关开启了 + if(!has_wifi_list){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(519989,user.getLanguage())); + } + if("1".equalsIgnoreCase(wififacecheck)){ + //如果开启了人脸打卡 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(521384,user.getLanguage())); + } + } + } + + if(!ori_auto_checkin.equalsIgnoreCase(auto_checkin)){ + //如果上班自动打卡变化了,需要去更新掉自定义的设置 + String up_cus_autoset = "update kq_autocheck_set set auto_checkin=? where groupid = ? "; + rs.executeUpdate(up_cus_autoset, auto_checkin,id); + } + if(!ori_auto_checkout.equalsIgnoreCase(ori_auto_checkout)){ + //如果下班自动打卡变化了,需要去更新掉自定义的设置 + String up_cus_autoset = "update kq_autocheck_set set auto_checkout=? where groupid = ? "; + rs.executeUpdate(up_cus_autoset, auto_checkout,id); + } + kqAutoCheckComInfo.removeCache(); + } + } + + /** + * 判断当前考勤组是否有考勤wifi列表 + * @param id + * @return + */ + public boolean has_wifi_list(String id) { + RecordSet rs = new RecordSet(); + String wifi_list_sql = "select 1 from kq_wifi where groupid = ? "; + rs.executeQuery(wifi_list_sql,id); + if(!rs.next()){ + return false; + } + return true; + } + + /** + * 判断当前考勤组是否有考勤地理位置列表 + * @param id + * @return + */ + public boolean has_location_list(String id) { + + RecordSet rs = new RecordSet(); + String location_list_sql = "select 1 from kq_location where groupid = ? "; + rs.executeQuery(location_list_sql,id); + if(!rs.next()){ + return false; + } + return true; + } + + private Map saveKqTypeInfo(){ + Map kqTypeInfo = new HashMap<>(); + RecordSet rs = new RecordSet(); + BatchRecordSet batchRecordSet = new BatchRecordSet(); + String sql = ""; + try{ + String groupid = Util.null2String(params.get("id")); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String kqtype = Util.null2String(jsonObj.get("kqtype"));//考勤类型 + + if(kqtype.equals("1")){//固定班次 + JSONArray fixedSchedulce = jsonObj.getJSONArray("fixedSchedulce");//固定班次明细表 + + if(fixedSchedulce==null || fixedSchedulce.size()>7) return kqTypeInfo; + for(int i=0;fixedSchedulce!=null&&i0){ + sql = "update kq_fixedschedulce set serialid =? where id=? "; + rs.executeUpdate(sql,serialid.length()==0?null:serialid,id); + }else{ + sql = "insert into kq_fixedschedulce(weekday,serialid,groupid) values(?,?,?)"; + rs.executeUpdate(sql,weekday,serialid.length()==0?null:serialid,groupid); + } + } + } + else if(kqtype.equals("2")){//排班制 + JSONArray shiftSchedulce = jsonObj.getJSONArray("shiftSchedulce");//固定班次明细表 + + List lsDelete = new ArrayList<>(); + sql = " select id from kq_group_shiftcycle where groupid = ? "; + rs.executeQuery(sql, groupid); + while(rs.next()){ + lsDelete.add(rs.getString("id")); + } + + List> paramUpdate = new ArrayList<>(); + List> paramInsert = new ArrayList<>(); + List shiftSchedulceParams = null; + for(int i=0;shiftSchedulce!=null&&i(); + if(id.length()>0){ + shiftSchedulceParams.add(shiftcyclename); + shiftSchedulceParams.add(shiftcycleday); + shiftSchedulceParams.add(shiftcycleserialids); + shiftSchedulceParams.add(id); + paramUpdate.add(shiftSchedulceParams); + lsDelete.remove(id); + }else{ + shiftSchedulceParams.add(shiftcyclename); + shiftSchedulceParams.add(shiftcycleday); + shiftSchedulceParams.add(shiftcycleserialids); + shiftSchedulceParams.add(groupid); + paramInsert.add(shiftSchedulceParams); + } + } + sql = " update kq_group_shiftcycle set shiftcyclename=?, shiftcycleday=?,shiftcycleserialids=? where id = ? "; + batchRecordSet.executeBatchSql(sql, paramUpdate); + + sql = " insert into kq_group_shiftcycle (shiftcyclename, shiftcycleday, shiftcycleserialids,groupid) values (?,?,?,?)"; + batchRecordSet.executeBatchSql(sql, paramInsert); + + for(int i=0;i> lsParams = new ArrayList>(); +// for(int i=0;i params = new ArrayList(); +// params.add(weekdays[i]); +// params.add(signstart); +// params.add(groupid); +// lsParams.add(params); +// } +// } +// } +// if(lsParams.size()>0){ +// sql = "insert into kq_freeschedulce(weekday,signstart,groupid) values(?,?,?)"; +// rs.executeUpdate(sql,lsParams); +// } +// } + }catch (Exception e){ + writeLog(e); + } + return kqTypeInfo; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/grouplocation/DelGroupLocationCmd.java b/src/com/engine/kq/cmd/grouplocation/DelGroupLocationCmd.java new file mode 100644 index 0000000..433fce7 --- /dev/null +++ b/src/com/engine/kq/cmd/grouplocation/DelGroupLocationCmd.java @@ -0,0 +1,119 @@ +package com.engine.kq.cmd.grouplocation; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQLoactionComInfo; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class DelGroupLocationCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + public DelGroupLocationCmd(Map params, User user) { + this.user = user; + this.params = params; + String groupId = Util.null2String(params.get("groupId")); + this.boforeLog(groupId); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + String ids = Util.null2String(params.get("ids")); + + String groupId = Util.null2String(params.get("groupId")); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + String auto_checkin = kqGroupComInfo.getAuto_checkin(groupId); + String auto_checkout = kqGroupComInfo.getAuto_checkout(groupId); + if("1".equalsIgnoreCase(auto_checkin) || "1".equalsIgnoreCase(auto_checkout)){ + String check_empty_sql = "select 1 from kq_wifi where groupId=? "; + rs.executeQuery(check_empty_sql, groupId); + if(!rs.next()){ + //如果wifi已经空了,删除办公地点的时候需要判断了 + List sqlParams = new ArrayList(); + Object[] objects= DBUtil.transListIn(ids,sqlParams); + check_empty_sql = "select 1 from kq_location where groupId=? and id not in ("+objects[0]+") "; + rs.executeQuery(check_empty_sql, groupId, sqlParams); + if(!rs.next()){ + //如果除去要删除的信息之后,当前考勤组的办公地点没了,说明要被清空了。这是要给出提示的 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(519989,user.getLanguage())); + return retmap; + } + } + + } + + List sqlParams = new ArrayList(); + Object[] objects= DBUtil.transListIn(ids,sqlParams); + sql = "delete from kq_location where id in ("+objects[0]+") "; + rs.executeUpdate(sql, sqlParams); + + new KQLoactionComInfo().removeCache(); + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(18758, user.getLanguage())); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private void boforeLog(String id){ + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String mainSql = " select * from kq_group where id= " + id; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("groupname"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_location where groupid="+id; + subLogInfo1.setSubPrimarykey("id"); + subLogInfo1.setSubTargetNameColumn("id"); + subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(389125); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + logger.before(logContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/grouplocation/GetGroupLocationFormCmd.java b/src/com/engine/kq/cmd/grouplocation/GetGroupLocationFormCmd.java new file mode 100644 index 0000000..97d9616 --- /dev/null +++ b/src/com/engine/kq/cmd/grouplocation/GetGroupLocationFormCmd.java @@ -0,0 +1,109 @@ +package com.engine.kq.cmd.grouplocation; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class GetGroupLocationFormCmd extends AbstractCommonCommand> { + + public GetGroupLocationFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + Map> fieldGroups= new LinkedHashMap>(); + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + List options = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("locationname"); + hrmFieldBean.setFieldlabel("195"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("checkscope"); + hrmFieldBean.setFieldlabel("507863"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|integer"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("address"); + hrmFieldBean.setFieldlabel("110"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + lsField.add(hrmFieldBean); + + fieldGroups.put("20331", lsField); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + Iterator>> iter = fieldGroups.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry> entry = iter.next(); + String grouplabel = entry.getKey(); + List fields = entry.getValue(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("defaultshow", true); + + itemlist = new ArrayList(); + for (int j = 0; j < fields.size(); j++) { + hrmFieldBean = fields.get(j); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + retmap.put("formField", grouplist); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/grouplocation/GetGroupLocationListCmd.java b/src/com/engine/kq/cmd/grouplocation/GetGroupLocationListCmd.java new file mode 100644 index 0000000..7f713b7 --- /dev/null +++ b/src/com/engine/kq/cmd/grouplocation/GetGroupLocationListCmd.java @@ -0,0 +1,54 @@ +package com.engine.kq.cmd.grouplocation; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.cmd.group.GetGroupFormCmd; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +public class GetGroupLocationListCmd extends AbstractCommonCommand> { + + public GetGroupLocationListCmd(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{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + String locationname = Util.null2String(params.get("locationname")); + + GetGroupFormCmd getGroupFormCmd = new GetGroupFormCmd(params, user); + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = getGroupFormCmd.getKQLocationList(locationname); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/grouplocation/SaveGroupLocationCmd.java b/src/com/engine/kq/cmd/grouplocation/SaveGroupLocationCmd.java new file mode 100644 index 0000000..2f5f26a --- /dev/null +++ b/src/com/engine/kq/cmd/grouplocation/SaveGroupLocationCmd.java @@ -0,0 +1,123 @@ +package com.engine.kq.cmd.grouplocation; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLoactionComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class SaveGroupLocationCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + public SaveGroupLocationCmd(Map params, User user) { + this.user = user; + this.params = params; + String groupId = Util.null2String(params.get("groupId")); + this.boforeLog(groupId); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String datas = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(datas); + String id = Util.null2String(jsonObj.get("id")); + String locationname = Util.null2String(jsonObj.get("locationname"));//名称 + String checkscope = Util.null2String(jsonObj.get("checkscope"));//有效识别半径 + String longitude = Util.null2String(jsonObj.get("longitude"));//经度 + String latitude = Util.null2String(jsonObj.get("latitude"));//纬度 + String address = Util.null2String(jsonObj.get("address"));//地址 + String groupId = Util.null2String(jsonObj.get("groupId"));//分组id + + List lsParams = new ArrayList<>(); + lsParams.add(locationname.length()==0?null:locationname); + lsParams.add(checkscope.length()==0?null:checkscope); + lsParams.add(longitude.length()==0?null:longitude); + lsParams.add(latitude.length()==0?null:latitude); + lsParams.add(address.length()==0?null:address); + lsParams.add(groupId.length()==0?null:groupId); + + if(id.length()>0){ + sql = " update kq_location set locationname=?,checkscope=?,longitude=?,latitude=?,address=?,groupid=? where id=? "; + lsParams.add(id); + rs.executeUpdate(sql,lsParams); + }else{ + sql = " insert into kq_location (locationname,checkscope,longitude,latitude,address,groupid) values (?,?,?,?,?,?)"; + rs.executeUpdate(sql,lsParams); + + rs.executeQuery("select max(id) from kq_location") ; + if(rs.next()){ + id = rs.getString(1); + } + } + + new KQLoactionComInfo().removeCache(); + retmap.put("id", id); + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(18758, user.getLanguage())); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private void boforeLog(String id){ + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String mainSql = " select * from kq_group where id= " + id; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("groupname"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_location where groupid="+id; + subLogInfo1.setSubPrimarykey("id"); + subLogInfo1.setSubTargetNameColumn("id"); + subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(389125); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + logger.before(logContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/groupmemeber/DelGroupMemberCmd.java b/src/com/engine/kq/cmd/groupmemeber/DelGroupMemberCmd.java new file mode 100644 index 0000000..be48676 --- /dev/null +++ b/src/com/engine/kq/cmd/groupmemeber/DelGroupMemberCmd.java @@ -0,0 +1,109 @@ +package com.engine.kq.cmd.groupmemeber; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.biz.KQShiftscheduleBiz; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.Reminder.KQAutoCardTask; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class DelGroupMemberCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + public DelGroupMemberCmd(Map params, User user) { + this.user = user; + this.params = params; + String groupId = Util.null2String(params.get("groupId")); + this.boforeLog(groupId); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String ids = Util.null2String(params.get("ids")); + String groupId = Util.null2String(params.get("groupId")); + List sqlParams = new ArrayList(); + Object[] objects= DBUtil.transListIn(ids,sqlParams); + sql = "update kq_groupmember set isDelete=1 where id in ("+objects[0]+") "; + rs.executeUpdate(sql, sqlParams); + + new KQGroupMemberComInfo().removeCache(); + KQShiftscheduleBiz.keyList.clear(); + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + String auto_checkout = kQGroupComInfo.getAuto_checkout(groupId); + String auto_checkin = kQGroupComInfo.getAuto_checkin(groupId); + if("1".equalsIgnoreCase(auto_checkin) || "1".equalsIgnoreCase(auto_checkout)){ + //如果开启了自动打卡,保存考勤组成员之后需要格式化下缓存 + KQAutoCardTask kqAutoCardTask = new KQAutoCardTask(); + kqAutoCardTask.initAutoCardTask(groupId); + } + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(20461, user.getLanguage())); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private void boforeLog(String id){ + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String mainSql = " select * from kq_group where id= " + id; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("groupname"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_groupmember where (isdelete is null or isdelete <> '1') and groupid="+id; + subLogInfo1.setSubPrimarykey("id"); + subLogInfo1.setSubTargetNameColumn("id"); + subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(388736); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + logger.before(logContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + +} diff --git a/src/com/engine/kq/cmd/groupmemeber/GetGroupMemberFormCmd.java b/src/com/engine/kq/cmd/groupmemeber/GetGroupMemberFormCmd.java new file mode 100644 index 0000000..2f6c6ba --- /dev/null +++ b/src/com/engine/kq/cmd/groupmemeber/GetGroupMemberFormCmd.java @@ -0,0 +1,301 @@ +package com.engine.kq.cmd.groupmemeber; + +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.api.hrm.bean.HrmFieldBean; +import com.api.hrm.bean.SelectOption; +import com.api.hrm.bean.WeaRadioGroup; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupBiz; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetGroupMemberFormCmd extends AbstractCommonCommand> { + + public GetGroupMemberFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + Map groupitem = null; + List itemlist = null; + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + /*考勤组成员相关id*/ + String groupmemberId = Util.null2String(params.get("groupmemberId")); + String validateFrom = ""; + String validateTo = ""; + String type = ""; + if(!"".equals(groupmemberId)) { + String editSql = "select * from kq_groupmember kg where (isDelete is null or isDelete<>1) and id=?"; + rs.executeQuery(editSql, groupmemberId); + if (rs.next()) { + validateFrom = Util.null2String(rs.getString("validatefrom")); + validateTo = Util.null2String(rs.getString("validateto")); + type = Util.null2String(rs.getString("type")); + } + } + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + itemlist = new ArrayList(); + groupitem = new HashMap(); + //下拉 + List condition = new ArrayList(); + if("".equals(groupmemberId)) { + //类型、对象、成员级别 + String[] fields = new String[]{"type,63,5,1", "resourceid,106,3,17", "subcompanyid,106,3,164", "departmentid,106,3,4", + "jobtitle,106,3,24", "jobtitlelevel,28169,5,1", "jobtitlesubcompany,19437,3,164", "jobtitledepartment,19438,3,4", + "seclevel,683,1,scope"}; + groupitem.put("title", SystemEnv.getHtmlLabelName(1361, Util.getIntValue(user.getLanguage()))); + groupitem.put("defaultshow", true); + for(int i=0;i statusOptions = new ArrayList(); + if(hrmFieldBean.getFieldname().equals("type")){ + statusOptions.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(179,user.getLanguage()),true)); + statusOptions.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(141,user.getLanguage()))); + statusOptions.add(new SearchConditionOption("3",SystemEnv.getHtmlLabelName(124,user.getLanguage()))); + statusOptions.add(new SearchConditionOption("5",SystemEnv.getHtmlLabelName(6086,user.getLanguage()))); + if(!new ManageDetachComInfo().appDetachDisableAll(user)) { + statusOptions.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(1340, user.getLanguage()))); + } + searchConditionItem.setOptions(statusOptions); + }else if(hrmFieldBean.getFieldname().equals("jobtitlelevel")){ + statusOptions.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(140,user.getLanguage()),true)); + statusOptions.add(new SearchConditionOption("3",SystemEnv.getHtmlLabelName(19438,user.getLanguage()))); + statusOptions.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(19437,user.getLanguage()))); + searchConditionItem.setOptions(statusOptions); + } + } + searchConditionItem.setLabelcol(6); + if(hrmFieldBean.getFieldname().equals("typevalue")||hrmFieldBean.getFieldname().equals("jobtitle") + ||hrmFieldBean.getFieldname().equals("subcompanyid") || hrmFieldBean.getFieldname().equals("departmentid")){ + searchConditionItem.setFieldcol(10); + }else{ + searchConditionItem.setFieldcol(18); + } + + if(!hrmFieldBean.getFieldname().equals("type")||!hrmFieldBean.getFieldname().equals("seclevel")){ + searchConditionItem.setViewAttr(3); + } + if (fieldinfo[2].equals("3") && !"2".equals(fieldinfo[3])) { + searchConditionItem.getBrowserConditionParam().setViewAttr(3); + searchConditionItem.getBrowserConditionParam().setIsSingle(false); + } + if(hrmFieldBean.getFieldname().equals("jobtitlesubcompany")||hrmFieldBean.getFieldname().equals("jobtitledepartment")){ + searchConditionItem.getBrowserConditionParam().setIsSingle(true); + } + if(hrmFieldBean.getFieldname().equals("seclevel")){ + List value1 = new ArrayList(); + value1.add(0); + value1.add(100); + searchConditionItem.setValue(value1); + searchConditionItem.setConditionType(ConditionType.INPUT_INTERVAL); + } + itemlist.add(searchConditionItem); + } + ConditionFactory conditionFactory = new ConditionFactory(user); + searchConditionItem = conditionFactory.createCondition(ConditionType.CHECKBOX, "125963","alllevel",true); + itemlist.add(searchConditionItem); + + condition.add(itemlist.get(0)); + + List itemList = validateItemlist(hrmFieldSearchConditionComInfo, validateFrom, validateTo); + //人力 + Map conditionMap = new HashMap(); + List conditionlist = new ArrayList(); + List conditionlist2 = new ArrayList(); + conditionlist2.add(itemlist.get(1)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(0)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(1)); + conditionlist.add(conditionlist2); + conditionMap.put("1",conditionlist); + + //分部 + conditionlist2 = new ArrayList(); + conditionlist = new ArrayList(); + conditionlist2.add(itemlist.get(2)); + //暂不支持包含下级 + //conditionlist2.add(itemlist.get(11)); + conditionlist.add(conditionlist2); + + conditionlist2 = new ArrayList(); + conditionlist2.add(itemlist.get(8)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(0)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(1)); + conditionlist.add(conditionlist2); + conditionMap.put("2",conditionlist); + + //部门 + conditionlist2 = new ArrayList(); + conditionlist = new ArrayList(); + conditionlist2.add(itemlist.get(3)); + //暂不支持包含下级 + //conditionlist2.add(itemlist.get(11)); + conditionlist.add(conditionlist2); + + conditionlist2 = new ArrayList(); + conditionlist2.add(itemlist.get(8)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(0)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(1)); + conditionlist.add(conditionlist2); + conditionMap.put("3",conditionlist); + + //岗位 + conditionlist2 = new ArrayList(); + conditionlist = new ArrayList(); + conditionlist2.add(itemlist.get(4)); + conditionlist.add(conditionlist2); + + conditionlist2 = new ArrayList(); + conditionlist2.add(itemlist.get(5)); + + WeaRadioGroup wrg = new WeaRadioGroup(); + wrg.setLabel(SystemEnv.getHtmlLabelName(28169, user.getLanguage())); + List option = new ArrayList(); + Map selectLinkageDatas = new HashMap(); + selectLinkageDatas.put("2" ,itemlist.get(6)); + selectLinkageDatas.put("3" ,itemlist.get(7)); + wrg.setSelectLinkageDatas(selectLinkageDatas); + option.add(new SelectOption("1",SystemEnv.getHtmlLabelName(140, user.getLanguage()),true)); + option.add(new SelectOption("2",SystemEnv.getHtmlLabelName(19437, user.getLanguage()))); + option.add(new SelectOption("3",SystemEnv.getHtmlLabelName(19438, user.getLanguage()))); + + List domkey = new ArrayList(); + wrg.setOptions(option); + wrg.setConditionType("SELECT_LINKAGE"); + wrg.setFieldcol(18); + wrg.setLabelcol(6); + domkey.add("jobtitlelevel"); + wrg.setDomkey(domkey); + + conditionlist2 = new ArrayList(); + conditionlist2.add(wrg); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList(); + conditionlist2.add(itemlist.get(8)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(0)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(1)); + conditionlist.add(conditionlist2); + conditionMap.put("5",conditionlist); + + //所有人 + conditionlist = new ArrayList(); + conditionlist2 = new ArrayList(); + conditionlist2.add(itemlist.get(8)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(0)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(1)); + conditionlist.add(conditionlist2); + conditionMap.put("6",conditionlist); + + condition.add(conditionMap); + } else { + List itemList = validateItemlist(hrmFieldSearchConditionComInfo, validateFrom, validateTo); + condition.add(itemList.get(0)); + condition.add(itemList.get(1)); + } + retmap.put("conditions", condition); + retmap.put("status", "1"); + retmap.put("type", type); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private List validateItemlist(HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo, String validateFromDate, String validateToDate) { + List itemlist = new ArrayList<>(); + HrmFieldBean hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("validateFromDate");//开始日期 + hrmFieldBean.setFieldlabel("19548"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + validateFromDate = KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE.equals(validateFromDate) ? null : validateFromDate; + hrmFieldBean.setFieldvalue(validateFromDate); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setTip(SystemEnv.getHtmlLabelName(546202,user.getLanguage())); + SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("validateToDate");//结束日期 + hrmFieldBean.setFieldlabel("19547"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + validateToDate = KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE.equals(validateToDate) ? null : validateToDate; + hrmFieldBean.setFieldvalue(validateToDate); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setTip(SystemEnv.getHtmlLabelName(546202,user.getLanguage())); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + + return itemlist; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/groupmemeber/GetGroupMemberSearchConditionCmd.java b/src/com/engine/kq/cmd/groupmemeber/GetGroupMemberSearchConditionCmd.java new file mode 100644 index 0000000..7364b3d --- /dev/null +++ b/src/com/engine/kq/cmd/groupmemeber/GetGroupMemberSearchConditionCmd.java @@ -0,0 +1,124 @@ +package com.engine.kq.cmd.groupmemeber; + +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; +import java.util.Map.Entry; + +public class GetGroupMemberSearchConditionCmd extends AbstractCommonCommand> { + + public GetGroupMemberSearchConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + String sql = ""; + RecordSet rs = new RecordSet(); + try { + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + Map> fieldGroups= new LinkedHashMap>(); + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("hrmName"); + hrmFieldBean.setFieldlabel("106"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("hrmJobtitle"); + hrmFieldBean.setFieldlabel("6086"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("24"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("hrmSubcompany"); + hrmFieldBean.setFieldlabel("141"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("164"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("department"); + hrmFieldBean.setFieldlabel("124"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("4"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("validateFromDate");//开始日期 + hrmFieldBean.setFieldlabel("19548"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("validateToDate");//结束日期 + hrmFieldBean.setFieldlabel("19547"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + lsField.add(hrmFieldBean); + + fieldGroups.put("20331", lsField); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + Iterator>> iter = fieldGroups.entrySet().iterator(); + while (iter.hasNext()) { + Entry> entry = iter.next(); + String grouplabel = entry.getKey(); + List fields = entry.getValue(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("defaultshow", true); + + itemlist = new ArrayList(); + for (int j = 0; j < fields.size(); j++) { + hrmFieldBean = fields.get(j); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + retmap.put("status", "1"); + retmap.put("formField", grouplist); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/groupmemeber/GetGroupMemberSearchListCmd.java b/src/com/engine/kq/cmd/groupmemeber/GetGroupMemberSearchListCmd.java new file mode 100644 index 0000000..4416e28 --- /dev/null +++ b/src/com/engine/kq/cmd/groupmemeber/GetGroupMemberSearchListCmd.java @@ -0,0 +1,162 @@ +package com.engine.kq.cmd.groupmemeber; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.util.PageUidFactory; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.HashMap; +import java.util.Map; + +public class GetGroupMemberSearchListCmd extends AbstractCommonCommand> { + + public GetGroupMemberSearchListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + try { + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + String groupId = Util.null2String(params.get("groupId")); + String subcompanyId = new KQGroupComInfo().getSubcompanyid(groupId); + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + int operatelevel = -1; + if(hrmdetachable) { + operatelevel = checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(), "HrmKQGroup:Add", Util.getIntValue(subcompanyId, -1)); + }else{ + operatelevel = 2; + } + + if(user.getUID() == 1){ + operatelevel = 2; + } + + + String hrmName = Util.null2String(params.get("hrmName")); + String hrmJobtitle = Util.null2String(params.get("hrmJobtitle")); + String hrmSubcompany = Util.null2String(params.get("hrmSubcompany")); + String department = Util.null2String(params.get("department")); + + String validateFromDate = Util.null2String(params.get("validateFromDate")).trim(); + String validateToDate = Util.null2String(params.get("validateToDate")).trim(); + validateFromDate = "".equals(validateFromDate) ? KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE : validateFromDate; + validateToDate = "".equals(validateToDate) ? KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE : validateToDate; + + String backfields = " * "; + String fromSql = " kq_groupmember a "; + String sqlWhere = " (isdelete is null "+(rs.getDBType().equals("oracle") ? "" : " or isdelete=0")+") and groupId = "+groupId; + String orderby = " a.id asc " ; + + if(hrmName.length() > 0 ){ + sqlWhere += " and ( exists ( select 1 from hrmresource where a.typevalue=id and a.type=1 and lastname like '%"+hrmName+"%') " + + " or exists ( select 1 from hrmjobtitles where a.typevalue=id and a.type=5 and jobtitlename like '%"+hrmName+"%')" + + " or exists ( select 1 from hrmsubcompany where a.typevalue=id and a.type=2 and subcompanyname like '%"+hrmName+"%')" + + " or exists ( select 1 from hrmdepartment where a.typevalue=id and a.type=3 and departmentname like '%"+hrmName+"%')) "; + + } + if(hrmJobtitle.length() > 0){ + sqlWhere += " and a.type=5 and a.typevalue = "+hrmJobtitle; + } + if(hrmSubcompany.length() > 0){ + sqlWhere += " and a.type=2 and a.typevalue = "+hrmSubcompany; + } + if(department.length() >0){ + sqlWhere += " and a.type=3 and a.typevalue = "+department ; + } + + if(!KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE.equals(validateFromDate)){ + sqlWhere += " and ('"+validateFromDate+"' between a.validatefrom and a.validateto) "; +// if(rs.getDBType().equalsIgnoreCase("oracle")) { +// sqlWhere += " and ('"+validateFromDate+"' between nvl(a.validatefrom,'2000-01-01') and nvl(a.validateto,'2999-12-31')) "; +// }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ +// sqlWhere += " and ('"+validateFromDate+"' between ifnull(a.validatefrom,'2000-01-01') and ifnull(a.validateto,'2999-12-31')) "; +// }else { +// sqlWhere += " and ('"+validateFromDate+"' between isnull(a.validatefrom,'2000-01-01') and isnull(a.validateto,'2999-12-31')) "; +// } + } + if(!KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE.equals(validateToDate)){ + sqlWhere += " and ('"+validateToDate+"' between a.validatefrom and a.validateto) "; +// if(rs.getDBType().equalsIgnoreCase("oracle")) { +// sqlWhere += " and ('"+validateToDate+"' between nvl(a.validatefrom,'2000-01-01') and nvl(a.validateto,'2999-12-31')) "; +// }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ +// sqlWhere += " and ('"+validateToDate+"' between ifnull(a.validatefrom,'2000-01-01') and ifnull(a.validateto,'2999-12-31')) "; +// }else { +// sqlWhere += " and ('"+validateToDate+"' between isnull(a.validatefrom,'2000-01-01') and isnull(a.validateto,'2999-12-31')) "; +// } + } + + String pageUid = PageUidFactory.getHrmPageUid("KQGroupMembersSearchList"); + + String operateString= ""; + operateString+=" "; + //operateString+=" "; + if(operatelevel > 1) { + operateString += " "; + } + operateString+=" "; + operateString+=""; + String tableString = " " + + " " + + " " + + operateString + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + if(operatelevel > 0){ + retmap.put("canAdd", true); + }else{ + retmap.put("canAdd", false); + } + if(operatelevel > 1){ + retmap.put("canDel", true); + }else{ + retmap.put("canDel", false); + } + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/groupmemeber/SaveGroupMemberCmd.java b/src/com/engine/kq/cmd/groupmemeber/SaveGroupMemberCmd.java new file mode 100644 index 0000000..6493ed4 --- /dev/null +++ b/src/com/engine/kq/cmd/groupmemeber/SaveGroupMemberCmd.java @@ -0,0 +1,390 @@ +package com.engine.kq.cmd.groupmemeber; + +import com.alibaba.fastjson.JSON; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +import com.engine.kq.log.KQLog; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.Reminder.KQAutoCardTask; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class SaveGroupMemberCmd extends AbstractCommonCommand> { + private KQLog kqLog = new KQLog(); + private SimpleBizLogger logger; + public SaveGroupMemberCmd(Map params, User user) { + this.user = user; + this.params = params; + String groupId = Util.null2String(params.get("groupId")); + String groupmemberId = Util.null2String(params.get("groupmemberId")).trim(); + if("".equals(groupId)) { + groupId = groupmemberId; + } + this.boforeLog(groupId); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + kqLog.info("params::::::::::::"+ JSON.toJSONString(params)); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String groupId = Util.null2String(params.get("groupId")); + String type = Util.null2String(params.get("type")); + String resourceid = Util.null2String(params.get("resourceid")); + String subcompanyid = Util.null2String(params.get("subcompanyid")); + String departmentid = Util.null2String(params.get("departmentid")); + String alllevel = Util.null2String(params.get("alllevel")).trim(); + String jobtitle = Util.null2String(params.get("jobtitle")).trim(); + String jobtitlelevel = Util.null2String(params.get("jobtitlelevel")).trim(); + String jobtitlesubcompany = Util.null2String(params.get("jobtitlesubcompany")).trim(); + String jobtitledepartment = Util.null2String(params.get("jobtitledepartment")).trim(); + + String groupmemberId = Util.null2String(params.get("groupmemberId")).trim(); + String validateFromDate = Util.null2String(params.get("validateFromDate")).trim(); + String validateToDate = Util.null2String(params.get("validateToDate")).trim(); + validateFromDate = "".equals(validateFromDate) ? KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE : validateFromDate; + validateToDate = "".equals(validateToDate) ? KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE : validateToDate; + boolean isAllEmpty = KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE.equals(validateFromDate) && KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE.equals(validateToDate); + String seclevel = Util.null2String(params.get("seclevel")).trim(); + String seclevelto = Util.null2String(params.get("seclevelto")).trim(); + + if(!"".equals(groupmemberId)) { + String searchSql = "select * from kq_groupmember where id=?"; + rs.executeQuery(searchSql, groupmemberId); + if(rs.next()) { + groupId = Util.null2String(rs.getString("groupid")); + type = Util.null2String(rs.getString("type")); + if("1".equals(type)) { + resourceid = Util.null2String(rs.getString("typevalue")); + } else if("2".equals(type)) { + subcompanyid = Util.null2String(rs.getString("typevalue")); + } else if("3".equals(type)) { + departmentid = Util.null2String(rs.getString("typevalue")); + } else if("5".equals(type)) { + jobtitle = Util.null2String(rs.getString("typevalue")); + } + alllevel = Util.null2String(rs.getString("alllevel")); + jobtitlelevel = Util.null2String(rs.getString("jobtitlelevel")); + if("2".equals(jobtitlelevel)) {//岗位--分部 + jobtitlesubcompany = Util.null2String(rs.getString("jobtitlelevelvalue")); + } else if("3".equals(jobtitlelevel)) {//岗位--部门 + jobtitledepartment = Util.null2String(rs.getString("jobtitlelevelvalue")); + } + seclevel = Util.null2String(rs.getString("seclevel")); + seclevelto = Util.null2String(rs.getString("seclevelto")); + } + } + kqLog.info("validateFromDate1111>>>>>>>>"+validateFromDate+"::::validateToDate::::"+validateToDate); + if(!isAllEmpty) { + List paramLists = new ArrayList<>(); + List paramList = null; + // 1. 查找同级别的有效期 + sql = "select * from kq_groupmember where type=? and (isdelete is null or isdelete <> '1') "; + paramList = new ArrayList<>(); + paramList.add(type); + paramLists.add(paramList); + if (!"".equals(groupmemberId)) { + sql += "and id != ?"; + paramList = new ArrayList<>(); + paramList.add(groupmemberId); + paramLists.add(paramList); + } + if (rs.getDBType().equalsIgnoreCase("sqlserver") + || rs.getDBType().equalsIgnoreCase("mysql")) { + sql += " and (validatefrom is not null or validatefrom<>'')"; + sql += " and (validateto is not null or validateto<>'')"; + } else { + sql += " and ((validatefrom is not null)"; + sql += " or (validateto is not null))"; + } + switch (Util.getIntValue(type)) { + case 1: + sql += " and typevalue in("+ KQReportBiz.splitParamStr(resourceid)+") "; + for(String bean : resourceid.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + break; + case 2: + sql += " and typevalue in("+ KQReportBiz.splitParamStr(subcompanyid)+") and (? between seclevel and seclevelto or ? between seclevel and seclevelto)"; + for(String bean : subcompanyid.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + paramList = new ArrayList<>(); + paramList.add(seclevel); + paramLists.add(paramList); + paramList = new ArrayList<>(); + paramList.add(seclevelto); + paramLists.add(paramList); + break; + case 3: + sql += " and typevalue in("+ KQReportBiz.splitParamStr(departmentid)+") and (? between seclevel and seclevelto or ? between seclevel and seclevelto)"; + for(String bean : departmentid.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + paramList = new ArrayList<>(); + paramList.add(seclevel); + paramLists.add(paramList); + paramList = new ArrayList<>(); + paramList.add(seclevelto); + paramLists.add(paramList); + break; + case 5: + sql += " and typevalue in("+ KQReportBiz.splitParamStr(jobtitle)+") and (? between seclevel and seclevelto or ? between seclevel and seclevelto)"; + for(String bean : jobtitle.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + paramList = new ArrayList<>(); + paramList.add(seclevel); + paramLists.add(paramList); + paramList = new ArrayList<>(); + paramList.add(seclevelto); + paramLists.add(paramList); + if ("2".equals(jobtitlelevel)) { + sql += " and (jobtitlelevelvalue in("+ KQReportBiz.splitParamStr(jobtitlesubcompany)+") or jobtitlelevel=1)"; + for(String bean : jobtitlesubcompany.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } else if ("3".equals(jobtitlelevel)) { + sql += " and (jobtitlelevelvalue in("+ KQReportBiz.splitParamStr(jobtitledepartment)+") or jobtitlelevel=1)"; + for(String bean : jobtitledepartment.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + break; + case 6: + sql += " and typevalue in(0)"; + break; + default: + break; + } + rs.executeQuery(sql, paramLists); + new KQLog().info("sql>>>>>>>>>>>>>>>>" + sql+"::paramLists::"+JSON.toJSONString(paramLists)); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + while (rs.next()) { + String groupid = Util.null2String(rs.getString("groupid")); + String validatefrom = Util.null2String(rs.getString("validatefrom")); + validatefrom = "".equals(validatefrom) ? KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE : validatefrom; + String validateto = Util.null2String(rs.getString("validateto")); + validateto = "".equals(validateto) ? KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE : validateto; + boolean bothNonValidate = KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE.equals(validatefrom) && KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE.equals(validateto); + boolean bothNonFormValidate = KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE.equals(validateFromDate) && KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE.equals(validateToDate); + if(!KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE.equals(validateFromDate) && validateFromDate.compareTo(validatefrom) >= 0 && + validateFromDate.compareTo(validateto) <= 0 && !bothNonValidate) { + retmap.put("status", "-1"); + String kqGroupName = kqGroupComInfo.getGroupname(groupid); + retmap.put("message", SystemEnv.getHtmlLabelName(31052, user.getLanguage())+"'" + kqGroupName + "'"+SystemEnv.getHtmlLabelName(546920, user.getLanguage())); + return retmap; + } + if(!KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE.equals(validateToDate) && validateToDate.compareTo(validatefrom) >= 0 && + validateToDate.compareTo(validateto) <= 0 && !bothNonValidate) { + retmap.put("status", "-1"); + String kqGroupName = kqGroupComInfo.getGroupname(groupid); + retmap.put("message", SystemEnv.getHtmlLabelName(31052, user.getLanguage())+"'" + kqGroupName + "'"+SystemEnv.getHtmlLabelName(546920, user.getLanguage())); + return retmap; + } + if(!KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE.equals(validatefrom) && validatefrom.compareTo(validateFromDate) >= 0 && + validatefrom.compareTo(validateToDate) <= 0 && !bothNonFormValidate) { + retmap.put("status", "-1"); + String kqGroupName = kqGroupComInfo.getGroupname(groupid); + retmap.put("message", SystemEnv.getHtmlLabelName(31052, user.getLanguage())+"'" + kqGroupName + "'"+SystemEnv.getHtmlLabelName(546920, user.getLanguage())); + return retmap; + } + if(!KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE.equals(validateto) && validateto.compareTo(validateFromDate) >= 0 && + validateto.compareTo(validateToDate) <= 0 && !bothNonFormValidate) { + retmap.put("status", "-1"); + String kqGroupName = kqGroupComInfo.getGroupname(groupid); + retmap.put("message", SystemEnv.getHtmlLabelName(31052, user.getLanguage())+"'" + kqGroupName + "'"+SystemEnv.getHtmlLabelName(546920, user.getLanguage())); + return retmap; + } + } + } + kqLog.info("validateFromDate2222>>>>>>>>"+validateFromDate+"::::validateToDate::::"+validateToDate+":::groupmemberId::"+groupmemberId); + if(!"".equals(groupmemberId) && !isAllEmpty) { + sql = " UPDATE kq_groupmember set validatefrom=? ,validateto=? where id=?"; + rs.executeUpdate(sql,validateFromDate,validateToDate,groupmemberId); + } else { + String jobtitlelevelvalue = ""; + if (jobtitlelevel.equals("2")) { + jobtitlelevelvalue = jobtitlesubcompany; + } else if (jobtitlelevel.equals("3")) { + jobtitlelevelvalue = jobtitledepartment; + } + + + String objId = "0"; + switch (Util.getIntValue(type)) { + case 1: + objId = resourceid; + break; + case 2: + objId = subcompanyid; + break; + case 3: + objId = departmentid; + break; + case 5: + objId = jobtitle; + break; + default: + break; + } + String[] arrObjIds = Util.splitString(objId, ","); + new KQLog().info("arrObjIds>>>>>>>>>>>>>>>>" + objId); + if(isAllEmpty) { + for (int i = 0; i < arrObjIds.length; i++) { + List paramLists = new ArrayList<>(); + List paramList = new ArrayList<>(); + //考勤组成员重复判断,单条判断下 + sql = " select count(id) from kq_groupmember where groupid=?"+ + " and (isdelete is null or isdelete <> '1') and typevalue = ? and type = ?"; + paramList.add(groupId); + paramList.add(arrObjIds[i]); + paramList.add(type); + if(!"".equals(groupmemberId)) { + sql += " and id != ?"; + paramList.add(groupmemberId); + } + if (alllevel.length() > 0) { + sql += " and alllevel = ?"; + paramList.add(alllevel); + } + if (seclevel.length() > 0) { + sql += " and seclevel = ?"; + paramList.add(seclevel); + } + if (seclevelto.length() > 0) { + sql += " and seclevelto = ?"; + paramList.add(seclevelto); + } + if (jobtitlelevelvalue.length() > 0) { + sql += " and jobtitlelevelvalue = ?"; + paramList.add(jobtitlelevelvalue); + } + if (jobtitlelevel.length() > 0) { + sql += " and jobtitlelevel = ?"; + paramList.add(jobtitlelevel); + } + paramLists.add(paramList); + rs.executeQuery(sql, paramLists); + new KQLog().info("sql2222>>>>>>>>>>>>>>>>" + sql+"::paramLists::"+JSON.toJSONString(paramLists)); + if (rs.next() && rs.getInt(1) > 0) { + if (arrObjIds.length == 1) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(17567, user.getLanguage())); + return retmap; + } + } + } + } + if(!"".equals(groupmemberId)) { + sql = " UPDATE kq_groupmember set validatefrom=? ,validateto=? where id=?"; + rs.executeUpdate(sql,validateFromDate,validateToDate,groupmemberId); + } else { + + //人员类型,后面的需要替换前面的数据 + //TODO 现在有有效期,一个人是可以存在多个考勤组内的 +// if(type.equals("1")){ +// sql = "update kq_groupmember set isdelete=1 where type=1 and typevalue= ? "; +// rs.executeUpdate(sql,arrObjIds[i]); +// } + for (int i = 0; i < arrObjIds.length; i++) { + sql = " INSERT INTO kq_groupmember ( groupid ,typevalue ,type ,alllevel ," + + " seclevel ,seclevelto ,jobtitlelevelvalue ,jobtitlelevel,validatefrom,validateto) " + + " VALUES (?,?,?,?,?,?,?,?,?,?)"; + rs.executeUpdate(sql, groupId, arrObjIds[i], type, (alllevel.length() == 0 ? "null" : alllevel), (seclevel.length() == 0 ? "null" : seclevel), + (seclevelto.length() == 0 ? "null" : seclevelto), (jobtitlelevelvalue.length() == 0 ? "null" : jobtitlelevelvalue), + (jobtitlelevel.length() == 0 ? "null" : jobtitlelevel), (validateFromDate.length() == 0 ? "null" : validateFromDate), + (validateToDate.length() == 0 ? "null" : validateToDate)); + } + } + } + + new KQGroupMemberComInfo().removeCache(); + KQShiftscheduleBiz.keyList.clear(); + //格式化考勤 +// new KQFormatBiz().formatDateByGroupId(groupId, DateUtil.getCurrentDate()); + + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + String auto_checkout = kQGroupComInfo.getAuto_checkout(groupId); + String auto_checkin = kQGroupComInfo.getAuto_checkin(groupId); + if("1".equalsIgnoreCase(auto_checkin) || "1".equalsIgnoreCase(auto_checkout)){ + //如果开启了自动打卡,保存考勤组成员之后需要格式化下缓存 + KQAutoCardTask kqAutoCardTask = new KQAutoCardTask(); + kqAutoCardTask.initAutoCardTask(groupId); + } + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private void boforeLog(String id){ + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String mainSql = " select * from kq_group where id= "+id; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("groupname"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_groupmember where (isdelete is null or isdelete <> '1') and groupid="+id; + subLogInfo1.setSubPrimarykey("id"); + subLogInfo1.setSubTargetNameColumn("id"); + subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(388736); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + logger.before(logContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/groupmemeber/SaveValidateDateGroupMemberCmd.java b/src/com/engine/kq/cmd/groupmemeber/SaveValidateDateGroupMemberCmd.java new file mode 100644 index 0000000..c08c81b --- /dev/null +++ b/src/com/engine/kq/cmd/groupmemeber/SaveValidateDateGroupMemberCmd.java @@ -0,0 +1,267 @@ +package com.engine.kq.cmd.groupmemeber; + +import com.alibaba.fastjson.JSON; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.biz.KQShiftscheduleBiz; +import com.engine.kq.log.KQLog; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.Reminder.KQAutoCardTask; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SaveValidateDateGroupMemberCmd extends AbstractCommonCommand> { + private KQLog kqLog = new KQLog(); + private SimpleBizLogger logger; + public SaveValidateDateGroupMemberCmd(Map params, User user) { + this.user = user; + this.params = params; + String groupId = Util.null2String(params.get("groupId")); + this.boforeLog(groupId); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + kqLog.info("params::::::::::::"+ JSON.toJSONString(params)); + RecordSet rs = new RecordSet(); + RecordSet rs2 = new RecordSet(); + try { + if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String groupId = Util.null2String(params.get("groupId")); + String validateId = Util.null2String(params.get("validateId")); + // updatevalidate --0:生效日期;1:失效日期 + int updatevalidate = Util.getIntValue(Util.null2String(params.get("updatevalidate")), 0); + String validateDate = Util.null2String(params.get("validateDate")).trim(); + String backfieldsParam = ""; + String backfieldsParamValue = ""; + switch (updatevalidate) { + case 0: + validateDate = "".equals(validateDate) ? KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE : validateDate; + backfieldsParam = "validatefrom"; + break; + case 1: + validateDate = "".equals(validateDate) ? KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE : validateDate; + backfieldsParam = "validateto"; + break; + } + String[] validateIds = validateId.split(","); + String sql = "select * from kq_groupmember where id=?"; + String type = ""; + String resourceid = ""; + String subcompanyid = ""; + String departmentid = ""; + String alllevel = ""; + String jobtitle = ""; + String jobtitlelevel = ""; + String jobtitlesubcompany = ""; + String jobtitledepartment = ""; + String seclevel = ""; + String seclevelto = ""; + String validateFromDate = ""; + String validateToDate = ""; + for(String id : validateIds) { + rs.executeQuery(sql, id); + boolean isSuccess = true; + if(rs.next()) { + String dbValidateFromDate = rs.getString("validatefrom"); + String dbValidateToDate = rs.getString("validateto"); + validateFromDate = dbValidateFromDate; + validateToDate = dbValidateToDate; + switch (updatevalidate) { + case 0: + validateFromDate = validateDate; + if(validateDate.compareTo(dbValidateToDate) > 0) { // 如果开始日期>结束日期,不允许更新 + isSuccess = false; + } + break; + case 1: + validateToDate = validateDate; + if(dbValidateFromDate.compareTo(validateDate) > 0) { // 如果开始日期>结束日期,不允许更新 + isSuccess = false; + } + break; + } + + groupId = Util.null2String(rs.getString("groupid")); + type = Util.null2String(rs.getString("type")); + if("1".equals(type)) { + resourceid = Util.null2String(rs.getString("typevalue")); + } else if("2".equals(type)) { + subcompanyid = Util.null2String(rs.getString("typevalue")); + } else if("3".equals(type)) { + departmentid = Util.null2String(rs.getString("typevalue")); + } else if("5".equals(type)) { + jobtitle = Util.null2String(rs.getString("typevalue")); + } + alllevel = Util.null2String(rs.getString("alllevel")); + jobtitlelevel = Util.null2String(rs.getString("jobtitlelevel")); + if("2".equals(jobtitlelevel)) {//岗位--分部 + jobtitlesubcompany = Util.null2String(rs.getString("jobtitlelevelvalue")); + } else if("3".equals(jobtitlelevel)) {//岗位--部门 + jobtitledepartment = Util.null2String(rs.getString("jobtitlelevelvalue")); + } + seclevel = Util.null2String(rs.getString("seclevel")); + seclevelto = Util.null2String(rs.getString("seclevelto")); + // 1. 查找同级别的有效期 + String sql2 = "select * from kq_groupmember where type=" + type + " and (isdelete is null or isdelete <> '1') and id != " + id; + if (rs2.getDBType().equalsIgnoreCase("sqlserver") + || rs2.getDBType().equalsIgnoreCase("mysql")) { + sql2 += " and (validatefrom is not null or validatefrom<>'')"; + sql2 += " and (validateto is not null or validateto<>'')"; + } else { + sql2 += " and ((validatefrom is not null)"; + sql2 += " or (validateto is not null))"; + } + switch (Util.getIntValue(type)) { + case 1: + sql2 += " and typevalue in(" + resourceid + ")"; + break; + case 2: + sql2 += " and typevalue in(" + subcompanyid + ") and (" + seclevel + " between seclevel and seclevelto or " + seclevelto + " between seclevel and seclevelto)"; + break; + case 3: + sql2 += " and typevalue in(" + departmentid + ") and (" + seclevel + " between seclevel and seclevelto or " + seclevelto + " between seclevel and seclevelto)"; + break; + case 5: + sql2 += " and typevalue in(" + jobtitle + ") and (" + seclevel + " between seclevel and seclevelto or " + + seclevelto + " between seclevel and seclevelto)"; + if ("2".equals(jobtitlelevel)) { + sql2 += " and (jobtitlelevelvalue in(" + jobtitlesubcompany + ") or jobtitlelevel=1)"; + } else if ("3".equals(jobtitlelevel)) { + sql2 += " and (jobtitlelevelvalue in(" + jobtitledepartment + ") or jobtitlelevel=1)"; + } + break; + case 6: + sql2 += " and typevalue in(0)"; + break; + default: + break; + } + rs2.executeQuery(sql2); + new KQLog().info("sql2>>>>>>>>>>>>>>>>" + sql2+"::validateFromDate::"+validateFromDate+"::validateToDate::"+validateToDate); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + while (rs2.next()) { + String groupid = Util.null2String(rs2.getString("groupid")); + String validatefrom = Util.null2String(rs2.getString("validatefrom")); + validatefrom = "".equals(validatefrom) ? KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE : validatefrom; + String validateto = Util.null2String(rs2.getString("validateto")); + validateto = "".equals(validateto) ? KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE : validateto; + boolean bothNonValidate = KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE.equals(validatefrom) && KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE.equals(validateto); + boolean bothNonFormValidate = KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE.equals(validateFromDate) && KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE.equals(validateToDate); + new KQLog().info("groupid>>>>>>>" + groupid+"::validatefrom::"+validatefrom+"::validateto::"+validateto+"::validateFromDate::" + +validateFromDate+"::validateToDate::"+validateToDate+"::bothNonValidate::"+bothNonValidate+"::bothNonFormValidate::"+bothNonFormValidate); + if(!KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE.equals(validateFromDate) && validateFromDate.compareTo(validatefrom) >= 0 && + validateFromDate.compareTo(validateto) <= 0 && !bothNonValidate) { + retmap.put("status", "-1"); + String kqGroupName = kqGroupComInfo.getGroupname(groupid); + retmap.put("message", SystemEnv.getHtmlLabelName(31052, user.getLanguage())+"'" + kqGroupName + "'"+SystemEnv.getHtmlLabelName(546920, user.getLanguage())); + return retmap; + } + if(!KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE.equals(validateToDate) && validateToDate.compareTo(validatefrom) >= 0 && + validateToDate.compareTo(validateto) <= 0 && !bothNonValidate) { + retmap.put("status", "-1"); + String kqGroupName = kqGroupComInfo.getGroupname(groupid); + retmap.put("message", SystemEnv.getHtmlLabelName(31052, user.getLanguage())+"'" + kqGroupName + "'"+SystemEnv.getHtmlLabelName(546920, user.getLanguage())); + return retmap; + } + if(!KQGroupBiz.GROUPMEMBER_VALIDATE_FROMDATE.equals(validatefrom) && validatefrom.compareTo(validateFromDate) >= 0 && + validatefrom.compareTo(validateToDate) <= 0 && !bothNonFormValidate) { + retmap.put("status", "-1"); + String kqGroupName = kqGroupComInfo.getGroupname(groupid); + retmap.put("message", SystemEnv.getHtmlLabelName(31052, user.getLanguage())+"'" + kqGroupName + "'"+SystemEnv.getHtmlLabelName(546920, user.getLanguage())); + return retmap; + } + if(!KQGroupBiz.GROUPMEMBER_VALIDATE_TODATE.equals(validateto) && validateto.compareTo(validateFromDate) >= 0 && + validateto.compareTo(validateToDate) <= 0 && !bothNonFormValidate) { + retmap.put("status", "-1"); + String kqGroupName = kqGroupComInfo.getGroupname(groupid); + retmap.put("message", SystemEnv.getHtmlLabelName(31052, user.getLanguage())+"'" + kqGroupName + "'"+SystemEnv.getHtmlLabelName(546920, user.getLanguage())); + return retmap; + } + } + } + if(!isSuccess) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(546202, user.getLanguage())); + return retmap; + } + } + sql = "update kq_groupmember set "+backfieldsParam+"='"+validateDate+"' where groupid="+groupId+" and id in("+validateId+")"; + kqLog.info("sql:::"+sql); + rs.executeUpdate(sql); + new KQGroupMemberComInfo().removeCache(); + KQShiftscheduleBiz.keyList.clear(); + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + String auto_checkout = kQGroupComInfo.getAuto_checkout(groupId); + String auto_checkin = kQGroupComInfo.getAuto_checkin(groupId); + if("1".equalsIgnoreCase(auto_checkin) || "1".equalsIgnoreCase(auto_checkout)){ + //如果开启了自动打卡,保存考勤组成员之后需要格式化下缓存 + KQAutoCardTask kqAutoCardTask = new KQAutoCardTask(); + kqAutoCardTask.initAutoCardTask(groupId); + } + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private void boforeLog(String id){ + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String mainSql = " select * from kq_group where id= " + id; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("groupname"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_groupmember where (isdelete is null or isdelete <> '1') and groupid="+id; + subLogInfo1.setSubPrimarykey("id"); + subLogInfo1.setSubTargetNameColumn("id"); + subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(388736); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + logger.before(logContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/groupwifi/DelGroupWifiCmd.java b/src/com/engine/kq/cmd/groupwifi/DelGroupWifiCmd.java new file mode 100644 index 0000000..e6a9f40 --- /dev/null +++ b/src/com/engine/kq/cmd/groupwifi/DelGroupWifiCmd.java @@ -0,0 +1,118 @@ +package com.engine.kq.cmd.groupwifi; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQWifiComInfo; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class DelGroupWifiCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + public DelGroupWifiCmd(Map params, User user) { + this.user = user; + this.params = params; + String groupId = Util.null2String(params.get("groupId")); + this.boforeLog(groupId); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String ids = Util.null2String(params.get("ids")); + + String groupId = Util.null2String(params.get("groupId")); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + String auto_checkin = kqGroupComInfo.getAuto_checkin(groupId); + String auto_checkout = kqGroupComInfo.getAuto_checkout(groupId); + if("1".equalsIgnoreCase(auto_checkin) || "1".equalsIgnoreCase(auto_checkout)){ + String check_empty_sql = "select 1 from kq_location where groupId=? "; + rs.executeQuery(check_empty_sql, groupId); + if(!rs.next()){ + List sqlParams = new ArrayList(); + Object[] objects= DBUtil.transListIn(ids,sqlParams); + check_empty_sql = "select 1 from kq_wifi where groupId=? and id not in ("+objects[0]+") "; + rs.executeQuery(check_empty_sql, groupId, sqlParams); + if(!rs.next()){ + //如果除去要删除的信息之后,当前考勤组的wifi没了,说明要被清空了。这是要给出提示的 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(519989,user.getLanguage())); + return retmap; + } + } + } + List sqlParams = new ArrayList(); + Object[] objects= DBUtil.transListIn(ids,sqlParams); + sql = "delete from kq_wifi where id in ("+objects[0]+") "; + rs.executeUpdate(sql, sqlParams); + + new KQWifiComInfo().removeCache(); + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(18758, user.getLanguage())); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private void boforeLog(String id){ + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String mainSql = " select * from kq_group where id= " + id; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("groupname"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_wifi where groupid="+id; + subLogInfo1.setSubPrimarykey("id"); + subLogInfo1.setSubTargetNameColumn("id"); + subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(388736); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + logger.before(logContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + +} diff --git a/src/com/engine/kq/cmd/groupwifi/GetGroupWifiFormCmd.java b/src/com/engine/kq/cmd/groupwifi/GetGroupWifiFormCmd.java new file mode 100644 index 0000000..4bc21ea --- /dev/null +++ b/src/com/engine/kq/cmd/groupwifi/GetGroupWifiFormCmd.java @@ -0,0 +1,101 @@ +package com.engine.kq.cmd.groupwifi; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class GetGroupWifiFormCmd extends AbstractCommonCommand> { + + public GetGroupWifiFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + Map> fieldGroups= new LinkedHashMap>(); + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + List options = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("wifiname"); + hrmFieldBean.setFieldlabel("195"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + hrmFieldBean.setTip(SystemEnv.getHtmlLabelName(515484, user.getLanguage())); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("mac"); + hrmFieldBean.setFieldlabel("32072"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + lsField.add(hrmFieldBean); + + fieldGroups.put("20331", lsField); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + Iterator>> iter = fieldGroups.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry> entry = iter.next(); + String grouplabel = entry.getKey(); + List fields = entry.getValue(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("defaultshow", true); + + itemlist = new ArrayList(); + for (int j = 0; j < fields.size(); j++) { + hrmFieldBean = fields.get(j); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + retmap.put("formField", grouplist); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/groupwifi/GetGroupWifiListCmd.java b/src/com/engine/kq/cmd/groupwifi/GetGroupWifiListCmd.java new file mode 100644 index 0000000..a940e8b --- /dev/null +++ b/src/com/engine/kq/cmd/groupwifi/GetGroupWifiListCmd.java @@ -0,0 +1,54 @@ +package com.engine.kq.cmd.groupwifi; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.cmd.group.GetGroupFormCmd; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +public class GetGroupWifiListCmd extends AbstractCommonCommand> { + + public GetGroupWifiListCmd(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{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + String wifiname = Util.null2String(params.get("wifiname")); + + GetGroupFormCmd getGroupFormCmd = new GetGroupFormCmd(params, user); + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = getGroupFormCmd.getKQWifiList(wifiname); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/groupwifi/SaveGroupWifiCmd.java b/src/com/engine/kq/cmd/groupwifi/SaveGroupWifiCmd.java new file mode 100644 index 0000000..3e527bf --- /dev/null +++ b/src/com/engine/kq/cmd/groupwifi/SaveGroupWifiCmd.java @@ -0,0 +1,115 @@ +package com.engine.kq.cmd.groupwifi; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQWifiComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class SaveGroupWifiCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + public SaveGroupWifiCmd(Map params, User user) { + this.user = user; + this.params = params; + String groupId = Util.null2String(params.get("groupId")); + this.boforeLog(groupId); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + String datas = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(datas); + String id = Util.null2String(jsonObj.get("id")); + String wifiname = Util.null2String(jsonObj.get("wifiname"));//名称 + String mac = Util.null2String(jsonObj.get("mac"));//MAC地址 + String groupId = Util.null2String(jsonObj.get("groupId")); + + List lsParams = new ArrayList<>(); + lsParams.add(wifiname.length()==0?null:wifiname); + lsParams.add(mac.length()==0?null:mac); + lsParams.add(groupId.length()==0?null:groupId); + + if(id.length()>0){ + sql = " update kq_wifi set wifiname=?,mac=?,groupid=? where id=? "; + lsParams.add(id); + rs.executeUpdate(sql,lsParams); + }else{ + sql = " insert into kq_wifi (wifiname,mac,groupid) values (?,?,?)"; + rs.executeUpdate(sql,lsParams); + + rs.executeQuery("select max(id) from kq_wifi") ; + if(rs.next()){ + id = rs.getString(1); + } + } + + new KQWifiComInfo().removeCache(); + retmap.put("id", id); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private void boforeLog(String id){ + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String mainSql = " select * from kq_group where id= " + id; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("groupname"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_wifi where groupid="+id; + subLogInfo1.setSubPrimarykey("id"); + subLogInfo1.setSubTargetNameColumn("id"); + subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(388736); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + logger.before(logContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/AddHolidaySetCmd.java b/src/com/engine/kq/cmd/holidaySet/AddHolidaySetCmd.java new file mode 100644 index 0000000..039b21a --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/AddHolidaySetCmd.java @@ -0,0 +1,190 @@ +package com.engine.kq.cmd.holidaySet; + +import com.api.browser.bean.SearchConditionOption; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * + */ +public class AddHolidaySetCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public AddHolidaySetCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String groupId = Util.null2String(params.get("groupId"));//考勤组ID + String syncGroupIds = Util.null2String(params.get("syncGroupIds"));//需要同步的考勤组ID + String groupIds = groupId + (syncGroupIds.equals("") ? "" : ("," + syncGroupIds)); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_HOLIDAYSET);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_HOLIDAYSET);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_HolidaySet where groupId in (" + groupIds + ")"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4HolidaySet","column:groupId+column:holidayDate+"+user.getLanguage());//当前targetName对应的列(对应日志中的对象名) + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + String groupId = Util.null2String(params.get("groupId"));//考勤组ID + String startDate = Util.null2String(params.get("startDate"));//开始日期 + String endDate = Util.null2String(params.get("endDate"));//结束日期 + String changeType = Util.null2String(params.get("changeType"));//类型:1-公众假日、2-调配工作日、3-调配休息日 + String holidayDesc = Util.null2String(params.get("holidayDesc"));//说明 + int relatedDay = Util.getIntValue((String) params.get("relatedDay"), -1);//对应工作日:0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六、6-星期日 + String isSync = Util.null2String(params.get("isSync"));//是否需要同步到其他考勤组 + String syncGroupIds = Util.null2String(params.get("syncGroupIds"));//需要同步的考勤组ID + + try { + boolean canAdd = HrmUserVarify.checkUserRight("KQHolidaySetAdd:Add", user); + if (!canAdd) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + boolean flag = true; + + String deleteSql = "delete from kq_HolidaySet where groupId=? and holidayDate=?"; + String insertSql = " insert into kq_HolidaySet(groupId,holidayDate,changeType,holidayDesc,relatedDay) values(?,?,?,?,?)"; + RecordSet recordSet = new RecordSet(); + int days = Util.dayDiff(startDate, endDate); + for (int i = 0; i < days; i++) { + String holidayDate = getDateDel(startDate, i); + /** + * 如果这一天已经设置过数据,删除掉后再重新插入 + */ + recordSet.executeUpdate(deleteSql, groupId, holidayDate); + + flag = recordSet.executeUpdate(insertSql, groupId, holidayDate, changeType, holidayDesc, relatedDay); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + + + /** + * 同步到其他考勤组 + * 如果这一天已经设置过数据,删除掉后再重新插入 + */ + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + if (isSync.equals("1") || isSync.equals("true")) { + List syncGroupIdList = Util.TokenizerString(syncGroupIds, ","); + for (int j = 0; j < syncGroupIdList.size(); j++) { + String tempGroupId = syncGroupIdList.get(j); + + if (Util.null2String(kqGroupComInfo.getKqtype(tempGroupId)).equals("2") && changeType.equals("2")) { + continue; + } + recordSet.executeUpdate(deleteSql, tempGroupId, holidayDate); + flag = recordSet.executeUpdate(insertSql, tempGroupId, holidayDate, changeType, holidayDesc, relatedDay); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + } + + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } + } catch (Exception e) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } finally { + /*刷新缓存*/ + KQHolidaySetComInfo holidaySetComInfo = new KQHolidaySetComInfo(); + holidaySetComInfo.removeCache(); + + /*刷新报表*/ + List groupIdList = new ArrayList(); + if (isSync.equals("1") || isSync.equals("true")) { + groupIdList = Util.TokenizerString(syncGroupIds, ","); + if (groupIdList == null) { + groupIdList = new ArrayList(); + } + } + groupIdList.add(groupId); + List holidayDateList = new ArrayList(); + boolean isEnd = false; + for (String holidayDate = startDate; !isEnd; holidayDate = DateUtil.getDate(holidayDate, 1)) { + if (holidayDate.equals(endDate)) { + isEnd = true; + } + if (!holidayDateList.contains(holidayDate)) { + holidayDateList.add(holidayDate); + } + } + new KQHolidaySetThread(groupIdList,holidayDateList).start(); + } + return resultMap; + } + + /** + * 获取与data相隔num天的日期 + * + * @param date + * @param num + * @return + */ + private static String getDateDel(String date, int num) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + Date tempDate = null; + try { + tempDate = simpleDateFormat.parse(date); + } catch (ParseException e) { + e.printStackTrace(); + } + calendar.setTime(tempDate); + calendar.add(Calendar.DATE, num); + tempDate = calendar.getTime(); + date = simpleDateFormat.format(tempDate); + return date; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/DeleteHolidaySetCmd.java b/src/com/engine/kq/cmd/holidaySet/DeleteHolidaySetCmd.java new file mode 100644 index 0000000..afeb054 --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/DeleteHolidaySetCmd.java @@ -0,0 +1,124 @@ +package com.engine.kq.cmd.holidaySet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 节假日设置--删除 + */ +public class DeleteHolidaySetCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public DeleteHolidaySetCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String ids = Util.null2String(params.get("ids"));//需要删除的Id + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_HOLIDAYSET);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_HOLIDAYSET);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_HolidaySet where id in (" + ids + ")"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4HolidaySet","column:groupId+column:holidayDate+"+user.getLanguage());//当前targetName对应的列(对应日志中的对象名) + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + String ids = Util.null2String(params.get("ids"));//需要删除的Id + + List> list = new ArrayList>(); + Map map = new HashMap(); + try { + boolean canDelete = HrmUserVarify.checkUserRight("KQHolidaySetDelete:Delete", user); + if (!canDelete) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + /*预先加载删除了哪些考勤组的哪些日期的节假日设置*/ + String formateSql = "select * from kq_HolidaySet where id in (" + ids + ")"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(formateSql); + while (recordSet.next()) { + String groupId = recordSet.getString("groupId"); + String holidayDate = recordSet.getString("holidayDate"); + + map = new HashMap(); + map.put("groupId", groupId); + map.put("holidayDate", holidayDate); + list.add(map); + } + + /*删除节假日设置*/ + String sql = "delete from kq_HolidaySet where id in (" + ids + ")"; + boolean flag = recordSet.executeUpdate(sql); + + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(20461, user.getLanguage()));//删除成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(20462, user.getLanguage()));//删除失败 + } + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage()));//发生未知错误,请与管理员联系 + writeLog(e); + } finally { + /*刷新缓存*/ + KQHolidaySetComInfo holidaySetComInfo = new KQHolidaySetComInfo(); + holidaySetComInfo.removeCache(); + + /*刷新报表*/ + List groupIdList = new ArrayList(); + List holidayDateList = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + map = list.get(i); + String groupId = (String) map.get("groupId"); + String holidayDate = (String) map.get("holidayDate"); + if(!groupIdList.contains(groupId)){ + groupIdList.add(groupId); + } + if(!holidayDateList.contains(holidayDate)){ + holidayDateList.add(holidayDate); + } + } + new KQHolidaySetThread(groupIdList,holidayDateList).start(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/EditHolidaySetCmd.java b/src/com/engine/kq/cmd/holidaySet/EditHolidaySetCmd.java new file mode 100644 index 0000000..0ae8a65 --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/EditHolidaySetCmd.java @@ -0,0 +1,148 @@ +package com.engine.kq.cmd.holidaySet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 节假日设置--编辑 + */ +public class EditHolidaySetCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public EditHolidaySetCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String groupId = Util.null2String(params.get("groupId"));//考勤组ID + String syncGroupIds = Util.null2String(params.get("syncGroupIds"));//需要同步的考勤组ID + String groupIds = groupId + (syncGroupIds.equals("") ? "" : ("," + syncGroupIds)); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_HOLIDAYSET);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_HOLIDAYSET);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_HolidaySet where groupId in (" + groupIds + ")"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4HolidaySet","column:groupId+column:holidayDate+"+user.getLanguage());//当前targetName对应的列(对应日志中的对象名) + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + String id = Util.null2String(params.get("id"));//ID + String groupId = Util.null2String(params.get("groupId"));//考勤组ID + String holidayDate = Util.null2String(params.get("holidayDate"));//日期 + String changeType = Util.null2String(params.get("changeType"));//类型:1-公众假日、2-调配工作日、3-调配休息日 + String holidayDesc = Util.null2String(params.get("holidayDesc"));//说明 + int relatedDay = Util.getIntValue((String) params.get("relatedDay"), -1);//对应工作日:0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六、6-星期日 + String isSync = Util.null2String(params.get("isSync"));//是否需要同步到其他考勤组 + String syncGroupIds = Util.null2String(params.get("syncGroupIds"));//需要同步的考勤组ID + + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQHolidaySetEdit:Edit", user); + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + + String updateSql = "update kq_HolidaySet set changeType=?,holidayDesc=?,relatedDay=?,groupId=?,holidayDate=? where id=?"; + RecordSet recordSet = new RecordSet(); + boolean flag = recordSet.executeUpdate(updateSql, changeType, holidayDesc, relatedDay, groupId, holidayDate, id); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + + /** + * 同步到其他考勤组 + * 如果这一天已经设置过数据,删除掉后再重新插入 + */ + String deleteSql = "delete from kq_HolidaySet where groupId=? and holidayDate=?"; + String insertSql = " insert into kq_HolidaySet(groupId,holidayDate,changeType,holidayDesc,relatedDay) values(?,?,?,?,?)"; + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + if (isSync.equals("1") || isSync.equals("true")) { + List syncGroupIdList = Util.TokenizerString(syncGroupIds, ","); + for (int j = 0; j < syncGroupIdList.size(); j++) { + String tempGroupId = syncGroupIdList.get(j); + if (Util.null2String(kqGroupComInfo.getKqtype(tempGroupId)).equals("2") && changeType.equals("2")) { + continue; + } + recordSet.executeUpdate(deleteSql, tempGroupId, holidayDate); + + flag = recordSet.executeUpdate(insertSql, tempGroupId, holidayDate, changeType, holidayDesc, relatedDay); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } + } catch (Exception e) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + }finally { + /*刷新缓存*/ + KQHolidaySetComInfo holidaySetComInfo = new KQHolidaySetComInfo(); + holidaySetComInfo.removeCache(); + + /*刷新报表*/ + List groupIdList = new ArrayList(); + if (isSync.equals("1") || isSync.equals("true")) { + groupIdList = Util.TokenizerString(syncGroupIds, ","); + if(groupIdList==null){ + groupIdList = new ArrayList(); + } + } + groupIdList.add(groupId); + List holidayDateList = new ArrayList(); + holidayDateList.add(holidayDate); + new KQHolidaySetThread(groupIdList,holidayDateList).start(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/GetHolidayCountCmd.java b/src/com/engine/kq/cmd/holidaySet/GetHolidayCountCmd.java new file mode 100644 index 0000000..04cd022 --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/GetHolidayCountCmd.java @@ -0,0 +1,102 @@ +package com.engine.kq.cmd.holidaySet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.location.LocationComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.*; + +/** + * 节假日设置--总计数据 + */ +public class GetHolidayCountCmd extends AbstractCommonCommand> { + + public GetHolidayCountCmd(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(); + String groupId = Util.null2String(params.get("groupId"));//考勤组ID + String currentYear = Util.null2String(params.get("currentYear"));//年份 + + boolean canAdd = HrmUserVarify.checkUserRight("KQHolidaySetAdd:Add", user);//是否具有新建权限 + if (!canAdd) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + /*如果没有传入年份,默认为今年的年份*/ + Calendar today = Calendar.getInstance(); + if (currentYear.equals("")) { + currentYear = "" + today.get(Calendar.YEAR); + } + + Map countMap = new HashMap(); + List> countList = new ArrayList>(); + int sumNum1 = 0;//公众假日总计 + int sumNum2 = 0;//调配工作日总计 + int sumNum3 = 0;//调配休息日总计 + + String sql = " select changeType,COUNT(*) AS sum_num from kq_HolidaySet where 1=1 "; + if (!groupId.equals("")) { + sql += " and groupId in (" + groupId + ")"; + } + if (!currentYear.equals("")) { + String dateFrom = currentYear + "-01-01"; + String dateTo = currentYear + "-12-31"; + sql += " and holidayDate>='" + dateFrom + "' and holidayDate<='" + dateTo + "'"; + } + sql += " group by changeType "; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String changeType = recordSet.getString("changeType"); + if (changeType.equals("1")) { + sumNum1 = recordSet.getInt("sum_num"); + } else if (changeType.equals("2")) { + sumNum2 = recordSet.getInt("sum_num"); + } else if (changeType.equals("3")) { + sumNum3 = recordSet.getInt("sum_num"); + } + } + countMap = new HashMap(); + countMap.put("changeType", "1"); + countMap.put("typeName", SystemEnv.getHtmlLabelName(16478, user.getLanguage())); + countMap.put("bgColor", "#00cc66"); + countMap.put("value", sumNum1); + countList.add(countMap); + + countMap = new HashMap(); + countMap.put("changeType", "2"); + countMap.put("typeName", SystemEnv.getHtmlLabelName(16751, user.getLanguage())); + countMap.put("bgColor", "#ff0000"); + countMap.put("value", sumNum2); + countList.add(countMap); + + countMap = new HashMap(); + countMap.put("changeType", "3"); + countMap.put("typeName", SystemEnv.getHtmlLabelName(16752, user.getLanguage())); + countMap.put("bgColor", "#0066ff"); + countMap.put("value", sumNum3); + countList.add(countMap); + resultMap.put("type", countList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/GetHolidaySetCalendarCmd.java b/src/com/engine/kq/cmd/holidaySet/GetHolidaySetCalendarCmd.java new file mode 100644 index 0000000..17ffacf --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/GetHolidaySetCalendarCmd.java @@ -0,0 +1,185 @@ +package com.engine.kq.cmd.holidaySet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.location.LocationComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.*; + +/** + * 节假日设置--日历 + */ +public class GetHolidaySetCalendarCmd extends AbstractCommonCommand> { + + public GetHolidaySetCalendarCmd(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(); + RecordSet recordSet = new RecordSet(); + String groupId = Util.null2String(params.get("groupId"));//考勤组的ID + String currentYear = Util.null2String(params.get("currentYear"));//年份 + String changeType = Util.null2String(params.get("changeType"));//类型:1-公众假日、2-调配工作日、3-调配休息日 + + boolean canAdd = HrmUserVarify.checkUserRight("KQHolidaySetAdd:Add", user);//是否具有新建权限 + if (!canAdd) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + Map itemMap = new HashMap(); + List> itemList = new ArrayList>(); + List dataList = new ArrayList(); + + /*公众假日*/ + Map holidayMap1 = new HashMap(); + List holidayList1 = new ArrayList(); + + /*调配工作日*/ + Map holidayMap2 = new HashMap(); + List holidayList2 = new ArrayList(); + + /*调配休息日*/ + Map holidayMap3 = new HashMap(); + List holidayList3 = new ArrayList(); + + /*如果没有传入年份,默认为今年的年份*/ + Calendar today = Calendar.getInstance(); + if (currentYear.equals("")) { + currentYear = "" + today.get(Calendar.YEAR); + } + + String sql = "select * from kq_HolidaySet where 1=1"; + if (!groupId.equals("")) { + sql += " and groupId in (" + groupId + ")"; + } + if (!changeType.equals("")) { + sql += " and changeType in (" + changeType + ")"; + } else { + sql += " and 1=2 ";//表示不显示任何节假日数据 + } + if (!currentYear.equals("")) { + String dateFrom = currentYear + "-01-01"; + String dateTo = currentYear + "-12-31"; + sql += " and holidayDate>='" + dateFrom + "' and holidayDate<='" + dateTo + "'"; + } + recordSet.executeQuery(sql); + while (recordSet.next()) { + Map holidayMap = new HashMap(); + changeType = recordSet.getString("changeType");//类型:1-公众假日、2-调配工作日、3-调配休息日 + String holidayDate = recordSet.getString("holidayDate");//日期 + String holidayDesc = recordSet.getString("holidayDesc");//说明 + if (changeType.equals("1")) { + holidayMap.put("fontColor", "#FFF"); + holidayMap.put("bgColor", "#00CC66");//绿色 + holidayMap.put("changeType", "1");//1-公众假日 + holidayMap.put("typeName", getTypeName("1")); + holidayMap.put("desc", holidayDesc); + holidayMap.put("id", recordSet.getInt("id")); + holidayMap.put("date", holidayDate); + holidayMap1.put(holidayDate, holidayMap); + holidayList1.add(holidayDate); + } else if (changeType.equals("2")) { + holidayMap.put("fontColor", "#FFF"); + holidayMap.put("bgColor", "#FF0000");//红色 + holidayMap.put("changeType", "2");//调配工作日 + holidayMap.put("typeName", getTypeName("2")); + holidayMap.put("desc", holidayDesc); + holidayMap.put("id", recordSet.getInt("id")); + holidayMap.put("date", holidayDate); + holidayMap2.put(holidayDate, holidayMap); + holidayList2.add(holidayDate); + } else if (changeType.equals("3")) { + holidayMap.put("fontColor", "#FFF"); + holidayMap.put("bgColor", "#0066FF");//蓝色 + holidayMap.put("changeType", "3");//调配休息日 + holidayMap.put("typeName", getTypeName("3")); + holidayMap.put("desc", holidayDesc); + holidayMap.put("id", recordSet.getInt("id")); + holidayMap.put("date", holidayDate); + holidayMap3.put(holidayDate, holidayMap); + holidayList3.add(holidayDate); + } + } + Calendar dateTemp = Calendar.getInstance(); + String dateStr = ""; + for (int i = 1; i <= 12; i++) { + itemList = new ArrayList>(); + for (int j = 1; j <= 31; j++) { + itemMap = new HashMap(); + dateTemp.clear(); + dateTemp.set(Util.getIntValue(currentYear), i - 1, j); + if (dateTemp.get(Calendar.MONTH) != i - 1) {//防止出现2月30号等错误日期参数 + continue; + } + dateStr = Util.add0(dateTemp.get(Calendar.YEAR), 4) + "-" + + Util.add0(dateTemp.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(dateTemp.get(Calendar.DAY_OF_MONTH), 2); + if (holidayList1.contains(dateStr)) { + itemMap = (Map) holidayMap1.get(dateStr); + } else if (holidayList2.contains(dateStr)) { + itemMap = (Map) holidayMap2.get(dateStr); + } else if (holidayList3.contains(dateStr)) { + itemMap = (Map) holidayMap3.get(dateStr); + } else if (dateTemp.getTime().getDay() == 6 || dateTemp.getTime().getDay() == 0) {//周末 + itemMap.put("date", dateStr); + itemMap.put("fontColor", "#C0C0C0");//灰色 + itemMap.put("bgColor", ""); + itemMap.put("changeType", ""); + itemMap.put("typeName", ""); + itemMap.put("desc", ""); + itemMap.put("id", ""); + } else { + itemMap.put("date", dateStr); + itemMap.put("fontColor", "#000000"); + itemMap.put("bgColor", ""); + itemMap.put("changeType", ""); + itemMap.put("typeName", ""); + itemMap.put("desc", ""); + itemMap.put("id", ""); + } + itemList.add(itemMap); + } + dataList.add(itemList); + } + resultMap.put("data", dataList); + return resultMap; + } + + /** + * 根据类型值获取显示名称 + * + * @param type + * @return + */ + private String getTypeName(String type) { + String typeName = ""; + if (type.equals("1")) { + typeName = SystemEnv.getHtmlLabelName(16478, user.getLanguage());//公众假日 + } else if (type.equals("2")) { + typeName = SystemEnv.getHtmlLabelName(16751, user.getLanguage());//调配工作日 + } else if (type.equals("3")) { + typeName = SystemEnv.getHtmlLabelName(16752, user.getLanguage());//调配休息日 + } else { + typeName = ""; + } + return typeName; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/GetHolidaySetFormCmd.java b/src/com/engine/kq/cmd/holidaySet/GetHolidaySetFormCmd.java new file mode 100644 index 0000000..178db70 --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/GetHolidaySetFormCmd.java @@ -0,0 +1,238 @@ +package com.engine.kq.cmd.holidaySet; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import weaver.conn.RecordSet; +import weaver.filter.XssUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.country.CountryComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 节假日设置--新建或编辑的表单 + */ +public class GetHolidaySetFormCmd extends AbstractCommonCommand> { + + public GetHolidaySetFormCmd(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(); + String id = Util.null2String(params.get("id"));//ID + String groupId = Util.null2String(params.get("groupId"));//考勤组的ID + String holidayDate = Util.null2String(params.get("holidayDate"));//节假日日期 + String holidayDesc = "";//说明 + String changeType = "1";//类型:1-公众假日、2-调配工作日、3-调配休息日 + String relatedDay = "";//对应工作日:0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六、6-星期日 + String shiftId = "";//班次ID + + /*参数有误*/ + if (id.equals("") && groupId.equals("")) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage())); + return resultMap; + } + + /*是否具有编辑的权限*/ + boolean canEdit = HrmUserVarify.checkUserRight("KQHolidaySetEdit:Edit", user); + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + List> replaceDatas = new ArrayList>(); + Map datas = new HashMap(); + + boolean isEdit = false; + if (!id.equals("")) { + String sql = "select * from kq_HolidaySet where id=" + id; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + isEdit = true; + holidayDate = recordSet.getString("holidayDate"); + groupId = recordSet.getString("groupId"); + holidayDesc = recordSet.getString("holidayDesc"); + changeType = recordSet.getString("changeType"); + relatedDay = recordSet.getString("relatedDay"); + shiftId = recordSet.getString("shiftId"); + } + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("groupId");//考勤组 + hrmFieldBean.setFieldlabel("390221"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("kqgroup"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(1); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + replaceDatas = new ArrayList>(); + datas = new HashMap(); + datas.put("id", groupId); + datas.put("name", kqGroupComInfo.getGroupname(groupId)); + replaceDatas.add(datas); + searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas); + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + if (isEdit) { + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("holidayDate");//日期 + hrmFieldBean.setFieldlabel("97"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(holidayDate); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(1); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + } else { + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("startDate");//开始日期 + hrmFieldBean.setFieldlabel("740"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(holidayDate); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("endDate");//结束日期 + hrmFieldBean.setFieldlabel("741"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(holidayDate); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("holidayDesc");//说明 + hrmFieldBean.setFieldlabel("85"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(holidayDesc); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (hrmFieldBean.getViewAttr() == 1) { + OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("changeType");//类型 + hrmFieldBean.setFieldlabel("132033"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(changeType); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List statusOptions = new ArrayList(); + statusOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(16478, user.getLanguage()), changeType.equals("1"))); + statusOptions.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(16752, user.getLanguage()), changeType.equals("3"))); + if (!Util.null2String(kqGroupComInfo.getKqtype(groupId)).equals("2")) { + statusOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(16751, user.getLanguage()), changeType.equals("2"))); + } + searchConditionItem.setOptions(statusOptions); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(529901, user.getLanguage())); + searchConditionItem.setDetailtype(3); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("relatedDay");//对应工作日 + hrmFieldBean.setFieldlabel("16754"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(relatedDay); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + statusOptions = new ArrayList(); + statusOptions.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(392, user.getLanguage()), relatedDay.equals("0") || relatedDay.equals(""))); + statusOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(393, user.getLanguage()), relatedDay.equals("1"))); + statusOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(394, user.getLanguage()), relatedDay.equals("2"))); + statusOptions.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(395, user.getLanguage()), relatedDay.equals("3"))); + statusOptions.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(396, user.getLanguage()), relatedDay.equals("4"))); + statusOptions.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(397, user.getLanguage()), relatedDay.equals("5"))); + statusOptions.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(398, user.getLanguage()), relatedDay.equals("6"))); + searchConditionItem.setOptions(statusOptions); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("isSync");//同步到其他考勤组 + hrmFieldBean.setFieldlabel("506392"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + Map otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + itemList.add(searchConditionItem); + +// XssUtil xssUtil = new XssUtil(); + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("syncGroupIds");//同步到考勤组--多选 + hrmFieldBean.setFieldlabel("390664"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("mkqgroup"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + Map dataMap = new HashMap(); +// dataMap.put("sqlWhere",xssUtil.put(" kqtype!=2 ")); + searchConditionItem.getBrowserConditionParam().setDataParams(dataMap); + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/GetImportFormCmd.java b/src/com/engine/kq/cmd/holidaySet/GetImportFormCmd.java new file mode 100644 index 0000000..17b24fa --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/GetImportFormCmd.java @@ -0,0 +1,123 @@ +package com.engine.kq.cmd.holidaySet; + +import com.api.browser.bean.SearchConditionItem; +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 weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 节假日设置--Excel导入时的表单 + */ +public class GetImportFormCmd extends AbstractCommonCommand> { + + public GetImportFormCmd(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(); + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + SearchConditionItem searchConditionItem = null; + + String filePath = "/hrm/import/templet/KQHolidaySet.xls"; + if(user.getLanguage()==9){ + filePath = "/hrm/import/templet/traditional/KQHolidaySet.xls"; + }else if(user.getLanguage()==8){ + filePath = "/hrm/import/templet/englisgh/KQHolidaySet.xls"; + } + + + groupItem.put("title", SystemEnv.getHtmlLabelName(384128, user.getLanguage()));//基本信息 + groupItem.put("defaultshow", true); + + //模板文件 + ConditionFactory conditionFactory = new ConditionFactory(user); + searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, 28576, "templet"); + searchConditionItem.setValue(filePath); + itemList.add(searchConditionItem); + + //Excel文件 + searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, 16630, "excelfile"); + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + + /*导入说明*/ + Map itemMap = null; + itemList = new ArrayList(); + groupItem = new HashMap(); + groupItem.put("title", SystemEnv.getHtmlLabelName(33803, user.getLanguage())); + groupItem.put("defaultshow", true); + + /*请先下载模板*/ + itemMap = new HashMap(); + itemMap.put("index", 0); + itemMap.put("value", SystemEnv.getHtmlLabelName(383083, user.getLanguage())); + itemMap.put("link", filePath); + itemList.add(itemMap); + + /* 填写模板数据后将文件上传。 */ + itemMap = new HashMap(); + itemMap.put("index", 1); + itemMap.put("value", SystemEnv.getHtmlLabelName(125452, user.getLanguage())); + itemList.add(itemMap); + + /*【考勤组】是必填列,请填写考勤组的名称*/ + itemMap = new HashMap(); + itemMap.put("index", 2); + itemMap.put("value", SystemEnv.getHtmlLabelName(390304, user.getLanguage())); + itemList.add(itemMap); + + /*【日期】列是必填列,日期格式为yyyy-MM-dd*/ + itemMap = new HashMap(); + itemMap.put("index", 3); + itemMap.put("value", SystemEnv.getHtmlLabelName(389753, user.getLanguage())); + itemList.add(itemMap); + + /*【类型】列是必填列,只能选择公众假日、调配工作日、调配休息日中的一种,当选择类型为调配工作日时,【对应工作日】必须选择一个工作日*/ + itemMap = new HashMap(); + itemMap.put("index", 4); + itemMap.put("value", SystemEnv.getHtmlLabelName(389754, user.getLanguage())); + itemList.add(itemMap); + + /* 【对应工作日】列只当【类型】列选择“调配工作日”时才需要选择 */ + itemMap = new HashMap(); + itemMap.put("index", 5); + itemMap.put("value", SystemEnv.getHtmlLabelName(389992, user.getLanguage())); + itemList.add(itemMap); + + /* 暂时不支持为排班制的考勤组设置节假日 */ + itemMap = new HashMap(); + itemMap.put("index", 6); + itemMap.put("value", SystemEnv.getHtmlLabelName(526272, user.getLanguage())); + itemList.add(itemMap); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + resultMap.put("status", "1"); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/GetRightMenuCmd.java b/src/com/engine/kq/cmd/holidaySet/GetRightMenuCmd.java new file mode 100644 index 0000000..f2350e5 --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/GetRightMenuCmd.java @@ -0,0 +1,90 @@ +package com.engine.kq.cmd.holidaySet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 节假日设置--列表--右键菜单 + */ +public class GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(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(); + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + int languageId = user.getLanguage();//用户选择的语言 + RightMenu rightMenu = null; + + String groupId = Util.null2String(params.get("groupId"));//考勤组的ID + if("".equals(groupId)||groupId.equals("0")){ + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } + boolean isList = Util.null2String(params.get("isList")).equals("true");//是日历还是清单 + boolean canAdd = HrmUserVarify.checkUserRight("KQHolidaySetAdd:Add", user);//是否具有新建权限 + boolean canDelete = HrmUserVarify.checkUserRight("KQHolidaySetDelete:Delete", user);//是否具有删除权限 + boolean canLog = HrmUserVarify.checkUserRight("KQHolidaySet:Log", user);//是否具有查看日志的权限 + if (canAdd) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Addnew, "new", true);//新建 + rightMenuList.add(rightMenu); + } + if (canAdd) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Import, "import", true);//导入 + rightMenuList.add(rightMenu); + } + if(canAdd && !isList){ + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Init, "init", true);//初始化 + rightMenuList.add(rightMenu); + } + if (canDelete && isList) { + List> menuList = new ArrayList>(); + if (canDelete) { + Map menuMap = new HashMap(); + menuMap.put("key", "0"); + menuMap.put("show", SystemEnv.getHtmlLabelName(32136, user.getLanguage()));//批量删除 + menuMap.put("selected", true); + menuList.add(menuMap); + + menuMap = new HashMap(); + menuMap.put("key", "1"); + menuMap.put("show", SystemEnv.getHtmlLabelName(19015, user.getLanguage()));//同步 + menuList.add(menuMap); + } + resultMap.put("buttonSelect", menuList); + } + if (canLog) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_log, "log", false);//日志 + rightMenuList.add(rightMenu); + } + if (isList) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_COLUMN, "custom", false); //显示列定制 + rightMenuList.add(rightMenu); + } + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/GetSearchConditionCmd.java b/src/com/engine/kq/cmd/holidaySet/GetSearchConditionCmd.java new file mode 100644 index 0000000..2b35d19 --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/GetSearchConditionCmd.java @@ -0,0 +1,47 @@ +package com.engine.kq.cmd.holidaySet; + +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.hrm.User; + +import java.util.*; + +/** + * 节假日设置--查询条件 + */ +public class GetSearchConditionCmd extends AbstractCommonCommand> { + + + public GetSearchConditionCmd(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(); + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + /*日历/清单、年份 等搜索条件写在前端的*/ + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/GetSearchListCmd.java b/src/com/engine/kq/cmd/holidaySet/GetSearchListCmd.java new file mode 100644 index 0000000..e43f0f8 --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/GetSearchListCmd.java @@ -0,0 +1,96 @@ +package com.engine.kq.cmd.holidaySet; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.general.PageIdConst; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.CompanyComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.location.LocationComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.Calendar; +import java.util.HashMap; +import java.util.Map; + +/** + * 节假日设置--清单 + */ +public class GetSearchListCmd extends AbstractCommonCommand> { + + 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(); + String groupId = Util.null2String(params.get("groupId"));//考勤组ID + String currentYear = Util.null2String(params.get("currentYear"));//年份 + String holidayDesc = Util.null2String(params.get("holidayDesc"));//说明 + String isSync = Util.null2String(params.get("isSync"));//同步还是批量删除:true--同步、false--批量删除 + + boolean canEdit = HrmUserVarify.checkUserRight("KQHolidaySetEdit:Edit", user);//是否具有编辑的权限; + boolean canDelete = HrmUserVarify.checkUserRight("KQHolidaySetDelete:Delete", user);//是否具有删除的权限; + boolean canLog = HrmUserVarify.checkUserRight("KQHolidaySet:Log", user);//是否具有查看日志的权限; + + /*如果没有传入年份,默认为今年的年份*/ + Calendar today = Calendar.getInstance(); + if (currentYear.equals("")) { + currentYear = "" + today.get(Calendar.YEAR); + } + + String backFields = " * "; + String sqlFrom = " from kq_HolidaySet "; + String sqlWhere = " where 1=1 "; + String orderBy = " groupId,holidayDate "; + + if (!groupId.equals("")) { + sqlWhere += " and groupId in (" + groupId + ")"; + } + if (!currentYear.equals("")) { + String dateFrom = currentYear + "-01-01"; + String dateTo = currentYear + "-12-31"; + sqlWhere += " and holidayDate>='" + dateFrom + "' and holidayDate<='" + dateTo + "'"; + } + if (!holidayDesc.equals("")) { + sqlWhere += " and holidayDesc like '%" + holidayDesc + "%'"; + } + String pageUid = "70efc34c-7a61-da9b-87a7-69a4a4d72859"; + String operateString = ""; + operateString = ""; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += ""; + String tableString = "" + + "" + + " " + + operateString + + " " + + " " + + " " + + " " + + " " + + " " + + "
"; + String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionKey, tableString); + resultMap.put("sessionkey", sessionKey); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/GetSyncFormCmd.java b/src/com/engine/kq/cmd/holidaySet/GetSyncFormCmd.java new file mode 100644 index 0000000..cdd11fd --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/GetSyncFormCmd.java @@ -0,0 +1,67 @@ +package com.engine.kq.cmd.holidaySet; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.filter.XssUtil; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 节假日设置--获取同步表单的数据 + */ +public class GetSyncFormCmd extends AbstractCommonCommand> { + + public GetSyncFormCmd(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(); + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + +// XssUtil xssUtil = new XssUtil(); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("syncGroupIds");//同步到考勤组--多选 + hrmFieldBean.setFieldlabel("390664"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("mkqgroup"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(529901, user.getLanguage())); + searchConditionItem.setRules("required|string"); + Map dataMap = new HashMap(); +// dataMap.put("sqlWhere", xssUtil.put(" kqtype!=2 ")); + searchConditionItem.getBrowserConditionParam().setDataParams(dataMap); + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/HasRepeatDataCmd.java b/src/com/engine/kq/cmd/holidaySet/HasRepeatDataCmd.java new file mode 100644 index 0000000..44f36a4 --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/HasRepeatDataCmd.java @@ -0,0 +1,89 @@ +package com.engine.kq.cmd.holidaySet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * 节假日设置--新建时选择的日期范围内是否已经存在设置过的数据 + */ +public class HasRepeatDataCmd extends AbstractCommonCommand> { + + public HasRepeatDataCmd(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(); + String groupId = Util.null2String(params.get("groupId"));//考勤组ID + String startDate = Util.null2String(params.get("startDate"));//开始日期 + String endDate = Util.null2String(params.get("endDate"));//结束日期 + try{ + boolean canAdd = HrmUserVarify.checkUserRight("KQHolidaySetAdd:Add", user); + if (!canAdd) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + boolean hasRepeatData = false; + RecordSet recordSet = new RecordSet(); + int days = Util.dayDiff(startDate, endDate); + for (int i = 0; i < days; i++) { + String holidayDate = getDateDel(startDate, i); + String sql = "select * from kq_HolidaySet where groupId="+groupId+" and holidayDate='"+holidayDate+"'"; + recordSet.executeQuery(sql); + if(recordSet.next()){ + hasRepeatData = true; + break; + } + } + resultMap.put("hasRepeatData",hasRepeatData);//为true表示所选的时间范围内有设置过数据,请确认是否覆盖 + }catch (Exception e){ + e.printStackTrace(); + } + return resultMap; + } + + /** + * 获取与data相隔num天的日期 + * + * @param date + * @param num + * @return + */ + private static String getDateDel(String date, int num) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + Date tempDate = null; + try { + tempDate = simpleDateFormat.parse(date); + } catch (ParseException e) { + e.printStackTrace(); + } + calendar.setTime(tempDate); + calendar.add(Calendar.DATE, num); + tempDate = calendar.getTime(); + date = simpleDateFormat.format(tempDate); + return date; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/InitHolidaySetCmd.java b/src/com/engine/kq/cmd/holidaySet/InitHolidaySetCmd.java new file mode 100644 index 0000000..b28a2b4 --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/InitHolidaySetCmd.java @@ -0,0 +1,85 @@ +package com.engine.kq.cmd.holidaySet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQHolidaySetBiz; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class InitHolidaySetCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public InitHolidaySetCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String groupId = Util.null2String(params.get("groupId"));//考勤组的ID + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_HOLIDAYSET);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_HOLIDAYSET);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_HolidaySet where groupId=" + groupId; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4HolidaySet","column:groupId+column:holidayDate+"+user.getLanguage());//当前targetName对应的列(对应日志中的对象名) + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + + String groupId = Util.null2String(params.get("groupId"));//考勤组的ID + String currentYear = Util.null2String(params.get("currentYear"));//年份 + try { + /** + * 调用初始化考勤组节假日的接口(只初始化公众假日,调配休息日和调配工作日需要单个维护) + * 返回的数据格式: + * status: 0-初始化失败、1-初始化成功 + * sketch: '简述' + * description[ + * '详细说明1', + * '详细说明2', …… + * '详细说明N' + * ] + */ + Map tempMap = KQHolidaySetBiz.initHolidaySet(groupId, currentYear,user); + if ("0".equals((String) tempMap.get("status"))) { + resultMap.put("status", "-1"); + resultMap.put("message", tempMap.get("sketch")); + } else { + resultMap.put("status", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(20196, user.getLanguage())); + } + } catch (Exception e) { + writeLog(e); + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(125960, user.getLanguage())); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/SaveImportCmd.java b/src/com/engine/kq/cmd/holidaySet/SaveImportCmd.java new file mode 100644 index 0000000..4ceba9a --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/SaveImportCmd.java @@ -0,0 +1,68 @@ +package com.engine.kq.cmd.holidaySet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.util.ImportProcessUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 节假日设置--保存导入 + */ +public class SaveImportCmd extends AbstractCommonCommand> { + + private HttpServletRequest request; + + public SaveImportCmd(Map params, HttpServletRequest request, User user) { + this.user = user; + this.params = params; + this.request = request; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canAdd = HrmUserVarify.checkUserRight("KQHolidaySetAdd:Add", user); + if (!canAdd) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + List errorInfoList = new ArrayList(); + ImportProcessUtil importProcessUtil = new ImportProcessUtil(); + List errorInfo = importProcessUtil.importXls(params, user, request); + if (errorInfo != null && !errorInfo.isEmpty()) { + Map error = null; + for (int i = 0; i < errorInfo.size(); i++) { + error = new HashMap(); + error.put("message", Util.null2String(errorInfo.get(i))); + errorInfoList.add(error); + } + } + resultMap.put("errorInfo", errorInfoList); + resultMap.put("status", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(24645, user.getLanguage())); + } catch (Exception e) { + writeLog("导入节假日设置数据失败:" + e); + resultMap.put("status", "-1"); + resultMap.put("message", e.getMessage()); + } + resultMap.put("pId", request.getSession(true).getAttribute("KQHolidaySetPId")); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/holidaySet/SyncHolidaySetCmd.java b/src/com/engine/kq/cmd/holidaySet/SyncHolidaySetCmd.java new file mode 100644 index 0000000..eda75e5 --- /dev/null +++ b/src/com/engine/kq/cmd/holidaySet/SyncHolidaySetCmd.java @@ -0,0 +1,131 @@ +package com.engine.kq.cmd.holidaySet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 节假日设置--同步 + */ +public class SyncHolidaySetCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public SyncHolidaySetCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String syncGroupIds = Util.null2String(params.get("syncGroupIds"));//需要同步的考勤组ID + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_HOLIDAYSET);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_HOLIDAYSET);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_HolidaySet where groupId in (" + syncGroupIds + ")"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4HolidaySet", "column:groupId+column:holidayDate+" + user.getLanguage());//当前targetName对应的列(对应日志中的对象名) + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + String ids = Util.null2String(params.get("ids"));//kq_HolidaySet的主键ID + String syncGroupIds = Util.null2String(params.get("syncGroupIds"));//考勤组的ID + try { + boolean flag = true; + + String deleteSql = "delete from kq_HolidaySet where groupId=? and holidayDate=?"; + String insertSql = " insert into kq_HolidaySet(groupId,holidayDate,changeType,holidayDesc,relatedDay) values(?,?,?,?,?)"; + + String[] idArr = ids.split(","); + String[] groupIdArr = syncGroupIds.split(","); + RecordSet recordSet = new RecordSet(); + KQHolidaySetComInfo kqHolidaySetComInfo = new KQHolidaySetComInfo(); + for (int i = 0; i < idArr.length; i++) { + String id = idArr[i]; + String sql = "select * from kq_holidaySet where id=?"; + recordSet.executeQuery(sql, id); + if(recordSet.next()) { + String holidayDate = recordSet.getString("holidayDate"); + String holidayDesc = recordSet.getString("holidayDesc"); + String changeType = recordSet.getString("changeType"); + String relatedDay = recordSet.getString("relatedDay"); + + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + for (int j = 0; j < groupIdArr.length; j++) { + String groupId = groupIdArr[j]; + + if (Util.null2String(kqGroupComInfo.getKqtype(groupId)).equals("2") && changeType.equals("2")) { + continue; + } + recordSet.executeUpdate(deleteSql, groupId, holidayDate); + flag = recordSet.executeUpdate(insertSql, groupId, holidayDate, changeType, holidayDesc, relatedDay); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + } + + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } + } catch (Exception e) { + e.printStackTrace(); + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } finally { + /*刷新缓存*/ + KQHolidaySetComInfo kqHolidaySetComInfo = new KQHolidaySetComInfo(); + kqHolidaySetComInfo.removeCache(); + + /*刷新考勤报表*/ + List holidatDateList = new ArrayList(); + RecordSet recordSet = new RecordSet(); + String sql = " select * from kq_holidaySet where id in (" + ids + ") "; + recordSet.executeQuery(sql); + while (recordSet.next()) { + String holidayDate = recordSet.getString("holidayDate"); + if (!holidatDateList.contains(holidayDate)) { + holidatDateList.add(holidayDate); + } + } + List groupIdList = Util.TokenizerString(syncGroupIds,","); + new KQHolidaySetThread(groupIdList,holidatDateList).start(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/ChangeStateProcSetStatusCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/ChangeStateProcSetStatusCmd.java new file mode 100644 index 0000000..a5eb457 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/ChangeStateProcSetStatusCmd.java @@ -0,0 +1,95 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 改变考勤流程设置的信息 + * @author pzy + * + */ +public class ChangeStateProcSetStatusCmd extends AbstractCommonCommand>{ + + private SimpleBizLogger logger; + + public ChangeStateProcSetStatusCmd(Map params, User user) { + this.user = user; + this.params = params; + HrmAttProcSetLogUtil hrmAttProcSetLogUtil = new HrmAttProcSetLogUtil(user,BizLogType.HRM_ENGINE, BizLogSmallType4Hrm.HRM_ENGINE_HRM_ATT_PROCSET, BizLogSmallType4Hrm.HRM_ENGINE_HRM_ATT_PROCSET); + int id = StringUtil.parseToInt(StringUtil.vString(params.get("id")), 0); + String realLogSql = "select *from kq_ATT_PROC_SET where "+Util.getSubINClause(""+id, "id", "in");; + this.logger = hrmAttProcSetLogUtil.logStateSetLogSql(true, realLogSql, params,"basicinfo"); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + RecordSet rs = new RecordSet(); + try { + if(!HrmUserVarify.checkUserRight("HrmAttendanceProcess:setting", user)){ + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + int id = StringUtil.parseToInt(StringUtil.vString(params.get("id")), 0); + HrmAttProcSetManager attProcSetManager = new HrmAttProcSetManager(); + HrmAttProcSet bean = attProcSetManager.get(id); + if(bean != null) { + int workflowid = bean.getField001(); + int field006 = bean.getField006(); + int isuse = StringUtil.parseToInt(StringUtil.vString(params.get("field005")), 1); + if(isuse == 1){ + //启用 + attProcSetManager.welcomeToSet(workflowid, field006,"","",""); + }else{ + //禁用 + rs.executeSql(new StringBuffer("update workflow_base set custompage = '', custompage4Emoble = '' where id = "+workflowid).toString()); + } + bean.setField005(isuse); + bean.setField009(DateUtil.getCurrentDate()); + attProcSetManager.update(bean); + retmap.put("status", "true"); + } else retmap.put("status", "false"); + + + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/DelCustomKQFlowCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/DelCustomKQFlowCmd.java new file mode 100644 index 0000000..0fb1971 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/DelCustomKQFlowCmd.java @@ -0,0 +1,66 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 删除 自定义考勤流程 + * @author pzy + * + */ +public class DelCustomKQFlowCmd extends AbstractCommonCommand>{ + + public DelCustomKQFlowCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + try { + if(!HrmUserVarify.checkUserRight("HrmAttendanceProcess:setting", user)){ + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + List> tabs = new ArrayList>(); + Map tab = null; + + tab = new HashMap(); + tab.put("key", "1"); + tab.put("title", SystemEnv.getHtmlLabelName(500272,user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", "2"); + tab.put("title", SystemEnv.getHtmlLabelName(10000813,weaver.general.Util.getIntValue(user.getLanguage()))); + tabs.add(tab); + + retmap.put("status", "1"); + retmap.put("tabs", tabs); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/DelStateProcCheckRuleCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/DelStateProcCheckRuleCmd.java new file mode 100644 index 0000000..1af19a9 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/DelStateProcCheckRuleCmd.java @@ -0,0 +1,89 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 考勤流程 删除校验规则 + * @author pzy + * + */ +public class DelStateProcCheckRuleCmd extends AbstractCommonCommand>{ + + private SimpleBizLogger logger; + + public DelStateProcCheckRuleCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + try { + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + RecordSet rs3 = new RecordSet(); + String ids = StringUtil.vString(params.get("ids")); + List idList = Util.splitString2List(ids, ","); + for(String id : idList){ + String sql = "select * from kq_att_checkrule_set where id = ? "; + rs.executeQuery(sql,id); + if(rs.next()){ + String ruleid = rs.getString("ruleid"); + String rule_type_uuid = rs.getString("rule_type_uuid"); + String sql1 = "select * from kq_att_checkrule_type where uuid=? "; + rs1.executeQuery(sql1,rule_type_uuid); + boolean isDel = false; + if (rs1.next()) { + String rule_table = rs1.getString("rule_table"); + String sql2 = "delete from " +rule_table+" where id = ? "; + isDel = rs2.executeUpdate(sql2,ruleid); + } + if(isDel){ + String sql3 = "delete from kq_att_checkrule_set where id=? "; + isDel = rs3.executeUpdate(sql3,id); + } + } + } + + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/DelStateProcSetCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/DelStateProcSetCmd.java new file mode 100644 index 0000000..f069906 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/DelStateProcSetCmd.java @@ -0,0 +1,73 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 删除考勤流程设置 + * @author pzy + * + */ +public class DelStateProcSetCmd extends AbstractCommonCommand>{ + + private SimpleBizLogger logger; + + public DelStateProcSetCmd(Map params, User user) { + this.user = user; + this.params = params; + HrmAttProcSetLogUtil hrmAttProcSetLogUtil = new HrmAttProcSetLogUtil(user,BizLogType.HRM_ENGINE, BizLogSmallType4Hrm.HRM_ENGINE_HRM_ATT_PROCSET, BizLogSmallType4Hrm.HRM_ENGINE_HRM_ATT_PROCSET); + String ids = StringUtil.vString(params.get("ids")); + String realLogSql = "select *from kq_ATT_PROC_SET where "+Util.getSubINClause(""+ids, "id", "in");; + this.logger = hrmAttProcSetLogUtil.logStateSetLogSql(true, realLogSql, params,"basicinfo"); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + try { + if(!HrmUserVarify.checkUserRight("HrmAttendanceProcess:setting", user)){ + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + String ids = StringUtil.vString(params.get("ids")); + HrmAttProcSetManager attProcSetManager = new HrmAttProcSetManager(); + attProcSetManager.delete(ids); + + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/GetCustomKQFlowFormCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/GetCustomKQFlowFormCmd.java new file mode 100644 index 0000000..ab9a9d2 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/GetCustomKQFlowFormCmd.java @@ -0,0 +1,302 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.workflow.workflow.WorkflowBillComInfo; +import weaver.workflow.workflow.WorkflowComInfo; + +/** + * 获取自定义考勤流程 新建编辑表单页面 + * @author pzy + * + */ +public class GetCustomKQFlowFormCmd extends AbstractCommonCommand>{ + + public GetCustomKQFlowFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + try { + + ManageDetachComInfo ManageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = ManageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + String hrmdftsubcomid = ManageDetachComInfo.getHrmdftsubcomid();//分权默认分部 + + RecordSet rs = new RecordSet(); + HrmAttProcSetManager attProcSetManager = new HrmAttProcSetManager(); + WorkflowComInfo wfci=new WorkflowComInfo(); + WorkflowBillComInfo wbc = new WorkflowBillComInfo(); + SubCompanyComInfo sc = new SubCompanyComInfo(); + + String id = StringUtil.vString(params.get("id")); + int subcompanyid = StringUtil.parseToInt(StringUtil.vString(params.get("subcompanyid")), 0); + subcompanyid = subcompanyid < 0 ? 0 : subcompanyid; + + boolean isEdit = id.length() > 0; + HrmAttProcSet bean = isEdit ? attProcSetManager.get(id) : null; + bean = bean == null ? new HrmAttProcSet() : bean; + boolean isForm = bean.isSysForm(); + if(bean.getField004() <= 0) bean.setField004(subcompanyid); + //流程路径 对应表单 所属分部 是否启用 变更流程类型 是否启用明细 模板文件 模板文件(手机版) 模板地址 流程可抵扣打卡記錄 + String[] fields = new String[]{"field001,34067,3,-99991","field002,15600,3,wfFormBrowser","field004,19799,3,169", + "field005,18095,4,2","field006,84791,5,1","usedetail,18411,4,2","flow_deduct_card,512290,4,2", + "templetfile,19971,1,1","templetmobilefile,19971,1,1","templetroute,82482,1,1"}; + String[] values = new String[fields.length]; + if(isEdit){ + values[0] = ""+bean.getField001(); + values[1] = ""+bean.getField002(); + values[2] = ""+bean.getField004(); + values[3] = Util.null2o(""+bean.getField005()); + values[4] = ""+bean.getField006(); + values[5] = ""+bean.getUsedetail(); + values[6] = ""+bean.getFlow_deduct_card(); + String custompage = ""; + String custompage4Emoble = ""; + String templetroute = ""; + switch (bean.getField006()){ + case 0 : + custompage = KqTempletEnum.LEAVE.getTempletfile(); + custompage4Emoble = KqTempletEnum.LEAVE.getTempletmobilefile(); + templetroute = KqTempletEnum.LEAVE.getTempletroute(); + break; + case 1 : + custompage = KqTempletEnum.EVECTION.getTempletfile(); + custompage4Emoble = KqTempletEnum.EVECTION.getTempletmobilefile(); + templetroute = KqTempletEnum.EVECTION.getTempletroute(); + break; + case 2 : + custompage = KqTempletEnum.OUT.getTempletfile(); + custompage4Emoble = KqTempletEnum.OUT.getTempletmobilefile(); + templetroute = KqTempletEnum.OUT.getTempletroute(); + break; + case 3 : + custompage = KqTempletEnum.OVERTIME.getTempletfile(); + custompage4Emoble = KqTempletEnum.OVERTIME.getTempletmobilefile(); + templetroute = KqTempletEnum.OVERTIME.getTempletroute(); + break; + case 4 : + custompage = KqTempletEnum.OTHER.getTempletfile(); + custompage4Emoble = KqTempletEnum.OTHER.getTempletmobilefile(); + templetroute = KqTempletEnum.OTHER.getTempletroute(); + break; + case 5 : + custompage = KqTempletEnum.SHIFT.getTempletfile(); + custompage4Emoble = KqTempletEnum.SHIFT.getTempletmobilefile(); + templetroute = KqTempletEnum.SHIFT.getTempletroute(); + break; + case 6 : + custompage = KqTempletEnum.LEAVEBACK.getTempletfile(); + custompage4Emoble = KqTempletEnum.LEAVEBACK.getTempletmobilefile(); + templetroute = KqTempletEnum.LEAVEBACK.getTempletroute(); + break; + case 7 : + custompage = KqTempletEnum.Card.getTempletfile(); + custompage4Emoble = KqTempletEnum.Card.getTempletmobilefile(); + templetroute = KqTempletEnum.Card.getTempletroute(); + break; + case 8 : + custompage = KqTempletEnum.PROCESSCHANGE.getTempletfile(); + custompage4Emoble = KqTempletEnum.PROCESSCHANGE.getTempletmobilefile(); + templetroute = KqTempletEnum.PROCESSCHANGE.getTempletroute(); + break; + default: + break; + } + values[7] = ""+Util.null2s(bean.getTempletfile(), custompage); + values[8] = ""+Util.null2s(bean.getTempletmobilefile(), custompage4Emoble); + values[9] = ""+Util.null2s(bean.getTempletroute(), templetroute); + } + + Map descMaps = new HashMap<>(); + Map tipMaps = new HashMap<>(); + + String[] optionIndex = new String[]{"-1","0","1","2","3","5","6","7","8"}; + String[] optionLabel = new String[]{"","670,18015","20084,18015","24058,18015","6151,18015","390737","24473,18015","390274","513400"}; + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + itemlist = new ArrayList(); + groupitem = new HashMap(); + List> replaceDatas = new ArrayList>(); + Map datas = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(1361,weaver.general.Util.getIntValue(user.getLanguage()))); + groupitem.put("defaultshow", true); + for(int i=0;i 0){ + hrmFieldBean.setFieldvalue(values[i]); + }else{ + hrmFieldBean.setFieldvalue(hrmdftsubcomid); + } + }else{ + //不开启分权的话,不显示分部 + continue; + } + } + + replaceDatas = new ArrayList>(); + datas = new HashMap(); + + if("field006".equals(hrmFieldBean.getFieldname())){ + List options = new ArrayList(); + if(isEdit){ + for(int k = 0; k < optionIndex.length ; k++){ + if(k == Util.getIntValue(values[i])){ + options.add(new SearchConditionOption(optionIndex[Util.getIntValue(values[i])],SystemEnv.getHtmlLabelNames(optionLabel[Util.getIntValue(values[i])], user.getLanguage()),true)); + }else{ + options.add(new SearchConditionOption(optionIndex[k],SystemEnv.getHtmlLabelNames(optionLabel[k],user.getLanguage()))); + } + } + }else{ + for(int k = 0; k < optionIndex.length ; k++){ + SearchConditionOption SearchConditionOption1 = new SearchConditionOption(optionIndex[k],SystemEnv.getHtmlLabelNames(optionLabel[k],user.getLanguage())); + if(k == 0){ + SearchConditionOption1.setSelected(true); + } + options.add(SearchConditionOption1); + } + } + hrmFieldBean.setSelectOption(options); + } + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if("field001".equals(hrmFieldBean.getFieldname())){ + searchConditionItem.getBrowserConditionParam().getDataParams().put("isWfTree", "1"); + searchConditionItem.getBrowserConditionParam().setHasAddBtn(true); + searchConditionItem.getBrowserConditionParam().setViewAttr(3); + if(isEdit){ + String tmpWfId = values[i]; + String wfname = wfci.getWorkflowname(tmpWfId); + datas.put("id",tmpWfId); + datas.put("name",wfname); + replaceDatas.add(datas); + searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas); + } + } + if("field002".equals(hrmFieldBean.getFieldname())){ + searchConditionItem.getBrowserConditionParam().setHasAddBtn(true); + searchConditionItem.getBrowserConditionParam().setViewAttr(3); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(82815,user.getLanguage())); + if(isEdit){ + String tmpFormId = values[i]; + String wfname = SystemEnv.getHtmlLabelNames(wbc.getNamelabel(tmpFormId),user.getLanguage()); + datas.put("id",tmpFormId); + datas.put("name",wfname); + replaceDatas.add(datas); + searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas); + } + } + if("flow_deduct_card".equals(hrmFieldBean.getFieldname())){ + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(512291,user.getLanguage())); + } + if("field004".equals(hrmFieldBean.getFieldname())){ + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "HrmAttendanceProcess:setting"); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("rightStr", "HrmAttendanceProcess:setting"); + } + if("field005".equals(hrmFieldBean.getFieldname())){ + if(isForm){ + searchConditionItem.setViewAttr(1); + } + } + searchConditionItem.setRules("required|string"); + searchConditionItem.setLabelcol(6); + searchConditionItem.setFieldcol(18); + + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + lsGroup.add(groupitem); + retmap.put("condition", lsGroup); + retmap.put("desc", descMaps); + retmap.put("tips", tipMaps); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/GetCustomKQFlowSearchConditionCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/GetCustomKQFlowSearchConditionCmd.java new file mode 100644 index 0000000..6597399 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/GetCustomKQFlowSearchConditionCmd.java @@ -0,0 +1,79 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取自定义考勤流程 查询条件 + * @author pzy + * + */ +public class GetCustomKQFlowSearchConditionCmd extends AbstractCommonCommand>{ + + public GetCustomKQFlowSearchConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + try{ + + //名称 报表显示名称 + String[] fields = new String[]{"name,34067,1,1","reportname,515882,1,1"}; + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + itemlist = new ArrayList(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(20331, user.getLanguage())); + groupitem.put("defaultshow", true); + for(int i=0;i>{ + + public GetCustomKQFlowSearchListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + try { + if(!HrmUserVarify.checkUserRight("HrmAttendanceProcess:setting", user)){ + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + List> tabs = new ArrayList>(); + Map tab = null; + + tab = new HashMap(); + tab.put("key", "1"); + tab.put("title", SystemEnv.getHtmlLabelName(500272,user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", "2"); + tab.put("title", SystemEnv.getHtmlLabelName(10000813,weaver.general.Util.getIntValue(user.getLanguage()))); + tabs.add(tab); + + retmap.put("status", "1"); + retmap.put("tabs", tabs); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/GetCustomKQFlowTabCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/GetCustomKQFlowTabCmd.java new file mode 100644 index 0000000..9e65c0c --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/GetCustomKQFlowTabCmd.java @@ -0,0 +1,66 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取自定义考勤流程tab页签 + * @author pzy + * + */ +public class GetCustomKQFlowTabCmd extends AbstractCommonCommand>{ + + public GetCustomKQFlowTabCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + try { + if(!HrmUserVarify.checkUserRight("HrmAttendanceProcess:setting", user)){ + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + List> tabs = new ArrayList>(); + Map tab = null; + + tab = new HashMap(); + tab.put("key", "1"); + tab.put("title", SystemEnv.getHtmlLabelName(500272,user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", "2"); + tab.put("title", SystemEnv.getHtmlLabelName(10000813,weaver.general.Util.getIntValue(user.getLanguage()))); + tabs.add(tab); + + retmap.put("status", "1"); + retmap.put("tabs", tabs); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/GetProcSetCheckRuleCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/GetProcSetCheckRuleCmd.java new file mode 100644 index 0000000..21d1c10 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/GetProcSetCheckRuleCmd.java @@ -0,0 +1,455 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQAttProcSetComInfo; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 新建编辑 校验规则 + * @author pzy + * + */ +public class GetProcSetCheckRuleCmd extends AbstractCommonCommand>{ + + public GetProcSetCheckRuleCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + try { + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String id = Util.null2s(Util.null2String(params.get("id")),""); + //校验规则的 校验类型 如果没有传过来,默认就是第一个 + String rule_type_uuid = Util.null2s(Util.null2String(params.get("rule_type_uuid")),""); + //考勤流程设置的id 取值自kq_att_proc_set + String attid = Util.null2s(Util.null2String(params.get("attid")),""); + + boolean isEdit = id.length() > 0; + String ruleid = ""; + String edit_sql = "select *from kq_att_checkrule_set where id = ? "; + rs.executeQuery(edit_sql, id); + if(rs.next()){ + attid = rs.getString("attid"); + ruleid = rs.getString("ruleid"); + rule_type_uuid = rs.getString("rule_type_uuid"); + } + + if(attid.length() == 0 ){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(500682, user.getLanguage())); + return retmap; + } + String kqtype = ""; + String att_sql = "select * from kq_att_proc_set where id = ? "; + rs.executeQuery(att_sql,attid); + if(rs.next()){ + kqtype = rs.getString("field006"); + } + if(kqtype.length() == 0 ){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(500682, user.getLanguage())); + return retmap; + } + + //如果新增的时候,下拉框需要有个默认值 + if(rule_type_uuid.length() == 0){ + String att_type_sql = "select * from kq_att_checkrule_type where att_type = ? order by rule_type_order "; + rs.executeQuery(att_type_sql,kqtype); + if(rs.next()){ + rule_type_uuid = rs.getString("uuid"); + } + } + //需要回显的动态提示内容 + Map msg = Maps.newHashMap(); + //因为提示语句是要根据选择的内容动态回显的,针对这样的字段增加动态映射 + Map field_map = Maps.newHashMap(); + get_field_map(field_map,rule_type_uuid); + + //得到下拉框校验类型的数据 + Map labelidMap = Maps.newLinkedHashMap(); + get_labelidMap(labelidMap,kqtype); + + //根据下拉框的校验类型,获取到每种类型对应的校验字段 + List> fieldList = Lists.newArrayList(); + get_fieldList(fieldList,rule_type_uuid); + + //校验类型 校验规则 需校验流程路径 校验强度 提示语句 + String[] fields = new String[fieldList.size()]; + for(int i = 0 ; i < fieldList.size() ; i++){ + Map fieldMap = fieldList.get(i); + fields[i] = fieldMap.get("fieldname")+","+fieldMap.get("fieldlabel")+","+fieldMap.get("fieldhtmltype")+","+fieldMap.get("fieldtype"); + } + + String[] values = new String[fieldList.size()]; + if(isEdit){ + //编辑情况下,根据字段对应把每个字段对应的值返还 + get_edit_value(values,rule_type_uuid,fieldList,ruleid); + } + + /** + * 根据什么字段的什么条件来联动 + */ + Map to_related_map = Maps.newHashMap(); + //需要被联动的字段 + Map from_related_map = Maps.newHashMap(); + + List> replaceDatas = new ArrayList>(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + List options = Lists.newArrayList(); + itemlist = new ArrayList(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(1361,weaver.general.Util.getIntValue(user.getLanguage()))); + groupitem.put("defaultshow", true); + for(int i=0;i>(); + + if("rule_type_uuid".equalsIgnoreCase(hrmFieldBean.getFieldname())){ + options = Lists.newArrayList(); + for(Iterator mapIterator = labelidMap.keySet().iterator();mapIterator.hasNext();){ + String key = Util.null2String(mapIterator.next()); + String val = labelidMap.get(key); + SearchConditionOption searchConditionOption = new SearchConditionOption(key,SystemEnv.getHtmlLabelNames(val, user.getLanguage())); + if(isEdit){ + if(values[i].equalsIgnoreCase(key)){ + searchConditionOption.setSelected(true); + } + }else{ + if(key.equalsIgnoreCase(rule_type_uuid)){ + searchConditionOption.setSelected(true); + hrmFieldBean.setFieldvalue(key); + } + } + options.add(searchConditionOption); + } + hrmFieldBean.setSelectOption(options); + } + if("duplicate_rule".equalsIgnoreCase(hrmFieldBean.getFieldname())){ + options = Lists.newArrayList(); + SearchConditionOption SearchConditionOption1 = new SearchConditionOption("0",SystemEnv.getHtmlLabelName(516103,weaver.general.Util.getIntValue(user.getLanguage()))); + SearchConditionOption SearchConditionOption2 = new SearchConditionOption("1",SystemEnv.getHtmlLabelName(516104,weaver.general.Util.getIntValue(user.getLanguage()))); + options.add(SearchConditionOption1); + options.add(SearchConditionOption2); + hrmFieldBean.setSelectOption(options); + if(!isEdit){ + hrmFieldBean.setFieldvalue("0"); + SearchConditionOption1.setSelected(true); + }else{ + if("0".equalsIgnoreCase(values[i])){ + SearchConditionOption1.setSelected(true); + }else if("1".equalsIgnoreCase(values[i])){ + SearchConditionOption2.setSelected(true); + } + } + } + if("duplicate_level".equalsIgnoreCase(hrmFieldBean.getFieldname()) || "frequency_level".equalsIgnoreCase(hrmFieldBean.getFieldname())){ + options = Lists.newArrayList(); + SearchConditionOption SearchConditionOption1 = new SearchConditionOption("0",SystemEnv.getHtmlLabelName(32137,weaver.general.Util.getIntValue(user.getLanguage()))); + SearchConditionOption SearchConditionOption2 = new SearchConditionOption("1",SystemEnv.getHtmlLabelName(32138,weaver.general.Util.getIntValue(user.getLanguage()))); + SearchConditionOption SearchConditionOption3 = new SearchConditionOption("2",SystemEnv.getHtmlLabelName(26009,weaver.general.Util.getIntValue(user.getLanguage()))); + options.add(SearchConditionOption1); + options.add(SearchConditionOption2); + options.add(SearchConditionOption3); + hrmFieldBean.setSelectOption(options); + if(!isEdit){ + hrmFieldBean.setFieldvalue("0"); + SearchConditionOption1.setSelected(true); + }else{ + if("0".equalsIgnoreCase(values[i])){ + SearchConditionOption1.setSelected(true); + }else if("1".equalsIgnoreCase(values[i])){ + SearchConditionOption2.setSelected(true); + }else if("1".equalsIgnoreCase(values[i])){ + SearchConditionOption3.setSelected(true); + } + } + if(field_map.containsValue(hrmFieldBean.getFieldname())){ + if("duplicate_level".equalsIgnoreCase(hrmFieldBean.getFieldname())){ + msg.put("check_level_0", SystemEnv.getHtmlLabelName(516560,weaver.general.Util.getIntValue(user.getLanguage()))); + msg.put("check_level_1", SystemEnv.getHtmlLabelName(516561,weaver.general.Util.getIntValue(user.getLanguage()))); + }else if("frequency_level".equalsIgnoreCase(hrmFieldBean.getFieldname())){ + msg.put("check_level_0", SystemEnv.getHtmlLabelName(516562,weaver.general.Util.getIntValue(user.getLanguage()))); + msg.put("check_level_1", SystemEnv.getHtmlLabelName(516563,weaver.general.Util.getIntValue(user.getLanguage()))); + } + } + } + if("frequency_rule".equalsIgnoreCase(hrmFieldBean.getFieldname())){ + options = Lists.newArrayList(); + SearchConditionOption SearchConditionOption1 = new SearchConditionOption("0",SystemEnv.getHtmlLabelName(539,weaver.general.Util.getIntValue(user.getLanguage()))); + SearchConditionOption SearchConditionOption2 = new SearchConditionOption("1",SystemEnv.getHtmlLabelName(545,weaver.general.Util.getIntValue(user.getLanguage()))); + SearchConditionOption SearchConditionOption3 = new SearchConditionOption("2",SystemEnv.getHtmlLabelName(541,weaver.general.Util.getIntValue(user.getLanguage()))); + SearchConditionOption SearchConditionOption4 = new SearchConditionOption("3",SystemEnv.getHtmlLabelName(543,weaver.general.Util.getIntValue(user.getLanguage()))); + SearchConditionOption SearchConditionOption5 = new SearchConditionOption("4",SystemEnv.getHtmlLabelName(546,weaver.general.Util.getIntValue(user.getLanguage()))); + options.add(SearchConditionOption1); + options.add(SearchConditionOption2); + options.add(SearchConditionOption3); + options.add(SearchConditionOption4); + options.add(SearchConditionOption5); + hrmFieldBean.setSelectOption(options); + if(!isEdit){ + hrmFieldBean.setFieldvalue("0"); + SearchConditionOption1.setSelected(true); + }else{ + if("0".equalsIgnoreCase(values[i])){ + SearchConditionOption1.setSelected(true); + }else if("1".equalsIgnoreCase(values[i])){ + SearchConditionOption2.setSelected(true); + }else if("2".equalsIgnoreCase(values[i])){ + SearchConditionOption3.setSelected(true); + }else if("3".equalsIgnoreCase(values[i])){ + SearchConditionOption4.setSelected(true); + }else if("4".equalsIgnoreCase(values[i])){ + SearchConditionOption5.setSelected(true); + } + } + } + if("duplicate_message".equalsIgnoreCase(hrmFieldBean.getFieldname())){ + if(!isEdit){ + hrmFieldBean.setFieldvalue(SystemEnv.getHtmlLabelName(516560,weaver.general.Util.getIntValue(user.getLanguage()))); + } + } + if("frequency_message".equalsIgnoreCase(hrmFieldBean.getFieldname())){ + if(!isEdit){ + hrmFieldBean.setFieldvalue(SystemEnv.getHtmlLabelName(516562,weaver.general.Util.getIntValue(user.getLanguage()))); + } + } + if(isEdit){ + hrmFieldBean.setFieldvalue(values[i]); + + if("rule_type_uuid".equalsIgnoreCase(hrmFieldBean.getFieldname())){ + hrmFieldBean.setViewAttr(1); + } + } + + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if("duplicate_level".equals(hrmFieldBean.getFieldname())){ + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(516108,weaver.general.Util.getIntValue(user.getLanguage()))); + } + if("duplicate_rule".equals(hrmFieldBean.getFieldname())){ + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(516168,weaver.general.Util.getIntValue(user.getLanguage()))); + } + if("duplicate_wfids".equalsIgnoreCase(hrmFieldBean.getFieldname())){ + if(isEdit){ + String tmpAttId = values[i]; + String workflowname = ""; + int version = 1; + List tmpAttIdList = Arrays.asList(tmpAttId.split(",")); + List vals = Lists.newArrayList(); + String id_str = ""; + for(String tmp_id : tmpAttIdList){ + id_str += ",?"; + vals.add(tmp_id); + } + if(id_str.length() > 0){ + id_str = id_str.substring(1); + } + String tmp_att_sql = "select * from workflow_base where id in("+id_str+")"; + rs.executeQuery(tmp_att_sql, vals); + while (rs.next()){ + Map datas = new HashMap(); + String wfid = rs.getString("id"); + workflowname = Util.null2String(rs.getString("workflowname")); + version = Util.getIntValue(rs.getString("version"),1); + workflowname = workflowname+"("+SystemEnv.getHtmlLabelName(33569,user.getLanguage()) + +SystemEnv.getHtmlLabelName(567,user.getLanguage())+":V"+version+")"; + datas.put("id",wfid); + datas.put("name",workflowname); + replaceDatas.add(datas); + } + searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas); + } + if("5".equalsIgnoreCase(rule_type_uuid)) { + //补卡流程 只能和补卡流程比较 + searchConditionItem.getBrowserConditionParam().getDataParams().put("kqtype", "7"); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("kqtype", "7"); + }else{ + //目前只有请假,出差,公出和加班流程可以比较 + searchConditionItem.getBrowserConditionParam().getDataParams().put("kqtype", "0,1,2,3,8"); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("kqtype", "0,1,2,3,8"); + } + } + searchConditionItem.setRules("required|string"); + searchConditionItem.setLabelcol(6); + searchConditionItem.setFieldcol(18); + + if("frequency_rule_count".equals(hrmFieldBean.getFieldname())){ + searchConditionItem.setRules("required|integer"); + Map otherParams = new HashMap(); + otherParams.put("min",1); + searchConditionItem.setOtherParams(otherParams); + } + + itemlist.add(searchConditionItem); + } + List msglist = new ArrayList<>(); + Map item = new HashMap(); + item.put("label", SystemEnv.getHtmlLabelName(516109,user.getLanguage())); + if("6".equalsIgnoreCase(rule_type_uuid)){ + //次数校验的补卡流程 + item.put("msg", SystemEnv.getHtmlLabelName(516638,user.getLanguage()) + +"
"+SystemEnv.getHtmlLabelName(516639,user.getLanguage())); + }else{ + item.put("msg", SystemEnv.getHtmlLabelName(516111,user.getLanguage()) + +"
"+SystemEnv.getHtmlLabelName(516112,user.getLanguage())); + } + msglist.add(item); + + groupitem.put("items", itemlist); + lsGroup.add(groupitem); + retmap.put("condition", lsGroup); + retmap.put("status", "1"); + retmap.put("msglist", msglist); + retmap.put("kqtype", kqtype); + retmap.put("msg", msg); + retmap.put("field_map", field_map); + + //以下的效果就是duplicate_rule为1的时候才联动显示出来duplicate_wfids + to_related_map.put("duplicate_rule", "1"); + from_related_map.put("duplicate_wfids", to_related_map); + //以下的效果就是duplicate_rule为1的时候才联动显示出来duplicate_wfids + to_related_map = Maps.newHashMap(); + to_related_map.put("duplicate_level", "0,1"); + from_related_map.put("duplicate_message", to_related_map); + to_related_map = Maps.newHashMap(); + to_related_map.put("frequency_level", "0,1"); + from_related_map.put("frequency_message", to_related_map); + retmap.put("related", from_related_map); + retmap.put("id", id); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + + /** + * 编辑情况下,根据字段对应把每个字段对应的值返还 + * @param values + * @param rule_type_uuid + * @param fieldList + * @param ruleid + */ + private void get_edit_value(String[] values, String rule_type_uuid, + List> fieldList, String ruleid) { + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String sql = "select * from kq_att_checkrule_type where uuid = ? "; + rs.executeQuery(sql,rule_type_uuid); + if(rs.next()){ + String rule_table = rs.getString("rule_table"); + String data_sql = "select * from "+rule_table+" where id = ? "; + rs1.executeQuery(data_sql,ruleid); + if(rs1.next()){ + for(int i = 0 ; i < fieldList.size() ; i++){ + Map fieldMap = fieldList.get(i); + String fieldname = fieldMap.get("fieldname"); + values[i] = rs1.getString(fieldname); + } + } + } + } + + /** + * 根据下拉框的校验类型,获取到每种类型对应的校验字段 + * @param fieldList + * @param rule_type_uuid + */ + private void get_fieldList(List> fieldList, String rule_type_uuid) { + RecordSet rs = new RecordSet(); + String fieldSql = "select * from kq_att_checkrule_fields where rule_type_uuid = ? order by fieldorder "; + rs.executeQuery(fieldSql,rule_type_uuid); + while (rs.next()){ + String fieldname = rs.getString("fieldname"); + String fieldlabel = rs.getString("fieldlabel"); + String fieldhtmltype = rs.getString("fieldhtmltype"); + String fieldtype = rs.getString("fieldtype"); + Map fieldMap = Maps.newHashMap(); + fieldMap.put("fieldname", fieldname); + fieldMap.put("fieldlabel", fieldlabel); + fieldMap.put("fieldhtmltype", fieldhtmltype); + fieldMap.put("fieldtype", fieldtype); + fieldList.add(fieldMap); + } + } + + /** + * 得到下拉框校验类型的数据 + * @param labelidMap + * @param kqtype + */ + private void get_labelidMap(Map labelidMap, String kqtype) { + RecordSet rs = new RecordSet(); + String rule_type_sql = "select * from kq_att_checkrule_type where att_type = ? order by rule_type_order "; + rs.executeQuery(rule_type_sql,kqtype); + while (rs.next()){ + String labelids = rs.getString("labelids"); + String uuid = rs.getString("uuid"); + labelidMap.put(uuid, labelids); + } + } + + /** + * 因为提示语句是要根据选择的内容动态回显的,针对这样的字段增加动态映射 + * @param field_map + * @param rule_type_uuid + */ + private void get_field_map(Map field_map, String rule_type_uuid) { + RecordSet rs = new RecordSet(); + String field_map_sql = "select * from kq_att_checkrule_fields where rule_type_uuid=? "; + rs.executeQuery(field_map_sql, rule_type_uuid); + while (rs.next()){ + String key_fieldname = rs.getString("key_fieldname"); + String fieldname = rs.getString("fieldname"); + if(key_fieldname.length() > 0 && fieldname.length() > 0){ + field_map.put(key_fieldname, fieldname); + } + } + } + +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/GetProcSetTempletCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/GetProcSetTempletCmd.java new file mode 100644 index 0000000..2f0936c --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/GetProcSetTempletCmd.java @@ -0,0 +1,105 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 根据基本信息页面的选择的下拉框同步,带出不同的模板文件 + * @author pzy + * + */ +public class GetProcSetTempletCmd extends AbstractCommonCommand>{ + + public GetProcSetTempletCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + try { + RecordSet RS = new RecordSet(); + int field006 = Util.getIntValue(Util.null2String(params.get("field006"))); + + String custompage = ""; + String custompage4Emoble = ""; + String templetroute = ""; + switch (field006){ + case 0 : + custompage = KqTempletEnum.LEAVE.getTempletfile(); + custompage4Emoble = KqTempletEnum.LEAVE.getTempletmobilefile(); + templetroute = KqTempletEnum.LEAVE.getTempletroute(); + break; + case 1 : + custompage = KqTempletEnum.EVECTION.getTempletfile(); + custompage4Emoble = KqTempletEnum.EVECTION.getTempletmobilefile(); + templetroute = KqTempletEnum.EVECTION.getTempletroute(); + break; + case 2 : + custompage = KqTempletEnum.OUT.getTempletfile(); + custompage4Emoble = KqTempletEnum.OUT.getTempletmobilefile(); + templetroute = KqTempletEnum.OUT.getTempletroute(); + break; + case 3 : + custompage = KqTempletEnum.OVERTIME.getTempletfile(); + custompage4Emoble = KqTempletEnum.OVERTIME.getTempletmobilefile(); + templetroute = KqTempletEnum.OVERTIME.getTempletroute(); + break; + case 4 : + custompage = KqTempletEnum.OTHER.getTempletfile(); + custompage4Emoble = KqTempletEnum.OTHER.getTempletmobilefile(); + templetroute = KqTempletEnum.OTHER.getTempletroute(); + break; + case 5 : + custompage = KqTempletEnum.SHIFT.getTempletfile(); + custompage4Emoble = KqTempletEnum.SHIFT.getTempletmobilefile(); + templetroute = KqTempletEnum.SHIFT.getTempletroute(); + break; + case 6 : + custompage = KqTempletEnum.LEAVEBACK.getTempletfile(); + custompage4Emoble = KqTempletEnum.LEAVEBACK.getTempletmobilefile(); + templetroute = KqTempletEnum.LEAVEBACK.getTempletroute(); + break; + case 7 : + custompage = KqTempletEnum.Card.getTempletfile(); + custompage4Emoble = KqTempletEnum.Card.getTempletmobilefile(); + templetroute = KqTempletEnum.Card.getTempletroute(); + break; + case 8 : + custompage = KqTempletEnum.PROCESSCHANGE.getTempletfile(); + custompage4Emoble = KqTempletEnum.PROCESSCHANGE.getTempletmobilefile(); + templetroute = KqTempletEnum.PROCESSCHANGE.getTempletroute(); + break; + default: + break; + } + + retmap.put("status", "1"); + retmap.put("templetfile", custompage); + retmap.put("templetmobilefile", custompage4Emoble); + retmap.put("templetroute", templetroute); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetCreateFormCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetCreateFormCmd.java new file mode 100644 index 0000000..35a27b3 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetCreateFormCmd.java @@ -0,0 +1,77 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取考勤流程设置 流程概览信息 + * @author pzy + * + */ +public class GetStateProcSetCreateFormCmd extends AbstractCommonCommand>{ + + public GetStateProcSetCreateFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + try { + + String[] fields = new String[]{"title,15451,1,1","usedetail,18411,4,2"}; + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = new HrmFieldBean(); + itemlist = new ArrayList(); + for(int i=0;i>{ + + public GetStateProcSetFlowCheckRuleListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try { + String type = Util.null2String(params.get("type")); + String id = Util.null2String(params.get("id")); + String attid = Util.null2s(Util.null2String(params.get("attid")),""); + if(attid.length() == 0){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(500682, user.getLanguage())); + return retmap; + } + + String backfields = " * "; + String fromSql = " ( select a.*,b.labelids,b.rule_table,b.uuid a_uuid,b.uuid b_uuid,b.uuid c_uuid from kq_att_checkrule_set a left join kq_att_checkrule_type b on a.rule_type_uuid=b.uuid) f "; + String sqlWhere = " where 1=1 "; + sqlWhere += " and attid = "+attid; + String orderby = " id " ; + String tableString = ""; + + //操作字符串 + String operateString= ""; + operateString = ""; + operateString+=" "; + operateString+=" "; + operateString+=""; + String tabletype="checkbox"; + String pageUid = PageUidFactory.getHrmPageUid("StateProcSetFlowCheckRuleList"); + + tableString =" "+ + " "+ + operateString+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetFlowFormCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetFlowFormCmd.java new file mode 100644 index 0000000..cffe2bb --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetFlowFormCmd.java @@ -0,0 +1,396 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; +import weaver.workflow.workflow.WorkflowBillComInfo; +import weaver.workflow.workflow.WorkflowComInfo; + +/** + * 获取考勤流程设置 流程概览信息 + * @author pzy + * + */ +public class GetStateProcSetFlowFormCmd extends AbstractCommonCommand>{ + + public GetStateProcSetFlowFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + try { + + ManageDetachComInfo ManageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = ManageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + String hrmdftsubcomid = ManageDetachComInfo.getHrmdftsubcomid();//分权默认分部 + + CheckSubCompanyRight newCheck=new CheckSubCompanyRight(); + RecordSet rs = new RecordSet(); + HrmAttProcSetManager attProcSetManager = new HrmAttProcSetManager(); + WorkflowComInfo wfci=new WorkflowComInfo(); + WorkflowBillComInfo wbc = new WorkflowBillComInfo(); + SubCompanyComInfo sc = new SubCompanyComInfo(); + + String id = StringUtil.vString(params.get("id")); + int subcompanyid = StringUtil.parseToInt(StringUtil.vString(params.get("subcompanyid")), 0); + subcompanyid = subcompanyid < 0 ? 0 : subcompanyid; + + boolean isEdit = id.length() > 0; + HrmAttProcSet bean = isEdit ? attProcSetManager.get(id) : null; + bean = bean == null ? new HrmAttProcSet() : bean; + boolean isForm = bean.isSysForm(); + if(bean.getField004() <= 0) bean.setField004(subcompanyid); +// String field002Name = ""; +// if(bean.getField002() != 0){ +// rs.executeSql("select b.labelname from WorkFlow_Bill a left join HtmlLabelInfo b on a.nameLabel = b.indexID and b.languageid = "+user.getLanguage()+" where a.id = "+bean.getField002()); +// field002Name = rs.next() ? rs.getString(1) : ""; +// } + //流程路径 对应表单 所属分部 是否启用 变更流程类型 是否启用明细 模板文件 模板文件(手机版) 模板地址 流程可抵扣打卡記錄 + String[] fields = new String[]{"field001,34067,3,-99991","field002,15600,3,wfFormBrowser","field004,19799,3,169", + "field005,18095,4,2","field006,84791,5,1","usedetail,18411,4,2","flow_deduct_card,512290,4,2", + "templetfile,19971,1,1","templetmobilefile,19971,1,1","templetroute,82482,1,1"}; + String[] values = new String[fields.length]; + if(isEdit){ + values[0] = ""+bean.getField001(); + values[1] = ""+bean.getField002(); + values[2] = ""+bean.getField004(); + subcompanyid = bean.getField004(); + values[3] = Util.null2o(""+bean.getField005()); + values[4] = ""+bean.getField006(); + values[5] = ""+bean.getUsedetail(); + values[6] = ""+bean.getFlow_deduct_card(); + String custompage = ""; + String custompage4Emoble = ""; + String templetroute = ""; + switch (bean.getField006()){ + case 0 : + custompage = KqTempletEnum.LEAVE.getTempletfile(); + custompage4Emoble = KqTempletEnum.LEAVE.getTempletmobilefile(); + templetroute = KqTempletEnum.LEAVE.getTempletroute(); + break; + case 1 : + custompage = KqTempletEnum.EVECTION.getTempletfile(); + custompage4Emoble = KqTempletEnum.EVECTION.getTempletmobilefile(); + templetroute = KqTempletEnum.EVECTION.getTempletroute(); + break; + case 2 : + custompage = KqTempletEnum.OUT.getTempletfile(); + custompage4Emoble = KqTempletEnum.OUT.getTempletmobilefile(); + templetroute = KqTempletEnum.OUT.getTempletroute(); + break; + case 3 : + custompage = KqTempletEnum.OVERTIME.getTempletfile(); + custompage4Emoble = KqTempletEnum.OVERTIME.getTempletmobilefile(); + templetroute = KqTempletEnum.OVERTIME.getTempletroute(); + break; + case 4 : + custompage = KqTempletEnum.OTHER.getTempletfile(); + custompage4Emoble = KqTempletEnum.OTHER.getTempletmobilefile(); + templetroute = KqTempletEnum.OTHER.getTempletroute(); + break; + case 5 : + custompage = KqTempletEnum.SHIFT.getTempletfile(); + custompage4Emoble = KqTempletEnum.SHIFT.getTempletmobilefile(); + templetroute = KqTempletEnum.SHIFT.getTempletroute(); + break; + case 6 : + custompage = KqTempletEnum.LEAVEBACK.getTempletfile(); + custompage4Emoble = KqTempletEnum.LEAVEBACK.getTempletmobilefile(); + templetroute = KqTempletEnum.LEAVEBACK.getTempletroute(); + break; + case 7 : + custompage = KqTempletEnum.Card.getTempletfile(); + custompage4Emoble = KqTempletEnum.Card.getTempletmobilefile(); + templetroute = KqTempletEnum.Card.getTempletroute(); + break; + case 8 : + custompage = KqTempletEnum.PROCESSCHANGE.getTempletfile(); + custompage4Emoble = KqTempletEnum.PROCESSCHANGE.getTempletmobilefile(); + templetroute = KqTempletEnum.PROCESSCHANGE.getTempletroute(); + break; + default: + break; + } + values[7] = ""+Util.null2s(bean.getTempletfile(), custompage); + values[8] = ""+Util.null2s(bean.getTempletmobilefile(), custompage4Emoble); + values[9] = ""+Util.null2s(bean.getTempletroute(), templetroute); + } + + Map descMaps = new HashMap<>(); + Map tipMaps = new HashMap<>(); + + String[] optionIndex = new String[]{"-1","0","1","2","3","5","6","7","8"}; + String[] optionLabel = new String[]{"","670,18015","20084,18015","24058,18015","6151,18015","390737","24473,18015","390274","513400"}; + + //增加对于字段的说明 + handleDescMap(descMaps,optionIndex,tipMaps); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + itemlist = new ArrayList(); + groupitem = new HashMap(); + List> replaceDatas = new ArrayList>(); + Map datas = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(1361,weaver.general.Util.getIntValue(user.getLanguage()))); + groupitem.put("defaultshow", true); + for(int i=0;i 0){ + hrmFieldBean.setFieldvalue(subcompanyid); + }else{ + hrmFieldBean.setFieldvalue(defaultSubcompanyid); + } + + }else{ + //不开启分权的话,不显示分部 + continue; + } + } + + replaceDatas = new ArrayList>(); + datas = new HashMap(); + + if("field006".equals(hrmFieldBean.getFieldname())){ + List options = new ArrayList(); + if(isEdit){ + for(int k = 0; k < optionIndex.length ; k++){ + if(k == Util.getIntValue(values[i])){ + options.add(new SearchConditionOption(optionIndex[Util.getIntValue(values[i])],SystemEnv.getHtmlLabelNames(optionLabel[Util.getIntValue(values[i])], user.getLanguage()),true)); + }else{ + options.add(new SearchConditionOption(optionIndex[k],SystemEnv.getHtmlLabelNames(optionLabel[k],user.getLanguage()))); + } + } + }else{ + for(int k = 0; k < optionIndex.length ; k++){ + SearchConditionOption SearchConditionOption1 = new SearchConditionOption(optionIndex[k],SystemEnv.getHtmlLabelNames(optionLabel[k],user.getLanguage())); + if(k == 0){ + SearchConditionOption1.setSelected(true); + } + options.add(SearchConditionOption1); + } + } + hrmFieldBean.setSelectOption(options); + } + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if("field001".equals(hrmFieldBean.getFieldname())){ + //流程树是不支持多版本的,只有列表的是可以显示多版本的 + searchConditionItem.getBrowserConditionParam().getDataParams().put("isWfTree", "1"); + searchConditionItem.getBrowserConditionParam().getDataParams().put("isvalid", "1,3"); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("isvalid", "1,3"); + searchConditionItem.getBrowserConditionParam().setHasAddBtn(true); + searchConditionItem.getBrowserConditionParam().setViewAttr(3); + if(isEdit){ + String tmpWfId = values[i]; + String wfname = wfci.getWorkflowname(tmpWfId); + datas.put("id",tmpWfId); + datas.put("name",wfname); + replaceDatas.add(datas); + searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas); + } + } + if("field002".equals(hrmFieldBean.getFieldname())){ + searchConditionItem.getBrowserConditionParam().setHasAddBtn(true); + searchConditionItem.getBrowserConditionParam().setViewAttr(3); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(82815,user.getLanguage())); + if(isEdit){ + String tmpFormId = values[i]; + String wfname = SystemEnv.getHtmlLabelNames(wbc.getNamelabel(tmpFormId),user.getLanguage()); + datas.put("id",tmpFormId); + datas.put("name",wfname); + replaceDatas.add(datas); + searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas); + } + } + if("flow_deduct_card".equals(hrmFieldBean.getFieldname())){ + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(512291,user.getLanguage())); + } + if("field004".equals(hrmFieldBean.getFieldname())){ + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "HrmAttendanceProcess:setting"); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("rightStr", "HrmAttendanceProcess:setting"); + } + if("field005".equals(hrmFieldBean.getFieldname())){ + if(isForm){ + searchConditionItem.setViewAttr(1); + } + } + searchConditionItem.setRules("required|string"); + searchConditionItem.setLabelcol(6); + searchConditionItem.setFieldcol(18); + + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + lsGroup.add(groupitem); + retmap.put("condition", lsGroup); + retmap.put("desc", descMaps); + retmap.put("tips", tipMaps); + retmap.put("status", "1"); + + int operatelevel = -1; + if(hrmdetachable){ + if(subcompanyid > 0){ + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + operatelevel=checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"HrmAttendanceProcess:setting",subcompanyid); + } + }else{ + operatelevel = 2; + } + if(!isEdit){ + operatelevel = 2; + } + + if(user.getUID() == 1){ + operatelevel = 2; + } + if(operatelevel > 0){ + retmap.put("canAdd", true); + }else{ + retmap.put("canAdd", false); + } + + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + + /** + * 增加对于字段的说明 + * @param descMaps + * @param tipMaps + */ + private void handleDescMap(Map descMaps, String[] optionIndex, + Map tipMaps) { + Map descMap = new HashMap<>(); + Map tipMap = new HashMap<>(); + for(int i = 0 ; i < optionIndex.length ; i++){ + if("5".equalsIgnoreCase(optionIndex[i])){ + //排班流程 仅支持明细表单 + descMap.put(""+i, SystemEnv.getHtmlLabelName(391247, user.getLanguage())); + }else if("6".equalsIgnoreCase(optionIndex[i]) || "7".equalsIgnoreCase(optionIndex[i])){ + //补卡或者销假 仅支持明细表单 + descMap.put(""+i, SystemEnv.getHtmlLabelName(391247, user.getLanguage())); + }else if("8".equalsIgnoreCase(optionIndex[i])){ + //考勤变更流程 仅支持明细表单 + descMap.put(""+i, SystemEnv.getHtmlLabelName(391247, user.getLanguage())); + tipMap.put(""+i, SystemEnv.getHtmlLabelName(513401, user.getLanguage())); + }else{ + //其他流程 支持主表或者明细表单 + if(i < 0){ + descMap.put(""+i, ""); + }else{ + descMap.put(""+i, SystemEnv.getHtmlLabelName(391249, user.getLanguage())); + } + } + } + descMaps.put("field006", descMap); + tipMaps.put("field006", tipMap); + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetFlowWfFieldsCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetFlowWfFieldsCmd.java new file mode 100644 index 0000000..a9af28b --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetFlowWfFieldsCmd.java @@ -0,0 +1,347 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.wfset.attendance.domain.HrmAttProcFields; +import com.engine.kq.wfset.attendance.domain.HrmAttProcRelation; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.attendance.domain.WorkflowBillfield; +import com.engine.kq.wfset.attendance.manager.HrmAttProcFieldsManager; +import com.engine.kq.wfset.attendance.manager.HrmAttProcRelationManager; +import com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager; +import com.engine.kq.wfset.attendance.manager.WorkflowBillfieldManager; +import com.google.common.collect.Lists; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取考勤流程设置 字段对应信息 + * + * @author pzy + */ +public class GetStateProcSetFlowWfFieldsCmd extends AbstractCommonCommand> { + + public GetStateProcSetFlowWfFieldsCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + try { + + RecordSet rs = new RecordSet(); + HrmAttProcSetManager attProcSetManager = new HrmAttProcSetManager(); + HrmAttProcFieldsManager attProcFieldsManager = new HrmAttProcFieldsManager(); + HrmAttProcRelationManager attProcRelationManager = new HrmAttProcRelationManager(); + WorkflowBillfieldManager workflowBillfieldManager = new WorkflowBillfieldManager(); + + String id = StringUtil.vString(params.get("id")); + int subcompanyid = StringUtil.parseToInt(StringUtil.vString(params.get("subcompanyid")), 0); + subcompanyid = subcompanyid < 0 ? 0 : subcompanyid; + + HrmAttProcSet bean = attProcSetManager.get(id); + int billId = bean.getField002(); + //考勤流程类型 + int field006 = bean.getField006(); + List list = attProcFieldsManager.find(attProcSetManager.getMapParam("field001:" + bean.getBillId() + ";languageid:" + user.getLanguage())); + List fieldList = workflowBillfieldManager.find(attProcSetManager.getMapParam("billid:" + billId + ";languageid:" + user.getLanguage() + ";viewtype:0")); + List detailList = workflowBillfieldManager.find(attProcSetManager.getMapParam("billid:" + billId + ";languageid:" + user.getLanguage() + ";viewtype:1")); + + List relationList = attProcRelationManager.find(attProcSetManager.getMapParam("field001:" + id)); + + HrmAttProcFields fBean = null; + StringBuffer checkFields = new StringBuffer(); + for (int i = 0; i < (list == null ? 0 : list.size()); i++) { + fBean = (HrmAttProcFields) list.get(i); + if (fBean.getField010() == 1) { + checkFields.append(checkFields.length() == 0 ? "" : ",") + .append("select" + fBean.getId()); + } + } + if (bean.isHAF() && relationList.size() == 0) { + attProcRelationManager.initRelation(bean.getId(), list, fieldList); + relationList = attProcRelationManager.find(attProcSetManager.getMapParam("field001:" + id)); + } + + int usedetail = bean.getUsedetail(); + //排班的现在只有明细 + if (field006 == 5) { + usedetail = 1; + } + Map mapFields = new HashMap(); + + //补卡和销假流程是主表和明细表都需要的 + if (field006 == 7 || field006 == 6 || field006 == 8) { + //生成主表字段的集合 + getFieldsInfo(mapFields, list, fieldList, relationList, bean, "0"); + if (mapFields != null && !mapFields.isEmpty()) { + getGroupitems(lsGroup, groupitem, itemlist, mapFields, bean.getTablename()); + } + mapFields = new HashMap(); + //生成明细字段的集合 + getFieldsInfo(mapFields, list, detailList, relationList, bean, "1"); + if (mapFields != null && !mapFields.isEmpty()) { + getGroupitems(lsGroup, groupitem, itemlist, mapFields, bean.getDetailtablename()); + } + + } else { + String labelFormName = ""; + if (usedetail == 1) { + labelFormName = bean.getDetailtablename(); + //生成明细字段的集合 + getFieldsInfo(mapFields, list, detailList, relationList, bean, "1"); + } else { + labelFormName = bean.getTablename(); + //生成主表字段的集合 + getFieldsInfo(mapFields, list, fieldList, relationList, bean, "0"); + } + if (mapFields != null && !mapFields.isEmpty()) { + getGroupitems(lsGroup, groupitem, itemlist, mapFields, labelFormName); + } + } + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + HrmFieldBean hrmFieldBean = null; + String[] msg = new String[]{ + "1,10005333,8,1"}; + itemlist = new ArrayList(); + for (int i = 0; i < msg.length; i++) { + String msg_str = msg[i]; + String[] fieldConfig = msg_str.split(","); + String fieldname = fieldConfig[0]; + String fieldlabel = ""; + String fieldhtmltype = fieldConfig[2]; + String type = fieldConfig[3]; + String fieldvalue = Util.toScreen(SystemEnv.getHtmlLabelName(Util.getIntValue(fieldConfig[1]), user.getLanguage()), user.getLanguage()); + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(fieldname); + hrmFieldBean.setFieldlabel(fieldlabel); + hrmFieldBean.setFieldhtmltype(fieldhtmltype); + hrmFieldBean.setType(type); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(1); + hrmFieldBean.setFieldvalue(fieldvalue); + itemlist.add(hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user)); + } + if (field006 == KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype()) { + msg = new String[]{ + "2,547698,8,1"}; + for (int i = 0; i < msg.length; i++) { + String msg_str = msg[i]; + String[] fieldConfig = msg_str.split(","); + String fieldname = fieldConfig[0]; + String fieldlabel = ""; + String fieldhtmltype = fieldConfig[2]; + String type = fieldConfig[3]; + String fieldvalue = Util.toScreen(SystemEnv.getHtmlLabelName(Util.getIntValue(fieldConfig[1]), user.getLanguage()), user.getLanguage()); + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(fieldname); + hrmFieldBean.setFieldlabel(fieldlabel); + hrmFieldBean.setFieldhtmltype(fieldhtmltype); + hrmFieldBean.setType(type); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(1); + hrmFieldBean.setFieldvalue(fieldvalue); + itemlist.add(hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user)); + } + } + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(85, user.getLanguage())); + groupitem.put("defaultshow", true); + groupitem.put("items", itemlist); + if (field006 == KqSplitFlowTypeEnum.CARD.getFlowtype() || field006 == KqSplitFlowTypeEnum.SHIFT.getFlowtype()) { + } else { + lsGroup.add(groupitem); + } + + retmap.put("condition", lsGroup); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + + return retmap; + } + + /** + * 根据主表、明细表生成相应的返回字段数据 + * + * @param lsGroup + * @param groupitem + * @param itemlist + * @param mapFields + * @param labelFormName + */ + private void getGroupitems(List lsGroup, Map groupitem, List itemlist, Map mapFields, String labelFormName) { + + for (Map.Entry me : mapFields.entrySet()) { + String key = me.getKey();//得到group的标签 + List> listFields = (List>) me.getValue(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + itemlist = new ArrayList(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(key, user.getLanguage()) + labelFormName); + groupitem.put("defaultshow", true); + for (int i = 0; i < listFields.size(); i++) { + List fieldinfo = listFields.get(i); + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(Util.null2String(fieldinfo.get(0))); + hrmFieldBean.setFieldlabel(Util.null2String(fieldinfo.get(1))); + hrmFieldBean.setFieldhtmltype(Util.null2String(fieldinfo.get(2))); + hrmFieldBean.setType(Util.null2String(fieldinfo.get(3))); + hrmFieldBean.setIsFormField(true); + List options = (List) fieldinfo.get(4); + if (options != null && options.size() > 0) { + hrmFieldBean.setSelectOption(options); + } + boolean isMust = (Boolean) fieldinfo.get(5); + if (isMust) { + hrmFieldBean.setViewAttr(3); + } + hrmFieldBean.setTip(Util.null2String(fieldinfo.get(6))); + + boolean isDisabled = (Boolean) fieldinfo.get(7); + if (isDisabled) { + hrmFieldBean.setViewAttr(1); + } + + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (isMust) { + searchConditionItem.setRules("required|string"); + } + searchConditionItem.setHelpfulTip(Util.null2String(fieldinfo.get(6))); + searchConditionItem.setLabelcol(6); + searchConditionItem.setFieldcol(18); + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + lsGroup.add(groupitem); + } + } + + + /** + * 生成字段对应的集合数据 + * + * @param mapFields + * @param list + * @param fieldList + * @param relationList + * @param bean + * @param usedetail 1表示明细表 + */ + private void getFieldsInfo(Map mapFields, List list, List fieldList, List relationList, HrmAttProcSet bean, String usedetail) { + List> listFields = new ArrayList>(); + List options = new ArrayList(); + List lFields = new ArrayList(); + HrmAttProcFields fBean = null; + HrmAttProcRelation rBean = null; + WorkflowBillfield wfBean = null; + + String groupLable = "18020"; + if ("1".equalsIgnoreCase(usedetail)) { + groupLable = "18550"; + } + + String bean_detailname = bean.getDetailtablename(); + int billId = bean.getField002(); + boolean isDisabled = false; + for (int i = 0; i < (list == null ? 0 : list.size()); i++) { + fBean = (HrmAttProcFields) list.get(i); + String selectFieldName = ""; + if ("1".equalsIgnoreCase(usedetail)) { + //如果是明细表,不以detail_开头的都要去除 + if (!fBean.getField002().startsWith("detail_")) { + continue; + } + } else { + //如果是主表,以detail_开头的都要去除 + if (fBean.getField002().startsWith("detail_")) { + continue; + } + } + + for (int x = 0; x < (relationList == null ? 0 : relationList.size()); x++) { + rBean = (HrmAttProcRelation) relationList.get(x); + if (String.valueOf(rBean.getField002()).equals(String.valueOf(fBean.getId()))) { + selectFieldName = rBean.getField004(); + break; + } + } + + if (mapFields.get(groupLable) != null) { + listFields = (List>) mapFields.get(groupLable); + } else { + listFields = new ArrayList>(); + mapFields.put(groupLable, listFields); + } + + boolean isSameType = false, isSameHtmltype = false, isSelectField = false; + SearchConditionOption emptySearch = new SearchConditionOption("", ""); + options.add(emptySearch); + for (int j = 0; j < (fieldList == null ? 0 : fieldList.size()); j++) { + wfBean = (WorkflowBillfield) fieldList.get(j); + String detailtable = wfBean.getDetailtable(); + if ("1".equalsIgnoreCase(usedetail)) { + if (bean_detailname.length() > 0 && detailtable.length() > 0 && !detailtable.equalsIgnoreCase(bean_detailname)) { + continue; + } + } + isSameType = String.valueOf(wfBean.getType()).equals(String.valueOf(fBean.getField006())); + isSameHtmltype = wfBean.getFieldhtmltype().equals(String.valueOf(fBean.getField005())); + isSelectField = selectFieldName.length() > 0 && selectFieldName.equals(wfBean.getFieldname()); + SearchConditionOption SearchConditionOption1 = new SearchConditionOption(wfBean.getFieldname() + "___" + wfBean.getId(), wfBean.getLabelName(), (selectFieldName.length() > 0 && selectFieldName.equals(wfBean.getFieldname()) ? true : false)); + if (!isSelectField && ((fBean.getField005() == 5 && !isSameHtmltype) || (fBean.getField005() != 5 && (!isSameHtmltype || !isSameType)))) { +// continue; + SearchConditionOption1.setVisible(false); + } + options.add(SearchConditionOption1); + + } + + lFields = new ArrayList(); + lFields.add("select" + fBean.getId()); + lFields.add("" + fBean.getField003()); + lFields.add("5"); + lFields.add("1"); + lFields.add(options); + lFields.add(fBean.getField010() == 1); + lFields.add(SystemEnv.getHtmlLabelNames(fBean.getField005Title(), user.getLanguage())); + lFields.add(isDisabled); + listFields.add(lFields); + options = new ArrayList(); + } + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetFlowWfSetCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetFlowWfSetCmd.java new file mode 100644 index 0000000..140f466 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetFlowWfSetCmd.java @@ -0,0 +1,227 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.api.hrm.util.HrmFieldUtil; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.wfset.attendance.domain.HrmAttProcAction; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.attendance.manager.HrmAttProcActionManager; +import com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取考勤流程设置 动作设置 + * @author pzy + * + */ +public class GetStateProcSetFlowWfSetCmd extends AbstractCommonCommand>{ + + public GetStateProcSetFlowWfSetCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + List lsGroup = new ArrayList(); + Map groupitem = null; + Map groupitems = null; + List itemlist = null; + try { + + StringUtil strUtil = new StringUtil(); + RecordSet rs = new RecordSet(); + HrmAttProcSetManager attProcSetManager = new HrmAttProcSetManager(); + HrmAttProcActionManager attProcActionManager = new HrmAttProcActionManager(); + itemlist = new ArrayList(); + groupitem = new HashMap(); + + String id = StringUtil.vString(params.get("id")); + HrmAttProcSet sBean = attProcSetManager.get(id); + attProcActionManager.setUser(user); + String wfId = sBean.getField001()+""; + int flowtype = sBean.getField006();//考勤流程类型 + String splitAction = KqSplitActionEnum.ATT.getSplitAction(); + List list = attProcActionManager.find("[map]field001:"+id+";field004:0;wfId:"+sBean.getField001()); + if(list == null || list.size() == 0) { + list = attProcActionManager.find("[map]field001:-1;field004:1;mfid:"+flowtype); + } + + //生成字段的集合 + Map mapFields = getFieldsInfo(list,wfId,splitAction,flowtype); + groupitem.put("table", mapFields); + itemlist.add(groupitem); + retmap.put("title", SystemEnv.getHtmlLabelName(1361,user.getLanguage())); + retmap.put("defaultshow", true); + retmap.put("items", itemlist); + + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + + /** + * 生成字段对应的集合数据 + * @param list + * @param wfId + * @param splitAction + * @param flowtype + */ + private Map getFieldsInfo(List list, String wfId, String splitAction, int flowtype){ + + Map infoMap = new HashMap(); + List> datasList = new ArrayList>(); + List> browserList = new ArrayList>(); + Map browserMap = new HashMap(); + Map data = new HashMap(); + + List> columnsList = new ArrayList>(); + + Map allMap = setColumns(wfId); + if(allMap != null){ + columnsList = (List>) allMap.get("column"); + browserList = (List>) allMap.get("browser"); + } + HrmAttProcAction bean = null; + List lFields = new ArrayList(); + String[] fields = new String[4]; + RecordSet rs = new RecordSet(); + String tmpField006Name = "",tmpField006 = ""; + for(int i=0; i<(list==null?0:list.size());i++) { + bean = (HrmAttProcAction)list.get(i); + + List options = new ArrayList(); + lFields = new ArrayList(); + + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(18009,user.getLanguage()),(bean.getField005() == 2 ? true : false))); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(18010,user.getLanguage()),(bean.getField005() == 1 ? true : false))); + options.add(new SearchConditionOption("0",SystemEnv.getHtmlLabelName(386027,weaver.general.Util.getIntValue(user.getLanguage())),(bean.getField005() == 0 ? true : false))); + String browserVal = bean.getField006().equals("-1") || bean.getField006().equals("0") ? "" : String.valueOf(bean.getField006()); + String checkBoxVal = bean.getField007() == 1 ? "1" : "0"; + String field005Val = bean.getField005() < 0 ? "2" : ""+bean.getField005(); + + String key = bean.getField002(); + String td0 = "fakeInp"; + String td1 = "field003"; + String td2 = "field005"; + String td3 = "field006"; + String td3Span = "field006span"; +// String td4 = "field007"; + String td5 = "field008"; + + data = new HashMap(); + data.put("rowKey", key); + if(flowtype == 5){ + data.put(td0, SystemEnv.getHtmlLabelName(33604,weaver.general.Util.getIntValue(user.getLanguage()))); + }else { + data.put(td0, SystemEnv.getHtmlLabelNames(bean.getField003(),user.getLanguage())); + } + data.put(td1, bean.getField003()); + data.put(td2, ""+field005Val); + data.put(td3, browserVal); + data.put(td3Span, bean.getField006Name()); +// data.put(td4, checkBoxVal); + data.put(td5, ""+bean.getField008()); + if(splitAction.equalsIgnoreCase(bean.getField002())){ + if(flowtype != 5){ + data.put("fakeInpHelpful", SystemEnv.getHtmlLabelName(10000814,weaver.general.Util.getIntValue(user.getLanguage()))); + } + } + //TODO 未考虑做这个创建节点后拆分流程的功能,暂时屏蔽 +// if(splitFreezeAction.equalsIgnoreCase(bean.getField002())){ +// data.put("fakeInpHelpful", SystemEnv.getHtmlLabelNames("389468",user.getLanguage())); +// } + datasList.add(data); + } + infoMap.put("columns", columnsList); + infoMap.put("datas", datasList); + infoMap.put("browsers", browserList); + return infoMap; + } + + private Map setColumns(String wfId) { + Map allMap = new HashMap(); + List titles = null; + List btitles = null; + List> columns = null; + List> bcolumns = null; + String td0 = "fakeInp"+",19831,7,1"; + String td2 = "field005"+",33408,5,1"; + String td3 = "field006"+",33410,3,workflowNode"; + String td4 = "field007"+",33409,4,1"; + + String btd1 = "field006"+",15587,3,wflink"; + String btd2 = "field006"+",15586,3,workflowNode"; + + String[] fields = new String[]{td0,td2,td3,btd1,btd2}; + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + titles = new ArrayList(); + btitles = new ArrayList(); + List selectOption = null; + Map otherparam = new HashMap(); + otherparam.put("workflowid", wfId); + otherparam.put("isSingle", false); + otherparam.put("noNeedActiveWfId", "1"); + for(int i=0;i(); + String[] fieldinfo = fields[i].split(","); + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(fieldinfo[0]); + hrmFieldBean.setFieldlabel(fieldinfo[1]); + hrmFieldBean.setFieldhtmltype(fieldinfo[2]); + hrmFieldBean.setType(fieldinfo[3]); + + if("field005".equals(fieldinfo[0])){ + selectOption.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(18009, user.getLanguage()),true)); + selectOption.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(18010, user.getLanguage()))); + selectOption.add(new SearchConditionOption("0",SystemEnv.getHtmlLabelName(386027,weaver.general.Util.getIntValue(user.getLanguage())))); + hrmFieldBean.setSelectOption(selectOption); + } + if("workflowNode".equals(fieldinfo[3])){ + hrmFieldBean.setOtherparam(otherparam); + } + if("wflink".equals(fieldinfo[3])){ + hrmFieldBean.setOtherparam(otherparam); + } + if(i > 2){ + btitles.add(hrmFieldBean); + }else{ + titles.add(hrmFieldBean); + } + } + columns = HrmFieldUtil.getHrmDetailTable(titles, null, user); + bcolumns = HrmFieldUtil.getHrmDetailTable(btitles, null, user); + allMap.put("column", columns); + allMap.put("browser", bcolumns); + return allMap; + } + + +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetListSearchConditionCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetListSearchConditionCmd.java new file mode 100644 index 0000000..46c5e80 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetListSearchConditionCmd.java @@ -0,0 +1,128 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; + +/** + * 获取考勤流程设置的查询条件 + * @author pzy + * + */ +public class GetStateProcSetListSearchConditionCmd extends AbstractCommonCommand> { + + public GetStateProcSetListSearchConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + try{ + + int subcompanyid = StringUtil.parseToInt(StringUtil.vString(params.get("subcompanyid")), 0); + //流程路径 对应表单 表单类型 状态 最后修改日期 变更流程类型 + String[] fields = new String[]{"field001,34067,1,1","field002,15600,3,wfFormBrowser","field003,18411,5,1" + ,"subcompanyid,19799,3,169","field005,602,5,1","createdateselect,19521,3,2" + ,"field006,84791,5,1"}; + + ManageDetachComInfo ManageDetachComInfo = new ManageDetachComInfo(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + itemlist = new ArrayList(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(20331, user.getLanguage())); + groupitem.put("defaultshow", true); + for(int i=0;i 0){ + hrmFieldBean.setFieldvalue(subcompanyid); + } + } + if("field003".equals(hrmFieldBean.getFieldname())){ + List options = new ArrayList(); + options.add(new SearchConditionOption("",SystemEnv.getHtmlLabelName(332, user.getLanguage()))); + options.add(new SearchConditionOption("0",SystemEnv.getHtmlLabelName(125026,weaver.general.Util.getIntValue(user.getLanguage())))); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(125027,weaver.general.Util.getIntValue(user.getLanguage())))); + hrmFieldBean.setSelectOption(options); + }else if("field005".equals(hrmFieldBean.getFieldname())){ + List options = new ArrayList(); + options.add(new SearchConditionOption("",SystemEnv.getHtmlLabelName(332, user.getLanguage()))); + options.add(new SearchConditionOption("0",SystemEnv.getHtmlLabelName(18096,user.getLanguage()))); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(18095,user.getLanguage()))); + hrmFieldBean.setSelectOption(options); + }else if("field006".equals(hrmFieldBean.getFieldname())){ + hrmFieldBean.setFieldlabel("15880,18015,63"); + List options = new ArrayList(); + options.add(new SearchConditionOption("",SystemEnv.getHtmlLabelName(332, user.getLanguage()))); + options.add(new SearchConditionOption("0",SystemEnv.getHtmlLabelName(83393,weaver.general.Util.getIntValue(user.getLanguage())))); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(83394,weaver.general.Util.getIntValue(user.getLanguage())))); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(83395,weaver.general.Util.getIntValue(user.getLanguage())))); + options.add(new SearchConditionOption("3",SystemEnv.getHtmlLabelName(83396,weaver.general.Util.getIntValue(user.getLanguage())))); + options.add(new SearchConditionOption("5",SystemEnv.getHtmlLabelName(390737,weaver.general.Util.getIntValue(user.getLanguage())))); + options.add(new SearchConditionOption("6",SystemEnv.getHtmlLabelName(389117,weaver.general.Util.getIntValue(user.getLanguage())))); + options.add(new SearchConditionOption("7",SystemEnv.getHtmlLabelName(390274,weaver.general.Util.getIntValue(user.getLanguage())))); + options.add(new SearchConditionOption("8",SystemEnv.getHtmlLabelName(513400,weaver.general.Util.getIntValue(user.getLanguage())))); + hrmFieldBean.setSelectOption(options); + } + + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if("subcompanyid".equals(hrmFieldBean.getFieldname())){ + //表示左侧分部树选择了 + if(subcompanyid > 0){ + searchConditionItem.setValue(subcompanyid); + } + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "HrmAttendanceProcess:setting"); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("rightStr", "HrmAttendanceProcess:setting"); + } + if(searchConditionItem.getBrowserConditionParam()!=null){ + searchConditionItem.getBrowserConditionParam().setViewAttr(2); + } + searchConditionItem.setViewAttr(2); + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + retmap.put("status", "1"); + retmap.put("conditions", grouplist); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetListSearchListCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetListSearchListCmd.java new file mode 100644 index 0000000..a8b2299 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetListSearchListCmd.java @@ -0,0 +1,216 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.api.hrm.util.PageUidFactory; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.common.SplitPageTagTableE9; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +/** + * 获取考勤流程设置的查询列表 + * @author pzy + * + */ +public class GetStateProcSetListSearchListCmd extends AbstractCommonCommand> { + + protected HttpServletRequest request; + + public GetStateProcSetListSearchListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + public GetStateProcSetListSearchListCmd(Map params,HttpServletRequest request, User user) { + this.user = user; + this.params = params; + this.request = request; + } + + @Override + public Map execute(CommandContext commandContext) { + + Map retmap = new HashMap(); + try{ + StringUtil strUtil = new StringUtil(); + RecordSet rs = new RecordSet(); + SubCompanyComInfo SubCompanyComInfo = new SubCompanyComInfo(); + ManageDetachComInfo ManageDetachComInfo = new ManageDetachComInfo(); + HttpSession session = request.getSession(true); +// String name = Util.null2String(params.get("name")); + String qCondition = strUtil.vString(params.get("qCondition")); + String field001 = strUtil.vString(params.get("field001")); + String field002 = strUtil.vString(params.get("field002")); + String field002Name = ""; + if(field002.length() > 0){ + rs.executeSql("select b.labelname from WorkFlow_Bill a left join HtmlLabelInfo b on a.nameLabel = b.indexID and b.languageid = "+user.getLanguage()+" where a.id in ("+field002+")"); + while(rs.next()) field002Name+= (field002Name.length()==0?"":",") + rs.getString(1); + } + int field003 = strUtil.parseToInt(params.get("field003")); + int field004 = strUtil.parseToInt(strUtil.vString(params.get("subcompanyid")), 0); + field004 = field004 < 0 ? 0 : field004; + + String field004Name = field004 == 0 ? "" : SubCompanyComInfo.getSubCompanyname(String.valueOf(field004)); + int field005 = strUtil.parseToInt(params.get("field005")); + int field006 = strUtil.parseToInt(params.get("field006")); + + String createdateselectselect = strUtil.vString(params.get("createdateselectselect")); + String fromdate = strUtil.vString(params.get("createdateselectfrom")); + String enddate = strUtil.vString(params.get("createdateselectto")); + if(!createdateselectselect.equals("") && !createdateselectselect.equals("0")&& !createdateselectselect.equals("6")){ + fromdate = TimeUtil.getDateByOption(createdateselectselect,"0"); + enddate = TimeUtil.getDateByOption(createdateselectselect,"1"); + } + + String allIds = ""; + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + if(strUtil.vString(ManageDetachComInfo.getDetachable()).equals("1")) { + + ArrayList sList = SubCompanyComInfo.getRightSubCompany(user.getUID(), "HrmAttendanceProcess:setting"); + for(int i=0;i0)subcompanyids+=","; + subcompanyids += arrSubcompanyids[i]; + } + if(subcompanyids.length() > 0 ){ + detach_sqlWhere += " and field004 in("+subcompanyids+")"; + }else{ + detach_sqlWhere += " and 1=2 "; + } + } + }else{ + operatelevel = 2; + } + + if(field004 > 0){ + detach_sqlWhere += " and field004 = " + field004; + if(hrmdetachable){ + operatelevel=checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"HrmAttendanceProcess:setting",field004); + } + } + if(user.getUID() == 1){ + operatelevel = 2; + } + + + String sqlField = "id, field001, field002, field003, field004, field005, field006, field009, tablename, labelname,usedetail"; + String sqlFrom = " from ( select a.id, field001, field002, field003, field004, field005, field006, field009, b.tablename, c.labelname,a.usedetail from kq_ATT_PROC_SET a left join WorkFlow_Bill b on a.field002 = b.id left join HtmlLabelInfo c on b.nameLabel = c.indexID and c.languageid = "+user.getLanguage()+" ) a"; + String sqlWhere = " where 1=1 "; + + if(qCondition.length() > 0){ + sqlWhere += " and field001 in (select id from workflow_base where workflowname like '%"+qCondition+"%')"; + } else if(field001.length() > 0){ + sqlWhere += " and field001 in (select id from workflow_base where workflowname like '%"+field001+"%')"; + } + if(field002.length() > 0) { + sqlWhere += " and field002 in ("+field002+")"; + } + if(field003 != -1) { + sqlWhere += " and field003 = "+field003; + } + if(field004 > 0) { + sqlWhere += " and field004 = "+field004; + } + if(detach_sqlWhere.length() > 0){ + sqlWhere += detach_sqlWhere; + } + if(field005 != -1) { + sqlWhere += " and field005 = "+field005; + } + if(field006 != -1) { + sqlWhere += " and field006 = "+field006; + } + if(fromdate.length() > 0 && enddate.length() > 0) { + sqlWhere += " and field009 between '"+fromdate+"' and '"+enddate+"'"; + } else { + if(fromdate.length() > 0) { + sqlWhere += " and field009 >= '"+fromdate+"'"; + } + if(enddate.length() > 0) { + sqlWhere += " and field009 between '1949-10-01' and '"+enddate+"'"; + } + } + String pageid = "KQ_HrmAttProcSet"; + String pageUid = PageUidFactory.getHrmPageUid(pageid); + SplitPageTagTableE9 table = new SplitPageTagTableE9(pageid, user); + if(operatelevel > 0){ + table.addOperate(SystemEnv.getHtmlLabelName(93,user.getLanguage()), "javascript:showContent();", "true", "column:field006"); + table.addOperate(SystemEnv.getHtmlLabelName(18095,user.getLanguage()), "javascript:changeStatus(1);", "+column:field005+==0and+column:field002+!=180and+column:field002+!=181and+column:field002+!=182"); + table.addOperate(SystemEnv.getHtmlLabelName(18096,user.getLanguage()), "javascript:changeStatus(0);", "+column:field005+==1and+column:field002+!=180and+column:field002+!=181and+column:field002+!=182"); + table.addOperate(SystemEnv.getHtmlLabelName(21954,user.getLanguage()), "javascript:procSet();", "true", "column:field001"); + } + if(operatelevel > 1){ + table.addOperate(SystemEnv.getHtmlLabelName(20230,user.getLanguage()), "javascript:doDel();", "true"); + } + table.addOperate(SystemEnv.getHtmlLabelName(83,user.getLanguage()), "javascript:showLog();", "true"); + table.setPopedompara("true"); + table.setSql(sqlField, sqlFrom, sqlWhere, "id"); + + int width1 = 20, width2 = 20, width3 = 15, width4 = 0, width5 = 10, width6 = 15, width7 = 20; + if(strUtil.vString(ManageDetachComInfo.getDetachable()).equals("1")) { + width3 = (width1 = width2 = width4 = 15) - 5; + } + table.addCol(width5, "ID", "id"); + table.addFormatCol(width1, SystemEnv.getHtmlLabelName(34067,user.getLanguage()), "field001", "field001", "{cmd:class[weaver.formmode.interfaces.WfToModeTransmethod.getWorkflowNameBlank(+column:field001+, "+user.getLanguage()+")]}"); + + table.addCol(width2, SystemEnv.getHtmlLabelName(15600,user.getLanguage()), "labelname"); + table.addCol(width3, SystemEnv.getHtmlLabelName(18411,user.getLanguage()), "field003", "field003", "weaver.hrm.common.SplitPageTagFormat.colFormat", "{cmd:array["+user.getLanguage()+";default=19516and19532,1=468and19532]}"); + if(strUtil.vString(ManageDetachComInfo.getDetachable()).equals("1")) { + table.addCol(width4, SystemEnv.getHtmlLabelName(19799,user.getLanguage()), "field004", "field004", "weaver.hrm.company.SubCompanyComInfo.getSubCompanyname"); + } + table.addCol(width5, SystemEnv.getHtmlLabelName(602,user.getLanguage()), "field005", "field005", "weaver.hrm.common.SplitPageTagFormat.colFormat", "{cmd:style[0=color:red]}{cmd:array["+user.getLanguage()+";default=18096,1=18095]}"); + table.addCol(width6, SystemEnv.getHtmlLabelName(19521,user.getLanguage()), "field009"); + table.addCol(width7, SystemEnv.getHtmlLabelName(10000608,weaver.general.Util.getIntValue(user.getLanguage())), "field006", "field006", "weaver.hrm.common.SplitPageTagFormat.colFormat", "{cmd:array["+user.getLanguage()+";default=670and18015,1=20084and18015,2=24058and18015,3=6151and18015,4=127655,5=390737,6=389117,7=390274,8=513400]}"); + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid+"_"+Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, table.toString()); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + if(operatelevel > 0){ + retmap.put("canAdd", true); + }else{ + retmap.put("canAdd", false); + } + if(operatelevel > 1){ + retmap.put("canDel", true); + }else{ + retmap.put("canDel", false); + } + }catch(Exception e){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetTabInfoCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetTabInfoCmd.java new file mode 100644 index 0000000..953fa94 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateProcSetTabInfoCmd.java @@ -0,0 +1,109 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取考勤流程设置的 tab页签数据 + * @author pzy + * + */ +public class GetStateProcSetTabInfoCmd extends AbstractCommonCommand>{ + + public GetStateProcSetTabInfoCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try { + if(!HrmUserVarify.checkUserRight("HrmAttendanceProcess:setting",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String url = ""; + String title = ""; + StringUtil strUtil = new StringUtil(); + String id = Util.null2String(params.get("id")); + int field006 = Util.getIntValue(Util.null2String(params.get("field006"))); + String subcompanyid = Util.null2String(params.get("subcompanyid")); + + HrmAttProcSetManager attProcSetManager = new HrmAttProcSetManager(); + HrmAttProcSet bean = attProcSetManager.get(id); + bean = bean == null ? new HrmAttProcSet() : bean; + + List> tabs = new ArrayList>(); + Map tab = null; + + tab = new HashMap(); + title = SystemEnv.getHtmlLabelName(500272,weaver.general.Util.getIntValue(user.getLanguage())); + url = "/hrm/attendance/hrmAttProcSet/content.jsp?id="+id+"&subcompanyid="+subcompanyid; + tab.put("key", "1"); + tab.put("url", url); + tab.put("title", title); + tabs.add(tab); + if(strUtil.isNotNull(id)) { + tab = new HashMap(); + title = SystemEnv.getHtmlLabelName(10000609,weaver.general.Util.getIntValue(user.getLanguage())); + url = "/hrm/attendance/hrmAttProcSet/wfFields.jsp?id="+id; + tab.put("key", "2"); + tab.put("url", url); + tab.put("title", title); + tabs.add(tab); + tab = new HashMap(); + title = SystemEnv.getHtmlLabelName(33085,weaver.general.Util.getIntValue(user.getLanguage())); + url = "/hrm/attendance/hrmAttProcSet/wfSet.jsp?id="+id; + tab.put("key", "3"); + tab.put("url", url); + tab.put("title", title); + tabs.add(tab); + } + if(field006 == KqSplitFlowTypeEnum.LEAVE.getFlowtype() + || field006 == KqSplitFlowTypeEnum.EVECTION.getFlowtype() + || field006 == KqSplitFlowTypeEnum.OUT.getFlowtype() + || field006 == KqSplitFlowTypeEnum.OVERTIME.getFlowtype() + || field006 == KqSplitFlowTypeEnum.CARD.getFlowtype() + || field006 == KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype()){ + tab = new HashMap(); + title = SystemEnv.getHtmlLabelName(83194,weaver.general.Util.getIntValue(user.getLanguage())); + tab.put("key", "4"); + tab.put("url", url); + tab.put("title", title); + tabs.add(tab); + } + + retmap.put("status", "1"); + retmap.put("tabs", tabs); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/GetStateRightMenuCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateRightMenuCmd.java new file mode 100644 index 0000000..bff4700 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/GetStateRightMenuCmd.java @@ -0,0 +1,73 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.api.hrm.bean.RightMenu; +import com.api.hrm.bean.RightMenuType; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +/** + * 获取考勤流程设置的右键菜单 + * @author pzy + * + */ +public class GetStateRightMenuCmd extends AbstractCommonCommand>{ + + public GetStateRightMenuCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + int id = Util.getIntValue((String)params.get("id")); + String pageid = Util.null2String(params.get("pageid"));//页面标识 + List rightMenu = new ArrayList(); + try { + if(!HrmUserVarify.checkUserRight("HrmAttendanceProcess:setting", user)){ + retmap.put("hasRight", false); + }else{ + retmap.put("hasRight", true); + } + rightMenu = getListMenu(type, id, pageid, user); + } catch (Exception e) { + writeLog(e); + } + retmap.put("status", "1"); + retmap.put("rightMenu", rightMenu); + retmap.put("hasDpIcon", true); + return retmap; + } + + /** + * 获取考勤流程设置的菜单 + * @param type + * @param id + * @param pageid + * @param user + * @return + */ + public static List getListMenu(String type, int id, String pageid, User user){ + List rightMenu = new ArrayList(); + + rightMenu.add(new RightMenu(user.getLanguage(), RightMenuType.BTN_Addnew, "showContent", true)); + rightMenu.add(new RightMenu(user.getLanguage(), RightMenuType.BTN_BatchDelete, "doDel", true, true)); + + return rightMenu; + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/HrmAttProcSetLogUtil.java b/src/com/engine/kq/cmd/hrmAttProcSet/HrmAttProcSetLogUtil.java new file mode 100644 index 0000000..7f27cb6 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/HrmAttProcSetLogUtil.java @@ -0,0 +1,92 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import java.util.Date; +import java.util.Map; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 考勤流程设置日志记录用工具类 + */ +public class HrmAttProcSetLogUtil { + + private User user; + private BizLogType logType; + private BizLogSmallType belongType; + private BizLogSmallType logSmallType; + + public HrmAttProcSetLogUtil() { + } + + public HrmAttProcSetLogUtil(User user,BizLogType logType,BizLogSmallType belongType,BizLogSmallType logSmallType) { + this.user = user; + this.logType = logType; + this.belongType = belongType; + this.logSmallType = logSmallType; + } + + /** + * 返回考勤流程设置操作相应的logger + * @param useSql 是否使用自定义的sql + * @param realLogSql + * @param params + * @param sourceType + * @return SimpleBizLogger + */ + public SimpleBizLogger logStateSetLogSql(boolean useSql,String realLogSql,Map params,String sourceType){ + SimpleBizLogger logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(logType); + logContext.setBelongType(belongType); + logContext.setLogSmallType(logSmallType); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_ATT_PROC_SET "; + if(useSql){ + if(realLogSql.length() > 0){ + mainSql = realLogSql; + } + } + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod(this.getClass().getName() + ".getTargetName", sourceType+"+"+user.getLanguage()); + logger.before(logContext); + return logger; + } + + /** + * 获取日志对象的名称 + * @param id + * @param para2 + * @return + */ + public String getTargetName(String id,String para2){ + String[] otherParams = Util.TokenizerString2(para2, "+"); + String sourceType = Util.null2s(otherParams[0], ""); + int languageId = Util.getIntValue(otherParams[1], 7); + String result = SystemEnv.getHtmlLabelName(82797, languageId); + switch (sourceType){ + case "basicinfo": + result = SystemEnv.getHtmlLabelName(10000610,weaver.general.Util.getIntValue(languageId)); + break; + case "wffield": + result = SystemEnv.getHtmlLabelName(10000611,weaver.general.Util.getIntValue(languageId)); + break; + case "action": + result = SystemEnv.getHtmlLabelName(10000612,weaver.general.Util.getIntValue(languageId)); + break; + case "createForm": + result = SystemEnv.getHtmlLabelName(10000613,weaver.general.Util.getIntValue(languageId)); + break; + default: + break; + } + return result; + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/KqSplitActionEnum.java b/src/com/engine/kq/cmd/hrmAttProcSet/KqSplitActionEnum.java new file mode 100644 index 0000000..4725f13 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/KqSplitActionEnum.java @@ -0,0 +1,74 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +/** + * 考勤流程类型和action对应 + */ +public enum KqSplitActionEnum { + /** + * 请假 + */ + LEAVE("0", "KqSplitAction"), + /** + * 出差 + */ + EVECTION("1", "KqSplitAction"), + /** + * 公出 + */ + OUT("2", "KqSplitAction"), + /** + * 加班 + */ + OVERTIME("3", "KqSplitAction"), + /** + * 异常流程 + */ + OTHER("4", "KqSplitAction"), + /** + * 排班流程 + */ + SHIFT("5", "KqSplitAction"), + /** + * 销假 + */ + LEAVEBACK("6", "KqSplitAction"), + /** + * 补卡 + */ + Card("7", "KqSplitAction"), + /** + * 考勤流程通用action + */ + ATT("", "KqSplitAction"); + + + private String flowtype; + private String splitAction; + private String splitFreezeAction; + + /** + * @param flowtype 考勤流程类型 + * @param splitAction action名称 + */ + KqSplitActionEnum(String flowtype, String splitAction) { + this.flowtype = flowtype; + this.splitAction = splitAction; + } + + public String getFlowtype() { + return flowtype; + } + + public void setFlowtype(String flowtype) { + this.flowtype = flowtype; + } + + public String getSplitAction() { + return splitAction; + } + + public void setSplitAction(String splitAction) { + this.splitAction = splitAction; + } + +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/KqTempletEnum.java b/src/com/engine/kq/cmd/hrmAttProcSet/KqTempletEnum.java new file mode 100644 index 0000000..4267e56 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/KqTempletEnum.java @@ -0,0 +1,94 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +/** + * 考勤流程类型和模板对应 + */ +public enum KqTempletEnum { + /** + * 请假 + */ + LEAVE("0", "HrmCustomLeave_e9.jsp","HrmCustomLeave_e9.jsp","/workflow/request/ext4e9/"), + /** + * 出差 + */ + EVECTION("1", "HrmCustomEvection_e9.jsp","HrmCustomEvection_e9.jsp","/workflow/request/ext4e9/"), + /** + * 公出 + */ + OUT("2", "HrmCustomOut_e9.jsp","HrmCustomOut_e9.jsp","/workflow/request/ext4e9/"), + /** + * 加班 + */ + OVERTIME("3", "HrmCustomOvertime_e9.jsp","HrmCustomOvertime_e9.jsp","/workflow/request/ext4e9/"), + /** + * 异常流程 + */ + OTHER("4", "HrmCustomOther_e9.jsp","HrmCustomOther_e9.jsp","/workflow/request/ext4e9/"), + /** + * 调班 + */ + SHIFT("5", "HrmCustomShift_e9.jsp","HrmCustomShift_e9.jsp","/workflow/request/ext4e9/"), + /** + * 销假 + */ + LEAVEBACK("6", "HrmCustomLeaveBack_e9.jsp","HrmCustomLeaveBack_e9.jsp","/workflow/request/ext4e9/"), + /** + * 补卡 + */ + Card("7", "HrmCustomCard_e9.jsp","HrmCustomCard_e9.jsp","/workflow/request/ext4e9/"), + /** + * 补卡 + */ + PROCESSCHANGE("8", "HrmCustomProcessChange_e9.jsp","HrmCustomProcessChange_e9.jsp","/workflow/request/ext4e9/"); + + + private String flowtype; + private String templetfile; + private String templetmobilefile; + private String templetroute; + + /** + * @param flowtype 考勤流程类型 + * @param templetfile 模板文件 + * @param templetmobilefile 手机端模板文件 + * @param templetroute 模板地址 + */ + KqTempletEnum(String flowtype, String templetfile, String templetmobilefile,String templetroute) { + this.flowtype = flowtype; + this.templetfile = templetfile; + this.templetmobilefile = templetmobilefile; + this.templetroute = templetroute; + } + + public String getFlowtype() { + return flowtype; + } + + public void setFlowtype(String flowtype) { + this.flowtype = flowtype; + } + + public String getTempletfile() { + return templetfile; + } + + public void setTempletfile(String templetfile) { + this.templetfile = templetfile; + } + + public String getTempletmobilefile() { + return templetmobilefile; + } + + public void setTempletmobilefile(String templetmobilefile) { + this.templetmobilefile = templetmobilefile; + } + + public String getTempletroute() { + return templetroute; + } + + public void setTempletroute(String templetroute) { + this.templetroute = templetroute; + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/SaveCustomKQFlowCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/SaveCustomKQFlowCmd.java new file mode 100644 index 0000000..30c5659 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/SaveCustomKQFlowCmd.java @@ -0,0 +1,66 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 保存 自定义考勤流程 + * @author pzy + * + */ +public class SaveCustomKQFlowCmd extends AbstractCommonCommand>{ + + public SaveCustomKQFlowCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + try { + if(!HrmUserVarify.checkUserRight("HrmAttendanceProcess:setting", user)){ + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + List> tabs = new ArrayList>(); + Map tab = null; + + tab = new HashMap(); + tab.put("key", "1"); + tab.put("title", SystemEnv.getHtmlLabelName(500272,user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", "2"); + tab.put("title", SystemEnv.getHtmlLabelName(10000813,weaver.general.Util.getIntValue(user.getLanguage()))); + tabs.add(tab); + + retmap.put("status", "1"); + retmap.put("tabs", tabs); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcCheckRuleCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcCheckRuleCmd.java new file mode 100644 index 0000000..5f61127 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcCheckRuleCmd.java @@ -0,0 +1,265 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.log.KQLog; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 考勤流程 保存校验规则 + * @author pzy + * + */ +public class SaveStateProcCheckRuleCmd extends AbstractCommonCommand>{ + + private SimpleBizLogger logger; + private KQLog kqLog = new KQLog(); + + public SaveStateProcCheckRuleCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + try { + String id = Util.null2s(Util.null2String(params.get("id")),""); + kqLog.info("SaveStateProcCheckRuleCmd:params:"+params); + List> fieldList = Lists.newArrayList(); + buildFiledList(fieldList); + if(id.length() > 0){ + checkCanSave(params,fieldList,retmap,id); + if(!retmap.isEmpty()){ + return retmap; + } + edit(params,id,fieldList); + }else{ + checkCanSave(params,fieldList,retmap,""); + if(!retmap.isEmpty()){ + return retmap; + } + add(params,fieldList); + } + kqLog.info("SaveStateProcCheckRuleCmd:retmap:"+retmap); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + + /** + * 判断是否可以添加 + * 重复校验不允许添加多个 + * 次数校验,不允许添加同样类型的,比如同一天控制的不能添加多个 + * @param params + * @param fieldList + * @param retmap + * @param id 如果是编辑的话,是有id的 + */ + private void checkCanSave(Map params, List> fieldList, + Map retmap,String id) { + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + RecordSet rs3 = new RecordSet(); + String rule_type_uuid = Util.null2s(Util.null2String(params.get("rule_type_uuid")),""); + String attid = Util.null2s(Util.null2String(params.get("attid")),""); + String kqtype = Util.null2s(Util.null2String(params.get("kqtype")),""); + String sql = "select * from kq_att_checkrule_type where uuid = ? and att_type=? "; + rs.executeQuery(sql,rule_type_uuid,kqtype); + if(rs.next()) { + String rule_table = rs.getString("rule_table"); + if (rule_table.length() > 0) { + if("kq_att_duplicate_rule".equalsIgnoreCase(rule_table)){ + //重复校验 + String check_sql = "select * from kq_att_checkrule_set where rule_type_uuid=? and attid=? "; + rs1.executeQuery(check_sql, rule_type_uuid,attid); + if(id.length() > 0){ + //如果是编辑的情况 ,需要判断是 + check_sql = "select * from kq_att_checkrule_set where rule_type_uuid=? and attid=? and id <>? "; + rs1.executeQuery(check_sql, rule_type_uuid,attid,id); + } + if(rs1.next()){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(516715,user.getLanguage())); + return ; + } + }else if("kq_att_frequency_rule".equalsIgnoreCase(rule_table)){ + //次数校验 + String check_sql = "select * from kq_att_checkrule_set where rule_type_uuid=? and attid=? "; + rs1.executeQuery(check_sql, rule_type_uuid,attid); + if(id.length() > 0){ + //如果是编辑的情况 ,需要判断是 + check_sql = "select * from kq_att_checkrule_set where rule_type_uuid=? and attid=? and id <>? "; + rs1.executeQuery(check_sql, rule_type_uuid,attid,id); + } + while (rs1.next()){ + String ruleid = rs1.getString("ruleid"); + String frequency_rule = Util.null2s(Util.null2String(params.get("frequency_rule")),""); + String check_type_sql = "select * from "+rule_table+" where id=? and frequency_rule=? "; + rs2.executeQuery(check_type_sql,ruleid,frequency_rule); + if(rs2.next()){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(516715,user.getLanguage())); + return ; + } + } + } + } + } + } + + public void buildFiledList(List> fieldList) throws Exception{ + RecordSet rs = new RecordSet(); + //校验规则的 校验类型 如果没有传过来,默认就是第一个 + String rule_type_uuid = Util.null2s(Util.null2String(params.get("rule_type_uuid")),""); + String kqtype = Util.null2s(Util.null2String(params.get("kqtype")),""); + if(rule_type_uuid.length() == 0){ + String att_type_sql = "select * from kq_att_checkrule_type where att_type = "+kqtype+" order by rule_type_order "; + rs.executeQuery(att_type_sql); + if(rs.next()){ + rule_type_uuid = rs.getString("uuid"); + } + } + String fieldSql = "select * from kq_att_checkrule_fields where rule_type_uuid = '"+rule_type_uuid+"' order by fieldorder "; + rs.executeQuery(fieldSql); + while (rs.next()){ + String fieldname = rs.getString("fieldname"); + String fieldlabel = rs.getString("fieldlabel"); + String fieldhtmltype = rs.getString("fieldhtmltype"); + String fieldtype = rs.getString("fieldtype"); + Map fieldMap = Maps.newHashMap(); + fieldMap.put("fieldname", fieldname); + fieldMap.put("fieldlabel", fieldlabel); + fieldMap.put("fieldhtmltype", fieldhtmltype); + fieldMap.put("fieldtype", fieldtype); + fieldList.add(fieldMap); + } + } + + public void add(Map params, + List> fieldList) throws Exception{ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + RecordSet rs3 = new RecordSet(); + String rule_type_uuid = Util.null2s(Util.null2String(params.get("rule_type_uuid")),""); + String attid = Util.null2s(Util.null2String(params.get("attid")),""); + String kqtype = Util.null2s(Util.null2String(params.get("kqtype")),""); + String sql = "select * from kq_att_checkrule_type where uuid = ? and att_type=? "; + rs.executeQuery(sql,rule_type_uuid,kqtype); + if(rs.next()){ + String rule_table = rs.getString("rule_table"); + if(rule_table.length() > 0){ + String uuid = UUID.randomUUID().toString(); + String fieldnames = ""; + String values_key = ""; + List values_value = Lists.newArrayList(); + + for(int i = 0 ; i < fieldList.size() ; i++){ + Map fieldMap = fieldList.get(i); + String fieldname = fieldMap.get("fieldname"); + String fieldvalue = Util.null2s(Util.null2String(params.get(fieldname)),""); + fieldnames += ","+fieldname; + values_key += ",? "; + values_value.add(fieldvalue); + } + if(fieldnames.length() > 0){ + fieldnames = fieldnames.substring(1); + } + if(values_key.length() > 0){ + values_key = values_key.substring(1); + } + String sql1 = "insert into "+rule_table+"("+fieldnames+",uuid)" + + " values("+values_key+",?)"; + values_value.add(uuid); + + kqLog.info("SaveStateProcCheckRuleCmd:add:"+sql1+":values_value:"+values_value); + boolean isok = rs1.executeUpdate(sql1,values_value); + if(isok){ + String sql2 = "select * from "+rule_table+" where uuid = ? "; + kqLog.info("SaveStateProcCheckRuleCmd:sql2:"+sql2+":uuid:"+uuid); + rs2.executeQuery(sql2,uuid); + if(rs2.next()){ + String ruleid = rs2.getString("id"); + String sql3 = "insert into kq_att_checkrule_set(attid,ruleid,rule_type_uuid,uuid) values(?,?,?,?)"; + isok = rs3.executeUpdate(sql3, attid,ruleid,rule_type_uuid,uuid); + kqLog.info("SaveStateProcCheckRuleCmd:sql3:"+sql3+":attid:"+attid+":ruleid:"+ruleid + +":rule_type_uuid:"+rule_type_uuid+":uuid:"+uuid+":isok:"+isok); + } + }else{ + throw new Exception("数据插入失败"); + } + } + } + } + + public void edit(Map params, String id, + List> fieldList) throws Exception{ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String rule_type_uuid = Util.null2s(Util.null2String(params.get("rule_type_uuid")),""); + String kqtype = Util.null2s(Util.null2String(params.get("kqtype")),""); + String sql = "select * from kq_att_checkrule_type where uuid = ? and att_type=?"; + rs.executeQuery(sql,rule_type_uuid,kqtype); + if(rs.next()){ + String rule_table = rs.getString("rule_table"); + if(rule_table.length() > 0){ + String check_sql = "select * from kq_att_checkrule_set where id=? "; + rs1.executeQuery(check_sql, id); + if(rs1.next()){ + String ruleid = rs1.getString("ruleid"); + if(ruleid.length() > 0){ + String fieldvalues_key = ""; + List fieldvalues_value = Lists.newArrayList(); + for(int i = 0 ; i < fieldList.size() ; i++){ + Map fieldMap = fieldList.get(i); + String fieldname = fieldMap.get("fieldname"); + String fieldvalue = Util.null2s(Util.null2String(params.get(fieldname)),""); + fieldvalues_key += ","+fieldname+"=? "; + fieldvalues_value.add(fieldvalue); + } + if(fieldvalues_key.length() > 0){ + fieldvalues_key = fieldvalues_key.substring(1); + } + String sql1 = " update "+rule_table+" set "+fieldvalues_key+" where id=? "; + fieldvalues_value.add(ruleid); + boolean isok = rs1.executeUpdate(sql1,fieldvalues_value); + + if(isok){ + }else{ + throw new Exception("数据插入失败"); + } + } + } + } + } + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcSetCreateFormCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcSetCreateFormCmd.java new file mode 100644 index 0000000..990489e --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcSetCreateFormCmd.java @@ -0,0 +1,243 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.wfset.attendance.domain.HrmAttProcFields; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.attendance.manager.HrmAttProcFieldsManager; +import com.engine.kq.wfset.auto.AutoInitWFSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.common.database.dialect.DialectUtil; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.label.LabelComInfo; +import weaver.workflow.form.FormManager; +import weaver.workflow.workflow.BillComInfo; +import weaver.workflow.workflow.WorkflowBillComInfo; + +/** + * 改变考勤流程设置的信息 + * @author pzy + * + */ +public class SaveStateProcSetCreateFormCmd extends AbstractCommonCommand>{ + + private SimpleBizLogger logger; + + public SaveStateProcSetCreateFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + try { + if(!HrmUserVarify.checkUserRight("HrmAttendanceProcess:setting", user)){ + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + int formid1 = 0; + + int field006 = StringUtil.parseToInt(StringUtil.vString(params.get("field006")), 0); + int usedetail = StringUtil.parseToInt(StringUtil.vString(params.get("usedetail")), 0); + if(field006 == 5 || field006 == 6 || field006 == 7 || field006 == 8){ + //排班流程默认只有明细 + usedetail = 1; + } + String formname = StringUtil.vString(params.get("formName")); + AutoInitWFSet autoInitWFSet = new AutoInitWFSet(); + autoInitWFSet.setUser(user); + autoInitWFSet.setLog(false); + autoInitWFSet.setIsdetail(1==usedetail); + formid1 = autoInitWFSet.InitForm(""+field006, formname); +// formid1 = createTable(field006,formname,retmap); + + if(formid1 != 0){ + retmap.put("formId", formid1); + retmap.put("formName", formname); + retmap.put("status", "1"); + } + + } catch (Exception e) { + retmap.put("status", "-1"); + if(e.getMessage().equalsIgnoreCase(SystemEnv.getHtmlLabelName(83791,user.getLanguage()))){ + retmap.put("message", SystemEnv.getHtmlLabelName(83791,user.getLanguage())); + }else{ + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + writeLog(e); + } + + return retmap; + } + + /** + * 生成表单和字段对应关系 + * @param field006 + * @param formname + * @param retmap + * @return + * @throws Exception + */ + public int createTable(int field006, String formname,Map retmap) throws Exception{ + RecordSet rs = new RecordSet(); + boolean isoracle = rs.getDBType().equals("oracle") ; + boolean issqlserver = rs.getDBType().equals("sqlserver"); + + formname = formname.replaceAll("<","<").replaceAll(">",">").replaceAll("'","''"); + formname = Util.toHtmlForSplitPage(formname); + rs.executeSql("select COUNT(*) from (select t2.labelname from workflow_bill t left join htmllabelinfo t2 on t.namelabel = t2.indexid where t2.labelname = '"+formname+"' union all select formname from workflow_formbase where formname = '"+formname+"') t"); + if(rs.next() && rs.getInt(1) > 0){ + String errorLabel = SystemEnv.getHtmlLabelName(83791, user.getLanguage()); + retmap.put("status", "-1"); + retmap.put("message", errorLabel); + return 0; + } + FormManager FormManager = new FormManager(); + RecordSetTrans RecordSetTrans = new RecordSetTrans(); + BillComInfo BillComInfo = new BillComInfo(); + LabelComInfo LabelComInfo = new LabelComInfo(); + HrmAttProcFieldsManager attProcFieldsManager = new HrmAttProcFieldsManager(); + + String formdes = StringUtil.vString(params.get("formdes")); + formdes = formdes.replaceAll("<","<").replaceAll(">",">").replaceAll("'","''"); + formdes = Util.toHtmlForSplitPage(formdes); + int subcompanyid = Util.getIntValue(StringUtil.vString(params.get("subcompanyid")),-1); + int subCompanyId3 = Util.getIntValue(StringUtil.vString(params.get("subcompanyid3")),-1); + int formid1 = FormManager.getNewFormId(); + String formtable_main = "formtable_main_"+formid1*(-1); + if(formid1 < -1) { + HrmAttProcSetLogUtil hrmAttProcSetLogUtil = new HrmAttProcSetLogUtil(user,BizLogType.HRM_ENGINE, BizLogSmallType4Hrm.HRM_ENGINE_HRM_ATT_PROCSET, BizLogSmallType4Hrm.HRM_ENGINE_HRM_ATT_PROCSET); + String realLogSql = "select *from workflow_billfield where "+Util.getSubINClause(""+formid1, "billid", "in");; + this.logger = hrmAttProcSetLogUtil.logStateSetLogSql(true, realLogSql, params,"createForm"); + + boolean success = false; + RecordSetTrans.setAutoCommit(false); + try{ + int namelabelid = -1; + if(issqlserver) RecordSetTrans.executeSql("select indexid from HtmlLabelInfo where labelname='"+formname+"' collate Chinese_PRC_CS_AI and languageid="+user.getLanguage()); + else RecordSetTrans.executeSql("select indexid from HtmlLabelInfo where labelname='"+formname+"' and languageid="+user.getLanguage()); + if(RecordSetTrans.next()) namelabelid = RecordSetTrans.getInt("indexid");//如果表单名称在标签库中存在,取得标签id + else{ + namelabelid = FormManager.getNewIndexId(RecordSetTrans);//生成新的标签id + if(namelabelid!=-1){//更新标签库 + RecordSetTrans.executeSql("delete from HtmlLabelIndex where id="+namelabelid); + RecordSetTrans.executeSql("delete from HtmlLabelInfo where indexid="+namelabelid); + RecordSetTrans.executeSql(" insert into HtmlLabelIndex(id,indexdesc) values("+namelabelid+",'"+formname+"')"); + RecordSetTrans.executeSql(" insert into HtmlLabelInfo(INDEXID,labelname, LANGUAGEID) values("+namelabelid+",'"+formname+"',7)"); + RecordSetTrans.executeSql(" insert into HtmlLabelInfo(INDEXID,labelname, LANGUAGEID) values("+namelabelid+",'"+formname+"',8)"); + RecordSetTrans.executeSql(" insert into HtmlLabelInfo(INDEXID,labelname, LANGUAGEID) values("+namelabelid+",'"+formname+"',9)"); + } + } + int minSubId = -1; + if(subcompanyid==-1){//分权分部的取得。如果页面没有,则首先从分权设置的默认机构取得,如果默认机构没有设置则取所有分部中id最小的那个分部。 + RecordSetTrans.executeSql("select dftsubcomid from SystemSet"); + if(RecordSetTrans.next()) subcompanyid = Util.getIntValue(RecordSetTrans.getString("dftsubcomid"),-1); + if(subcompanyid==-1){ + RecordSetTrans.executeSql("select min(id) as id from HrmSubCompany"); + if(RecordSetTrans.next()) { + minSubId = subcompanyid = RecordSetTrans.getInt("id"); + } + } + } + if(subCompanyId3==-1){//分权分部的取得。如果页面没有,则首先从分权设置的默认机构取得,如果默认机构没有设置则取所有分部中id最小的那个分部。 + RecordSetTrans.executeSql("select fmdftsubcomid,dftsubcomid from SystemSet"); + if(RecordSetTrans.next()){ + subCompanyId3 = Util.getIntValue(RecordSetTrans.getString("fmdftsubcomid"),-1); + if(subCompanyId3 == -1) subCompanyId3 = Util.getIntValue(RecordSetTrans.getString("dftsubcomid"),-1); + } + if(subCompanyId3 == -1){ + if(minSubId == -1) { + RecordSetTrans.executeSql("select min(id) as id from HrmSubCompany"); + if(RecordSetTrans.next()) subCompanyId3 = RecordSetTrans.getInt("id"); + } else { + subCompanyId3 = minSubId; + } + } + } + RecordSetTrans.executeSql("insert into workflow_bill(id,namelabel,tablename,detailkeyfield,formdes,subcompanyid,subCompanyId3,from_module_) values("+formid1+",'"+namelabelid+"','"+formtable_main+"','mainid','"+formdes+"','"+subcompanyid+"','"+subCompanyId3+"','hrm_mf')"); + FormManager.createMainForm(formid1,formtable_main); + RecordSetTrans.commit(); + + LabelComInfo.addLabeInfoCache(String.valueOf(namelabelid)); + BillComInfo.addBillCache(""+formid1); + WorkflowBillComInfo workflowBillComInfo=new WorkflowBillComInfo(); + workflowBillComInfo.addWorkflowBillCache(String.valueOf(formid1)); + success = true; + }catch(Exception exception){ + exception.printStackTrace(); + success = false; + RecordSetTrans.rollback(); + } + //根据已有表单新建表单,需要把原表单的信息复制过来 + if(success){ + int oldformid = Util.getIntValue(String.valueOf(params.get("oldformid")), 0); + if(oldformid != 0){ + int detachable=Util.getIntValue(String.valueOf(params.get("detachable")),0); + FormManager.setFormInfoByTemplate(formid1, oldformid,0,user); + } + } + RecordSetTrans = new RecordSetTrans(); + RecordSetTrans.setAutoCommit(false); + HrmAttProcSet setBean = new HrmAttProcSet(); + setBean.setField006(field006); + List list = attProcFieldsManager.find("[map]field001:"+setBean.getBillId()+";languageid:"+user.getLanguage()); + //生成主表字段 + String isDecimal = "number\\((\\d+),(\\d+)\\)" ; + HrmAttProcFields bean = null; + String fieldname = ""; + String fielddbtype = ""; + for(int i=0; i>{ + + private SimpleBizLogger logger; + + public SaveStateProcSetFlowCmd(Map params, User user) { + this.user = user; + this.params = params; + HrmAttProcSetLogUtil hrmAttProcSetLogUtil = new HrmAttProcSetLogUtil(user,BizLogType.HRM_ENGINE, BizLogSmallType4Hrm.HRM_ENGINE_HRM_ATT_PROCSET, BizLogSmallType4Hrm.HRM_ENGINE_HRM_ATT_PROCSET); + String realLogSql = ""; + this.logger = hrmAttProcSetLogUtil.logStateSetLogSql(false, realLogSql, params,"basicinfo"); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + try { + if(!HrmUserVarify.checkUserRight("HrmAttendanceProcess:setting", user)){ + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + KQAttFlowSetComInfo kqAttFlowSetComInfo = new KQAttFlowSetComInfo(); + RecordSet rs = new RecordSet(); + HrmAttProcSetManager attProcSetManager = new HrmAttProcSetManager(); + + int id = StringUtil.parseToInt(StringUtil.vString(params.get("id")), 0); + int field001 = StringUtil.parseToInt(StringUtil.vString(params.get("field001")), 0); + + boolean hasDefined = checkHasDefined(field001,id); + if(hasDefined){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(500705,user.getLanguage())); + return retmap; + } + + int field002 = StringUtil.parseToInt(StringUtil.vString(params.get("field002")), 0); + int field003 = StringUtil.parseToInt(StringUtil.vString(params.get("field003")), 0); + int field004 = StringUtil.parseToInt(StringUtil.vString(params.get("field004")), 0); + int field005 = StringUtil.parseToInt(StringUtil.vString(params.get("field005")), 1); + int field006 = StringUtil.parseToInt(StringUtil.vString(params.get("field006"))); + int field007 = StringUtil.parseToInt(StringUtil.vString(params.get("field007")), 0); + String field008 = StringUtil.vString(StringUtil.vString(params.get("field008")), DateUtil.getCurrentDate()); + String field009 = StringUtil.vString(StringUtil.vString(params.get("field009")), DateUtil.getCurrentDate()); + String field010 = StringUtil.vString(StringUtil.vString(params.get("field010"))); + int usedetail = StringUtil.parseToInt(StringUtil.vString(params.get("usedetail")), 0); + int flow_deduct_card = StringUtil.parseToInt(StringUtil.vString(params.get("flow_deduct_card")), 0); + usedetail = usedetail < 0 ? 0 : usedetail; + if(KqTempletEnum.SHIFT.getFlowtype().equalsIgnoreCase(""+field006) + ||KqTempletEnum.Card.getFlowtype().equalsIgnoreCase(""+field006) + ||KqTempletEnum.LEAVEBACK.getFlowtype().equalsIgnoreCase(""+field006) + ||KqTempletEnum.PROCESSCHANGE.getFlowtype().equalsIgnoreCase(""+field006)){ + usedetail = 1; + } + if(!(KqTempletEnum.LEAVE.getFlowtype().equalsIgnoreCase(""+field006) + ||KqTempletEnum.EVECTION.getFlowtype().equalsIgnoreCase(""+field006) + ||KqTempletEnum.OUT.getFlowtype().equalsIgnoreCase(""+field006))){ + flow_deduct_card = 0; + } + String templetfile = StringUtil.vString(StringUtil.vString(params.get("templetfile"))); + String templetmobilefile = StringUtil.vString(StringUtil.vString(params.get("templetmobilefile"))); + String templetroute = StringUtil.vString(StringUtil.vString(params.get("templetroute"))); + + rs.executeSql("select * from view_workflowForm_selectAll where isoldornew = 1 and id > 0 and id = "+field002); + if(rs.next()) { + field003 = 1; + } + HrmAttProcSet bean = null; + if(id > 0) { + bean = attProcSetManager.get(id); + } + bean = bean == null ? new HrmAttProcSet(true) : bean; + bean.setField001(field001); + bean.setField002(field002); + bean.setField003(field003); + bean.setField004(field004); + bean.setField005(field005); + bean.setField006(field006); + if(id <= 0) { + bean.setField007(field007); + bean.setField008(field008); + } else { + bean.setField010(field010); + } + bean.setField009(field009); + bean.setUsedetail(usedetail); + bean.setTempletfile(templetfile); + bean.setTempletmobilefile(templetmobilefile); + bean.setTempletroute(templetroute); + bean.setFlow_deduct_card(flow_deduct_card); + retmap.put("id", String.valueOf(attProcSetManager.save(bean))); + if(field005 == 1) { + attProcSetManager.welcomeToSet(field001, field006,templetfile,templetmobilefile,templetroute); + } + kqAttFlowSetComInfo.removeKQAttFlowSetComInfoCache(); + + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + + /** + * 判断此流程是否已经关联考勤 + * @param field001 + * @param id + */ + private boolean checkHasDefined(int field001, int id) { + RecordSet rs = new RecordSet(); + String hasDefinedSql = "select 1 from kq_att_proc_set where field001= ? and id <> ?"; + rs.executeQuery(hasDefinedSql, field001,id); + if(rs.next()){ + return true; + } + return false; + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcSetFlowWfFieldsCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcSetFlowWfFieldsCmd.java new file mode 100644 index 0000000..c77f816 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcSetFlowWfFieldsCmd.java @@ -0,0 +1,94 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQAttFlowSetComInfo; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.attendance.manager.HrmAttProcRelationManager; +import com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import weaver.common.DateUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 保存考勤流程设置的 字段对应信息 + * @author pzy + * + */ +public class SaveStateProcSetFlowWfFieldsCmd extends AbstractCommonCommand>{ + + private HttpServletRequest request; + private SimpleBizLogger logger; + + public SaveStateProcSetFlowWfFieldsCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + public SaveStateProcSetFlowWfFieldsCmd(Map params, HttpServletRequest request,User user) { + this.user = user; + this.params = params; + this.request = request; + HrmAttProcSetLogUtil hrmAttProcSetLogUtil = new HrmAttProcSetLogUtil(user,BizLogType.HRM_ENGINE, BizLogSmallType4Hrm.HRM_ENGINE_HRM_ATT_PROCSET, BizLogSmallType4Hrm.HRM_ENGINE_HRM_ATT_PROCSET); + String realLogSql = "select * from kq_ATT_PROC_RELATION"; + this.logger = hrmAttProcSetLogUtil.logStateSetLogSql(true, realLogSql, params,"wffield"); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + try { + if(!HrmUserVarify.checkUserRight("HrmAttendanceProcess:setting", user)){ + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + KQAttFlowSetComInfo kqAttFlowSetComInfo = new KQAttFlowSetComInfo(); + HrmAttProcSetManager attProcSetManager = new HrmAttProcSetManager(); + HrmAttProcRelationManager attProcRelationManager = new HrmAttProcRelationManager(); + HrmAttProcSet bean = attProcSetManager.get(Util.getIntValue(Util.null2String(request.getParameter("field001")), 0)); + if(bean != null) { + attProcRelationManager.save(request,bean,retmap,user); + if(!retmap.isEmpty()){ + return retmap; + } + bean.setField009(DateUtil.getCurrentDate()); + attProcSetManager.update(bean); + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog("字段对应保存的时候获取HrmAttProcSet报错"); + return retmap; + } + kqAttFlowSetComInfo.removeKQAttFlowSetComInfoCache(); + retmap.put("status", "1"); + + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } +} diff --git a/src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcSetFlowWfSetCmd.java b/src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcSetFlowWfSetCmd.java new file mode 100644 index 0000000..cb47976 --- /dev/null +++ b/src/com/engine/kq/cmd/hrmAttProcSet/SaveStateProcSetFlowWfSetCmd.java @@ -0,0 +1,90 @@ +package com.engine.kq.cmd.hrmAttProcSet; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.wfset.attendance.manager.HrmAttProcActionManagerE9; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import weaver.common.StringUtil; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 保存考勤流程设置的 动作设置 + * @author pzy + * + */ +public class SaveStateProcSetFlowWfSetCmd extends AbstractCommonCommand>{ + + private HttpServletRequest request; + private HttpServletResponse response; + private SimpleBizLogger logger; + + public SaveStateProcSetFlowWfSetCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + public SaveStateProcSetFlowWfSetCmd(Map params, HttpServletRequest request,HttpServletResponse response,User user) { + this.user = user; + this.params = params; + this.request = request; + this.response = response; + HrmAttProcSetLogUtil hrmAttProcSetLogUtil = new HrmAttProcSetLogUtil(user,BizLogType.HRM_ENGINE, BizLogSmallType4Hrm.HRM_ENGINE_HRM_ATT_PROCSET, BizLogSmallType4Hrm.HRM_ENGINE_HRM_ATT_PROCSET); + String realLogSql = "select * from kq_ATT_PROC_ACTION"; + this.logger = hrmAttProcSetLogUtil.logStateSetLogSql(true, realLogSql, params,"action"); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + try { + if(!HrmUserVarify.checkUserRight("HrmAttendanceProcess:setting", user)){ + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + HrmAttProcActionManagerE9 attProcActionManager = new HrmAttProcActionManagerE9(); + String field001 = StringUtil.vString(params.get("field001")); + String field002 = StringUtil.vString(params.get("field002")); + + String result = attProcActionManager.save(request, response,field001,field002); + + if(result.length() == 0){ + retmap.put("status", "1"); + }else if("1".equalsIgnoreCase(result)){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(389757,user.getLanguage())); + }else if("2".equalsIgnoreCase(result)){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(389468,user.getLanguage())); + } + + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } +} diff --git a/src/com/engine/kq/cmd/importlog/GetHistorySearchConditionCmd.java b/src/com/engine/kq/cmd/importlog/GetHistorySearchConditionCmd.java new file mode 100644 index 0000000..74b0f09 --- /dev/null +++ b/src/com/engine/kq/cmd/importlog/GetHistorySearchConditionCmd.java @@ -0,0 +1,106 @@ +package com.engine.kq.cmd.importlog; + +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.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetHistorySearchConditionCmd extends AbstractCommonCommand> { + + public GetHistorySearchConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + List itemList = new ArrayList(); + try { + ConditionFactory conditionFactory = new ConditionFactory(user); + SearchConditionItem searchConditionItem = null; + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + + HrmFieldBean hrmFieldBean = null; + hrmFieldBean = new HrmFieldBean("operatorid", "17482", "3", "17"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setLabelcol(7); + searchConditionItem.setFieldcol(17); + itemList.add(searchConditionItem); + + searchConditionItem = conditionFactory.createCondition(ConditionType.DATE, 2061, "3", "2"); + searchConditionItem.setDomkey(new String[]{"dateSelect", "fromdate", "enddate"}); + List options = new ArrayList(); + options.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(332, user.getLanguage()), true)); + options.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(15537, user.getLanguage()))); + options.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(15539, user.getLanguage()))); + options.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(15541, user.getLanguage()))); + options.add(new SearchConditionOption("7", SystemEnv.getHtmlLabelName(27347, user.getLanguage()))); + options.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(21904, user.getLanguage()))); + options.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(15384, user.getLanguage()))); + options.add(new SearchConditionOption("8", SystemEnv.getHtmlLabelName(81716, user.getLanguage()))); + options.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(32530, user.getLanguage()))); + searchConditionItem.setOptions(options); + searchConditionItem.setLabelcol(7); + searchConditionItem.setFieldcol(17); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean("departmentid", "124", "3", "4"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setLabelcol(7); + searchConditionItem.setFieldcol(17); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean("subcompanyid", "141", "3", "164"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setLabelcol(7); + searchConditionItem.setFieldcol(17); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean("status", "602", "5", "1"); + options = new ArrayList(); + options.add(new SearchConditionOption("", SystemEnv.getHtmlLabelName(332, user.getLanguage()), true)); + options.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(15242, user.getLanguage()))); + options.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(498, user.getLanguage()))); + hrmFieldBean.setSelectOption(options); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setLabelcol(7); + searchConditionItem.setFieldcol(17); + itemList.add(searchConditionItem); + + List groupList = new ArrayList(); + Map groupItem = new HashMap(); + groupItem.put("title", ""); + groupItem.put("defaultshow", true); + groupItem.put("items", itemList); + groupList.add(groupItem); + + resultMap.put("status", "1"); + resultMap.put("searchCondition", groupList); + } catch (Exception e) { + writeLog(e); + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return resultMap; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/com/engine/kq/cmd/importlog/GetImportColResultLogCmd.java b/src/com/engine/kq/cmd/importlog/GetImportColResultLogCmd.java new file mode 100644 index 0000000..74acfa0 --- /dev/null +++ b/src/com/engine/kq/cmd/importlog/GetImportColResultLogCmd.java @@ -0,0 +1,117 @@ +package com.engine.kq.cmd.importlog; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * 获取导入日志 + */ +public class GetImportColResultLogCmd extends AbstractCommonCommand> { + + + protected User user; + + public GetImportColResultLogCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + return getImportSyslog(params, user); + } + + public Map getImportSyslog(Map params, User user) { + Map resultMap = new HashMap(); + try { + String importType = Util.null2String(params.get("importType")); + String pId = Util.null2String(params.get("pId")); + String fromdate = Util.null2String(params.get("fromdate")); + String enddate = Util.null2String(params.get("enddate")); + String operatorid = Util.null2String(params.get("operatorid")); + String departmentid = Util.null2String(params.get("departmentid")); + String subcompanyid = Util.null2String(params.get("subcompanyid")); + String dateSelect = Util.null2String(params.get("dateSelect")); + if (!dateSelect.equals("") && !dateSelect.equals("0") && !dateSelect.equals("6")) { + fromdate = TimeUtil.getDateByOption(dateSelect, "0"); + enddate = TimeUtil.getDateByOption(dateSelect, "1"); + } + if (!enddate.equals("")) { + enddate = TimeUtil.dateAdd(enddate, 1); + } + String status = Util.null2String(params.get("status")); + + String tabletype = "none"; + String backfields = " a.id,b.operator,b.operatetime,b.operatetype,b.importtype,b.clientaddress,a.relatedname,a.status,a.operatedetail "; + String sqlform = " hrmimporthistorydetail a, hrmimporthistory b, hrmresourceallview c "; + String sqlwhere = " a.pid=b.id and b.operator = c.id "; + + if (pId.length() > 0) { + sqlwhere += " and a.pid=" + pId; + } else { + sqlwhere += " and b.importtype = '" + importType + "'"; + } + + if (!fromdate.equals("")) { + sqlwhere += " and b.operatetime>='" + fromdate + "' and b.operatetime<='" + enddate + "' "; + } + if (!operatorid.equals("")) { + sqlwhere += " and b.operator in (" + operatorid + ") "; + } + if (user.getUID() != 1) { + sqlwhere += " and b.operator in (" + user.getUID() + ") "; + } + if (!departmentid.equals("")) { + sqlwhere += " and c.departmentid in (" + departmentid + ") "; + } + if (!subcompanyid.equals("")) { + sqlwhere += " and c.subcompanyid1 in (" + subcompanyid + ") "; + } + if (!status.equals("")) { + sqlwhere += " and a.status = " + status; + } + + String pageUid = "3e2f875a-65bf-422a-7d78-cf188a805afd"; + String tableString = "" + + "" + + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "" + + "
"; + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + resultMap.put("status", "1"); + resultMap.put("sessionkey", sessionkey); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return resultMap; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/com/engine/kq/cmd/importlog/GetImportHistoryCmd.java b/src/com/engine/kq/cmd/importlog/GetImportHistoryCmd.java new file mode 100644 index 0000000..3f21b02 --- /dev/null +++ b/src/com/engine/kq/cmd/importlog/GetImportHistoryCmd.java @@ -0,0 +1,74 @@ +package com.engine.kq.cmd.importlog; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.general.PageIdConst; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * 获取历史导入记录 + */ +public class GetImportHistoryCmd extends AbstractCommonCommand> { + + public GetImportHistoryCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @SuppressWarnings("unchecked") + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + String importType = Util.null2String(params.get("importType")); + + String sqlWhere = " where importtype = '" + importType + "' "; + if (user.getUID() != 1) { + sqlWhere += " and operator = " + user.getUID() + " "; + } + String tabletype = "none"; + String backfields = " a.*, (select count(1) from hrmimporthistorydetail where pid = a.id) as allnum , (select count(1) from hrmimporthistorydetail where pid = a.id and status = '1') as succnum "; + String sqlform = " hrmimporthistory a "; + String groupby = " "; + String pageUid = "d8d953d3-bbd6-b3b9-f283-45b70b91ea7b"; + String tableString = "" + + "" + + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + "" + + "
"; + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + resultMap.put("status", "1"); + resultMap.put("sessionkey", sessionkey); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + + return resultMap; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/com/engine/kq/cmd/importlog/GetImportProcessLogCmd.java b/src/com/engine/kq/cmd/importlog/GetImportProcessLogCmd.java new file mode 100644 index 0000000..03b7537 --- /dev/null +++ b/src/com/engine/kq/cmd/importlog/GetImportProcessLogCmd.java @@ -0,0 +1,102 @@ +package com.engine.kq.cmd.importlog; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * + */ +public class GetImportProcessLogCmd extends AbstractCommonCommand> { + + protected HttpServletRequest request; + + public GetImportProcessLogCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + public GetImportProcessLogCmd(Map params, HttpServletRequest request, User user) { + this.request = request; + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + return getImportMessage(params, request, user); + } + + @SuppressWarnings("unchecked") + public Map getImportMessage(Map params, HttpServletRequest request, User user) { + Map resultMap = new HashMap(); + Map dataMap = new HashMap(); + List dataList = new ArrayList(); + int logId = Util.getIntValue((String)params.get("index"), 0); + String importType = Util.null2String(params.get("importType")); + String pIdName = "hrm" + importType + "PId"; + String pId = Util.null2String(this.request.getSession(true).getAttribute(pIdName)).trim(); + try { + String importStatus = ""; + String sql = ""; + RecordSet rs = new RecordSet(); + + int index = logId; + if (pId.length() > 0) { + sql = "select * from hrmimporthistory where id= " + pId; + rs.executeSql(sql); + if (rs.next()) { + importStatus = rs.getString("status"); + } + + if ("importing".equals(importStatus) || "over".equals(importStatus)) { + sql = "select * from hrmimporthistorydetail where pid = " + pId; + if (logId > 0) { + sql += " and id> " + logId; + } + rs.executeSql(sql); + while (rs.next()) { + index = rs.getInt("id"); + dataMap = new HashMap(); + dataMap.put("rownum", rs.getInt("rownums")); + dataMap.put("status", rs.getString("status")); + dataMap.put("message", rs.getString("operateDetail")); + dataList.add(dataMap); + } + if ("over".equals(importStatus)) { + this.request.getSession(true).removeAttribute(pIdName); + } + } + } + + resultMap.put("status", "1"); + resultMap.put("index", index); + resultMap.put("pId", pId); + resultMap.put("importStatus", importStatus); + resultMap.put("datas", dataList); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return resultMap; + } + + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/com/engine/kq/cmd/importlog/GetImportResultCmd.java b/src/com/engine/kq/cmd/importlog/GetImportResultCmd.java new file mode 100644 index 0000000..54d3a96 --- /dev/null +++ b/src/com/engine/kq/cmd/importlog/GetImportResultCmd.java @@ -0,0 +1,87 @@ +package com.engine.kq.cmd.importlog; + +import com.api.hrm.util.PageUidFactory; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * 获取导入结果 + */ +public class GetImportResultCmd extends AbstractCommonCommand> { + + public GetImportResultCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + + try { + String pId = Util.null2String(params.get("pId")); + Map dataMap = new HashMap(); + int failnum = 0;//失败的数量 + int succnum = 0;//成功的数量 + RecordSet rs = new RecordSet(); + rs.executeSql("select status,count(status) from hrmimporthistorydetail where pid =" + pId + " group by status "); + while (rs.next()) { + int status = rs.getInt("status"); + int rowCount = rs.getInt(2); + if (status == 1) { + succnum = rowCount; + } else { + failnum = rowCount; + } + } + + dataMap.put("succnum", succnum); + dataMap.put("failnum", failnum); + if (failnum > 0) { + String sqlwhere = " where pid =" + pId + " and status = '0' "; + String tabletype = "none"; + String backfields = " * "; + String sqlform = "hrmimporthistorydetail"; + String groupby = " "; + String pageUid = "34d997a0-55bf-4221-a303-2cca5917436e"; + String tableString = "" + + "" + + "" + + "" + + " " + + " " + + "" + + "
"; + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + dataMap.put("sessionkey", sessionkey); + } + + resultMap.put("status", "1"); + resultMap.put("datas", dataMap); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + + return resultMap; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/com/engine/kq/cmd/importlog/SaveImportDeitalLogCmd.java b/src/com/engine/kq/cmd/importlog/SaveImportDeitalLogCmd.java new file mode 100644 index 0000000..e1f7741 --- /dev/null +++ b/src/com/engine/kq/cmd/importlog/SaveImportDeitalLogCmd.java @@ -0,0 +1,49 @@ +package com.engine.kq.cmd.importlog; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +public class SaveImportDeitalLogCmd extends AbstractCommonCommand>{ + + public SaveImportDeitalLogCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String sql = ""; + RecordSet rs = new RecordSet(); + try { + String pId = Util.null2String(this.params.get("pId")); + String lineNum = Util.null2String(this.params.get("lineNum")); + String relatedName = Util.null2String(this.params.get("relatedName")); + String msg = Util.null2String(this.params.get("msg")); + String status = Util.null2String(this.params.get("status")); + sql = " insert into hrmimporthistoryDetail (pid,rownums,relatedName,operateDetail,status)" + + " values("+pId+","+lineNum+",'"+relatedName+"','"+msg+"','"+status+"') "; + rs.executeSql(sql); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/com/engine/kq/cmd/importlog/SaveImportLogCmd.java b/src/com/engine/kq/cmd/importlog/SaveImportLogCmd.java new file mode 100644 index 0000000..3e25f3b --- /dev/null +++ b/src/com/engine/kq/cmd/importlog/SaveImportLogCmd.java @@ -0,0 +1,57 @@ +package com.engine.kq.cmd.importlog; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; + +public class SaveImportLogCmd extends AbstractCommonCommand>{ + + HttpServletRequest request; + + public SaveImportLogCmd(Map params, HttpServletRequest request, User user) { + this.user = user; + this.params = params; + this.request = request; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String sql = ""; + RecordSet rs = new RecordSet(); + try { + String importType = Util.null2String(params.get("importType")); + String operateType = Util.null2String(params.get("operateType")); + + sql = " insert into hrmimporthistory (operator,operatetime,operatetype,importtype,sourcefrom,clientaddress,status) " + + " values("+this.user.getUID()+",'"+DateUtil.getFullDate()+"','"+operateType+"','"+importType+"','excel','"+Util.getIpAddr(request)+"','importing')"; + rs.executeSql(sql); + + rs.executeSql(" select max(id) from hrmimporthistory "); + if(rs.next()) { + retmap.put("pId", rs.getInt(1)); + } + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/com/engine/kq/cmd/importlog/SaveImportLogStatusCmd.java b/src/com/engine/kq/cmd/importlog/SaveImportLogStatusCmd.java new file mode 100644 index 0000000..77e8c20 --- /dev/null +++ b/src/com/engine/kq/cmd/importlog/SaveImportLogStatusCmd.java @@ -0,0 +1,47 @@ +package com.engine.kq.cmd.importlog; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +public class SaveImportLogStatusCmd extends AbstractCommonCommand>{ + + + public SaveImportLogStatusCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String sql = ""; + RecordSet rs = new RecordSet(); + try { + String pId = Util.null2String(params.get("pId")); + String status = Util.null2String(params.get("status")); + sql = " update hrmimporthistory set status ='"+status+"' where id="+pId; + rs.executeSql(sql); + + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/com/engine/kq/cmd/leaveParentalrules/GetLeaveRulesFormCmd.java b/src/com/engine/kq/cmd/leaveParentalrules/GetLeaveRulesFormCmd.java new file mode 100644 index 0000000..be1a7a5 --- /dev/null +++ b/src/com/engine/kq/cmd/leaveParentalrules/GetLeaveRulesFormCmd.java @@ -0,0 +1,209 @@ +package com.engine.kq.cmd.leaveParentalrules; + +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.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.province.ProvinceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 假期规则--获取新建编辑的表单 + */ +public class GetLeaveRulesFormCmd extends AbstractCommonCommand> { + + public GetLeaveRulesFormCmd(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(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + /**假期类型的相关信息:*/ + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + + /*新建假期规则时选择完请假类型后会再次请求此表单接口*/ + /*规则对应的假期类型的ID*/ + String ruleId = Util.null2String(params.get("typeId")); + + /*是否启用:0-未启用、1-启用*/ + int isEnable = 1; + + /*最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假*/ + int minimumUnit = 1; + + /******************************************************************************/ + + /**假期规则详情的相关信息:*/ + + /*是否是编辑*/ + boolean isEdit = false; + + /*假期规则详情的ID*/ + String ruleDetailId = Util.null2String(params.get("ruleId")); + String id = Util.null2String(params.get("id")); + /*假期规则名称*/ + String ruleName = ""; + + + int provinceid = 0;//省份id + int yearsOld = 0;//孩子周岁 + double amount = 0;//假期天数 + + + List> replaceDatas = new ArrayList>(); + Map datas = new HashMap(); + + if (!id.equals("")) { + String sql = "select * from kq_provinceToLeave where id=" + id; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + isEdit = true; + id = recordSet.getString("id"); + provinceid = recordSet.getInt("provinceid"); + yearsOld = recordSet.getInt("yearsOld"); + amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + } + } + String provincename = ""; + if (provinceid > 0) { + ProvinceComInfo coun = new ProvinceComInfo(); + provincename = coun.getProvincename(provinceid + ""); + datas.put("id", provinceid); + datas.put("name", provincename); + replaceDatas.add(datas); + } + String[] fields = new String[]{"provinceid,800,3,2222", "yearsOld,546831,1,2", "amount,503237,1,2"}; + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + Map retmap = new HashMap(); + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + itemlist = new ArrayList(); + groupitem = new HashMap(); + if (isEdit) { + groupitem.put("title", SystemEnv.getHtmlLabelName(84552, weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + groupitem.put("title", SystemEnv.getHtmlLabelName(84551, weaver.general.Util.getIntValue(user.getLanguage()))); + } + groupitem.put("defaultshow", true); + for (int i = 0; i < fields.length; i++) { + String[] fieldinfo = fields[i].split(","); + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(fieldinfo[0]); + hrmFieldBean.setFieldlabel(fieldinfo[1]); + hrmFieldBean.setFieldhtmltype(fieldinfo[2]); + hrmFieldBean.setType(fieldinfo[3]); + if (fieldinfo[0].equals("provinceid")) { + hrmFieldBean.setFieldvalue(provinceid); + } else if (fieldinfo[0].equals("yearsOld")) { + hrmFieldBean.setFieldvalue(yearsOld); + } else if (fieldinfo[0].equals("amount")) { + hrmFieldBean.setFieldvalue(amount); + minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(ruleId), 1); + String unitName = "";//单位名称,天/小时 + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) { + unitName = "547751"; + } else { + unitName = "546840"; + } + writeLog("GetLeaveRulesFormCmd>ruleId="+ruleId+";name="+SystemEnv.getHtmlLabelNames(unitName, user.getLanguage())); + hrmFieldBean.setFieldlabel(unitName); + } + + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); +// if (fieldinfo[0].equals("provinceid") && provinceid>0) { +// searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas); +// } + searchConditionItem.setViewAttr(3); + if (hrmFieldBean.getFieldname().equals("provinceid")) { + List list = new ArrayList(); + String value = provinceid + ""; + + char flag = 2; + String sql = "select * from HrmProvince where (canceled is null or canceled != 1) "; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + int tmpselectvalue = recordSet.getInt("id"); + String tmpselectname = recordSet.getString("provincename"); + + SearchConditionOption options = new SearchConditionOption(); + options.setKey(tmpselectvalue + ""); + options.setShowname(tmpselectname); + if (value.indexOf(",") > -1) { + String[] SelecV = value.split(","); + for (String v : SelecV) { + if ((tmpselectvalue + "").equals(v)) { + options.setSelected(true); + } + } + } else { + options.setSelected((tmpselectvalue + "").equals(value)); + } + list.add(options); + } + ConditionFactory conditionFactory = new ConditionFactory(user); + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("multiple", true); + searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, "800", "multiselectprovinceValue", list); + searchConditionItem.setMultiple(true); + searchConditionItem.setMultiSelection(true); + searchConditionItem.setRules("required|string"); + searchConditionItem.setOtherParams(OtherParamsMap); + + } + if (hrmFieldBean.getFieldname().equals("yearsOld")) { + searchConditionItem.setRules("required|integer"); + searchConditionItem.setMin("0"); + } + if ( hrmFieldBean.getFieldname().equals("amount")) { + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("0"); + } + itemlist.add(searchConditionItem); + } + + groupitem.put("items", itemlist); + lsGroup.add(groupitem); + retmap.put("condition", lsGroup); + return retmap; + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leaverules/AddLeaveRulesCmd.java b/src/com/engine/kq/cmd/leaverules/AddLeaveRulesCmd.java new file mode 100644 index 0000000..99630de --- /dev/null +++ b/src/com/engine/kq/cmd/leaverules/AddLeaveRulesCmd.java @@ -0,0 +1,465 @@ +package com.engine.kq.cmd.leaverules; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesDetailComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 假期规则--新建 + */ +public class AddLeaveRulesCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public AddLeaveRulesCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String ruleId = Util.null2String(params.get("typeId")); + String ruleName = Util.null2String(params.get("ruleName")); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%'"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("rulename"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_EntryToLeave where leaveRulesId in (select id from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%')"; + subLogInfo1.setSubSql(subSql1, "id"); + logger.addSubLogInfo(subLogInfo1); + + SimpleBizLogger.SubLogInfo subLogInfo2 = logger.getNewSubLogInfo(); + String subSql2 = "select * from kq_WorkingAgeToLeave where leaveRulesId in (select id from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%')"; + subLogInfo2.setSubSql(subSql2, "id"); + logger.addSubLogInfo(subLogInfo2); + + SimpleBizLogger.SubLogInfo subLogInfo3 = logger.getNewSubLogInfo(); + String subSql3 = "select * from kq_MixModeToLegalLeave where leaveRulesId in (select id from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%')"; + subLogInfo3.setSubSql(subSql3, "id"); + logger.addSubLogInfo(subLogInfo3); + + SimpleBizLogger.SubLogInfo subLogInfo4 = logger.getNewSubLogInfo(); + String subSql4 = "select * from kq_MixModeToWelfareLeave where leaveRulesId in (select id from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%')"; + subLogInfo4.setSubSql(subSql4, "id"); + logger.addSubLogInfo(subLogInfo4); + + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canAdd = HrmUserVarify.checkUserRight("KQLeaveRulesAdd:Add", user);//是否具有新建权限 + if (!canAdd) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));//没有权限 + return resultMap; + } + + /*假期规则对应的假期类型的ID*/ + String ruleId = Util.null2String(params.get("typeId")); + + /*假期规则名称*/ + String ruleName = Util.null2String(params.get("ruleName")); + + /*应用范围:0-总部、1-分部*/ + int scopeType = Util.getIntValue((String) params.get("scopeType")); + + /*应用范围为分部时,选择的分部ID*/ + String scopeValue = Util.null2String(params.get("scopeValue")); + String deductorder = Util.null2String(params.get("deductorder")); + + /*应用范围为部门时,选择的部门ID*/ + String scopeValueDepartment = Util.null2String(params.get("scopeValueDepartment")); + + /*应用范围为人员时,选择的人员ID*/ + String scopeValueMember = Util.null2String(params.get("scopeValueMember")); + + if(scopeType == 2) { + scopeValue = scopeValueDepartment; + } else if(scopeType == 3) { + scopeValue = scopeValueMember; + } + + /*余额发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按司龄+工龄自动发放*/ + int distributionMode = Util.getIntValue((String) params.get("distributionMode"), 1); + + /*每人发放小时(天)数(当余额发放方式为每年自动发放固定天数时有效)*/ + double annualAmount = Util.getDoubleValue((String) params.get("annualAmount"), 0); + + //法定年假规则:0-工龄、1-司龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效) + String legalKey = Util.null2s((String) params.get("legalKey"), "0"); + + //福利年假规则:0-工龄、1-工龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效) + String welfareKey = Util.null2s((String) params.get("welfareKey"), "1"); + + /*扣减优先级:1-法定年假、2-福利年假*/ + int priority = Util.getIntValue((String) params.get("priority"), 1); + + /*有效期规则:0-不限制、1-按自然月(1月1日-12月31日)、2-按入职日期起12个月、3-自定义次年失效日期、4-自定义有效天数*/ + int validityRule = Util.getIntValue((String) params.get("validityRule"), 1); + + /*有效期天数:(当有效期天数选择按天数失效的时候有效)*/ + int effectiveDays = Util.getIntValue((String) params.get("effectiveDays"), 30); + + //有效月数(当有效期规则选择自定义有效月数时) + int effectiveMonths = Util.getIntValue((String) params.get("effectiveMonths"), 1); + + /*失效日期--月(当有效期规则选择3-自定义次年失效日期时有效)*/ + String expirationMonth = Util.null2String(params.get("expirationMonth")); + + /*失效日期--日(当有效期规则选择3-自定义次年失效日期时有效)*/ + String expirationDay = Util.null2String(params.get("expirationDay")); + + /*允许延长有效期:0-不允许、1-允许*/ + int extensionEnable = Util.getIntValue((String) params.get("extensionEnable"), 0); + + if(validityRule==4 || validityRule==6){ + extensionEnable = 0; + } + + /*允许超过有效期天数*/ + int extendedDays = Util.getIntValue((String) params.get("extendedDays"), 0); + + /*释放规则:0-不限制、1-按天释放、2-按月释放*/ + int releaseRule = Util.getIntValue((String) params.get("releaseRule"), 0); + + /*假期基数计算方式:0-精确计算、1-按最少的假期余额计算、2-按最多的假期余额计算*/ + int calcMethod = Util.getIntValue((String) params.get("calcMethod"), 0); + + /*是否折算:0-不折算、1-四舍五入、2-向上取整、3-向下取整、4-向上取0.5的倍数、5-向下取0.5的倍数*/ + int convertMode = Util.getIntValue("" + params.get("convertMode"), 1); + + /*次账号是否发放假期余额:0-不发放、1-发放*/ + int excludeSubAccount = Util.getIntValue("" + params.get("excludeSubAccount"), 1); + + //多孩叠加开关。 + int severalChildren = Util.getIntValue("" + params.get("severalChildren"), 0); + + //孩子多少周岁前发放。 + int yearsOld = Util.getIntValue("" + params.get("yearsOld"), 3); + + //是否按照省份发放育儿假。 + int isprovince = Util.getIntValue("" + params.get("isprovince"), 1); + +// 2、在假期规则页面,增加开关控制是否开启。carryOver +// 3、增加输入框控制结转天数。 carryOverDays + int carryOver = Util.getIntValue("" + params.get("carryOver"), 0); + double carryOverDays = Util.getDoubleValue((String) params.get("carryOverDays"), 0); + + /*转正之前是否发放假期余额:0-不发放、1-发放*/ + int beforeFormal = Util.getIntValue("" + params.get("beforeFormal"), 1); + + if (scopeType != 0 && scopeValue.equals("")) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));//参数有误 + return resultMap; + } + /*两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式*/ + if (distributionMode == 5) { + releaseRule = 0; + Map data = KQLeaveRulesBiz.isRepeat(ruleId,scopeType,scopeValue,user,""); + if(null != data && "1".equals(data.get("flag"))){ + resultMap.put("status", "-1"); + resultMap.put("message", data.get("msg"));//两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式 + return resultMap; + } +// String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id<>? and id in (select ruleId from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=5)"; +// RecordSet recordSet = new RecordSet(); +// recordSet.executeQuery(sql, ruleId); +// if (recordSet.next()) { +// resultMap.put("status", "-1"); +// resultMap.put("message", SystemEnv.getHtmlLabelName(505664, user.getLanguage()));//两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式 +// return resultMap; +// } + if(null != deductorder && deductorder.length()>0){ + String[] orders = deductorder.split(","); + if(null != orders && orders.length != 3){ + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(547752, user.getLanguage())); + return resultMap; + } + } + } else if (distributionMode == 6) { + /*同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存*/ + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode<>6"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505665, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存 + return resultMap; + } + } else if (distributionMode == 8) { + /*同一假期类型下 育儿假 不能与其他余额发放方式共存*/ + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode<>8"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546858, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存 + return resultMap; + } + sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=8"; + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + int severalChildrenValue = Util.getIntValue(Util.null2s(recordSet.getString("severalChildren"), "0"), 0); + if(severalChildrenValue!=severalChildren){ + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546859, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存 + return resultMap; + } + } + } else { + /*同一个假期类型下其他余额发放方式不能与 按司龄+工龄自动发放 共存*/ + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=6"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505666, user.getLanguage()));//同一个假期类型下其他余额发放方式不能与 按司龄+工龄自动发放 共存 + return resultMap; + } + + //同一个假期类型下其他余额发放方式不能与 加班时长自动计入余额 共存 + sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=5"; + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(510357, user.getLanguage()));//同一个假期类型下其他余额发放方式不能与 加班时长自动计入余额 共存 + return resultMap; + } + //同一个假期类型下其他余额发放方式不能与 育儿假叠加 共存 + sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=8"; + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546858, user.getLanguage())); + return resultMap; + } + } + + String searchSql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(searchSql, ruleId); + while (recordSet.next()) { + int scopeTypeTemp = Util.getIntValue(recordSet.getString("scopeType"), 0); + String scopeValueTemp = recordSet.getString("scopeValue"); + + if (scopeType == 0 && scopeTypeTemp == 0) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505667, user.getLanguage()));//该假期类型下已经新建过总部的假期规则,请勿重复新建 + return resultMap; + } + if (scopeType == 1 && scopeTypeTemp == 1) { + List scopeValueTempList = Util.TokenizerString(scopeValueTemp, ","); + List scopeValueList = Util.TokenizerString(scopeValue, ","); + for (String temp : scopeValueList) + if (scopeValueTempList.contains(temp)) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + String subcomName = subCompanyComInfo.getSubCompanyname(temp); + + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505668, user.getLanguage()).replace("$", subcomName));//该假期类型下已经新建过分部的假期规则,请勿重复新建 + return resultMap; + } + } + if (scopeType == 2 && scopeTypeTemp == 2) { + List scopeValueTempList = Util.TokenizerString(scopeValueTemp, ","); + List scopeValueList = Util.TokenizerString(scopeValue, ","); + for (String temp : scopeValueList) + if (scopeValueTempList.contains(temp)) { + DepartmentComInfo comInfo = new DepartmentComInfo(); + String name = comInfo.getDepartmentname(temp); + + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(534890, user.getLanguage()).replace("$", name));//该假期类型下已经新建过部门的假期规则,请勿重复新建 + return resultMap; + } + } + if (scopeType == 3 && scopeTypeTemp == 3) { + List scopeValueTempList = Util.TokenizerString(scopeValueTemp, ","); + List scopeValueList = Util.TokenizerString(scopeValue, ","); + for (String temp : scopeValueList) + if (scopeValueTempList.contains(temp)) { + ResourceComInfo comInfo = new ResourceComInfo(); + String name = comInfo.getLastname(temp); + + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(534891, user.getLanguage()).replace("$", name));//该假期类型下已经新建过人员的假期规则,请勿重复新建 + return resultMap; + } + } + } + boolean flag = false;//数据是否插入成功 + String sql = "insert into kq_LeaveRulesDetail(ruleId,ruleName,scopeType,scopeValue," + + "distributionMode,annualAmount,legalKey,welfareKey,priority,validityRule,effectiveDays,effectiveMonths,expirationMonth,expirationDay,extensionEnable,extendedDays,releaseRule,calcMethod,convertMode,excludeSubAccount,beforeFormal,severalChildren,yearsOld,isprovince,carryOver,carryOverDays,deductorder,isDelete) values(?,?,?,?, ?,?,?,?, ?,?,?,?, ?,?,?,?, ?,?,?,?, ?,?,?,?,?,?,?,0)"; + flag = recordSet.executeUpdate(sql, ruleId, ruleName, scopeType, scopeValue, + distributionMode, annualAmount, legalKey, welfareKey, priority, validityRule, effectiveDays, effectiveMonths, expirationMonth, expirationDay, extensionEnable, extendedDays, releaseRule, calcMethod, convertMode, excludeSubAccount, beforeFormal,severalChildren,yearsOld,isprovince,carryOver,carryOverDays,deductorder); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + + /*获取刚才插入的假期规则详情的ID*/ + int ruleDetailId = 0; + sql = "select max(id) maxId from kq_LeaveRulesDetail"; + recordSet.executeQuery(sql); + if (recordSet.next()) { + ruleDetailId = Util.getIntValue(recordSet.getString("maxId"), 0); + } + + if ((distributionMode == 2 || distributionMode == 7) && ruleDetailId != 0) { + int lowerLimit = 0;//司龄下限 + int upperLimit = 0;//司龄上限 + String data = Util.null2String(params.get("detailRule")); + JSONArray jsonArray = JSONArray.parseArray(data); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int timePoint = jsonObject.getIntValue("timePoint"); + double amount = jsonObject.getDoubleValue("amount"); + + lowerLimit = i == 0 ? 0 : timePoint; + upperLimit = i == jsonArray.size() - 1 ? 9999 : jsonArray.getJSONObject(i + 1).getIntValue("timePoint"); + + sql = "insert into kq_EntryToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, lowerLimit, upperLimit, amount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (distributionMode == 3 && ruleDetailId != 0) { + int lowerLimit = 0;//工龄下限 + int upperLimit = 0;//工龄上限 + String data = Util.null2String(params.get("detailRule")); + JSONArray jsonArray = JSONArray.parseArray(data); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int timePoint = jsonObject.getIntValue("timePoint"); + double amount = jsonObject.getDoubleValue("amount"); + + lowerLimit = i == 0 ? 0 : timePoint; + upperLimit = i == jsonArray.size() - 1 ? 9999 : jsonArray.getJSONObject(i + 1).getIntValue("timePoint"); + + sql = "insert into kq_WorkingAgeToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, lowerLimit, upperLimit, amount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (distributionMode == 6 && ruleDetailId != 0) { + String mixModeData = Util.null2String(params.get("legalRule")); + JSONArray jsonArray = JSONArray.parseArray(mixModeData); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int workYear = jsonObject.getIntValue("workYear"); + int entryTime = jsonObject.getIntValue("entryTime"); + double legalAmount = jsonObject.getDoubleValue("legalAmount"); + + sql = "insert into kq_MixModeToLegalLeave(leaveRulesId,limit1,limit2,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, workYear, entryTime, legalAmount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + + mixModeData = Util.null2String(params.get("welfareRule")); + jsonArray = JSONArray.parseArray(mixModeData); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int workYear = jsonObject.getIntValue("workYear"); + int entryTime = jsonObject.getIntValue("entryTime"); + double welfareAmount = jsonObject.getDoubleValue("welfareAmount"); + + sql = "insert into kq_MixModeToWelfareLeave(leaveRulesId,limit1,limit2,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, workYear, entryTime, welfareAmount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (distributionMode == 8 && ruleDetailId != 0) { + int provinceidValue = 0;//省份id + int yearsOldValue = 0;//孩子周岁 + double amountValue = 0;//假期天数 + String data = Util.null2String(params.get("detailRule")); + JSONArray jsonArray = JSONArray.parseArray(data); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + provinceidValue = jsonObject.getIntValue("provinceid"); + yearsOldValue = jsonObject.getIntValue("yearsOld"); + amountValue = jsonObject.getDoubleValue("amount"); + + sql = "insert into kq_provinceToLeave(leaveRulesId,provinceid,yearsOld,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, provinceidValue, yearsOldValue, amountValue); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } + } catch (Exception e) { + writeLog(e); + } finally { + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + detailComInfo.removeCache(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leaverules/DeleteLeaveRulesCmd.java b/src/com/engine/kq/cmd/leaverules/DeleteLeaveRulesCmd.java new file mode 100644 index 0000000..fd72f52 --- /dev/null +++ b/src/com/engine/kq/cmd/leaverules/DeleteLeaveRulesCmd.java @@ -0,0 +1,95 @@ +package com.engine.kq.cmd.leaverules; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQLeaveRulesDetailComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 假期规则--删除 + */ +public class DeleteLeaveRulesCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public DeleteLeaveRulesCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String ruleDetailIds = Util.null2String(params.get("ruleIds"));//需要删除的ID + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_leaveRulesDetail where (isDelete is null or isDelete<>1) and id in ("+ruleDetailIds+")"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("rulename"); + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + String ruleDetailIds = Util.null2String(params.get("ruleIds"));//需要删除的ID + try { + boolean canDelete = HrmUserVarify.checkUserRight("KQLeaveRulesDelete:Delete", user);//是否具有删除的权限 + if (!canDelete) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + if (ruleDetailIds.equals("")) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));//参数有误 + return resultMap; + } + + boolean flag = false; + String sql = "update kq_LeaveRulesDetail set isDelete=1 where id in (" + ruleDetailIds + ")"; + RecordSet recordSet = new RecordSet(); + flag = recordSet.executeUpdate(sql); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(20461, user.getLanguage()));//删除成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(20462, user.getLanguage()));//删除失败 + } + } catch (Exception e) { + writeLog(e); + } finally { + /*刷新缓存*/ + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + detailComInfo.removeCache(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leaverules/EditLeaveRulesCmd.java b/src/com/engine/kq/cmd/leaverules/EditLeaveRulesCmd.java new file mode 100644 index 0000000..8b255ca --- /dev/null +++ b/src/com/engine/kq/cmd/leaverules/EditLeaveRulesCmd.java @@ -0,0 +1,496 @@ +package com.engine.kq.cmd.leaverules; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesDetailComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * 假期规则--编辑 + */ +public class EditLeaveRulesCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public EditLeaveRulesCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + int ruleDetailId = Util.getIntValue((String) params.get("ruleId")); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_LeaveRulesDetail where id=" + ruleDetailId; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("rulename"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_EntryToLeave where leaveRulesId=" + ruleDetailId; + subLogInfo1.setSubSql(subSql1, "id"); + logger.addSubLogInfo(subLogInfo1); + + SimpleBizLogger.SubLogInfo subLogInfo2 = logger.getNewSubLogInfo(); + String subSql2 = "select * from kq_WorkingAgeToLeave where leaveRulesId=" + ruleDetailId; + subLogInfo2.setSubSql(subSql2, "id"); + logger.addSubLogInfo(subLogInfo2); + + SimpleBizLogger.SubLogInfo subLogInfo3 = logger.getNewSubLogInfo(); + String subSql3 = "select * from kq_MixModeToLegalLeave where leaveRulesId=" + ruleDetailId; + subLogInfo3.setSubSql(subSql3, "id"); + logger.addSubLogInfo(subLogInfo3); + + SimpleBizLogger.SubLogInfo subLogInfo4 = logger.getNewSubLogInfo(); + String subSql4 = "select * from kq_MixModeToLegalLeave where leaveRulesId=" + ruleDetailId; + subLogInfo4.setSubSql(subSql4, "id"); + logger.addSubLogInfo(subLogInfo4); + + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有新建权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + /*假期类型的ID*/ + int ruleId = Util.getIntValue((String) params.get("typeId")); + + /*假期规则详情的ID*/ + int ruleDetailId = Util.getIntValue((String) params.get("ruleId")); + + /*假期规则名称*/ + String ruleName = Util.null2String(params.get("ruleName")); + + /*应用范围:0-总部、1-分部*/ + int scopeType = Util.getIntValue((String) params.get("scopeType")); + + /*应用范围为分部时,选择的分部ID*/ + String scopeValue = Util.null2String(params.get("scopeValue")); + String deductorder = Util.null2String(params.get("deductorder")); + + /*应用范围为部门时,选择的部门ID*/ + String scopeValueDepartment = Util.null2String(params.get("scopeValueDepartment")); + + /*应用范围为人员时,选择的人员ID*/ + String scopeValueMember = Util.null2String(params.get("scopeValueMember")); + + if(scopeType == 2) { + scopeValue = scopeValueDepartment; + } else if(scopeType == 3) { + scopeValue = scopeValueMember; + } + + /*余额发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、 5-加班时长自动计入余额*/ + int distributionMode = Util.getIntValue((String) params.get("distributionMode"), 1); + + /*每人发放小时(天)数(当余额发放方式为每年自动发放固定天数时有效)*/ + double annualAmount = Util.getDoubleValue((String) params.get("annualAmount"), 0); + + /*扣减优先级:1-法定年假、2-福利年假*/ + int priority = Util.getIntValue((String) params.get("priority"), 1); + + //法定年假规则:0-工龄、1-司龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效) + String legalKey = Util.null2s((String) params.get("legalKey"), "0"); + + //福利年假规则:0-工龄、1-工龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效) + String welfareKey = Util.null2s((String) params.get("welfareKey"), "1"); + + /*有效期规则:0-不限制、1-按自然月(1月1日-12月31日)、2-按入职日期起12个月、3-自定义次年失效日期、4-自定义有效天数*/ + int validityRule = Util.getIntValue((String) params.get("validityRule"), 1); + + /*有效期天数:(当有效期天数选择按天数失效的时候有效)*/ + int effectiveDays = Util.getIntValue((String) params.get("effectiveDays"), 30); + + //有效月数(当有效期规则选择自定义有效月数时) + int effectiveMonths = Util.getIntValue((String) params.get("effectiveMonths"), 1); + + /*失效日期--月(当有效期规则选择3-自定义次年失效日期时有效)*/ + String expirationMonth = Util.null2String(params.get("expirationMonth")); + + /*失效日期--日(当有效期规则选择3-自定义次年失效日期时有效)*/ + String expirationDay = Util.null2String(params.get("expirationDay")); + + /*允许延长有效期:0-不允许、1-允许*/ + int extensionEnable = Util.getIntValue((String) params.get("extensionEnable"), 0); + + if(validityRule==4 || validityRule==6){ + extensionEnable = 0; + } + + /*允许超过有效期天数*/ + int extendedDays = Util.getIntValue((String) params.get("extendedDays"), 0); + + /*释放规则:0-不限制、1-按天释放、2-按月释放*/ + int releaseRule = Util.getIntValue((String) params.get("releaseRule"), 0); + + /*假期基数计算方式:0-精确计算、1-按最少的假期余额计算、2-按最多的假期余额计算*/ + int calcMethod = Util.getIntValue((String) params.get("calcMethod"), 0); + + /*是否折算:0-不折算、1-四舍五入、2-向上取整、3-向下取整、4-向上取0.5的倍数、5-向下取0.5的倍数*/ + int convertMode = Util.getIntValue("" + params.get("convertMode"), 1); + + /*次账号是否发放假期余额:0-不发放、1-发放*/ + int excludeSubAccount = Util.getIntValue("" + params.get("excludeSubAccount"), 1); + + /*转正之前是否发放假期余额:0-不发放、1-发放*/ + int beforeFormal = Util.getIntValue("" + params.get("beforeFormal"), 1); + + //多孩叠加开关。 + int severalChildren = Util.getIntValue("" + params.get("severalChildren"), 0); + + //孩子多少周岁前发放。 + int yearsOld = Util.getIntValue("" + params.get("yearsOld"), 3); + + //是否按照省份发放育儿假。 + int isprovince = Util.getIntValue("" + params.get("isprovince"), 1); +// 2、在假期规则页面,增加开关控制是否开启。carryOver +// 3、增加输入框控制结转天数。 carryOverDays + + int carryOver = Util.getIntValue("" + params.get("carryOver"), 0); + double carryOverDays = Util.getDoubleValue((String) params.get("carryOverDays"), 0); + if (scopeType == 1 && scopeValue.equals("")) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));//参数有误 + return resultMap; + } + if (distributionMode == 5) { + releaseRule = 0; + Map data = KQLeaveRulesBiz.isRepeat(Util.null2String(ruleId),scopeType,scopeValue,user,Util.null2String(ruleDetailId)); + if(null != data && "1".equals(data.get("flag"))){ + resultMap.put("status", "-1"); + resultMap.put("message", data.get("msg"));//两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式 + return resultMap; + } + /*两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式*/ +// String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id<>? and id in (select ruleId from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=5)"; +// RecordSet recordSet = new RecordSet(); +// recordSet.executeQuery(sql, ruleId); +// if (recordSet.next()) { +// resultMap.put("status", "-1"); +// resultMap.put("message", SystemEnv.getHtmlLabelName(505664, user.getLanguage()));//两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式 +// return resultMap; +// } + if(null != deductorder && deductorder.length()>0){ + String[] orders = deductorder.split(","); + if(null != orders && orders.length != 3){ + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(547752, user.getLanguage())); + return resultMap; + } + } + } else if (distributionMode == 6) { + /*同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存*/ + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode<>6"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505665, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存 + return resultMap; + } + }else if (distributionMode == 8) { + /*同一假期类型下 育儿假 不能与其他余额发放方式共存*/ + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode<>8"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546858, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存 + return resultMap; + } + sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=8 and id<>?"; + recordSet.executeQuery(sql, ruleId,ruleDetailId); + if (recordSet.next()) { + int severalChildrenValue = Util.getIntValue(Util.null2s(recordSet.getString("severalChildren"), "0"), 0); + if(severalChildrenValue!=severalChildren){ + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546859, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存 + return resultMap; + } + } + } else { + /*同一个假期类型下其他余额发放方式不能与 按司龄+工龄自动发放 共存*/ + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=6"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505666, user.getLanguage()));//同一个假期类型下其他余额发放方式不能与 按司龄+工龄自动发放 共存 + return resultMap; + } + + //同一个假期类型下其他余额发放方式不能与 加班时长自动计入余额 共存 + sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=5"; + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(510357, user.getLanguage()));//同一个假期类型下其他余额发放方式不能与 加班时长自动计入余额 共存 + return resultMap; + } + //同一个假期类型下其他余额发放方式不能与 育儿假叠加 共存 + sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=8"; + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546858, user.getLanguage())); + return resultMap; + } + } + + String searchSql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and id<>?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(searchSql, ruleId, ruleDetailId); + while (recordSet.next()) { + int scopeTypeTemp = Util.getIntValue(recordSet.getString("scopeType"), 0); + String scopeValueTemp = recordSet.getString("scopeValue"); + + if (scopeType == 0 && scopeTypeTemp == 0) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505667, user.getLanguage()));//该假期类型下已经新建过总部的假期规则,请勿重复新建 + return resultMap; + } + if (scopeType == 1 && scopeTypeTemp == 1) { + List scopeValueTempList = Util.TokenizerString(scopeValueTemp, ","); + List scopeValueList = Util.TokenizerString(scopeValue, ","); + for (String temp : scopeValueList) + if (scopeValueTempList.contains(temp)) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + String subcomName = subCompanyComInfo.getSubCompanyname(temp); + + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505668, user.getLanguage()).replace("$", subcomName));//该假期类型下已经新建过分部的假期规则,请勿重复新建 + return resultMap; + } + } + if (scopeType == 2 && scopeTypeTemp == 2) { + List scopeValueTempList = Util.TokenizerString(scopeValueTemp, ","); + List scopeValueList = Util.TokenizerString(scopeValue, ","); + for (String temp : scopeValueList) + if (scopeValueTempList.contains(temp)) { + DepartmentComInfo comInfo = new DepartmentComInfo(); + String name = comInfo.getDepartmentname(temp); + + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(534890, user.getLanguage()).replace("$", name));//该假期类型下已经新建过部门的假期规则,请勿重复新建 + return resultMap; + } + } + if (scopeType == 3 && scopeTypeTemp == 3) { + List scopeValueTempList = Util.TokenizerString(scopeValueTemp, ","); + List scopeValueList = Util.TokenizerString(scopeValue, ","); + for (String temp : scopeValueList) + if (scopeValueTempList.contains(temp)) { + ResourceComInfo comInfo = new ResourceComInfo(); + String name = comInfo.getLastname(temp); + + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(534891, user.getLanguage()).replace("$", name));//该假期类型下已经新建过人员的假期规则,请勿重复新建 + return resultMap; + } + } + } + boolean flag = false;//数据是否更新成功 + String sql = "update kq_LeaveRulesDetail set ruleId=?,ruleName=?,scopeType=?,scopeValue=?," + + "distributionMode=?,annualAmount=?,legalKey=?,welfareKey=?,priority=?,validityRule=?,effectiveDays=?,effectiveMonths=?,expirationMonth=?,expirationDay=?,extensionEnable=?,extendedDays=?,releaseRule=?,calcMethod=?,convertMode=?,excludeSubAccount=?,beforeFormal=?,severalChildren=?,yearsOld=?,isprovince=? ,carryOver=?,carryOverDays=?,deductorder=? where id=?"; + flag = recordSet.executeUpdate(sql, ruleId, ruleName, scopeType, scopeValue, + distributionMode, annualAmount, legalKey, welfareKey, priority, validityRule, effectiveDays, effectiveMonths, expirationMonth, expirationDay, extensionEnable, extendedDays, releaseRule, calcMethod, convertMode, excludeSubAccount, beforeFormal,severalChildren,yearsOld,isprovince,carryOver,carryOverDays,deductorder,ruleDetailId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + + if ((distributionMode == 2 || distributionMode == 7) && ruleDetailId != 0) { + sql = "delete from kq_EntryToLeave where leaveRulesId=?"; + flag = recordSet.executeUpdate(sql, ruleDetailId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + int lowerLimit = 0;//司龄下限 + int upperLimit = 0;//司龄上限 + String data = Util.null2String(params.get("detailRule")); + JSONArray jsonArray = JSONArray.parseArray(data); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int timePoint = jsonObject.getIntValue("timePoint"); + double amount = jsonObject.getDoubleValue("amount"); + + lowerLimit = i == 0 ? 0 : timePoint; + upperLimit = i == jsonArray.size() - 1 ? 9999 : jsonArray.getJSONObject(i + 1).getIntValue("timePoint"); + + sql = "insert into kq_EntryToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, lowerLimit, upperLimit, amount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (distributionMode == 3 && ruleDetailId != 0) { + sql = "delete from kq_WorkingAgeToLeave where leaveRulesId=?"; + flag = recordSet.executeUpdate(sql, ruleDetailId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + int lowerLimit = 0;//工龄下限 + int upperLimit = 0;//工龄上限 + String data = Util.null2String(params.get("detailRule")); + JSONArray jsonArray = JSONArray.parseArray(data); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int timePoint = jsonObject.getIntValue("timePoint"); + double amount = jsonObject.getDoubleValue("amount"); + + lowerLimit = i == 0 ? 0 : timePoint; + upperLimit = i == jsonArray.size() - 1 ? 9999 : jsonArray.getJSONObject(i + 1).getIntValue("timePoint"); + + sql = "insert into kq_WorkingAgeToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, lowerLimit, upperLimit, amount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (distributionMode == 6 && ruleDetailId != 0) { + sql = "delete from kq_MixModeToLegalLeave where leaveRulesId=?"; + flag = recordSet.executeUpdate(sql, ruleDetailId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + + sql = "delete from kq_MixModeToWelfareLeave where leaveRulesId=?"; + flag = recordSet.executeUpdate(sql, ruleDetailId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + String mixModeData = Util.null2String(params.get("legalRule")); + JSONArray jsonArray = JSONArray.parseArray(mixModeData); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int workYear = jsonObject.getIntValue("workYear"); + int entryTime = jsonObject.getIntValue("entryTime"); + double legalAmount = jsonObject.getDoubleValue("legalAmount"); + + sql = "insert into kq_MixModeToLegalLeave(leaveRulesId,limit1,limit2,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, workYear, entryTime, legalAmount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + + mixModeData = Util.null2String(params.get("welfareRule")); + jsonArray = JSONArray.parseArray(mixModeData); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int workYear = jsonObject.getIntValue("workYear"); + int entryTime = jsonObject.getIntValue("entryTime"); + double welfareAmount = jsonObject.getDoubleValue("welfareAmount"); + + sql = "insert into kq_MixModeToWelfareLeave(leaveRulesId,limit1,limit2,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, workYear, entryTime, welfareAmount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + if (distributionMode == 8 && ruleDetailId != 0) { + sql = "delete from kq_provinceToLeave where leaveRulesId=?"; + flag = recordSet.executeUpdate(sql, ruleDetailId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + int provinceidValue = 0;//省份id + int yearsOldValue = 0;//孩子周岁 + double amountValue = 0;//假期天数 + String data = Util.null2String(params.get("detailRule")); + JSONArray jsonArray = JSONArray.parseArray(data); + if (Objects.nonNull(jsonArray)) { + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + provinceidValue = jsonObject.getIntValue("provinceid"); + yearsOldValue = jsonObject.getIntValue("yearsOld"); + amountValue = jsonObject.getDoubleValue("amount"); + + sql = "insert into kq_provinceToLeave(leaveRulesId,provinceid,yearsOld,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, provinceidValue, yearsOldValue, amountValue); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + } + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } + } catch (Exception e) { + writeLog(e); + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } finally { + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + detailComInfo.removeCache(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leaverules/GetLeaveRulesFormCmd.java b/src/com/engine/kq/cmd/leaverules/GetLeaveRulesFormCmd.java new file mode 100644 index 0000000..95706d6 --- /dev/null +++ b/src/com/engine/kq/cmd/leaverules/GetLeaveRulesFormCmd.java @@ -0,0 +1,1065 @@ +package com.engine.kq.cmd.leaverules; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.conn.RecordSet; +import weaver.filter.XssUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.province.ProvinceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +/** + * 假期规则--获取新建编辑的表单 + */ +public class GetLeaveRulesFormCmd extends AbstractCommonCommand> { + + public GetLeaveRulesFormCmd(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(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + /**假期类型的相关信息:*/ + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + + /*新建假期规则时选择完请假类型后会再次请求此表单接口*/ + /*规则对应的假期类型的ID*/ + String ruleId = Util.null2String(params.get("typeId")); + + /*是否启用:0-未启用、1-启用*/ + int isEnable = 1; + + /*最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假*/ + int minimumUnit = 1; + + /******************************************************************************/ + + /**假期规则详情的相关信息:*/ + + /*是否是编辑*/ + boolean isEdit = false; + + /*假期规则详情的ID*/ + String ruleDetailId = Util.null2String(params.get("ruleId")); + + /*假期规则名称*/ + String ruleName = ""; + + /*应用范围:0-总部、1-分部*/ + int scopeType = 0; + + /*应用范围为分部时,选择的分部ID*/ + String scopeValue = ""; + + /*余额发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按工龄+司龄自动发放*/ + int distributionMode = 1; + + //年假基数计算方式: + // 0(精确计算)-假期基数发放日期和假期基数变动日期均为每年的01月01号(但是假期基数是结合 司龄/工龄 变化前后的值按天数比例折算出来的)、 + // 1(按最少的余额计算)-假期基数发放日期和假期基数变动日期均为每年的01月01号、 + // 2(按最多的余额计算)-假期基数发放日期发放日期为每年的01月01号,假期基数的变动日期为每年的 入职日期/参加工作日期 + int calcMethod = 1; + + //是否折算:0-不折算、1-四舍五入、2-向上取整、3-向下取整、4-向上取0.5的倍数、向下取0.5的倍数 + int convertMode = 1; + + //折算后的小数点位数 + int decimalDigit = 2; + + /*每人发放小时(天)数(当余额发放方式为是每年发放固定天数时有效)*/ + double annualAmount = 0; + + //法定年假规则:0-工龄、1-司龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效) + String legalKey = "0"; + + //福利年假规则:0-工龄、1司龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效) + String welfareKey = "1"; + + /*扣减优先级:1-法定年假、2-福利年假(当余额发放方式为按工龄+司龄自动发放时有效)*/ + int priority = 1; + + //有效期规则:0-永久有效、1-按自然年(1月1日-12月31日)、2-按入职日期起12个月、3-自定义次年失效日期、4、按天数失效、5-按季度失效、6-按月数失效 + int validityRule = 0; + + /*失效日期--月(当有效期规则选择自定义次年失效日期时有效)*/ + String expirationMonth = "1"; + + /*失效日期--日(当有效期规则选择自定义次年失效日期时有效)*/ + String expirationDay = "1"; + + //有效天数(当有效期规则选择自定义有效天数时) + String effectiveDays = "30"; + + //有效月数(当有效期规则选择自定义有效月数时) + String effectiveMonths = "1"; + + /*允许延长有效期:0-不允许、1-允许*/ + int extensionEnable = 0; + + /*允许超过有效期天数*/ + int extendedDays = 90; + + /*释放规则:0-不限制、1-按天释放、2-按月释放*/ + int releaseRule = 0; + + //是否需要排除次账号:0--不排除,即次账号正常享受年假、1--排除,即次账号不能享受年假 + int excludeSubAccount = 1; + + //转正之前是否允许发放假期余额:0-不允许、1-允许 + int beforeFormal = 1; + + //多孩叠加开关。 + int severalChildren = 0; + + //孩子多少周岁前发放。 + int yearsOld = 3; + + //是否按照省份发放育儿假。1否,2是 + String isprovince = "1"; + +// 2、在假期规则页面,增加开关控制是否开启。carryOver +// 3、增加输入框控制结转天数。 carryOverDays + + int carryOver =0; + double carryOverDays = 0; + + String deductorder =""; + + /*入职时长--年假*/ + Map entryMap = new HashMap(); + List entryList = new ArrayList(); + + /*工龄--年假*/ + Map workingAgeMap = new HashMap(); + List workingAgeList = new ArrayList(); + + /*入职时长+工龄混合--年假*/ + Map mixedModeMap = new HashMap(); + List mixedModeList = new ArrayList(); + + if (!ruleDetailId.equals("")) { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete != 1) and id=" + ruleDetailId; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + isEdit = true; + + ruleName = recordSet.getString("ruleName"); + ruleId = recordSet.getString("ruleId"); + scopeType = recordSet.getInt("scopeType"); + scopeValue = recordSet.getString("scopeValue"); + deductorder = recordSet.getString("deductorder"); + distributionMode = Util.getIntValue(recordSet.getString("distributionMode"), 1); + annualAmount = Util.getDoubleValue(recordSet.getString("annualAmount"), 0); + legalKey = "" + Util.getIntValue(recordSet.getString("legalKey"), 0); + welfareKey = "" + Util.getIntValue(recordSet.getString("welfareKey"), 1); + priority = Util.getIntValue(recordSet.getString("priority"), 1); + validityRule = Util.getIntValue(recordSet.getString("validityRule"), 0); + effectiveDays = Util.null2s(recordSet.getString("effectiveDays"), "30"); + effectiveMonths = Util.null2s(recordSet.getString("effectiveMonths"),"1"); + expirationMonth = Util.null2s(recordSet.getString("expirationMonth"), "1"); + expirationDay = Util.null2s(recordSet.getString("expirationDay"), "1"); + extensionEnable = Util.getIntValue(recordSet.getString("extensionEnable"), 0); + extendedDays = Util.getIntValue(recordSet.getString("extendedDays"), 90); + releaseRule = Util.getIntValue(recordSet.getString("releaseRule"), 0); + calcMethod = Util.getIntValue(recordSet.getString("calcMethod"), 1); + convertMode = Util.getIntValue(recordSet.getString("convertMode"), 1); + excludeSubAccount = Util.getIntValue(recordSet.getString("excludeSubAccount"), 1); + beforeFormal = Util.getIntValue(recordSet.getString("beforeFormal"), 1); + severalChildren = Util.getIntValue(recordSet.getString("severalChildren"), 0); + yearsOld = Util.getIntValue(recordSet.getString("yearsOld"), 3); + isprovince = Util.null2s(recordSet.getString("isprovince"), "1"); + carryOver = Util.getIntValue(recordSet.getString("carryOver"), 0); + carryOverDays = Util.getDoubleValue(recordSet.getString("carryOverDays"), 0); + } + + if (distributionMode == 2 || distributionMode == 7) { + sql = "select * from kq_EntryToLeave where leaveRulesId = ? order by lowerLimit,upperLimit"; + recordSet.executeQuery(sql, ruleDetailId); + int lowerLimit = 0;//入职年限下限 + int upperLimit = 0;//入职年限上限 + double amount = 0;//假期天数 + while (recordSet.next()) { + lowerLimit = recordSet.getInt("lowerLimit"); + upperLimit = recordSet.getInt("upperLimit"); + amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + + entryMap = new HashMap(); + entryMap.put("timePoint", lowerLimit); + entryMap.put("amount", String.format("%.2f", amount)); + entryList.add(entryMap); + } + resultMap.put("detailRule", entryList); + } + + if (distributionMode == 3) { + sql = "select * from kq_WorkingAgeToLeave where leaveRulesId = ? order by lowerLimit,upperLimit"; + recordSet.executeQuery(sql, ruleDetailId); + int lowerLimit = 0;//工龄下限 + int upperLimit = 0;//工龄上限 + double amount = 0;//假期天数 + while (recordSet.next()) { + lowerLimit = recordSet.getInt("lowerLimit"); + upperLimit = recordSet.getInt("upperLimit"); + amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + + workingAgeMap = new HashMap(); + workingAgeMap.put("timePoint", lowerLimit); + workingAgeMap.put("amount", String.format("%.2f", amount)); + workingAgeList.add(workingAgeMap); + } + resultMap.put("detailRule", workingAgeList); + } + + if (distributionMode == 6) { + sql = "select * from kq_MixModeToLegalLeave where leaveRulesId=? order by id "; + recordSet.executeQuery(sql, ruleDetailId); + double limit1 = 0;//工龄下限 + double limit2 = 0;//司龄下限 + double amount = 0;//法定年假天数or福利年假天数 + while (recordSet.next()) { + limit1 = Util.getDoubleValue(recordSet.getString("limit1"), 0); + limit2 = Util.getDoubleValue(recordSet.getString("limit2"), 0); + amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + + mixedModeMap = new HashMap(); + if (legalKey.equals("0") || legalKey.equals("2")) { + mixedModeMap.put("workYear", limit1); + } + if (legalKey.equals("1") || legalKey.equals("2")) { + mixedModeMap.put("entryTime", limit2); + } + mixedModeMap.put("legalAmount", String.format("%.2f", amount)); + mixedModeList.add(mixedModeMap); + } + resultMap.put("legalRule", mixedModeList); + resultMap.put("legalKey", legalKey); + + mixedModeList = new ArrayList(); + sql = "select * from kq_MixModeToWelfareLeave where leaveRulesId=? order by id "; + recordSet.executeQuery(sql, ruleDetailId); + while (recordSet.next()) { + limit1 = Util.getDoubleValue(recordSet.getString("limit1"), 0); + limit2 = Util.getDoubleValue(recordSet.getString("limit2"), 0); + amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + + mixedModeMap = new HashMap(); + if (welfareKey.equals("0") || welfareKey.equals("2")) { + mixedModeMap.put("workYear", limit1); + } + if (welfareKey.equals("1") || welfareKey.equals("2")) { + mixedModeMap.put("entryTime", limit2); + } + mixedModeMap.put("welfareAmount", String.format("%.2f", amount)); + mixedModeList.add(mixedModeMap); + } + resultMap.put("welfareRule", mixedModeList); + resultMap.put("welfareKey", welfareKey); + } + if (distributionMode == 8) { + sql = "select * from kq_provinceToLeave where leaveRulesId = ? order by id "; + recordSet.executeQuery(sql, ruleDetailId); + int provinceid = 0;//省份id + int yearsOldValue = 0;//孩子周岁 + int id = 0;//id + double amount = 0;//假期天数 + String provincename = ""; + ProvinceComInfo coun = new ProvinceComInfo(); + while (recordSet.next()) { + id = recordSet.getInt("id"); + provinceid = recordSet.getInt("provinceid"); + yearsOldValue = recordSet.getInt("yearsOld"); + amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + provincename = coun.getProvincename(provinceid + ""); + workingAgeMap = new HashMap(); + workingAgeMap.put("id", id); + workingAgeMap.put("provinceid", provinceid); + workingAgeMap.put("provincename", provincename); + workingAgeMap.put("yearsOld", yearsOldValue); + workingAgeMap.put("amount", String.format("%.2f", amount)); + workingAgeList.add(workingAgeMap); + } + resultMap.put("detailRule", workingAgeList); + } + } + + if (isEdit) { + isEnable = Util.getIntValue(rulesComInfo.getIsEnable(ruleId), 1); + } + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + /****************************************************基本信息****************************************************/ + + groupItem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage())); + groupItem.put("defaultshow", true); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("typeId");//假期类型 + hrmFieldBean.setFieldlabel("129811"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(ruleId); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 || isEdit ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList = new ArrayList(); + if (!isEdit) { + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + if (!rulesComInfo.getIsEnable().equals("1") || !rulesComInfo.getBalanceEnable().equals("1")) { + continue; + } + optionsList.add(new SearchConditionOption(rulesComInfo.getId(), Util.formatMultiLang(rulesComInfo.getLeaveName(), "" + user.getLanguage()), ruleId.equals(rulesComInfo.getId()))); + } + } else { + optionsList.add(new SearchConditionOption(ruleId, Util.formatMultiLang(rulesComInfo.getLeaveName(ruleId), "" + user.getLanguage()), true)); + } + searchConditionItem.setOptions(optionsList); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(505298, user.getLanguage()));//只能选择启用状态下开启了假期余额的假期类型,并且编辑假期规则时不能变更假期类型 + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("ruleName");//规则名称 + hrmFieldBean.setFieldlabel("19829"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(ruleName); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + /*应用范围是否能够选择总部,如果已经新建过总部的假期规则,则无法新建总部的假期规则*/ + boolean canSelectCom = true; + /*已经新建过某分部的假期规则,则无法继续新建该分部的假期规则*/ + String selectedSubcomIds = "", selectedDepartmentIds = "", selectedMemberIds = ""; + /*新建假期规则的时候选择完假期类型后重亲请求了此接口*/ + if (!ruleId.equals("") && !isEdit) { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + while (recordSet.next()) { + int scopeTypeTemp = Util.getIntValue(recordSet.getString("scopeType"), 0); + String scopeValueTemp = recordSet.getString("scopeValue"); + + if (scopeTypeTemp == 0) { + canSelectCom = false; + } else if (scopeTypeTemp == 1) { + selectedSubcomIds += "," + scopeValueTemp; + } else if (scopeTypeTemp == 2) { + selectedDepartmentIds += "," + scopeValueTemp; + } else if (scopeTypeTemp == 3) { + selectedMemberIds += "," + scopeValueTemp; + } + } + } + selectedSubcomIds = selectedSubcomIds.length() > 0 ? selectedSubcomIds.substring(1) : ""; + selectedDepartmentIds = selectedDepartmentIds.length() > 0 ? selectedDepartmentIds.substring(1) : ""; + selectedMemberIds = selectedMemberIds.length() > 0 ? selectedMemberIds.substring(1) : ""; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("scopeType");//此规则适用范围 + hrmFieldBean.setFieldlabel("19374"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 || !canSelectCom ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(140, user.getLanguage()), scopeType == 0 || !canSelectCom)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(33553, user.getLanguage()), scopeType == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(124, user.getLanguage()), scopeType == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(1867, user.getLanguage()), scopeType == 3)); + searchConditionItem.setOptions(optionsList); + //对于一个请假类型,各分部能够且仅能够设置一个属于本分部的假期规则,如果未设置本分部的假期规则,默认取总部的假期规则,如果总部也未设置,则假期基数视作0.00 + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(534889, user.getLanguage())); + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("scopeValue");//分部 + hrmFieldBean.setFieldlabel("33553"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("170"); + hrmFieldBean.setFieldvalue(scopeType == 1 ? scopeValue : ""); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "KQLeaveRulesAdd:Add"); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("rightStr", "KQLeaveRulesAdd:Add"); + if (selectedSubcomIds.length() > 0) { + XssUtil xssUtil = new XssUtil(); + String sqlWhere = " id not in (" + selectedSubcomIds + ") "; + searchConditionItem.getBrowserConditionParam().getDataParams().put("sqlWhere", xssUtil.put(sqlWhere)); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("sqlWhere", xssUtil.put(sqlWhere)); + searchConditionItem.getBrowserConditionParam().getDestDataParams().put("sqlWhere", xssUtil.put(sqlWhere)); + } + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("scopeValueDepartment");//部门 + hrmFieldBean.setFieldlabel("124"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("168"); + hrmFieldBean.setFieldvalue(scopeType == 2 ? scopeValue : ""); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "KQLeaveRulesAdd:Add"); + if (selectedDepartmentIds.length() > 0) { + XssUtil xssUtil = new XssUtil(); + String sqlWhere = " id not in (" + selectedDepartmentIds + ") "; + searchConditionItem.getBrowserConditionParam().getDataParams().put("sqlWhere", xssUtil.put(sqlWhere)); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("sqlWhere", xssUtil.put(sqlWhere)); + searchConditionItem.getBrowserConditionParam().getDestDataParams().put("sqlWhere", xssUtil.put(sqlWhere)); + } + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("scopeValueMember");//人员 + hrmFieldBean.setFieldlabel("1867"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("166"); + hrmFieldBean.setFieldvalue(scopeType == 3 ? scopeValue : ""); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "KQLeaveRulesAdd:Add"); + if (selectedMemberIds.length() > 0) { + XssUtil xssUtil = new XssUtil(); + String sqlWhere = " id not in (" + selectedMemberIds + ") "; + searchConditionItem.getBrowserConditionParam().getDataParams().put("sqlWhere", xssUtil.put(sqlWhere)); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("sqlWhere", xssUtil.put(sqlWhere)); + searchConditionItem.getBrowserConditionParam().getDestDataParams().put("sqlWhere", xssUtil.put(sqlWhere)); + } + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + + /****************************************************发放规则****************************************************/ + + groupItem = new HashMap(); + itemList = new ArrayList(); + groupItem.put("title", SystemEnv.getHtmlLabelName(508539, user.getLanguage())); + groupItem.put("defaultshow", true); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("distributionMode");//余额发放方式 + hrmFieldBean.setFieldlabel("388946"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr((isEnable == 0 || (isEdit && distributionMode == 6)) ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388947, user.getLanguage()), distributionMode == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(390374, user.getLanguage()), distributionMode == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(388949, user.getLanguage()), distributionMode == 3)); + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(390323, user.getLanguage()), distributionMode == 4)); + optionsList.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(388951, user.getLanguage()), distributionMode == 5)); + SearchConditionOption searchConditionOption = new SearchConditionOption("6", SystemEnv.getHtmlLabelName(390822, user.getLanguage()), distributionMode == 6); + searchConditionOption.setDisabled((isEdit && distributionMode != 6) ? true : false); + optionsList.add(searchConditionOption); + optionsList.add(new SearchConditionOption("7", SystemEnv.getHtmlLabelName(514025, user.getLanguage()), distributionMode == 7)); + optionsList.add(new SearchConditionOption("8", SystemEnv.getHtmlLabelName(536880, user.getLanguage()), distributionMode == 8)); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setHelpfulTip("★" + SystemEnv.getHtmlLabelName(10000815,user.getLanguage()) + "★" + SystemEnv.getHtmlLabelName(501107, user.getLanguage())); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + List distributionModeTips = new ArrayList(); + distributionModeTips.add(SystemEnv.getHtmlLabelName(389735, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(500952, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(500953, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511046, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(389736, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(389737, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(500954, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511046, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(514026, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(536881, user.getLanguage())); + resultMap.put("distributionMode", distributionModeTips); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("calcMethod");//假期基数计算方式 + hrmFieldBean.setFieldlabel("501121"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(505302, user.getLanguage()), calcMethod == 0)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(505303, user.getLanguage()), calcMethod == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(505304, user.getLanguage()), calcMethod == 2)); + searchConditionItem.setOptions(optionsList); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + List calcMethodTips = new ArrayList(); + //以入职日期(或参加工作日期)为分隔点将一年划分为上半年和下半年,全年可用假期天数=上半年天数/全年总天数*上半年司龄(或工龄)对应的假期天数+下半年天数/全年总天数*下半年司龄(或工龄)对应的假期天数。每年1月1日自动发放假期天数。 + calcMethodTips.add(SystemEnv.getHtmlLabelName(505305, user.getLanguage())); + //每年1月1日计算员工的司龄(或工龄),取对应的假期天数,于1月1日自动发放。 + calcMethodTips.add(SystemEnv.getHtmlLabelName(505306, user.getLanguage())); + //每年1月1日计算员工的司龄(或工龄),取对应的假期天数,于1月1日自动发放。若一年中员工司龄(或工龄)增加后,对应的假期天数也随之增加,则自动补发增加的假期天数。 + calcMethodTips.add(SystemEnv.getHtmlLabelName(505307, user.getLanguage())); + resultMap.put("calcMethod", calcMethodTips); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("priority");//扣减优先级 + hrmFieldBean.setFieldlabel("2093"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(129819, user.getLanguage()), priority == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(132046, user.getLanguage()), priority == 2)); + searchConditionItem.setOptions(optionsList); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("annualAmount");//每人发放小时数 + hrmFieldBean.setFieldlabel("503237"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(annualAmount); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("0"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("carryOver"); + hrmFieldBean.setFieldlabel("546921"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(carryOver); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + Map otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(547604, user.getLanguage())); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("carryOverDays"); + hrmFieldBean.setFieldlabel("546922"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(carryOverDays); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + //育儿假多孩叠加 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("severalChildren"); + hrmFieldBean.setFieldlabel("546788"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(severalChildren); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + //育儿假孩子多少周岁 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("yearsOld"); + hrmFieldBean.setFieldlabel("546789"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(yearsOld); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|integer"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + //育儿假是否按照省份发放 +// hrmFieldBean = new HrmFieldBean(); +// hrmFieldBean.setFieldname("isprovince"); +// hrmFieldBean.setFieldlabel("546790"); +// hrmFieldBean.setFieldhtmltype("4"); +// hrmFieldBean.setType("1"); +// hrmFieldBean.setFieldvalue(isprovince); +// hrmFieldBean.setIsFormField(true); +// hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2); +// searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); +// otherParamsMap = new HashMap(); +// otherParamsMap.put("display", "switch"); +// searchConditionItem.setOtherParams(otherParamsMap); +// if (hrmFieldBean.getViewAttr() == 1) { +// Map OtherParamsMap = new HashMap(); +// OtherParamsMap.put("hasBorder", true); +// searchConditionItem.setOtherParams(OtherParamsMap); +// } +// itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("isprovince"); + hrmFieldBean.setFieldlabel("546825"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(isprovince); + List options = new ArrayList(); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(546827, user.getLanguage())+yearsOld+ + SystemEnv.getHtmlLabelName(546828, user.getLanguage())+annualAmount, + isprovince.equals("1"))); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(546790, user.getLanguage()),isprovince.equals("2"))); + hrmFieldBean.setSelectOption(options); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("convertMode");//是否折算 + hrmFieldBean.setFieldlabel("508419"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(508423, user.getLanguage()), convertMode == 0)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(389654, user.getLanguage()), convertMode == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(508424, user.getLanguage()), convertMode == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(508425, user.getLanguage()), convertMode == 3)); + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(508426, user.getLanguage()), convertMode == 4)); + optionsList.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(508427, user.getLanguage()), convertMode == 5)); + searchConditionItem.setOptions(optionsList); + //当假期基数计算方式选择【精确计算】时,不能选择【不折算】 + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(510491, user.getLanguage())); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + List convertModeTips = new ArrayList(); + //指不考虑是否是入职当年还是初始获得年(即年初01月01日的时候计算工龄或者司龄,得出对应的假期基数为0。但是当这一年的工龄或者司龄增加后,对应的假期基数就不再是0了,这样的年份称作初始获得年),通过工龄或司龄计算出对应的假期基数,不做任何扣减折算 + convertModeTips.add(SystemEnv.getHtmlLabelName(510131, user.getLanguage())); + //通过工龄或司龄计算出对应的假期基数后(若是入职当年或初始获得年会进行扣减折算),折算后四舍五入保留两位小数 + convertModeTips.add(SystemEnv.getHtmlLabelName(510132, user.getLanguage())); + //通过工龄或司龄计算出对应的假期基数后(若是入职当年或初始获得年会进行扣减折算),折算后的数值取整,例如:折算后的基数为3.21,取整后为4.0 + convertModeTips.add(SystemEnv.getHtmlLabelName(510133, user.getLanguage())); + //通过工龄或司龄计算出对应的假期基数后(若是入职当年或初始获得年会进行扣减折算),折算后的数值取整,例如:折算后的基数为3.21,取整后为3.0 + convertModeTips.add(SystemEnv.getHtmlLabelName(510134, user.getLanguage())); + //通过工龄或司龄计算出对应的假期基数后(若是入职当年或初始获得年会进行扣减折算),折算后的数值取0.5的倍数,例如:折算后的基数为3.21,最终为3.5 + convertModeTips.add(SystemEnv.getHtmlLabelName(510135, user.getLanguage())); + //通过工龄或司龄计算出对应的假期基数后(若是入职当年或初始获得年会进行扣减折算),折算后的数值取0.5的倍数,例如:折算后的基数为3.21,最终后为3.0 + convertModeTips.add(SystemEnv.getHtmlLabelName(510136, user.getLanguage())); + resultMap.put("convertModeTips", convertModeTips); + + groupItem.put("items", itemList); + groupList.add(groupItem); + + /****************************************************有效期****************************************************/ + + groupItem = new HashMap(); + itemList = new ArrayList(); + groupItem.put("title", SystemEnv.getHtmlLabelName(15030, user.getLanguage())); + groupItem.put("defaultshow", true); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("validityRule");//有效期规则 + hrmFieldBean.setFieldlabel("388952"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(22135, user.getLanguage()), validityRule == 0)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388953, user.getLanguage()), validityRule == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(388954, user.getLanguage()), validityRule == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(389739, user.getLanguage()), validityRule == 3)); + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(508428, user.getLanguage()), validityRule == 4)); + optionsList.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(513525, user.getLanguage()), validityRule == 5)); + optionsList.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(515135, user.getLanguage()), validityRule == 6)); + optionsList.add(new SearchConditionOption("7", SystemEnv.getHtmlLabelName(536941, user.getLanguage()), validityRule == 7)); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(515354, user.getLanguage())); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("effectiveDays");//有效月数 + hrmFieldBean.setFieldlabel("132356"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(effectiveDays); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|integer"); + searchConditionItem.setMin("1"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("effectiveMonths");//有效月数 + hrmFieldBean.setFieldlabel("515174"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(effectiveMonths); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|integer"); + searchConditionItem.setMin("1"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("expirationMonth");//失效日期--月 + hrmFieldBean.setFieldlabel("390103"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(expirationMonth); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + for (int i = 1; i <= 12; i++) { + if(user.getLanguage()==8){ + optionsList.add(new SearchConditionOption("" + i, i+"", Util.getIntValue(expirationMonth, 1) == i)); + }else { + optionsList.add(new SearchConditionOption("" + i, i + SystemEnv.getHtmlLabelName(383373, user.getLanguage()), Util.getIntValue(expirationMonth, 1) == i)); + } + } + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("expirationDay");//失效日期--日 + hrmFieldBean.setFieldlabel("390103"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(expirationDay); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + for (int i = 1; i <= 31; i++) { + if(user.getLanguage()==8){ + optionsList.add(new SearchConditionOption("" + i, i+"", Util.getIntValue(expirationMonth, 1) == i)); + }else { + optionsList.add(new SearchConditionOption("" + i, i + SystemEnv.getHtmlLabelName(390, user.getLanguage()), Util.getIntValue(expirationDay, 1) == i)); + } + } + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("extensionEnable");//允许延长有效期 + hrmFieldBean.setFieldlabel("388955"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(extensionEnable); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("extendedDays");//允许延长的天数 + hrmFieldBean.setFieldlabel("389198"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(extendedDays); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|integer"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + + /****************************************************其他设置****************************************************/ + + groupItem = new HashMap(); + itemList = new ArrayList(); + groupItem.put("title", SystemEnv.getHtmlLabelName(20824, user.getLanguage())); + groupItem.put("defaultshow", true); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("releaseRule");//释放规则 + hrmFieldBean.setFieldlabel("389093"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(32499, user.getLanguage()), releaseRule == 0)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(127263, user.getLanguage()), releaseRule == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(127262, user.getLanguage()), releaseRule == 2)); + searchConditionItem.setOptions(optionsList); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(510129, user.getLanguage())); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("excludeSubAccount");//次账号发放假期余额 + hrmFieldBean.setFieldlabel("510174"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(excludeSubAccount); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("beforeFormal");//转正之前发放假期余额 + hrmFieldBean.setFieldlabel("510175"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(beforeFormal); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + + /** + *调休扣减顺序 + */ + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("deductorder"); + hrmFieldBean.setFieldlabel("547670"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("391"); + hrmFieldBean.setFieldvalue(deductorder); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List> replaceDatas = new ArrayList>(); + Map datas = new HashMap(); + if(null != deductorder){ + String[] leaveidArr = deductorder.split(","); +// Collections.sort(leaveidArr, Comparator.comparingInt(Util::getIntValue)); + if(null != leaveidArr && leaveidArr.length>0){ + for (int i = 0; i < leaveidArr.length; i++) { + String leaveid = leaveidArr[i]; + datas = new HashMap(); + datas.put("id", leaveid); + datas.put("name", "1".equals(leaveid)?"节假日":("2".equals(leaveid)?"工作日":"休息日")); + replaceDatas.add(datas); + } + } + } + searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas); + Map dataMap = new HashMap(); + Map completeMap = new HashMap(); + XssUtil xssUtil = new XssUtil(); + dataMap.put("sqlWhere", xssUtil.put(" id not in (" + deductorder + ")")); + completeMap.put("sqlWhere", xssUtil.put(" id not in (" + deductorder+ ")") ); + searchConditionItem.getBrowserConditionParam().setDataParams(dataMap); + searchConditionItem.getBrowserConditionParam().setCompleteParams(completeMap); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(547671, user.getLanguage())); + itemList.add(searchConditionItem); + + + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + resultMap.put("isEnable", "" + isEnable); + if (isEdit) { + minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(ruleId), 1); + + String unitName = "";//单位名称,天/小时 + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) { + unitName = SystemEnv.getHtmlLabelName(1925, user.getLanguage());//天 + } else { + unitName = SystemEnv.getHtmlLabelName(391, user.getLanguage());//小时 + } + resultMap.put("unitName", unitName); + } + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leaverules/GetRightMenuCmd.java b/src/com/engine/kq/cmd/leaverules/GetRightMenuCmd.java new file mode 100644 index 0000000..863a05b --- /dev/null +++ b/src/com/engine/kq/cmd/leaverules/GetRightMenuCmd.java @@ -0,0 +1,62 @@ +package com.engine.kq.cmd.leaverules; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 假期规则--获取右键菜单 + */ +public class GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(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(); + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + int languageId = user.getLanguage();//用户选择的语言 + RightMenu rightMenu = null; + + boolean canAdd = HrmUserVarify.checkUserRight("KQLeaveRulesAdd:Add", user);//是否具有新建权限 + boolean canDelete = HrmUserVarify.checkUserRight("KQLeaveRulesDelete:Delete", user);//是否具有删除权限 + boolean canLog = HrmUserVarify.checkUserRight("KQLeaveRules:Log", user);//是否具有查看日志的权限 + if (canAdd) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Addnew, "new", true);//新建 + rightMenuList.add(rightMenu); + } + if(canDelete){ + rightMenu = new RightMenu(languageId, RightMenuType.BTN_BatchDelete, "batchDelete", true, true);//批量删除 + rightMenuList.add(rightMenu); + } + if (canLog) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_log, "log", false);//日志 + rightMenuList.add(rightMenu); + } + rightMenu = new RightMenu(languageId, RightMenuType.BTN_COLUMN, "custom", false); //显示列定制 + rightMenuList.add(rightMenu); + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leaverules/GetSearchConditionCmd.java b/src/com/engine/kq/cmd/leaverules/GetSearchConditionCmd.java new file mode 100644 index 0000000..e0706c2 --- /dev/null +++ b/src/com/engine/kq/cmd/leaverules/GetSearchConditionCmd.java @@ -0,0 +1,78 @@ +package com.engine.kq.cmd.leaverules; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 假期规则--高级搜索条件 + */ +public class GetSearchConditionCmd extends AbstractCommonCommand> { + + public GetSearchConditionCmd(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(); + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("ruleName");//规则名称 + hrmFieldBean.setFieldlabel("19829"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("typeId");//假期类型 + hrmFieldBean.setFieldlabel("129811"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList = new ArrayList(); + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + optionsList.add(new SearchConditionOption(rulesComInfo.getId(), Util.formatMultiLang(rulesComInfo.getLeaveName()))); + } + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + groupItem.put("title", SystemEnv.getHtmlLabelName(347,weaver.general.Util.getIntValue(user.getLanguage()))); + groupItem.put("defaultshow", true); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leaverules/GetSearchListCmd.java b/src/com/engine/kq/cmd/leaverules/GetSearchListCmd.java new file mode 100644 index 0000000..e65922f --- /dev/null +++ b/src/com/engine/kq/cmd/leaverules/GetSearchListCmd.java @@ -0,0 +1,86 @@ +package com.engine.kq.cmd.leaverules; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.general.PageIdConst; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.HashMap; +import java.util.Map; + +/** + * 假期规则--查询结果列表 + */ +public class GetSearchListCmd extends AbstractCommonCommand> { + + 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(); + String ruleName = Util.null2String(params.get("ruleName"));//假期规则名称 + String typeId = Util.null2String(params.get("typeId"));//假期类型的ID + + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限 + boolean canDelete = HrmUserVarify.checkUserRight("KQLeaveRulesDelete:Delete", user);//是否具有删除权限 + boolean canLog = HrmUserVarify.checkUserRight("KQLeaveRules:Log", user);//是否具有查看日志的权限 + + /*如果没有权限*/ + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + String backFields = " * "; + String sqlFrom = " from kq_LeaveRulesDetail "; + String sqlWhere = " where (isDelete is null or isDelete!=1) "; + String orderBy = " id "; + if (!ruleName.equals("")) { + sqlWhere += " and ruleName like '%" + ruleName + "%'"; + } + if(!typeId.equals("")){ + sqlWhere += " and ruleId="+typeId; + } + String pageUid = "b0c005a2-447f-0977-b692-6d8de7ead576"; + String operateString = ""; + operateString = ""; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += ""; + String tableString = "" + + "" + + "" + + operateString + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "
"; + String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionKey, tableString); + resultMap.put("sessionkey", sessionKey); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leaverules/GetUnitNameCmd.java b/src/com/engine/kq/cmd/leaverules/GetUnitNameCmd.java new file mode 100644 index 0000000..9d55cf2 --- /dev/null +++ b/src/com/engine/kq/cmd/leaverules/GetUnitNameCmd.java @@ -0,0 +1,56 @@ +package com.engine.kq.cmd.leaverules; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Auther: Administrator + * @Date: 2019-03-13 17:21 + * @Description: + */ +public class GetUnitNameCmd extends AbstractCommonCommand> { + + public GetUnitNameCmd(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(); + try{ + /*假期类型的ID(数据库表kq_leaveRules表的主键ID)*/ + String ruleId = Util.null2String(params.get("typeId")); + + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + + /*最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假*/ + int minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(ruleId)); + + String unitName = "";//单位名称,天/小时 + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) { + unitName = SystemEnv.getHtmlLabelName(1925, user.getLanguage());//天 + } else { + unitName = SystemEnv.getHtmlLabelName(391, user.getLanguage());//小时 + } + + resultMap.put("unitName",unitName); + }catch (Exception e){ + e.printStackTrace(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leaverules/IsNameRepeatCmd.java b/src/com/engine/kq/cmd/leaverules/IsNameRepeatCmd.java new file mode 100644 index 0000000..0f89a5d --- /dev/null +++ b/src/com/engine/kq/cmd/leaverules/IsNameRepeatCmd.java @@ -0,0 +1,50 @@ +package com.engine.kq.cmd.leaverules; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +/** + * 假期余额--判断名称是否重复 + */ +public class IsNameRepeatCmd extends AbstractCommonCommand> { + + public IsNameRepeatCmd(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(); + + /*假期规则ID*/ + String ruleDetailId = Util.null2String(params.get("ruleId")); + /*假期规则名称*/ + String ruleName = Util.null2String(params.get("ruleName")); + + boolean isRepeat = false;//名称是否重复了 + RecordSet recordSet = new RecordSet(); + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete!=1) and ruleName='" + ruleName + "' "; + if (!ruleDetailId.equals("")) { + sql += " and id not in (" + ruleDetailId + ")"; + } + recordSet.executeQuery(sql); + if (recordSet.next()) { + isRepeat = true; + } + resultMap.put("isRepeat", isRepeat); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leavetypes/AddLeaveTypesCmd.java b/src/com/engine/kq/cmd/leavetypes/AddLeaveTypesCmd.java new file mode 100644 index 0000000..467abcf --- /dev/null +++ b/src/com/engine/kq/cmd/leavetypes/AddLeaveTypesCmd.java @@ -0,0 +1,162 @@ +package com.engine.kq.cmd.leavetypes; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQAttFlowSetComInfo; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.util.KQTransMethod; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Auther: xiaj + * @Date: 2019-03-07 16:41 + * @Description: + */ +public class AddLeaveTypesCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public AddLeaveTypesCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String leaveName = Util.null2String(params.get("leaveName")); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVETYPES);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVETYPES);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and leaveName like '%" + leaveName + "%'"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("leavename"); + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + /*假期类型的ID*/ + KQTransMethod kqTransMethod = new KQTransMethod(); + String ruleId = "" + kqTransMethod.getNextId(); + + /*假期类型的名称*/ + String leaveName = Util.null2String(params.get("leaveName")); + String schevacationON = Util.null2String(params.get("schevacationON")+"", "0"); + String schevacation = Util.null2String(params.get("schevacation")); + + /*校验名称是否已经有其他假期类型使用*/ + String nameSql = "select * from kq_leaveRules where (isDelete is null or isDelete<>1) and leaveName=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(nameSql, leaveName); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505662, user.getLanguage())); + return resultMap; + } + + /*流程可见范围:0-总部、1-分部(只有在此范围内的人请假的时候才能看见此假期类型)*/ + int scopeType = Util.getIntValue((String) params.get("scopeType"), 0); + + /*流程可见范围为分部时,选择的分部ID*/ + String scopeValue = Util.null2String(params.get("scopeValue")); + + /*应用范围为部门时,选择的部门ID*/ + String scopeValueDepartment = Util.null2String(params.get("scopeValueDepartment")); + + /*应用范围为人员时,选择的人员ID*/ + String scopeValueMember = Util.null2String(params.get("scopeValueMember")); + + if(scopeType == 2) { + scopeValue = scopeValueDepartment; + } else if(scopeType == 3) { + scopeValue = scopeValueMember; + } + /*最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假*/ + int minimumUnit = Util.getIntValue((String) params.get("minimumUnit"), 1); + + /*折算方式:1-四舍五入、2-向上取整、3-向下取整*/ + int conversion = Util.getIntValue((String) params.get("conversion"), 1); + + /*计算请假时长方式:1-按工作日计算请假时长、2-按自然气计算请假时长*/ + int computingMode = Util.getIntValue((String) params.get("computingMode"), 1); + + /*日折算时长(按自然气计算请假时长时有效)*/ + double hoursToDay = Util.getDoubleValue((String) params.get("hoursToDay"), 8.00); + + /*按自然日计算请假时长,是否过滤节假期:0-不启用,1-启用*/ + String filterHolidays = Util.null2String((String)params.get("filterHolidays"), "0"); + + /*启用假期余额:0-不启用、1-启用*/ + int balanceEnable = Util.getIntValue((String) params.get("balanceEnable"), 0); + + //显示顺序 + double showOrder = Util.getDoubleValue((String) params.get("showOrder"), 0.00); + + //半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + int timeselection = Util.getIntValue((String) params.get("timeselection"), 1); + + /*每天重复时段:0-不启用、1-启用*/ + int repeatTime = Util.getIntValue((String) params.get("repeatTime"), 0); + + if(minimumUnit != 2){ + //如果请假类型不再是半天了,需要删除原半天设置 + String del_2_sql = "delete from kq_timeselection where selectiontype=0 and leaveruleid=? and minimumUnit=2"; + boolean is_2_del = recordSet.executeUpdate(del_2_sql,ruleId); + timeselection = 1; + } + + String sql = "insert into kq_LeaveRules(Id,leaveName,scopeType,scopeValue,minimumUnit,computingMode,hoursToDay,filterHolidays,balanceEnable,isEnable,showOrder,isDelete,timeselection,conversion,schevacationON,schevacation,repeat_time) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + boolean flag = recordSet.executeUpdate(sql, ruleId, leaveName, scopeType, scopeValue, minimumUnit, computingMode, hoursToDay,filterHolidays, balanceEnable, 1, showOrder, 0,timeselection,conversion,schevacationON,schevacation,repeatTime); + + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } + } catch (Exception e) { + e.printStackTrace(); + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } finally { + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + KQAttFlowSetComInfo kqAttFlowSetComInfo = new KQAttFlowSetComInfo(); + rulesComInfo.removeCache(); + kqAttFlowSetComInfo.removeKQAttFlowSetComInfoCache(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leavetypes/DeleteLeaveTypesCmd.java b/src/com/engine/kq/cmd/leavetypes/DeleteLeaveTypesCmd.java new file mode 100644 index 0000000..38bdae2 --- /dev/null +++ b/src/com/engine/kq/cmd/leavetypes/DeleteLeaveTypesCmd.java @@ -0,0 +1,111 @@ +package com.engine.kq.cmd.leavetypes; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Auther: xiaj + * @Date: 2019-03-07 16:42 + * @Description: + */ +public class DeleteLeaveTypesCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public DeleteLeaveTypesCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String ruleIds = Util.null2String(params.get("typeIds"));//需要删除的ID + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVETYPES);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVETYPES);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_leaveRules where (isDelete is null or isDelete<>1) and id in ("+ruleIds+")"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("leavename"); + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canDelete = HrmUserVarify.checkUserRight("KQLeaveRulesDelete:Delete", user);//是否具有删除的权限 + if (!canDelete) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));//没有权限 + return resultMap; + } + + String ruleIds = Util.null2String(params.get("typeIds"));//需要删除的ID + + if (ruleIds.equals("")) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));//参数有误 + return resultMap; + } + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + List ruleIds_list = Util.splitString2List(ruleIds, ","); + if(!ruleIds_list.isEmpty()){ + RecordSet rs = new RecordSet(); + for(String ruleId : ruleIds_list){ + String minimumUnit = kqLeaveRulesComInfo.getMinimumUnit(ruleId); + if(Util.getIntValue(minimumUnit) != 2){ + //如果请假类型不再是半天了,需要删除原半天设置 + String del_2_sql = "delete from kq_timeselection where selectiontype=0 and leaveruleid=? and minimumUnit=2"; + boolean is_2_del = rs.executeUpdate(del_2_sql,ruleId); + System.out.println("is_2_del:"+is_2_del); + } + } + } + + String sql = "delete from kq_LeaveRules where id in (" + ruleIds + ")"; + RecordSet recordSet = new RecordSet(); + boolean flag = recordSet.executeUpdate(sql); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(20461, user.getLanguage()));//删除成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(20462, user.getLanguage()));//删除失败 + } + } catch (Exception e) { + e.printStackTrace(); + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(20462, user.getLanguage()));//删除失败 + }finally { + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + rulesComInfo.removeCache(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leavetypes/EditLeaveTypesCmd.java b/src/com/engine/kq/cmd/leavetypes/EditLeaveTypesCmd.java new file mode 100644 index 0000000..84ef5e2 --- /dev/null +++ b/src/com/engine/kq/cmd/leavetypes/EditLeaveTypesCmd.java @@ -0,0 +1,381 @@ +package com.engine.kq.cmd.leavetypes; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQAttFlowSetComInfo; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQUnitBiz; +import com.engine.kq.biz.KQUsageHistoryBiz; +import com.engine.kq.entity.KQUsageHistoryEntity; +import com.engine.kq.jucailin.util.KQDateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +/** + * @Auther: xiaj + * @Date: 2019-03-07 16:42 + * @Description: + */ +public class EditLeaveTypesCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public EditLeaveTypesCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String ruleId = Util.null2String(params.get("typeId")); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVETYPES);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVETYPES);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_leaveRules where (isDelete is null or isDelete<>1) and id =" + ruleId; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("leavename"); + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + /*假期类型的ID*/ + String ruleId = Util.null2String(params.get("typeId")); + + /*假期类型的名称*/ + String leaveName = Util.null2String(params.get("leaveName")); + String schevacationON = Util.null2String(params.get("schevacationON")+"", "0"); + String schevacation = Util.null2String(params.get("schevacation")); + /*校验名称是否已经有其他假期类型使用*/ + String nameSql = "select * from kq_leaveRules where (isDelete is null or isDelete<>1) and leaveName=? and id<>?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(nameSql, leaveName, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505662, user.getLanguage())); + return resultMap; + } + + /*流程可见范围:0-总部、1-分部(只有在此范围内的人请假的时候才能看见此假期类型)*/ + int scopeType = Util.getIntValue((String) params.get("scopeType"), 0); + + /*流程可见范围为分部时,选择的分部ID*/ + String scopeValue = Util.null2String(params.get("scopeValue")); + + /*应用范围为部门时,选择的部门ID*/ + String scopeValueDepartment = Util.null2String(params.get("scopeValueDepartment")); + + /*应用范围为人员时,选择的人员ID*/ + String scopeValueMember = Util.null2String(params.get("scopeValueMember")); + + if(scopeType == 2) { + scopeValue = scopeValueDepartment; + } else if(scopeType == 3) { + scopeValue = scopeValueMember; + } + + /*最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假*/ + int minimumUnit = Util.getIntValue((String) params.get("minimumUnit"), 1); + + /*折算方式:1-四舍五入、2-向上取整、3-向下取整*/ + int conversion = Util.getIntValue((String) params.get("conversion"), 1); + + /*假期规则单位变更时的天和小时的换算比例*/ + double proportion = Util.getDoubleValue((String) params.get("proportion"), Util.getDoubleValue(rulesComInfo.getProportion(ruleId), 8.00)); + + /*计算请假时长方式:1-按工作日计算请假时长、2-按自然日计算请假时长*/ + int computingMode = Util.getIntValue((String) params.get("computingMode"), 1); + + /*日折算时长(当按自然日计算请假时长时有效)*/ + double hoursToDay = Util.getDoubleValue((String) params.get("hoursToDay"), 8.00); + + /*按自然日计算请假时长,是否过滤节假期:0-不启用,1-启用*/ + String filterHolidays = Util.null2String((String)params.get("filterHolidays"), "0"); + + /*启用假期余额:0-不启用、1-启用*/ + int balanceEnable = Util.getIntValue((String) params.get("balanceEnable"), 0); + + double showOrder = Util.getDoubleValue((String) params.get("showOrder"), 0.00); + + /*判断是否改变了假期类型的最小请假单位,是否需要转换员工假期余额 start*/ + int oldMinimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(ruleId), 1); + + //半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + int timeselection = Util.getIntValue((String) params.get("timeselection"), 1); + + /*每天重复时段:0-不启用、1-启用*/ + int repeatTime = Util.getIntValue((String) params.get("repeatTime"), 0); + + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4 && (KQUnitBiz.isLeaveHour(oldMinimumUnit+""))) { + changeMinimumUnit(ruleId, oldMinimumUnit, minimumUnit, proportion); + } else if (oldMinimumUnit == 1 || oldMinimumUnit == 2 || oldMinimumUnit == 4 && (KQUnitBiz.isLeaveHour(minimumUnit+""))) { + changeMinimumUnit(ruleId, oldMinimumUnit, minimumUnit, proportion); + } + if(minimumUnit != 2){ + //如果请假类型不再是半天了,需要删除原半天设置 + String del_2_sql = "delete from kq_timeselection where selectiontype=0 and leaveruleid=? and minimumUnit=2"; + boolean is_2_del = recordSet.executeUpdate(del_2_sql,ruleId); + timeselection = 1; + } + /*判断是否改变了假期类型的最小请假单位,是否需要转换员工假期余额 start*/ + + String sql = "update kq_LeaveRules set leaveName=?,scopeType=?,scopeValue=?,minimumUnit=?,proportion=?,computingMode=?,hoursToDay=?,filterHolidays=?,balanceEnable=?,showOrder=?,timeselection=?,conversion=?,schevacationON=?,schevacation=?,repeat_time=? where id=?"; + boolean flag = recordSet.executeUpdate(sql, leaveName, scopeType, scopeValue, minimumUnit, proportion, computingMode, hoursToDay, filterHolidays,balanceEnable, showOrder,timeselection,conversion,schevacationON,schevacation,repeatTime, ruleId); + + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } + } catch (Exception e) { + writeLog(e); + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } finally { + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + KQAttFlowSetComInfo kqAttFlowSetComInfo = new KQAttFlowSetComInfo(); + kqAttFlowSetComInfo.removeKQAttFlowSetComInfoCache(); + rulesComInfo.removeCache(); + } + return resultMap; + } + + /** + * 假期规则的最小请假单位发生变更时,需要重新计算假期余额 + * + * @param ruleId 指定假期类型的ID + * @param oldMinimumUnit 变更之前的假期类型的最小请假单位 + * @param newMinimumUnit 变更之后的假期类型的最小请假单位 + */ + private boolean changeMinimumUnit(String ruleId, int oldMinimumUnit, int newMinimumUnit, double proportion) { + boolean flag = true; + try { + List updateValueList = new ArrayList();//每一个所有Update SQL操作的参数集合 + List updateParamList = new ArrayList();//所有所有Update SQL操作的参数集合 + + /*员工假期余额变更记录*/ + KQUsageHistoryEntity usageHistoryEntity = new KQUsageHistoryEntity(); + List usageHistoryEntityList = new ArrayList(); + + /*获取当前日期,当前时间*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + + RecordSet recordSet = new RecordSet(); + if (((oldMinimumUnit == 1 || oldMinimumUnit == 2 || oldMinimumUnit == 4) && (KQUnitBiz.isLeaveHour(newMinimumUnit+"")))) { + String sql = "select * from kq_BalanceOfLeave where leaveRulesId=" + ruleId; + recordSet.executeQuery(sql); + while (recordSet.next()) { + String belongYear = recordSet.getString("belongYear"); + String resourceId = recordSet.getString("resourceId"); + String balanceId = recordSet.getString("id"); + double baseAmount = Util.getDoubleValue(recordSet.getString("baseAmount"), 0.00); + double extraAmount = Util.getDoubleValue(recordSet.getString("extraAmount"), 0.00); + double usedAmount = Util.getDoubleValue(recordSet.getString("usedAmount"), 0.00); + double baseAmount2 = Util.getDoubleValue(recordSet.getString("baseAmount2"), 0.00); + double extraAmount2 = Util.getDoubleValue(recordSet.getString("extraAmount2"), 0.00); + double usedAmount2 = Util.getDoubleValue(recordSet.getString("usedAmount2"), 0.00); + double tiaoxiuamount = Util.getDoubleValue(recordSet.getString("tiaoxiuamount"), 0.00); + + if (baseAmount == 0.00 && extraAmount == 0.00 && usedAmount == 0.00 && baseAmount2 == 0.00 && extraAmount2 == 0.00 && usedAmount2 == 0.00 && tiaoxiuamount == 0.00) { + continue; + } + + double newBaseAmount = baseAmount * proportion; + double newExtraAmount = extraAmount * proportion; + double newUsedAmount = usedAmount * proportion; + double newBaseAmount2 = baseAmount2 * proportion; + double newExtraAmount2 = extraAmount2 * proportion; + double newUsedAmount2 = usedAmount2 * proportion; + double newTiaoxiuamount = tiaoxiuamount * proportion; + + /*组装Update SQL操作的参数 start*/ + updateValueList = new ArrayList(); + updateValueList.add(String.format("%.2f", newBaseAmount)); + updateValueList.add(String.format("%.2f", newExtraAmount)); + updateValueList.add(String.format("%.2f", newUsedAmount)); + updateValueList.add(String.format("%.2f", newBaseAmount2)); + updateValueList.add(String.format("%.2f", newExtraAmount2)); + updateValueList.add(String.format("%.2f", newUsedAmount2)); + updateValueList.add(String.format("%.2f", newTiaoxiuamount)); + updateValueList.add(KQDateUtil.getUpdateTimeStamp()); + updateValueList.add(balanceId); + + updateParamList.add(updateValueList); + /*组装Update SQL操作的参数 end*/ + + if(tiaoxiuamount > 0){ + extraAmount = extraAmount+tiaoxiuamount; + } + if(newTiaoxiuamount > 0){ + newExtraAmount = newExtraAmount+newTiaoxiuamount; + } + + /*组装UsageHistory SQL操作的参数 start*/ + usageHistoryEntity = new KQUsageHistoryEntity(); + usageHistoryEntity.setLeaveRulesId(ruleId); + usageHistoryEntity.setRelatedId(resourceId); + usageHistoryEntity.setOperator("" + user.getUID()); + usageHistoryEntity.setOperateDate(currentDate); + usageHistoryEntity.setOperateTime(currentTime); + usageHistoryEntity.setOperateType("0"); + usageHistoryEntity.setBelongYear(belongYear); + usageHistoryEntity.setOldBaseAmount(String.format("%.2f", baseAmount)); + usageHistoryEntity.setNewBaseAmount(String.format("%.2f", newBaseAmount)); + usageHistoryEntity.setOldExtraAmount(String.format("%.2f", extraAmount)); + usageHistoryEntity.setNewExtraAmount(String.format("%.2f", newExtraAmount)); + usageHistoryEntity.setOldUsedAmount(String.format("%.2f", usedAmount)); + usageHistoryEntity.setNewUsedAmount(String.format("%.2f", newUsedAmount)); + usageHistoryEntity.setOldBaseAmount2(String.format("%.2f", baseAmount2)); + usageHistoryEntity.setNewBaseAmount2(String.format("%.2f", newBaseAmount2)); + usageHistoryEntity.setOldExtraAmount2(String.format("%.2f", extraAmount2)); + usageHistoryEntity.setNewExtraAmount2(String.format("%.2f", newExtraAmount2)); + usageHistoryEntity.setOldUsedAmount2(String.format("%.2f", usedAmount2)); + usageHistoryEntity.setNewUsedAmount2(String.format("%.2f", newUsedAmount2)); + usageHistoryEntity.setOldMinimumUnit(String.valueOf(oldMinimumUnit)); + usageHistoryEntity.setNewMinimumUnit(String.valueOf(newMinimumUnit)); + usageHistoryEntity.setInsertOrUpdate("update"); + + usageHistoryEntityList.add(usageHistoryEntity); + /*组装UsageHistory SQL操作的参数 end*/ + } + } else if ((KQUnitBiz.isLeaveHour(oldMinimumUnit+"")) && (newMinimumUnit == 1 || newMinimumUnit == 2 || newMinimumUnit == 4)) { + String sql = "select * from kq_BalanceOfLeave where leaveRulesId=" + ruleId; + recordSet.executeQuery(sql); + while (recordSet.next()) { + String resourceId = recordSet.getString("resourceId"); + String belongYear = recordSet.getString("belongYear"); + String balanceId = recordSet.getString("id"); + double baseAmount = Util.getDoubleValue(recordSet.getString("baseAmount"), 0.00); + double extraAmount = Util.getDoubleValue(recordSet.getString("extraAmount"), 0.00); + double usedAmount = Util.getDoubleValue(recordSet.getString("usedAmount"), 0.00); + double baseAmount2 = Util.getDoubleValue(recordSet.getString("baseAmount2"), 0.00); + double extraAmount2 = Util.getDoubleValue(recordSet.getString("extraAmount2"), 0.00); + double usedAmount2 = Util.getDoubleValue(recordSet.getString("usedAmount2"), 0.00); + double tiaoxiuamount = Util.getDoubleValue(recordSet.getString("tiaoxiuamount"), 0.00); + + if (baseAmount == 0.00 && extraAmount == 0.00 && usedAmount == 0.00 && baseAmount2 == 0.00 && extraAmount2 == 0.00 && usedAmount2 == 0.00 && tiaoxiuamount == 0.00) { + continue; + } + + double newBaseAmount = baseAmount / proportion; + double newExtraAmount = extraAmount / proportion; + double newUsedAmount = usedAmount / proportion; + double newBaseAmount2 = baseAmount2 / proportion; + double newExtraAmount2 = extraAmount2 / proportion; + double newUsedAmount2 = usedAmount2 / proportion; + double newTiaoxiuamount = tiaoxiuamount / proportion; + + /*组装Update SQL操作的参数 start*/ + updateValueList = new ArrayList(); + updateValueList.add(String.format("%.2f", newBaseAmount)); + updateValueList.add(String.format("%.2f", newExtraAmount)); + updateValueList.add(String.format("%.2f", newUsedAmount)); + updateValueList.add(String.format("%.2f", newBaseAmount2)); + updateValueList.add(String.format("%.2f", newExtraAmount2)); + updateValueList.add(String.format("%.2f", newUsedAmount2)); + updateValueList.add(String.format("%.2f", newTiaoxiuamount)); + updateValueList.add(KQDateUtil.getUpdateTimeStamp()); + updateValueList.add(balanceId); + + updateParamList.add(updateValueList); + /*组装Update SQL操作的参数 end*/ + + if(tiaoxiuamount > 0){ + extraAmount = extraAmount+tiaoxiuamount; + } + if(newTiaoxiuamount > 0){ + newExtraAmount = newExtraAmount+newTiaoxiuamount; + } + /*组装UsageHistory SQL操作的参数 start*/ + usageHistoryEntity = new KQUsageHistoryEntity(); + usageHistoryEntity.setLeaveRulesId(ruleId); + usageHistoryEntity.setRelatedId(resourceId); + usageHistoryEntity.setOperator("" + user.getUID()); + usageHistoryEntity.setOperateDate(currentDate); + usageHistoryEntity.setOperateTime(currentTime); + usageHistoryEntity.setOperateType("0"); + usageHistoryEntity.setBelongYear(belongYear); + usageHistoryEntity.setOldBaseAmount(String.format("%.2f", baseAmount)); + usageHistoryEntity.setNewBaseAmount(String.format("%.2f", newBaseAmount)); + usageHistoryEntity.setOldExtraAmount(String.format("%.2f", extraAmount)); + usageHistoryEntity.setNewExtraAmount(String.format("%.2f", newExtraAmount)); + usageHistoryEntity.setOldUsedAmount(String.format("%.2f", usedAmount)); + usageHistoryEntity.setNewUsedAmount(String.format("%.2f", newUsedAmount)); + usageHistoryEntity.setOldBaseAmount2(String.format("%.2f", baseAmount2)); + usageHistoryEntity.setNewBaseAmount2(String.format("%.2f", newBaseAmount2)); + usageHistoryEntity.setOldExtraAmount2(String.format("%.2f", extraAmount2)); + usageHistoryEntity.setNewExtraAmount2(String.format("%.2f", newExtraAmount2)); + usageHistoryEntity.setOldUsedAmount2(String.format("%.2f", usedAmount2)); + usageHistoryEntity.setNewUsedAmount2(String.format("%.2f", newUsedAmount2)); + usageHistoryEntity.setOldMinimumUnit(String.valueOf(oldMinimumUnit)); + usageHistoryEntity.setNewMinimumUnit(String.valueOf(newMinimumUnit)); + usageHistoryEntity.setInsertOrUpdate("update"); + + usageHistoryEntityList.add(usageHistoryEntity); + /*组装UsageHistory SQL操作的参数 end*/ + } + } + + /** + * 执行批量更新操作,如果失败,整体回滚 + */ + String updateSql = "update kq_BalanceOfLeave set baseAmount=?,extraAmount=?,usedAmount=?,baseAmount2=?,extraAmount2=?,usedAmount2=?,tiaoxiuamount=?,update_time=? where id=?"; + if (recordSet.getDBType().equals("postgresql")) { + updateSql = "update kq_BalanceOfLeave set baseAmount=?,extraAmount=?,usedAmount=?,baseAmount2=?,extraAmount2=?,usedAmount2=?,tiaoxiuamount=?,update_time=?::timestamp where id=?"; + } + if (updateParamList.size() > 0) { + flag = recordSet.executeBatchSql(updateSql, updateParamList); + } + + /** + * 执行批量插入使用记录操作,如果失败,插入记录整体回滚 + */ + if (usageHistoryEntityList.size() > 0) { + KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz(); + flag = usageHistoryBiz.save(usageHistoryEntityList); + } + } catch (Exception e) { + writeLog(e); + } + return flag; + } +} diff --git a/src/com/engine/kq/cmd/leavetypes/GetLeaveTypesFormCmd.java b/src/com/engine/kq/cmd/leavetypes/GetLeaveTypesFormCmd.java new file mode 100644 index 0000000..ad94e1a --- /dev/null +++ b/src/com/engine/kq/cmd/leavetypes/GetLeaveTypesFormCmd.java @@ -0,0 +1,510 @@ +package com.engine.kq.cmd.leavetypes; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.conn.RecordSet; +import weaver.filter.XssUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +/** + * @Auther: xiaj + * @Date: 2019-03-07 16:29 + * @Description:假期类型--获取新建或者编辑的菜单 + */ +public class GetLeaveTypesFormCmd extends AbstractCommonCommand> { + + public GetLeaveTypesFormCmd(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(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + /*假期类型的ID*/ + String ruleId = Util.null2String(params.get("typeId")); + + /*假期类型的名称*/ + String leaveName = ""; + + /*流程可见范围:0-总部、1-分部(只有在此范围内的人请假的时候才能看见此假期类型)*/ + int scopeType = 0; + + /*流程可见范围为分部时,选择的分部ID*/ + String scopeValue = ""; + + /*最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假*/ + int minimumUnit = 1; + //折算方式:1-四舍五入、2-向上取整、3-向下取整 + int conversion = 1; + + /*换算比例*/ + double proportion = 8.00; + + /*计算请假时长方式:1-按工作日计算请假时长、2-按自然日计算请假时长*/ + int computingMode = 1; + + /*日折算时长(按自然日计算请假时长时有效)*/ + double hoursToDay = 8.00; + + /*按自然日计算请假时长,0-不排除,1-排除节假日,2-排除休息日,3-排除节假日和休息日*/ + String filterHolidays ="0"; + + /*启用假期余额:0-不启用、1-启用*/ + int balanceEnable = 0; + + /*每天重复时段:0-不启用、1-启用*/ + String repeatTime = "0"; + + /*是否启用:0-未启用、1-启用*/ + int isEnable = 1; + + /*是否启用优先使用假期:0-未启用、1-启用*/ + int schevacationON = 0; + String schevacation = ""; + //半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + int timeselection = 1; + + //显示顺序 + double showOrder = getMaxShowOrder(); + + if (!ruleId.equals("")) { + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + leaveName = recordSet.getString("leaveName"); + scopeType = Util.getIntValue(recordSet.getString("scopeType"), 0); + scopeValue = recordSet.getString("scopeValue"); + minimumUnit = recordSet.getInt("minimumUnit"); + conversion = recordSet.getInt("conversion"); + conversion = conversion < 1 ? 1 : conversion; + proportion = Util.getDoubleValue(recordSet.getString("proportion"), 8.00); + computingMode = recordSet.getInt("computingMode"); + hoursToDay = Util.getDoubleValue(recordSet.getString("hoursToDay"), 8.00); + filterHolidays = Util.null2String(recordSet.getString("filterHolidays"),"0"); + balanceEnable = recordSet.getInt("balanceEnable"); + repeatTime = Util.null2String(recordSet.getString("repeat_time"),"0"); + isEnable = Util.getIntValue(recordSet.getString("isEnable"), 0); + schevacationON = Util.getIntValue(recordSet.getString("SchevacationON"), 0); + schevacation = Util.null2s(recordSet.getString("Schevacation"), ""); + showOrder = Util.getDoubleValue(recordSet.getString("showOrder"), 0.00); + timeselection = recordSet.getInt("timeselection"); + timeselection = timeselection < 1 ? 1 : timeselection; + } + } + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("leaveName");//假期类型的名称 + hrmFieldBean.setFieldlabel("388883"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(leaveName); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("scopeType");//流程可见范围 + hrmFieldBean.setFieldlabel("390881"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(140, user.getLanguage()), scopeType == 0)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(33553, user.getLanguage()), scopeType == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(124, user.getLanguage()), scopeType == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(1867, user.getLanguage()), scopeType == 3)); + + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(500951, user.getLanguage())); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("scopeValue");//分部 + hrmFieldBean.setFieldlabel("33553"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("170"); + hrmFieldBean.setFieldvalue(scopeType == 1 ? scopeValue : ""); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "KQLeaveRulesAdd:Add"); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("rightStr", "KQLeaveRulesAdd:Add"); + searchConditionItem.setRules("required|string"); + searchConditionItem.setViewAttr(3); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("scopeValueDepartment");//部门 + hrmFieldBean.setFieldlabel("124"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("168"); + hrmFieldBean.setFieldvalue(scopeType == 2 ? scopeValue : ""); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "KQLeaveRulesAdd:Add"); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("rightStr", "KQLeaveRulesAdd:Add"); + searchConditionItem.setRules("required|string"); + searchConditionItem.setViewAttr(3); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("scopeValueMember");//人员 + hrmFieldBean.setFieldlabel("1867"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("166"); + hrmFieldBean.setFieldvalue(scopeType == 3 ? scopeValue : ""); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "KQLeaveRulesAdd:Add"); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("rightStr", "KQLeaveRulesAdd:Add"); + searchConditionItem.setRules("required|string"); + searchConditionItem.setViewAttr(3); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("minimumUnit");//最小请假单位 + hrmFieldBean.setFieldlabel("388884"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388885, user.getLanguage()), minimumUnit == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(388886, user.getLanguage()), minimumUnit == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(388887, user.getLanguage()), minimumUnit == 3)); + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(389680, user.getLanguage()), minimumUnit == 4)); + optionsList.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(514712, user.getLanguage()), minimumUnit == 5)); + optionsList.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(514786, user.getLanguage()), minimumUnit == 6)); + searchConditionItem.setOptions(optionsList); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + //时长折算方式 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("conversion"); + hrmFieldBean.setFieldlabel("530092"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(389654, user.getLanguage()), conversion == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(508424, user.getLanguage()), conversion == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(508425, user.getLanguage()), conversion == 3)); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + if (!ruleId.equals("")) { + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("proportion");//换算比例 + hrmFieldBean.setFieldlabel("390754"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(proportion); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("1"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + } + + List minimumUnitTips = new ArrayList(); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(390372, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389733, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389734, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389732, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389734, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389734, user.getLanguage())); + resultMap.put("minimumUnit", minimumUnitTips); + + // 按半小时请假联动说明: + List conversionTips = new ArrayList(); + conversionTips.add(SystemEnv.getHtmlLabelName(530011, user.getLanguage())); + conversionTips.add(SystemEnv.getHtmlLabelName(530068, user.getLanguage())); + conversionTips.add(SystemEnv.getHtmlLabelName(530069, user.getLanguage())); + resultMap.put("conversion5", conversionTips); + + // 按整小时请假联动说明: + conversionTips = new ArrayList(); + conversionTips.add(SystemEnv.getHtmlLabelName(530065, user.getLanguage())); + conversionTips.add(SystemEnv.getHtmlLabelName(530066, user.getLanguage())); + conversionTips.add(SystemEnv.getHtmlLabelName(530067, user.getLanguage())); + resultMap.put("conversion6", conversionTips); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("timeselection");//时间选择方式 + hrmFieldBean.setFieldlabel("513304"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(timeselection+""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(513301, user.getLanguage()), timeselection == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(513302, user.getLanguage()), timeselection == 2)); + searchConditionItem.setOptions(optionsList); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("computingMode");//计算请假时长方式 + hrmFieldBean.setFieldlabel("388888"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388889, user.getLanguage()), computingMode == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(388890, user.getLanguage()), computingMode == 2)); + searchConditionItem.setOptions(optionsList); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("hoursToDay");//日折算时长 + hrmFieldBean.setFieldlabel("388907"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(hoursToDay); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("0"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("filterHolidays");/*按自然日计算请假时长,0-不排除,1-排除节假日,2-排除休息日,3-排除节假日和休息日*/ + hrmFieldBean.setFieldlabel("126833"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + if(filterHolidays.equals("0")){ + filterHolidays = ""; + } + hrmFieldBean.setFieldvalue(filterHolidays); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List statusOptions = new ArrayList(); + statusOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(28386, user.getLanguage()))); + statusOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(458, user.getLanguage()))); + searchConditionItem.setOptions(statusOptions); + searchConditionItem.setDetailtype(2); + itemList.add(searchConditionItem); + + /*如果之前开了假期余额并且新建了假期规则,在删除该假期类型下的所有假期规则之前,不允许关闭 启用假期余额*/ + boolean canCloseBalanceEnable = true; + if (!ruleId.equals("")) { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + canCloseBalanceEnable = false; + } + } + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("balanceEnable");//启用假期余额 + hrmFieldBean.setFieldlabel("388945"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue("" + balanceEnable); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 || (balanceEnable == 1 && !canCloseBalanceEnable) ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + Map otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(505663, user.getLanguage())); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("showOrder");//显示顺序 + hrmFieldBean.setFieldlabel("15513"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(showOrder); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("repeatTime");//每天重复时段 + hrmFieldBean.setFieldlabel("547941"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(repeatTime); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(546638, user.getLanguage())); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("schevacationON");//启用假期余额 + hrmFieldBean.setFieldlabel("547022"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue("" + schevacationON); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(547023, user.getLanguage())); + itemList.add(searchConditionItem); + + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("schevacation");//多个假期类型 + hrmFieldBean.setFieldlabel("547019"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("390"); + hrmFieldBean.setFieldvalue(schevacation); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + List> replaceDatas = new ArrayList>(); + Map datas = new HashMap(); + List leaveidArr =Util.splitString2List(schevacation,","); + for (String leaveid : leaveidArr) { + datas = new HashMap(); + datas.put("id", leaveid); + datas.put("name", kqLeaveRulesComInfo.getLeaveName(leaveid)); + replaceDatas.add(datas); + } + searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas); + Map dataMap = new HashMap(); + Map completeMap = new HashMap(); + XssUtil xssUtil = new XssUtil(); + dataMap.put("sqlWhere", xssUtil.put(" id not in (" + ruleId + ")")); + completeMap.put("sqlWhere", xssUtil.put(" id not in (" + ruleId+ ")") ); + searchConditionItem.getBrowserConditionParam().setDataParams(dataMap); + searchConditionItem.getBrowserConditionParam().setCompleteParams(completeMap); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(547021, user.getLanguage())); + itemList.add(searchConditionItem); + + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + resultMap.put("isEnable", isEnable == 1); + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + private double getMaxShowOrder() { + double maxShowOrder = 0; + String sql = "select max(showOrder) maxShowOrder from kq_leaveRules where 1=1 and (isDelete is null or isDelete<>1) "; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + maxShowOrder = Util.getDoubleValue(recordSet.getString("maxShowOrder"), 0) + 1; + } + return maxShowOrder; + } +} diff --git a/src/com/engine/kq/cmd/leavetypes/GetRightMenuCmd.java b/src/com/engine/kq/cmd/leavetypes/GetRightMenuCmd.java new file mode 100644 index 0000000..5694182 --- /dev/null +++ b/src/com/engine/kq/cmd/leavetypes/GetRightMenuCmd.java @@ -0,0 +1,63 @@ +package com.engine.kq.cmd.leavetypes; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Auther: xiaj + * @Date: 2019-03-07 16:28 + * @Description: 假期类型--获取右键菜单 + */ +public class GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(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(); + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + int languageId = user.getLanguage();//用户选择的语言 + RightMenu rightMenu = null; + + boolean canAdd = HrmUserVarify.checkUserRight("KQLeaveRulesAdd:Add", user);//是否具有新建权限 + boolean canDelete = HrmUserVarify.checkUserRight("KQLeaveRulesDelete:Delete", user);//是否具有删除权限 + boolean canLog = HrmUserVarify.checkUserRight("KQLeaveRules:Log", user);//是否具有查看日志的权限 + if (canAdd) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Addnew, "new", true);//新建 + rightMenuList.add(rightMenu); + + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Save, "save", true);//保存 + rightMenuList.add(rightMenu); + } + if(canDelete){ + rightMenu = new RightMenu(languageId, RightMenuType.BTN_BatchDelete, "batchDelete", true, true);//批量删除 + rightMenuList.add(rightMenu); + } + if (canLog) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_log, "log", false);//日志 + rightMenuList.add(rightMenu); + } + rightMenu = new RightMenu(languageId, RightMenuType.BTN_COLUMN, "custom", false); //显示列定制 + rightMenuList.add(rightMenu); + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leavetypes/GetSearchConditionCmd.java b/src/com/engine/kq/cmd/leavetypes/GetSearchConditionCmd.java new file mode 100644 index 0000000..fbedbb4 --- /dev/null +++ b/src/com/engine/kq/cmd/leavetypes/GetSearchConditionCmd.java @@ -0,0 +1,108 @@ +package com.engine.kq.cmd.leavetypes; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Auther: Administrator + * @Date: 2019-03-12 22:09 + * @Description: + */ +public class GetSearchConditionCmd extends AbstractCommonCommand> { + + public GetSearchConditionCmd(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(); + try{ + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("leaveName");//假期类型名称 + hrmFieldBean.setFieldlabel("388883"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("minimumUnit");//请假单位 + hrmFieldBean.setFieldlabel("388884"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(332, user.getLanguage()),true)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388885, user.getLanguage()))); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(388886, user.getLanguage()))); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(388887, user.getLanguage()))); + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(389680, user.getLanguage()))); + optionsList.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(514712, user.getLanguage()))); + optionsList.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(514786, user.getLanguage()))); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("computingMode");//计算请假时长方式 + hrmFieldBean.setFieldlabel("388888"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(332, user.getLanguage()),true)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388889, user.getLanguage()))); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(388890, user.getLanguage()))); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("balanceEnable");//是否启用假期余额 + hrmFieldBean.setFieldlabel("388945"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("-1", SystemEnv.getHtmlLabelName(332, user.getLanguage()),true)); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(32386, user.getLanguage()))); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(18095, user.getLanguage()))); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + groupItem.put("title", SystemEnv.getHtmlLabelName(347,weaver.general.Util.getIntValue(user.getLanguage()))); + groupItem.put("defaultshow", true); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + }catch (Exception e){ + e.printStackTrace(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leavetypes/GetSearchListCmd.java b/src/com/engine/kq/cmd/leavetypes/GetSearchListCmd.java new file mode 100644 index 0000000..577ab0f --- /dev/null +++ b/src/com/engine/kq/cmd/leavetypes/GetSearchListCmd.java @@ -0,0 +1,93 @@ +package com.engine.kq.cmd.leavetypes; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.general.PageIdConst; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Auther: Administrator + * @Date: 2019-03-07 18:37 + * @Description: + */ +public class GetSearchListCmd extends AbstractCommonCommand> { + + 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(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限 + boolean canDelete = HrmUserVarify.checkUserRight("KQLeaveRulesDelete:Delete", user);//是否具有删除权限 + boolean canLog = HrmUserVarify.checkUserRight("KQLeaveRules:Log", user);//是否具有查看日志的权限 + + String leaveName = Util.null2String(params.get("leaveName"));//假期类型的名称 + String minimumUnit = Util.null2String(params.get("minimumUnit"));//最小请假单位 + String computingMode = Util.null2String(params.get("computingMode"));//计算请假时长方式 + String balanceEnable = Util.null2String(params.get("balanceEnable"));//是否启用假期余额 + + String backFields = " * "; + String sqlFrom = " from kq_LeaveRules "; + String sqlWhere = " where (isDelete is null or isDelete!=1) "; + if (!leaveName.equals("")) { + sqlWhere += " and leaveName like '%" + leaveName + "%' "; + } + if (!minimumUnit.equals("0") && !minimumUnit.equals("")) { + sqlWhere += " and minimumUnit=" + minimumUnit; + } + if (!computingMode.equals("0") && !computingMode.equals("")) { + sqlWhere += " and computingMode=" + computingMode; + } + if (!balanceEnable.equals("-1") && !balanceEnable.equals("")) { + sqlWhere += " and balanceEnable=" + balanceEnable; + } + String orderBy = " showOrder,id "; + String pageUid = "ff6a16be-57bc-002d-6223-600b9031e252"; + String operateString = ""; + operateString = ""; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += ""; + String tableString = "" + + "" + + "" + + "" + + operateString + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "
"; + String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionKey, tableString); + resultMap.put("sessionkey", sessionKey); + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leavetypes/GetTimeSelectionFormCmd.java b/src/com/engine/kq/cmd/leavetypes/GetTimeSelectionFormCmd.java new file mode 100644 index 0000000..4a6c859 --- /dev/null +++ b/src/com/engine/kq/cmd/leavetypes/GetTimeSelectionFormCmd.java @@ -0,0 +1,133 @@ +package com.engine.kq.cmd.leavetypes; + +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +public class GetTimeSelectionFormCmd extends AbstractCommonCommand> { + + public GetTimeSelectionFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + //半天设置的类型,是请假0,还是出差1,公出2,加班3 + int selectiontype = Util.getIntValue(Util.null2String(params.get("selectiontype")),-1); + //请假可以细分到每一种请假类型,leaveruleid为请假类型的id + int leaveruleid = Util.getIntValue(Util.null2String(params.get("leaveruleid")),-1); + //最小请假单位:2-按半天请假、4-按整天请假 + //目前只做2半天的情况 + int minimumUnit = Util.getIntValue((String) params.get("minimumUnit"), 2); + boolean isEdit = false; + String half_on = ""; + String half_off = ""; + String whole = ""; + if(selectiontype == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + if(selectiontype < 0 || leaveruleid == -1){ + retmap.put("status", "-1"); + writeLog("SaveTimeSelectionForm:参数有问题:selectiontype:"+selectiontype+":leaveruleid:"+leaveruleid); + retmap.put("message", SystemEnv.getHtmlLabelName(514241, user.getLanguage())); + return retmap; + } + }else{ + if(selectiontype < 0){ + retmap.put("status", "-1"); + writeLog("SaveTimeSelectionForm:参数有问题:selectiontype:"+selectiontype+":leaveruleid:"+leaveruleid); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + } + RecordSet rs = new RecordSet(); + String editSql = ""; + if(selectiontype == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + editSql = "select * from kq_timeselection where selectiontype="+ selectiontype+" and leaveruleid="+leaveruleid+" and minimumUnit="+minimumUnit; + }else { + editSql = "select * from kq_timeselection where selectiontype="+ selectiontype+" and minimumUnit="+minimumUnit; + } + rs.executeQuery(editSql); + if(rs.next()){ + isEdit = true; + half_on = Util.null2String(rs.getString("half_on")); + half_off = Util.null2String(rs.getString("half_off")); + whole = Util.null2String(rs.getString("whole")); + } + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + if(minimumUnit == 2){ + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("half_on");//上午 + hrmFieldBean.setFieldlabel("16689"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(isEdit?half_on:""); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setMultilang(true); + hrmFieldBean.setViewAttr(2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("half_off");//下午 + hrmFieldBean.setFieldlabel("16690"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(isEdit?half_off:""); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setMultilang(true); + hrmFieldBean.setViewAttr(2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + }else if(minimumUnit == 4){ + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("whole");//整天 + hrmFieldBean.setFieldlabel("390728"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(isEdit?whole:""); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setMultilang(true); + hrmFieldBean.setViewAttr(2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + } + + groupItem.put("items", itemList); + groupList.add(groupItem); + retmap.put("status", "1"); + retmap.put("condition", groupList); + + }catch (Exception e){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } +} + diff --git a/src/com/engine/kq/cmd/leavetypes/IsNameRepeatCmd.java b/src/com/engine/kq/cmd/leavetypes/IsNameRepeatCmd.java new file mode 100644 index 0000000..8ae8401 --- /dev/null +++ b/src/com/engine/kq/cmd/leavetypes/IsNameRepeatCmd.java @@ -0,0 +1,61 @@ +package com.engine.kq.cmd.leavetypes; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Auther: xiaj + * @Date: 2019-03-07 16:43 + * @Description: + */ +public class IsNameRepeatCmd extends AbstractCommonCommand> { + + public IsNameRepeatCmd(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(); + try{ + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + /*假期类型的ID*/ + String ruleId = Util.null2String(params.get("typeId")); + + /*假期类型的名称*/ + String leaveName = Util.null2String(params.get("leaveName")); + + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and leaveName=? and id<>?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql,leaveName,ruleId); + if(recordSet.next()){ + resultMap.put("isRepeat",true); + }else{ + resultMap.put("isRepeat",false); + } + }catch (Exception e){ + writeLog(e); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leavetypes/SaveDisableLeaveTypesCmd.java b/src/com/engine/kq/cmd/leavetypes/SaveDisableLeaveTypesCmd.java new file mode 100644 index 0000000..a5695de --- /dev/null +++ b/src/com/engine/kq/cmd/leavetypes/SaveDisableLeaveTypesCmd.java @@ -0,0 +1,100 @@ +package com.engine.kq.cmd.leavetypes; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Auther: xiaj + * @Date: 2019-03-07 16:43 + * @Description: + */ +public class SaveDisableLeaveTypesCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public SaveDisableLeaveTypesCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVETYPES);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVETYPES);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_leaveRules where (isDelete is null or isDelete<>1) "; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("leavename"); + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + List valueList = new ArrayList(); + List paramList = new ArrayList(); + String datas = Util.null2String(params.get("datas"));//需要启用的假期规则 + JSONArray jsonArray = JSONArray.parseArray(datas); + for(int i=0;i> { + + public SaveTimeSelectionFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + //半天设置的类型,是请假单位,还是出差,公出,加班单位 + int selectiontype = Util.getIntValue(Util.null2String(params.get("selectiontype")),-1); + //请假可以细分到每一种请假类型,leaveruleid为请假类型的id + int leaveruleid = Util.getIntValue(Util.null2String(params.get("leaveruleid")),0); + //最小请假单位:2-按半天请假、4-按整天请假 + //目前只做2半天的情况 + int minimumUnit = Util.getIntValue((String) params.get("minimumUnit"), 2); + String half_on = Util.null2String(params.get("half_on")); + String half_off = Util.null2String(params.get("half_off")); + String whole = Util.null2String(params.get("whole")); + + if(selectiontype == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + if(selectiontype < 0 || leaveruleid == 0){ + retmap.put("status", "-1"); + writeLog("SaveTimeSelectionForm:参数有问题:selectiontype:"+selectiontype+":leaveruleid:"+leaveruleid); + retmap.put("message", SystemEnv.getHtmlLabelName(514241, user.getLanguage())); + return retmap; + } + }else{ + if(selectiontype < 0){ + retmap.put("status", "-1"); + writeLog("SaveTimeSelectionForm:参数有问题:selectiontype:"+selectiontype+":leaveruleid:"+leaveruleid); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + } + RecordSet rs = new RecordSet(); + String delSql = ""; + if(selectiontype == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + delSql = "delete from kq_timeselection where selectiontype="+ selectiontype+" and leaveruleid="+leaveruleid+" and minimumUnit="+minimumUnit; + }else { + delSql = "delete from kq_timeselection where selectiontype="+ selectiontype+" and minimumUnit="+minimumUnit; + } + boolean isDel = rs.executeUpdate(delSql); + if(isDel){ + String addSql = "insert into kq_timeselection(selectiontype,leaveruleid,minimumUnit,half_on,half_off,whole) values(?,?,?,?,?,?)"; + rs.executeUpdate(addSql,selectiontype,leaveruleid,minimumUnit,half_on,half_off,whole); + } + KQTimeSelectionComInfo kqTimeSelectionComInfo = new KQTimeSelectionComInfo(); + kqTimeSelectionComInfo.removeCache(); + retmap.put("status", "1"); + + }catch (Exception e){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } +} + diff --git a/src/com/engine/kq/cmd/myattendance/GetDetailCondition4MobileCmd.java b/src/com/engine/kq/cmd/myattendance/GetDetailCondition4MobileCmd.java new file mode 100644 index 0000000..f7c35ca --- /dev/null +++ b/src/com/engine/kq/cmd/myattendance/GetDetailCondition4MobileCmd.java @@ -0,0 +1,98 @@ +package com.engine.kq.cmd.myattendance; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.portal.util.DateUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +/** + * 获取【我的考勤】各明细的高级搜索条件 + */ +public class GetDetailCondition4MobileCmd extends AbstractCommonCommand> { + + public GetDetailCondition4MobileCmd(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(); + try { + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + String kqtype = Util.null2String(params.get("kqtype"));//类型,不同明细下的高级搜索可能不同 + if ("overtime".equalsIgnoreCase(kqtype)) { + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("paidLeaveEnable");//关联调休 + hrmFieldBean.setFieldlabel("125804"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("-1", SystemEnv.getHtmlLabelName(332, user.getLanguage()), true));//全部 + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(163, user.getLanguage())));//是 + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(161, user.getLanguage())));//否 + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("computingMode");//加班方式 + hrmFieldBean.setFieldlabel("513203"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(332, user.getLanguage()), true));//全部 + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(500382, user.getLanguage())));//需审批,以加班流程为准 + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(500383, user.getLanguage())));//需审批,以打卡为准,但是不能超过加班流程时长 + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(390837, user.getLanguage())));//无需审批,根据打卡时间计算加班时长 + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(524827, user.getLanguage())));//需审批,以打卡为准,与加班流程时长取交集。 + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + } else { + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("signType");//打卡类型 + hrmFieldBean.setFieldlabel("500502,63"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(332, user.getLanguage()), true)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(512504, user.getLanguage()))); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(512505, user.getLanguage()))); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + } + + groupItem.put("title", SystemEnv.getHtmlLabelName(347,weaver.general.Util.getIntValue(user.getLanguage()))); + groupItem.put("defaultshow", true); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/myattendance/GetDetailList4MobileCmd.java b/src/com/engine/kq/cmd/myattendance/GetDetailList4MobileCmd.java new file mode 100644 index 0000000..d0f5dda --- /dev/null +++ b/src/com/engine/kq/cmd/myattendance/GetDetailList4MobileCmd.java @@ -0,0 +1,1083 @@ +package com.engine.kq.cmd.myattendance; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQAttFlowSetBiz; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.util.KQTransMethod; +import com.engine.kq.util.TransMethod; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class GetDetailList4MobileCmd extends AbstractCommonCommand> { + + public GetDetailList4MobileCmd(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(); + try { + String kqtype = Util.null2String(params.get("kqtype")); + if (kqtype.equalsIgnoreCase("realWorkdays")) { + resultMap = getRealWorkdaysList(); + } else if (kqtype.equalsIgnoreCase("absent")) { + resultMap = getAbsentList(); + } else if (kqtype.equalsIgnoreCase("beLate") || kqtype.equalsIgnoreCase("graveBeLate")) { + if (kqtype.equalsIgnoreCase("graveBeLate")) { + params.put("tabKey", "2"); + } + resultMap = getBeLateList(); + } else if (kqtype.equalsIgnoreCase("leaveEarly") || kqtype.equalsIgnoreCase("graveLeaveEarly")) { + if (kqtype.equalsIgnoreCase("graveLeaveEarly")) { + params.put("tabKey", "2"); + } + resultMap = getLeaveEearlyList(); + } else if (kqtype.equalsIgnoreCase("noSign")) { + resultMap = getForgotCheckList(); + } else if (kqtype.startsWith("leaveType_") + || kqtype.equalsIgnoreCase("evection") + || kqtype.equalsIgnoreCase("outDays")) { + resultMap = getLeaveList(); + } else if (kqtype.equalsIgnoreCase("overTime")) { + resultMap = getOverTimeList(); + } + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + /** + * 获取实际出勤明细 + * + * @return + */ + private Map getRealWorkdaysList() { + Map resultMap = new HashMap(); + try { + String resourceId = Util.null2String(params.get("resourceId")); + if ("".equals(resourceId)) { + resourceId = "" + user.getUID(); + } + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String lastName = resourceComInfo.getResourcename(resourceId); + String searchDateSelect = Util.null2String(params.get("searchDateselect"));//日期范围 + String searchDateFrom = Util.null2String(params.get("searchDatefrom"));//开始日期 + String searchDateTo = Util.null2String(params.get("searchDateto"));//结束日期 + if (!searchDateSelect.equals("") && !searchDateSelect.equals("0") && !searchDateSelect.equals("6")) { + searchDateFrom = TimeUtil.getDateByOption(searchDateSelect, "0"); + searchDateTo = TimeUtil.getDateByOption(searchDateSelect, "1"); + } + String signType = Util.null2String(params.get("signType"));//打卡类型 + //由于手机端无法一次性获取所有得数据,需要分批次获取 + int index = Util.getIntValue((String) params.get("index"), 0);//从第几个开始获取 + int pageSize = Util.getIntValue((String) params.get("pageSize"), 10);//一次获取多少个 + + TransMethod transMethod = new TransMethod(); + List dataList = new ArrayList(); + Map itemMap = new HashMap(); + List> itemList = new ArrayList>(); + + RecordSet recordSet = new RecordSet(); + String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid,serialid as serialid1, serialid as serialid2," + + " workbegintime,workendtime,signintime,signouttime, attendanceMins, signMins "; + String sqlFrom = "from hrmresource a, kq_format_detail b "; + String sqlWhere = " where a.id = b.resourceid and (attendanceMins>0 or signMins>0)"; + String orderBy = " kqdate asc, workbegintime asc "; + if (!"".equals(resourceId)) { + sqlWhere += " and resourceId=" + resourceId; + } + if (!"".equals(searchDateFrom)) { + sqlWhere += " and kqdate>='" + searchDateFrom + "' "; + } + if (!"".equals(searchDateTo)) { + sqlWhere += " and kqdate<='" + searchDateTo + "' "; + } + if ("1".equals(signType)) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere += " and (signInTime is not null and signInTime<>'') "; + } else { + sqlWhere += " and (signInTime is not null) "; + } + } else if ("2".equals(signType)) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere += " and (signOutTime is not null and signOutTime<>'') "; + } else { + sqlWhere += " and (signOutTime is not null) "; + } + } + String pageSql = "select * from (select tmp.*,rownum rn from ( select" + backFields + sqlFrom + sqlWhere + " order by " + orderBy + ") tmp where rownum<=" + (pageSize + index) + ") c where rn>=" + (index + 1); + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + pageSql = "select t.* from ( select " + backFields + ",ROW_NUMBER() OVER( order by " + orderBy + ") rn " + sqlFrom + sqlWhere + ") t where 1=1 and rn>=" + (index + 1) + " and rn<=" + (pageSize + index); + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + pageSql = "select " + backFields + sqlFrom + sqlWhere + " order by " + orderBy + " limit " + index + "," + pageSize; + }else if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + pageSql = "select " + backFields + sqlFrom + sqlWhere + " order by " + orderBy + " limit " + pageSize + " offset " + index; + } + recordSet.executeQuery(pageSql); + if (pageSize > recordSet.getCounts()) { + resultMap.put("isEnd", true); + } else { + resultMap.put("isEnd", false); + } + while (recordSet.next()) { + String kqDate = recordSet.getString("kqDate"); + String serialId = recordSet.getString("serialId"); + String serialNumber = recordSet.getString("serialNumber"); + String workBeginTime = recordSet.getString("workBeginTime"); + String workEndTime = recordSet.getString("workEndTime"); + String signInDate = recordSet.getString("signInDate"); + String signInTime = recordSet.getString("signInTime"); + String signOutDate = recordSet.getString("signOutDate"); + String signOutTime = recordSet.getString("signOutTime"); + String signMins = recordSet.getString("signMins"); + String attendanceMins = recordSet.getString("attendanceMins"); + + String serialInfo = transMethod.getSerailName(serialId, workBeginTime + "+" + workEndTime); + String signInTimeShow = transMethod.getReportDetialSignInTime(serialId, signInTime + "+" + kqDate + "+" + resourceId + "+" + user.getLanguage()); + String signOutTimeShow = transMethod.getReportDetialSignOutTime(serialId, signOutTime + "+" + kqDate + "+" + resourceId + "+" + user.getLanguage()); + + itemList = new ArrayList>(); + itemMap = new HashMap(); + itemMap.put("label", ""); + itemMap.put("key", "kqDate"); + itemMap.put("value", kqDate); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(390054, user.getLanguage())); + itemMap.put("key", "serialInfo"); + itemMap.put("value", serialInfo); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(390495, user.getLanguage())); + itemMap.put("key", "signInTime"); + itemMap.put("value", signInTimeShow); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(390496, user.getLanguage())); + itemMap.put("key", "signOutTime"); + itemMap.put("value", signOutTimeShow); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(391040, user.getLanguage())); + itemMap.put("key", "attendanceMins"); + itemMap.put("value", transMethod.getReportDetialMinToHour(attendanceMins)); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(504433, user.getLanguage())); + itemMap.put("key", "signMins"); + itemMap.put("value", transMethod.getReportDetialMinToHour(signMins)); + itemList.add(itemMap); + + dataList.add(itemList); + } + resultMap.put("data", dataList); + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(10000816,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(513174, user.getLanguage()).replace("{lastName}", lastName)); + } + } catch (Exception e) { + writeLog(e); + resultMap.put("api_status", false); + resultMap.put("message", e.getMessage()); + } + return resultMap; + } + + /** + * 获取旷工明细 + * + * @return + */ + private Map getAbsentList() { + Map resultMap = new HashMap(); + try { + String resourceId = Util.null2String(params.get("resourceId")); + if ("".equals(resourceId)) { + resourceId = "" + user.getUID(); + } + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String lastName = resourceComInfo.getResourcename(resourceId); + String searchDateSelect = Util.null2String(params.get("searchDateselect"));//日期范围 + String searchDateFrom = Util.null2String(params.get("searchDatefrom"));//开始日期 + String searchDateTo = Util.null2String(params.get("searchDateto"));//结束日期 + if (!searchDateSelect.equals("") && !searchDateSelect.equals("0") && !searchDateSelect.equals("6")) { + searchDateFrom = TimeUtil.getDateByOption(searchDateSelect, "0"); + searchDateTo = TimeUtil.getDateByOption(searchDateSelect, "1"); + } + //由于手机端无法一次性获取所有得数据,需要分批次获取 + int index = Util.getIntValue((String) params.get("index"), 0);//从第几个开始获取 + int pageSize = Util.getIntValue((String) params.get("pageSize"), 10);//一次获取多少个 + + + TransMethod transMethod = new TransMethod(); + Map itemMap = new HashMap(); + List> itemList = new ArrayList>(); + List dataList = new ArrayList(); + + String backFields = " * "; + String sqlFrom = " from kq_format_detail "; + String sqlWhere = " where absenteeismMins>0 "; + String orderBy = " kqdate asc, workbegintime asc "; + if (!"".equals(resourceId)) { + sqlWhere += " and resourceId=" + resourceId; + } + if (!"".equals(searchDateFrom)) { + sqlWhere += " and kqDate>='" + searchDateFrom + "' "; + } + if (!"".equals(searchDateTo)) { + sqlWhere += " and kqDate<='" + searchDateTo + "' "; + } + RecordSet recordSet = new RecordSet(); + String pageSql = "select * from (select tmp.*,rownum rn from ( select" + backFields + sqlFrom + sqlWhere + " order by " + orderBy + ") tmp where rownum<=" + (pageSize + index) + ") c where rn>=" + (index + 1); + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + pageSql = "select t.* from ( select " + backFields + ",ROW_NUMBER() OVER( order by " + orderBy + ") rn " + sqlFrom + sqlWhere + ") t where 1=1 and rn>=" + (index + 1) + " and rn<=" + (pageSize + index); + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + pageSql = "select " + backFields + sqlFrom + sqlWhere + " order by " + orderBy + " limit " + index + "," + pageSize; + }else if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + pageSql = "select " + backFields + sqlFrom + sqlWhere + " order by " + orderBy + " limit " + pageSize + " offset " + index; + } + recordSet.executeQuery(pageSql); + if (pageSize > recordSet.getCounts()) { + resultMap.put("isEnd", true); + } else { + resultMap.put("isEnd", false); + } + while (recordSet.next()) { + String kqDate = recordSet.getString("kqDate"); + String serialId = recordSet.getString("serialId"); + String workBeginTime = recordSet.getString("workBeginTime"); + String workEndTime = recordSet.getString("workEndTime"); + String signInTime = recordSet.getString("signInTime"); + String signOutTime = recordSet.getString("signOutTime"); + + String serialInfo = transMethod.getSerailName(serialId, workBeginTime + "+" + workEndTime); + String signInfo = transMethod.getReportDetialSignTime(serialId, signInTime + "+" + signOutTime + "+" + kqDate + "+" + resourceId + "+" + user.getLanguage()); + String absenteeismMins = transMethod.getReportDetialMinToHour(recordSet.getString("absenteeismMins")); + + itemList = new ArrayList>(); + itemMap = new HashMap(); + itemMap.put("label", ""); + itemMap.put("key", "kqDate"); + itemMap.put("value", kqDate); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(390054, user.getLanguage())); + itemMap.put("key", "serialInfo"); + itemMap.put("value", serialInfo); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(18949, user.getLanguage())); + itemMap.put("key", "signInfo"); + itemMap.put("value", signInfo); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(391416, user.getLanguage())); + itemMap.put("key", "absenteeismMins"); + itemMap.put("value", absenteeismMins); + itemList.add(itemMap); + + dataList.add(itemList); + } + resultMap.put("data", dataList); + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(10000817,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(513179, user.getLanguage()).replace("{lastName}", lastName)); + } + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + /** + * 获取迟到或者严重迟到的明细 + * + * @return + */ + private Map getBeLateList() { + Map resultMap = new HashMap(); + try { + String resourceId = Util.null2String(params.get("resourceId")); + if ("".equals(resourceId)) { + resourceId = "" + user.getUID(); + } + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String lastName = resourceComInfo.getResourcename(resourceId); + String searchDateSelect = Util.null2String(params.get("searchDateselect"));//日期范围 + String searchDateFrom = Util.null2String(params.get("searchDatefrom"));//开始日期 + String searchDateTo = Util.null2String(params.get("searchDateto"));//结束日期 + if (!searchDateSelect.equals("") && !searchDateSelect.equals("0") && !searchDateSelect.equals("6")) { + searchDateFrom = TimeUtil.getDateByOption(searchDateSelect, "0"); + searchDateTo = TimeUtil.getDateByOption(searchDateSelect, "1"); + } + String tabKey = Util.null2String(params.get("tabKey"));//是迟到还是严重迟到 + //由于手机端无法一次性获取所有得数据,需要分批次获取 + int index = Util.getIntValue((String) params.get("index"), 0);//从第几个开始获取 + int pageSize = Util.getIntValue((String) params.get("pageSize"), 10);//一次获取多少个 + + + TransMethod transMethod = new TransMethod(); + Map itemMap = new HashMap(); + List> itemList = new ArrayList>(); + List dataList = new ArrayList(); + + String backFields = " * "; + String sqlFrom = " from kq_format_detail "; + String sqlWhere = "where 1=1 "; + String orderBy = " kqdate asc, workbegintime asc, resourceId asc "; + if (!"".equals(resourceId)) { + sqlWhere += " and resourceId=" + resourceId; + } + if (!"".equals(searchDateFrom)) { + sqlWhere += " and kqDate>='" + searchDateFrom + "' "; + } + if (!"".equals(searchDateTo)) { + sqlWhere += " and kqDate<='" + searchDateTo + "' "; + } + if ("2".equals(tabKey)) { + sqlWhere += " and graveBeLateMins>0 "; + } else { + sqlWhere += " and beLateMins>0 "; + } + RecordSet recordSet = new RecordSet(); + String pageSql = "select * from (select tmp.*,rownum rn from ( select" + backFields + sqlFrom + sqlWhere + " order by " + orderBy + ") tmp where rownum<=" + (pageSize + index) + ") c where rn>=" + (index + 1); + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + pageSql = "select t.* from ( select " + backFields + ",ROW_NUMBER() OVER( order by " + orderBy + ") rn " + sqlFrom + sqlWhere + ") t where 1=1 and rn>=" + (index + 1) + " and rn<=" + (pageSize + index); + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + pageSql = "select " + backFields + sqlFrom + sqlWhere + " order by " + orderBy + " limit " + index + "," + pageSize; + } else if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + pageSql = "select " + backFields + sqlFrom + sqlWhere + " order by " + orderBy + " limit " + pageSize + " offset " + index; + } + recordSet.executeQuery(pageSql); + if (pageSize > recordSet.getCounts()) { + resultMap.put("isEnd", true); + } else { + resultMap.put("isEnd", false); + } + while (recordSet.next()) { + String kqDate = recordSet.getString("kqDate"); + String serialId = recordSet.getString("serialId"); + String workBeginTime = recordSet.getString("workBeginTime"); + String workEndTime = recordSet.getString("workEndTime"); + String signInTime = recordSet.getString("signInTime"); + String signOutTime = recordSet.getString("signOutTime"); + + String serialInfo = transMethod.getSerailName(serialId, workBeginTime + "+" + workEndTime); + String signInfo = transMethod.getReportDetialSignTime(serialId, signInTime + "+" + signOutTime + "+" + kqDate + "+" + resourceId + "+" + user.getLanguage()); + String beLateMins = transMethod.getReportDetialMinToHour(recordSet.getString("beLateMins")); + String graveBeLateMins = transMethod.getReportDetialMinToHour(recordSet.getString("graveBeLateMins")); + + itemList = new ArrayList>(); + itemMap = new HashMap(); + itemMap.put("label", ""); + itemMap.put("key", "kqDate"); + itemMap.put("value", kqDate); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(390054, user.getLanguage())); + itemMap.put("key", "serialInfo"); + itemMap.put("value", serialInfo); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(18949, user.getLanguage())); + itemMap.put("key", "signInfo"); + itemMap.put("value", signInfo); + itemList.add(itemMap); + if ("2".equals(tabKey)) { + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(10000818,weaver.general.Util.getIntValue(user.getLanguage()))); + itemMap.put("key", "graveBeLateMins"); + itemMap.put("value", graveBeLateMins); + itemList.add(itemMap); + } else { + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(10000819,weaver.general.Util.getIntValue(user.getLanguage()))); + itemMap.put("key", "beLateMins"); + itemMap.put("value", beLateMins); + itemList.add(itemMap); + } + dataList.add(itemList); + } + resultMap.put("data", dataList); + if ("2".equals(tabKey)) { + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(10000820,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(513176, user.getLanguage()).replace("{lastName}", lastName)); + } + } else { + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(10000821,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(513175, user.getLanguage()).replace("{lastName}", lastName)); + } + } + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + /** + * 获取早退或者严重早退的明细 + * + * @return + */ + private Map getLeaveEearlyList() { + Map resultMap = new HashMap(); + try { + String resourceId = Util.null2String(params.get("resourceId")); + if ("".equals(resourceId)) { + resourceId = "" + user.getUID(); + } + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String lastName = resourceComInfo.getResourcename(resourceId); + String searchDateSelect = Util.null2String(params.get("searchDateselect"));//日期范围 + String searchDateFrom = Util.null2String(params.get("searchDatefrom"));//开始日期 + String searchDateTo = Util.null2String(params.get("searchDateto"));//结束日期 + if (!searchDateSelect.equals("") && !searchDateSelect.equals("0") && !searchDateSelect.equals("6")) { + searchDateFrom = TimeUtil.getDateByOption(searchDateSelect, "0"); + searchDateTo = TimeUtil.getDateByOption(searchDateSelect, "1"); + } + String tabKey = Util.null2String(params.get("tabKey")); + //由于手机端无法一次性获取所有得数据,需要分批次获取 + int index = Util.getIntValue((String) params.get("index"), 0);//从第几个开始获取 + int pageSize = Util.getIntValue((String) params.get("pageSize"), 10);//一次获取多少个 + + + TransMethod transMethod = new TransMethod(); + Map itemMap = new HashMap(); + List> itemList = new ArrayList>(); + List dataList = new ArrayList(); + + String backFields = " * "; + String sqlFrom = " from kq_format_detail "; + String sqlWhere = "where 1=1 "; + String orderBy = " kqdate asc, workbegintime asc, resourceId asc "; + if (!"".equals(resourceId)) { + sqlWhere += " and resourceId=" + resourceId; + } + if (!"".equals(searchDateFrom)) { + sqlWhere += " and kqDate>='" + searchDateFrom + "' "; + } + if (!"".equals(searchDateTo)) { + sqlWhere += " and kqDate<='" + searchDateTo + "' "; + } + if ("2".equals(tabKey)) { + sqlWhere += " and graveLeaveEarlyMins>0 "; + } else { + sqlWhere += " and leaveEarlyMins>0 "; + } + RecordSet recordSet = new RecordSet(); + String pageSql = "select * from (select tmp.*,rownum rn from ( select" + backFields + sqlFrom + sqlWhere + " order by " + orderBy + ") tmp where rownum<=" + (pageSize + index) + ") c where rn>=" + (index + 1); + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + pageSql = "select t.* from ( select " + backFields + ",ROW_NUMBER() OVER( order by " + orderBy + ") rn " + sqlFrom + sqlWhere + ") t where 1=1 and rn>=" + (index + 1) + " and rn<=" + (pageSize + index); + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + pageSql = "select " + backFields + sqlFrom + sqlWhere + " order by " + orderBy + " limit " + index + "," + pageSize; + } else if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + pageSql = "select " + backFields + sqlFrom + sqlWhere + " order by " + orderBy + " limit " + pageSize + " offset " + index; + } + recordSet.executeQuery(pageSql); + if (pageSize > recordSet.getCounts()) { + resultMap.put("isEnd", true); + } else { + resultMap.put("isEnd", false); + } + while (recordSet.next()) { + String kqDate = recordSet.getString("kqDate"); + String serialId = recordSet.getString("serialId"); + String workBeginTime = recordSet.getString("workBeginTime"); + String workEndTime = recordSet.getString("workEndTime"); + String signInTime = recordSet.getString("signInTime"); + String signOutTime = recordSet.getString("signOutTime"); + String serialInfo = transMethod.getSerailName(serialId, workBeginTime + "+" + workEndTime); + String signInfo = transMethod.getReportDetialSignTime(serialId, signInTime + "+" + signOutTime + "+" + kqDate + "+" + resourceId + "+" + user.getLanguage()); + String leaveEarlyMins = transMethod.getReportDetialMinToHour(recordSet.getString("leaveEarlyMins")); + String graveLeaveEarlyMins = transMethod.getReportDetialMinToHour(recordSet.getString("graveLeaveEarlyMins")); + + itemList = new ArrayList>(); + itemMap = new HashMap(); + itemMap.put("label", ""); + itemMap.put("key", "kqDate"); + itemMap.put("value", kqDate); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(390054, user.getLanguage())); + itemMap.put("key", "serialInfo"); + itemMap.put("value", serialInfo); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(18949, user.getLanguage())); + itemMap.put("key", "signInfo"); + itemMap.put("value", signInfo); + itemList.add(itemMap); + if ("2".equals(tabKey)) { + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(10000822,weaver.general.Util.getIntValue(user.getLanguage()))); + itemMap.put("key", graveLeaveEarlyMins); + itemMap.put("value", graveLeaveEarlyMins); + itemList.add(itemMap); + } else { + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(10000823,weaver.general.Util.getIntValue(user.getLanguage()))); + itemMap.put("key", leaveEarlyMins); + itemMap.put("value", leaveEarlyMins); + itemList.add(itemMap); + } + dataList.add(itemList); + } + resultMap.put("data", dataList); + if ("2".equals(tabKey)) { + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(10000824,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(513177, user.getLanguage()).replace("{lastName}", lastName)); + } + } else { + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(10000825,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(513178, user.getLanguage()).replace("{lastName}", lastName)); + } + } + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + /** + * 获取漏签的明细 + * + * @return + */ + private Map getForgotCheckList() { + Map resultMap = new HashMap(); + try { + String resourceId = Util.null2String(params.get("resourceId")); + if ("".equals(resourceId)) { + resourceId = "" + user.getUID(); + } + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String lastName = resourceComInfo.getResourcename(resourceId); + String searchDateSelect = Util.null2String(params.get("searchDateselect"));//日期范围 + String searchDateFrom = Util.null2String(params.get("searchDatefrom"));//开始日期 + String searchDateTo = Util.null2String(params.get("searchDateto"));//结束日期 + if (!searchDateSelect.equals("") && !searchDateSelect.equals("0") && !searchDateSelect.equals("6")) { + searchDateFrom = TimeUtil.getDateByOption(searchDateSelect, "0"); + searchDateTo = TimeUtil.getDateByOption(searchDateSelect, "1"); + } + //由于手机端无法一次性获取所有得数据,需要分批次获取 + int index = Util.getIntValue((String) params.get("index"), 0);//从第几个开始获取 + int pageSize = Util.getIntValue((String) params.get("pageSize"), 10);//一次获取多少个 + + TransMethod transMethod = new TransMethod(); + Map itemMap = new HashMap(); + List> itemList = new ArrayList>(); + List dataList = new ArrayList(); + + String backFields = " * "; + String sqlFrom = " from kq_format_detail "; + String sqlWhere = "where 1=1 and (forgotCheckMins>0 or forgotBeginWorkCheckMins>0) "; + String orderBy = " kqdate asc, workbegintime asc "; + if (!"".equals(resourceId)) { + sqlWhere += " and resourceId=" + resourceId; + } + if (!"".equals(searchDateFrom)) { + sqlWhere += " and kqDate>='" + searchDateFrom + "' "; + } + if (!"".equals(searchDateTo)) { + sqlWhere += " and kqDate<='" + searchDateTo + "' "; + } + RecordSet recordSet = new RecordSet(); + String pageSql = "select * from (select tmp.*,rownum rn from ( select" + backFields + sqlFrom + sqlWhere + " order by " + orderBy + ") tmp where rownum<=" + (pageSize + index) + ") c where rn>=" + (index + 1); + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + pageSql = "select t.* from ( select " + backFields + ",ROW_NUMBER() OVER( order by " + orderBy + ") rn " + sqlFrom + sqlWhere + ") t where 1=1 and rn>=" + (index + 1) + " and rn<=" + (pageSize + index); + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + pageSql = "select " + backFields + sqlFrom + sqlWhere + " order by " + orderBy + " limit " + index + "," + pageSize; + }else if (recordSet.getDBType().equalsIgnoreCase("postgresql")) { + pageSql = "select " + backFields + sqlFrom + sqlWhere + " order by " + orderBy + " limit " + pageSize + " offset " + index; + } + recordSet.executeQuery(pageSql); + if (pageSize > recordSet.getCounts()) { + resultMap.put("isEnd", true); + } else { + resultMap.put("isEnd", false); + } + while (recordSet.next()) { + String kqDate = recordSet.getString("kqDate"); + String serialId = recordSet.getString("serialId"); + String workBeginTime = recordSet.getString("workBeginTime"); + String workEndTime = recordSet.getString("workEndTime"); + String signInTime = recordSet.getString("signInTime"); + String signOutTime = recordSet.getString("signOutTime"); + String forgotCheckMins = recordSet.getString("forgotcheckmins"); + String forgotBeginWorkCheckMins = recordSet.getString("forgotBeginWorkCheckMins"); + int forgotCheck = 0; + if (Util.getIntValue(forgotCheckMins, 0) > 0) { + forgotCheck++; + } + if (Util.getIntValue(forgotBeginWorkCheckMins, 0) > 0) { + forgotCheck++; + } + + String serialInfo = transMethod.getSerailName(serialId, workBeginTime + "+" + workEndTime); + String signInInfo = transMethod.getReportDetialSignInTime(serialId, signInTime + "+" + kqDate + "+" + resourceId + "+" + user.getLanguage()); + String signOutInfo = transMethod.getReportDetialSignOutTime(serialId, signOutTime + "+" + kqDate + "+" + resourceId + "+" + user.getLanguage()); + + itemList = new ArrayList>(); + itemMap = new HashMap(); + itemMap.put("label", ""); + itemMap.put("key", "kqDate"); + itemMap.put("value", kqDate); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(390054, user.getLanguage())); + itemMap.put("key", "serialInfo"); + itemMap.put("value", serialInfo); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(390495, user.getLanguage())); + itemMap.put("key", "signInInfo"); + itemMap.put("value", signInInfo); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(390496, user.getLanguage())); + itemMap.put("key", "signOutInfo"); + itemMap.put("value", signOutInfo); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(34099, user.getLanguage())); + itemMap.put("key", "forgotCheck"); + itemMap.put("value", forgotCheck); + itemList.add(itemMap); + dataList.add(itemList); + } + resultMap.put("data", dataList); + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(10000826,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(513180, user.getLanguage()).replace("{lastName}", lastName)); + } + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + /** + * 获取出差、公出、请假的明细 + * + * @return + */ + private Map getLeaveList() { + Map resultMap = new HashMap(); + try { + String resourceId = Util.null2String(params.get("resourceId")); + if ("".equals(resourceId)) { + resourceId = "" + user.getUID(); + } + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String lastName = resourceComInfo.getResourcename(resourceId); + String searchDateSelect = Util.null2String(params.get("searchDateselect"));//日期范围 + String searchDateFrom = Util.null2String(params.get("searchDatefrom"));//开始日期 + String searchDateTo = Util.null2String(params.get("searchDateto"));//结束日期 + if (!searchDateSelect.equals("") && !searchDateSelect.equals("0") && !searchDateSelect.equals("6")) { + searchDateFrom = TimeUtil.getDateByOption(searchDateSelect, "0"); + searchDateTo = TimeUtil.getDateByOption(searchDateSelect, "1"); + } + String kqType = Util.null2String(params.get("kqtype")); + + Map paramsMap = new HashMap(); + paramsMap.put("typeselect", "6"); + paramsMap.put("tabKey", "1"); + paramsMap.put("resourceId", resourceId); + paramsMap.put("fromDate", searchDateFrom); + paramsMap.put("toDate", searchDateTo); + paramsMap.put("isMyKQ", "1"); + if (kqType.equalsIgnoreCase("evection")) {//出差 + paramsMap.put("kqtype", KqSplitFlowTypeEnum.EVECTION.getFlowtype()); + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(10000827,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(513182, user.getLanguage()).replace("{lastName}", lastName)); + } + } else if (kqType.equalsIgnoreCase("outDays")) {//公出 + paramsMap.put("kqtype", KqSplitFlowTypeEnum.OUT.getFlowtype()); + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(10000828,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(513181, user.getLanguage()).replace("{lastName}", lastName)); + } + } else if (kqType.startsWith("leaveType_")) { + String[] typeInfo = Util.splitString(kqType, "_"); + if (typeInfo[0].equals("leaveType")) { + paramsMap.put("kqtype", KqSplitFlowTypeEnum.LEAVE.getFlowtype()); + paramsMap.put("newleavetype", typeInfo[1]); + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(10000829,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(513184, user.getLanguage()).replace("{lastName}", lastName)); + } + } + } + + Map itemMap = new HashMap(); + List> itemList = new ArrayList>(); + + KQAttFlowSetBiz kqAttFlowSetBiz = new KQAttFlowSetBiz(); + Map sqlMap = kqAttFlowSetBiz.getFLowSql(paramsMap, user); + String sqlFrom = sqlMap.get("from"); + String sqlWhere = sqlMap.get("where"); + + String sql = "select * " + sqlFrom + sqlWhere; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String requestId = recordSet.getString("requestId"); + String requestName = recordSet.getString("requestName"); + int durationRule = Util.getIntValue(recordSet.getString("durationrule")); + String unitName = ""; + if (durationRule == 3 || durationRule == 5 || durationRule == 6) { + unitName = SystemEnv.getHtmlLabelName(389326, user.getLanguage()); + } else { + unitName = SystemEnv.getHtmlLabelName(389325, user.getLanguage()); + } + double duration = Util.getDoubleValue(recordSet.getString("duration"), 0.00); + double backDuration = Util.getDoubleValue(recordSet.getString("backDuraion"), 0.00); + double period = duration - backDuration; + if (period <= 0) { + continue; + } + + itemMap = new HashMap(); + itemMap.put("label", requestName); + itemMap.put("period", String.format("%.2f", period) + unitName); + itemMap.put("requestId", requestId); + itemList.add(itemMap); + } + resultMap.put("data", itemList); + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + /** + * 获取加班的明细 + * + * @return + */ + private Map getOverTimeList() { + Map resultMap = new HashMap(); + try { + String resourceId = Util.null2String(params.get("resourceId")); + if ("".equals(resourceId)) { + resourceId = "" + user.getUID(); + } + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String lastName = resourceComInfo.getResourcename(resourceId); + String searchDateSelect = Util.null2String(params.get("searchDateselect"));//日期范围 + String searchDateFrom = Util.null2String(params.get("searchDatefrom"));//开始日期 + String searchDateTo = Util.null2String(params.get("searchDateto"));//结束日期 + if (!searchDateSelect.equals("") && !searchDateSelect.equals("0") && !searchDateSelect.equals("6")) { + searchDateFrom = TimeUtil.getDateByOption(searchDateSelect, "0"); + searchDateTo = TimeUtil.getDateByOption(searchDateSelect, "1"); + } + String computingMode = Util.null2s((String) params.get("computingMode"), "0"); + + Map data4ComputingMode = new TreeMap( + new Comparator() { + @Override + public int compare(String obj1, String obj2) { + // 降序排序 + return obj2.compareTo(obj1); + } + } + ); + if ("0".equalsIgnoreCase(computingMode) || "1".equalsIgnoreCase(computingMode)) { + Map data4ComputingMode1 = getOvertime4ComputingMode1(resourceId, searchDateFrom, searchDateTo); + data4ComputingMode.putAll(data4ComputingMode1); + } + if ("0".equalsIgnoreCase(computingMode) || "2".equalsIgnoreCase(computingMode)) { + Map data4ComputingMode2 = getOvertime4ComputingMode2(resourceId, searchDateFrom, searchDateTo); + data4ComputingMode.putAll(data4ComputingMode2); + } + if ("0".equalsIgnoreCase(computingMode) || "3".equalsIgnoreCase(computingMode)) { + Map data4ComputingMode3 = getOvertime4ComputingMode3(resourceId, searchDateFrom, searchDateTo); + data4ComputingMode.putAll(data4ComputingMode3); + } + if ("0".equalsIgnoreCase(computingMode) || "4".equalsIgnoreCase(computingMode)) { + Map data4ComputingMode4 = getOvertime4ComputingMode4(resourceId, searchDateFrom, searchDateTo); + data4ComputingMode.putAll(data4ComputingMode4); + } + + List dataList = new ArrayList(); + for (Map.Entry entry : data4ComputingMode.entrySet()) { + dataList.add(entry.getValue()); + } + + resultMap.put("data", dataList); + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(10000830,weaver.general.Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(513185, user.getLanguage()).replace("{lastName}", lastName)); + } + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + private Map getOvertime4ComputingMode1(String resourceId, String searchDateFrom, String searchDateTo) { + Map resultMap = new HashMap(); + try { + String paidLeaveEnable = Util.null2String(params.get("paidLeaveEnable")); + + RecordSet recordSet = new RecordSet(); + String dbType = recordSet.getDBType(); + String overtimeTable = ""; + String belongDateWhere = ""; + if (searchDateFrom.length() > 0 && searchDateTo.length() > 0) { + belongDateWhere += " and ( belongdate between '" + searchDateFrom + "' and '" + searchDateTo + "' " + + " or belongdate between '" + searchDateFrom + "' and '" + searchDateTo + "' " + + " or '" + searchDateFrom + "' between belongdate and belongdate " + + " or '" + searchDateTo + "' between belongdate and belongdate) "; + } + String paidLeaveEnableWhere = ""; + if ("0".equalsIgnoreCase(paidLeaveEnable) || "1".equalsIgnoreCase(paidLeaveEnable)) { + paidLeaveEnableWhere += " and paidLeaveEnable=" + paidLeaveEnable; + } + if ("oracle".equalsIgnoreCase(dbType)||"postgresql".equalsIgnoreCase(dbType)) { + overtimeTable = " select requestid,resourceid,fromdatedb fromdate,fromtimedb fromtime,todatedb todate,totimedb totime,computingmode,paidLeaveEnable,expiringdate,to_char(sum(duration_min)) duration_min from kq_flow_overtime where computingmode=1 " + + (belongDateWhere.length() == 0 ? "" : belongDateWhere) + (paidLeaveEnableWhere.length() == 0 ? "" : paidLeaveEnableWhere) + " group by requestid,resourceid,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate "; + } else if ("mysql".equalsIgnoreCase(dbType)) { + overtimeTable = " select requestid,resourceid,fromdatedb fromdate,fromtimedb fromtime,todatedb todate,totimedb totime,computingmode,paidLeaveEnable,expiringdate,CONVERT (sum(duration_min), CHAR ) duration_min from kq_flow_overtime where computingmode=1 " + + (belongDateWhere.length() == 0 ? "" : belongDateWhere) + (paidLeaveEnableWhere.length() == 0 ? "" : paidLeaveEnableWhere) + " group by requestid,resourceid,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate "; + } else { + overtimeTable = " select requestid,resourceid,fromdatedb fromdate,fromtimedb fromtime,todatedb todate,totimedb totime,computingmode,paidLeaveEnable,expiringdate,convert(varchar,sum(cast(duration_min as NUMERIC))) duration_min from kq_flow_overtime where computingmode=1 " + + (belongDateWhere.length() == 0 ? "" : belongDateWhere) + (paidLeaveEnableWhere.length() == 0 ? "" : paidLeaveEnableWhere) + " group by requestid,resourceid,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate "; + } + + String backFields = " * "; + String fromSql = " (select b.lastname,b.loginid,b.subcompanyid1,b.departmentid,b.jobtitle,b.managerid,b.managerstr,a.* from (" + overtimeTable + ") a left join hrmresource b on a.resourceid = b.id) f "; + String sqlWhere = " 1=1 "; + if (resourceId.length() > 0) { + sqlWhere += " and resourceId in(" + resourceId + ")"; + } + if ("0".equalsIgnoreCase(paidLeaveEnable) || "1".equalsIgnoreCase(paidLeaveEnable)) { + sqlWhere += " and paidLeaveEnable=" + paidLeaveEnable; + } + String orderBy = " computingMode "; + String sql = "select " + backFields + " from " + fromSql + " where " + sqlWhere + " order by " + orderBy; + resultMap = executeSQL(sql, "1"); + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + private Map getOvertime4ComputingMode2(String resourceId, String searchDateFrom, String searchDateTo) { + Map resultMap = new HashMap(); + try { + String paidLeaveEnable = Util.null2String(params.get("paidLeaveEnable")); + + String belongDateWhere = ""; + if (searchDateFrom.length() > 0 && searchDateTo.length() > 0) { + belongDateWhere += " and ( belongdate between '" + searchDateFrom + "' and '" + searchDateTo + "' or belongdate between '" + searchDateFrom + "' and '" + searchDateTo + "' " + + " or '" + searchDateFrom + "' between belongdate and belongdate or '" + searchDateTo + "' between belongdate and belongdate) "; + } + String paidLeaveEnableWhere = ""; + if ("0".equalsIgnoreCase(paidLeaveEnable) || "1".equalsIgnoreCase(paidLeaveEnable)) { + paidLeaveEnableWhere += " and paidLeaveEnable=" + paidLeaveEnable; + } + String overtimeTable = " select requestid,resourceid,fromdate,fromtime,todate,totime,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,duration_min from kq_flow_overtime where computingmode = 2 " + + (belongDateWhere.length() == 0 ? "" : belongDateWhere) + + (paidLeaveEnableWhere.length() == 0 ? "" : paidLeaveEnableWhere); + + String backFields = " * "; + String fromSql = " (select b.lastname,b.loginid,b.subcompanyid1,b.departmentid,b.jobtitle,b.managerid,b.managerstr,a.* from (" + overtimeTable + ") a left join hrmresource b on a.resourceid = b.id) f "; + String sqlWhere = " 1=1 "; + String orderBy = " computingMode "; + if (resourceId.length() > 0) { + sqlWhere += " and resourceId in(" + resourceId + ")"; + } + String sql = "select " + backFields + " from " + fromSql + " where " + sqlWhere + " order by " + orderBy; + resultMap = executeSQL(sql, "2"); + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + private Map getOvertime4ComputingMode3(String resourceId, String searchDateFrom, String searchDateTo) { + Map resultMap = new HashMap(); + try { + String paidLeaveEnable = Util.null2String(params.get("paidLeaveEnable")); + + String belongDateWhere = ""; + if (searchDateFrom.length() > 0 && searchDateTo.length() > 0) { + belongDateWhere += " and ( belongdate between '" + searchDateFrom + "' and '" + searchDateTo + "' or belongdate between '" + searchDateFrom + "' and '" + searchDateTo + "' " + + " or '" + searchDateFrom + "' between belongdate and belongdate or '" + searchDateTo + "' between belongdate and belongdate) "; + } + String paidLeaveEnableWhere = ""; + if ("0".equalsIgnoreCase(paidLeaveEnable) || "1".equalsIgnoreCase(paidLeaveEnable)) { + paidLeaveEnableWhere += " and paidLeaveEnable=" + paidLeaveEnable; + } + String overtimeTable = " select requestid,resourceid,fromdate,fromtime,todate,totime,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,duration_min from kq_flow_overtime where computingmode = 3 " + + (belongDateWhere.length() == 0 ? "" : belongDateWhere) + + (paidLeaveEnableWhere.length() == 0 ? "" : paidLeaveEnableWhere); + + String backFields = " * "; + String fromSql = " (select b.lastname,b.loginid,b.subcompanyid1,b.departmentid,b.jobtitle,b.managerid,b.managerstr,a.* from (" + overtimeTable + ") a left join hrmresource b on a.resourceid = b.id) f "; + String sqlWhere = " 1=1 "; + String orderBy = " computingmode "; + if (resourceId.length() > 0) { + sqlWhere += " and resourceId in(" + resourceId + ")"; + } + String sql = "select " + backFields + " from " + fromSql + " where " + sqlWhere + " order by " + orderBy; + resultMap = executeSQL(sql, "3"); + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + private Map getOvertime4ComputingMode4(String resourceId, String searchDateFrom, String searchDateTo) { + Map resultMap = new HashMap(); + try { + String paidLeaveEnable = Util.null2String(params.get("paidLeaveEnable")); + + String belongDateWhere = ""; + if (searchDateFrom.length() > 0 && searchDateTo.length() > 0) { + belongDateWhere += " and ( belongdate between '" + searchDateFrom + "' and '" + searchDateTo + "' or belongdate between '" + searchDateFrom + "' and '" + searchDateTo + "' " + + " or '" + searchDateFrom + "' between belongdate and belongdate or '" + searchDateTo + "' between belongdate and belongdate) "; + } + String paidLeaveEnableWhere = ""; + if ("0".equalsIgnoreCase(paidLeaveEnable) || "1".equalsIgnoreCase(paidLeaveEnable)) { + paidLeaveEnableWhere += " and paidLeaveEnable=" + paidLeaveEnable; + } + String overtimeTable = " select requestid,resourceid,fromdate,fromtime,todate,totime,fromdatedb,fromtimedb,todatedb,totimedb,computingmode,paidLeaveEnable,expiringdate,duration_min from kq_flow_overtime where computingmode = 4 " + + (belongDateWhere.length() == 0 ? "" : belongDateWhere) + + (paidLeaveEnableWhere.length() == 0 ? "" : paidLeaveEnableWhere); + + String backFields = " * "; + String fromSql = " (select b.lastname,b.loginid,b.subcompanyid1,b.departmentid,b.jobtitle,b.managerid,b.managerstr,a.* from (" + overtimeTable + ") a left join hrmresource b on a.resourceid = b.id) f "; + String sqlWhere = " 1=1 "; + String orderBy = " computingmode "; + if (resourceId.length() > 0) { + sqlWhere += " and resourceId in(" + resourceId + ")"; + } + String sql = "select " + backFields + " from " + fromSql + " where " + sqlWhere + " order by " + orderBy; + resultMap = executeSQL(sql, "4"); + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + private Map executeSQL(String sql, String computingMode) { + Map resultMap = new HashMap(); + try { + String computingModeShow = ""; + if ("1".equals(computingMode)) { + computingModeShow += SystemEnv.getHtmlLabelName(500382, user.getLanguage());//需审批,以加班流程为准 + } else if ("2".equals(computingMode)) { + computingModeShow += SystemEnv.getHtmlLabelName(500383, user.getLanguage());//需审批,以打卡为准,但是不能超过加班流程时长 + } else if ("3".equals(computingMode)) { + computingModeShow += SystemEnv.getHtmlLabelName(390837, user.getLanguage());//无需审批,根据打卡时间计算加班时长 + } else if ("4".equals(computingMode)) { + computingModeShow += SystemEnv.getHtmlLabelName(524827, user.getLanguage());//打卡审批交集 + } + + KQTransMethod kqTransMethod = new KQTransMethod(); + TransMethod transMethod = new TransMethod(); + Map itemMap = new HashMap(); + List> itemList = new ArrayList>(); + List dataList = new ArrayList(); + + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String requestId = recordSet.getString("requestId"); + String resourceId = recordSet.getString("resourceId"); + String fromDate = recordSet.getString("fromdate"); + String fromTime = recordSet.getString("fromtime"); + String toDate = recordSet.getString("todate"); + String toTime = recordSet.getString("toTime"); + if("4".equals(computingMode) || "2".equals(computingMode)){ +// fromdatedb,fromtimedb,todatedb,totimedb + fromDate = recordSet.getString("fromdatedb"); + fromTime = recordSet.getString("fromtimedb"); + toDate = recordSet.getString("todatedb"); + toTime = recordSet.getString("totimedb"); + } + + String duration_min = transMethod.getDuration_minByUnit(recordSet.getString("duration_min")); + String paidLeaveEnable = transMethod.getPaidLeaveEnable(recordSet.getString("PaidLeaveEnable"), "" + user.getLanguage()); + + String key = requestId + "|" + resourceId + "|" + fromDate + "|" + fromTime + "|" + toDate + "|" + toTime; + + itemList = new ArrayList>(); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(740, user.getLanguage())); + itemMap.put("key", "fromDate"); + itemMap.put("value", fromDate); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(742, user.getLanguage())); + itemMap.put("key", "fromTime"); + itemMap.put("value", fromTime); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(741, user.getLanguage())); + itemMap.put("key", "toDate"); + itemMap.put("value", toDate); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(743, user.getLanguage())); + itemMap.put("key", "toTime"); + itemMap.put("value", toTime); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(509604, user.getLanguage())); + itemMap.put("key", "duration_min"); + itemMap.put("value", duration_min); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(125804, user.getLanguage())); + itemMap.put("key", "paidLeaveEnable"); + itemMap.put("value", paidLeaveEnable); + itemList.add(itemMap); + itemMap = new HashMap(); + itemMap.put("label", SystemEnv.getHtmlLabelName(26408, user.getLanguage())); + itemMap.put("key", "computingMode"); + itemMap.put("value", computingModeShow); + itemList.add(itemMap); + + resultMap.put(key, itemList); + } + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/myattendance/GetHrmKQMonthReportInfoCmd.java b/src/com/engine/kq/cmd/myattendance/GetHrmKQMonthReportInfoCmd.java new file mode 100644 index 0000000..0dfae15 --- /dev/null +++ b/src/com/engine/kq/cmd/myattendance/GetHrmKQMonthReportInfoCmd.java @@ -0,0 +1,1228 @@ +package com.engine.kq.cmd.myattendance; + +import com.api.hrm.bean.KQReportType; +import com.api.hrm.util.HrmTransMethod; +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.entity.WorkTimeEntity; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.wfset.util.KQSignUtil; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.engine.kq.wfset.util.SplitSelectSet; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +/** + * 前台--人事--我的考勤 + */ +public class GetHrmKQMonthReportInfoCmd extends AbstractCommonCommand> { + + public GetHrmKQMonthReportInfoCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + private static boolean isIndirectSuperId(String id,String checkSuperId,ResourceComInfo info){ + + int loopBreakTimes = 20 ; + for(String loopId = id; + isRightResourceId(loopId) && (loopBreakTimes--)>0 ; + loopId = info.getManagerID(loopId)){ + if(isDirectSuperId(loopId,checkSuperId,info)) return true ; + } + return false ; + } + + private static boolean isDirectSuperId(String id,String checkSuperId,ResourceComInfo info){ + String superId = Util.null2String(info.getManagerID(id)) ; + return isRightResourceId(superId) && superId.equals(checkSuperId) ; + } + + private static boolean isRightResourceId(String id){ + return StringUtils.isNotBlank(id) && !"0".equals(id) ; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + String nowdate = DateUtil.getCurrentDate(); + String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据:1-年、2-月 + String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份 + String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点 + String toDate = Util.null2String(params.get("toDate"));//指定日期终点 + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0);//指定查看的人员的所属分部 + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0);//指定查看的人员的所属部门 + String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID + String status = Util.null2String(params.get("status"));//? + /** + * 若未指定查看人员,则默认为当前登录人员 + */ + if (resourceId.length() == 0) { + resourceId = "" + user.getUID(); + } + ResourceComInfo resourceComInfo = new ResourceComInfo(); + if (subCompanyId == 0 || departmentId == 0) { + subCompanyId = Util.getIntValue(resourceComInfo.getSubCompanyID(resourceId), 0); + departmentId = Util.getIntValue(resourceComInfo.getDepartmentID(resourceId), 0); + } + String lastName = resourceComInfo.getResourcename(resourceId); + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(513535, user.getLanguage())); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(515563, user.getLanguage()).replace("{name}", lastName)); + } + /** + * 判断是否有权限查看 + */ + if (!resourceId.equals("" + user.getUID()) && !isIndirectSuperId(resourceId, user.getUID() + "", resourceComInfo) && !HrmUserVarify.checkUserRight("HrmResource:Absense", user, departmentId)) { + resultMap.put("status", "-1"); + resultMap.put("hasRight", false); + return resultMap; + } + + /** + * 获取指定日期范围的起点和终点 + */ + if (type.equals("1")) {//年 + if (typevalue.length() == 0 || typevalue.length() != 4) { + typevalue = DateUtil.getYear(); + } + fromDate = typevalue + "-01-01"; + toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate)); + } else if (type.equals("2")) {//月 + if (typevalue.length() == 0) { + typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth(); + } + fromDate = typevalue + "-01"; + toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate)); + } + + Map year = new HashMap(); + Map month = new HashMap(); + Map day = new HashMap(); + + // 没有权限的人最大只支持查询本季 + Map getRealDate = new KQReportBiz().realDate(fromDate, toDate, user, "1"); + String realFromDate = getRealDate.get("fromDate"); + String realToDate = getRealDate.get("toDate"); + if("-1".equals(realFromDate) || "-1".equals(realToDate)) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(543747, user.getLanguage())); + return resultMap; + } + + /**获取今天的日期*/ + Calendar today = Calendar.getInstance(); + String currentdate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + /**判断是否在考勤日历上显示签到签退数据*/ + boolean showSign = true; + String settingSql = "select * from KQ_SETTINGS where main_key='showSignOnCalendar'"; + RecordSet rs = new RecordSet(); + rs.executeQuery(settingSql); + if (rs.next()) { + String main_val = rs.getString("main_val"); + showSign = main_val.equals("1"); + } + + //签到签退明细 + Map signInfoMap = getSignInfo(); + List> signInfoList = new ArrayList>(); + //休息明细(统计工作日) + List isNotRestList = new ArrayList(); + //迟到明细 + List beLateList = new ArrayList(); + //早退明细 + List leaveEarlyList = new ArrayList(); + //旷工明细 + List absentList = new ArrayList(); + //漏签明细 + List noSignList = new ArrayList(); + //请假明细 + Map leaveMap = getFlowData(KqSplitFlowTypeEnum.LEAVE.getFlowtype()); + //出差明细 + Map evectionMap = getFlowData(KqSplitFlowTypeEnum.EVECTION.getFlowtype()); + //公出明细 + Map outDaysMap = getFlowData(KqSplitFlowTypeEnum.OUT.getFlowtype()); + //加班明细 + Map overtimeMap = getFlowData(KqSplitFlowTypeEnum.OVERTIME.getFlowtype()); + //调配工作日 + List workdayList = new ArrayList(); + //调配休息日、公众假日 + List holidayList = new ArrayList(); + + //获取节假日 + List> tempList = KQHolidaySetBiz.getHolidaySetListByScope(resourceId, fromDate, toDate); + for (Map tempMap : tempList) { + String date = Util.null2String(tempMap.get("date")); + int changeType = Util.getIntValue((String) tempMap.get("type"), 1); + if (changeType == 1 || changeType == 3) { + holidayList.add(date); + } else if (changeType == 2) { + workdayList.add(date); + } + } + + String sql = "select * from kq_format_detail where resourceId=" + resourceId + " and KQDate>='" + fromDate + "' and KQDate<='" + toDate + "' order by kqDate"; + RecordSet recordSet = new RecordSet(); + RecordSet detailRs = new RecordSet(); + recordSet.executeQuery(sql); + KQWorkTime kqWorkTime = new KQWorkTime(); + while (recordSet.next()) { + String kqDate = recordSet.getString("kqDate"); + String serialId = recordSet.getString("serialId"); + + WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceId,kqDate); + String dayType = workTime.getDayType(); + boolean isWorkDay = "work".equalsIgnoreCase(dayType); + if (!isNotRestList.contains(kqDate) && isWorkDay) { + isNotRestList.add(kqDate); + }else if(Util.null2String(workTime.getKQType()).equals("3")){ + if(workTime!=null&&Util.getIntValue(workTime.getWorkMins())>0) { + isNotRestList.add(kqDate); +// groupid = Util.null2String(workTime.getGroupId()); +// signstart = Util.null2String(workTime.getSignStart());//签到开始时间 +// workMins = Util.getIntValue(Util.null2String(workTime.getWorkMins()));//工作时长 + } + } + + int beLate = recordSet.getInt("beLateMins");//迟到 + int graveBeLate = recordSet.getInt("graveBeLateMins");//严重迟到 + int leaveEarly = recordSet.getInt("leaveEarlyMins");//早退 + int graveLeaveEarly = recordSet.getInt("graveLeaveEarlyMins");//严重早退 + int absenteeism = recordSet.getInt("absenteeismMins");//旷工 + int forgotCheck = recordSet.getInt("forgotCheckMins");//下班打卡漏签 + int forgotBeginWorkCheckMins = recordSet.getInt("forgotBeginWorkCheckMins");//上班打卡漏签 + if (absenteeism > 0) {//旷工 + absentList.add(kqDate); + } else { + if (beLate > 0 || graveBeLate > 0) { //迟到 + beLateList.add(kqDate); + } + if (leaveEarly > 0 || graveLeaveEarly > 0) {//早退 + leaveEarlyList.add(kqDate); + } + if (forgotCheck > 0 || forgotBeginWorkCheckMins > 0) {//漏签 + noSignList.add(kqDate); + } + } + } + + List types = new ArrayList(); + List> lsWorkflow = new ArrayList>(); + Map workflow = new HashMap(); + + boolean isEnd = false; + for (String date = fromDate; !isEnd; ) { + String tmpMonth = "" + Util.getIntValue(date.split("-")[1]); + String tmpDay = "" + Util.getIntValue(date.split("-")[2]); + if (date.compareTo(toDate) >= 0) { + isEnd = true; + } + /*如果是按年份查看*/ + if (type.equals("1")) { + if (!year.containsKey(tmpMonth)) { + month = new HashMap(); + year.put(tmpMonth, month); + } + } + + day = new HashMap(); + month.put(tmpDay, day); + if (isNotRestList.contains(date)) { + day.put("isWorkDay", true); + } else { + day.put("isWorkDay", false); + } + if (type.equals("1")) { + day.put("tip", ""); + } + if (holidayList.contains(date)) { + day.put("tip", SystemEnv.getHtmlLabelName(125806, user.getLanguage())); + day.put("isWorkDay", false); + } else if (workdayList.contains(date)) { + day.put("tip", SystemEnv.getHtmlLabelName(125807, user.getLanguage())); + day.put("isWorkDay", true); + } + day.put("date", date); + types = new ArrayList(); + if (type.equals("2")) { + day.put("types", types); + } + lsWorkflow = new ArrayList>(); + /*只有月视图才显示流程数据、只有月视图才把签到签退信息显示在日历上*/ + if (type.equals("2") && showSign) { + signInfoList = (List)signInfoMap.get(date); + if (signInfoList != null && signInfoList.size() > 0) { + day.put("signInfo", signInfoList); + } + } + /*只有月视图才显示流程数据*/ + if (type.equals("2")) { + day.put("workflow", lsWorkflow); + } + boolean isNormal = true; + //迟到明细 + if (beLateList.contains(date)) { + if (!types.contains(KQReportType.BELATE)) { + types.add(KQReportType.BELATE); + isNormal = false; + } + } + + //旷工明细 + if (absentList.contains(date)) { + if (!types.contains(KQReportType.ABSENT)) { + types.add(KQReportType.ABSENT); + isNormal = false; + } + } + + //早退明细 + if (leaveEarlyList.contains(date)) { + if (!types.contains(KQReportType.LEAVEEARLY)) { + types.add(KQReportType.LEAVEEARLY); + isNormal = false; + } + } + + //漏签明细 + if (noSignList.contains(date)) { + if (!types.contains(KQReportType.NOSIGN)) { + types.add(KQReportType.NOSIGN); + isNormal = false; + } + } + + //请假明细 + if (leaveMap.containsKey(resourceId + "|" + date)) { + if (!types.contains(KQReportType.LEAVE)) { + types.add(KQReportType.LEAVE); + isNormal = false; + } + tempList = (List>) leaveMap.get(resourceId + "|" + date); + for (Map tempMap : tempList) { + lsWorkflow.add(tempMap); + } + } + + //加班明细 + if (!Util.null2String(overtimeMap.get(resourceId + "|" + date)).equals("")) { + if (!types.contains(KQReportType.OVERTIME)) { + types.add(KQReportType.OVERTIME); + } + tempList = (List>) overtimeMap.get(resourceId + "|" + date); + for (Map tempMap : tempList) { + lsWorkflow.add(tempMap); + } + } + + //外出明细 + if (evectionMap.containsKey(resourceId + "|" + date)) { + if (!types.contains(KQReportType.EVECTION)) { + types.add(KQReportType.EVECTION); + isNormal = false; + } + tempList = (List>) evectionMap.get(resourceId + "|" + date); + for (Map tempMap : tempList) { + lsWorkflow.add(tempMap); + } + } + + //公出明细 + if (outDaysMap.containsKey(resourceId + "|" + date)) { + if (!types.contains(KQReportType.OUTDAYS)) { + types.add(KQReportType.OUTDAYS); + isNormal = false; + } + tempList = (List>) outDaysMap.get(resourceId + "|" + date); + for (Map tempMap : tempList) { + lsWorkflow.add(tempMap); + } + } + + if (isNotRestList.contains(date) && DateUtil.isInDateRange(date, fromDate, nowdate)) { + if (isNormal) { + types.add(KQReportType.NORMAL); + } + } + + if (type.equals("1")) { + day.put("type", types.size() > 0 ? types.get(0) : "NORMAL"); + } + date = DateUtil.getDate(date, 1); + } + if (type.equals("1")) { + resultMap.put("result", year); + } else { + resultMap.put("result", month); + } + resultMap.put("status", "1"); + } catch (Exception e) { + resultMap.put("api_status", false); + resultMap.put("api_errormsg", e.getMessage()); + writeLog(e); + } + return resultMap; + } + + /** + * 获取指定人员在指定时间范围内的流程集合 + * + * @return + */ + public Map getFlowData(int flowType) { + Map resultMap = new HashMap(); + try { + String nowdate = DateUtil.getCurrentDate(); + String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据:1-年、2-月 + String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份 + String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点 + String toDate = Util.null2String(params.get("toDate"));//指定日期终点 + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0);//指定查看的人员的所属分部 + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0);//指定查看的人员的所属部门 + String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID + String status = Util.null2String(params.get("status"));//? + + /** + * 若未指定查看人员,则默认为当前登录人员 + */ + if (resourceId.length() == 0) { + resourceId = "" + user.getUID(); + } + + /** + * 获取指定日期的起点和终点 + */ + if (type.equals("1")) {//年 + if (typevalue.length() == 0 || typevalue.length() != 4) { + typevalue = DateUtil.getYear(); + } + fromDate = typevalue + "-01-01"; + toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate)); + } else if (type.equals("2")) {//月 + if (typevalue.length() == 0) { + typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth(); + } + fromDate = typevalue + "-01"; + toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate)); + } + + /**获取销假*/ + List leaveBackList = getLeaveDate(); + + KQExitRulesComInfo exitRulesComInfo = new KQExitRulesComInfo(); + KQTravelRulesComInfo travelRulesComInfo = new KQTravelRulesComInfo(); + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + KQTimeSelectionComInfo kqTimeSelectionComInfo = new KQTimeSelectionComInfo(); + KQWorkTime kqWorkTime = new KQWorkTime(); + + boolean showOnHoliday = true;//非工作日是否显示流程(出差、公出、请假) + + String timeselection = "1"; + String selectiontype = ""; + String typeName = ""; + KQReportType workflowType = null; + switch (flowType) { + case 3://加班 + typeName = SystemEnv.getHtmlLabelName(6151, user.getLanguage()); + workflowType = KQReportType.OVERTIME; + selectiontype = ""+KqSplitFlowTypeEnum.OVERTIME.getFlowtype(); + timeselection = KQOvertimeRulesBiz.getTimeselection(); + break; + case 2://公出 + typeName = SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + workflowType = KQReportType.OUTDAYS; + showOnHoliday = exitRulesComInfo.getComputingMode("1").equals("2"); + selectiontype = ""+KqSplitFlowTypeEnum.OUT.getFlowtype(); + timeselection = KQExitRulesBiz.getTimeselection(); + break; + case 1://出差 + typeName = SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + workflowType = KQReportType.EVECTION; + showOnHoliday = travelRulesComInfo.getComputingMode("1").equals("2"); + selectiontype = ""+KqSplitFlowTypeEnum.EVECTION.getFlowtype(); + timeselection = KQTravelRulesBiz.getTimeselection(); + break; + case 0://请假 + typeName = SystemEnv.getHtmlLabelName(670, user.getLanguage()); + workflowType = KQReportType.LEAVE; + selectiontype = ""+KqSplitFlowTypeEnum.LEAVE.getFlowtype(); + break; + default: + break; + } + + /** + * 获取数据集合 + */ + List> workflowList = new ArrayList>(); + Map workflowMap = new HashMap(); + + Map paramsMap = new HashMap(); + paramsMap.put("typeselect", "6"); + paramsMap.put("tabKey", "1"); + paramsMap.put("kqtype", "" + flowType); + paramsMap.put("resourceId", resourceId); + paramsMap.put("fromDate", fromDate); + paramsMap.put("toDate", toDate); + paramsMap.put("isMyKQ", "1"); + paramsMap.put("isNoAccount","1"); + + KQAttFlowSetBiz kqAttFlowSetBiz = new KQAttFlowSetBiz(); + Map sqlMap = kqAttFlowSetBiz.getFLowSql(paramsMap, user); + String sqlFrom = sqlMap.get("from"); + String sqlWhere = sqlMap.get("where"); + + String sql = "select * " + sqlFrom + sqlWhere; + RecordSet recordSet = new RecordSet(); + + Map overtimemap = new HashMap<>(); + if(flowType == 3){ +// String overtimesql = "select * from kq_flow_split_overtime where belongdate>='"+fromDate+"' and belongdate<='"+toDate+"'"; +// recordSet.executeQuery(overtimesql); +// while(recordSet.next()){ +// String resourceid = recordSet.getString("resourceid"); +// String requestid = recordSet.getString("requestid"); +// String belongdate = recordSet.getString("belongdate"); +// String fromDatedb = recordSet.getString("fromDatedb"); +// String fromTimeTemp = recordSet.getString("fromTimedb"); +// String toDatedb = recordSet.getString("toDatedb"); +// String toTimeTemp = recordSet.getString("toTimedb"); +// if(belongdate.compareTo(fromDatedb)<0 || belongdate.compareTo(toDatedb)>0){//比如加班是2月1号,但是属于前一天1月31 +// overtimemap.put(resourceid+"|belongdate",belongdate); +// overtimemap.put(resourceid+"|fromdatedb",fromDatedb); +// overtimemap.put(resourceid+"|fromtimedb",fromTimeTemp); +// overtimemap.put(resourceid+"|todatedb",toDatedb); +// overtimemap.put(resourceid+"|totimedb",toTimeTemp); +// overtimemap.put(resourceid+"|requestid",requestid); +// } +// } + recordSet.writeLog("hef>>>>>>>>sql>>>>>>>>>>>"+sql); + } + + recordSet.writeLog("month.sql="+sql); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String resourceid = recordSet.getString("resourceid"); + String requestId = recordSet.getString("requestId"); + double duration = Util.getDoubleValue(recordSet.getString("duration"), 0.00); + double backDuration = 0.00; + int durationrule = recordSet.getInt("durationrule"); + String fromDateTemp = recordSet.getString("fromDate"); + String fromTimeTemp = recordSet.getString("fromTime"); + String toDateTemp = recordSet.getString("toDate"); + String toTimeTemp = recordSet.getString("toTime"); + if (duration <= 0) { + continue; + } + String belongdate = ""; +// if(flowType == 3 && null != overtimemap && overtimemap.containsKey(resourceid+"|requestid")){ +// String tmp_fromdatedb = overtimemap.get(resourceid+"|fromdatedb");//存在一个requestid对应多个加班明细的情况,需要把没有跨天归属的过滤掉 +// String tmp_fromtimedb = overtimemap.get(resourceid+"|fromtimedb"); +// String tmp_todatedb = overtimemap.get(resourceid+"|todatedb"); +// String tmp_totimedb = overtimemap.get(resourceid+"|totimedb"); +// String tmp_requestid = overtimemap.get(resourceid+"|requestid"); +// if(requestId.equals(tmp_requestid) && fromTimeTemp.equals(tmp_fromtimedb) && toTimeTemp.equals(tmp_totimedb)){ +//// belongdate = overtimemap.get(resourceid+"|belongdate"); +// } +// } + + String leaveRulesId = ""; + String filterholidays = ""; + String count = String.format("%.2f", duration) + "(" + ((durationrule == 3||durationrule == 5||durationrule == 6) ? SystemEnv.getHtmlLabelName(391, user.getLanguage()) : SystemEnv.getHtmlLabelName(1925, user.getLanguage())) + ")"; + if(flowType == 3){ + count = String.format("%.2f", duration) + "(" + ((durationrule == 3||durationrule == 5||durationrule == 6) ? SystemEnv.getHtmlLabelName(391, user.getLanguage()) : SystemEnv.getHtmlLabelName(1925, user.getLanguage())) + ")"; + } + if (flowType == 0) { + backDuration = Util.getDoubleValue(recordSet.getString("backDuraion"), 0.00); + if (backDuration > 0) { + count = String.format("%.2f", duration) + "(" + (SystemEnv.getHtmlLabelName(24473, user.getLanguage()) + ":" + String.format("%.2f", backDuration)) + ")" + ((durationrule == 3||durationrule == 5||durationrule == 6) ? SystemEnv.getHtmlLabelName(391, user.getLanguage()) : SystemEnv.getHtmlLabelName(1925, user.getLanguage())); + } + leaveRulesId = recordSet.getString("newleavetype"); + String computingMode = rulesComInfo.getComputingMode(leaveRulesId); + if("2".equalsIgnoreCase(computingMode)){ + //按照自然日计算 + showOnHoliday = true; + filterholidays= rulesComInfo.getFilterHolidays(leaveRulesId); + } else { + + showOnHoliday = false; + } + typeName = Util.formatMultiLang(rulesComInfo.getLeaveName(leaveRulesId), "" + user.getLanguage()); + } + String start = fromDateTemp + " " + fromTimeTemp; + String end = toDateTemp + " " + toTimeTemp; + if (2 == durationrule || 4 == durationrule) { + if (2 == durationrule) { + if(leaveRulesId.length() > 0){ + timeselection = rulesComInfo.getTimeSelection(leaveRulesId); + } + if("1".equalsIgnoreCase(timeselection)){ + Map half_map = kqTimeSelectionComInfo.getTimeselections(selectiontype,leaveRulesId,durationrule+""); + String cus_am = SystemEnv.getHtmlLabelName(16689, user.getLanguage()); + String cus_pm = SystemEnv.getHtmlLabelName(16690, user.getLanguage()); + if(half_map != null && !half_map.isEmpty()){ + cus_am = Util.null2String(half_map.get("half_on")); + cus_pm = Util.null2String(half_map.get("half_off")); + } + if (fromTimeTemp.equalsIgnoreCase(SplitSelectSet.forenoon_start)) { + start = fromDateTemp + " " + cus_am; + } else if (fromTimeTemp.equalsIgnoreCase(SplitSelectSet.forenoon_end)) { + start = fromDateTemp + " " + cus_pm; + } + + if (toTimeTemp.equalsIgnoreCase(SplitSelectSet.afternoon_start)) { + end = toDateTemp + " " + cus_am; + } else if (toTimeTemp.equalsIgnoreCase(SplitSelectSet.afternoon_end)) { + end = toDateTemp + " " + cus_pm; + } + } + } + if (4 == durationrule) { + if (fromTimeTemp.equalsIgnoreCase(SplitSelectSet.forenoon_start)) { + start = fromDateTemp + " " + SystemEnv.getHtmlLabelName(390728, user.getLanguage()); + } + + if (toTimeTemp.equalsIgnoreCase(SplitSelectSet.afternoon_end)) { + end = toDateTemp + " " + SystemEnv.getHtmlLabelName(390728, user.getLanguage()); + } + } + } + + //加班存在跨月的情况,比如2023年1月31夜班【20:00-08:00】,2023年2月1是白班【09:00-18:00】,申请加班2023年2月1【18:00-20:00】的加班, + //因为默认归属逻辑,该加班归属到前一天(2023年1月31号),而我的考勤日历上显示又是根据fromdatedb和todatedb来展示,导致错开该加班流程1月31不显示,2月1也不显示 + //所以按归属日期belongdate来匹配,否则下面的fromDateTemp=2023-02-01,todateTemp=2023-02-01,匹配不到 +// if(!"".equals(belongdate)){ +// fromDateTemp = belongdate;//加班只有跨前一天的,todateTemp不需要搞了 +// } + if(fromDateTemp.compareTo(toDateTemp) > 0) { + recordSet.writeLog("hef>>>>>>>开始日期大于结束日期>>>fromDateTemp>>>"+fromDateTemp + +">>>>toDateTemp>>>"+toDateTemp+">>>>>requestid>>>>>"+requestId); + continue; + } + boolean isEnd = false; + int overtimeCount = 0; + for (String date = fromDateTemp; !isEnd; ) { + if (date.equals(toDateTemp)) { + isEnd = true; + } + overtimeCount++; + if(overtimeCount > 365) { + break; + } + if(isEnd && "00:00".equals(toTimeTemp)){//最后一天,如果totime=00:00 + continue; + } + boolean isWorkDay = kqWorkTime.isWorkDay(resourceId, date); + if(!isWorkDay && !showOnHoliday) { + date = DateUtil.getDate(date, 1); + continue; + } + if (!leaveBackList.contains(resourceId + "|" + date + "|" + requestId)) { + workflowList = (ArrayList>) resultMap.get(resourceId + "|" + date); + if (null == workflowList) { + workflowList = new ArrayList>(); + } + workflowMap = new HashMap(); + workflowMap.put("count", count); + workflowMap.put("start", start); + workflowMap.put("end", end); + workflowMap.put("type", typeName); + workflowMap.put("workflowtype", workflowType); + workflowMap.put("requestId", requestId); + workflowMap.put("title", "" + typeName + ""); + workflowList.add(workflowMap); + + if (!(!isWorkDay && !showOnHoliday)) { + SplitActionUtil splitActionUtil = new SplitActionUtil(); + boolean is_filterholidays = splitActionUtil.check_filterholidays(filterholidays, resourceId, date, 1); + if(!is_filterholidays){ + resultMap.put(resourceId + "|" + date, workflowList); + } + } + } + + date = DateUtil.getDate(date, 1); + } + } + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + /** + * 获取请完假之后又销掉的日期 + * + * @return + */ + private List getLeaveDate() { + List resultList = new ArrayList(); + try { + String nowdate = DateUtil.getCurrentDate(); + String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据:1-年、2-月 + String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份 + String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点 + String toDate = Util.null2String(params.get("toDate"));//指定日期终点 + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0);//指定查看的人员的所属分部 + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0);//指定查看的人员的所属部门 + String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID + String status = Util.null2String(params.get("status"));//? + + /** + * 若未指定查看人员,则默认为当前登录人员 + */ + if (resourceId.length() == 0) { + resourceId = "" + user.getUID(); + } + + /** + * 获取指定日期的起点和终点 + */ + if (type.equals("1")) {//年 + if (typevalue.length() == 0 || typevalue.length() != 4) { + typevalue = DateUtil.getYear(); + } + fromDate = typevalue + "-01-01"; + toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate)); + } else if (type.equals("2")) {//月 + if (typevalue.length() == 0) { + typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth(); + } + fromDate = typevalue + "-01"; + toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate)); + } + + String leaveBackTableName = KqSplitFlowTypeEnum.LEAVEBACK.getTablename(); + String leaveTableName = KqSplitFlowTypeEnum.LEAVE.getTablename(); + String sql = " select requestId,resourceId,belongDate,duration,durationRule," + + " (select sum(duration) from " + leaveBackTableName + " where " + leaveBackTableName + ".leavebackrequestid=" + leaveTableName + ".requestid " + + " and " + leaveBackTableName + ".newleavetype=" + leaveTableName + ".newleavetype " + + " and " + leaveBackTableName + ".resourceId=" + leaveTableName + ".resourceId " + + " and " + leaveBackTableName + ".belongdate=" + leaveTableName + ".belongDate ) as backDuration " + + " from " + leaveTableName + " where 1=1 "; + if (!resourceId.equals("")) { + sql += " and " + leaveTableName + ".resourceId=" + resourceId; + } + if (fromDate.length() > 0 && toDate.length() > 0) { + sql += " and " + leaveTableName + ".belongdate between'" + fromDate + "' and '" + toDate + "' "; + } + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String requestId = recordSet.getString("requestId"); + String belongDate = recordSet.getString("belongDate"); + double duration = Util.getDoubleValue(recordSet.getString("duration"), 0.00); + if (duration <= 0) { + continue; + } + double backDuration = Util.getDoubleValue(recordSet.getString("backDuration"), 0.00); + if (backDuration >= duration) { + resultList.add(resourceId + "|" + belongDate + "|" + requestId); + } + } + } catch (Exception e) { + writeLog(e); + } + return resultList; + } + + /** + * 获取某段时间内的所有签到签退信息 + * + * @return + */ + private Map getSignInfo() { + Map resultMap = new HashMap(); + try { + String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据:1-年、2-月 + String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份 + String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点 + String toDate = Util.null2String(params.get("toDate"));//指定日期终点 + String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID + + /** + * 若未指定查看人员,则默认为当前登录人员 + */ + if (resourceId.length() == 0) { + resourceId = "" + user.getUID(); + } + + /** + * 获取指定日期的起点和终点 + */ + if (type.equals("1")) {//年 + if (typevalue.length() == 0 || typevalue.length() != 4) { + typevalue = DateUtil.getYear(); + } + fromDate = typevalue + "-01-01"; + toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate)); + } else if (type.equals("2")) {//月 + if (typevalue.length() == 0) { + typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth(); + } + fromDate = typevalue + "-01"; + toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate)); + } + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + /** + * 判断是否显示补打卡数据 + */ + RecordSet recordSet = new RecordSet(); + boolean showCard = false; + String settingSql = "select * from KQ_SETTINGS where main_key='showSignFromCard'"; + recordSet.executeQuery(settingSql); + if (recordSet.next()) { + String main_val = recordSet.getString("main_val"); + showCard = main_val.equals("1"); + } + + SignInfo signInfo = null; + Map signInfoMap = new LinkedHashMap(); + + String sql = "SELECT a.kqdate,a.resourceId,a.serialNumber,a.workMins,a.day_type,a.serialId,'signIn' signType,a.signInDate signDate,a.signInTime signTime,b.clientAddress,b.addr,b.attachment FROM KQ_FORMAT_DETAIL a LEFT JOIN HrmScheduleSign b ON a.signInId=b.id WHERE 1=1 AND resourceId=" + resourceId + "\n "; + if (!showCard) { + sql += " AND (signFrom is null or signFrom not like 'card%') "; + } + if (!"".equals(fromDate)) { + sql += " AND kqDate>='" + fromDate + "' "; + } + if (!"".equals(toDate)) { + sql += " AND kqDate<='" + toDate + "' "; + } + sql += " UNION ALL\n " + + "SELECT a.kqdate,a.resourceId,a.serialNumber,a.workMins,a.day_type,a.serialId,'signOut' signType,a.signOutDate signDate,a.signOutTime signTime,b.clientAddress,b.addr,b.attachment FROM KQ_FORMAT_DETAIL a LEFT JOIN HrmScheduleSign b ON a.signOutId=b.id WHERE 1=1 AND resourceId=" + resourceId + "\n "; + if (!showCard) { + sql += " AND (signFrom is null or signFrom not like 'card%') "; + } + if (!"".equals(fromDate)) { + sql += " AND kqDate>='" + fromDate + "' "; + } + if (!"".equals(toDate)) { + sql += " AND kqDate<='" + toDate + "' "; + } + sql += "ORDER BY kqDate,resourceId,serialNumber,signType "; + recordSet.executeQuery(sql); + while (recordSet.next()) { + String kqDate = Util.null2String(recordSet.getString("kqDate")); + String signType = Util.null2String(recordSet.getString("signType")); + String signDate = Util.null2String(recordSet.getString("signDate")); + String signTime = Util.null2String(recordSet.getString("signTime")); + String serialId = Util.null2String(recordSet.getString("serialId")); + String dayType = Util.null2String(recordSet.getString("day_type")); + int workMins = Util.getIntValue(recordSet.getString("workMins")); + boolean isNonWork = false; + if(dayType.length() > 0){ + if("holiday".equals(dayType) || "playday".equals(dayType)){ + isNonWork = true; + } + }else{ + if(workMins<=0){ + isNonWork = true; + }else{ + if(serialId.length() > 0){ + String isRest = Util.null2s(kqShiftManagementComInfo.getIsRest(serialId),""); + if("1".equals(isRest)){ + isNonWork = true; + }else if(serialId.equals("0")){ + isNonWork = true; + } + } + } + } + int serialNumber = Util.getIntValue(recordSet.getString("serialNumber"), 0); + String attachment = Util.null2String(recordSet.getString("attachment")); + if(!attachment.isEmpty()){ + attachment = new HrmTransMethod().getAttachment(attachment, user.getUID()+""); + } + + signInfo = signInfoMap.get(kqDate); + if (signInfo == null) { + signInfo = new SignInfo(); + } + signInfo.setSerialId("" + serialId); + signInfo.setNonWork(isNonWork); + if ("signIn".equals(signType)) { + if (serialNumber == 2) { + signInfo.setNeedSign3(true); + signInfo.setSignInTime3(signTime); + signInfo.setSignIn_attachment3(attachment); + } else if (serialNumber == 1) { + signInfo.setNeedSign2(true); + signInfo.setSignInTime2(signTime); + signInfo.setSignIn_attachment2(attachment); + } else { + signInfo.setNeedSign1(true); + signInfo.setSignInTime1(signTime); + signInfo.setSignIn_attachment1(attachment); + } + } else { + if (serialNumber == 2) { + signInfo.setNeedSign3(true); + signInfo.setSignOutTime3(signTime); + signInfo.setSignOut_attachment3(attachment); + } else if (serialNumber == 1) { + signInfo.setNeedSign2(true); + signInfo.setSignOutTime2(signTime); + signInfo.setSignOut_attachment2(attachment); + } else { + signInfo.setNeedSign1(true); + signInfo.setSignOutTime1(signTime); + signInfo.setSignOut_attachment1(attachment); + } + } + signInfoMap.put(kqDate,signInfo); + } + + Map itemMap = null; + List> itemList = null; + for (Map.Entry entry : signInfoMap.entrySet()) { + String kqDate = (String) entry.getKey(); + signInfo = (SignInfo) entry.getValue(); + String serialId = Util.null2String(signInfo.getSerialId()); + boolean needSign1 = signInfo.isNeedSign1(); + String signInTime1 = Util.null2String(signInfo.getSignInTime1()); + String signOutTime1 = Util.null2String(signInfo.getSignOutTime1()); + boolean needSign2 = signInfo.isNeedSign2(); + String signInTime2 = Util.null2String(signInfo.getSignInTime2()); + String signOutTime2 = Util.null2String(signInfo.getSignOutTime2()); + boolean needSign3 = signInfo.isNeedSign3(); + String signInTime3 = Util.null2String(signInfo.getSignInTime3()); + String signOutTime3 = Util.null2String(signInfo.getSignOutTime3()); + + String signIn_attachment1 = Util.null2String(signInfo.getSignIn_attachment1()); + String signOut_attachment1 = Util.null2String(signInfo.getSignOut_attachment1()); + String signIn_attachment2 = Util.null2String(signInfo.getSignIn_attachment2()); + String signOut_attachment2 = Util.null2String(signInfo.getSignOut_attachment2()); + String signIn_attachment3 = Util.null2String(signInfo.getSignIn_attachment3()); + String signOut_attachment3 = Util.null2String(signInfo.getSignOut_attachment3()); + + boolean isNonWork = signInfo.isNonWork(); + itemList = new ArrayList>(); + + if (isNonWork) { + if(signInTime1.length() > 0 || signOutTime1.length() > 0 + || signInTime2.length() > 0 || signOutTime2.length() > 0 + || signInTime3.length() > 0 || signOutTime3.length() > 0){ + if(needSign1){ + itemMap = new HashMap(); + itemMap.put("title", SystemEnv.getHtmlLabelName(512504, user.getLanguage())); + if (signInTime1.equals("")) { + itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage())); + } else { + itemMap.put("signTime", signInTime1); + } + itemMap.put("attachment", signIn_attachment1); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("title", SystemEnv.getHtmlLabelName(512505, user.getLanguage())); + if (signOutTime1.equals("")) { + itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage())); + } else { + itemMap.put("signTime", signOutTime1); + } + itemMap.put("attachment", signOut_attachment1); + itemList.add(itemMap); + } + + if(needSign2){ + itemMap = new HashMap(); + itemMap.put("title", SystemEnv.getHtmlLabelName(512504, user.getLanguage())); + if (signInTime2.equals("")) { + itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage())); + } else { + itemMap.put("signTime", signInTime2); + } + itemMap.put("attachment", signIn_attachment2); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("title", SystemEnv.getHtmlLabelName(512505, user.getLanguage())); + if (signOutTime2.equals("")) { + itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage())); + } else { + itemMap.put("signTime", signOutTime2); + } + itemMap.put("attachment", signOut_attachment2); + itemList.add(itemMap); + } + + if(needSign3){ + itemMap = new HashMap(); + itemMap.put("title", SystemEnv.getHtmlLabelName(512504, user.getLanguage())); + if (signInTime3.equals("")) { + itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage())); + } else { + itemMap.put("signTime", signInTime3); + } + itemMap.put("attachment", signIn_attachment3); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("title", SystemEnv.getHtmlLabelName(512505, user.getLanguage())); + if (signOutTime3.equals("")) { + itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage())); + } else { + itemMap.put("signTime", signOutTime3); + } + itemMap.put("attachment", signOut_attachment3); + itemList.add(itemMap); + } + }else{ + continue; + } + + resultMap.put(kqDate,itemList); + } else { + itemMap = new HashMap(); + itemMap.put("title", SystemEnv.getHtmlLabelName(512504, user.getLanguage())); + if (signInTime1.equals("")) { + itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage())); + } else { + itemMap.put("signTime", signInTime1); + } + itemMap.put("attachment", signIn_attachment1); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("title", SystemEnv.getHtmlLabelName(512505, user.getLanguage())); + if (signOutTime1.equals("")) { + itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage())); + } else { + itemMap.put("signTime", signOutTime1); + } + itemMap.put("attachment", signOut_attachment1); + itemList.add(itemMap); + + if (needSign2) { + itemMap = new HashMap(); + itemMap.put("title", SystemEnv.getHtmlLabelName(512504, user.getLanguage())); + if (signInTime2.equals("")) { + itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage())); + } else { + itemMap.put("signTime", signInTime2); + } + itemMap.put("attachment", signIn_attachment2); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("title", SystemEnv.getHtmlLabelName(512505, user.getLanguage())); + if (signOutTime2.equals("")) { + itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage())); + } else { + itemMap.put("signTime", signOutTime2); + } + itemMap.put("attachment", signOut_attachment2); + itemList.add(itemMap); + } + + if (needSign3) { + itemMap = new HashMap(); + itemMap.put("title", SystemEnv.getHtmlLabelName(512504, user.getLanguage())); + if (signInTime3.equals("")) { + itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage())); + } else { + itemMap.put("signTime", signInTime3); + } + itemMap.put("attachment", signIn_attachment3); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("title", SystemEnv.getHtmlLabelName(512505, user.getLanguage())); + if (signOutTime3.equals("")) { + itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage())); + } else { + itemMap.put("signTime", signOutTime3); + } + itemMap.put("attachment", signOut_attachment3); + itemList.add(itemMap); + } + resultMap.put(kqDate,itemList); + } + } + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + class SignInfo { + private String serialId; + private boolean needSign1 = false; + private String signInTime1; + private String signOutTime1; + private String signIn_attachment1; + private String signOut_attachment1; + + private boolean needSign2 = false; + private String signInTime2; + private String signOutTime2; + private String signIn_attachment2; + private String signOut_attachment2; + private boolean needSign3 = false; + private String signInTime3; + private String signOutTime3; + private String signIn_attachment3; + private String signOut_attachment3; + private boolean isNonWork; + + public SignInfo() { + } + + public boolean isNonWork() { + return isNonWork; + } + + public void setNonWork(boolean nonWork) { + isNonWork = nonWork; + } + + public String getSerialId() { + return serialId; + } + + public void setSerialId(String serialId) { + this.serialId = serialId; + } + + public boolean isNeedSign1() { + return needSign1; + } + + public void setNeedSign1(boolean needSign1) { + this.needSign1 = needSign1; + } + + public String getSignInTime1() { + return signInTime1; + } + + public void setSignInTime1(String signInTime1) { + this.signInTime1 = signInTime1; + } + + public String getSignOutTime1() { + return signOutTime1; + } + + public void setSignOutTime1(String signOutTime1) { + this.signOutTime1 = signOutTime1; + } + + public boolean isNeedSign2() { + return needSign2; + } + + public void setNeedSign2(boolean needSign2) { + this.needSign2 = needSign2; + } + + public String getSignInTime2() { + return signInTime2; + } + + public void setSignInTime2(String signInTime2) { + this.signInTime2 = signInTime2; + } + + public String getSignOutTime2() { + return signOutTime2; + } + + public void setSignOutTime2(String signOutTime2) { + this.signOutTime2 = signOutTime2; + } + + public boolean isNeedSign3() { + return needSign3; + } + + public void setNeedSign3(boolean needSign3) { + this.needSign3 = needSign3; + } + + public String getSignInTime3() { + return signInTime3; + } + + public void setSignInTime3(String signInTime3) { + this.signInTime3 = signInTime3; + } + + public String getSignOutTime3() { + return signOutTime3; + } + + public void setSignOutTime3(String signOutTime3) { + this.signOutTime3 = signOutTime3; + } + + public String getSignIn_attachment1() { + return signIn_attachment1; + } + + public void setSignIn_attachment1(String signIn_attachment1) { + this.signIn_attachment1 = signIn_attachment1; + } + + public String getSignOut_attachment1() { + return signOut_attachment1; + } + + public void setSignOut_attachment1(String signOut_attachment1) { + this.signOut_attachment1 = signOut_attachment1; + } + + public String getSignIn_attachment2() { + return signIn_attachment2; + } + + public void setSignIn_attachment2(String signIn_attachment2) { + this.signIn_attachment2 = signIn_attachment2; + } + + public String getSignOut_attachment2() { + return signOut_attachment2; + } + + public void setSignOut_attachment2(String signOut_attachment2) { + this.signOut_attachment2 = signOut_attachment2; + } + + public String getSignIn_attachment3() { + return signIn_attachment3; + } + + public void setSignIn_attachment3(String signIn_attachment3) { + this.signIn_attachment3 = signIn_attachment3; + } + + public String getSignOut_attachment3() { + return signOut_attachment3; + } + + public void setSignOut_attachment3(String signOut_attachment3) { + this.signOut_attachment3 = signOut_attachment3; + } + } +} diff --git a/src/com/engine/kq/cmd/myattendance/GetHrmKQReportDetialInfoCmd.java b/src/com/engine/kq/cmd/myattendance/GetHrmKQReportDetialInfoCmd.java new file mode 100644 index 0000000..5cf9064 --- /dev/null +++ b/src/com/engine/kq/cmd/myattendance/GetHrmKQReportDetialInfoCmd.java @@ -0,0 +1,1407 @@ +package com.engine.kq.cmd.myattendance; + +import com.alibaba.fastjson.JSON; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQAttFlowSetBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQTimeSelectionComInfo; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.util.KQTransMethod; +import com.engine.kq.util.PageUidFactory; +import com.engine.kq.wfset.util.SplitSelectSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +/** + * 前台--人事--我的考勤--明细 + */ +public class GetHrmKQReportDetialInfoCmd extends AbstractCommonCommand> { + + public GetHrmKQReportDetialInfoCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + private static boolean isIndirectSuperId(String id,String checkSuperId,ResourceComInfo info){ + + int loopBreakTimes = 20 ; + for(String loopId = id; + isRightResourceId(loopId) && (loopBreakTimes--)>0 ; + loopId = info.getManagerID(loopId)){ + if(isDirectSuperId(loopId,checkSuperId,info)) return true ; + } + return false ; + } + + private static boolean isRightResourceId(String id){ + return StringUtils.isNotBlank(id) && !"0".equals(id) ; + } + + private static boolean isDirectSuperId(String id,String checkSuperId,ResourceComInfo info){ + String superId = Util.null2String(info.getManagerID(id)) ; + return isRightResourceId(superId) && superId.equals(checkSuperId) ; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String resourceId = Util.null2String(params.get("resourceId")); + int departmentId = 0; + if("".equals(resourceId)) { + resourceId = ""+user.getUID(); + departmentId = user.getUserDepartment(); + } else { + departmentId = Util.getIntValue(resourceComInfo.getDepartmentID(resourceId), 0); + } + if (!resourceId.equals("" + user.getUID()) && !isIndirectSuperId(resourceId, user.getUID() + "", resourceComInfo) && !HrmUserVarify.checkUserRight("HrmResource:Absense", user, departmentId)) { + resultMap.put("status", "-1"); + resultMap.put("hasRight", false); + return resultMap; + } + String kqtype = Util.null2String(params.get("kqtype")); + if (kqtype.equalsIgnoreCase("realWorkdays")) { + resultMap = getRealWorkdaysList(); + } else if (kqtype.equalsIgnoreCase("absent")) { + resultMap = getAbsentList(); + } else if (kqtype.equalsIgnoreCase("beLate") || kqtype.equalsIgnoreCase("graveBeLate")) { + if (kqtype.equalsIgnoreCase("graveBeLate")) { + params.put("tabKey", "2"); + } + resultMap = getBeLateList(); + } else if (kqtype.equalsIgnoreCase("leaveEarly") || kqtype.equalsIgnoreCase("graveLeaveEarly")) { + if (kqtype.equalsIgnoreCase("graveLeaveEarly")) { + params.put("tabKey", "2"); + } + resultMap = getLeaveEearlyList(); + } else if (kqtype.equalsIgnoreCase("noSign")) { + resultMap = getForgotCheckList(); + } else if (kqtype.startsWith("leaveType_") + || kqtype.equalsIgnoreCase("evection") + || kqtype.equalsIgnoreCase("outDays") + || kqtype.equalsIgnoreCase("overTime")) { + resultMap = getLeaveList(); + } else if (kqtype.equals("leaveDays")) { + resultMap = getLeaveDaysList(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } + + /** + * 获取缺勤明细 + * + * @return + */ + private Map getLeaveDaysList() { + Map resultMap = new HashMap(); + try { + String nowdate = DateUtil.getCurrentDate(); + String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据:1-年、2-月 + String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份 + String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点 + String toDate = Util.null2String(params.get("toDate"));//指定日期终点 + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0);//指定查看的人员的所属分部 + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0);//指定查看的人员的所属部门 + String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID + String status = Util.null2String(params.get("status"));//? + + /**若未指定查看人员,则默认为当前登录人员*/ + if (resourceId.length() == 0) { + resourceId = "" + user.getUID(); + } + + /**获取指定日期的起点和终点*/ + if (type.equals("1")) {//年 + if (typevalue.length() == 0 || typevalue.length() != 4) { + typevalue = DateUtil.getYear(); + } + fromDate = typevalue + "-01-01"; + toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate)); + } else if (type.equals("2")) {//月 + if (typevalue.length() == 0) { + typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth(); + } + fromDate = typevalue + "-01"; + toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate)); + } + + /**获取今天的日期*/ + Calendar today = Calendar.getInstance(); + String currentdate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + /**未出勤不需要查询今天之后的日期*/ + if (fromDate.compareTo(currentdate) > 0) { + return resultMap; + } + if (fromDate.compareTo(currentdate) <= 0 && toDate.compareTo(currentdate) > 0) { + toDate = currentdate; + } + + /**获取请假类型对应的随机颜色值*/ + KQTransMethod kqTransMethod = new KQTransMethod(); + KQTimeSelectionComInfo kqTimeSelectionComInfo = new KQTimeSelectionComInfo(); + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + Map leaveTypeColorMap = new HashMap(); + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + leaveTypeColorMap.put(rulesComInfo.getId(), KQLeaveRulesBiz.getColor()); + } + + KQGroupComInfo groupComInfo = new KQGroupComInfo(); + + boolean hasLate = false;//是否存在迟到 + boolean hasEarly = false;//是否存在早退 + boolean hasAbsent = false;//是否存在旷工 + + /*获取缺勤时长*/ + Map dayMap = new HashMap();//缺勤时长 + String str = "select * from kq_format_total where resourceId=? and kqDate>=? and kqDate<=? and workdays!=attendancedays order by kqDate desc"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(str, resourceId, fromDate, toDate); + while (recordSet.next()) { + String kqDate = recordSet.getString("kqDate");//考勤日期 + String workDays = recordSet.getString("workdays");//应出勤天数; + String attendanceDays = recordSet.getString("attendancedays");//实际出勤天数 + if (workDays.equals(attendanceDays)) { + continue; + } + + String day = String.format("%.2f", Util.getDoubleValue(workDays, 0.00) - Util.getDoubleValue(attendanceDays, 0.00)); + dayMap.put(kqDate, day); + } + + /*获取缺勤明细:迟到、严重迟到、早退、严重早退、旷工、请假*/ + Map sclTimeMap = new HashMap();//上班时段 + List sclTimeDetailList = new ArrayList(); + + Map absTimeMap = new HashMap();//具体的缺勤时段 + List> absTimeDetailList = new ArrayList>(); + Map absTimeDetailMap = new HashMap(); + String sql = "select * from kq_format_detail where resourceId=? and kqDate>=? and kqDate<=? " + + " and (belatemins>0 or graveBeLateMins>0 or leaveearlymins>0 or graveLeaveEarlyMins>0 or absenteeismmins>0 or leaveMins>0) order by kqDate"; + recordSet.executeQuery(sql, resourceId, fromDate, toDate); + while (recordSet.next()) { + String kqDate = recordSet.getString("kqDate");//考勤日期 + String workBeginDate = recordSet.getString("workbegindate");//工作开始日期 + String workBeginTime = recordSet.getString("workbegintime");//工作开始时间 + String workEndDate = recordSet.getString("workenddate");//工作结束日期 + String workEndTime = recordSet.getString("workendtime");//工作结束时间 + String belateMins = recordSet.getString("belatemins");//迟到时长 + String graveBeLateMins = recordSet.getString("graveBeLateMins");//严重迟到时长 + String leaveearlyMins = recordSet.getString("leaveearlymins");//早退时长 + String graveLeaveEarlyMins = recordSet.getString("graveLeaveEarlyMins");//严重早退时长 + String absenteeismmins = recordSet.getString("absenteeismmins");//旷工时长 + String signInDate = recordSet.getString("signInDate");//签到日期 + String signInTime = recordSet.getString("signintime");//签到时间 + String signOutDate = recordSet.getString("signOutDate");//签退日期 + String signOutTime = recordSet.getString("signouttime");//签退时间 + String groupId = recordSet.getString("groupId");//考勤组ID + + if (kqDate.compareTo(workBeginDate) == 0 && kqDate.compareTo(workEndDate) == 0) { + /*上班时段*/ + sclTimeDetailList = (List) sclTimeMap.get(kqDate); + if (sclTimeDetailList == null) { + sclTimeDetailList = new ArrayList(); + } + String temp = workBeginTime + "-" + workEndTime; + if (!sclTimeDetailList.contains(temp)) { + sclTimeDetailList.add(temp); + } + sclTimeMap.put(kqDate, sclTimeDetailList); + + /*迟到和严重迟到算作缺勤*/ + if (Util.getDoubleValue(belateMins, 0.00) > 0.00 || Util.getDoubleValue(graveBeLateMins, 0.00) > 0.00) { + hasLate = true; + + absTimeDetailList = (List) absTimeMap.get(kqDate); + if (absTimeDetailList == null) { + absTimeDetailList = new ArrayList>(); + } + + absTimeDetailMap = new HashMap(); + absTimeDetailMap.put("bgColor", "#FFCCFF"); + absTimeDetailMap.put("time", workBeginTime + "-" + signInTime); + absTimeDetailMap.put("tips", new String[]{SystemEnv.getHtmlLabelName(505421, user.getLanguage()) + ":" + workBeginDate + " " + workBeginTime, SystemEnv.getHtmlLabelName(512504, user.getLanguage()) + ":" + signInDate + " " + signInTime, SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":" + SystemEnv.getHtmlLabelName(20081, user.getLanguage())}); + absTimeDetailMap.put("type", SystemEnv.getHtmlLabelName(20081, user.getLanguage()));//迟到 + absTimeDetailList.add(absTimeDetailMap); + + absTimeMap.put(kqDate, absTimeDetailList); + } + /*早退和严重早退算作缺勤*/ + if (Util.getDoubleValue(leaveearlyMins, 0.00) > 0.00 || Util.getDoubleValue(graveLeaveEarlyMins, 0.00) > 0.00) { + hasEarly = true; + + absTimeDetailList = (List) absTimeMap.get(kqDate); + if (absTimeDetailList == null) { + absTimeDetailList = new ArrayList>(); + } + + absTimeDetailMap = new HashMap(); + absTimeDetailMap.put("bgColor", "#6EBF70"); + absTimeDetailMap.put("time", signOutTime + "-" + workEndTime); + absTimeDetailMap.put("tips", new String[]{SystemEnv.getHtmlLabelName(512505, user.getLanguage()) + ":" + signOutDate + " " + signOutTime, SystemEnv.getHtmlLabelName(505423, user.getLanguage()) + ":" + workEndDate + " " + workEndTime, SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":" + SystemEnv.getHtmlLabelName(20082, user.getLanguage())}); + absTimeDetailMap.put("type", SystemEnv.getHtmlLabelName(20082, user.getLanguage()));//早退 + absTimeDetailList.add(absTimeDetailMap); + + absTimeMap.put(kqDate, absTimeDetailList); + } + /*旷工算作缺勤*/ + if (Util.getDoubleValue(absenteeismmins, 0.00) > 0.00) { + hasAbsent = true; + + absTimeDetailList = (List) absTimeMap.get(kqDate); + if (absTimeDetailList == null) { + absTimeDetailList = new ArrayList>(); + } + + absTimeDetailMap = new HashMap(); + absTimeDetailMap.put("bgColor", "#CCCCFF"); + absTimeDetailMap.put("time", workBeginTime + "-" + workEndTime); + absTimeDetailMap.put("tips", new String[]{SystemEnv.getHtmlLabelName(505421, user.getLanguage()) + ":" + workBeginDate + " " + workBeginTime, SystemEnv.getHtmlLabelName(505423, user.getLanguage()) + ":" + workEndDate + " " + workEndTime, SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":" + SystemEnv.getHtmlLabelName(20085, user.getLanguage())}); + absTimeDetailMap.put("type", SystemEnv.getHtmlLabelName(20085, user.getLanguage()));//旷工 + absTimeDetailList.add(absTimeDetailMap); + + absTimeMap.put(kqDate, absTimeDetailList); + } + } else if (kqDate.compareTo(workBeginDate) == 0 && kqDate.compareTo(workEndDate) < 0) { + /*上班时段*/ + sclTimeDetailList = (List) sclTimeMap.get(kqDate); + if (sclTimeDetailList == null) { + sclTimeDetailList = new ArrayList(); + } + String temp = workBeginTime + "-24:00"; + if (!sclTimeDetailList.contains(temp)) { + sclTimeDetailList.add(temp); + } + sclTimeMap.put(kqDate, sclTimeDetailList); + + sclTimeDetailList = (List) sclTimeMap.get(workEndDate); + if (sclTimeDetailList == null) { + sclTimeDetailList = new ArrayList(); + } + temp = "00:00-" + workEndTime; + if (!sclTimeDetailList.contains(temp)) { + sclTimeDetailList.add(temp); + } + sclTimeMap.put(workEndDate, sclTimeDetailList); + + /*迟到和严重迟到算作缺勤*/ + if (Util.getDoubleValue(belateMins, 0.00) > 0.00 || Util.getDoubleValue(graveBeLateMins, 0.00) > 0.00) { + hasLate = true; + + if (signInDate.compareTo(workBeginDate) == 0) { + absTimeDetailList = (List) absTimeMap.get(kqDate); + if (absTimeDetailList == null) { + absTimeDetailList = new ArrayList>(); + } + + absTimeDetailMap = new HashMap(); + absTimeDetailMap.put("bgColor", "#FFCCFF"); + absTimeDetailMap.put("time", workBeginTime + "-" + signInTime); + absTimeDetailMap.put("tips", new String[]{SystemEnv.getHtmlLabelName(505421, user.getLanguage()) + ":" + workBeginDate + " " + workBeginTime, SystemEnv.getHtmlLabelName(512504, user.getLanguage()) + ":" + signInDate + " " + signInTime, SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":" + SystemEnv.getHtmlLabelName(20081, user.getLanguage())}); + absTimeDetailMap.put("type", SystemEnv.getHtmlLabelName(20081, user.getLanguage()));//迟到 + absTimeDetailList.add(absTimeDetailMap); + + absTimeMap.put(kqDate, absTimeDetailList); + } else { + absTimeDetailList = (List) absTimeMap.get(kqDate); + if (absTimeDetailList == null) { + absTimeDetailList = new ArrayList>(); + } + + absTimeDetailMap = new HashMap(); + absTimeDetailMap.put("bgColor", "#FFCCFF"); + absTimeDetailMap.put("time", workBeginTime + "-24:00"); + absTimeDetailMap.put("tips", new String[]{SystemEnv.getHtmlLabelName(505421, user.getLanguage()) + ":" + workBeginDate + " " + workBeginTime, SystemEnv.getHtmlLabelName(512504, user.getLanguage()) + ":" + signInDate + " " + signInTime, SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":" + SystemEnv.getHtmlLabelName(20081, user.getLanguage())}); + absTimeDetailMap.put("type", SystemEnv.getHtmlLabelName(20081, user.getLanguage()));//迟到 + absTimeDetailList.add(absTimeDetailMap); + absTimeMap.put(kqDate, absTimeDetailList); + + absTimeDetailList = (List) absTimeMap.get(workEndDate); + if (absTimeDetailList == null) { + absTimeDetailList = new ArrayList>(); + } + + absTimeDetailMap = new HashMap(); + absTimeDetailMap.put("bgColor", "#FFCCFF"); + absTimeDetailMap.put("time", "00:00-" + workEndTime); + absTimeDetailMap.put("tips", new String[]{SystemEnv.getHtmlLabelName(505421, user.getLanguage()) + ":" + workBeginDate + " " + workBeginTime, SystemEnv.getHtmlLabelName(512504, user.getLanguage()) + ":" + signInDate + " " + signInTime, SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":" + SystemEnv.getHtmlLabelName(20081, user.getLanguage())}); + absTimeDetailMap.put("type", SystemEnv.getHtmlLabelName(20081, user.getLanguage()));//迟到 + absTimeDetailList.add(absTimeDetailMap); + absTimeMap.put(workEndDate, absTimeDetailList); + } + } + /*早退和严重早退算作缺勤*/ + if (Util.getDoubleValue(leaveearlyMins, 0.00) > 0.00 || Util.getDoubleValue(graveLeaveEarlyMins, 0.00) > 0.00) { + hasEarly = true; + + if (signOutDate.compareTo(workEndDate) == 0) { + absTimeDetailList = (List) absTimeMap.get(workEndDate); + if (absTimeDetailList == null) { + absTimeDetailList = new ArrayList>(); + } + + absTimeDetailMap = new HashMap(); + absTimeDetailMap.put("bgColor", "#6EBF70"); + absTimeDetailMap.put("time", signOutTime + "-" + workEndTime); + absTimeDetailMap.put("tips", new String[]{SystemEnv.getHtmlLabelName(512505, user.getLanguage()) + ":" + signOutDate + " " + signOutTime, SystemEnv.getHtmlLabelName(505423, user.getLanguage()) + ":" + workEndDate + " " + workEndTime, SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":" + SystemEnv.getHtmlLabelName(20082, user.getLanguage())}); + absTimeDetailMap.put("type", SystemEnv.getHtmlLabelName(20082, user.getLanguage()));//早退 + absTimeDetailList.add(absTimeDetailMap); + absTimeMap.put(workEndDate, absTimeDetailList); + } else { + absTimeDetailList = (List) absTimeMap.get(kqDate); + if (absTimeDetailList == null) { + absTimeDetailList = new ArrayList>(); + } + + absTimeDetailMap = new HashMap(); + absTimeDetailMap.put("bgColor", "#6EBF70"); + absTimeDetailMap.put("time", signOutTime + "-24:00"); + absTimeDetailMap.put("tips", new String[]{SystemEnv.getHtmlLabelName(512505, user.getLanguage()) + ":" + signOutDate + " " + signOutTime, SystemEnv.getHtmlLabelName(505423, user.getLanguage()) + ":" + workEndDate + " " + workEndTime, SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":" + SystemEnv.getHtmlLabelName(20082, user.getLanguage())}); + absTimeDetailMap.put("type", SystemEnv.getHtmlLabelName(20082, user.getLanguage()));//早退 + absTimeDetailList.add(absTimeDetailMap); + absTimeMap.put(workEndDate, absTimeDetailList); + + absTimeDetailList = (List) absTimeMap.get(workEndDate); + if (absTimeDetailList == null) { + absTimeDetailList = new ArrayList>(); + } + + absTimeDetailMap = new HashMap(); + absTimeDetailMap.put("bgColor", "#6EBF70"); + absTimeDetailMap.put("time", "24:00-" + workEndTime); + absTimeDetailMap.put("tips", new String[]{SystemEnv.getHtmlLabelName(512505, user.getLanguage()) + ":" + signOutDate + " " + signOutTime, SystemEnv.getHtmlLabelName(505423, user.getLanguage()) + ":" + workEndDate + " " + workEndTime, SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":" + SystemEnv.getHtmlLabelName(20082, user.getLanguage())}); + absTimeDetailMap.put("type", SystemEnv.getHtmlLabelName(20082, user.getLanguage()));//早退 + absTimeDetailList.add(absTimeDetailMap); + absTimeMap.put(workEndDate, absTimeDetailList); + } + } + /*旷工算作缺勤*/ + if (Util.getDoubleValue(absenteeismmins, 0.00) > 0.00) { + hasAbsent = true; + + absTimeDetailList = (List) absTimeMap.get(kqDate); + if (absTimeDetailList == null) { + absTimeDetailList = new ArrayList>(); + } + + absTimeDetailMap = new HashMap(); + absTimeDetailMap.put("bgColor", "#CCCCFF"); + absTimeDetailMap.put("time", workBeginTime + "-24:00"); + absTimeDetailMap.put("tips", new String[]{SystemEnv.getHtmlLabelName(505421, user.getLanguage()) + ":" + workBeginDate + " " + workBeginTime, SystemEnv.getHtmlLabelName(505423, user.getLanguage()) + ":" + workEndDate + " " + workEndTime, SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":" + SystemEnv.getHtmlLabelName(20085, user.getLanguage())}); + absTimeDetailMap.put("type", SystemEnv.getHtmlLabelName(20085, user.getLanguage()));//旷工 + absTimeDetailList.add(absTimeDetailMap); + absTimeMap.put(kqDate, absTimeDetailList); + + absTimeDetailList = (List) absTimeMap.get(workEndDate); + if (absTimeDetailList == null) { + absTimeDetailList = new ArrayList>(); + } + + absTimeDetailMap = new HashMap(); + absTimeDetailMap.put("bgColor", "#CCCCFF"); + absTimeDetailMap.put("time", "00:00-" + workEndTime); + absTimeDetailMap.put("tips", new String[]{SystemEnv.getHtmlLabelName(505421, user.getLanguage()) + ":" + workBeginDate + " " + workBeginTime, SystemEnv.getHtmlLabelName(505423, user.getLanguage()) + ":" + workEndDate + " " + workEndTime, SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":" + SystemEnv.getHtmlLabelName(20085, user.getLanguage())}); + absTimeDetailMap.put("type", SystemEnv.getHtmlLabelName(20085, user.getLanguage()));//旷工 + absTimeDetailList.add(absTimeDetailMap); + absTimeMap.put(kqDate, absTimeDetailList); + } + } else { + //弹性工作制 + String kqType = groupComInfo.getKqtype(groupId); + if (kqType.equals("3")) { + String signStart = groupComInfo.getSignstart(groupId); + + /*上班时段*/ + sclTimeDetailList = (List) sclTimeMap.get(kqDate); + if (sclTimeDetailList == null) { + sclTimeDetailList = new ArrayList(); + } + String temp = signStart + "-24:00"; + if (!sclTimeDetailList.contains(temp)) { + sclTimeDetailList.add(temp); + } + sclTimeMap.put(kqDate, sclTimeDetailList); + + /*旷工算作缺勤*/ + if (Util.getDoubleValue(absenteeismmins, 0.00) > 0.00) { + hasAbsent = true; + + absTimeDetailList = (List) absTimeMap.get(kqDate); + if (absTimeDetailList == null) { + absTimeDetailList = new ArrayList>(); + } + + absTimeDetailMap = new HashMap(); + absTimeDetailMap.put("bgColor", "#CCCCFF"); + absTimeDetailMap.put("time", signStart + "-24:00"); + absTimeDetailMap.put("tips", new String[]{SystemEnv.getHtmlLabelName(505421, user.getLanguage()) + ":" + kqDate + " " + signStart, SystemEnv.getHtmlLabelName(505423, user.getLanguage()) + ":" + kqDate + " 24:00", SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":" + SystemEnv.getHtmlLabelName(20085, user.getLanguage())}); + absTimeDetailMap.put("type", SystemEnv.getHtmlLabelName(20085, user.getLanguage()));//旷工 + absTimeDetailList.add(absTimeDetailMap); + + absTimeMap.put(kqDate, absTimeDetailList); + } + } + } + } + + /*请假流程*/ + List leaveTypeList = new ArrayList(); + + Map paramsMap = new HashMap(); + paramsMap.put("typeselect", "6"); + paramsMap.put("tabKey", "1"); + paramsMap.put("kqtype", "" + KqSplitFlowTypeEnum.LEAVE.getFlowtype()); + paramsMap.put("resourceId", resourceId); + paramsMap.put("fromDate", fromDate); + paramsMap.put("toDate", toDate); + + KQAttFlowSetBiz kqAttFlowSetBiz = new KQAttFlowSetBiz(); + Map sqlMap = kqAttFlowSetBiz.getFLowSql(paramsMap, user); + String sqlFrom = sqlMap.get("from"); + String sqlWhere = sqlMap.get("where"); + sql = "select * " + sqlFrom + sqlWhere; + recordSet.executeQuery(sql); + while (recordSet.next()) { + String requestId = recordSet.getString("requestId"); + String leaveType = recordSet.getString("newLeaveType"); + double duration = Util.getDoubleValue(recordSet.getString("duration"), 0.00); + double backDuration = Util.getDoubleValue(recordSet.getString("backDuraion"),0.00); + String durationRule = recordSet.getString("durationRule"); + String fromDateTemp = recordSet.getString("fromDate"); + String fromTimeTemp = recordSet.getString("fromTime"); + String toDateTemp = recordSet.getString("toDate"); + String toTimeTemp = recordSet.getString("toTime"); + String requestName = recordSet.getString("requestName"); + + if (backDuration >= duration) { + continue; + } + if (!leaveTypeList.contains(leaveType)) { + leaveTypeList.add(leaveType); + } + Map> leaveBackMap = Maps.newHashMap(); + if(backDuration > 0.0){ + leaveBackMap = getLeaveBackList(requestId); + } + + String unitName = "";//单位名称,天/小时 + if (durationRule.equals("1") || durationRule.equals("2") || durationRule.equals("4")) { + unitName = SystemEnv.getHtmlLabelName(389325, user.getLanguage());//(天) + } else { + unitName = SystemEnv.getHtmlLabelName(389326, user.getLanguage());//(小时) + } + String timeselection = ""; + if ("2".equalsIgnoreCase(durationRule)) { + if (leaveType.length() > 0) { + timeselection = rulesComInfo.getTimeSelection(leaveType); + } + } + + boolean isEnd = false; + for (String date = fromDateTemp; !isEnd; date = DateUtil.getDate(date, 1)) { + if (date.equals(toDateTemp)) { + isEnd = true; + } + absTimeDetailList = (List>) absTimeMap.get(date); + if (absTimeDetailList == null) { + absTimeDetailList = new ArrayList>(); + } + absTimeDetailMap = new HashMap(); + absTimeDetailMap.put("bgColor", leaveTypeColorMap.get(leaveType)); + String fromtime_ = fromTimeTemp; + String toTime_ = toTimeTemp; + if("2".equalsIgnoreCase(durationRule) && "1".equalsIgnoreCase(timeselection)){ + Map half_map = kqTimeSelectionComInfo.getTimeselections("0",leaveType,durationRule); + Map apm_Map = getTimeDetail4Half(half_map,fromTimeTemp,toTimeTemp); + fromtime_ = Util.null2String(apm_Map.get("am")); + toTime_ = Util.null2String(apm_Map.get("pm")); + } + absTimeDetailMap.put("tips", new String[]{"" + requestName + "", + SystemEnv.getHtmlLabelName(500371, user.getLanguage()) + ":" + fromDateTemp + " " + fromtime_, SystemEnv.getHtmlLabelName(500372, user.getLanguage()) + ":" + toDateTemp + " " + toTime_, + SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":" + Util.formatMultiLang(rulesComInfo.getLeaveName(leaveType), "" + user.getLanguage()), SystemEnv.getHtmlLabelName(21551, user.getLanguage()) + unitName + ":" + String.format("%.2f",duration)+ + (backDuration > 0.0 ? ("("+SystemEnv.getHtmlLabelName(24473,user.getLanguage())+":"+String.format("%.2f",backDuration)+")") : "")}); + + absTimeDetailMap.put("type", SystemEnv.getHtmlLabelName(670, user.getLanguage())); + if (date.equals(fromDateTemp) && !date.equals(toDateTemp)) { + if(!leaveBackMap.isEmpty() && leaveBackMap.containsKey(date)){ + List leaveBackList = leaveBackMap.get(date); + for(int i = 0 ; i < leaveBackList.size() ; i++){ + if(i == 0){ + Map tmpMap = Maps.newHashMap(); + tmpMap.putAll(absTimeDetailMap); + tmpMap.put("time", fromTimeTemp + "-" + leaveBackList.get(0)); + absTimeDetailList.add(tmpMap); + }else if(i == leaveBackList.size()-1){ + Map tmpMap = Maps.newHashMap(); + tmpMap.putAll(absTimeDetailMap); + tmpMap.put("time", leaveBackList.get(leaveBackList.size()-1) + "-" + "24:00"); + absTimeDetailList.add(tmpMap); + }else{ + Map tmpMap = Maps.newHashMap(); + tmpMap.putAll(absTimeDetailMap); + tmpMap.put("time", leaveBackList.get(i) + "-" + leaveBackList.get(i+1)); + absTimeDetailList.add(tmpMap); + } + } + }else{ + absTimeDetailMap.put("time", fromTimeTemp + "-" + "24:00"); + absTimeDetailList.add(absTimeDetailMap); + } + } + if (date.equals(fromDateTemp) && date.equals(toDateTemp)) { + if(!leaveBackMap.isEmpty() && leaveBackMap.containsKey(date)){ + List leaveBackList = leaveBackMap.get(date); + for(int i = 0 ; i < leaveBackList.size() ; i++){ + if(i == 0){ + Map tmpMap = Maps.newHashMap(); + tmpMap.putAll(absTimeDetailMap); + tmpMap.put("time", fromTimeTemp + "-" + leaveBackList.get(0)); + absTimeDetailList.add(tmpMap); + }else if(i == leaveBackList.size()-1){ + Map tmpMap = Maps.newHashMap(); + tmpMap.putAll(absTimeDetailMap); + tmpMap.put("time", leaveBackList.get(leaveBackList.size()-1) + "-" + toTimeTemp); + absTimeDetailList.add(tmpMap); + }else{ + Map tmpMap = Maps.newHashMap(); + tmpMap.putAll(absTimeDetailMap); + tmpMap.put("time", leaveBackList.get(i) + "-" + leaveBackList.get(i+1)); + absTimeDetailList.add(tmpMap); + } + } + }else{ + absTimeDetailMap.put("time", fromTimeTemp + "-" + toTimeTemp); + absTimeDetailList.add(absTimeDetailMap); + } + } + if (!date.equals(fromDateTemp) && date.equals(toDateTemp)) { + if(!leaveBackMap.isEmpty() && leaveBackMap.containsKey(date)){ + List leaveBackList = leaveBackMap.get(date); + for(int i = 0 ; i < leaveBackList.size() ; i++){ + if(i == 0){ + Map tmpMap = Maps.newHashMap(); + tmpMap.putAll(absTimeDetailMap); + tmpMap.put("time", "00:00" + "-" + leaveBackList.get(0)); + absTimeDetailList.add(tmpMap); + }else if(i == leaveBackList.size()-1){ + Map tmpMap = Maps.newHashMap(); + tmpMap.putAll(absTimeDetailMap); + tmpMap.put("time", leaveBackList.get(leaveBackList.size()-1) + "-" + toTimeTemp); + absTimeDetailList.add(tmpMap); + }else{ + Map tmpMap = Maps.newHashMap(); + tmpMap.putAll(absTimeDetailMap); + tmpMap.put("time", leaveBackList.get(i) + "-" + leaveBackList.get(i+1)); + absTimeDetailList.add(tmpMap); + } + } + }else{ + absTimeDetailMap.put("time", "00:00-" + toTimeTemp); + absTimeDetailList.add(absTimeDetailMap); + } + } + if (date.compareTo(fromDateTemp) > 0 && date.compareTo(toDateTemp) < 0) { + if(!leaveBackMap.isEmpty() && leaveBackMap.containsKey(date)){ + List leaveBackList = leaveBackMap.get(date); + for(int i = 0 ; i < leaveBackList.size() ; i++){ + if(i == 0){ + Map tmpMap = Maps.newHashMap(); + tmpMap.putAll(absTimeDetailMap); + tmpMap.put("time", "00:00" + "-" + leaveBackList.get(0)); + absTimeDetailList.add(tmpMap); + }else if(i == leaveBackList.size()-1){ + Map tmpMap = Maps.newHashMap(); + tmpMap.putAll(absTimeDetailMap); + tmpMap.put("time", leaveBackList.get(leaveBackList.size()-1) + "-" + "24:00"); + absTimeDetailList.add(tmpMap); + }else{ + Map tmpMap = Maps.newHashMap(); + tmpMap.putAll(absTimeDetailMap); + tmpMap.put("time", leaveBackList.get(i) + "-" + leaveBackList.get(i+1)); + absTimeDetailList.add(tmpMap); + } + } + }else{ + absTimeDetailMap.put("time", "00:00-24:00"); + absTimeDetailList.add(absTimeDetailMap); + } + } + absTimeMap.put(date, absTimeDetailList); + } + } + + /*拼凑数据给前端展现*/ + List> typesList = new ArrayList>(); + Map typeMap = new HashMap(); + for (String leaveType : leaveTypeList) { + typeMap = new HashMap(); + typeMap.put("bgcolor", leaveTypeColorMap.get(leaveType)); + typeMap.put("value", rulesComInfo.getLeaveName(leaveType)); + + typesList.add(typeMap); + } + if (hasLate) { + typeMap = new HashMap(); + typeMap.put("bgcolor", "#FFCCFF"); + typeMap.put("value", SystemEnv.getHtmlLabelName(20081, user.getLanguage())); + typesList.add(typeMap); + } + + if (hasEarly) { + typeMap = new HashMap(); + typeMap.put("bgcolor", "#6EBF70"); + typeMap.put("value", SystemEnv.getHtmlLabelName(20082, user.getLanguage())); + typesList.add(typeMap); + } + + if (hasAbsent) { + typeMap = new HashMap(); + typeMap.put("bgcolor", "#CCCCFF"); + typeMap.put("value", SystemEnv.getHtmlLabelName(20085, user.getLanguage())); + typesList.add(typeMap); + } + + resultMap.put("types", typesList); + + List> detailsList = new ArrayList>(); + Map detailsMap = new HashMap(); + double daySum = 0.00; + boolean isEnd = false; + for (String date = fromDate; !isEnd; date = DateUtil.getDate(date, 1)) { + if (date.equals(toDate)) { + isEnd = true; + } + String day = (String) dayMap.get(date); + if (day == null || "".equals(day)) { + continue; + } + + daySum = daySum + Util.getDoubleValue(day, 0.00); + //如果取不到上班时间,默认未09:00-18:00,否则点击未出勤明细会闪退 + if (sclTimeMap.get(date) == null || "".equals(sclTimeMap.get(date))) { + List temp = new ArrayList(); + temp.add("09:00-18:00"); + sclTimeMap.put(date, temp); + } + + detailsMap = new HashMap(); + detailsMap.put("day", day); + detailsMap.put("date", kqTransMethod.getBelongDateShow(date, "" + user.getLanguage())); + detailsMap.put("sclTime", sclTimeMap.get(date)); + if(!absTimeMap.containsKey(date)){ + continue; + } + detailsMap.put("absTime", absTimeMap.get(date)); + + detailsList.add(detailsMap); + } + resultMap.put("absenceDay", String.format("%.2f", daySum)); + resultMap.put("details", detailsList); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String lastName = resourceComInfo.getResourcename(resourceId); + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(10000831, Util.getIntValue(user.getLanguage()))); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(513188, user.getLanguage()).replace("{lastName}", lastName)); + } + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } + + public Map> getLeaveBackList(String requestId) { + Map> leaveBackMap = Maps.newHashMap(); + RecordSet recordSet1 = new RecordSet(); + String back_sql = "select distinct requestid,fromdatedb,fromtimedb,todatedb,totimedb,durationrule,newleavetype from kq_flow_split_leaveback where leavebackrequestid=? order by fromdatedb, fromtimedb "; + recordSet1.executeQuery(back_sql, requestId); + while (recordSet1.next()){ + String back_fromdatedb = recordSet1.getString("fromdatedb"); + String back_fromtimedb = recordSet1.getString("fromtimedb"); + String back_todatedb = recordSet1.getString("todatedb"); + String back_totimedb = recordSet1.getString("totimedb"); + String durationrule = recordSet1.getString("durationrule"); + String newleavetype = recordSet1.getString("newleavetype"); + boolean isEnd = false; + for (String date = back_fromdatedb; !isEnd; date = DateUtil.getDate(date, 1)) { + if (date.equals(back_todatedb)) { + isEnd = true; + } + List leaveBackListTmp = Lists.newArrayList(); + if(leaveBackMap.containsKey(date)){ + leaveBackListTmp = leaveBackMap.get(date); + } + if (date.equals(back_fromdatedb) && !date.equals(back_todatedb)) { + leaveBackListTmp.add(back_fromtimedb); + leaveBackListTmp.add("24:00"); + } + if (date.equals(back_fromdatedb) && date.equals(back_todatedb)) { + leaveBackListTmp.add(back_fromtimedb); + leaveBackListTmp.add(back_totimedb); + } + if (!date.equals(back_fromdatedb) && date.equals(back_todatedb)) { + leaveBackListTmp.add("00:00"); + leaveBackListTmp.add(back_totimedb); + } + if (date.compareTo(back_fromdatedb) > 0 && date.compareTo(back_todatedb) < 0) { + leaveBackListTmp.add("00:00"); + leaveBackListTmp.add("24:00"); + } + leaveBackMap.put(date, leaveBackListTmp); + } + } + return leaveBackMap; + } + + /** + * 半天时间的显示 + * @param half_map + * @param fromTimeTemp + * @param toTimeTemp + */ + public Map getTimeDetail4Half(Map half_map, String fromTimeTemp, String toTimeTemp) { + Map apm_Map = new HashMap<>(); + String cus_am = SystemEnv.getHtmlLabelName(16689, user.getLanguage()); + String cus_pm = SystemEnv.getHtmlLabelName(16690, user.getLanguage()); + if(half_map != null && !half_map.isEmpty()){ + cus_am = Util.null2String(half_map.get("half_on")); + cus_pm = Util.null2String(half_map.get("half_off")); + } + String start = cus_am; + String end = cus_pm; + if (fromTimeTemp.equalsIgnoreCase(SplitSelectSet.forenoon_start)) { + start = cus_am; + } else if (fromTimeTemp.equalsIgnoreCase(SplitSelectSet.forenoon_end)) { + start = cus_pm; + } + if (toTimeTemp.equalsIgnoreCase(SplitSelectSet.afternoon_start)) { + end = cus_am; + } else if (toTimeTemp.equalsIgnoreCase(SplitSelectSet.afternoon_end)) { + end = cus_pm; + } + apm_Map.put("am", start); + apm_Map.put("pm", end); + return apm_Map; + } + + /** + * 获取实际出勤天数的明细列表 + * + * @return + */ + public Map getRealWorkdaysList() { + Map resultMap = new HashMap(); + try { + String nowdate = DateUtil.getCurrentDate(); + String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据:1-年、2-月 + String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份 + String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点 + String toDate = Util.null2String(params.get("toDate"));//指定日期终点 + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0);//指定查看的人员的所属分部 + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0);//指定查看的人员的所属部门 + String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID + String status = Util.null2String(params.get("status"));//? + + /** + * 若未指定查看人员,则默认为当前登录人员 + */ + if (resourceId.length() == 0) { + resourceId = "" + user.getUID(); + } + + /** + * 获取指定日期的起点和终点 + */ + if (type.equals("1")) {//年 + if (typevalue.length() == 0 || typevalue.length() != 4) { + typevalue = DateUtil.getYear(); + } + fromDate = typevalue + "-01-01"; + toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate)); + } else if (type.equals("2")) {//月 + if (typevalue.length() == 0) { + typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth(); + } + fromDate = typevalue + "-01"; + toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate)); + } + + /**获取今天的日期*/ + Calendar today = Calendar.getInstance(); + String currentdate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + /** + * 获取明细列表 + */ + String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid,serialid as serialid1, serialid as serialid2," + + " workbegintime,workendtime,signintime,signouttime, attendanceMins, signMins "; + String sqlFrom = " from hrmresource a, kq_format_detail b "; + String sqlWhere = " where a.id = b.resourceid and (attendanceMins>0 or signMins>0)"; + String orderBy = " kqdate asc, workbegintime asc " ; + if (fromDate.length() > 0) { + sqlWhere += " and kqdate >= '" + fromDate + "'"; + } + if (toDate.length() > 0) { + sqlWhere += " and kqdate <= '" + toDate + "'"; + } + if (resourceId.length() > 0) { + sqlWhere += " and resourceid = " + resourceId; + } + + String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList"); + String tableString = "" + + "" + + "" + + "" + + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + "" + + "
"; + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + resultMap.put("sessionkey", sessionkey); + resultMap.put("status", "1"); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + e.printStackTrace(); + } + return resultMap; + } + + /** + * 获取旷工的明细列表 + * + * @return + */ + public Map getAbsentList() { + Map resultMap = new HashMap(); + try { + String nowdate = DateUtil.getCurrentDate(); + String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据:1-年、2-月 + String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份 + String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点 + String toDate = Util.null2String(params.get("toDate"));//指定日期终点 + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0);//指定查看的人员的所属分部 + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0);//指定查看的人员的所属部门 + String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID + String status = Util.null2String(params.get("status"));//? + + /** + * 若未指定查看人员,则默认为当前登录人员 + */ + if (resourceId.length() == 0) { + resourceId = "" + user.getUID(); + } + + /** + * 获取指定日期的起点和终点 + */ + if (type.equals("1")) {//年 + if (typevalue.length() == 0 || typevalue.length() != 4) { + typevalue = DateUtil.getYear(); + } + fromDate = typevalue + "-01-01"; + toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate)); + } else if (type.equals("2")) {//月 + if (typevalue.length() == 0) { + typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth(); + } + fromDate = typevalue + "-01"; + toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate)); + } + + /**获取今天的日期*/ + Calendar today = Calendar.getInstance(); + String currentdate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + /** + * 获取明细列表 + */ + String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid, serialid as serialid1," + + " workbegintime,workendtime, signintime,signouttime,absenteeismmins "; + + String sqlFrom = "from hrmresource a, kq_format_detail b "; + String sqlWhere = " where a.id = b.resourceid and absenteeismMins>0 "; + String orderBy = " kqdate asc, workbegintime asc "; + if (fromDate.length() > 0) { + sqlWhere += " and kqdate >= '" + fromDate + "'"; + } + + if (toDate.length() > 0) { + sqlWhere += " and kqdate <= '" + toDate + "'"; + } + + if (resourceId.length() > 0) { + sqlWhere += " and resourceid = " + resourceId; + } + + String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList"); + String tableString = "" + + "" + + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "" + + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + resultMap.put("sessionkey", sessionkey); + resultMap.put("status", "1"); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + e.printStackTrace(); + } + return resultMap; + } + + /** + * 获取迟到明细列表 + * + * @return + */ + public Map getBeLateList() { + Map resultMap = new HashMap(); + try { + String nowdate = DateUtil.getCurrentDate(); + String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据:1-年、2-月 + String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份 + String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点 + String toDate = Util.null2String(params.get("toDate"));//指定日期终点 + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0);//指定查看的人员的所属分部 + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0);//指定查看的人员的所属部门 + String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID + String status = Util.null2String(params.get("status"));//? + String tabKey = Util.null2String(params.get("tabKey"));//是迟到还是严重迟到:2-严重迟到、其他-迟到 + + /** + * 若未指定查看人员,则默认为当前登录人员 + */ + if (resourceId.length() == 0) { + resourceId = "" + user.getUID(); + } + + /** + * 获取指定日期的起点和终点 + */ + if (type.equals("1")) {//年 + if (typevalue.length() == 0 || typevalue.length() != 4) { + typevalue = DateUtil.getYear(); + } + fromDate = typevalue + "-01-01"; + toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate)); + } else if (type.equals("2")) {//月 + if (typevalue.length() == 0) { + typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth(); + } + fromDate = typevalue + "-01"; + toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate)); + } + + /**获取今天的日期*/ + Calendar today = Calendar.getInstance(); + String currentdate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + /** + * 获取明细列表 + */ + String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid, serialid as serialid1," + + " workbegintime,workendtime, signintime,signouttime, beLateMins, graveBeLateMins "; + String sqlFrom = "from hrmresource a, kq_format_detail b "; + String sqlWhere = " where a.id = b.resourceid"; + String orderBy = " kqdate asc, workbegintime asc "; + if (fromDate.length() > 0) { + sqlWhere += " and kqdate >= '" + fromDate + "'"; + } + + if (toDate.length() > 0) { + sqlWhere += " and kqdate <= '" + toDate + "'"; + } + + if (resourceId.length() > 0) { + sqlWhere += " and resourceid = " + resourceId; + } + + if (tabKey.equals("2")) { + sqlWhere += " and graveBeLateMins>0 "; + } else { + sqlWhere += " and beLateMins>0 "; + } + + String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList"); + String tableString = "" + + "" + + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " "; + if (tabKey.equals("2")) { + tableString += " "; + } else { + tableString += " "; + } + tableString += "" + + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + resultMap.put("sessionkey", sessionkey); + resultMap.put("status", "1"); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + e.printStackTrace(); + } + return resultMap; + } + + /** + * 获取早退的明细列表 + * + * @return + */ + public Map getLeaveEearlyList() { + Map resultMap = new HashMap(); + try { + String nowdate = DateUtil.getCurrentDate(); + String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据:1-年、2-月 + String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份 + String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点 + String toDate = Util.null2String(params.get("toDate"));//指定日期终点 + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0);//指定查看的人员的所属分部 + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0);//指定查看的人员的所属部门 + String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID + String status = Util.null2String(params.get("status"));//? + String tabKey = Util.null2String(params.get("tabKey"));//是早退还是严重早退:2-严重早退、其他-早退 + + /** + * 若未指定查看人员,则默认为当前登录人员 + */ + if (resourceId.length() == 0) { + resourceId = "" + user.getUID(); + } + + /** + * 获取指定日期的起点和终点 + */ + if (type.equals("1")) {//年 + if (typevalue.length() == 0 || typevalue.length() != 4) { + typevalue = DateUtil.getYear(); + } + fromDate = typevalue + "-01-01"; + toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate)); + } else if (type.equals("2")) {//月 + if (typevalue.length() == 0) { + typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth(); + } + fromDate = typevalue + "-01"; + toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate)); + } + + /**获取今天的日期*/ + Calendar today = Calendar.getInstance(); + String currentdate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + /** + * 获取明细列表 + */ + String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid," + + " workbegintime,workendtime, signintime,signouttime, leaveEarlyMins, graveLeaveEarlyMins "; + String sqlFrom = "from hrmresource a, kq_format_detail b "; + String sqlWhere = " where a.id = b.resourceid"; + String orderBy = " kqdate asc, workbegintime asc "; + if (fromDate.length() > 0) { + sqlWhere += " and kqdate >= '" + fromDate + "'"; + } + + if (toDate.length() > 0) { + sqlWhere += " and kqdate <= '" + toDate + "'"; + } + + if (resourceId.length() > 0) { + sqlWhere += " and resourceid = " + resourceId; + } + + if (tabKey.equals("2")) { + sqlWhere += " and graveLeaveEarlyMins>0 "; + } else { + sqlWhere += " and leaveEarlyMins>0 "; + } + + String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList"); + + String tableString = "" + + "" + + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " "; + if (tabKey.equals("2")) { + tableString += " "; + } else { + tableString += " "; + } + tableString += "" + + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + resultMap.put("sessionkey", sessionkey); + resultMap.put("status", "1"); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + e.printStackTrace(); + } + return resultMap; + } + + /** + * 获取漏签的明细列表 + * + * @return + */ + public Map getForgotCheckList() { + Map resultMap = new HashMap(); + try { + String nowdate = DateUtil.getCurrentDate(); + String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据:1-年、2-月 + String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份 + String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点 + String toDate = Util.null2String(params.get("toDate"));//指定日期终点 + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0);//指定查看的人员的所属分部 + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0);//指定查看的人员的所属部门 + String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID + String status = Util.null2String(params.get("status"));//? + + /** + * 若未指定查看人员,则默认为当前登录人员 + */ + if (resourceId.length() == 0) { + resourceId = "" + user.getUID(); + } + + /** + * 获取指定日期的起点和终点 + */ + if (type.equals("1")) {//年 + if (typevalue.length() == 0 || typevalue.length() != 4) { + typevalue = DateUtil.getYear(); + } + fromDate = typevalue + "-01-01"; + toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate)); + } else if (type.equals("2")) {//月 + if (typevalue.length() == 0) { + typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth(); + } + fromDate = typevalue + "-01"; + toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate)); + } + + /**获取今天的日期*/ + Calendar today = Calendar.getInstance(); + String currentdate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + /** + * 获取明细列表 + */ + String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid, serialid as serialid1, serialid as serialid2," + + " workbegintime,workendtime, signintime,signouttime,case when forgotcheckmins> 0 then 1 when forgotBeginWorkCheckMins> 0 then 1 else 0 end as forgotcheck " ; + + String sqlFrom = "from hrmresource a, kq_format_detail b "; + String sqlWhere = " where a.id = b.resourceid and (forgotCheckMins>0 or forgotBeginWorkCheckMins>0)"; + String orderby = " kqdate asc, workbegintime asc " ; + String tableString = ""; + + if (fromDate.length() > 0) { + sqlWhere += " and kqdate >= '" + fromDate + "'"; + } + + if (toDate.length() > 0) { + sqlWhere += " and kqdate <= '" + toDate + "'"; + } + + if (resourceId.length() > 0) { + sqlWhere += " and resourceid = " + resourceId; + } + + String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList"); + + tableString = "" + + "" + + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " "+ + " "+ + " "+ + " "+ + "" + + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + resultMap.put("sessionkey", sessionkey); + resultMap.put("status", "1"); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + e.printStackTrace(); + } + return resultMap; + } + + /** + * 获取请假、加班、出差、公出、异常数据抵冲的明细列表 + * + * @return + */ + public Map getLeaveList() { + Map resultMap = new HashMap(); + try { + String kqtype = Util.null2String(params.get("kqtype")); + String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据:1-年、2-月 + String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份 + String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点 + String toDate = Util.null2String(params.get("toDate"));//指定日期终点 + String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID + + /** + * 若未指定查看人员,则默认为当前登录人员 + */ + if (resourceId.length() == 0) { + resourceId = "" + user.getUID(); + } + + /** + * 获取指定日期的起点和终点 + */ + if (type.equals("1")) {//年 + if (typevalue.length() == 0 || typevalue.length() != 4) { + typevalue = DateUtil.getYear(); + } + fromDate = typevalue + "-01-01"; + toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate)); + } else if (type.equals("2")) {//月 + if (typevalue.length() == 0) { + typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth(); + } + fromDate = typevalue + "-01"; + toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate)); + } + + /**获取今天的日期*/ + Calendar today = Calendar.getInstance(); + String currentdate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + params.put("tabKey", "1"); + params.put("resourceId", resourceId); + params.put("fromDate", fromDate); + params.put("toDate", toDate); + params.put("typeselect", "6"); + params.put("isNoAccount","1"); + + if (kqtype.equalsIgnoreCase("overtime")) {//加班 + params.put("kqtype", KqSplitFlowTypeEnum.OVERTIME.getFlowtype()); + } else if (kqtype.equalsIgnoreCase("evection")) {//出差 + params.put("kqtype", KqSplitFlowTypeEnum.EVECTION.getFlowtype()); + } else if (kqtype.equalsIgnoreCase("outDays")) {//公出 + params.put("kqtype", KqSplitFlowTypeEnum.OUT.getFlowtype()); + } else if (kqtype.startsWith("leaveType_")) { + String[] typeInfo = Util.splitString(kqtype, "_"); + if (typeInfo[0].equals("leaveType")) { + params.put("kqtype", KqSplitFlowTypeEnum.LEAVE.getFlowtype()); + params.put("newleavetype", typeInfo[1]); + } + } + + resultMap.put("sessionkey", new KQAttFlowSetBiz().buildFlowSetTableString(params, user)); + resultMap.put("status", "1"); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/myattendance/GetHrmKQReportInfoCmd.java b/src/com/engine/kq/cmd/myattendance/GetHrmKQReportInfoCmd.java new file mode 100644 index 0000000..76fe495 --- /dev/null +++ b/src/com/engine/kq/cmd/myattendance/GetHrmKQReportInfoCmd.java @@ -0,0 +1,446 @@ +package com.engine.kq.cmd.myattendance; + +import com.alibaba.fastjson.JSON; +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.entity.WorkTimeEntity; +import weaver.common.DateUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; +import org.apache.commons.lang3.StringUtils; + +import java.util.*; + +/** + * 前台--人事--我的考勤 + */ +public class GetHrmKQReportInfoCmd extends AbstractCommonCommand> { + + public GetHrmKQReportInfoCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + private static boolean isIndirectSuperId(String id,String checkSuperId,ResourceComInfo info){ + + int loopBreakTimes = 20 ; + for(String loopId = id; + isRightResourceId(loopId) && (loopBreakTimes--)>0 ; + loopId = info.getManagerID(loopId)){ + if(isDirectSuperId(loopId,checkSuperId,info)) return true ; + } + return false ; + } + + private static boolean isDirectSuperId(String id,String checkSuperId,ResourceComInfo info){ + String superId = Util.null2String(info.getManagerID(id)) ; + return isRightResourceId(superId) && superId.equals(checkSuperId) ; + } + + private static boolean isRightResourceId(String id){ + return StringUtils.isNotBlank(id) && !"0".equals(id) ; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + /** + * 判断是否有权限 + */ + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0); + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0); + String resourceId = Util.null2String(params.get("resourceId")); + if (resourceId.equals("")) { + resourceId = "" + user.getUID(); + } + String lastName = resourceComInfo.getResourcename(resourceId); + if (resourceId.equals("" + user.getUID())) { + resultMap.put("title", SystemEnv.getHtmlLabelName(513095, user.getLanguage())); + } else { + resultMap.put("title", SystemEnv.getHtmlLabelName(515562, user.getLanguage()).replace("{name}", lastName)); + } + if (subCompanyId == 0 || departmentId == 0) { + subCompanyId = Util.getIntValue(resourceComInfo.getSubCompanyID(resourceId), 0); + departmentId = Util.getIntValue(resourceComInfo.getDepartmentID(resourceId), 0); + } + if (!resourceId.equals("" + user.getUID()) && !isIndirectSuperId(resourceId, user.getUID() + "", resourceComInfo) && !HrmUserVarify.checkUserRight("HrmResource:Absense", user, departmentId)) { + resultMap.put("status", "-1"); + resultMap.put("hasRight", false); + return resultMap; + } + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + + // 没有权限的人最大只支持查询本季 + Map getRealDate = new KQReportBiz().realDate(fromDate, toDate, user, "1"); + String realFromDate = getRealDate.get("fromDate"); + String realToDate = getRealDate.get("toDate"); + if("-1".equals(realFromDate) || "-1".equals(realToDate)) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(543747, user.getLanguage())); + return resultMap; + } + + Calendar today = Calendar.getInstance(); + /**今年*/ + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + /**上一年*/ + String lastYearDate = Util.add0(today.get(Calendar.YEAR) - 1, 4) + "-12-31"; + + + String currentYear = currentDate.substring(0,4); + String balanceDate = currentDate; + String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份 + String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据:1-年、2-月 + if (type.equals("1")) {//年 + if (typevalue.length() == 0 || typevalue.length() != 4) { + typevalue = DateUtil.getYear(); + } + if(typevalue.compareTo(currentYear)<0){ + balanceDate = typevalue + "-12-31"; + }else if(typevalue.compareTo(currentYear)==0){ + balanceDate = currentDate; + }else if(typevalue.compareTo(currentYear)>0){ + balanceDate = typevalue + "-01-01"; + } + } else if (type.equals("2")) {//月 + if (typevalue.length() == 0) { + typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth(); + } + balanceDate = typevalue + "-01"; + } + + + + /** + * 拼凑前端所属数据格式 + */ + Map groupMap = new HashMap(); + List groupItemList = new ArrayList(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + Map itemMap = new HashMap(); + List itemList5 = new ArrayList(); + Map groupItem5 = new HashMap(); + /** + * 出勤统计 + * workDays:应出勤天数 + * realWorkDays:实际出勤天数 + * leaveDays:缺勤天数 + */ + double workDays = 0.00; + double realWorkDays = 0.00; + double leaveDays = 0.00; + /** + * beLate:迟到次数 + * graveBeLate;严重迟到次数 + * leaveEearly:早退次数 + * graveLeaveEarly:严重迟到次数 + * absenteeism:旷工次数 + * forgotCheck:漏签次数 + */ + int beLate = 0; + int graveBeLate = 0; + int leaveEearly = 0; + int graveLeaveEarly = 0; + int absenteeism = 0; + int forgotCheck = 0; + /** + * or_minimumUnit:最小加班单位 + * or_unitName:(小时)/(天) + * tr_minimumUnit:最小出差单位 + * tr_unitName:(小时)/(天) + * er_minimumUnit:最小公出单位 + * er_unitName:(小时)/(天) + */ + int or_minimumUnit = KQOvertimeRulesBiz.getMinimumUnit();//最小加班单位 + String or_unitName = (or_minimumUnit == 3 || or_minimumUnit == 5 || or_minimumUnit == 6) ? SystemEnv.getHtmlLabelName(389326, user.getLanguage()) : SystemEnv.getHtmlLabelName(389325, user.getLanguage()); + KQTravelRulesComInfo kqTravelRulesComInfo = new KQTravelRulesComInfo(); + int tr_minimumUnit = Util.getIntValue(kqTravelRulesComInfo.getMinimumUnit("1"));//最小出差单位 + String tr_unitName = tr_minimumUnit == 3 ? SystemEnv.getHtmlLabelName(389326, user.getLanguage()) : SystemEnv.getHtmlLabelName(389325, user.getLanguage()); + KQExitRulesComInfo kqExitRulesComInfo = new KQExitRulesComInfo(); + int er_minimumUnit = Util.getIntValue(kqExitRulesComInfo.getMinimumUnit("1"));//最小公出单位 + String er_unitName = er_minimumUnit == 3 ? SystemEnv.getHtmlLabelName(389326, user.getLanguage()) : SystemEnv.getHtmlLabelName(389325, user.getLanguage()); + /** + * overtimeTotal:加班时长 + * businessLeave:出差时长 + * officialBusiness:公出时长 + */ + double overtimeTotal = 0.00;//加班时长 + double businessLeave = 0.00;//出差时长 + double officialBusiness = 0.00;//公出时长 + /** + * 记录请假时长(考虑到人员调整部门之后,考勤汇总报表会存在两条记录,用于累计请假时长) + */ + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + Map leaveMap = new HashMap(); + /** + * 获取考勤的相关统计数据,数据来源于考勤汇总报表,在service层调用了考勤汇总报表的接口重新封装了数据传入此接口 + * 调用的考勤汇总报表的接口为:com/engine/kq/cmd/report/GetKQReportCmd.java + */ + List> datasList = new ArrayList>(); + Map datasMap = new HashMap<>(); + + datasList = (List>) params.get("datas"); + boolean isKqReportHalfOpen = "1".equals(new KQSettingsComInfo().getMain_val("kq_report_half")); + for (int i = 0; datasList != null && i < datasList.size(); i++) { + datasMap = (Map) datasList.get(i); + //String rowSpan = Util.null2String(datasMap.get("rowSpan")); + //if ("2".equalsIgnoreCase(rowSpan)) { + // 如果是开启了半天开关,那么就不可能是一天多次上下班,所以这里直接显示第一次结果就行了 + if(isKqReportHalfOpen && i>0) { + break; + } + workDays += Util.getDoubleValue((String) datasMap.get("workdays"), 0.00);//应出勤天数 + realWorkDays += Util.getDoubleValue((String) datasMap.get("attendancedays"), 0.00);//实际出勤天数 + leaveDays = workDays - realWorkDays;//缺勤天数 + + beLate += Util.getIntValue((String) datasMap.get("beLate"), 0);//迟到次数 + graveBeLate += Util.getIntValue((String) datasMap.get("graveBeLate"), 0);//严重迟到次数 + leaveEearly += Util.getIntValue((String) datasMap.get("leaveEearly"), 0);//早退次数 + graveLeaveEarly += Util.getIntValue((String) datasMap.get("graveLeaveEarly"), 0);//严重迟到次数 + absenteeism += Util.getIntValue((String) datasMap.get("absenteeism"), 0);//旷工次数 + forgotCheck += Util.getIntValue((String) datasMap.get("forgotCheck"), 0);//漏签次数 + + overtimeTotal += Util.getDoubleValue((String) datasMap.get("overtimeTotal"), 0.00);//加班时长 + businessLeave += Util.getDoubleValue((String) datasMap.get("businessLeave"), 0.00);//出差时长 + officialBusiness += Util.getDoubleValue((String) datasMap.get("officialBusiness"), 0.00);//公出时长 + + rulesComInfo.setTofirstRow(); + while (i == 0 && rulesComInfo.next()) { + double value = Util.getDoubleValue(String.valueOf(leaveMap.get("leaveType_" + rulesComInfo.getId())), 0.00); + value += Util.getDoubleValue((String) datasMap.get("leaveType_" + rulesComInfo.getId()), 0.00);//请假时长 + leaveMap.put("leaveType_" + rulesComInfo.getId(), value); + } + //} + } + + /**统计应出勤天数*/ + KQWorkTime kqWorkTime = new KQWorkTime(); + if (!toDate.equals("") && toDate.compareTo(currentDate) > 0 && Util.getIntValue(resourceComInfo.getStatus(resourceId), 0) < 4) { + workDays = 0.00; + if (!fromDate.equals("") && fromDate.compareTo(currentDate) > 0) { + //查询没有到的月份,缺勤天数以及出勤天数应该都为0 + realWorkDays = 0.00; + leaveDays = 0.00; + } + + boolean isEnd = false; + for (String date = fromDate; !isEnd; ) { + if (date.compareTo(toDate)>=0) { + isEnd = true; + } + + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(resourceId, date); + String dayType = workTimeEntity.getDayType(); + String convertAttendDay = Util.null2s(workTimeEntity.getConvertAttendDay(),"1.0"); + boolean isWorkDay = "work".equalsIgnoreCase(dayType); + if (isWorkDay) { + workDays += (1.00*Util.getDoubleValue(convertAttendDay, 1.0)); + } + + date = DateUtil.getDate(date, 1); + } + } + + /**********************************************************************************************************/ + + itemList = new ArrayList(); + itemMap = new HashMap(); + itemMap.put("id", "leaveDays"); + itemMap.put("name", SystemEnv.getHtmlLabelName(506345, user.getLanguage()));//未出勤 + itemMap.put("title", SystemEnv.getHtmlLabelName(506345, user.getLanguage())); + itemMap.put("type", "ABSENT"); + itemMap.put("value", String.format("%.2f", leaveDays)); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("id", "realWorkDays"); + itemMap.put("name", SystemEnv.getHtmlLabelName(130566, user.getLanguage()));//实际出勤 + itemMap.put("title", SystemEnv.getHtmlLabelName(130566, user.getLanguage())); + itemMap.put("type", "REALWORKDAYS"); + itemMap.put("value", String.format("%.2f", realWorkDays)); + itemList.add(itemMap); + + groupItem = new HashMap(); + groupItem.put("id", "workDays"); + groupItem.put("name", SystemEnv.getHtmlLabelName(513089, user.getLanguage()));//应出勤(天) + groupItem.put("title", SystemEnv.getHtmlLabelName(16732, user.getLanguage())); + groupItem.put("value", String.format("%.2f", workDays)); + groupItem.put("items", itemList); + resultMap.put("groupitem1", groupItem); + + /**********************************************************************************************************/ + + itemList = new ArrayList(); + itemMap = new HashMap(); + itemMap.put("name", "evection"); + itemMap.put("title", SystemEnv.getHtmlLabelName(20084, user.getLanguage()) + tr_unitName);//出差 + itemMap.put("type", "EVECTION"); + itemMap.put("value", String.format("%.2f",businessLeave)); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("name", "outDays"); + itemMap.put("title", SystemEnv.getHtmlLabelName(24058, user.getLanguage()) + er_unitName);//公出 + itemMap.put("type", "OUTDAYS"); + itemMap.put("value",String.format("%.2f",officialBusiness)); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("name", "overTimes"); + itemMap.put("title", SystemEnv.getHtmlLabelName(6151, user.getLanguage()) + or_unitName);//加班 + itemMap.put("type", "OVERTIME"); + itemMap.put("value", String.format("%.2f",overtimeTotal)); + itemList.add(itemMap); + + groupItem = new HashMap(); + groupItem.put("items", itemList); + resultMap.put("groupitem2", groupItem); + + /**********************************************************************************************************/ + + itemList = new ArrayList(); + itemMap = new HashMap(); + itemMap.put("name", "beLate"); + itemMap.put("title", SystemEnv.getHtmlLabelName(34089, user.getLanguage()));//迟到 + itemMap.put("type", "BELATE"); + itemMap.put("value", beLate); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("name", "graveBeLate"); + itemMap.put("title", SystemEnv.getHtmlLabelName(535131, user.getLanguage()));//严重迟到 + itemMap.put("type", "graveBeLate"); + itemMap.put("value", graveBeLate); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("name", "leaveEarly"); + itemMap.put("title", SystemEnv.getHtmlLabelName(34098, user.getLanguage()));//早退 + itemMap.put("type", "LEAVEEARLY"); + itemMap.put("value", leaveEearly); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("name", "graveLeaveEarly"); + itemMap.put("title", SystemEnv.getHtmlLabelName(535132, user.getLanguage()));//严重早退 + itemMap.put("type", "graveLeaveEarly"); + itemMap.put("value", graveLeaveEarly); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("name", "absentFromWork"); + itemMap.put("title", SystemEnv.getHtmlLabelName(10000344, user.getLanguage()));//旷工 + itemMap.put("type", "ABSENT"); + itemMap.put("value", absenteeism); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("name", "noSign"); + itemMap.put("title", SystemEnv.getHtmlLabelName(34099, user.getLanguage()));//漏签 + itemMap.put("type", "noSign"); + itemMap.put("value", forgotCheck); + itemList.add(itemMap); + + groupItem = new HashMap(); + groupItem.put("items", itemList); + resultMap.put("groupitem3", groupItem); + + /**********************************************************************************************************/ + + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + if (!rulesComInfo.getIsEnable().equals("1") || !rulesComInfo.getBalanceEnable().equals("1")) { + continue; + } +// writeLog("lxr2018>.resourceId="+resourceId+ +// ";getScopeType="+rulesComInfo.getScopeType()+ +// ";getScopeValue="+rulesComInfo.getScopeValue()); + boolean flag = KQLeaveRulesBiz.filterSubLeaveRule(resourceId, rulesComInfo.getScopeType(), rulesComInfo.getScopeValue(), subCompanyId+"", departmentId+""); + if (flag) { + continue; + } +// writeLog("lxr2018>.flag="+flag); + String allRestAmount = KQBalanceOfLeaveBiz.getRestAmount("" + resourceId, rulesComInfo.getId(), balanceDate, true, true); + String currentRestAmount = KQBalanceOfLeaveBiz.getRestAmount("" + resourceId, rulesComInfo.getId(), balanceDate, true, false); + String beforeRestAmount = String.format("%.2f", Util.getDoubleValue(allRestAmount, 0) - Util.getDoubleValue(currentRestAmount, 0)); + itemList = new ArrayList(); + if(KQSettingsBiz.show_split_balance()) { + itemMap = new HashMap(); + itemMap.put("title", (KQUnitBiz.isLeaveHour(rulesComInfo.getMinimumUnit())) ? SystemEnv.getHtmlLabelName(513286, user.getLanguage()) : SystemEnv.getHtmlLabelName(513287, user.getLanguage())); + itemMap.put("value", beforeRestAmount); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("title", (KQUnitBiz.isLeaveHour(rulesComInfo.getMinimumUnit())) ? SystemEnv.getHtmlLabelName(504395, user.getLanguage()) : SystemEnv.getHtmlLabelName(504394, user.getLanguage())); + itemMap.put("value", currentRestAmount); + itemList.add(itemMap); + + itemMap = new HashMap(); + itemMap.put("title", (KQUnitBiz.isLeaveHour(rulesComInfo.getMinimumUnit())) ? SystemEnv.getHtmlLabelName(513288, user.getLanguage()) : SystemEnv.getHtmlLabelName(513289, user.getLanguage())); + itemMap.put("value", allRestAmount); + itemList.add(itemMap); + }else{ + itemMap = new HashMap(); + itemMap.put("title", (KQUnitBiz.isLeaveHour(rulesComInfo.getMinimumUnit())) ? SystemEnv.getHtmlLabelName(513288, user.getLanguage()) : SystemEnv.getHtmlLabelName(513289, user.getLanguage())); + itemMap.put("value", allRestAmount); + itemList.add(itemMap); + } + + groupItem = new HashMap(); + groupItem.put("color", "#25C6DA"); + groupItem.put("icon", "icon-Human-resources-adjustment"); + groupItem.put("title", rulesComInfo.getLeaveName()); + groupItem.put("item", itemList); + groupItemList.add(groupItem); + } + groupMap.put("items", groupItemList); + groupMap.put("title", SystemEnv.getHtmlLabelName(132058, user.getLanguage())); + resultMap.put("groupitem4", groupMap); + + /**********************************************************************************************************/ + + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + boolean flag = KQLeaveRulesBiz.filterSubLeaveRule(resourceId, rulesComInfo.getScopeType(), rulesComInfo.getScopeValue(), subCompanyId+"", departmentId+""); + if (flag) { + continue; + } + double value = Util.getDoubleValue(String.valueOf(leaveMap.get("leaveType_" + rulesComInfo.getId())), 0.00);//请假时长 + if (value > 0) { + String leaveName = Util.formatMultiLang(rulesComInfo.getLeaveName(), "" + user.getLanguage()); + int le_minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(), 1);//最小请假单位 + String le_unitName = (le_minimumUnit == 3 || le_minimumUnit == 5 || le_minimumUnit == 6) ? SystemEnv.getHtmlLabelName(389326, user.getLanguage()) : SystemEnv.getHtmlLabelName(389325, user.getLanguage()); + + itemMap = new HashMap(); + itemMap.put("name", "leaveType_" + rulesComInfo.getId()); + itemMap.put("title", leaveName + le_unitName); + itemMap.put("type", "leaveType_" + rulesComInfo.getId()); + itemMap.put("value", Util.toDecimalDigits("" + value, 2)); + itemList5.add(itemMap); + } + } + groupItem5.put("items", itemList5); + resultMap.put("groupitem5", groupItem5); + resultMap.put("status", "1"); + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/myattendance/GetHrmKQSignInfoCmd.java b/src/com/engine/kq/cmd/myattendance/GetHrmKQSignInfoCmd.java new file mode 100644 index 0000000..f66ea68 --- /dev/null +++ b/src/com/engine/kq/cmd/myattendance/GetHrmKQSignInfoCmd.java @@ -0,0 +1,508 @@ +package com.engine.kq.cmd.myattendance; + +import com.api.hrm.util.HrmTransMethod; +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.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.wfset.util.KQSignUtil; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 获取签到签退信息 + */ +public class GetHrmKQSignInfoCmd extends AbstractCommonCommand> { + + public GetHrmKQSignInfoCmd(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(); + try { + String date = Util.null2String(params.get("date")); + String resourceId = Util.null2String(params.get("resourceId")); + if (resourceId.equals("")) { + resourceId = String.valueOf(user.getUID()); + } + String isMobile = Util.null2String(params.get("isMobile"));//是否是移动端的【我的考勤】 + + /**判断是否显示补打卡数据*/ + boolean showCard = false; + String settingSql = "select * from KQ_SETTINGS where main_key='showSignFromCard'"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(settingSql); + if (recordSet.next()) { + String main_val = recordSet.getString("main_val"); + showCard = main_val.equals("1"); + } + + Map signStatusInfo = new HashMap(); + + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + List dataList = new ArrayList<>(); + Map dataMap = new HashMap<>(); + List dataItemList = new ArrayList<>(); + Map dataItemMap = new HashMap<>(); + + String serialId = ""; + String sql = "SELECT a.RESOURCEID, a.KQDATE, a.GROUPID,a.day_type, a.SERIALID, a.SERIALNUMBER, a.WORKBEGINDATE,\n " + + "a.WORKBEGINTIME, a.WORKENDDATE, a.WORKENDTIME, a.WORKMINS, a.SIGNINDATE, a.SIGNINTIME,\n " + + "a.SIGNINID, a.SIGNOUTDATE, a.SIGNOUTTIME, a.SIGNOUTID, a.ATTENDANCEMINS, a.BELATEMINS,\n " + + "a.GRAVEBELATEMINS, a.LEAVEEARLYMINS, a.GRAVELEAVEEARLYMINS, a.ABSENTEEISMMINS, a.LEAVEMINS,\n " + + "a.EVECTIONMINS, a.OUTMINS, a.FORGOTCHECKMINS, a.SIGNMINS, a.LEAVEINFO, a.FORGOTBEGINWORKCHECKMINS,\n " + + "'signIn' signType,a.signInDate signDate,a.signInTime signTime,b.clientAddress,b.addr,b.attachment \n " + + "FROM KQ_FORMAT_DETAIL a LEFT JOIN HrmScheduleSign b ON a.signInId=b.id " + + "WHERE kqDate='" + date + "' AND resourceId=" + resourceId + "\n "; + if (!showCard) { + sql += " AND (signFrom is null or signFrom not like 'card%') "; + } + sql += "UNION ALL\n " + + "SELECT a.RESOURCEID, a.KQDATE, a.GROUPID,a.day_type, a.SERIALID, a.SERIALNUMBER, a.WORKBEGINDATE,\n " + + "a.WORKBEGINTIME, a.WORKENDDATE, a.WORKENDTIME, a.WORKMINS, a.SIGNINDATE, a.SIGNINTIME,\n " + + "a.SIGNINID, a.SIGNOUTDATE, a.SIGNOUTTIME, a.SIGNOUTID, a.ATTENDANCEMINS, a.BELATEMINS,\n " + + "a.GRAVEBELATEMINS, a.LEAVEEARLYMINS, a.GRAVELEAVEEARLYMINS, a.ABSENTEEISMMINS, a.LEAVEMINS,\n " + + "a.EVECTIONMINS, a.OUTMINS, a.FORGOTCHECKMINS, a.SIGNMINS, a.LEAVEINFO, a.FORGOTBEGINWORKCHECKMINS,\n " + + "'signOut' signType,a.signOutDate signDate,a.signOutTime signTime,b.clientAddress,b.addr,b.attachment \n " + + "FROM KQ_FORMAT_DETAIL a LEFT JOIN HrmScheduleSign b ON a.signOutId=b.id " + + "WHERE kqDate='" + date + "' AND resourceId=" + resourceId + "\n "; + if (!showCard) { + sql += " AND (signFrom is null or signFrom not like 'card%') "; + } + sql += "ORDER BY kqDate,resourceId,serialNumber,signType "; + recordSet.executeQuery(sql); + boolean hasRecord = false; + while (recordSet.next()) { + hasRecord = true; + String signType = recordSet.getString("signType"); + String dayType = recordSet.getString("day_type"); + String signDate = recordSet.getString("signDate"); + String signTime = recordSet.getString("signTime"); + String clientAddress = recordSet.getString("clientAddress"); + String addr = recordSet.getString("addr"); + String attachment = recordSet.getString("attachment"); + + serialId = Util.null2String(recordSet.getString("serialId")); + int serialNumber = recordSet.getInt("serialnumber") + 1; + String workBeginTime = Util.null2String(recordSet.getString("workbegintime")).trim(); + String workEndTime = Util.null2String(recordSet.getString("workendtime")).trim(); + int workMins = recordSet.getInt("workMins"); + int attendanceMins = recordSet.getInt("attendanceMins"); + String beLateMins = Util.null2String(recordSet.getString("beLateMins")).trim(); + String graveBeLateMins = Util.null2String(recordSet.getString("graveBeLateMins")).trim(); + String leaveEarlyMins = Util.null2String(recordSet.getString("leaveEarlyMins")).trim(); + String graveLeaveEarlyMins = Util.null2String(recordSet.getString("graveLeaveEarlyMins")).trim(); + String absenteeismMins = Util.null2String(recordSet.getString("absenteeismMins")).trim(); + String forgotCheckMins = Util.null2String(recordSet.getString("forgotcheckMins")).trim(); + String forgotBeginWorkCheckMins = Util.null2String(recordSet.getString("forgotBeginWorkCheckMins")).trim(); + int leaveMins = recordSet.getInt("leaveMins"); + String leaveInfo = Util.null2String(recordSet.getString("leaveInfo")); + int evectionMins = recordSet.getInt("evectionMins"); + int outMins = recordSet.getInt("outMins"); + + boolean isNonWork = false; + if(dayType.length() > 0){ + if("holiday".equals(dayType) || "playday".equals(dayType)){ + isNonWork = true; + } + }else{ + if(workMins<=0){ + isNonWork = true; + }else{ + if(serialId.length() > 0){ + String isRest = Util.null2s(kqShiftManagementComInfo.getIsRest(serialId),""); + if("1".equals(isRest)){ + isNonWork = true; + } + } + } + } + signStatusInfo = new HashMap(); + signStatusInfo.put("worktime", workBeginTime); + signStatusInfo.put("absenteeismMins", absenteeismMins); + signStatusInfo.put("leaveMins", leaveMins); + signStatusInfo.put("leaveInfo", leaveInfo); + signStatusInfo.put("evectionMins", evectionMins); + signStatusInfo.put("outMins", outMins); + signStatusInfo.put("isNonWork", isNonWork); + String signStatus = ""; + boolean needWorkFlow = false;//是否需要提交考勤异常流程 + if ("signIn".equals(signType)) { + signStatusInfo.put("beLateMins", beLateMins); + signStatusInfo.put("graveBeLateMins", graveBeLateMins); + signStatusInfo.put("forgotBeginWorkCheckMins", forgotBeginWorkCheckMins); + signStatus = "on"; + if (Util.getDoubleValue(beLateMins, 0) > 0 || Util.getDoubleValue(graveBeLateMins, 0) > 0 || Util.getDoubleValue(forgotBeginWorkCheckMins, 0) > 0 || Util.getDoubleValue(absenteeismMins, 0) > 0) { + needWorkFlow = true; + } + } else { + signStatusInfo.put("leaveEarlyMins", leaveEarlyMins); + signStatusInfo.put("graveLeaveEarlyMins", graveLeaveEarlyMins); + signStatusInfo.put("forgotCheckMins", forgotCheckMins); + signStatusInfo.put("forgotBeginWorkCheckMins", forgotBeginWorkCheckMins); + signStatus = "off"; + if (Util.getDoubleValue(leaveEarlyMins, 0) > 0 || Util.getDoubleValue(graveLeaveEarlyMins, 0) > 0 || Util.getDoubleValue(forgotCheckMins, 0) > 0 || Util.getDoubleValue(absenteeismMins, 0) > 0) { + needWorkFlow = true; + } + } + if (!resourceId.equals("" + user.getUID())) { + needWorkFlow = false; + } + String status = KQReportBiz.getSignStatus2(signStatusInfo, user, signStatus); +// if (serialId.equalsIgnoreCase("")) { +// continue; +// } + if ("signIn".equals(signType)) { + //签到 start + String signDateTime = signDate + " " + signTime; + if (signTime.trim().length() <= 0) { + signDateTime = SystemEnv.getHtmlLabelName(25994, user.getLanguage()); + } + + dataMap = new HashMap<>(); + dataItemList = new ArrayList(); + + dataItemMap = new HashMap(); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(512504, user.getLanguage())); + dataItemMap.put("value", signDateTime); + dataItemList.add(dataItemMap); + + dataItemMap = new HashMap(); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(20032, user.getLanguage()) + "IP"); + dataItemMap.put("value", clientAddress); + dataItemList.add(dataItemMap); + + dataItemMap = new HashMap(); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(125531, user.getLanguage())); + dataItemMap.put("value", addr); + dataItemList.add(dataItemMap); + + if(StringUtils.isNotBlank(attachment)){ + dataItemMap = new HashMap(); + dataItemMap.put("key", "attachment"); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(74, user.getLanguage())); + dataItemMap.put("value", new HrmTransMethod().getAttachment(attachment, user.getUID()+"")); + dataItemList.add(dataItemMap); + } + + dataMap.put("item", dataItemList); + dataMap.put("status", status); + dataMap.put("needWorkFlow", needWorkFlow); + dataList.add(dataMap); + //签到 end + } else { + //签退 start + String signDateTime = signDate + " " + signTime; + if (signTime.trim().length() <= 0) { + signDateTime = SystemEnv.getHtmlLabelName(25994, user.getLanguage()); + } + + dataMap = new HashMap<>(); + dataItemList = new ArrayList(); + + dataItemMap = new HashMap(); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(512505, user.getLanguage())); + dataItemMap.put("value", signDateTime); + dataItemList.add(dataItemMap); + + dataItemMap = new HashMap(); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(20033, user.getLanguage()) + "IP"); + dataItemMap.put("value", clientAddress); + dataItemList.add(dataItemMap); + + dataItemMap = new HashMap(); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(132060, user.getLanguage())); + dataItemMap.put("value", addr); + dataItemList.add(dataItemMap); + + if(StringUtils.isNotBlank(attachment)){ + dataItemMap = new HashMap(); + dataItemMap.put("key", "attachment"); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(74, user.getLanguage())); + dataItemMap.put("value", new HrmTransMethod().getAttachment(attachment, user.getUID()+"")); + dataItemList.add(dataItemMap); + } + + dataMap.put("item", dataItemList); + dataMap.put("status", status); + dataMap.put("needWorkFlow", needWorkFlow); + dataList.add(dataMap); + //签退 end + } + } + + //未来工作日填充打卡信息 + if (!hasRecord) { + //签到 start + String signDateTime = SystemEnv.getHtmlLabelName(25994, user.getLanguage()); + HashMap dataMapStart = new HashMap<>(); + List dataItemListStart = new ArrayList(); + + dataItemMap = new HashMap(); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(512504, user.getLanguage())); + dataItemMap.put("value", signDateTime); + dataItemListStart.add(dataItemMap); + + dataItemMap = new HashMap(); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(20032, user.getLanguage()) + "IP"); + dataItemMap.put("value", ""); + dataItemListStart.add(dataItemMap); + + dataItemMap = new HashMap(); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(125531, user.getLanguage())); + dataItemMap.put("value", ""); + dataItemListStart.add(dataItemMap); + + dataMapStart.put("item", dataItemListStart); + dataMapStart.put("status", ""); + dataMapStart.put("needWorkFlow", false); + dataList.add(dataMapStart); + //签到 end + + //签退 start + HashMap dataMapEnd = new HashMap<>(); + List dataItemListEnd = new ArrayList(); + + dataItemMap = new HashMap(); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(512505, user.getLanguage())); + dataItemMap.put("value", signDateTime); + dataItemListEnd.add(dataItemMap); + + dataItemMap = new HashMap(); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(20033, user.getLanguage()) + "IP"); + dataItemMap.put("value", ""); + dataItemListEnd.add(dataItemMap); + + dataItemMap = new HashMap(); + dataItemMap.put("title", SystemEnv.getHtmlLabelName(132060, user.getLanguage())); + dataItemMap.put("value", ""); + dataItemListEnd.add(dataItemMap); + + dataMapEnd.put("item", dataItemListEnd); + dataMapEnd.put("status", ""); + dataMapEnd.put("needWorkFlow", false); + dataList.add(dataMapEnd); + //签退 end + + } + + Map signDateMap = new HashMap(); + signDateMap.put("date", date); + signDateMap.put("signInfo", dataList); + //班次时间 + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); +// String serialInfo = shiftManagementToolKit.getShiftOnOffWorkSections(serialId, user.getLanguage()); + //班次信息--加入自由班制的判断 + String serialInfo = shiftManagementToolKit.getShiftOnOffWorkSections(serialId, user.getLanguage(), date, resourceId, "true".equals(isMobile)); + signDateMap.put("serialInfo", SystemEnv.getHtmlLabelName(24803, user.getLanguage()) + ":" + serialInfo); + resultMap.put("data", signDateMap); + new BaseBean().writeLog("GetHrmKQSignInfoCmd>>isMobile="+isMobile+";date="+date); + //只有移动端的【我的考勤】才需要显示流程相关的数据 + if ("true".equals(isMobile)) { + //获取考勤流程的相关数据 + List> workflowList = new ArrayList>(); + //请假 + workflowList = getFlowData(KqSplitFlowTypeEnum.LEAVE.getFlowtype()); + if (workflowList == null) { + workflowList = new ArrayList>(); + } + //出差 + workflowList.addAll(getFlowData(KqSplitFlowTypeEnum.EVECTION.getFlowtype())); + if (workflowList == null) { + workflowList = new ArrayList>(); + } + //公出 + workflowList.addAll(getFlowData(KqSplitFlowTypeEnum.OUT.getFlowtype())); + if (workflowList == null) { + workflowList = new ArrayList>(); + } + //加班 + workflowList.addAll(getFlowData(KqSplitFlowTypeEnum.OVERTIME.getFlowtype())); + resultMap.put("workflowInfo", workflowList); + } + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } + + public List> getFlowData(int flowType) { + List> resultList = new ArrayList>(); + try { + String resourceId = Util.null2String(params.get("resourceId")); + if ("".equals(resourceId)) { + resourceId = "" + user.getUID(); + } + String date = Util.null2String(params.get("date")); + if ("".equals(date)) { + date = DateUtil.getCurrentDate(); + } + String firstDateOfMonth = DateUtil.getFirstDayOfMonth(date); + String lastDateOfMonth = DateUtil.getLastDayOfMonth(date); + + /**获取销假*/ + List leaveBackList = getLeaveDate(); + + Map dataMap = new HashMap(); + Map workflowMap = new HashMap(); + List> workflowList = new ArrayList>(); + + boolean showOnHoliday = true;//非工作日是否显示流程(出差、公出、请假) + KQExitRulesComInfo exitRulesComInfo = new KQExitRulesComInfo(); + KQTravelRulesComInfo travelRulesComInfo = new KQTravelRulesComInfo(); + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + KQWorkTime kqWorkTime = new KQWorkTime(); + + if (flowType == 2) { + showOnHoliday = exitRulesComInfo.getComputingMode("1").equals("2"); + } else if (flowType == 1) { + showOnHoliday = travelRulesComInfo.getComputingMode("1").equals("2"); + } + + Map paramsMap = new HashMap(); + paramsMap.put("typeselect", "6"); + paramsMap.put("tabKey", "1"); + paramsMap.put("kqtype", "" + flowType); + paramsMap.put("resourceId", resourceId); + paramsMap.put("fromDate", firstDateOfMonth); + paramsMap.put("toDate", lastDateOfMonth); + paramsMap.put("isMyKQ", "1"); + + KQAttFlowSetBiz kqAttFlowSetBiz = new KQAttFlowSetBiz(); + Map sqlMap = kqAttFlowSetBiz.getFLowSql(paramsMap, user); + String sqlFrom = sqlMap.get("from"); + String sqlWhere = sqlMap.get("where"); + + String sql = "select * " + sqlFrom + sqlWhere; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String requestId = recordSet.getString("requestId"); + double duration = Util.getDoubleValue(recordSet.getString("duration"), 0.00); + double backDuration = 0.00; + String requestName = recordSet.getString("requestName"); + int durationRule = Util.getIntValue(recordSet.getString("durationrule")); + String unitName = ""; + if (durationRule == 3 || durationRule == 5 || durationRule == 6) { + unitName = SystemEnv.getHtmlLabelName(389326, user.getLanguage()); + } else { + unitName = SystemEnv.getHtmlLabelName(389325, user.getLanguage()); + } + String fromDateTemp = recordSet.getString("fromDate"); + String fromTimeTemp = recordSet.getString("fromTime"); + String toDateTemp = recordSet.getString("toDate"); + String toTimeTemp = recordSet.getString("toTime"); + String leaveRulesId = ""; + String period = SystemEnv.getHtmlLabelName(506047, user.getLanguage()) + ":" + String.format("%.2f", duration) + unitName; + if (flowType == 0) { + backDuration = Util.getDoubleValue(recordSet.getString("backDuraion"), 0.00); + if (backDuration > 0) { + period = SystemEnv.getHtmlLabelName(506047, user.getLanguage()) + ":" + String.format("%.2f", duration) + "(" + SystemEnv.getHtmlLabelName(24473, user.getLanguage()) + ":" + String.format("%.2f", backDuration) + ")" + unitName; + } + leaveRulesId = recordSet.getString("newleavetype"); + showOnHoliday = rulesComInfo.getComputingMode(leaveRulesId).equals("2"); + } + + boolean isEnd = false; + for (String dateTemp = fromDateTemp; !isEnd; ) { + if (dateTemp.equals(toDateTemp)) { + isEnd = true; + } + if (!leaveBackList.contains(resourceId + "|" + date + "|" + requestId)) { + workflowList = (ArrayList>) dataMap.get(resourceId + "|" + dateTemp); + if (null == workflowList) { + workflowList = new ArrayList>(); + } + workflowMap = new HashMap(); + workflowMap.put("title", requestName); + workflowMap.put("period", period); + workflowMap.put("requestId", requestId); + workflowList.add(workflowMap); + + boolean isWorkDay = kqWorkTime.isWorkDay(resourceId, date); + if (!(!isWorkDay && !showOnHoliday)) { + dataMap.put(resourceId + "|" + dateTemp, workflowList); + } + } + + dateTemp = DateUtil.getDate(dateTemp, 1); + } + } + if (dataMap.get(resourceId + "|" + date) != null) { + resultList = (ArrayList>) dataMap.get(resourceId + "|" + date); + } + } catch (Exception e) { + e.printStackTrace(); + } + return resultList; + } + + /** + * 获取请完假之后又销掉的日期 + * + * @return + */ + private List getLeaveDate() { + List resultList = new ArrayList(); + try { + String resourceId = Util.null2String(params.get("resourceId")); + if ("".equals(resourceId)) { + resourceId = "" + user.getUID(); + } + String date = Util.null2String(params.get("date")); + if ("".equals(date)) { + date = DateUtil.getCurrentDate(); + } + String firstDateOfMonth = DateUtil.getFirstDayOfMonth(date); + String lastDateOfMonth = DateUtil.getLastDayOfMonth(date); + + String leaveBackTableName = KqSplitFlowTypeEnum.LEAVEBACK.getTablename(); + String leaveTableName = KqSplitFlowTypeEnum.LEAVE.getTablename(); + String sql = " select requestId,resourceId,belongDate,duration,durationRule," + + " (select sum(duration) from " + leaveBackTableName + " where " + leaveBackTableName + ".leavebackrequestid=" + leaveTableName + ".requestid " + + " and " + leaveBackTableName + ".newleavetype=" + leaveTableName + ".newleavetype " + + " and " + leaveBackTableName + ".belongdate=" + leaveTableName + ".belongDate ) as backDuration " + + " from " + leaveTableName + " where 1=1 "; + if (!resourceId.equals("")) { + sql += " and " + leaveTableName + ".resourceId=" + resourceId; + } + if (firstDateOfMonth.length() > 0 && lastDateOfMonth.length() > 0) { + sql += " and " + leaveTableName + ".belongdate between'" + firstDateOfMonth + "' and '" + lastDateOfMonth + "' "; + } + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String requestId = recordSet.getString("requestId"); + String belongDate = recordSet.getString("belongDate"); + double duration = Util.getDoubleValue(recordSet.getString("duration"), 0.00); + double backDuration = Util.getDoubleValue(recordSet.getString("backDuration"), 0.00); + if (backDuration >= duration) { + resultList.add(resourceId + "|" + belongDate + "|" + requestId); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return resultList; + } +} diff --git a/src/com/engine/kq/cmd/originalpunchrp/ExportExcelCmd.java b/src/com/engine/kq/cmd/originalpunchrp/ExportExcelCmd.java new file mode 100644 index 0000000..2967518 --- /dev/null +++ b/src/com/engine/kq/cmd/originalpunchrp/ExportExcelCmd.java @@ -0,0 +1,347 @@ +package com.engine.kq.cmd.originalpunchrp; + +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.KQTransMethod; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.*; +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.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.OutputStream; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 原始打卡记录--将查询结果导出为Excel文件 + */ +public class ExportExcelCmd extends AbstractCommonCommand> { + + private HttpServletRequest request; + private HttpServletResponse response; + + public ExportExcelCmd(Map params, User user, HttpServletRequest request, HttpServletResponse response) { + this.user = user; + this.params = params; + this.request = request; + this.response = response; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + long startTime = System.currentTimeMillis(); + RecordSet recordSet = new RecordSet(); + Map resultMap = new HashMap(); + new KQReportBiz().insertKqReportExportLog(params, user); + /** + * 展示列 + */ + String displayColumn = Util.null2String(params.get("showCol"));//展示列 + List displayColumnList = Util.TokenizerString(displayColumn, ","); + // #1473334-概述:满足考勤报分部部门显示及导出时显示全路径 + String fullPathMainKey = "show_full_path"; + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); + String subCompanyNameTmp = ""; + String departmentNameTmp = ""; + boolean has_incom = false; + String sql = "select * from kq_settings where main_key='show_incom' "; + recordSet.executeQuery(sql); + if(recordSet.next()){ + String main_val = recordSet.getString("main_val"); + if("1".equalsIgnoreCase(main_val)){ + has_incom = true; + } + } + /** + * 数据范围 + * dataScope:0-总部、1-分部、2-分部、3-人员、4-我的下属 + * subcomId:指定分部ID + * deptId:指定部门ID + * resourceId:指定人员ID + * allLevel:是否包含下级下属:0-不包含、1-包含 + */ + String dateScope = Util.null2String(params.get("dateScope"));//日期范围 + String startDate = Util.null2String(params.get("startDate"));//开始日期 + String endDate = Util.null2String(params.get("endDate"));//结束日期 + if (!dateScope.equals("") && !dateScope.equals("0") && !dateScope.equals("6")) { + startDate = TimeUtil.getDateByOption(dateScope, "0"); + endDate = TimeUtil.getDateByOption(dateScope, "1"); + } + // 没有权限的人最大只支持查询本季 + Map getRealDate = new KQReportBiz().realDate(startDate, endDate, user, "3"); + startDate = getRealDate.get("fromDate"); + endDate = getRealDate.get("toDate"); + + //人员状态 + String status = Util.null2String(params.get("status")); + String dataScope = Util.null2String(params.get("dataScope"));//数据范围 + String subcomId = Util.null2String(params.get("subcomId"));//分部ID + String deptId = Util.null2String(params.get("deptId"));//部门ID + String resourceId = Util.null2String(params.get("resourceId"));//人员ID + String allLevel = Util.null2String(params.get("allLevel"));//包含下级下属 + String isNoaccount = Util.null2String(params.get("isNoAccount"));//是否显示无账号人员 + + try { + /** + * 获取考勤报表权限共享设置 + */ + KQReportBiz kqReportBiz = new KQReportBiz(); + String rightStr = kqReportBiz.getReportRight("3", "" + user.getUID(), "b"); + + /** + * 拼凑查询结果Excel文件的表头 + */ + HSSFWorkbook workbook = new HSSFWorkbook(); + HSSFSheet sheet = workbook.createSheet(SystemEnv.getHtmlLabelName(390248, user.getLanguage()));//原始打卡记录 + // 设置字体 + Font font = workbook.createFont(); + //设置字体大小 + font.setFontHeightInPoints((short) 14); + //字体加粗 + font.setBold(true); + //设置字体名字 + font.setFontName("宋体"); + //设置样式; + CellStyle style = workbook.createCellStyle(); + //设置底边框; + style.setBorderBottom(BorderStyle.THIN); + //设置底边框颜色; + style.setBottomBorderColor(IndexedColors.BLACK.index); + //设置左边框; + style.setBorderLeft(BorderStyle.THIN); + //设置左边框颜色; + style.setLeftBorderColor(IndexedColors.BLACK.index); + //设置右边框; + style.setBorderRight(BorderStyle.THIN); + //设置右边框颜色; + style.setRightBorderColor(IndexedColors.BLACK.index); + //设置顶边框; + style.setBorderTop(BorderStyle.THIN); + //设置顶边框颜色; + style.setTopBorderColor(IndexedColors.BLACK.index); + //在样式用应用设置的字体; + style.setFont(font); + //设置自动换行; + style.setWrapText(false); + //设置水平对齐的样式为居中对齐; + style.setAlignment(HorizontalAlignment.CENTER); + //设置垂直对齐的样式为居中对齐; + style.setVerticalAlignment(VerticalAlignment.CENTER); + + int index = 0; + HSSFRow headerRow = sheet.createRow(0); + String[] tempArr = new String[]{SystemEnv.getHtmlLabelName(413, user.getLanguage()) + ",lastName", SystemEnv.getHtmlLabelName(141, user.getLanguage()) + ",subcom", SystemEnv.getHtmlLabelName(124, user.getLanguage()) + ",dept", SystemEnv.getHtmlLabelName(6086, user.getLanguage()) + ",jobtitle", SystemEnv.getHtmlLabelName(714, user.getLanguage()) + ",workcode"}; + for (int i = 0; i < tempArr.length; i++) { + String[] fieldInfo = tempArr[i].split(","); + if (fieldInfo[1].equals("lastName") || displayColumnList.indexOf(fieldInfo[1]) > -1) { + headerRow.setHeight((short) 312); + HSSFCell headCell = headerRow.createCell(index); + headCell.setCellValue(fieldInfo[0]); + headCell.setCellStyle(style); + sheet.setColumnWidth((short) index, (short) (6 * 1000)); + index++; + } + } + + /**********************************************************************************************************/ + String[] columnList = new String[] {"18949#signDate","390501#addr","32531#clientAddress","28006#signFrom","515803#deviceinfo","520084#isincom","547817#mayVirtualLocation"}; + for(String columnStr : columnList) { + String inShowIncom = columnStr.split("#")[1]; + if(!has_incom) { + if("isincom".equals(inShowIncom) || "mayVirtualLocation".equals(inShowIncom)) { + continue; + } + } + String showName = SystemEnv.getHtmlLabelName(Integer.valueOf(columnStr.split("#")[0]), user.getLanguage()); + headerRow.setHeight((short) 312); + HSSFCell headCell = headerRow.createCell(index); + headCell.setCellValue(showName); + headCell.setCellStyle(style); + sheet.setColumnWidth((short) index, (short) (6 * 1000)); + index++; + } + + /** + * 用于拼凑查询结果列表的表数据 + */ + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + + index = 0; + String backFields = " a.*,b.subcompanyId1,b.departmentId,b.jobtitle,b.workcode "; + String sqlFrom = " from HrmScheduleSign a,HrmResource b "; + String sqlWhere = " where a.userId=b.id "; + /*原始打卡记录是否显示补打卡流程的数据*/ + String showCardOnOriginalpunchRp = "0";//0-表示不显示、1-表示显示 + String kqSettingSql = "select * from kq_settings where main_key='showCardOnOriginalpunchRp'"; + + recordSet.executeQuery(kqSettingSql); + if(recordSet.next()){ + showCardOnOriginalpunchRp = recordSet.getString("main_val"); + } + if(!showCardOnOriginalpunchRp.equals("1")){ + sqlWhere += " and (signfrom is null or signfrom='' or signfrom not like 'card%') "; + } + if (!startDate.equals("")) { + sqlWhere += " and (signDate is not null and signDate>='" + startDate + "') "; + } + if (!endDate.equals("")) { + sqlWhere += " and (signDate is not null and signDate<='" + endDate + "') "; + } + if (dataScope.equals("1") && !subcomId.equals("")) { + sqlWhere += " and b.subcompanyId1 in (" + subcomId + ")"; + } + if (dataScope.equals("2") && !deptId.equals("")) { + sqlWhere += " and b.departmentId in (" + deptId + ")"; + } + if (dataScope.equals("3") && !resourceId.equals("")) { + sqlWhere += " and userId in (" + resourceId + ")"; + } + if (dataScope.equals("4")) { + if (allLevel.equals("1")) { + sqlWhere += " and (b.id=" + user.getUID() + " or b.managerStr like '%," + user.getUID() + ",%' )"; + } else { + sqlWhere += " and (b.id=" + user.getUID() + " or b.managerid = " + user.getUID() + ")"; + } + } + if (isNoaccount.equals("false")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") + || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere += " and (loginId is not null and loginId<>'')"; + } else { + sqlWhere += " and (loginId is not null)"; + } + } + + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and b.status = "+status+ ""; + }else if (status.equals("8")) { + sqlWhere += " and (b.status = 0 or b.status = 1 or b.status = 2 or b.status = 3) "; + } + } + + //考勤报表共享设置 + if (!rightStr.equals("") && !dataScope.equals("4")) { + sqlWhere += rightStr; + } + String orderBy = " order by userId,signDate,signTime "; + if("-1".equals(startDate) || "-1".equals(endDate)) { + sqlWhere += " and 1=2 "; + } + sql = "select "+backFields+sqlFrom+sqlWhere+orderBy; + recordSet.executeQuery(sql); + while (recordSet.next()) { + HSSFRow row = sheet.createRow(++index); + + String id = recordSet.getString("id"); + String lastName = recordSet.getString("lastName"); + String departmentId = recordSet.getString("departmentId"); + String subcompanyId = recordSet.getString("subcompanyId1"); + String jobtitleId = recordSet.getString("jobtitle"); + String workcode = recordSet.getString("workcode"); + + int cellIndex = 0; + HSSFCell cell = row.createCell(cellIndex); + cell.setCellValue(Util.formatMultiLang(lastName, "" + user.getLanguage())); + cellIndex++; + if (displayColumnList.indexOf("subcom") > -1) { + cell = row.createCell(cellIndex); + + // 导出时,是否显示全路径 + subCompanyNameTmp = "1".equals(isShowFullPath) ? + SubCompanyComInfo.getSubcompanyRealPath(subcompanyId, "/", "0") : + subCompanyComInfo.getSubCompanyname(subcompanyId); + cell.setCellValue(Util.formatMultiLang(subCompanyNameTmp, "" + user.getLanguage())); + + // cell.setCellValue(Util.formatMultiLang(subCompanyComInfo.getSubcompanyname(subcompanyId), "" + user.getLanguage())); + cellIndex++; + } + if (displayColumnList.indexOf("dept") > -1) { + cell = row.createCell(cellIndex); + + // 导出时,是否显示全路径 + departmentNameTmp = "1".equals(isShowFullPath) ? + departmentComInfo.getDepartmentRealPath(departmentId, "/", "0") : + departmentComInfo.getDepartmentname(departmentId); + cell.setCellValue(Util.formatMultiLang(departmentNameTmp, "" + user.getLanguage())); + + // cell.setCellValue(Util.formatMultiLang(departmentComInfo.getDepartmentname(departmentId), "" + user.getLanguage())); + cellIndex++; + } + if (displayColumnList.indexOf("jobtitle") > -1) { + cell = row.createCell(cellIndex); + cell.setCellValue(Util.formatMultiLang(jobTitlesComInfo.getJobTitlesname(jobtitleId), "" + user.getLanguage())); + cellIndex++; + } + if (displayColumnList.indexOf("workcode") > -1) { + cell = row.createCell(cellIndex); + cell.setCellValue(Util.formatMultiLang(workcode, "" + user.getLanguage())); + cellIndex++; + } + for(String columnStr : columnList) { + String inShowIncom = columnStr.split("#")[1]; + if(!has_incom) { + if("isincom".equals(inShowIncom) || "mayVirtualLocation".equals(inShowIncom)) { + continue; + } + } + String showName = SystemEnv.getHtmlLabelName(Integer.valueOf(columnStr.split("#")[0]), user.getLanguage()); + cell = row.createCell(cellIndex); + cell.setCellValue(Util.formatMultiLang(showName, "" + user.getLanguage())); + cellIndex++; + } + } + + String encodedFileName = SystemEnv.getHtmlLabelName(390248, user.getLanguage()); + response.reset(); + response.setContentType("application/vnd.ms-excel;charset=utf-8"); + response.setCharacterEncoding("utf-8"); + String header = request.getHeader("User-Agent").toUpperCase(); + if (header.contains("MSIE") || header.contains("TRIDENT") || header.contains("EDGE")) { + encodedFileName = URLEncoder.encode(encodedFileName, "utf-8"); + encodedFileName = encodedFileName.replace("+", "%20"); //IE下载文件名空格变+号问题 + } else { + encodedFileName = new String(encodedFileName.getBytes("utf-8"), "ISO_8859_1"); + } + response.setHeader("Content-disposition", "attachment;filename=" + encodedFileName + "excel.xls"); + response.setContentType("application/msexcel"); + response.setContentType("application/x-msdownload"); + OutputStream responseOutput = response.getOutputStream(); + workbook.write(responseOutput); + responseOutput.flush(); + } catch (Exception e) { + writeLog(e); + } + long endTime = System.currentTimeMillis(); + float seconds = (endTime - startTime) / 1000F; + System.out.println(Float.toString(seconds) + " seconds."); + resultMap.put("status", "1"); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/originalpunchrp/GetRightMenuCmd.java b/src/com/engine/kq/cmd/originalpunchrp/GetRightMenuCmd.java new file mode 100644 index 0000000..6b6a8eb --- /dev/null +++ b/src/com/engine/kq/cmd/originalpunchrp/GetRightMenuCmd.java @@ -0,0 +1,46 @@ +package com.engine.kq.cmd.originalpunchrp; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 原始打卡记录报表--获取右键菜单 + */ +public class GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(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(); + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + int languageId = user.getLanguage();//用户选择的语言 + RightMenu rightMenu = null; + + rightMenu = new RightMenu(languageId, RightMenuType.BTN_EXPORTEXCEL, "excel", true);//Excel导出 + rightMenuList.add(rightMenu); + + rightMenu = new RightMenu(languageId, RightMenuType.BTN_KQ_Refresh, "refresh", false);//刷新 + rightMenuList.add(rightMenu); + + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/originalpunchrp/GetSearchConditionCmd.java b/src/com/engine/kq/cmd/originalpunchrp/GetSearchConditionCmd.java new file mode 100644 index 0000000..ecbec2e --- /dev/null +++ b/src/com/engine/kq/cmd/originalpunchrp/GetSearchConditionCmd.java @@ -0,0 +1,281 @@ +package com.engine.kq.cmd.originalpunchrp; + +import com.api.browser.bean.BrowserTabBean; +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.bean.SelectOption; +import com.api.hrm.bean.WeaRadioGroup; +import com.api.hrm.util.HrmAdvancedSearchUtil; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.biz.KQSettingsBiz; +import com.google.common.collect.Lists; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.settings.ChgPasswdReminder; +import weaver.hrm.settings.RemindSettings; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 原始打卡记录报表--获取查询条件 + */ +public class GetSearchConditionCmd extends AbstractCommonCommand> { + + public GetSearchConditionCmd(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(); + // true: 开启; false: 关闭--关闭的话就是标准功能 + boolean kq_personal_reportsearch = KQSettingsBiz.showLeaveTypeSet("kq_personal_reportsearch"); + /** + * 数据范围 + * 总部、分部、部门、人员、我的下属(管理员没有我的下属,没有下属的人员也不显示我的下属) + * 如果人员是否在考勤报表权限共享设置里,则表示此人拥有权限,否则,没有权限 + */ + boolean hasRight = new KQReportBiz().hasReportRight("3",""+user.getUID()); +// String sql = "select * from kq_ReportShare where resourceId=" + user.getUID() + " and reportName=3"; + RecordSet recordSet = new RecordSet(); +// recordSet.executeQuery(sql); +// hasRight = recordSet.getCounts() > 0; + + HrmAdvancedSearchUtil hrmAdvancedSearchUtil = new HrmAdvancedSearchUtil(); + /*展示列*/ + Map optionMap = new HashMap(); + List> optionList = new ArrayList>(); + + optionMap = new HashMap(); + optionMap.put("key", "subcom"); + optionMap.put("showname", SystemEnv.getHtmlLabelName(33553, user.getLanguage())); + optionList.add(optionMap); + optionMap = new HashMap(); + optionMap.put("key", "dept"); + optionMap.put("showname", SystemEnv.getHtmlLabelName(27511, user.getLanguage())); + optionList.add(optionMap); + optionMap = new HashMap(); + optionMap.put("key", "jobtitle"); + optionMap.put("showname", SystemEnv.getHtmlLabelName(6086, user.getLanguage())); + optionList.add(optionMap); + optionMap = new HashMap(); + optionMap.put("key", "workcode"); + optionMap.put("showname", SystemEnv.getHtmlLabelName(714, user.getLanguage())); + optionList.add(optionMap); + + String valueStr = "subcom,dept,jobtitle,workcode"; + resultMap.put("option", optionList); + resultMap.put("value", valueStr); + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + /*时间范围*/ + WeaRadioGroup weaRadioGroup = new WeaRadioGroup();//WeaRadioGroup组件 + List options = new ArrayList();//WeaRadioGroup组件内的options参数 + List domkey = new ArrayList();//WeaRadioGroup组件内的domkey参数 + Map selectLinkageDatas = new HashMap();//WeaRadioGroup组件内的selectLinkageDatas参数 + Map linkMap = new HashMap();//selectLinkageDatas参数内部Map数据 + + weaRadioGroup.setLabel(SystemEnv.getHtmlLabelName(19482, user.getLanguage())); + + options.add(new SelectOption("1", SystemEnv.getHtmlLabelName(15537, user.getLanguage())));//今天 + options.add(new SelectOption("2", SystemEnv.getHtmlLabelName(15539, user.getLanguage())));//本周 + options.add(new SelectOption("3", SystemEnv.getHtmlLabelName(15541, user.getLanguage()), true));//本月 + options.add(new SelectOption("7", SystemEnv.getHtmlLabelName(27347, user.getLanguage())));//上个月 + options.add(new SelectOption("4", SystemEnv.getHtmlLabelName(21904, user.getLanguage())));//本季 + if(kq_personal_reportsearch) { + if(hasRight) { + options.add(new SelectOption("5", SystemEnv.getHtmlLabelName(15384, user.getLanguage())));//本年 + options.add(new SelectOption("8", SystemEnv.getHtmlLabelName(81716, user.getLanguage())));//上一年 + } + } else { + options.add(new SelectOption("5", SystemEnv.getHtmlLabelName(15384, user.getLanguage())));//本年 + options.add(new SelectOption("8", SystemEnv.getHtmlLabelName(81716, user.getLanguage())));//上一年 + } + options.add(new SelectOption("6", SystemEnv.getHtmlLabelName(32530, user.getLanguage())));//指定日期范围 + weaRadioGroup.setOptions(options); + + domkey.add("dateScope"); + weaRadioGroup.setDomkey(domkey); + + linkMap.put("conditionType", "RANGEPICKER"); + domkey = new ArrayList(); + domkey.add("startDate"); + domkey.add("endDate"); + linkMap.put("domkey", domkey); + selectLinkageDatas.put("6", linkMap); + weaRadioGroup.setSelectLinkageDatas(selectLinkageDatas); + + weaRadioGroup.setLabelcol(6); + weaRadioGroup.setFieldcol(18); + itemList.add(weaRadioGroup); + + + /*判断当前登录人员是否有下级*/ + boolean hasSubordinate = false; + String sql = "select count(*) from HrmResource where managerId=" + user.getUID(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + hasSubordinate = recordSet.getInt(1) > 0; + } + + weaRadioGroup = new WeaRadioGroup(); + options = new ArrayList();//WeaRadioGroup组件内的options参数 + domkey = new ArrayList();//WeaRadioGroup组件内的domkey参数 + selectLinkageDatas = new HashMap();//WeaRadioGroup组件内的selectLinkageDatas参数 + + weaRadioGroup.setLabel(SystemEnv.getHtmlLabelName(34216, user.getLanguage()));//数据范围 + + if (hasRight) { + options.add(new SelectOption("0", SystemEnv.getHtmlLabelName(140, user.getLanguage()), hasRight && user.isAdmin()));//总部 + options.add(new SelectOption("1", SystemEnv.getHtmlLabelName(33553, user.getLanguage())));//分部 + options.add(new SelectOption("2", SystemEnv.getHtmlLabelName(27511, user.getLanguage())));//部门 + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("subcomId");//分部 + hrmFieldBean.setFieldlabel("33553"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("194"); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + List browserTabBeanList = searchConditionItem.getBrowserConditionParam().getTabs(); + for (BrowserTabBean browserTabBean : browserTabBeanList) { + if (browserTabBean.getKey().equals("2")) { + browserTabBean.setSelected(true); + browserTabBean.setShowOrder(0); + } else { + browserTabBean.setShowOrder(1); + } + } + selectLinkageDatas.put("1", searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("deptId");//部门 + hrmFieldBean.setFieldlabel("27511"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("57"); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + browserTabBeanList = searchConditionItem.getBrowserConditionParam().getTabs(); + for (BrowserTabBean browserTabBean : browserTabBeanList) { + if (browserTabBean.getKey().equals("2")) { + browserTabBean.setSelected(true); + browserTabBean.setShowOrder(0); + } else { + browserTabBean.setShowOrder(1); + } + } + selectLinkageDatas.put("2", searchConditionItem); + } + + options.add(new SelectOption("3", SystemEnv.getHtmlLabelName(30042, user.getLanguage()), !hasRight || !user.isAdmin()));//人员 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("resourceId");//人员 + hrmFieldBean.setFieldlabel("30042"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("17"); + hrmFieldBean.setViewAttr(hasRight ? 3 : 1); + if (!hasRight || !user.isAdmin()) { + hrmFieldBean.setFieldvalue("" + user.getUID()); + } + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if (!hasRight) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + searchConditionItem.setRules("required|string"); + selectLinkageDatas.put("3", searchConditionItem); + + if (!user.isAdmin() && hasSubordinate) { + options.add(new SelectOption("4", SystemEnv.getHtmlLabelName(15089, user.getLanguage())));//我的下属 + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("allLevel");//包含下级下属 + hrmFieldBean.setFieldlabel("389995"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + selectLinkageDatas.put("4", searchConditionItem); + } + + weaRadioGroup.setOptions(options); + weaRadioGroup.setSelectLinkageDatas(selectLinkageDatas); + + domkey.add("dataScope"); + weaRadioGroup.setDomkey(domkey); + + weaRadioGroup.setLabelcol(4); + weaRadioGroup.setFieldcol(20); + itemList.add(weaRadioGroup); + + WeaRadioGroup wrg1 = new WeaRadioGroup(); + + ChgPasswdReminder reminder = new ChgPasswdReminder(); + RemindSettings settings = reminder.getRemindSettings(); + String checkUnJob = Util.null2String(settings.getCheckUnJob(), "0"); + List statusList = Lists.newArrayList(); + if ("1".equals(checkUnJob)) {//启用后,只有有“离职人员查看”权限的用户才能检索非在职人员 + if (HrmUserVarify.checkUserRight("hrm:departureView", user)) { + statusList.add("9,332,false"); + } + } else { + statusList.add("9,332,false"); + } + statusList.add("0,15710,false"); + statusList.add("1,15711,false"); + statusList.add("2,480,false"); + statusList.add("3,15844,false"); + if ("1".equals(checkUnJob)) {//启用后,只有有“离职人员查看”权限的用户才能检索非在职人员 + if (HrmUserVarify.checkUserRight("hrm:departureView", user)) { + statusList.add("4,6094,false"); + statusList.add("5,6091,false"); + statusList.add("6,6092,false"); + statusList.add("7,2245,false"); + } + } else { + statusList.add("4,6094,false"); + statusList.add("5,6091,false"); + statusList.add("6,6092,false"); + statusList.add("7,2245,false"); + } + statusList.add("8,1831,true"); + String[] strOptions = new String[statusList.size()]; + for(int i = 0 ; i < statusList.size() ; i++){ + String statusStr = statusList.get(i); + strOptions[i] = statusStr; + } + + wrg1 = hrmAdvancedSearchUtil.getAdvanceCondition("status","602",strOptions,null,user); + wrg1.setLabelcol(3); + wrg1.setFieldcol(20); + itemList.add(wrg1); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/originalpunchrp/GetSearchListCmd.java b/src/com/engine/kq/cmd/originalpunchrp/GetSearchListCmd.java new file mode 100644 index 0000000..1c80679 --- /dev/null +++ b/src/com/engine/kq/cmd/originalpunchrp/GetSearchListCmd.java @@ -0,0 +1,204 @@ +package com.engine.kq.cmd.originalpunchrp; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportBiz; +import java.util.HashMap; +import java.util.Map; + +import com.engine.kq.biz.KQSettingsComInfo; +import weaver.conn.RecordSet; +import weaver.general.PageIdConst; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 原始打卡记录报表--获取查询结果列表 + */ +public class GetSearchListCmd extends AbstractCommonCommand> { + + 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(); + try { + String showCol = Util.null2String(params.get("showCol"));//展示列 + String dateScope = Util.null2String(params.get("dateScope"));//日期范围 + String startDate = Util.null2String(params.get("startDate"));//开始日期 + String endDate = Util.null2String(params.get("endDate"));//结束日期 + if (!dateScope.equals("") && !dateScope.equals("0") && !dateScope.equals("6")) { + startDate = TimeUtil.getDateByOption(dateScope, "0"); + endDate = TimeUtil.getDateByOption(dateScope, "1"); + } + // 没有权限的人最大只支持查询本季 + Map getRealDate = new KQReportBiz().realDate(startDate, endDate, user, "3"); + startDate = getRealDate.get("fromDate"); + endDate = getRealDate.get("toDate"); + + //人员状态 + String status = Util.null2String(params.get("status")); + String dataScope = Util.null2String(params.get("dataScope"));//数据范围 + String subcomId = Util.null2String(params.get("subcomId"));//分部ID + String deptId = Util.null2String(params.get("deptId"));//部门ID + String resourceId = Util.null2String(params.get("resourceId"));//人员ID + String allLevel = Util.null2String(params.get("allLevel"));//包含下级下属 + String isNoaccount = Util.null2String(params.get("isNoAccount"));//是否显示无账号人员 + + /** + * 获取考勤报表权限共享设置 + */ + KQReportBiz kqReportBiz = new KQReportBiz(); + String rightStr = kqReportBiz.getReportRight("3", "" + user.getUID(), "b"); + + String backFields = " a.*,'' as canViewSignImg,b.subcompanyId1,b.departmentId,b.jobtitle,b.workcode "; + String sqlFrom = " from HrmScheduleSign a,HrmResource b "; + String sqlWhere = " where a.userId=b.id "; + /*原始打卡记录是否显示补打卡流程的数据*/ + String showCardOnOriginalpunchRp = "0";//0-表示不显示、1-表示显示 + String kqSettingSql = "select * from kq_settings where main_key='showCardOnOriginalpunchRp'"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(kqSettingSql); + if(recordSet.next()){ + showCardOnOriginalpunchRp = recordSet.getString("main_val"); + } + if(!showCardOnOriginalpunchRp.equals("1")){ + sqlWhere += " and (signfrom is null or signfrom='' or signfrom not like 'card%') "; + } + if (!startDate.equals("")) { + sqlWhere += " and (signDate is not null and signDate>='" + startDate + "') "; + } + if (!endDate.equals("")) { + sqlWhere += " and (signDate is not null and signDate<='" + endDate + "') "; + } + if (dataScope.equals("1") && !subcomId.equals("")) { + sqlWhere += " and b.subcompanyId1 in (" + subcomId + ")"; + } + if (dataScope.equals("2") && !deptId.equals("")) { + sqlWhere += " and b.departmentId in (" + deptId + ")"; + } + if (dataScope.equals("3") && !resourceId.equals("")) { + sqlWhere += " and userId in (" + resourceId + ")"; + } + if (dataScope.equals("4")) { + if (allLevel.equals("1")) { + sqlWhere += " and (b.id=" + user.getUID() + " or b.managerStr like '%," + user.getUID() + ",%' )"; + } else { + sqlWhere += " and (b.id=" + user.getUID() + " or b.managerid = " + user.getUID() + ")"; + } + } + if (isNoaccount.equals("false")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver") + || recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere += " and (loginId is not null and loginId<>'')"; + } else { + sqlWhere += " and (loginId is not null)"; + } + } + + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and b.status = "+status+ ""; + }else if (status.equals("8")) { + sqlWhere += " and (b.status = 0 or b.status = 1 or b.status = 2 or b.status = 3) "; + } + } + + //考勤报表共享设置 + if (!rightStr.equals("") && !dataScope.equals("4")) { + sqlWhere += rightStr; + } + if("-1".equals(startDate) || "-1".equals(endDate)) { + sqlWhere += " and 1=2 "; + } + String orderBy = " userId,signDate,signTime "; + + // #1473334-概述:满足考勤报分部部门显示及导出时显示全路径 + String fullPathMainKey = "show_full_path"; + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); + String transMethodString = ""; + + String colString = ""; + + // 根据开关,决定是否显示部门分部全路径 + if (showCol.indexOf("subcom") > -1) { + if("1".equals(isShowFullPath)){ + transMethodString = "com.engine.hrm.util.HrmUtil.showSubCompanyFullPath"; + }else { + transMethodString = "weaver.hrm.company.SubCompanyComInfo.getSubCompanyname"; + } + colString += ""; + } + + if (showCol.indexOf("dept") > -1) { + if("1".equals(isShowFullPath)){ + transMethodString = "com.engine.hrm.util.HrmUtil.showDepartmentFullPath"; + }else { + transMethodString = "weaver.hrm.company.DepartmentComInfo.getDepartmentName"; + } + colString += ""; + } + + if (showCol.indexOf("jobtitle") > -1) { + colString += ""; + } + if (showCol.indexOf("workcode") > -1) { + colString += ""; + } + String isincom_String = ""; + // 是否疑似外挂打卡 + String mayVirtualLocation_String = ""; + + boolean has_incom = false; + String sql = "select * from kq_settings where main_key='show_incom' "; + recordSet.executeQuery(sql); + if(recordSet.next()){ + String main_val = recordSet.getString("main_val"); + if("1".equalsIgnoreCase(main_val)){ + has_incom = true; + } + } + if(has_incom){ + isincom_String = " " ; + mayVirtualLocation_String = " " ; + } + + String pageUid = "e85dea76-8ac5-c0b1-9221-71742fe87e03"; + String tableString = "" + + "" + + " " + + " " + + " " + + colString + + " " + + " " + + " " + + " " + + " " + isincom_String + + mayVirtualLocation_String+ + " " + + " "+ + " " + + "
"; + String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionKey, tableString); + resultMap.put("sessionkey", sessionKey); + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/overtimerules/AddOvertimeRulesCmd.java b/src/com/engine/kq/cmd/overtimerules/AddOvertimeRulesCmd.java new file mode 100644 index 0000000..e96d135 --- /dev/null +++ b/src/com/engine/kq/cmd/overtimerules/AddOvertimeRulesCmd.java @@ -0,0 +1,482 @@ +package com.engine.kq.cmd.overtimerules; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.log.KQLog; +import com.google.common.collect.Lists; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 加班规则--新建 + */ +public class AddOvertimeRulesCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public AddOvertimeRulesCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String name = Util.null2String(params.get("name")); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMERULES);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMERULES);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_overtimeRules where name like '%" + name + "%' and (isDelete is null or isDelete!=1)"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("name"); + + SimpleBizLogger.SubLogInfo subLogInfo0 = logger.getNewSubLogInfo(); + String subSql0 = "select id,serial from kq_shiftmanagement where overtime_rule_id in (select id from kq_overtimeRules where name like '%" + name + "%' and (isDelete is null or isDelete!=1)) order by id"; + subLogInfo0.setSubSql(subSql0, "id"); + subLogInfo0.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo0.setSubGroupNameLabel(546282); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo0); + + SimpleBizLogger.SubLogInfo subLogInfo = logger.getNewSubLogInfo(); + String subSql = "select * from kq_overtimeRulesDetail where ruleId in (select id from kq_overtimeRules where name like '%" + name + "%' and (isDelete is null or isDelete!=1)) order by id"; + subLogInfo.setSubSql(subSql, "id"); + subLogInfo.setGroupId("1"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo.setSubGroupNameLabel(22045); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_OvertimeRestTime where ruleId in (select id from kq_overtimeRules where name like '%" + name + "%' and (isDelete is null or isDelete!=1)) order by id"; + subLogInfo1.setSubSql(subSql1, "id"); + subLogInfo1.setGroupId("2"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(525905); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo1); + + SimpleBizLogger.SubLogInfo subLogInfo2 = logger.getNewSubLogInfo(); + String subSql2 = "select * from kq_OvertimeRestlength where ruleId in (select id from kq_overtimeRules where name like '%" + name + "%' and (isDelete is null or isDelete!=1)) order by id"; + subLogInfo2.setSubSql(subSql2, "id"); + subLogInfo2.setGroupId("3"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo2.setSubGroupNameLabel(524834); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo2); + + SimpleBizLogger.SubLogInfo subLogInfo3 = logger.getNewSubLogInfo(); + String subSql3 = "select * from kq_OvertimeBalanceLengthDetail where rulesdetailid in (select id from kq_overtimeRules where name like '%" + name + "%' and (isDelete is null or isDelete!=1)) order by id"; + subLogInfo3.setSubSql(subSql3, "id"); + subLogInfo3.setGroupId("4"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo3.setSubGroupNameLabel(524831); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo3); + + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canAdd = HrmUserVarify.checkUserRight("KQOvertimeRulesAdd:Add", user);//是否具有新建权限 + if (!canAdd) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + /*加班规则名称*/ + String name = Util.null2String(params.get("name")); + /*考勤组的ID*/ + String groupIds = Util.null2String(params.get("groupIds")); + //班次 + String shift = Util.null2String(params.get("shift")); + + /*工作日是否允许加班:0-不允许、1-允许*/ + int overtimeEnable2 = Util.getIntValue((String) params.get("overtimeEnable2"), 1); + int canmiddlerest2 = Util.getIntValue((String) params.get("canmiddlerest2"), 0); + /*工作日的加班方式:1-需审批,以审批单为准、2-需审批,以打卡为准,但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/ + int computingMode2 = Util.getIntValue((String) params.get("computingMode2"), 1); + /*工作日下班多少分钟后开始计算加班*/ + int startTime2 = Util.getIntValue((String) params.get("startTime2"), 30); + /*工作日最小加班时长*/ + int minimumLen2 = Util.getIntValue((String) params.get("minimumLen2"), 30); + /*工作日最大加班时长*/ + int maxmumLen2 = Util.getIntValue((String) params.get("maxmumLen2"), 1440); + /*工作日是否允许加班转调休*/ + int paidLeaveEnable2 = Util.getIntValue((String) params.get("paidLeaveEnable2"), 0); + /*工作日加班转调休比例中的加班时长*/ + double lenOfOvertime2 = Util.getDoubleValue((String) params.get("lenOfOvertime2"), 30.0); + /*工作日加班转调休比例中的调休时长*/ + double lenOfLeave2 = Util.getDoubleValue((String) params.get("lenOfLeave2"), 30.0); + + /*休息日是否允许加班:0-不允许、1-允许*/ + int overtimeEnable3 = Util.getIntValue((String) params.get("overtimeEnable3"), 1); + int canmiddlerest3 = Util.getIntValue((String) params.get("canmiddlerest3"), 0); + /*休息日的加班方式:1-需审批,以审批单为准、2-需审批,以打卡为准,但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/ + int computingMode3 = Util.getIntValue((String) params.get("computingMode3"), 1); + /*休息日的最小加班时长*/ + int minimumLen3 = Util.getIntValue((String) params.get("minimumLen3"), 30); + /*休息日最大加班时长*/ + int maxmumLen3 = Util.getIntValue((String) params.get("maxmumLen3"), 1440); + /*休息日是否允许加班转调休*/ + int paidLeaveEnable3 = Util.getIntValue((String) params.get("paidLeaveEnable3"), 0); + /*休息日加班转调休比例中的加班时长*/ + double lenOfOvertime3 = Util.getDoubleValue((String) params.get("lenOfOvertime3"), 30.0); + /*休息日加班转调休比例中的调休时长*/ + double lenOfLeave3 = Util.getDoubleValue((String) params.get("lenOfLeave3"), 30.0); + /*休息日是否有休息时间*/ + int hasRestTime3 = Util.getIntValue((String) params.get("hasRestTime3"), 0); + + /*节假日是否允许加班:0-不允许、1-允许*/ + int overtimeEnable1 = Util.getIntValue((String) params.get("overtimeEnable1"), 1); + int canmiddlerest1 = Util.getIntValue((String) params.get("canmiddlerest1"), 0); + /*节假日的加班方式:1-需审批,以审批单为准、2-需审批,以打卡为准,但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/ + int computingMode1 = Util.getIntValue((String) params.get("computingMode1"), 1); + /*节假日的最小加班时长*/ + int minimumLen1 = Util.getIntValue((String) params.get("minimumLen1"), 30); + /*节假日最大加班时长*/ + int maxmumLen1 = Util.getIntValue((String) params.get("maxmumLen1"), 1440); + /*节假日是否允许加班转调休*/ + int paidLeaveEnable1 = Util.getIntValue((String) params.get("paidLeaveEnable1"), 0); + /*节假日加班转调休比例中的加班时长*/ + double lenOfOvertime1 = Util.getDoubleValue((String) params.get("lenOfOvertime1"), 30.0); + /*假节日加班转调休比例中的调休时长*/ + double lenOfLeave1 = Util.getDoubleValue((String) params.get("lenOfLeave1"), 30.0); + /*节假日是否有休息时间*/ + int hasRestTime1 = Util.getIntValue((String) params.get("hasRestTime1"), 0); + if(computingMode2 == 4 || computingMode1 == 4 || computingMode3 == 4 ){ + //如果是流程和打卡取交集的话,加班单位不能是下拉框半天或者整天 + int minimumUnit = KQOvertimeRulesBiz.getMinimumUnit(); + if(minimumUnit == 2 || minimumUnit == 4){ + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(529168, user.getLanguage())); + return resultMap; + } + } + KQLog kqLog = new KQLog(); + kqLog.info("AddOvertimeRulesCmd:params:"+params); + + /*获取今天的日期*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + String tomorrowDate = DateUtil.addDate(currentDate, 1); + + //顺序显示,2是工作日,3是休息日,1是节假日 + int[] changetype = {2,3,1}; + + boolean flag = false;//是否保存成功 + + String sql = "insert into kq_OvertimeRules(name,groupIds,isDelete) values(?,?,0)"; + RecordSet recordSet = new RecordSet(); + RecordSet recordSet1 = new RecordSet(); + flag = recordSet.executeUpdate(sql, name, groupIds); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + + int ruleId = 0;//刚刚插入的数据的ID + sql = "select max(id) maxId from kq_OvertimeRules"; + recordSet.executeQuery(sql); + if (recordSet.next()) { + ruleId = recordSet.getInt("maxId"); + } + if(StringUtil.isNotNull(shift)){ + String shifSql = "update kq_shiftmanagement set overtime_rule_id = "+ruleId+" where "+Util.getSubINClause(shift, "id", "in"); + recordSet.executeUpdate(shifSql); + } + + List rulesdetailidList = Lists.newArrayList(); + + String[] fields = new String[]{"overtimeEnable","computingMode","startTime","minimumLen","maxmumLen", + "paidLeaveEnable","lenOfOvertime","lenOfLeave","hasRestTime","before_startTime", + "has_cut_point","cut_point","paidLeaveEnableType","paidLeaveEnableDefaultType", + "paidLeaveEnableFlowType","restTimeType","canmiddlerest"}; + String str_fields = Arrays.asList(fields).stream().collect(Collectors.joining(",")); + String split_str = Arrays.asList(fields).stream().map(s -> {return "?";}).collect(Collectors.joining(",")); + for(int i = 0 ; i < changetype.length ; i++) { + int changetype_index = changetype[i]; + sql = "insert into kq_OvertimeRulesDetail(ruleId,dayType,"+str_fields+") " + + "values(?,?,"+split_str+")"; + String value_str = ""; + int size = 2+fields.length; + Object[] objects = new Object[size]; + objects[0] = ruleId; + objects[1] = changetype_index; + for(int j = 0 ; j < fields.length ;j++){ + String _key = fields[j]+changetype_index; + String _value = Util.null2String(params.get(_key)); + if("before_startTime".equalsIgnoreCase(fields[j]) || "maxmumLen".equalsIgnoreCase(fields[j])){ + if(params.containsKey(_key)){ + _value = Util.null2String(params.get(_key)); + if("".equals(_value)){ + _value = null; + } + }else{ + _value = null; + } + } + if("startTime".equalsIgnoreCase(fields[j])){ + _value = Util.null2s(Util.null2String(params.get(_key)),"0"); + } + if("canmiddlerest".equalsIgnoreCase(fields[j])){ + _value = Util.null2s(Util.null2String(params.get(_key)),"0"); + } + if(null == _value){ + value_str += ",null"; + }else { + value_str += ","+_value; + } + objects[2+j] = _value; + } + if(value_str.length() > 0){ + flag = recordSet.executeUpdate(sql, objects); + if(flag){ + + int rulesdetailid = 0;//刚刚插入的明细数据的ID + sql = "select max(id) maxId from kq_OvertimeRulesDetail"; + recordSet.executeQuery(sql); + if (recordSet.next()) { + rulesdetailid = recordSet.getInt("maxId"); + } + rulesdetailidList.add(rulesdetailid+""); + + String hasRestTime_key = "hasRestTime"+changetype_index; + String hasRestTime_value = Util.null2String(params.get(hasRestTime_key)); + if("1".equalsIgnoreCase(hasRestTime_value)){ + List restIds = Lists.newArrayList(); + String restTimeType_key = "restTimeType"+changetype_index; + String restTimeType_value = Util.null2String(params.get(restTimeType_key)); + + String restTimeRule_key = "restTimeRule"+changetype_index; + String restTimeRule_value = Util.null2String(params.get(restTimeRule_key)); + if(restTimeRule_value.length() > 0){ + JSONArray jsonArray = JSONArray.parseArray(restTimeRule_value); + if("1".equalsIgnoreCase(restTimeType_value)){ + for(int k = 0 ; k < jsonArray.size() ; k++){ + JSONObject jsonObject = (JSONObject) jsonArray.get(k); + String startTime = Util.null2String(jsonObject.get("startTime")); + String startType = Util.null2String(jsonObject.get("startType")); + String endTime = Util.null2String(jsonObject.get("endTime")); + String endType = Util.null2String(jsonObject.get("endType")); + String restTimeSql = "insert into kq_OvertimeRestTime(ruleId,dayType,startType,startTime,endType,endTime) values(?,?,?,?,?,?)"; + flag = recordSet.executeUpdate(restTimeSql, ruleId, changetype_index, startType, startTime, endType, endTime); + if (flag) { + int restId = 0; + String restSql = "select max(id) maxId from kq_OvertimeRestTime"; + recordSet1.executeQuery(restSql); + if (recordSet1.next()) { + restId = recordSet1.getInt("maxId"); + restIds.add(""+restId); + } + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + if(!rulesdetailidList.isEmpty()){ + delFail(rulesdetailidList,restIds,ruleId); + } + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + }else if("2".equalsIgnoreCase(restTimeType_value)){ + for(int k = 0 ; k < jsonArray.size() ; k++){ + JSONObject jsonObject = (JSONObject) jsonArray.get(k); + String overtime = Util.null2String(jsonObject.get("overtime")); + String exclude = Util.null2String(jsonObject.get("exclude")); + String restTimeSql = "insert into kq_OvertimeRestlength(ruleId,dayType,overlength,cutlength,dsporder) values(?,?,?,?,?)"; + flag = recordSet.executeUpdate(restTimeSql, ruleId, changetype_index, overtime, exclude, k); + if (flag) { + int restId = 0; + String restSql = "select max(id) maxId from kq_OvertimeRestlength"; + recordSet1.executeQuery(restSql); + if (recordSet1.next()) { + restId = recordSet1.getInt("maxId"); + restIds.add(""+restId); + } + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + if(!rulesdetailidList.isEmpty()){ + delFail(rulesdetailidList, restIds, ruleId); + } + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + } + } + String paidLeaveEnableType_key = "paidLeaveEnableType"+changetype_index; + String paidLeaveEnableType_value = Util.null2String(params.get(paidLeaveEnableType_key)); + + String paidLeaveEnableTypeRule_key = "paidLeaveEnableTypeRule"+changetype_index; + String paidLeaveEnableTypeRule_value = Util.null2String(params.get(paidLeaveEnableTypeRule_key)); + if("1".equalsIgnoreCase(paidLeaveEnableType_value)){ + String paidLeaveEnableDefaultType_key = "paidLeaveEnableDefaultType"+changetype_index; + String paidLeaveEnableDefaultType_value = Util.null2String(params.get(paidLeaveEnableDefaultType_key)); + if("2".equalsIgnoreCase(paidLeaveEnableDefaultType_value)){ +// 按加班时长范围设置转调休时长 + JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value); + for(int k = 0 ; k < jsonArray.size() ; k++){ + JSONObject jsonObject = (JSONObject) jsonArray.get(k); + String work = Util.null2String(jsonObject.get("work")); + String rest = Util.null2String(jsonObject.get("rest")); + String detailsql = "insert into kq_OvertimeBalanceLengthDetail(rulesdetailid,overtimelength,balancelength,dsporder) values(?,?,?,?)"; + flag = recordSet.executeUpdate(detailsql, rulesdetailid, work, rest, k); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + if(!rulesdetailidList.isEmpty()){ + delFail(rulesdetailidList, null, ruleId); + } + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + }else if("3".equalsIgnoreCase(paidLeaveEnableDefaultType_value)){ +// 按加班的时间段设置转调休时长 + JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value); + for(int k = 0 ; k < jsonArray.size() ; k++){ + JSONObject jsonObject = (JSONObject) jsonArray.get(k); + String time = Util.null2String(jsonObject.get("time")); + String left = Util.null2String(jsonObject.get("left")); + String right = Util.null2String(jsonObject.get("right")); + String detailsql = "insert into kq_OvertimeBalanceTimeDetail(rulesdetailid,timepoint,lenOfOvertime,lenOfLeave,dsporder) values(?,?,?,?,?)"; + flag = recordSet.executeUpdate(detailsql, rulesdetailid, time, left, right,k); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + if(!rulesdetailidList.isEmpty()){ + delFail(rulesdetailidList, null, ruleId); + } + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + }else if("2".equalsIgnoreCase(paidLeaveEnableType_value)){ + String paidLeaveEnableFlowType_key = "paidLeaveEnableFlowType"+changetype_index; + String paidLeaveEnableFlowType_value = Util.null2String(params.get(paidLeaveEnableFlowType_key)); + if("2".equalsIgnoreCase(paidLeaveEnableFlowType_value)){ +// 按加班时长范围设置转调休时长 + JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value); + for(int k = 0 ; k < jsonArray.size() ; k++){ + JSONObject jsonObject = (JSONObject) jsonArray.get(k); + String work = Util.null2String(jsonObject.get("work")); + String rest = Util.null2String(jsonObject.get("rest")); + String detailsql = "insert into kq_OvertimeBalanceLengthDetail(rulesdetailid,overtimelength,balancelength,dsporder) values(?,?,?,?)"; + flag = recordSet.executeUpdate(detailsql, rulesdetailid, work, rest, k); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + if(!rulesdetailidList.isEmpty()){ + delFail(rulesdetailidList, null, ruleId); + } + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + }else if("3".equalsIgnoreCase(paidLeaveEnableFlowType_value)){ +// 按加班的时间段设置转调休时长 + JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value); + for(int k = 0 ; k < jsonArray.size() ; k++){ + JSONObject jsonObject = (JSONObject) jsonArray.get(k); + String time = Util.null2String(jsonObject.get("time")); + String left = Util.null2String(jsonObject.get("left")); + String right = Util.null2String(jsonObject.get("right")); + String detailsql = "insert into kq_OvertimeBalanceTimeDetail(rulesdetailid,timepoint,lenOfOvertime,lenOfLeave,dsporder) values(?,?,?,?,?)"; + flag = recordSet.executeUpdate(detailsql, rulesdetailid, time, left, right,k); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + if(!rulesdetailidList.isEmpty()){ + delFail(rulesdetailidList, null, ruleId); + } + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + } + }else{ + if(!rulesdetailidList.isEmpty()){ + delFail(rulesdetailidList, null, ruleId); + } + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + + } catch (Exception e) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return resultMap; + } + + /** + * 保存失败时候把错误数据删除 + * @param rulesdetailidList + * @param restIds + * @param ruleId + */ + public void delFail(List rulesdetailidList, List restIds, int ruleId){ + RecordSet rs = new RecordSet(); + String delSql1 = "delete from kq_OvertimeRules where id = ? "; + rs.executeUpdate(delSql1, ruleId); + + for(String rulesdetailid : rulesdetailidList){ + String delSql = "delete from kq_overtimerulesdetail where id = ? "; + rs.executeUpdate(delSql,rulesdetailid); + } + if(restIds != null && !restIds.isEmpty()){ + for(String restId : restIds){ + String delSql = "delete from kq_overtimeresttime where id = ? "; + rs.executeUpdate(delSql,restId); + delSql = "delete from kq_overtimerestlength where id = ? "; + rs.executeUpdate(delSql,restId); + } + } + } +} diff --git a/src/com/engine/kq/cmd/overtimerules/DeleteOvertimeRulesCmd.java b/src/com/engine/kq/cmd/overtimerules/DeleteOvertimeRulesCmd.java new file mode 100644 index 0000000..a15fa6a --- /dev/null +++ b/src/com/engine/kq/cmd/overtimerules/DeleteOvertimeRulesCmd.java @@ -0,0 +1,102 @@ +package com.engine.kq.cmd.overtimerules; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 加班规则--删除 + */ +public class DeleteOvertimeRulesCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public DeleteOvertimeRulesCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String ruleIds = Util.null2String(params.get("ruleIds"));//需要删除的加班规则ID + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMERULES);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMERULES);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_overtimeRules where (isDelete is null or isDelete<>1) and id in ("+ruleIds+")"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("name"); + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + String ruleIds = Util.null2String(params.get("ruleIds"));//需要删除的加班规则ID + if (ruleIds.equals("")) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage())); + return resultMap; + } + + boolean canDelete = HrmUserVarify.checkUserRight("KQOvertimeRulesDelete:Delete", user);//是否具有删除的权限; + if (!canDelete) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + RecordSet recordSet = new RecordSet(); + + String shifIds = ""; + String getShiftSql = "select * from kq_shiftmanagement where (isdelete is null or isdelete <> '1') and "+Util.getSubINClause(ruleIds, "overtime_rule_id", "in"); + recordSet.execute(getShiftSql); + while (recordSet.next()){ + String id = recordSet.getString("id"); + if(shifIds.length() == 0){ + shifIds = id; + }else{ + shifIds += ","+id; + } + } + if(StringUtil.isNotNull(shifIds)){ + String upSql = "update kq_shiftmanagement set overtime_rule_id=null where "+Util.getSubINClause(shifIds, "id", "in"); + recordSet.executeUpdate(upSql); + } + + boolean flag = false; + String sql = "update kq_OvertimeRules set isDelete=1,groupids=null where id in (" + ruleIds + ")"; + flag = recordSet.executeUpdate(sql); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(20461, user.getLanguage()));//删除成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(20462, user.getLanguage()));//删除失败 + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/overtimerules/EditOverTimeRulesCmd.java b/src/com/engine/kq/cmd/overtimerules/EditOverTimeRulesCmd.java new file mode 100644 index 0000000..a954d9f --- /dev/null +++ b/src/com/engine/kq/cmd/overtimerules/EditOverTimeRulesCmd.java @@ -0,0 +1,566 @@ +package com.engine.kq.cmd.overtimerules; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.log.KQLog; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 加班规则--编辑 + */ +public class EditOverTimeRulesCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public EditOverTimeRulesCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + int ruleId = Util.getIntValue((String) params.get("ruleId"), 0); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMERULES);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMERULES);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_overtimeRules where id="+ruleId; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("name"); + + SimpleBizLogger.SubLogInfo subLogInfo0 = logger.getNewSubLogInfo(); + String subSql0 = "select id,serial from kq_shiftmanagement where overtime_rule_id ="+ruleId; + subLogInfo0.setSubSql(subSql0, "id"); + subLogInfo0.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo0.setSubGroupNameLabel(546282); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo0); + + SimpleBizLogger.SubLogInfo subLogInfo = logger.getNewSubLogInfo(); + String subSql = "select * from kq_overtimeRulesDetail where ruleId="+ruleId +" order by id"; + subLogInfo.setSubSql(subSql, "id"); + subLogInfo.setGroupId("1"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo.setSubGroupNameLabel(22045); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_OvertimeRestTime where ruleId="+ruleId+" order by id"; + subLogInfo1.setSubSql(subSql1, "id"); + subLogInfo1.setGroupId("2"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(525905); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo1); + + SimpleBizLogger.SubLogInfo subLogInfo2 = logger.getNewSubLogInfo(); + String subSql2 = "select * from kq_OvertimeRestTime where ruleId="+ruleId+" order by id"; + subLogInfo2.setSubSql(subSql2, "id"); + subLogInfo2.setGroupId("2"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo2.setSubGroupNameLabel(524834); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo2); + + SimpleBizLogger.SubLogInfo subLogInfo3 = logger.getNewSubLogInfo(); + String subSql3 = "select * from kq_OvertimeBalanceLengthDetail where rulesdetailid in (select id from kq_overtimeRulesDetail where ruleId=" + ruleId + ") order by id"; + subLogInfo3.setSubSql(subSql3, "id"); + subLogInfo3.setGroupId("4"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo3.setSubGroupNameLabel(524831); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo3); + + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + /*加班规则的ID*/ + int ruleId = Util.getIntValue((String) params.get("ruleId"), 0); + if (ruleId == 0) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage())); + return resultMap; + } + + boolean canEdit = HrmUserVarify.checkUserRight("KQOvertimeRulesEdit:Edit", user);//是否具有编辑的权限; + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + /*加班规则名称*/ + String name = Util.null2String(params.get("name")); + /*考勤组的ID*/ + String groupIds = Util.null2String(params.get("groupIds")); + //班次 + String shift = Util.null2String(params.get("shift")); + + /*工作日是否允许加班:0-不允许、1-允许*/ + int overtimeEnable2 = Util.getIntValue((String) params.get("overtimeEnable2"), 1); + /*工作日的加班方式:1-需审批,以审批单为准、2-需审批,以打卡为准,但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/ + int computingMode2 = Util.getIntValue((String) params.get("computingMode2"), 1); + /*工作日下班多少分钟后开始计算加班*/ + int startTime2 = Util.getIntValue((String) params.get("startTime2"), 30); + /*工作日最小加班时长*/ + int minimumLen2 = Util.getIntValue((String) params.get("minimumLen2"), 30); + /*工作日是否允许加班转调休*/ + int paidLeaveEnable2 = Util.getIntValue((String) params.get("paidLeaveEnable2"), 0); + /*工作日加班转调休比例中的加班时长*/ + double lenOfOvertime2 = Util.getDoubleValue((String) params.get("lenOfOvertime2"), 30.0); + /*工作日加班转调休比例中的调休时长*/ + double lenOfLeave2 = Util.getDoubleValue((String) params.get("lenOfLeave2"), 30.0); + + /*休息日是否允许加班:0-不允许、1-允许*/ + int overtimeEnable3 = Util.getIntValue((String) params.get("overtimeEnable3"), 1); + /*休息日的加班方式:1-需审批,以审批单为准、2-需审批,以打卡为准,但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/ + int computingMode3 = Util.getIntValue((String) params.get("computingMode3"), 1); + /*休息日的最小加班时长*/ + int minimumLen3 = Util.getIntValue((String) params.get("minimumLen3"), 30); + /*休息日是否允许加班转调休*/ + int paidLeaveEnable3 = Util.getIntValue((String) params.get("paidLeaveEnable3"), 0); + /*休息日加班转调休比例中的加班时长*/ + double lenOfOvertime3 = Util.getDoubleValue((String) params.get("lenOfOvertime3"), 30.0); + /*休息日加班转调休比例中的调休时长*/ + double lenOfLeave3 = Util.getDoubleValue((String) params.get("lenOfLeave3"), 30.0); + /*休息日是否有休息时间*/ + int hasRestTime3 = Util.getIntValue((String) params.get("hasRestTime3"), 0); + + /*节假日是否允许加班:0-不允许、1-允许*/ + int overtimeEnable1 = Util.getIntValue((String) params.get("overtimeEnable1"), 1); + /*节假日的加班方式:1-需审批,以审批单为准、2-需审批,以打卡为准,但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/ + int computingMode1 = Util.getIntValue((String) params.get("computingMode1"), 1); + /*节假日的最小加班时长*/ + int minimumLen1 = Util.getIntValue((String) params.get("minimumLen1"), 30); + /*节假日是否允许加班转调休*/ + int paidLeaveEnable1 = Util.getIntValue((String) params.get("paidLeaveEnable1"), 0); + /*节假日加班转调休比例中的加班时长*/ + double lenOfOvertime1 = Util.getDoubleValue((String) params.get("lenOfOvertime1"), 30.0); + /*假节日加班转调休比例中的调休时长*/ + double lenOfLeave1 = Util.getDoubleValue((String) params.get("lenOfLeave1"), 30.0); + /*节假日是否有休息时间*/ + int hasRestTime1 = Util.getIntValue((String) params.get("hasRestTime1"), 0); + + if(computingMode2 == 4 || computingMode1 == 4 || computingMode3 == 4 ){ + //如果是流程和打卡取交集的话,加班单位不能是下拉框半天或者整天 + int minimumUnit = KQOvertimeRulesBiz.getMinimumUnit(); + if(minimumUnit == 2 || minimumUnit == 4){ + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(529168, user.getLanguage())); + return resultMap; + } + } + KQLog kqLog = new KQLog(); + kqLog.info("EditOverTimeRulesCmd:params:"+params); + + + /*获取今天的日期*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + String tomorrowDate = DateUtil.addDate(currentDate, 1); + + //顺序显示,2是工作日,3是休息日,1是节假日 + int[] changetype = {2,3,1}; + + boolean flag = false;//是否保存成功 + + String sql = "update kq_OvertimeRules set name=?,groupIds=? where id=?"; + RecordSet recordSet = new RecordSet(); + RecordSet recordSet1 = new RecordSet(); + RecordSet recordSet2 = new RecordSet(); + flag = recordSet.executeUpdate(sql, name, groupIds, ruleId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + String shifIds = ""; + String getShiftSql = "select * from kq_shiftmanagement where (isdelete is null or isdelete <> '1') and overtime_rule_id="+ruleId; + recordSet.execute(getShiftSql); + while (recordSet.next()){ + String id = recordSet.getString("id"); + if(shifIds.length() == 0){ + shifIds = id; + }else{ + shifIds += ","+id; + } + } + if(StringUtil.isNotNull(shifIds)){ + String upSql = "update kq_shiftmanagement set overtime_rule_id=null where "+Util.getSubINClause(shifIds, "id", "in"); + recordSet.executeUpdate(upSql); + } + if(StringUtil.isNotNull(shift)){ + String shifSql = "update kq_shiftmanagement set overtime_rule_id = "+ruleId+" where "+Util.getSubINClause(shift, "id", "in"); + recordSet.executeUpdate(shifSql); + } + Map detailMap = Maps.newHashMap(); + String detailSql = "select * from kq_OvertimeRulesDetail where ruleId=?"; + recordSet.executeQuery(detailSql,ruleId); + while (recordSet.next()){ + String daytype = recordSet.getString("daytype"); + String id = recordSet.getString("id"); + detailMap.put(daytype, id); + } + + String[] fields = new String[]{"overtimeEnable","computingMode","startTime","minimumLen","maxmumLen", + "paidLeaveEnable","lenOfOvertime","lenOfLeave","hasRestTime","before_startTime", + "has_cut_point","cut_point","paidLeaveEnableType","paidLeaveEnableDefaultType", + "paidLeaveEnableFlowType","restTimeType","canmiddlerest"}; + String str_fields = Arrays.asList(fields).stream().collect(Collectors.joining(",")); + String split_str = Arrays.asList(fields).stream().map(s -> {return "?";}).collect(Collectors.joining(",")); + for(int i = 0 ; i < changetype.length ; i++) { + int changetype_index = changetype[i]; + String fieldName = ""; + for(int j = 0 ; j < fields.length ;j++){ + String _key = fields[j]+changetype_index; + String _value = Util.null2String(params.get(_key)); + if("before_startTime".equalsIgnoreCase(fields[j]) || "maxmumLen".equalsIgnoreCase(fields[j])){ + if(params.containsKey(_key)){ + _value = Util.null2String(params.get(_key)); + if("".equals(_value)){ + _value = null; + } + }else{ + _value = null; + } + } + if("startTime".equalsIgnoreCase(fields[j])){ + _value = Util.null2s(Util.null2String(params.get(_key)),"0"); + } + if("canmiddlerest".equalsIgnoreCase(fields[j])){ + _value = Util.null2s(Util.null2String(params.get(_key)),"0"); + } + if(null == _value){ + fieldName += ","+fields[j]+"=null"; + }else{ + fieldName += ","+fields[j]+"='"+_value+"'"; + } + } + if(fieldName.length() > 0){ + fieldName = fieldName.substring(1); + fieldName += ",ruleId="+ruleId+",dayType="+changetype_index; + String detailid = Util.null2s(detailMap.get((changetype_index+"")),"-1"); + + String updateSql = "update kq_OvertimeRulesDetail set "+fieldName+" where id = ? "; + flag = recordSet.executeUpdate(updateSql,detailid); + if(flag){ + + List restIds = Lists.newArrayList(); + List lengthDetailIds = Lists.newArrayList(); + List timeDetailIds = Lists.newArrayList(); + int rulesdetailid = Util.getIntValue(detailid); + + String hasRestTime_key = "hasRestTime"+changetype_index; + String hasRestTime_value = Util.null2String(params.get(hasRestTime_key)); + if("1".equalsIgnoreCase(hasRestTime_value)){ + String restTimeType_key = "restTimeType"+changetype_index; + String restTimeType_value = Util.null2String(params.get(restTimeType_key)); + + String restTimeRule_key = "restTimeRule"+changetype_index; + String restTimeRule_value = Util.null2String(params.get(restTimeRule_key)); + if(restTimeRule_value.length() > 0){ + JSONArray jsonArray = JSONArray.parseArray(restTimeRule_value); + if("1".equalsIgnoreCase(restTimeType_value)){ + String deleteSql = "delete from kq_OvertimeRestTime where dayType=? and ruleId = ?"; + flag = recordSet.executeUpdate(deleteSql, changetype_index,ruleId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + for(int k = 0 ; k < jsonArray.size() ; k++){ + JSONObject jsonObject = (JSONObject) jsonArray.get(k); + String startTime = Util.null2String(jsonObject.get("startTime")); + String startType = Util.null2String(jsonObject.get("startType")); + String endTime = Util.null2String(jsonObject.get("endTime")); + String endType = Util.null2String(jsonObject.get("endType")); + String restTimeSql = "insert into kq_OvertimeRestTime(ruleId,dayType,startType,startTime,endType,endTime) values(?,?,?,?,?,?)"; + flag = recordSet.executeUpdate(restTimeSql, ruleId, changetype_index, startType, startTime, endType, endTime); + if (flag) { + int restDetailId = 0; + String getIdSql = "select max(id) maxId from kq_OvertimeRestTime"; + recordSet1.executeQuery(getIdSql); + if (recordSet1.next()) { + restDetailId = recordSet1.getInt("maxId"); + restIds.add(""+restDetailId); + } + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + if(!restIds.isEmpty()){ + if(restIds != null && !restIds.isEmpty()){ + for(String detailId : restIds){ + String delSql = "delete from kq_OvertimeRestTime where id = ? "; + recordSet2.executeUpdate(delSql,detailId); + } + } + } + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + }else if("2".equalsIgnoreCase(restTimeType_value)){ + String deleteSql = "delete from kq_OvertimeRestlength where dayType=? and ruleId = ?"; + flag = recordSet.executeUpdate(deleteSql, changetype_index,ruleId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + for(int k = 0 ; k < jsonArray.size() ; k++){ + JSONObject jsonObject = (JSONObject) jsonArray.get(k); + String overtime = Util.null2String(jsonObject.get("overtime")); + String exclude = Util.null2String(jsonObject.get("exclude")); + String restTimeSql = "insert into kq_OvertimeRestlength(ruleId,dayType,overlength,cutlength,dsporder) values(?,?,?,?,?)"; + flag = recordSet.executeUpdate(restTimeSql, ruleId, changetype_index, overtime, exclude, k); + if (flag) { + int restDetailId = 0; + String getIdSql = "select max(id) maxId from kq_OvertimeRestlength"; + recordSet1.executeQuery(getIdSql); + if (recordSet1.next()) { + restDetailId = recordSet1.getInt("maxId"); + restIds.add(""+restDetailId); + } + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + if(!restIds.isEmpty()){ + if(restIds != null && !restIds.isEmpty()){ + for(String detailId : restIds){ + String delSql = "delete from kq_OvertimeRestlength where id = ? "; + recordSet2.executeUpdate(delSql,detailId); + } + } + } + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + } + } + String paidLeaveEnableType_key = "paidLeaveEnableType"+changetype_index; + String paidLeaveEnableType_value = Util.null2String(params.get(paidLeaveEnableType_key)); + + String paidLeaveEnableTypeRule_key = "paidLeaveEnableTypeRule"+changetype_index; + String paidLeaveEnableTypeRule_value = Util.null2String(params.get(paidLeaveEnableTypeRule_key)); + if("1".equalsIgnoreCase(paidLeaveEnableType_value)){ + String paidLeaveEnableDefaultType_key = "paidLeaveEnableDefaultType"+changetype_index; + String paidLeaveEnableDefaultType_value = Util.null2String(params.get(paidLeaveEnableDefaultType_key)); + if("2".equalsIgnoreCase(paidLeaveEnableDefaultType_value)){ + String deleteSql = "delete from kq_OvertimeBalanceLengthDetail where rulesdetailid = ?"; + flag = recordSet.executeUpdate(deleteSql, detailid); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } +// 按加班时长范围设置转调休时长 + JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value); + for(int k = 0 ; k < jsonArray.size() ; k++){ + JSONObject jsonObject = (JSONObject) jsonArray.get(k); + String work = Util.null2String(jsonObject.get("work")); + String rest = Util.null2String(jsonObject.get("rest")); + String detailsql = "insert into kq_OvertimeBalanceLengthDetail(rulesdetailid,overtimelength,balancelength,dsporder) values(?,?,?,?)"; + flag = recordSet.executeUpdate(detailsql, rulesdetailid, work, rest, k); + if (flag) { + int lengthDetailId = 0; + String getIdSql = "select max(id) maxId from kq_OvertimeBalanceLengthDetail"; + recordSet1.executeQuery(getIdSql); + if (recordSet1.next()) { + lengthDetailId = recordSet1.getInt("maxId"); + lengthDetailIds.add(""+lengthDetailId); + } + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + if(!lengthDetailIds.isEmpty()){ + if(lengthDetailIds != null && !lengthDetailIds.isEmpty()){ + for(String detailId : lengthDetailIds){ + String delSql = "delete from kq_OvertimeBalanceLengthDetail where id = ? "; + recordSet2.executeUpdate(delSql,detailId); + } + } + } + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + }else if("3".equalsIgnoreCase(paidLeaveEnableDefaultType_value)){ + String deleteSql = "delete from kq_OvertimeBalanceTimeDetail where rulesdetailid = ?"; + flag = recordSet.executeUpdate(deleteSql, detailid); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } +// 按加班的时间段设置转调休时长 + JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value); + for(int k = 0 ; k < jsonArray.size() ; k++){ + JSONObject jsonObject = (JSONObject) jsonArray.get(k); + String time = Util.null2String(jsonObject.get("time")); + String left = Util.null2String(jsonObject.get("left")); + String right = Util.null2String(jsonObject.get("right")); + String detailsql = "insert into kq_OvertimeBalanceTimeDetail(rulesdetailid,timepoint,lenOfOvertime,lenOfLeave,dsporder) values(?,?,?,?,?)"; + flag = recordSet.executeUpdate(detailsql, rulesdetailid, time, left, right,k); + if (flag) { + int timeDetailId = 0; + String getIdSql = "select max(id) maxId from kq_OvertimeBalanceTimeDetail"; + recordSet1.executeQuery(getIdSql); + if (recordSet1.next()) { + timeDetailId = recordSet1.getInt("maxId"); + timeDetailIds.add(""+timeDetailId); + } + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + if(!timeDetailIds.isEmpty()){ + if(timeDetailIds != null && !timeDetailIds.isEmpty()){ + for(String detailId : timeDetailIds){ + String delSql = "delete from kq_OvertimeBalanceTimeDetail where id = ? "; + recordSet2.executeUpdate(delSql,detailId); + } + } + } + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + }else if("2".equalsIgnoreCase(paidLeaveEnableType_value)){ + String paidLeaveEnableFlowType_key = "paidLeaveEnableFlowType"+changetype_index; + String paidLeaveEnableFlowType_value = Util.null2String(params.get(paidLeaveEnableFlowType_key)); + if("2".equalsIgnoreCase(paidLeaveEnableFlowType_value)){ + String deleteSql = "delete from kq_OvertimeBalanceLengthDetail where rulesdetailid = ?"; + flag = recordSet.executeUpdate(deleteSql, detailid); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } +// 按加班时长范围设置转调休时长 + JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value); + for(int k = 0 ; k < jsonArray.size() ; k++){ + JSONObject jsonObject = (JSONObject) jsonArray.get(k); + String work = Util.null2String(jsonObject.get("work")); + String rest = Util.null2String(jsonObject.get("rest")); + String detailsql = "insert into kq_OvertimeBalanceLengthDetail(rulesdetailid,overtimelength,balancelength,dsporder) values(?,?,?,?)"; + flag = recordSet.executeUpdate(detailsql, rulesdetailid, work, rest, k); + if (flag) { + int lengthDetailId = 0; + String getIdSql = "select max(id) maxId from kq_OvertimeBalanceLengthDetail"; + recordSet1.executeQuery(getIdSql); + if (recordSet1.next()) { + lengthDetailId = recordSet1.getInt("maxId"); + lengthDetailIds.add(""+lengthDetailId); + } + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + if(!lengthDetailIds.isEmpty()){ + if(lengthDetailIds != null && !lengthDetailIds.isEmpty()){ + for(String detailId : lengthDetailIds){ + String delSql = "delete from kq_OvertimeBalanceLengthDetail where id = ? "; + recordSet2.executeUpdate(delSql,detailId); + } + } + } + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + }else if("3".equalsIgnoreCase(paidLeaveEnableFlowType_value)){ + String deleteSql = "delete from kq_OvertimeBalanceTimeDetail where rulesdetailid = ?"; + flag = recordSet.executeUpdate(deleteSql, detailid); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } +// 按加班的时间段设置转调休时长 + JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value); + for(int k = 0 ; k < jsonArray.size() ; k++){ + JSONObject jsonObject = (JSONObject) jsonArray.get(k); + String time = Util.null2String(jsonObject.get("time")); + String left = Util.null2String(jsonObject.get("left")); + String right = Util.null2String(jsonObject.get("right")); + String detailsql = "insert into kq_OvertimeBalanceTimeDetail(rulesdetailid,timepoint,lenOfOvertime,lenOfLeave,dsporder) values(?,?,?,?,?)"; + flag = recordSet.executeUpdate(detailsql, rulesdetailid, time, left, right,k); + if (flag) { + int timeDetailId = 0; + String getIdSql = "select max(id) maxId from kq_OvertimeBalanceTimeDetail"; + recordSet1.executeQuery(getIdSql); + if (recordSet1.next()) { + timeDetailId = recordSet1.getInt("maxId"); + timeDetailIds.add(""+timeDetailId); + } + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + if(!timeDetailIds.isEmpty()){ + if(timeDetailIds != null && !timeDetailIds.isEmpty()){ + for(String detailId : timeDetailIds){ + String delSql = "delete from kq_OvertimeBalanceTimeDetail where id = ? "; + recordSet2.executeUpdate(delSql,detailId); + } + } + } + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + } + }else{ + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + + } + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + + } catch (Exception e) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return resultMap; + } + +} diff --git a/src/com/engine/kq/cmd/overtimerules/GetOvertimeRulesFormCmd.java b/src/com/engine/kq/cmd/overtimerules/GetOvertimeRulesFormCmd.java new file mode 100644 index 0000000..bd32139 --- /dev/null +++ b/src/com/engine/kq/cmd/overtimerules/GetOvertimeRulesFormCmd.java @@ -0,0 +1,795 @@ +package com.engine.kq.cmd.overtimerules; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQShiftManagementComInfo; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.filter.XssUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 加班规则--获取新建或编辑的表单 + */ +public class GetOvertimeRulesFormCmd extends AbstractCommonCommand> { + + public GetOvertimeRulesFormCmd(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(); + String ruleId = Util.null2String(params.get("ruleId"));//加班规则的ID + boolean canAdd = HrmUserVarify.checkUserRight("KQOvertimeRulesAdd:Add", user);//是否具有新建权限 + boolean canEdit = HrmUserVarify.checkUserRight("KQOvertimeRulesEdit:Edit", user);//是否具有编辑的权限 + if (!canAdd && !canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + boolean isEdit = false; + /*班次名称*/ + String shifName = ""; + /*加班规则名称*/ + String name = ""; + /*考勤组的ID*/ + String groupIds = ""; + /*班次的ID*/ + String shiftIds = ""; + + /** + * 从这开始,下面的变量都是之前的写法,现在改成动态参数的,下面的这些参数就不用了 + */ + /*工作日是否允许加班:0-不允许、1-允许*/ + int overtimeEnable2 = 1; + /*工作日的加班方式:1-需审批,以加班流程为准、2-需审批,以打卡为准,但是不能超过加班流程时长、3-无需审批,根据打卡时间计算加班时长*/ + int computingMode2 = 1; + /*工作日下班多少分钟后开始计算加班*/ + int startTime2 = 30; + /*工作日上班前多少分钟后开始计算加班*/ + int before_startTime2 = 0; + /*工作日最小加班时长*/ + int minimumLen2 = 30; + /*工作日是否允许加班转调休*/ + int paidLeaveEnable2 = 0; + /*工作日加班转调休比例中的加班时长*/ + double lenOfOvertime2 = 1; + /*工作日加班转调休比例中的调休时长*/ + double lenOfLeave2 = 1; + + /*工作日加班补偿方式 1-默认加班补偿规则、2-根据员工在加班流程上选择的加班补偿类型进行补偿两种*/ + int paidLeaveEnableType2 = 0; + /*工作日默认加班补偿方式 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长*/ + int paidLeaveEnableDefaultType2 = 1; + /*工作日 根据员工在加班流程上选择的加班补偿类型进行补偿 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长*/ + int paidLeaveEnableFlowType2 = 1; + + // 按加班时长范围设置转调休时长: 加班时长 ≥* 分钟,转调休时长*分钟 + List> balanceLengthDetailLists2 = Lists.newArrayList(); + // 加班时间在19:00后,比例转调休时长 按照1:1 + List> balanceTimeDetailLists2 = Lists.newArrayList(); + /*工作日是否有休息时间*/ + int hasRestTime2 = 0; + /*排除休息时间两种方式 :1、设置休息时间 2、根据加班时长扣除 */ + int restType2=1; +// 工作日 是否开启 自定义跨天加班归属分界点 + int has_cut_point2 = 0; +// 开启 自定义跨天加班归属分界点 + String cut_point2 = "00:00"; + + + /*休息日是否允许加班:0-不允许、1-允许*/ + int overtimeEnable3 = 1; + /*休息日的加班方式:1-需审批,以加班流程为准、2-需审批,以打卡为准,但是不能超过加班流程时长、3-无需审批,根据打卡时间计算加班时长*/ + int computingMode3 = 1; + /*休息日的最小加班时长*/ + int minimumLen3 = 30; + /*休息日是否允许加班转调休*/ + int paidLeaveEnable3 = 0; + /*休息日加班转调休比例中的加班时长*/ + double lenOfOvertime3 = 1; + /*休息日加班转调休比例中的调休时长*/ + double lenOfLeave3 = 1; + /*休息日是否有休息时间*/ + int hasRestTime3 = 0; + + /*休息日加班补偿方式 1-默认加班补偿规则、2-根据员工在加班流程上选择的加班补偿类型进行补偿两种*/ + int paidLeaveEnableType3 = 0; + /*休息日默认加班补偿方式 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长*/ + int paidLeaveEnableDefaultType3 = 1; + /*休息日 根据员工在加班流程上选择的加班补偿类型进行补偿 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长*/ + int paidLeaveEnableFlowType3 = 1; + + // 按加班时长范围设置转调休时长: 加班时长 ≥* 分钟,转调休时长*分钟 + List> balanceLengthDetailLists3 = Lists.newArrayList(); + // 加班时间在19:00后,比例转调休时长 按照1:1 + List> balanceTimeDetailLists3 = Lists.newArrayList(); + /*排除休息时间两种方式 :1、设置休息时间 2、根据加班时长扣除 */ + int restType3=1; + + /*节假日是否允许加班:0-不允许、1-允许*/ + int overtimeEnable1 = 1; + /*节假日的加班方式:1-需审批,以加班流程为准、2-需审批,以打卡为准,但是不能超过加班流程时长、3-无需审批,根据打卡时间计算加班时长*/ + int computingMode1 = 1; + /*节假日的最小加班时长*/ + int minimumLen1 = 30; + /*节假日是否允许加班转调休*/ + int paidLeaveEnable1 = 0; + /*节假日加班转调休比例中的加班时长*/ + double lenOfOvertime1 = 1; + /*假节日加班转调休比例中的调休时长*/ + double lenOfLeave1 = 1; + /*节假日是否有休息时间*/ + int hasRestTime1 = 0; + + /*节假日加班补偿方式 1-默认加班补偿规则、2-根据员工在加班流程上选择的加班补偿类型进行补偿两种*/ + int paidLeaveEnableType1 = 0; + /*节假日默认加班补偿方式 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长*/ + int paidLeaveEnableDefaultType1 = 1; + /*节假日 根据员工在加班流程上选择的加班补偿类型进行补偿 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长*/ + int paidLeaveEnableFlowType1 = 1; + + // 按加班时长范围设置转调休时长: 加班时长 ≥* 分钟,转调休时长*分钟 + List> balanceLengthDetailLists1 = Lists.newArrayList(); + // 加班时间在19:00后,比例转调休时长 按照1:1 + List> balanceTimeDetailLists1 = Lists.newArrayList(); + /*排除节假时间两种方式 :1、设置休息时间 2、根据加班时长扣除 */ + int restType1=1; + /** + * 到这里结束,这块区间的变量就用不到了,就起到一个文字说明的意义 + */ + + //顺序显示,2是工作日,3是休息日,1是节假日 + int[] changetype = {2,3,1}; + + Map valueMap = Maps.newHashMap(); + if (!ruleId.equals("")) { + String sql = "select t1.name,t1.groupids,t2.* from kq_OvertimeRules t1 left join kq_OvertimeRulesDetail t2 on t1.id=t2.ruleId where (t1.isDelete is null or t1.isDelete!=1) and t1.id=" + ruleId; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + int dayType = 0;//1-工作日、2-休息日、3-节假日 + while (recordSet.next()) { + isEdit = true; + name = recordSet.getString("name"); + groupIds = recordSet.getString("groupIds"); + dayType = recordSet.getInt("dayType"); + int detailid = recordSet.getInt("id"); + int overtimeEnable = recordSet.getInt("overtimeEnable"); + int computingMode = recordSet.getInt("computingMode"); + int startTime = recordSet.getInt("startTime"); + Integer before_startTime = recordSet.getInt("before_startTime"); + int minimumLen = recordSet.getInt("minimumLen"); + Integer maxmumLen = recordSet.getInt("maxmumLen"); + int paidLeaveEnable = recordSet.getInt("paidLeaveEnable"); + double lenOfOvertime = recordSet.getDouble("lenOfOvertime"); + double lenOfLeave = recordSet.getDouble("lenOfLeave"); + int hasRestTime = recordSet.getInt("hasRestTime"); + int canmiddlerest = recordSet.getInt("canmiddlerest"); + int has_cut_point = recordSet.getInt("has_cut_point"); + String cut_point = recordSet.getString("cut_point"); + if("-1".equalsIgnoreCase(cut_point)){ + cut_point = "00:00"; + } + if(has_cut_point < 0){ + has_cut_point = 0; + } + if(has_cut_point == 0){ + cut_point = "00:00"; + } + if(maxmumLen == null){ + maxmumLen = -1; + } + if(before_startTime == null){ + before_startTime = -1; + } + int paidLeaveEnableType = recordSet.getInt("paidLeaveEnableType"); + int paidLeaveEnableDefaultType = recordSet.getInt("paidLeaveEnableDefaultType"); + int paidLeaveEnableFlowType = recordSet.getInt("paidLeaveEnableFlowType"); + int restTimeType = recordSet.getInt("restTimeType"); + if(paidLeaveEnableType <= 0){ + paidLeaveEnableType = 1; + } + if(paidLeaveEnableDefaultType <= 0){ + paidLeaveEnableDefaultType = 1; + } + if(paidLeaveEnableFlowType <= 0){ + paidLeaveEnableFlowType = 1; + } + if(paidLeaveEnableDefaultType == 1 && paidLeaveEnable == 0){ + //如果是第一种生成调休方式,且没有开启关联调休,那么默认的加班转调休方式就是第一种 + paidLeaveEnableDefaultType = 1; + } + if(restTimeType <= 0){ + restTimeType = 1; + } + + valueMap.put("ID_"+dayType, detailid+""); + + valueMap.put("overtimeEnable"+dayType, overtimeEnable+""); + valueMap.put("computingMode"+dayType, computingMode+""); + valueMap.put("startTime"+dayType, startTime+""); + valueMap.put("before_startTime"+dayType, before_startTime < 0 ? "" : String.valueOf(before_startTime)); + valueMap.put("minimumLen"+dayType, minimumLen+""); + valueMap.put("maxmumLen"+dayType, maxmumLen < 0 ? "" : String.valueOf(maxmumLen)); + valueMap.put("paidLeaveEnable"+dayType, paidLeaveEnable+""); + valueMap.put("lenOfOvertime"+dayType, lenOfOvertime+""); + valueMap.put("lenOfLeave"+dayType, lenOfLeave+""); + valueMap.put("hasRestTime"+dayType, hasRestTime+""); + valueMap.put("canmiddlerest"+dayType, canmiddlerest+""); + valueMap.put("restTimeType"+dayType, restTimeType+""); + valueMap.put("has_cut_point"+dayType, has_cut_point+""); + valueMap.put("cut_point"+dayType, cut_point+""); + valueMap.put("paidLeaveEnableType"+dayType, paidLeaveEnableType+""); + valueMap.put("paidLeaveEnableDefaultType"+dayType, paidLeaveEnableDefaultType+""); + valueMap.put("paidLeaveEnableFlowType"+dayType, paidLeaveEnableFlowType+""); + } + + for(int i = 0 ; i < changetype.length ; i++) { + int changetype_index = changetype[i]; + String hasRestTime_index = "hasRestTime"+changetype_index; + String paidLeaveEnable_index = "paidLeaveEnable"+changetype_index; + String paidLeaveEnableType_index = "paidLeaveEnableType"+changetype_index; + String paidLeaveEnableDefaultType_index = "paidLeaveEnableDefaultType"+changetype_index; + String paidLeaveEnableFlowType_index = "paidLeaveEnableFlowType"+changetype_index; + if(valueMap.containsKey(hasRestTime_index)){ + String hasRestTime = Util.null2String(valueMap.get(hasRestTime_index)); + if("1".equalsIgnoreCase(hasRestTime)){ + String restTimeType_index = "restTimeType"+changetype_index; + if(valueMap.containsKey(restTimeType_index)){ + String restTimeType = Util.null2String(valueMap.get(restTimeType_index)); + if("1".equalsIgnoreCase(restTimeType)){ +// 排除休息时间 + List restTimeList = new ArrayList(); + sql = "select * from kq_OvertimeRestTime where ruleId=? and dayType=? order by dayType,id"; + recordSet.executeQuery(sql, ruleId,changetype_index); + while (recordSet.next()) { + String startType = recordSet.getString("startType"); + String startTime = recordSet.getString("startTime"); + String endType = recordSet.getString("endType"); + String endTime = recordSet.getString("endTime"); + + Map restTimeMap = new HashMap(); + restTimeMap.put("startType", startType); + restTimeMap.put("startTime", startTime); + restTimeMap.put("endType", endType); + restTimeMap.put("endTime", endTime); + restTimeList.add(restTimeMap); + } + if(!restTimeList.isEmpty()){ + resultMap.put("restTimeRule"+changetype_index, restTimeList); + } + }else if("2".equalsIgnoreCase(restTimeType)){ +// 排除休息时长 + List restTimeList = new ArrayList(); + sql = "select * from kq_OvertimeRestlength where ruleId=? and dayType=? order by dayType,dsporder"; + recordSet.executeQuery(sql, ruleId,changetype_index); + while (recordSet.next()) { + String overlength = recordSet.getString("overlength"); + String cutlength = recordSet.getString("cutlength"); + + Map restTimeMap = new HashMap(); + restTimeMap.put("overtime", overlength); + restTimeMap.put("exclude", cutlength); + restTimeList.add(restTimeMap); + } + if(!restTimeList.isEmpty()){ + resultMap.put("restTimeRule"+changetype_index, restTimeList); + } + } + } + } + } + if(valueMap.containsKey(paidLeaveEnableType_index)){ + String ID_index = "ID_"+changetype_index; + if(valueMap.containsKey(ID_index)){ + String detailid = Util.null2String(valueMap.get(ID_index)); + String paidLeaveEnableType = Util.null2String(valueMap.get(paidLeaveEnableType_index)); + String paidLeaveEnableDefaultType = Util.null2String(valueMap.get(paidLeaveEnableDefaultType_index)); + String paidLeaveEnableFlowType = Util.null2String(valueMap.get(paidLeaveEnableFlowType_index)); + if("1".equalsIgnoreCase(paidLeaveEnableType)){ + if(valueMap.containsKey(paidLeaveEnable_index)) { + String paidLeaveEnable = Util.null2String(valueMap.get(paidLeaveEnable_index)); + if("1".equalsIgnoreCase(paidLeaveEnable)){ + if("2".equalsIgnoreCase(paidLeaveEnableDefaultType)){ + set_lengthDetailList(detailid,changetype_index,resultMap); + }else if("3".equalsIgnoreCase(paidLeaveEnableDefaultType)){ + set_TimeDetailList(detailid,changetype_index,resultMap); + } + } + } + }else if("2".equalsIgnoreCase(paidLeaveEnableType)){ + if("2".equalsIgnoreCase(paidLeaveEnableFlowType)){ + set_lengthDetailList(detailid,changetype_index,resultMap); + }else if("3".equalsIgnoreCase(paidLeaveEnableFlowType)){ + set_TimeDetailList(detailid,changetype_index,resultMap); + } + } + } + } + + } + + String shiftSql = "select * from kq_shiftmanagement where OVERTIME_RULE_ID="+ruleId; + recordSet.execute(shiftSql); + while (recordSet.next()){ + String serialId = recordSet.getString("id"); + if(shiftIds.length() == 0){ + shiftIds = serialId; + }else{ + shiftIds += ","+serialId; + } + } + } + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("name");//加班规则名称 + hrmFieldBean.setFieldlabel("388831"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(name); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("groupIds");//应用范围--考勤组 + hrmFieldBean.setFieldlabel("546281"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("mkqgroup"); + hrmFieldBean.setFieldvalue(groupIds); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + List> replaceDatas = new ArrayList>(); + Map datas = new HashMap(); + String[] groupIdArr = groupIds.split(","); + for (String groupId : groupIdArr) { + datas = new HashMap(); + datas.put("id", groupId); + datas.put("name", kqGroupComInfo.getGroupname(groupId)); + replaceDatas.add(datas); + } + searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas); + /*一个考勤组只能关联一个加班规则,所以新建或者编辑的时候需要对考勤组浏览按钮内的数据进行过滤*/ + Map dataMap = new HashMap(); + Map completeMap = new HashMap(); + String kqGroupIdStr = ""; + String sql = "select * from kq_OvertimeRules where (isDelete is null or isDelete !=1) "; + if (isEdit) { + sql += " and id !=" + ruleId; + } + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String kqGroupIds = recordSet.getString("groupIds"); + if (kqGroupIds.equals("")) { + continue; + } + kqGroupIdStr += "," + kqGroupIds; + } + XssUtil xssUtil = new XssUtil(); + dataMap.put("sqlWhere", kqGroupIdStr.length() > 0 ? xssUtil.put(" kqType <>3 and id not in (" + kqGroupIdStr.substring(1) + ")") : xssUtil.put(" kqType <>3 ")); + completeMap.put("sqlWhere", kqGroupIdStr.length() > 0 ? xssUtil.put(" kqType <>3 and id not in (" + kqGroupIdStr.substring(1) + ")") : xssUtil.put(" kqType <>3 ")); + searchConditionItem.getBrowserConditionParam().setDataParams(dataMap); + searchConditionItem.getBrowserConditionParam().setCompleteParams(completeMap); + itemList.add(searchConditionItem); + + String shiftidStr = ""; + String overSql = "select distinct id as shiftid from kq_shiftmanagement where (isdelete is null or isdelete <> '1') and overtime_rule_id > 0 "; + recordSet.execute(overSql); + while (recordSet.next()){ + String shiftid = Util.null2s(recordSet.getString("shiftid"),""); + if(shiftid.length() > 0){ + if(shiftidStr.length() > 0){ + shiftidStr += ","+shiftid; + }else{ + shiftidStr = shiftid; + } + } + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("shift");//班次 + hrmFieldBean.setFieldlabel("546282"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("mkqshift"); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(shiftIds); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + List> replaceDatas1 = new ArrayList>(); + Map datas1 = new HashMap(); + String[] shiftIdArr = shiftIds.split(","); + for (String shiftId : shiftIdArr) { + datas1 = new HashMap(); + datas1.put("id", shiftId); + datas1.put("name", kqShiftManagementComInfo.getSerial(shiftId)); + replaceDatas1.add(datas1); + } + searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas1); + if(shiftidStr.length() > 0){ + dataMap = new HashMap(); + completeMap = new HashMap(); + dataMap.put("sqlWhere", xssUtil.put(" id not in (" + shiftidStr + ")")); + completeMap.put("sqlWhere", xssUtil.put(" id not in (" + shiftidStr + ")")); + searchConditionItem.getBrowserConditionParam().setDataParams(dataMap); + searchConditionItem.getBrowserConditionParam().setCompleteParams(completeMap); + } + itemList.add(searchConditionItem); + + groupItem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage())); + groupItem.put("defaultshow", true); + groupItem.put("items", itemList); + groupList.add(groupItem); + + for(int i = 0 ; i < changetype.length ; i++){ + int changetype_index = changetype[i]; + groupItem = new HashMap(); + itemList = new ArrayList(); + String overtimeEnable_key = "overtimeEnable"+changetype_index; + String overtimeEnable_value = isEdit?Util.null2String(valueMap.get(overtimeEnable_key),"1"):"1"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(overtimeEnable_key);//是否允许加班 + hrmFieldBean.setFieldlabel("388833"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(overtimeEnable_value); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + Map otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + itemList.add(searchConditionItem); + + String computingMode_key = "computingMode"+changetype_index; + String computingMode_value = isEdit?Util.null2String(valueMap.get(computingMode_key),"1"):"1"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(computingMode_key);//加班方式 + hrmFieldBean.setFieldlabel("388834"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List statusOptions = new ArrayList(); + statusOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(500382, user.getLanguage()),"1".equalsIgnoreCase(computingMode_value))); + statusOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(500383, user.getLanguage()),"2".equalsIgnoreCase(computingMode_value))); + statusOptions.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(524827, user.getLanguage()),"4".equalsIgnoreCase(computingMode_value))); + statusOptions.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(390837, user.getLanguage()),"3".equalsIgnoreCase(computingMode_value))); + searchConditionItem.setOptions(statusOptions); + searchConditionItem.setDetailtype(3); + itemList.add(searchConditionItem); + + if(changetype_index == 2){ + String startTime_key = "startTime"+changetype_index; + String startTime_value = isEdit?Util.null2String(valueMap.get(startTime_key),"30"):"30"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(startTime_key);//工作日下班多少分钟后开始计算加班 + hrmFieldBean.setFieldlabel("388842"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(startTime_value); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|integer"); + searchConditionItem.setMin("0"); + itemList.add(searchConditionItem); + + String before_startTime_key = "before_startTime"+changetype_index; + String before_startTime_value = isEdit?Util.null2String(valueMap.get(before_startTime_key)):""; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(before_startTime_key);//工作日上班前多少分钟后开始计算加班 + hrmFieldBean.setFieldlabel("388842"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); +// hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(before_startTime_value); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); +// searchConditionItem.setRules("required|integer"); + searchConditionItem.setMin("0"); + itemList.add(searchConditionItem); + } + + String minimumLen_key = "minimumLen"+changetype_index; + String minimumLen_value = isEdit?Util.null2String(valueMap.get(minimumLen_key),"30"):"30"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(minimumLen_key);//最小加班时长 + hrmFieldBean.setFieldlabel("388843"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(minimumLen_value); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|integer"); + searchConditionItem.setMin("1"); + itemList.add(searchConditionItem); + + + String maxmumLen_key = "maxmumLen"+changetype_index; + String maxmumLen_value = isEdit?Util.null2String(valueMap.get(maxmumLen_key)):""; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(maxmumLen_key);//最大加班时长 + hrmFieldBean.setFieldlabel("546893"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); +// hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(maxmumLen_value); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); +// searchConditionItem.setRules("required|integer"); + searchConditionItem.setMin("1"); + itemList.add(searchConditionItem); + + String paidLeaveEnableType_key = "paidLeaveEnableType"+changetype_index; + String paidLeaveEnableType_value = isEdit?Util.null2String(valueMap.get(paidLeaveEnableType_key),"1"):"1"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(paidLeaveEnableType_key);//加班补偿方式 + hrmFieldBean.setFieldlabel("388838"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List paidLeaveEnableOptions = new ArrayList(); + paidLeaveEnableOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(524828, user.getLanguage()),"1".equalsIgnoreCase(paidLeaveEnableType_value))); + paidLeaveEnableOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(524833, user.getLanguage()),"2".equalsIgnoreCase(paidLeaveEnableType_value))); + searchConditionItem.setOptions(paidLeaveEnableOptions); + searchConditionItem.setDetailtype(3); + itemList.add(searchConditionItem); + + String paidLeaveEnableDefaultType_key = "paidLeaveEnableDefaultType"+changetype_index; + String paidLeaveEnableDefaultType_value = isEdit?Util.null2String(valueMap.get(paidLeaveEnableDefaultType_key),"1"):"1"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(paidLeaveEnableDefaultType_key);//默认加班补偿方式 里转调休的方式 + hrmFieldBean.setFieldlabel("524828"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List paidLeaveDefaultTypeOptions = new ArrayList(); + paidLeaveDefaultTypeOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(524830, user.getLanguage()),"1".equalsIgnoreCase(paidLeaveEnableDefaultType_value))); + paidLeaveDefaultTypeOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(524831, user.getLanguage()),"2".equalsIgnoreCase(paidLeaveEnableDefaultType_value))); +// 这个方式只是临时屏蔽,后面可能还是会启用,不要占用这个key是3的 +// paidLeaveDefaultTypeOptions.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(524832, user.getLanguage()),"3".equalsIgnoreCase(paidLeaveEnableDefaultType_value))); + searchConditionItem.setOptions(paidLeaveDefaultTypeOptions); + searchConditionItem.setDetailtype(1); + itemList.add(searchConditionItem); + + String paidLeaveEnableFlowType_key = "paidLeaveEnableFlowType"+changetype_index; + String paidLeaveEnableFlowType_value = isEdit?Util.null2String(valueMap.get(paidLeaveEnableFlowType_key),"1"):"1"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(paidLeaveEnableFlowType_key);//根据员工在加班流程上选择的加班补偿类型进行补偿 + hrmFieldBean.setFieldlabel("524833"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List paidLeaveFlowTypeOptions = new ArrayList(); + paidLeaveFlowTypeOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(524830, user.getLanguage()),"1".equalsIgnoreCase(paidLeaveEnableFlowType_value))); + paidLeaveFlowTypeOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(524831, user.getLanguage()),"2".equalsIgnoreCase(paidLeaveEnableFlowType_value))); +// 这个方式只是临时屏蔽,后面可能还是会启用,不要占用这个key是3的 +// paidLeaveFlowTypeOptions.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(524832, user.getLanguage()),"3".equalsIgnoreCase(paidLeaveEnableFlowType_value))); + searchConditionItem.setOptions(paidLeaveFlowTypeOptions); + searchConditionItem.setDetailtype(1); + itemList.add(searchConditionItem); + + String paidLeaveEnable_key = "paidLeaveEnable"+changetype_index; + String paidLeaveEnable_value = isEdit?Util.null2String(valueMap.get(paidLeaveEnable_key),"0"):"0"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(paidLeaveEnable_key);//是否允许加班转调休 + hrmFieldBean.setFieldlabel("388838"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(paidLeaveEnable_value); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + String lenOfOvertime_key = "lenOfOvertime"+changetype_index; + String lenOfOvertime_value = isEdit?Util.null2String(valueMap.get(lenOfOvertime_key),"1"):"1"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(lenOfOvertime_key);//加班转调休比例中的加班时长 + hrmFieldBean.setFieldlabel("389222"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(lenOfOvertime_value); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setStep("0.01"); + searchConditionItem.setPrecision(2); + itemList.add(searchConditionItem); + + String lenOfLeave_key = "lenOfLeave"+changetype_index; + String lenOfLeave_value = isEdit?Util.null2String(valueMap.get(lenOfLeave_key),"1"):"1"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(lenOfLeave_key);//加班转调休比例中的调休时长 + hrmFieldBean.setFieldlabel("389223"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(lenOfLeave_value); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setStep("0.01"); + searchConditionItem.setPrecision(2); + itemList.add(searchConditionItem); + + if(changetype_index == 2){ + String canmiddlerest_key = "canmiddlerest"+changetype_index; + String canmiddlerest_value = isEdit?Util.null2String(valueMap.get(canmiddlerest_key),"0"):"0"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(canmiddlerest_key);//休息时间计入加班 + hrmFieldBean.setFieldlabel("545557"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(canmiddlerest_value); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(545991, user.getLanguage())); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + itemList.add(searchConditionItem); + } + String hasRestTime_key = "hasRestTime"+changetype_index; + String hasRestTime_value = isEdit?Util.null2String(valueMap.get(hasRestTime_key),"0"):"0"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(hasRestTime_key);//排除休息时间 + hrmFieldBean.setFieldlabel("388565"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(hasRestTime_value); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + itemList.add(searchConditionItem); + + String restTimeType_key = "restTimeType"+changetype_index; + String restTimeType_value = isEdit?Util.null2String(valueMap.get(restTimeType_key),"1"):"1"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(restTimeType_key);//排除休息时间类型 + hrmFieldBean.setFieldlabel("388565"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List restTimeTypeOptions = new ArrayList(); + restTimeTypeOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(525905, user.getLanguage()),"1".equalsIgnoreCase(restTimeType_value))); + restTimeTypeOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(524834, user.getLanguage()),"2".equalsIgnoreCase(restTimeType_value))); + searchConditionItem.setOptions(restTimeTypeOptions); + searchConditionItem.setDetailtype(3); + itemList.add(searchConditionItem); + + String has_cut_point_key = "has_cut_point"+changetype_index; + String has_cut_point_value = isEdit?Util.null2String(valueMap.get(has_cut_point_key),"0"):"0"; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(has_cut_point_key);// 是否开启 自定义跨天加班归属分界点 + hrmFieldBean.setFieldlabel("524835"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(has_cut_point_value); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + String cut_point_key = "cut_point"+changetype_index; + String cut_point_value = isEdit?Util.null2String(valueMap.get(cut_point_key),"00:00"):"00:00"; + if("0".equalsIgnoreCase(has_cut_point_value)){ + cut_point_value = "00:00"; + } + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(cut_point_key);// 自定义跨天加班归属分界点 + hrmFieldBean.setFieldlabel("524835"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("19"); + hrmFieldBean.setFieldvalue(cut_point_value); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + +// 2是工作日,3是休息日,1是节假日 + if(changetype_index == 2){ + groupItem.put("title", SystemEnv.getHtmlLabelName(388841, user.getLanguage()));//工作日加班 + }else if(changetype_index == 3){ + groupItem.put("title", SystemEnv.getHtmlLabelName(389730, user.getLanguage()));//休息日加班 + }else if(changetype_index == 1){ + groupItem.put("title", SystemEnv.getHtmlLabelName(1959, user.getLanguage()));//节假日加班 + } + groupItem.put("defaultshow", true); + groupItem.put("items", itemList); + groupList.add(groupItem); + } + resultMap.put("condition", groupList); + + /** + * 判断调休是否已设置 + */ + sql = "select * from kq_LeaveRules where (isDelete is null or isDelete <>1) and id in (select ruleId from kq_LeaveRulesDetail where (isDelete is null or isDelete <>1) and distributionMode=5)"; + recordSet.executeQuery(sql); + boolean hasTXRules = recordSet.getCounts()>0; + resultMap.put("hasTXrules",hasTXRules); + return resultMap; + } + + private void set_TimeDetailList(String detailid, int changetype_index, Map resultMap) { + RecordSet recordSet = new RecordSet(); + List timeDetailList = new ArrayList(); + String sql = "select * from kq_OvertimeBalanceTimeDetail where rulesdetailid=? order by timepoint"; + recordSet.executeQuery(sql, detailid); + while (recordSet.next()) { + String timepoint = recordSet.getString("timepoint"); + String lenOfOvertime = recordSet.getString("lenOfOvertime"); + String lenOfLeave = recordSet.getString("lenOfLeave"); + String dsporder = recordSet.getString("dsporder"); + + Map timeDetailMap = new HashMap(); + timeDetailMap.put("time", timepoint); + timeDetailMap.put("left", lenOfOvertime); + timeDetailMap.put("right", lenOfLeave); + timeDetailMap.put("dsporder", dsporder); + timeDetailList.add(timeDetailMap); + } + if(!timeDetailList.isEmpty()){ + resultMap.put("paidLeaveEnableTypeRule"+changetype_index, timeDetailList); + } + } + + private void set_lengthDetailList(String detailid, int changetype_index, + Map resultMap){ + + RecordSet recordSet = new RecordSet(); + List lengthDetailList = new ArrayList(); + String sql = "select * from kq_OvertimeBalanceLengthDetail where rulesdetailid=? order by overtimelength"; + recordSet.executeQuery(sql, detailid); + while (recordSet.next()) { + String overtimelength = recordSet.getString("overtimelength"); + String balancelength = recordSet.getString("balancelength"); + String dsporder = recordSet.getString("dsporder"); + + Map lengthDetailMap = new HashMap(); + lengthDetailMap.put("work", overtimelength); + lengthDetailMap.put("rest", balancelength); + lengthDetailMap.put("dsporder", dsporder); + lengthDetailList.add(lengthDetailMap); + } + if(!lengthDetailList.isEmpty()){ + resultMap.put("paidLeaveEnableTypeRule"+changetype_index, lengthDetailList); + } + } +} diff --git a/src/com/engine/kq/cmd/overtimerules/GetOvertimeSearchConditionCmd.java b/src/com/engine/kq/cmd/overtimerules/GetOvertimeSearchConditionCmd.java new file mode 100644 index 0000000..faa99e8 --- /dev/null +++ b/src/com/engine/kq/cmd/overtimerules/GetOvertimeSearchConditionCmd.java @@ -0,0 +1,112 @@ +package com.engine.kq.cmd.overtimerules; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +public class GetOvertimeSearchConditionCmd extends AbstractCommonCommand> { + + public GetOvertimeSearchConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("KQOvertimeRulesAdd:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + Map> fieldGroups= new LinkedHashMap>(); + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("name"); + hrmFieldBean.setFieldlabel("388831"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("groupIds"); + hrmFieldBean.setFieldlabel("546281"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("mkqgroup"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("shift"); + hrmFieldBean.setFieldlabel("546282"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("mkqshift"); + lsField.add(hrmFieldBean); + fieldGroups.put("1361", lsField); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + Iterator>> iter = fieldGroups.entrySet().iterator(); + while (iter.hasNext()) { + Entry> entry = iter.next(); + String grouplabel = entry.getKey(); + List fields = entry.getValue(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("defaultshow", true); + + itemlist = new ArrayList(); + for (int j = 0; j < fields.size(); j++) { + hrmFieldBean = fields.get(j); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if("groupIds".equals(hrmFieldBean.getFieldname())){ + Map dataMap = new HashMap(); + Map completeMap = new HashMap(); + dataMap.put("includeAll", "1"); + completeMap.put("includeAll", "1"); + searchConditionItem.getBrowserConditionParam().setDataParams(dataMap); + searchConditionItem.getBrowserConditionParam().setCompleteParams(completeMap); + } + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + + retmap.put("status", "1"); + retmap.put("conditions", grouplist); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/overtimerules/GetOvertimeUnitFormCmd.java b/src/com/engine/kq/cmd/overtimerules/GetOvertimeUnitFormCmd.java new file mode 100644 index 0000000..6580ae4 --- /dev/null +++ b/src/com/engine/kq/cmd/overtimerules/GetOvertimeUnitFormCmd.java @@ -0,0 +1,163 @@ +package com.engine.kq.cmd.overtimerules; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 加班规则--加班单位 + */ +public class GetOvertimeUnitFormCmd extends AbstractCommonCommand> { + + public GetOvertimeUnitFormCmd(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(); + + int id = 1;////暂为备用字段,加班单位ID,固定为1 + int minimumUnit = 1;//最小加班单位:1-按天加班、2-按半天加班、3-按小时加班、4-按整天加班 + int overtimeConversion = 1;//加班时长折算方式:1-四舍五入、2-向上取整、3-向下取整 + double hoursToDay = 8.00;//日折算时长 + //半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + int timeselection = 1; + + /* 加班规则维护权限 */ + boolean canAdd = HrmUserVarify.checkUserRight("KQOvertimeRulesAdd:Add", user);//是否具有新建权限 + boolean canEdit = HrmUserVarify.checkUserRight("KQOvertimeRulesEdit:Edit", user);//是否具有编辑的权限; + if(!canAdd && !canEdit){ + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + String sql = "select * from kq_OvertimeUnit where (isDelete is null or isDelete !=1) and id="+id; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if(recordSet.next()){ + minimumUnit = recordSet.getInt("minimumUnit"); + overtimeConversion = recordSet.getInt("overtimeConversion"); + hoursToDay = recordSet.getDouble("hoursToDay"); + timeselection = recordSet.getInt("timeselection"); + timeselection = timeselection < 1 ? 1 : timeselection; + } + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("minimumUnit");//最小加班单位 + hrmFieldBean.setFieldlabel("390388"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(390389, user.getLanguage()), minimumUnit == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(390390, user.getLanguage()), minimumUnit == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(390391, user.getLanguage()), minimumUnit == 3)); + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(390392, user.getLanguage()), minimumUnit == 4)); + optionsList.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(528529, user.getLanguage()), minimumUnit == 5)); + optionsList.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(528530, user.getLanguage()), minimumUnit == 6)); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + List minimumUnitTips = new ArrayList(); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(390372, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389733, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389734, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389732, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389734, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389734, user.getLanguage())); + resultMap.put("minimumUnit", minimumUnitTips); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("timeselection");//时间选择方式 + hrmFieldBean.setFieldlabel("513304"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(timeselection+""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(513301, user.getLanguage()), timeselection == 1)); +// optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(513302, user.getLanguage()), timeselection == 2)); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("hoursToday");//日折算时长 + hrmFieldBean.setFieldlabel("388907"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(hoursToDay); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2);//保留两位小数 + itemList.add(searchConditionItem); + + //加班时长折算方式 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("overtimeConversion"); + hrmFieldBean.setFieldlabel("528531"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(389654, user.getLanguage()), overtimeConversion == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(508424, user.getLanguage()), overtimeConversion == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(508425, user.getLanguage()), overtimeConversion == 3)); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + +// 按半小时加班联动说明: + List overtimeConversionTips = new ArrayList(); + overtimeConversionTips.add(SystemEnv.getHtmlLabelName(528532, user.getLanguage())); + overtimeConversionTips.add(SystemEnv.getHtmlLabelName(528533, user.getLanguage())); + overtimeConversionTips.add(SystemEnv.getHtmlLabelName(528534, user.getLanguage())); + resultMap.put("overtimeConversion5", overtimeConversionTips); + + // 按整小时加班联动说明: + overtimeConversionTips = new ArrayList(); + overtimeConversionTips.add(SystemEnv.getHtmlLabelName(528535, user.getLanguage())); + overtimeConversionTips.add(SystemEnv.getHtmlLabelName(528536, user.getLanguage())); + overtimeConversionTips.add(SystemEnv.getHtmlLabelName(529548, user.getLanguage())); + resultMap.put("overtimeConversion6", overtimeConversionTips); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/overtimerules/GetRightMenuCmd.java b/src/com/engine/kq/cmd/overtimerules/GetRightMenuCmd.java new file mode 100644 index 0000000..16cd987 --- /dev/null +++ b/src/com/engine/kq/cmd/overtimerules/GetRightMenuCmd.java @@ -0,0 +1,75 @@ +package com.engine.kq.cmd.overtimerules; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 加班规则--右键菜单 + */ +public class GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(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(); + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + int languageId = user.getLanguage();//用户选择的语言 + RightMenu rightMenu = null; + + String tabKey = Util.null2String(params.get("tabKey"));//是加班规则还是加班单位 + + boolean canAdd = HrmUserVarify.checkUserRight("KQOvertimeRulesAdd:Add", user);//是否具有新建权限 + boolean canDelete = HrmUserVarify.checkUserRight("KQOvertimeRulesDelete:Delete", user);//是否具有删除权限 + boolean canLog = HrmUserVarify.checkUserRight("KQOvertimeRules:Log", user);//是否具有查看日志的权限 + + if (tabKey.equals("1")) {//加班单位页签 + if (canAdd) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Save, "save", true);//保存 + rightMenuList.add(rightMenu); + } + if (canLog) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_log, "log", false);//日志 + rightMenuList.add(rightMenu); + } + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } else {//加班规则页签 + if (canAdd) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Addnew, "new", true);//新建 + rightMenuList.add(rightMenu); + } + if (canDelete) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_BatchDelete, "batchDelete", true, true);//批量删除 + rightMenuList.add(rightMenu); + } + if (canLog) { + rightMenu = new RightMenu(languageId, RightMenuType.BTN_log, "log", false);//日志 + rightMenuList.add(rightMenu); + } + rightMenu = new RightMenu(languageId, RightMenuType.BTN_COLUMN, "custom", false); //显示列定制 + rightMenuList.add(rightMenu); + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } + } +} diff --git a/src/com/engine/kq/cmd/overtimerules/GetSearchListCmd.java b/src/com/engine/kq/cmd/overtimerules/GetSearchListCmd.java new file mode 100644 index 0000000..6853649 --- /dev/null +++ b/src/com/engine/kq/cmd/overtimerules/GetSearchListCmd.java @@ -0,0 +1,94 @@ +package com.engine.kq.cmd.overtimerules; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.PageIdConst; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.proj.util.SQLUtil; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * 加班规则--获取加班规则列表 + */ +public class GetSearchListCmd extends AbstractCommonCommand> { + + 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(); + + RecordSet recordSet = new RecordSet(); + boolean canEdit = HrmUserVarify.checkUserRight("KQOvertimeRulesEdit:Edit", user);//是否具有编辑的权限; + boolean canDelete = HrmUserVarify.checkUserRight("KQOvertimeRulesDelete:Delete", user);//是否具有删除的权限; + boolean canLog = HrmUserVarify.checkUserRight("KQOvertimeRules:Log", user);//是否具有查看日志的权限; + + String name = Util.null2String(params.get("name")); + String groupIds = Util.null2String(params.get("groupIds")); + String shift = Util.null2String(params.get("shift")); + + String backFields = " id,name,groupIds,id as sid "; + String sqlFrom = " from kq_OvertimeRules "; + String sqlWhere = " where 1=1 and (isDelete is null or isDelete!=1) "; + + if (name.length() > 0) { + sqlWhere += " and name like '%" + name + "%' "; + } + if (groupIds.length() > 0) { + String dbtype = recordSet.getDBType(); + if ("oracle".equalsIgnoreCase(dbtype)) { + sqlWhere += " and "+ SQLUtil.filteSql(recordSet.getDBType(), " ','+groupids+',' like '%," + groupIds + ",%' "); + }else if("mysql".equalsIgnoreCase(dbtype)){ + sqlWhere += " and CONCAT(',',cast(groupids as char),',') like '%,"+groupIds+",%' "; + }else if ("postgresql".equalsIgnoreCase(dbtype)) { + sqlWhere += " and CONCAT(',',groupids,',') like '%,"+groupIds+",%' "; + }else{ + sqlWhere += " and ','+convert(varchar(2000),groupids)+',' like '%," + groupIds + ",%' "; + } + } + if (shift.length() > 0) { + sqlWhere += " and id in(select OVERTIME_RULE_ID from kq_shiftmanagement where id="+shift+" )"; + } + + String orderBy = " id "; + String pageUid = "1b3ad739-67fa-8b1e-1c19-6d37c1a33469"; + String operateString = ""; + operateString = ""; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += ""; + String tableString = "" + + "" + + " " + + operateString + + " " + + " " + + " " + + " " + + " " + + " " + + "
"; + String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionKey, tableString); + resultMap.put("sessionkey", sessionKey); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/overtimerules/IsRepeatSettingCmd.java b/src/com/engine/kq/cmd/overtimerules/IsRepeatSettingCmd.java new file mode 100644 index 0000000..fb41d90 --- /dev/null +++ b/src/com/engine/kq/cmd/overtimerules/IsRepeatSettingCmd.java @@ -0,0 +1,70 @@ +package com.engine.kq.cmd.overtimerules; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 加班规则--判断某考勤组是否重复设置了加班规则 + */ +public class IsRepeatSettingCmd extends AbstractCommonCommand> { + + public IsRepeatSettingCmd(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(); + + String ruleId = Util.null2String(params.get("ruleId"));//加班规则的ID + String groupIds = Util.null2String(params.get("groupIds"));//考勤组的ID + + List errMsgList = new ArrayList();//考勤组重复设置了加班规则的错误信息提示集合 + + RecordSet recordSet = new RecordSet(); + String[] groupIdArr = groupIds.split(","); + for (int i = 0; i < groupIdArr.length; i++) { + String groupId = groupIdArr[i]; + String groupName = "";//考勤组的名称 + String sql = "select * from kq_overtimeRules where (isDelete is null or isDelete!=1) "; + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sql += " and ','+groupIds+',' like '%," + groupId + ",%'"; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sql += " and contract(',',groupIds,',') like '%," + groupId + ",%'"; + } else { + sql += " and ','||groupIds||',' like '%," + groupId + ",%'"; + } + if (!ruleId.equals("")) { + sql += " and ruleId not in (" + ruleId + ")"; + } + recordSet.executeQuery(sql); + if (recordSet.next()) { + errMsgList.add(groupName + SystemEnv.getHtmlLabelName(81869, user.getLanguage())); + } + } + + if(errMsgList.size()==0){ + resultMap.put("isRepeatSetting",false); + }else{ + resultMap.put("isRepeatSetting",true); + resultMap.put("message",errMsgList); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/overtimerules/SaveDefaultCmd.java b/src/com/engine/kq/cmd/overtimerules/SaveDefaultCmd.java new file mode 100644 index 0000000..9f44d11 --- /dev/null +++ b/src/com/engine/kq/cmd/overtimerules/SaveDefaultCmd.java @@ -0,0 +1,67 @@ +package com.engine.kq.cmd.overtimerules; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * 保存是否默认 + */ +public class SaveDefaultCmd extends AbstractCommonCommand> { + + public SaveDefaultCmd(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(); + String ruleId = Util.null2String(params.get("ruleId"));//规则ID + if (ruleId.equals("")) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage())); + return resultMap; + } + boolean flag = false; + String sql = "update kq_OvertimeRules set isDefault=1 where id=?"; + RecordSet recordSet = new RecordSet(); + flag = recordSet.executeUpdate(sql, ruleId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + + if (!ruleId.equals("")) { + sql = "update kq_OvertimeRules set isDefault=0 where id not in (" + ruleId + ")"; + flag = recordSet.executeUpdate(sql); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/overtimerules/SaveOvertimeUnitCmd.java b/src/com/engine/kq/cmd/overtimerules/SaveOvertimeUnitCmd.java new file mode 100644 index 0000000..386922e --- /dev/null +++ b/src/com/engine/kq/cmd/overtimerules/SaveOvertimeUnitCmd.java @@ -0,0 +1,115 @@ +package com.engine.kq.cmd.overtimerules; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQAttFlowSetComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 加班单位--保存 + */ +public class SaveOvertimeUnitCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public SaveOvertimeUnitCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMEUNIT);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMEUNIT);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_overtimeUnit"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4OvertimeUnit",""+user.getLanguage()); + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + + /* 加班规则维护权限 */ + boolean canAdd = HrmUserVarify.checkUserRight("KQOvertimeRulesAdd:Add", user);//是否具有新建权限 + boolean canEdit = HrmUserVarify.checkUserRight("KQOvertimeRulesEdit:Edit", user);//是否具有编辑的权限; + if (!canAdd && !canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + //是否设置了【流程和打卡取交集的加班方式】 + boolean hasComputingmode4 = false; + RecordSet recordSet1 = new RecordSet(); + String checkSql = "select * from kq_overtimerulesdetail where computingmode = 4 and ruleid not in(select id from kq_overtimerules where isdelete =1) "; + recordSet1.executeQuery(checkSql); + if(recordSet1.next()){ + hasComputingmode4 = true; + } + + + int id = 1;////暂为备用字段,加班单位ID,固定为1 + int minimumUnit = Util.getIntValue((String) params.get("minimumUnit"), 1);//最小加班单位:1-按天加班、2-按半天加班、3-按小时加班、4-按整天加班 + int overtimeConversion = Util.getIntValue((String) params.get("overtimeConversion"), 1);//加班时长折算方式:1-四舍五入、2-向上取整、3-向下取整 + double hoursToday = Util.getDoubleValue((String) params.get("hoursToday"), -1.00);//日折算时长 + int timeselection = Util.getIntValue((String) params.get("timeselection"), 1);//半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + if(hasComputingmode4){ + if(minimumUnit == 2 || minimumUnit == 4){ + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(529168, user.getLanguage())); + return resultMap; + } + } + + if(minimumUnit != 2){ + RecordSet rs = new RecordSet(); + //如果出差单位不再是半天了,需要删除原半天设置 + String del_2_sql = "delete from kq_timeselection where selectiontype=3 and minimumUnit=2"; + boolean is_2_del = rs.executeUpdate(del_2_sql); + } + + boolean flag = true; + String sql = "update kq_OvertimeUnit set minimumUnit=?,hoursToday=?,timeselection=?,overtimeConversion=? where id=?"; + RecordSet recordSet = new RecordSet(); + flag = recordSet.executeUpdate(sql, minimumUnit, hoursToday,timeselection,overtimeConversion, id); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } + + KQAttFlowSetComInfo kqAttFlowSetComInfo = new KQAttFlowSetComInfo(); + kqAttFlowSetComInfo.removeKQAttFlowSetComInfoCache(); + + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/remindOnPC/GetRemindInfoCmd.java b/src/com/engine/kq/cmd/remindOnPC/GetRemindInfoCmd.java new file mode 100644 index 0000000..298adce --- /dev/null +++ b/src/com/engine/kq/cmd/remindOnPC/GetRemindInfoCmd.java @@ -0,0 +1,258 @@ +package com.engine.kq.cmd.remindOnPC; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.KQHrmScheduleSign; +import com.engine.kq.biz.*; +import com.engine.kq.entity.KQGroupEntity; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.TimeSignScopeEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class GetRemindInfoCmd extends AbstractCommonCommand> { + + private static KQLog logger = new KQLog();//用于记录日志信息 + + public GetRemindInfoCmd(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(); + + //获取当前日期 + String currentDate = DateUtil.getCurrentDate(); + //获取当前时间 + String currentTime = DateUtil.getCurrentHourMin(); + //获取当前的日期时间 + String currentDateTime = DateUtil.getFullDate(); + //获取当前登录人员ID + String resourceId = "" + user.getUID(); + //获取当前登录人员的考勤组 + KQGroupEntity kqGroupEntity = null; + KQGroupMemberComInfo groupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupEntity = groupMemberComInfo.getUserKQGroupInfo(resourceId, currentDate); + if (kqGroupEntity == null) { + //logger.info("获取不到当前人员的考勤组,登录PC端不提醒。resourceId=" + resourceId); + resultMap.put("isOpen", false); + return resultMap; + } + //判断是否是无需考勤人员 + String excludeId = kqGroupEntity.getExcludeid(); + List excludeIdList = Arrays.asList(excludeId.split(",")); + if (excludeIdList != null && excludeIdList.contains(resourceId)) { + //logger.info("当前人员无需考勤,登录PC端不提醒。resourceId=" + resourceId); + resultMap.put("isOpen", false); + return resultMap; + } + //获取考勤组的打卡方式 + String signType = kqGroupEntity.getSignintype(); + if ("4".equals(signType)) { + //logger.info("当前考勤组无需打卡,登录PC端不提醒。resourceId=" + resourceId); + resultMap.put("isOpen", false); + return resultMap; + } + /** + * 假如班次时间如下: + * 2019-10-15 22:00:00~~2019-10-16 02:00:00 + * 2019-10-16 12:00:00~~2019-10-16 20:00:00 + * 那么人员A于2019-10-16 01:00:00登录系统时要弹窗提示其打卡(如果他没有打卡的话) + * 所以这里需要判断前一天的班次情况 + */ + for (int i = -1; i <= 0; i++) { + KQWorkTime kqWorkTime = new KQWorkTime(); + String kqDate = DateUtil.addDate(currentDate, i); + //获取当前对应人员的班次 + String serialId = kqWorkTime.getSerialIds(resourceId, kqDate); + if (serialId == null || "".equals(serialId) || serialId.contains("{")) { + if (i == 0) { + //logger.info("获取不到当前人员的班次,登录PC端不提醒。resourceId=" + resourceId); + resultMap.put("isOpen", false); + return resultMap; + } else { + continue; + } + } + //判断班次是否开启了打卡提醒 + KQShiftManagementComInfo shiftManagementComInfo = new KQShiftManagementComInfo(); + String cardRemind = shiftManagementComInfo.getCardRemind(serialId); + if (!"1".equals(cardRemind)) { + if (i == 0) { + //logger.info("未开启打卡提醒,登录PC端不提醒。resourceId=" + resourceId); + resultMap.put("isOpen", false); + return resultMap; + } else { + continue; + } + } + //判断班次是否开启了登录PC端打卡提醒 + String remindOnPC = shiftManagementComInfo.getRemindOnPC(serialId); + if (!"1".equals(remindOnPC)) { + if (i == 0) { + //logger.info("未开启打卡提醒,登录PC端不提醒。resourceId=" + resourceId); + resultMap.put("isOpen", false); + return resultMap; + } else { + continue; + } + } + //判断是否能获取到工作时间 + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(resourceId, kqDate); + //如果获取不到workTimeEntity肯定是休息,非工作日班次,如果能获取到workTimeEntity直接查询非工作日班次的属性 + int nonWorkShift = workTimeEntity == null ? 1 : workTimeEntity.getNonWorkShift(); + if (workTimeEntity == null || nonWorkShift == 1) { + if (i == 0) { + //logger.info("获取不到工作时间,登录PC端不提醒。resourceId=" + resourceId); + resultMap.put("isOpen", false); + return resultMap; + } else { + continue; + } + } + //判断是否当前时间是否在考勤时间范围内 + boolean isInScope = false; + String preDate = DateUtil.addDate(kqDate, -1); + String nextDate = DateUtil.addDate(kqDate, 1); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + List signTime = workTimeEntity.getSignTime(); + for (int j = 0; j < signTime.size(); j++) { + TimeScopeEntity signTimeScope = signTime.get(j); + + String signBeginDateTime = "";//上班打卡开始时间 +// signBeginDateTime = signTimeScope.getBeginTimeAcross() ? preDate : kqDate; + signBeginDateTime = signTimeScope.isBeginTimePreAcross() ? preDate : kqDate; + signBeginDateTime += " " + kqTimesArrayComInfo.turn48to24Time(signTimeScope.getBeginTime()) + ":00"; + + String signEndDateTime = "";//下班打卡结束时间 + signEndDateTime = signTimeScope.getEndTimeAcross() ? nextDate : kqDate; + signEndDateTime += " " + kqTimesArrayComInfo.turn48to24Time(signTimeScope.getEndTime()) + ":59"; + + String signBeginDateTimeStart = signBeginDateTime;//上班打卡开始时间 + String signBeginDateTimeEnd = signEndDateTime;//上班打卡结束时间 + + String signEndDateTimeStart = signBeginDateTime;//下班打卡开始时间 + String signEndDateTimeEnd = signEndDateTime;//下班打卡结束时间 + TimeSignScopeEntity timeSignScopeEntity = signTimeScope.getTimeSignScopeEntity(); + if (timeSignScopeEntity == null) { + //没有设置 上班打卡结束时间和下班打卡开始时间 + } else { + String beginTimeEnd = timeSignScopeEntity.getBeginTimeEnd();//上班打卡结束时间 + boolean beginTimeEndAcross = timeSignScopeEntity.isBeginTimeEndAcross(); + + String endTimeStart = timeSignScopeEntity.getEndTimeStart();//下班打卡开始时间 + boolean endTimeStartAcross = timeSignScopeEntity.isEndTimeStartAcross(); + + if (beginTimeEnd.length() > 0) { + //如果设置了 上班结束时间 + if (endTimeStart.length() > 0) { + signBeginDateTimeStart = signBeginDateTime; + signBeginDateTimeEnd = beginTimeEndAcross ? nextDate : kqDate; + signBeginDateTimeEnd += " " + kqTimesArrayComInfo.turn48to24Time(beginTimeEnd) + ":59"; + + signEndDateTimeStart = endTimeStartAcross ? preDate : kqDate; + signEndDateTimeStart += " " + kqTimesArrayComInfo.turn48to24Time(endTimeStart) + ":00"; + signEndDateTimeEnd = signEndDateTime; + } else { + //没有设置下班开始时间 + signBeginDateTimeStart = signBeginDateTime; + signBeginDateTimeEnd = beginTimeEndAcross ? nextDate : kqDate; + signBeginDateTimeEnd += " " + kqTimesArrayComInfo.turn48to24Time(beginTimeEnd) + ":59"; + + //如果设置了上班结束时间,相当于下班开始时间也被限定了 + String kqTime = kqTimesArrayComInfo.getTimesByArrayindex(kqTimesArrayComInfo.getArrayindexByTimes(beginTimeEnd) + 1); + signEndDateTimeStart = beginTimeEndAcross ? nextDate : kqDate; + signEndDateTimeStart += " " + kqTimesArrayComInfo.turn48to24Time(kqTime) + ":00"; + signEndDateTimeEnd = signEndDateTime; + } + } else { + //如果没有设置上班结束时间,设置了下班开始时间 + //如果设置了下班开始时间,相当于上班结束时间也被限定了 + if (endTimeStart.length() > 0) { + signBeginDateTimeStart = signBeginDateTime; + String kqTime = kqTimesArrayComInfo.getTimesByArrayindex(kqTimesArrayComInfo.getArrayindexByTimes(endTimeStart) - 1); + signBeginDateTimeEnd = endTimeStartAcross ? preDate : kqDate; + signBeginDateTimeEnd += " " + kqTimesArrayComInfo.turn48to24Time(kqTime) + ":59"; + + signEndDateTimeStart = endTimeStartAcross ? preDate : kqDate; + signEndDateTimeStart += " " + kqTimesArrayComInfo.turn48to24Time(endTimeStart) + ":00"; + signEndDateTimeEnd = signEndDateTime; + } else { + //没有设置 上班打卡结束时间和下班打卡开始时间 + } + } + } + if (signBeginDateTimeStart.compareTo(currentDateTime) <= 0 && signBeginDateTimeEnd.compareTo(currentDateTime) >= 0) { + //判断是否已经打过卡 + boolean hasSign = hasSign(resourceId, signBeginDateTimeStart, signBeginDateTimeEnd); + if (hasSign) { + //logger.info("已经打过卡了,登录PC端不提醒。resourceId=" + resourceId); + resultMap.put("isOpen", false); + return resultMap; + } else { + break; + } + } else { + if (i == 0 && j == signTime.size() - 1) { + //logger.info("不在打卡时间范围内,登录PC端不提醒。resourceId=" + resourceId); + resultMap.put("isOpen", false); + return resultMap; + } else { + continue; + } + } + } + } + + if ("1".equals(signType) || "2".equals(signType)) { + resultMap.put("msg", SystemEnv.getHtmlLabelName(21415, user.getLanguage())); + resultMap.put("canSignOnPC", true); + resultMap.put("isOpen", true); + } else { + resultMap.put("msg", SystemEnv.getHtmlLabelName(510586, user.getLanguage())); + resultMap.put("canSignOnPC", false); + resultMap.put("isOpen", true); + } + return resultMap; + } + + /** + * 拼接打卡日期和时间的SQL + * + * @param beginDateTime + * @param endDateTime + * @return + */ + private boolean hasSign(String resourceId, String beginDateTime, String endDateTime) { + RecordSet rs = new RecordSet(); + StringBuffer sql = new StringBuffer(); + sql.append("select * from hrmschedulesign where isincom=1 and userid = ").append(resourceId); + if (rs.getDBType().equals("oracle")||rs.getDBType().equals("postgresql")) { + sql.append(" AND signDate||' '||signTime>='").append(beginDateTime).append("' "); + sql.append(" AND signDate||' '||signTime<='").append(endDateTime).append("' "); + } else if (rs.getDBType().equals("mysql")) { + sql.append(" AND concat(signDate,' ',signTime)>='").append(beginDateTime).append("' "); + sql.append(" AND concat(signDate,' ',signTime)<='").append(endDateTime).append("' "); + } else { + sql.append(" AND signDate+' '+signTime>='").append(beginDateTime).append("' "); + sql.append(" AND signDate+' '+signTime<='").append(endDateTime).append("' "); + } + rs.executeQuery(sql.toString()); + boolean hasSign = rs.getCounts() > 0; + return hasSign; + } +} diff --git a/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java b/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java new file mode 100644 index 0000000..85c9a82 --- /dev/null +++ b/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java @@ -0,0 +1,708 @@ +package com.engine.kq.cmd.report; + +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.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.util.ExcelUtil; +import com.engine.kq.util.KQDurationCalculatorUtil; +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 javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.*; + +public class ExportDailyExcelCmd extends AbstractCommonCommand> { + + private HttpServletRequest request; + private HttpServletResponse response; + private List lsFieldDataKey; + + public ExportDailyExcelCmd(Map params, HttpServletRequest request, HttpServletResponse response, User user) { + this.user = user; + this.params = params; + this.request = request; + this.response = response; + this.lsFieldDataKey = new ArrayList<>(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + KQWorkTime kqWorkTime = new KQWorkTime(); + KQReportBiz kqReportBiz = new KQReportBiz(); + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"0"); + + new KQReportBiz().insertKqReportExportLog(params, user); + 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 status = Util.null2String(jsonObj.get("status")); + 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")); + List showColumns = Util.splitString2List(Util.null2String(jsonObj.get("showColumns")),","); + showColumns.add("lastname"); + showColumns.add("kqdate"); + showColumns.add("serialid"); + showColumns.removeIf(showColumn->showColumn.trim().equals("")); + + List tmpShowColumns = new ArrayList<>(); + for(String showColumn:showColumns){ + tmpShowColumns.add(showColumn); + String cascadekey = ""; + if(showColumn.equals("signin1")){ + cascadekey = "signout1"; + }else if(showColumn.equals("signin2")){ + cascadekey = "signout2"; + }else if(showColumn.equals("signin3")){ + cascadekey = "signout3"; + }else if(showColumn.equals("beLate")){ + cascadekey = "beLateMins"; + }else if(showColumn.equals("leaveEearly")){ + cascadekey = "leaveEarlyMins"; + }else if(showColumn.equals("graveBeLate")){ + cascadekey = "graveBeLateMins"; + }else if(showColumn.equals("graveLeaveEarly")){ + cascadekey = "graveLeaveEarlyMins"; + }else if(showColumn.equals("absenteeism")){ + cascadekey = "absenteeismMins"; + }else if(showColumn.equals("overtime")){ + tmpShowColumns.add("overtime_4leave"); + tmpShowColumns.add("overtime_nonleave"); + tmpShowColumns.add("workingDayOvertime_nonleave"); + tmpShowColumns.add("workingDayOvertime_4leave"); + tmpShowColumns.add("restDayOvertime_nonleave"); + tmpShowColumns.add("restDayOvertime_4leave"); + tmpShowColumns.add("holidayOvertime_4leave"); + tmpShowColumns.add("holidayOvertime_nonleave"); + } + if(cascadekey.length()>0){ + tmpShowColumns.add(cascadekey); + } + } + showColumns = tmpShowColumns; + + String today = DateUtil.getCurrentDate(); + if(DateUtil.compDate(today, toDate)>0){//结束如期不大于今天 + toDate = today; + } + + String rightSql = new KQReportBiz().getReportRight("2",""+user.getUID(),"a"); + + LinkedHashMap workbook = new LinkedHashMap<>(); + List lsSheet = new ArrayList<>(); + Map sheet = null; + List titleList = new ArrayList<>(); + Map title = null; + List> dataList = new ArrayList<>(); + List data = null; + List> constraintList = null; + Map constraint = null; + + sheet = new HashMap<>(); + sheet.put("sheetName", SystemEnv.getHtmlLabelName( 390352, user.getLanguage())); + sheet.put("sheetTitle", SystemEnv.getHtmlLabelName( 390352, user.getLanguage())); + + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + + Map mapChildColumnInfo = null; + List childColumns = null; + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()){ + if(Util.null2String(kqReportFieldComInfo.getParentid()).length()>0)continue; + if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("daily"))continue; + if (!showColumns.contains(kqReportFieldComInfo.getFieldname())&&!showColumns.contains(kqReportFieldComInfo.getParentid())) continue; + if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){ + continue; + } + title = new HashMap<>(); + String unitType = KQReportBiz.getUnitType(kqReportFieldComInfo, user); + if(unitType.length()>0){ + title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())+ "(" + unitType + ")"); + }else{ + title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())); + } + title.put("width",30*256); + this.lsFieldDataKey.add(kqReportFieldComInfo.getFieldname()); + mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(),user); + childColumns = (List)mapChildColumnInfo.get("childColumns"); + if(childColumns.size()>0) {//跨列width取子列的width + title.put("children", childColumns); + title.put("colSpan",childColumns.size()); + }else{ + title.put("rowSpan", 3); + } + titleList.add(title); + } + sheet.put("titleList", titleList); + + // 没有权限的人最大只支持查询本季 + Map getRealDate = new KQReportBiz().realDate(fromDate, toDate, user, "2"); + fromDate = getRealDate.get("fromDate"); + toDate = getRealDate.get("toDate"); + if("-1".equals(fromDate) || "-1".equals(toDate)) { + retmap.put("status", "1"); + return retmap; + } + List paramLists = new ArrayList<>(); + List paramList = null; + String forgotBeginWorkCheck_field = " b.forgotbeginworkcheck "; + + if(rs.getDBType().equalsIgnoreCase("oracle")&&!Util.null2String(rs.getOrgindbtype()).equals("dm")&&!Util.null2String(rs.getOrgindbtype()).equals("st")) { + forgotBeginWorkCheck_field = " nvl(b.forgotBeginWorkCheck,0) "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + forgotBeginWorkCheck_field = " ifnull(b.forgotBeginWorkCheck,0) "; + }else { + forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) "; + } + + String backFields = " a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," + + " b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,b.attendanceMins,b.beLate," + + " b.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins,b.graveLeaveEarly," + + " b.graveLeaveEarlyMins,b.absenteeism,b.signdays,b.signmins, "+ + " b.absenteeismMins ,(b.forgotCheck+"+forgotBeginWorkCheck_field+") forgotCheck "; + 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; + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+KQReportBiz.splitParamStr(subCompanyId)+") "; + for(String bean : subCompanyId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+KQReportBiz.splitParamStr(departmentId)+") "; + for(String bean : departmentId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+KQReportBiz.splitParamStr(resourceId)+") "; + for(String bean : resourceId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + 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<>'' "); + } + + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and a.status = ?"; + paramList = new ArrayList<>(); + paramList.add(status); + paramLists.add(paramList); + }else if (status.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + String orderBy = " order by a.subcompanyid1 asc, a.departmentid asc,a.dsporder asc, a.lastname asc , b.kqDate asc "; + String descOrderBy = " order by a.subcompanyid1 desc, a.departmentid desc,a.dsporder desc, a.lastname desc "; + sql = "select "+backFields + sqlFrom + sqlWhere+orderBy; + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径 + String fullPathMainKey = "show_full_path"; + String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); + + Map serialdata = new HashMap<>(); + boolean isneedcal = KQSettingsBiz.getKqformatAccurate(); + params.put("isneedcal",isneedcal?"1":"0"); + Map flowData = kqReportBiz.getDailyFlowData(params,user); + rs.executeQuery(sql, paramLists); + while (rs.next()) { + data = new ArrayList<>(); + String id = rs.getString("id"); + String kqdate = rs.getString("kqdate"); + String tmpkey = id+"|"+kqdate+"|"; +// Map signDetailInfo = this.getSignDetailInfo(id,kqdate); + + for (int fieldDataKeyIdx =0;fieldDataKeyIdx0){ +// fieldValue = Util.formatMultiLang(shiftManagementToolKit.getShiftOnOffWorkSections(serialid, user.getLanguage())); + + if(null != serialdata && serialdata.containsKey(serialid)){ + fieldValue = serialdata.get(serialid); + }else{ + String tmpserialname = Util.formatMultiLang(shiftManagementToolKit.getShiftOnOffWorkSections(serialid, user.getLanguage())); + fieldValue = tmpserialname; + serialdata.put(serialid,tmpserialname); + } + } + } else if(fieldName.equals("signin1")){ + fieldValue = Util.null2String(flowData.get(tmpkey+"signintime1")); + data.add(fieldValue); + fieldValue = Util.null2String(flowData.get(tmpkey+"signinstatus1")); + data.add(fieldValue); + continue; + } else if(fieldName.equals("signin2")){ + fieldValue = Util.null2String(flowData.get(tmpkey+"signintime2")); + data.add(fieldValue); + fieldValue = Util.null2String(flowData.get(tmpkey+"signinstatus2")); + data.add(fieldValue); + continue; + } else if(fieldName.equals("signin3")){ + fieldValue = Util.null2String(flowData.get(tmpkey+"signintime3")); + data.add(fieldValue); + fieldValue = Util.null2String(flowData.get(tmpkey+"signinstatus3")); + data.add(fieldValue); + continue; + } else if(fieldName.equals("signout1")){ + fieldValue = Util.null2String(flowData.get(tmpkey+"signouttime1")); + data.add(fieldValue); + fieldValue = Util.null2String(flowData.get(tmpkey+"signoutstatus1")); + data.add(fieldValue); + continue; + } else if(fieldName.equals("signout2")){ + fieldValue = Util.null2String(flowData.get(tmpkey+"signouttime2")); + data.add(fieldValue); + fieldValue = Util.null2String(flowData.get(tmpkey+"signoutstatus2")); + data.add(fieldValue); + continue; + } else if(fieldName.equals("signout3")){ + fieldValue = Util.null2String(flowData.get(tmpkey+"signouttime3")); + data.add(fieldValue); + fieldValue = Util.null2String(flowData.get(tmpkey+"signoutstatus3")); + data.add(fieldValue); + continue; + } else if(fieldName.equals("leave")){ + //请假 + List> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules(); + if (("1").equals(leavetype_is_on)) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + for (int i = allLeaveRules.size() - 1; i >= 0; i--) { + Map leaveRule = allLeaveRules.get(i); + String leaveId = Util.null2String(leaveRule.get("id")); + boolean flag = KQLeaveRulesBiz.filterSubLeaveRule(kqLeaveRulesComInfo, user, leaveId); + if (flag) { + allLeaveRules.remove(i); + } + } + } + Map leaveRule = null; + for(int i=0;allLeaveRules!=null&&i)allLeaveRules.get(i); + String flowType = Util.null2String("leaveType_"+leaveRule.get("id")); + fieldValue = Util.null2String(flowData.get(id+"|"+kqdate+"|"+flowType)); + String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id")); + String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + kqdate + "|" + flowLeaveBackType)), "0.0"); + String b_flowLeaveData = ""; + String flowLeaveData = ""; + try { + //以防止出现精度问题 + if (fieldValue.length() == 0) { + fieldValue = "0.0"; + } + if (leavebackData.length() == 0) { + leavebackData = "0.0"; + } + BigDecimal b_leaveData = new BigDecimal(fieldValue); + 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("ExportDailyExcelCmd:fieldValue" + fieldValue + ":leavebackData:" + leavebackData + ":" + e); + } + //考虑下冻结的数据 + if (b_flowLeaveData.length() > 0) { + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData); + } else { + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(fieldValue, 0.0) - Util.getDoubleValue(leavebackData, 0.0))); + } + fieldValue = flowLeaveData; + + data.add(fieldValue); + } + }else if(fieldName.equals("overtime")){ + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|workingDayOvertime_nonleave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_nonleave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|restDayOvertime_nonleave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_nonleave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|holidayOvertime_nonleave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_nonleave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|workingDayOvertime_4leave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_4leave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|restDayOvertime_4leave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_4leave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|holidayOvertime_4leave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_4leave")))); + + double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|workingDayOvertime_4leave"))); + workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave; + double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|restDayOvertime_4leave"))); + restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave; + double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|holidayOvertime_4leave"))); + holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave; + + double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|workingDayOvertime_nonleave"))); + workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave; + double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|restDayOvertime_nonleave"))); + restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave; + double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|holidayOvertime_nonleave"))); + holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave; + fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+ + workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave)); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("overtimeTotal")))); + continue; + }else if(fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){ + String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+kqdate+"|"+fieldName)),"0.0"); + String backType = fieldName+"_back"; + String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+kqdate+"|"+backType)),"0.0"); + String businessLeave = ""; + try{ + //以防止出现精度问题 + if(businessLeaveData.length() == 0){ + businessLeaveData = "0.0"; + } + if(businessLeavebackData.length() == 0){ + businessLeavebackData = "0.0"; + } + BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData); + BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData); + businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString(); + if(Util.getDoubleValue(businessLeave, -1) < 0){ + businessLeave = "0.0"; + } + }catch (Exception e){ + } + fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave); + }else if(fieldName.equals("kqdate")){ + fieldValue=kqdate+" "+com.engine.portal.util.DateUtil.getDayWeekOfDate1(DateUtil.parseToDate(kqdate)); + } else { + fieldValue = Util.null2String(rs.getString(fieldName)); + fieldValue = getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(fieldid)); + } + + if(!fieldName.equals("leave")) { + fieldValue = Util.formatMultiLang(fieldValue, "" + user.getLanguage()); + data.add(fieldValue); + } + } + dataList.add(data); + } + sheet.put("dataList", dataList); + sheet.put("constraintList",constraintList); + sheet.put("createFile", "1"); + lsSheet.add(sheet); + + workbook.put("sheet", lsSheet); + String fileName = SystemEnv.getHtmlLabelName(390352, user.getLanguage())+" "+fromDate+" "+toDate;; + workbook.put("fileName", fileName); + ExcelUtil ExcelUtil = new ExcelUtil(); + Map exportMap= ExcelUtil.export(workbook,request,response,false,true); + retmap.putAll(exportMap); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private Map getChildColumnsInfo(String parentid, User user){ + Map returnMap = new HashMap<>(); + List titleList = new ArrayList<>(); + Map title = null; + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"0"); + if(parentid.equals("leave")){ + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + if (("1").equals(leavetype_is_on)) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + for (int i = leaveRules.size() - 1; i >= 0; i--) { + Map leaveRule = leaveRules.get(i); + String leaveId = Util.null2String(leaveRule.get("id")); + boolean flag = kqLeaveRulesBiz.filterSubLeaveRule(kqLeaveRulesComInfo, user, leaveId); + if (flag) { + leaveRules.remove(i); + } + } + } + for(int i=0;leaveRules!=null&&i leaveRule = leaveRules.get(i); + String name = Util.formatMultiLang(Util.null2String(leaveRule.get("name")),""+user.getLanguage()); + String unitType = Util.null2String(leaveRule.get("unitType")); + title = new HashMap<>(); + title.put("title",name+"("+ + ((KQUnitBiz.isLeaveHour(unitType))?SystemEnv.getHtmlLabelName(391, user.getLanguage()):SystemEnv.getHtmlLabelName(1925, user.getLanguage()))+")"); + title.put("width",30*256); + titleList.add(title); + + } + }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()); + } + } + title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage())+ "(" + unitTypeName + ")"); + } + Map mapChildColumnInfo = getChildColumnsInfo(id, user); + int childWidth = 65; + List childColumns = (List)mapChildColumnInfo.get("childColumns"); + if(childColumns.size()>0) {//跨列width取子列的width + title.put("children", childColumns); + childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65); + } + title.put("width", childWidth+""); + titleList.add(title); + } + } else{ + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()){ + if(kqReportFieldComInfo.getParentid().equals(parentid)) { + if(!kqReportFieldComInfo.getReportType().equals("daily"))continue; + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())+ + (KQReportBiz.getUnitType(kqReportFieldComInfo, user).length()>0?"("+ KQReportBiz.getUnitType(kqReportFieldComInfo, user)+")":"")); + title.put("width",30*256); + titleList.add(title); + } + } + } + returnMap.put("childColumns",titleList); + return returnMap; + } + + public Map getSignDetailInfo(String resourceId, String kqDate){ + Map data = new HashMap<>(); + Map signStatusInfo = null; + RecordSet rs = new RecordSet(); + String sql = ""; + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + try{ + sql = " select kqdate,resourceid,serialid,serialnumber,workbegindate,workbegintime, " + + " workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" + + " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," + + " leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid \n" + + " from kq_format_detail b \n" + + " where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' \n" + + " order by serialnumber \n"; + rs.execute(sql); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("resourceid")); + String kqdate = Util.null2String(rs.getString("kqdate")); + String serialid = Util.null2String(rs.getString("serialid")); + int serialnumber = rs.getInt("serialnumber")+1; + String workbegindate = Util.null2String(rs.getString("workbegindate")).trim(); + String workbegintime = Util.null2String(rs.getString("workbegintime")).trim(); + String workenddate = Util.null2String(rs.getString("workenddate")).trim(); + String workendtime = Util.null2String(rs.getString("workendtime")).trim(); + int workMins = rs.getInt("workMins"); + String signintime = Util.null2String(rs.getString("signintime")).trim(); + String signouttime = Util.null2String(rs.getString("signouttime")).trim(); + int attendanceMins = rs.getInt("attendanceMins"); + String beLateMins = Util.null2String(rs.getString("beLateMins")).trim(); + String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")).trim(); + String leaveEarlyMins= Util.null2String(rs.getString("leaveEarlyMins")).trim(); + String graveLeaveEarlyMins= Util.null2String(rs.getString("graveLeaveEarlyMins")).trim(); + String absenteeismMins= Util.null2String(rs.getString("absenteeismMins")).trim(); + String forgotCheckMins = Util.null2String(rs.getString("forgotcheckMins")).trim(); + String forgotBeginWorkCheckMins = Util.null2String(rs.getString("forgotBeginWorkCheckMins")).trim(); + String signinid = Util.null2String(rs.getString("signinid")).trim(); + String signoutid = Util.null2String(rs.getString("signoutid")).trim(); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = Util.null2String(rs.getString("leaveInfo")); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + + + if(serialid.length()>0){ + if (workbegintime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("workdate",workbegindate); + signStatusInfo.put("worktime",workbegintime); + signStatusInfo.put("beLateMins",beLateMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("graveBeLateMins",graveBeLateMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + + data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + } + + if (workendtime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("workdate",workenddate); + signStatusInfo.put("worktime",kqTimesArrayComInfo.turn48to24Time(workendtime)); + signStatusInfo.put("leaveEarlyMins",leaveEarlyMins); + signStatusInfo.put("graveLeaveEarlyMins",graveLeaveEarlyMins); + signStatusInfo.put("forgotCheckMins",forgotCheckMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + + data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else{ + if(workMins>0){ + //弹性工时打卡时间取自签到签退数据 + } + signStatusInfo = new HashMap(); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + + if(signinid.length() > 0){ + data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + if(signoutid.length() > 0){ + data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else{ + data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + } + } + } + }catch (Exception e){ + writeLog(e); + } + return data; + } + + private String getFieldValueByUnitType(String fieldValue,String unittype){ + if (Util.null2String(unittype).length() > 0) { + if (fieldValue.length() == 0) { + fieldValue = "0"; + } else { + if (unittype.equals("2")) { + fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0))); + } + } + } + return fieldValue; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/report/ExportExcelCmd.java b/src/com/engine/kq/cmd/report/ExportExcelCmd.java new file mode 100644 index 0000000..c18a7ac --- /dev/null +++ b/src/com/engine/kq/cmd/report/ExportExcelCmd.java @@ -0,0 +1,729 @@ +package com.engine.kq.cmd.report; + +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.ExcelUtil; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.util.UtilKQ; +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 com.google.common.collect.Lists; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.*; + +public class ExportExcelCmd extends AbstractCommonCommand> { + + private HttpServletRequest request; + private HttpServletResponse response; + private List lsFieldDataKey; + + private boolean isKqReportHalfOpen = "1".equals(new KQSettingsComInfo().getMain_val("kq_report_half")); + + public ExportExcelCmd(Map params, HttpServletRequest request, HttpServletResponse response, User user) { + this.user = user; + this.params = params; + this.request = request; + this.response = response; + this.lsFieldDataKey = new ArrayList<>(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"0"); + + KQReportBiz kqReportBiz = new KQReportBiz(); + new KQReportBiz().insertKqReportExportLog(params, user); + 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 status = Util.null2String(jsonObj.get("status")); + 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")); + List showColumns = Util.splitString2List(Util.null2String(jsonObj.get("showColumns")), ","); + showColumns.add("lastname"); + showColumns.removeIf(showColumn->showColumn.trim().equals("")); + + List tmpShowColumns = new ArrayList<>(); + for(String showColumn:showColumns){ + tmpShowColumns.add(showColumn); + String cascadekey = ""; + if(showColumn.equals("beLate")){ + cascadekey = "beLateMins"; + }else if(showColumn.equals("leaveEearly")){ + cascadekey = "leaveEarlyMins"; + }else if(showColumn.equals("graveBeLate")){ + cascadekey = "graveBeLateMins"; + }else if(showColumn.equals("graveLeaveEarly")){ + cascadekey = "graveLeaveEarlyMins"; + }else if(showColumn.equals("absenteeism")){ + cascadekey = "absenteeismMins"; + }else if(showColumn.equals("overtime")){ + tmpShowColumns.add("overtime_4leave"); + tmpShowColumns.add("overtime_nonleave"); + tmpShowColumns.add("workingDayOvertime_nonleave"); + tmpShowColumns.add("workingDayOvertime_4leave"); + tmpShowColumns.add("restDayOvertime_nonleave"); + tmpShowColumns.add("restDayOvertime_4leave"); + tmpShowColumns.add("holidayOvertime_4leave"); + tmpShowColumns.add("holidayOvertime_nonleave"); + } + if(cascadekey.length()>0){ + tmpShowColumns.add(cascadekey); + } + } + showColumns = tmpShowColumns; + + String rightSql = new KQReportBiz().getReportRight("1", "" + user.getUID(), "a"); + + LinkedHashMap workbook = new LinkedHashMap<>(); + List lsSheet = new ArrayList<>(); + Map sheet = null; + List titleList = new ArrayList<>(); + Map title = null; + List> dataList = new ArrayList<>(); + List data = null; + List> constraintList = null; + + sheet = new HashMap<>(); + sheet.put("sheetName", SystemEnv.getHtmlLabelName(390351, user.getLanguage())); + sheet.put("sheetTitle", SystemEnv.getHtmlLabelName(390351, user.getLanguage())); + boolean isEnd = false; + Calendar cal = DateUtil.getCalendar(); + + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + 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 (!showColumns.contains(kqReportFieldComInfo.getFieldname())&&!showColumns.contains(kqReportFieldComInfo.getParentid())) continue; + if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){ + continue; + } + title = new HashMap<>(); + String unitType = KQReportBiz.getUnitType(kqReportFieldComInfo, user); + if(unitType.length()>0){ + title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())+ "(" + unitType + ")"); + }else{ + title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())); + } + title.put("width", 30 * 256); + this.lsFieldDataKey.add(kqReportFieldComInfo.getFieldname()); + mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(), user); + childColumns = (List) mapChildColumnInfo.get("childColumns"); + if (childColumns.size() > 0) {//跨列width取子列的width + title.put("children", childColumns); + title.put("colSpan", childColumns.size()); + } else { + title.put("rowSpan", 3); + } + titleList.add(title); + + titleList.addAll(this.getCascadeKeyColumnsInfo(kqReportFieldComInfo.getCascadekey(),user)); + } + + String today = DateUtil.getCurrentDate(); +// if (DateUtil.compDate(today, toDate) > 0) {//结束如期不大于今天 +// toDate = today; +// } + + if(showColumns.contains("kqCalendar")) { + childColumns = new ArrayList<>(); + for (String date = fromDate; !isEnd; ) { + if (date.equals(toDate)) isEnd = true; + title = new HashMap<>(); + title.put("title", UtilKQ.getWeekDayShort(DateUtil.getWeek(date)-1,user.getLanguage()) +"\r\n"+ DateUtil.geDayOfMonth(date)); + title.put("width", 30 * 256); + childColumns.add(title); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + + title = new HashMap(); + title.put("title", SystemEnv.getHtmlLabelName(386476, user.getLanguage())); + if (childColumns.size() > 0) {//跨列width取子列的width + title.put("children", childColumns); + title.put("colSpan", childColumns.size()); + } + titleList.add(title); + } + sheet.put("titleList", titleList); + + // 没有权限的人最大只支持查询本季 + Map getRealDate = new KQReportBiz().realDate(fromDate, toDate, user, "1"); + fromDate = getRealDate.get("fromDate"); + toDate = getRealDate.get("toDate"); + if("-1".equals(fromDate) || "-1".equals(toDate)) { + retmap.put("status", "1"); + return retmap; + } + + List paramLists = new ArrayList<>(); + List paramList = null; + 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 a.subcompanyid1 in("+KQReportBiz.splitParamStr(subCompanyId)+") "; + for(String bean : subCompanyId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + if (departmentId.length() > 0) { + sqlWhere +=" and a.departmentid in("+KQReportBiz.splitParamStr(departmentId)+") "; + for(String bean : departmentId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + if (resourceId.length() > 0) { + sqlWhere +=" and a.id in("+KQReportBiz.splitParamStr(resourceId)+") "; + for(String bean : resourceId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + 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<>'' "); + } + + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and a.status = ?"; + paramList = new ArrayList<>(); + paramList.add(status); + paramLists.add(paramList); + }else if (status.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + String orderBy = " order by a.subcompanyid1 asc, a.departmentid asc, a.dsporder asc, a.lastname asc "; + String descOrderBy = " order by a.subcompanyid1 desc, a.departmentid desc, a.dsporder desc, a.lastname desc "; + sql = "select " + backFields + sqlFrom + sqlWhere + groupBy + orderBy; + + //System.out.println("start" + DateUtil.getFullDate()); + + + String show_card_source = Util.null2String(kqSettingsComInfo.getMain_val("show_card_source"),"0");//是否显示打卡数据,以及打卡数据来源 + params.put("show_card_source",show_card_source); + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + params.put("uintType",uintType); + params.put("hoursToDay",hoursToDay); + Map flowData = new KQReportBiz().getFlowData(params, user); + //System.out.println("end" + DateUtil.getFullDate()); + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径 + String fullPathMainKey = "show_full_path"; + String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); + + rs.executeQuery(sql, paramLists); + int calIndex = -1; + while (rs.next()) { + data = new ArrayList<>(); + String id = rs.getString("id"); + for (int fieldDataKeyIdx =0;fieldDataKeyIdx 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> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + if (("1").equals(leavetype_is_on)) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + for (int i = allLeaveRules.size() - 1; i >= 0; i--) { + Map leaveRule = allLeaveRules.get(i); + String leaveId = Util.null2String(leaveRule.get("id")); + boolean flag = kqLeaveRulesBiz.filterSubLeaveRule(kqLeaveRulesComInfo, user, leaveId); + if (flag) { + allLeaveRules.remove(i); + } + } + } + Map leaveRule = null; + for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) { + leaveRule = 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.add(flowLeaveData); + } + continue; + }else if(fieldName.equals("overtime")){ + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|workingDayOvertime_nonleave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_nonleave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|restDayOvertime_nonleave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_nonleave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|holidayOvertime_nonleave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_nonleave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|workingDayOvertime_4leave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_4leave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|restDayOvertime_4leave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_4leave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|holidayOvertime_4leave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_4leave")))); + + double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_4leave"))); + workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave; + double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_4leave"))); + restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave; + double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_4leave"))); + holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave; + + double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleave"))); + workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave; + double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleave"))); + restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave; + double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleave"))); + holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave; + fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+ + workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave)); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("overtimeTotal")))); + continue; + }else if(fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){ + String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+fieldName)),"0.0"); + String backType = fieldName+"_back"; + String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+backType)),"0.0"); + String businessLeave = ""; + try{ + //以防止出现精度问题 + if(businessLeaveData.length() == 0){ + businessLeaveData = "0.0"; + } + if(businessLeavebackData.length() == 0){ + businessLeavebackData = "0.0"; + } + BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData); + BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData); + businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString(); + if(Util.getDoubleValue(businessLeave, -1) < 0){ + businessLeave = "0.0"; + } + }catch (Exception e){ + } + fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave); + } else if(Util.null2String(kqReportFieldComInfo.getCascadekey(fieldid)).length()>0){ + fieldValue = Util.formatMultiLang(Util.null2String(rs.getString(fieldName)),""+user.getLanguage()); + data.add(fieldValue); + + List lsCascadekey = Util.splitString2List(kqReportFieldComInfo.getCascadekey(fieldid),","); + for(int i=0;i0){ + fieldid = KQReportFieldComInfo.field2Id.get(lsCascadekey.get(i)); + fieldValue = getFieldValueByUnitType(rs.getString(lsCascadekey.get(i)),kqReportFieldComInfo.getUnittype(fieldid)); + }else{ + fieldValue = "0"; + } + data.add(fieldValue); + } + continue; + }else { + fieldValue = Util.formatMultiLang(Util.null2String(rs.getString(fieldName)),""+user.getLanguage()); + fieldValue = getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(fieldid)); + } + fieldValue = Util.formatMultiLang(fieldValue,""+user.getLanguage()); + data.add(fieldValue); + } + + List amData = Lists.newArrayList(); + List pmData = Lists.newArrayList(); + if(isKqReportHalfOpen) { + amData.addAll(data); + pmData.addAll(data); + calIndex = data.size(); + } + + if(showColumns.contains("kqCalendar")) { +// Map detialDatas = kqReportBiz.getDetialDatas(id, fromDate, toDate, user,flowData,true); + Map detialDatas = kqReportBiz.getDetialDatas(id, fromDate, toDate, user,flowData,true,uintType,show_card_source); + String user_endDate = Util.null2String(resourceComInfo.getEndDate(id)); + String user_status = Util.null2String(resourceComInfo.getStatus(id)); + String begindate = Util.null2String(resourceComInfo.getCreatedate(id)).trim(); + String companyStartDate = Util.null2String(resourceComInfo.getCompanyStartDate(id)).trim(); + if(companyStartDate.length()!=10){ + companyStartDate = ""; + } + if(companyStartDate.length()>0 && companyStartDate.indexOf("-")>0){ + begindate=companyStartDate; + } + isEnd = false; + for (String date = fromDate; !isEnd; ) { + if (date.equals(toDate)) isEnd = true; + if(DateUtil.compDate(today, date)>0){ + if(isKqReportHalfOpen) { + amData.add(""); + pmData.add(""); + } else { + data.add(""); + } + }else{ + if(!(user_status.equals("0")||user_status.equals("1")||user_status.equals("2")||user_status.equals("3"))){ + //其他状态 + if(user_endDate.length()>0 && date.compareTo(user_endDate)>0){//人员合同结束日期之后 + if(isKqReportHalfOpen) { + amData.add(""); + pmData.add(""); + } else { + data.add(""); + } + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + continue; + } + } + if(begindate.length()>0 && date.compareTo(begindate)<0 ){//人员入职日期前无需计算考勤,如果没有入职日期,已创建日期为准 + if(isKqReportHalfOpen) { + amData.add(""); + pmData.add(""); + } else { + data.add(""); + } + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + continue; + } + if (detialDatas.get(id + "|" + date) != null) { + if(isKqReportHalfOpen) { + amData.add(((Map) detialDatas.get(id + "|" + date)).get("textAM")); + pmData.add(((Map) detialDatas.get(id + "|" + date)).get("textPM")); + } else { + data.add(((Map) detialDatas.get(id + "|" + date)).get("text")); + } + } else { + if(isKqReportHalfOpen) { + amData.add(SystemEnv.getHtmlLabelName(26593, user.getLanguage())); + pmData.add(SystemEnv.getHtmlLabelName(26593, user.getLanguage())); + } else { + data.add(SystemEnv.getHtmlLabelName(26593, user.getLanguage())); + } + } + } + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + } + if(isKqReportHalfOpen) { + dataList.add(amData); + dataList.add(pmData); + } else { + dataList.add(data); + } + } + sheet.put("dataList", dataList); + if(isKqReportHalfOpen) { + sheet.put("calIndex", calIndex); + } + sheet.put("constraintList", constraintList); + sheet.put("createFile", "1"); + lsSheet.add(sheet); + + workbook.put("sheet", lsSheet); + String fileName = SystemEnv.getHtmlLabelName(390351, user.getLanguage())+" "+fromDate+" "+toDate; + workbook.put("fileName", fileName); + ExcelUtil ExcelUtil = new ExcelUtil(); + Map exportMap = ExcelUtil.export(workbook, request, response,true); + retmap.putAll(exportMap); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private Map getChildColumnsInfo(String parentid, User user) { + Map returnMap = new HashMap<>(); + List titleList = new ArrayList<>(); + Map title = null; + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"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 < serialIds.size(); i++) { + title = new HashMap<>(); + title.put("title", Util.formatMultiLang(kqShiftManagementComInfo.getSerial(serialIds.get(i)),""+user.getLanguage())); + title.put("width", 30 * 256); + titleList.add(title); + } + } else if (parentid.equals("leave")) { + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + if (("1").equals(leavetype_is_on)) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + for (int i = leaveRules.size() - 1; i >= 0; i--) { + Map leaveRule = leaveRules.get(i); + String leaveId = Util.null2String(leaveRule.get("id")); + boolean flag = kqLeaveRulesBiz.filterSubLeaveRule(kqLeaveRulesComInfo, user, leaveId); + if (flag) { + leaveRules.remove(i); + } + } + } + for (int i = 0; leaveRules != null && i < leaveRules.size(); i++) { + Map leaveRule = leaveRules.get(i); + String name = Util.formatMultiLang(Util.null2String(leaveRule.get("name")),""+user.getLanguage()); + String unitType = Util.null2String(leaveRule.get("unitType")); + String unitName = (KQUnitBiz.isLeaveHour(unitType)) ? SystemEnv.getHtmlLabelName(391, user.getLanguage()) : SystemEnv.getHtmlLabelName(1925, user.getLanguage()); + title = new HashMap<>(); + title.put("title", name + "(" + unitName + ")"); + title.put("width", 30 * 256); + titleList.add(title); + } + }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()); + } + } + title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage())+ "(" + unitTypeName + ")"); + } + + Map mapChildColumnInfo = getChildColumnsInfo(id, user); + int childWidth = 65; + List childColumns = (List)mapChildColumnInfo.get("childColumns"); + if(childColumns.size()>0) {//跨列width取子列的width + title.put("children", childColumns); + childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65); + } + title.put("width", childWidth+""); + titleList.add(title); + } + } else { + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()) { + if (kqReportFieldComInfo.getParentid().equals(parentid)) { + if(!kqReportFieldComInfo.getReportType().equals("month"))continue; + title = new HashMap<>(); + title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()) + "(" + KQReportBiz.getUnitType(kqReportFieldComInfo, user) + ")"); + title.put("width", 30 * 256); + titleList.add(title); + } + } + } + returnMap.put("childColumns", titleList); + return returnMap; + } + + private List getCascadeKeyColumnsInfo(String cascadeKey, User user){ + List titleList = new ArrayList<>(); + Map title = null; + if(Util.null2String(cascadeKey).length()==0){ + return titleList; + } + List lsCascadeKey = Util.splitString2List(cascadeKey,","); + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + for(int i=0;i(); + title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()) + "(" + KQReportBiz.getUnitType(kqReportFieldComInfo, user) + ")"); + title.put("width", 30 * 256); + + titleList.add(title); + } + } + } + return titleList; + } + + private String getFieldValueByUnitType(String fieldValue,String unittype){ + if (Util.null2String(unittype).length() > 0) { + if (fieldValue.length() == 0) { + fieldValue = "0"; + } else { + if (unittype.equals("2")) { + fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0))); + } + } + } + return fieldValue; + } + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/report/FormatReportCmd.java b/src/com/engine/kq/cmd/report/FormatReportCmd.java new file mode 100644 index 0000000..e1ec047 --- /dev/null +++ b/src/com/engine/kq/cmd/report/FormatReportCmd.java @@ -0,0 +1,187 @@ +package com.engine.kq.cmd.report; + +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.KQFormatBiz; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.util.KQLockAttendaUtil; +import weaver.common.DateUtil; +import weaver.conn.BatchRecordSet; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class FormatReportCmd extends AbstractCommonCommand> { + + public FormatReportCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + BatchRecordSet bRs = new BatchRecordSet(); + RecordSet rs = new RecordSet(); + String sql = ""; + String delSql = ""; + try{ + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a"); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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 today = DateUtil.getCurrentDate(); + if(DateUtil.compDate(today, fromDate)>0){//开始如期不大于今天 + fromDate = today; + } + if(DateUtil.compDate(today, toDate)>0){//结束如期不大于今天 + toDate = today; + } + List lsDate = new ArrayList<>(); + Calendar cal = DateUtil.getCalendar(); + + if (DateUtil.timeInterval(toDate, fromDate) > 0) + { + retmap.put("status", "-1"); + retmap.put("message", ""+ SystemEnv.getHtmlLabelName(10005334,weaver.general.ThreadVarLanguage.getLang())+""); + writeLog("考勤格式开始时间不能大于结束时间 fromDate==" + fromDate + "toDate==" + toDate); + return retmap; + } + +// String kqformat_error = Util.null2String(Util_DataMap.getVal("kqformat_error")); +// if(kqformat_error.length()>0) { +// retmap.put("status", "-1"); +// retmap.put("message", SystemEnv.getHtmlLabelNames(kqformat_error, user.getLanguage())); +// Util_DataMap.clearVal("kqformat_error"); +// return retmap; +// } + + boolean isEnd = false; + for(String date=fromDate; !isEnd;) { + if(date.equals(toDate)) isEnd = true; + lsDate.add(date); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + + List paramLists = new ArrayList<>(); + List paramList = null; + 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")); + + + List> paramInsert = new ArrayList<>(); + List params = null; + + Map paramsObj = new HashMap(); + paramsObj.put("isNoAccount",isNoAccount); + sql = " select distinct a.id from hrmresource a , ("+new KQGroupBiz().getGroupMemberSql(paramsObj)+") b where a.id=b.resourceid "+rightSql; + String sqlWhere = " "; + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+KQReportBiz.splitParamStr(subCompanyId)+") "; + for(String bean : subCompanyId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+KQReportBiz.splitParamStr(departmentId)+") "; + for(String bean : departmentId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+KQReportBiz.splitParamStr(resourceId)+") "; + for(String bean : resourceId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + 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<>'' "); + } + +// if(rs.getDBType().equals("sqlserver")||rs.getDBType().equals("mysql")){ +// delSql = "delete t1 from kq_format_detail t1 inner join hrmresource a on t1.resourceid = a.id where t1.kqdate>=? and t1.kqdate<=? "+sqlWhere; +// rs.executeUpdate(delSql,fromDate,toDate); +// delSql = "delete t1 from kq_format_total t1 inner join hrmresource a on t1.resourceid = a.id where t1.kqdate>=? and t1.kqdate<=? "+sqlWhere; +// rs.executeUpdate(delSql,fromDate,toDate); +// }else{ +// delSql = "delete kq_format_detail t1 where exists ( select 1 from hrmresource a where t1.resourceid = a.id "+sqlWhere+") and t1.kqdate>=? and t1.kqdate<=? "; +// rs.executeUpdate(delSql,fromDate,toDate); +// delSql = "delete kq_format_total t1 where exists ( select 1 from hrmresource a where t1.resourceid = a.id "+sqlWhere+") and t1.kqdate>=? and t1.kqdate<=? "; +// rs.executeUpdate(delSql,fromDate,toDate); +// } + String LOCK_DEGREE = Util.null2String(Prop.getPropValue("kqLockAttenda", "LOCK_DEGREE")); + sql = sql +sqlWhere; + rs.executeQuery(sql, paramLists); + while(rs.next()){ + String resourceid = rs.getString("id"); + for(int i=0;i(); + params.add(resourceid); + params.add(lsDate.get(i)); + if(LOCK_DEGREE.equals("1")&&new KQLockAttendaUtil().checkLockStatus(resourceid, lsDate.get(i))){ + retmap.put("status", "-1"); + retmap.put("message", ""+ SystemEnv.getHtmlLabelName(547738,weaver.general.ThreadVarLanguage.getLang())+""); + return retmap; + } + paramInsert.add(params); + } + } + + new KQFormatBiz().format(paramInsert, 11); + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(30700, user.getLanguage())); + return retmap; + }catch (Exception e){ + writeLog(e); + } + return retmap; + } + + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java new file mode 100644 index 0000000..c624eaa --- /dev/null +++ b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java @@ -0,0 +1,728 @@ +package com.engine.kq.cmd.report; + +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.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.util.PageUidFactory; +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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetKQDailyReportCmd extends AbstractCommonCommand> { + + private KQLog kqLog = new KQLog(); + + public GetKQDailyReportCmd(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("KQDailyReport"); + + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + KQWorkTime kqWorkTime = new KQWorkTime(); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + KQReportBiz kqReportBiz = new KQReportBiz(); + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"0"); + + String rightSql = new KQReportBiz().getReportRight("2",""+user.getUID(),"a"); + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + 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 status = Util.null2String(jsonObj.get("status")); + 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")); + if(typeselect.length()==0)typeselect = "3"; + 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; + + 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; + boolean isDaily = kqReportFieldComInfo.getReportType().equals("daily"); + if(!kqReportFieldComInfo.getReportType().equals("all") && !isDaily)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("key", kqReportFieldComInfo.getFieldname()); + 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())); + } + if(kqReportFieldComInfo.getReportType1().equals("daily")){ + column.put("isdaily", "1"); + } + column.put("showDetial",kqReportFieldComInfo.getShowDetial()); + columns.add(column); + } + +// String today = DateUtil.getCurrentDate(); +// if(DateUtil.compDate(today, toDate)>0){//结束如期不大于今天 +// toDate = today; +// if(DateUtil.compDate(today, fromDate)>0){ +// fromDate = today; +// } +// } + + // 没有权限的人最大只支持查询本季 + Map getRealDate = new KQReportBiz().realDate(fromDate, toDate, user, "2"); + fromDate = getRealDate.get("fromDate"); + toDate = getRealDate.get("toDate"); + + String forgotBeginWorkCheck_field = " b.forgotbeginworkcheck "; + List paramLists = new ArrayList<>(); + List paramList = null; + + if(rs.getDBType().equalsIgnoreCase("oracle")&&!Util.null2String(rs.getOrgindbtype()).equals("dm")&&!Util.null2String(rs.getOrgindbtype()).equals("st")&&!Util.null2String(rs.getOrgindbtype()).equals("jc")) { + forgotBeginWorkCheck_field = " nvl(b.forgotBeginWorkCheck,0) "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + forgotBeginWorkCheck_field = " ifnull(b.forgotBeginWorkCheck,0) "; + }else { + forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) "; + } + + String backFields = " a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," + + " b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,b.attendanceMins," + + " b.beLate,b.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins," + + " b.signdays,b.signmins, "+ + " b.graveLeaveEarly,b.graveLeaveEarlyMins,b.absenteeism ,b.absenteeismMins ,(b.forgotCheck+"+forgotBeginWorkCheck_field+") forgotCheck "; + 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; + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+KQReportBiz.splitParamStr(subCompanyId)+") "; + for(String bean : subCompanyId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+KQReportBiz.splitParamStr(departmentId)+") "; + for(String bean : departmentId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+KQReportBiz.splitParamStr(resourceId)+") "; + for(String bean : resourceId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + 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<>'' "); + } + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and a.status = ?"; + paramList = new ArrayList<>(); + paramList.add(status); + paramLists.add(paramList); + }else if (status.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + if("-1".equals(fromDate) || "-1".equals(toDate)) { + sqlWhere += " and 1=2 "; + } + + sql = " select count(*) as c from ( select 1 as c "+sqlFrom+sqlWhere+") t"; + rs.executeQuery(sql, paramLists); + 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 a.subcompanyid1 asc, a.departmentid asc, a.dsporder asc, a.lastname asc, b.kqdate asc "; + String descOrderBy = " order by a.subcompanyid1 desc, a.departmentid desc,a.dsporder desc, a.lastname desc, b.kqdate desc "; + sql = backFields + sqlFrom + sqlWhere + orderBy; + + if (pageIndex > 0 && pageSize > 0) { + if (rs.getDBType().equals("oracle")) { + sql = " select " + sql; + 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 " + sql; + sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize; + } + else if (rs.getDBType().equals("postgresql")) { + sql = " select " + sql; + sql = "select t1.* from (" + sql + ") t1 limit " + pageSize+ " offset " + ((pageIndex - 1) * pageSize); + } + else { + orderBy = " order by subcompanyid asc, departmentid asc, dsporder asc, lastname asc, kqdate asc "; + descOrderBy = " order by subcompanyid desc, departmentid desc, dsporder desc, lastname desc, kqdate 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+" ) tbltemp1 " + descOrderBy + ") tbltemp2 " + orderBy; + } else { + sql = " select top " + pageSize + sql; + } + } + } else { + sql = " select " + sql; + } + boolean isneedcal = KQSettingsBiz.getKqformatAccurate(); + params.put("isneedcal",isneedcal?"1":"0"); + Map flowData = kqReportBiz.getDailyFlowData(params,user); + Map serialdata = new HashMap<>(); + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径 + String fullPathMainKey = "show_full_path"; + + String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); + + rs.executeQuery(sql, paramLists); + while (rs.next()) { + String id = rs.getString("id"); + String kqdate = rs.getString("kqdate"); + WorkTimeEntity workTime = kqWorkTime.getWorkTime(id, kqdate); + data = new HashMap<>(); + kqReportFieldComInfo.setTofirstRow(); + while (kqReportFieldComInfo.next()) { + if (!Util.null2String(kqReportFieldComInfo.getIsdataColumn()).equals("1")) continue; + if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("daily")) + continue; + String fieldName = kqReportFieldComInfo.getFieldname(); + String fieldValue = ""; + if (fieldName.equals("subcompany")) { + String fieldValueID = rs.getString("subcompanyid"); + fieldValue = "1".equals(isShowFullPath) ? + SubCompanyComInfo.getSubcompanyRealPath(fieldValueID, "/", "0") : + subCompanyComInfo.getSubCompanyname(fieldValueID); + + //fieldValue = subCompanyComInfo.getSubCompanyname(fieldValueID); + + if (fieldValue.length() == 0) { + fieldValueID = resourceComInfo.getSubCompanyID(id); + + fieldValue = "1".equals(isShowFullPath) ? + SubCompanyComInfo.getSubcompanyRealPath(fieldValueID, "/", "0") : + subCompanyComInfo.getSubCompanyname(fieldValueID); + + // fieldValue = subCompanyComInfo.getSubCompanyname(fieldValueID); + } + data.put(fieldName + "Id", fieldValueID); + data.put(fieldName, fieldValue); + } else if (fieldName.equals("department")) { + String fieldValueID = rs.getString("departmentid"); + fieldValue = "1".equals(isShowFullPath) ? + departmentComInfo.getDepartmentRealPath(fieldValueID, "/", "0") : + departmentComInfo.getDepartmentname(fieldValueID); + //fieldValue = departmentComInfo.getDepartmentname(fieldValueID); + + if (fieldValue.length() == 0) { + fieldValueID = resourceComInfo.getDepartmentID(id); + + fieldValue = "1".equals(isShowFullPath) ? + departmentComInfo.getDepartmentRealPath(fieldValueID, "/", "0") : + departmentComInfo.getDepartmentname(fieldValueID); + + // fieldValue = departmentComInfo.getDepartmentname(fieldValueID); + } + data.put(fieldName + "Id", fieldValueID); + data.put(fieldName, fieldValue); + } else if (fieldName.equals("jobtitle")) { + String fieldValueID = rs.getString("jobtitle"); + fieldValue = jobTitlesComInfo.getJobTitlesname(rs.getString("jobtitle")); + if (fieldValue.length() == 0) { + fieldValueID = resourceComInfo.getJobTitle(id); + fieldValue = jobTitlesComInfo.getJobTitlesname(fieldValueID); + } + data.put(fieldName + "Id", fieldValueID); + data.put(fieldName, fieldValue); + } else if (kqReportFieldComInfo.getParentid().equals("overtime") || kqReportFieldComInfo.getParentid().equals("overtime_nonleave") + || kqReportFieldComInfo.getParentid().equals("overtime_4leave") || fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")) { + if (fieldName.equals("overtimeTotal")) { + double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_4leave"))); + workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave; + double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_4leave"))); + restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave; + double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_4leave"))); + holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave; + + double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_nonleave"))); + workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave; + double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_nonleave"))); + restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave; + double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_nonleave"))); + holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave; + + fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave + + workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave)); + } else { + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|" + kqdate + "|" + fieldName))); + } + data.put(fieldName, fieldValue); + } else if (fieldName.equals("serialid")) { + fieldValue = Util.null2String(rs.getString(fieldName)); + if (fieldValue.length()>0) {//弹性工作制没有班次 +// data.put("serialid", shiftManagementToolKit.getShiftOnOffWorkSections(fieldValue, user.getLanguage())); + + if(null != serialdata && serialdata.containsKey(fieldValue)){ + data.put("serialid", serialdata.get(fieldValue)); + }else{ + String tmpserialname = shiftManagementToolKit.getShiftOnOffWorkSections(fieldValue, user.getLanguage()); + serialdata.put(fieldValue,tmpserialname); + data.put("serialid", tmpserialname); + } + } + }else { + fieldValue = Util.null2String(rs.getString(fieldName)); + if (kqReportFieldComInfo.getUnittype().equals("2") && fieldValue.length() > 0) { + fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0))); + } + data.put(fieldName, fieldValue); + } + } + data.putAll(this.getSignDetailInfo(id, kqdate)); + + //请假 + List> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules(); + if (("1").equals(leavetype_is_on)) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + for (int i = allLeaveRules.size() - 1; i >= 0; i--) { + Map leaveRule = allLeaveRules.get(i); + String leaveId = Util.null2String(leaveRule.get("id")); + boolean flag = KQLeaveRulesBiz.filterSubLeaveRule(kqLeaveRulesComInfo, user, leaveId); + if (flag) { + allLeaveRules.remove(i); + } + } + } + Map leaveRule = null; + for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) { + leaveRule = (Map) allLeaveRules.get(i); + String flowType = Util.null2String("leaveType_" + leaveRule.get("id")); + String leaveData = Util.null2String(flowData.get(id + "|" + kqdate + "|" + flowType)); + String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id")); + String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + kqdate + "|" + 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) { + kqLog.info("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); + } + + data.put("resourceId", id); + data.put("kqdate", kqdate); + 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 String getUnitType(String unitType, User user){ + String unitTypeName = ""; + if(Util.null2String(unitType).length()>0){ + 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()); + } + } + return unitTypeName; + } + + private Map getChildColumnsInfo(String parentid, User user){ + Map returnMap = new HashMap<>(); + List lsChildColumns = new ArrayList<>(); + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"0"); + Map column = null; + int sumChildColumnWidth = 0; + if(parentid.equals("leave")){ + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + if (("1").equals(leavetype_is_on)) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + for (int i = leaveRules.size() - 1; i >= 0; i--) { + Map leaveRule = leaveRules.get(i); + String leaveId = Util.null2String(leaveRule.get("id")); + boolean flag = kqLeaveRulesBiz.filterSubLeaveRule(kqLeaveRulesComInfo, user, leaveId); + if (flag) { + leaveRules.remove(i); + } + } + } + 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("daily"))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", 2); + column.put("colSpan", 1); + column.put("isdaily", kqReportFieldComInfo.getReportType1().equals("daily")?"1":"0"); + sumChildColumnWidth+=Util.getIntValue(kqReportFieldComInfo.getWidth()); + lsChildColumns.add(column); + } + } + } + returnMap.put("childColumns",lsChildColumns); + returnMap.put("sumChildColumnWidth",sumChildColumnWidth); + return returnMap; + } + + public Map getSignDetailInfo(String resourceId, String kqDate){ + Map data = new HashMap<>(); + Map signStatusInfo = null; + RecordSet rs = new RecordSet(); + String sql = ""; + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + try{ + sql = " select kqdate,resourceid,day_type,serialid,serialnumber,workbegindate,workbegintime, " + + " workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" + + " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," + + " leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid,flowinfo,on_absenteeismmins,off_absenteeismmins \n" + + " from kq_format_detail b \n" + + " where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' \n" + + " order by serialnumber \n"; + rs.execute(sql); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("resourceid")); + String kqdate = Util.null2String(rs.getString("kqdate")); + String serialid = Util.null2String(rs.getString("serialid")); + String dayType = Util.null2s(rs.getString("day_type"),""); + int workMins = rs.getInt("workMins"); + boolean isNonWork = false; + if(serialid.length()==0){ + isNonWork = true; + } + if(dayType.length() > 0){ + if("holiday".equals(dayType) || "playday".equals(dayType)){ + isNonWork = true; + } + }else{ + if(workMins<=0){ + isNonWork = true; + }else{ + if(serialid.length() > 0){ + String isRest = Util.null2s(kqShiftManagementComInfo.getIsRest(serialid),""); + if("1".equals(isRest)){ + isNonWork = true; + } + } + } + } + int serialnumber = rs.getInt("serialnumber")+1; + String workbegindate = Util.null2String(rs.getString("workbegindate")).trim(); + String workbegintime = Util.null2String(rs.getString("workbegintime")).trim(); + String workenddate = Util.null2String(rs.getString("workenddate")).trim(); + String workendtime = Util.null2String(rs.getString("workendtime")).trim(); + String signintime = Util.null2String(rs.getString("signintime")).trim(); + String signouttime = Util.null2String(rs.getString("signouttime")).trim(); + int attendanceMins = rs.getInt("attendanceMins"); + String beLateMins = Util.null2String(rs.getString("beLateMins")).trim(); + String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")).trim(); + String leaveEarlyMins= Util.null2String(rs.getString("leaveEarlyMins")).trim(); + String graveLeaveEarlyMins= Util.null2String(rs.getString("graveLeaveEarlyMins")).trim(); + String absenteeismMins= Util.null2String(rs.getString("absenteeismMins")).trim(); + String forgotCheckMins = Util.null2String(rs.getString("forgotcheckMins")).trim(); + String forgotBeginWorkCheckMins = Util.null2String(rs.getString("forgotBeginWorkCheckMins")).trim(); + String signinid = Util.null2String(rs.getString("signinid")).trim(); + String signoutid = Util.null2String(rs.getString("signoutid")).trim(); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = Util.null2String(rs.getString("leaveInfo")); + String flowinfo = Util.null2String(rs.getString("flowinfo")); + String on_absenteeismmins = Util.null2String(rs.getString("on_absenteeismmins")); + String off_absenteeismmins = Util.null2String(rs.getString("off_absenteeismmins")); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + + + if(!isNonWork){ + if (workbegintime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("workdate",workbegindate); + signStatusInfo.put("worktime",workbegintime); + signStatusInfo.put("beLateMins",beLateMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("graveBeLateMins",graveBeLateMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("on_absenteeismmins",on_absenteeismmins); + signStatusInfo.put("off_absenteeismmins",off_absenteeismmins); + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); + + data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + } + + if (workendtime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("workdate",workenddate); + signStatusInfo.put("worktime",kqTimesArrayComInfo.turn48to24Time(workendtime)); + signStatusInfo.put("leaveEarlyMins",leaveEarlyMins); + signStatusInfo.put("graveLeaveEarlyMins",graveLeaveEarlyMins); + signStatusInfo.put("forgotCheckMins",forgotCheckMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("on_absenteeismmins",on_absenteeismmins); + signStatusInfo.put("off_absenteeismmins",off_absenteeismmins); + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); + + data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else{ + if(workMins>0){ + //弹性工时打卡时间取自签到签退数据 + } + signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("on_absenteeismmins",on_absenteeismmins); + signStatusInfo.put("off_absenteeismmins",off_absenteeismmins); + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); + + if(signinid.length() > 0){ + data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + if(signoutid.length() > 0){ + data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + }else{ + data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else if (signoutid.length() > 0) { + data.put("signouttime" + serialnumber, signouttime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signouttime); + data.put("signoutstatus" + serialnumber, KQReportBiz.getSignStatus(signStatusInfo, user, "off")); + } else{ + data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + } + } + }catch (Exception e){ + writeLog(e); + } + return data; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/report/GetKQReportCmd.java b/src/com/engine/kq/cmd/report/GetKQReportCmd.java new file mode 100644 index 0000000..7ce52c1 --- /dev/null +++ b/src/com/engine/kq/cmd/report/GetKQReportCmd.java @@ -0,0 +1,837 @@ +package com.engine.kq.cmd.report; + +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.weaver.file.Prop; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.util.PageUidFactory; +import com.google.common.collect.Maps; +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(); + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"0"); + + 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 status = Util.null2String(jsonObj.get("status")); + 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()); + boolean isKqReportHalfOpen = "1".equals(new KQSettingsComInfo().getMain_val("kq_report_half")); + if(isKqReportHalfOpen) { + pageSize = pageSize/2; + } + 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", 90); + 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()*90); + column.put("children", childColumns); + } + columns.add(column); + + + // 没有权限的人最大只支持查询本季 + Map getRealDate = new KQReportBiz().realDate(fromDate, toDate, user, "1"); + fromDate = getRealDate.get("fromDate"); + toDate = getRealDate.get("toDate"); + + 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 "; + List paramLists = new ArrayList<>(); + List paramList = null; + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+KQReportBiz.splitParamStr(subCompanyId)+") "; + for(String bean : subCompanyId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+KQReportBiz.splitParamStr(departmentId)+") "; + for(String bean : departmentId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+KQReportBiz.splitParamStr(resourceId)+") "; + for(String bean : resourceId.split(",")) { + paramList = new ArrayList<>(); + paramList.add(bean); + paramLists.add(paramList); + } + } + + + 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<>'' "); + } + + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and a.status = ?"; + paramList = new ArrayList<>(); + paramList.add(status); + paramLists.add(paramList); + }else if (status.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + if("-1".equals(fromDate) || "-1".equals(toDate)) { + sqlWhere += " and 1=2 "; + } + sql = " select count(*) as c from ( select 1 as c "+sqlFrom+sqlWhere+groupBy+") t"; + rs.executeQuery(sql, paramLists); + 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.subcompanyid asc, t.departmentid asc, t.dsporder asc, t.lastname asc "; + String descOrderBy = " order by t.subcompanyid asc, t.departmentid asc, t.dsporder asc, t.lastname asc "; + + //默认排序设置 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 if (rs.getDBType().equals("postgresql")) { + sql = " select * from (select " + sql+") t "+orderBy; + sql = "select t1.* from (" + sql + ") t1 limit " +pageSize + " offset " + ((pageIndex - 1) * pageSize); + } + else { + orderBy = " order by subcompanyid asc, departmentid asc, dsporder asc, lastname asc "; + descOrderBy = " order by subcompanyid desc, departmentid desc, 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; + } + + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径 + String fullPathMainKey = "show_full_path"; + String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); + + String show_card_source = Util.null2String(kqSettingsComInfo.getMain_val("show_card_source"),"0");//是否显示打卡数据,以及打卡数据来源 + params.put("show_card_source",show_card_source); + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + params.put("uintType",uintType); + params.put("hoursToDay",hoursToDay); + Map flowData = kqReportBiz.getFlowData(params,user); + rs.writeLog(":::sql::::::::::"+sql+":::paramLists:::"+JSON.toJSONString(paramLists)); + rs.executeQuery(sql, paramLists); + 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 = "1".equals(isShowFullPath) ? + SubCompanyComInfo.getSubcompanyRealPath(tmpSubcompanyId, "/", "0") : + subCompanyComInfo.getSubCompanyname(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 = "1".equals(isShowFullPath) ? + departmentComInfo.getDepartmentRealPath(tmpDepartmentId, "/", "0") : + departmentComInfo.getDepartmentname(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(); + if(("1").equals(leavetype_is_on)) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + for (int i = allLeaveRules.size() - 1; i >= 0; i--) { + Map leaveRule = allLeaveRules.get(i); + String leaveId = Util.null2String(leaveRule.get("id")); + boolean flag = KQLeaveRulesBiz.filterSubLeaveRule(kqLeaveRulesComInfo, user, leaveId); + if (flag) { + allLeaveRules.remove(i); + } + } + } + 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 amData = Maps.newHashMap(); + Map pmData = Maps.newHashMap(); + if(isKqReportHalfOpen) { + amData.putAll(data); + pmData.putAll(data); + } + + Map detialDatas = kqReportBiz.getDetialDatas(id,fromDate,toDate,user,flowData,false,uintType,show_card_source); +// new KQLog().info("id:"+id+":detialDatas:"+detialDatas); + String user_endDate = Util.null2String(resourceComInfo.getEndDate(id)); + String user_status = Util.null2String(resourceComInfo.getStatus(id)); + String begindate = Util.null2String(resourceComInfo.getCreatedate(id)).trim(); + String companyStartDate = Util.null2String(resourceComInfo.getCompanyStartDate(id)).trim(); + if(companyStartDate.length()!=10){ + companyStartDate = ""; + } + if(companyStartDate.length()>0 && companyStartDate.indexOf("-")>0){ + begindate=companyStartDate; + } + isEnd = false; + for(String date=fromDate; !isEnd;) { + if(date.equals(toDate)) isEnd = true; + if(DateUtil.compDate(today, date)>0){ + if(isKqReportHalfOpen) { + amData.put(date,""); + pmData.put(date,""); + } else { + data.put(date,""); + } + }else{ + if(!(user_status.equals("0")||user_status.equals("1")||user_status.equals("2")||user_status.equals("3"))){ + //其他状态 + if(user_endDate.length()>0 && date.compareTo(user_endDate)>0){//人员合同结束日期之后 + if(isKqReportHalfOpen) { + amData.put(date,""); + pmData.put(date,""); + } else { + data.put(date,""); + } + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + continue; + } + } + if(begindate.length()>0 && date.compareTo(begindate)<0 ){//人员入职日期前无需计算考勤,如果没有入职日期,已创建日期为准 + if(isKqReportHalfOpen) { + amData.put(date,""); + pmData.put(date,""); + } else { + data.put(date,""); + } + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + continue; + } + + if(isKqReportHalfOpen) { + Map tmpData = Maps.newHashMap(); + Object tmpValue = null; + if(detialDatas.get(id+"|"+date)==null){ + tmpValue = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + data.put(date,tmpValue); + amData.put(date,tmpValue); + pmData.put(date,tmpValue); + }else { + tmpData = (Map) detialDatas.get(id+"|"+date); + data.put(date,tmpData); + if(tmpData != null){ + tmpData.put("text",Util.null2String(tmpData.get("textAM"))); + + Map amTmpData = Maps.newHashMap(); + amTmpData.put("text",Util.null2String(tmpData.get("textAM"))); + Map pmTmpData = Maps.newHashMap(); + pmTmpData.put("text",Util.null2String(tmpData.get("textPM"))); + amData.put(date,amTmpData); + pmData.put(date,pmTmpData); + } + } + } 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); + } + if(isKqReportHalfOpen) { + amData.put("rowSpan", "2"); + pmData.put("rowSpan", "0"); + datas.add(amData); + datas.add(pmData); + } else { + datas.add(data); + } + } + + List lsHolidays = KQHolidaySetBiz.getHolidaySetListByScope(""+user.getUID(),fromDate,toDate); + retmap.put("holidays", lsHolidays); + + retmap.put("columns",columns); + retmap.put("datas",datas); + if(isKqReportHalfOpen) { + retmap.put("pagesize", pageSize*2); + retmap.put("count", count*2); + } else { + retmap.put("pagesize", pageSize); + retmap.put("count", count); + } + retmap.put("pageindex", pageIndex); + retmap.put("pagecount", pageCount); + retmap.put("ishavepre", isHavePre); + retmap.put("ishavenext", isHaveNext); + retmap.put("isKqReportHalfOpen", isKqReportHalfOpen); + }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; + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String leavetype_is_on = Util.null2String(kqSettingsComInfo.getMain_val("leavetype_is_on"),"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(); + if (("1").equals(leavetype_is_on)) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + for (int i = leaveRules.size() - 1; i >= 0; i--) { + Map leaveRule = leaveRules.get(i); + String leaveId = Util.null2String(leaveRule.get("id")); + boolean flag = kqLeaveRulesBiz.filterSubLeaveRule(kqLeaveRulesComInfo, user, leaveId); + if (flag) { + leaveRules.remove(i); + } + } + } + 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= ? and jbksrq >= ? and sqr = ?"; + RecordSet rs = new RecordSet(); + rs.executeQuery(sql,fromDate, toDate, userid); + + while (rs.next()) { + String workdate = rs.getString("jbksrq"); + boolean workDay = kqWorkTime.isWorkDay(userid, workdate); + boolean isHoliday = KQHolidaySetBiz.isHoliday(userid,workdate); + double dxsc = rs.getDouble("dxsc"); + dxsc = (double)Math.round(dxsc*100)/100; + BigDecimal bigDecimalDxsc = new BigDecimal(Double.toString(dxsc)); + if(workDay){ + if("1".equals(leaveType)){ + bigDecimal.subtract(bigDecimalDxsc); + } + }else if(isHoliday ){ + if("2".equals(leaveType)){ + bigDecimal.subtract(bigDecimalDxsc); + } + + }else { + if("3".equals(leaveType)){ + bigDecimal.subtract(bigDecimalDxsc); + } + + } + } + return bigDecimal.doubleValue(); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + public static void main(String[] args) { + String s1 = String.format("%.2f", 1.2); + System.out.println(s1); + + } + +} diff --git a/src/com/engine/kq/cmd/report/GetRightMenuCmd.java b/src/com/engine/kq/cmd/report/GetRightMenuCmd.java new file mode 100644 index 0000000..6e303ca --- /dev/null +++ b/src/com/engine/kq/cmd/report/GetRightMenuCmd.java @@ -0,0 +1,57 @@ +package com.engine.kq.cmd.report; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + RightMenu rightMenu = null; + + rightMenu = new RightMenu(user.getLanguage(), RightMenuType.BTN_SHOW_NOACCOUNT, "showAll()", true);//不显示无账号人员 + rightMenuList.add(rightMenu); + + rightMenu = new RightMenu(user.getLanguage(), RightMenuType.BTN_SAVE_TEMPLETE, "saveTemplete()", true);//存为模板 + rightMenuList.add(rightMenu); + + rightMenu = new RightMenu(user.getLanguage(), RightMenuType.BTN_Export_Excel, "exportExcel()", true);//导出excel + rightMenuList.add(rightMenu); + +// rightMenu = new RightMenu(user.getLanguage(), RightMenuType.BTN_SET_ORDER, "setOrder()", false);//设置默认排序 +// rightMenuList.add(rightMenu); + + if (HrmUserVarify.checkUserRight("KQReport:Format", user)) { + rightMenu = new RightMenu(user.getLanguage(), RightMenuType.BTN_KQ_REPORT_FORMAT, "reportFormat", false); + rightMenuList.add(rightMenu); + } + + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/report/GetSearchConditionCmd.java b/src/com/engine/kq/cmd/report/GetSearchConditionCmd.java new file mode 100644 index 0000000..e2703ea --- /dev/null +++ b/src/com/engine/kq/cmd/report/GetSearchConditionCmd.java @@ -0,0 +1,261 @@ +package com.engine.kq.cmd.report; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.bean.WeaRadioGroup; +import com.api.hrm.util.HrmAdvancedSearchUtil; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.common.service.HrmCommonService; +import com.engine.common.service.impl.HrmCommonServiceImpl; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.biz.KQReportFieldComInfo; +import com.engine.kq.biz.KQSettingsBiz; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.settings.ChgPasswdReminder; +import weaver.hrm.settings.RemindSettings; +import weaver.systeminfo.SystemEnv; + +/** + * 获取排班查询条件 + * @author pzy + * + */ +public class GetSearchConditionCmd extends AbstractCommonCommand>{ + + public GetSearchConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) {Map retmap = new HashMap(); + List lsCondition = new ArrayList(); + List cusCondition = new ArrayList(); + String[] options = null; + String[] selectLinkageDatas = null; + try{ + HrmAdvancedSearchUtil hrmAdvancedSearchUtil = new HrmAdvancedSearchUtil(); + HrmCommonService hrmCommonService = new HrmCommonServiceImpl(); + + String reportType = Util.null2String(params.get("reportType")); + if(reportType.length()==0)reportType = "month"; + String reportTypeId = "1"; + boolean hasReportRight = false; + if("month".equals(reportType)) { + reportTypeId = "1"; //考勤汇总报表 + } else if("daily".equals(reportType)) { + reportTypeId = "2"; //每日统计报表 + } + hasReportRight = new KQReportBiz().hasReportRight(reportTypeId,""+user.getUID()); + boolean kq_personal_reportsearch = KQSettingsBiz.showLeaveTypeSet("kq_personal_reportsearch"); + //展示列、时间范围、数据范围 + WeaRadioGroup wrg = null; + if(kq_personal_reportsearch) { + if(hasReportRight) { + options = new String[]{"1,15537,false","2,15539,false","3,15541,true","7,27347,false","4,21904,false","5,15384,false","8,81716,false","6,32530,false"}; + } else { + options = new String[]{"1,15537,false","2,15539,false","3,15541,true","7,27347,false","4,21904,false","6,32530,false"}; + } + } else { + options = new String[]{"1,15537,false","2,15539,false","3,15541,true","7,27347,false","4,21904,false","5,15384,false","8,81716,false","6,32530,false"}; + } + wrg = hrmAdvancedSearchUtil.getAdvanceCondition("typeselect","19482",options,null,user); + wrg.setLabelcol(3); + wrg.setFieldcol(20); + Map selectLinks = new HashMap(); + List domkey = new ArrayList(); + Map map = new HashMap(); + selectLinks.put("conditionType", "RANGEPICKER"); + domkey = new ArrayList(); + domkey.add("fromDate"); + domkey.add("toDate"); + selectLinks.put("domkey", domkey); + map.put("6", selectLinks); + wrg.setSelectLinkageDatas(map); + lsCondition.add(wrg); + + if(!hasReportRight && kq_personal_reportsearch) { + if(hrmCommonService.isManager(user.getUID())){ + options = new String[]{"3,1867,false","4,15089,false"}; + } else { + options = new String[]{"3,1867,false"}; + } + } else { + if(hrmCommonService.isManager(user.getUID())){ + options = new String[]{"0,140,true","1,141,false","2,124,false","3,1867,false","4,15089,false"}; + }else{ + options = new String[]{"0,140,true","1,141,false","2,124,false","3,1867,false"}; + } + } + + selectLinkageDatas = new String[]{"1,subCompanyId,141,3,194","2,departmentId,124,3,57","3,resourceId,1867,3,17","4,allLevel,389995,4,1"}; + if(user.getUID()!=1){ + if(!hasReportRight && kq_personal_reportsearch) { + selectLinkageDatas[2]="3,resourceId,1867,3,17,"+user.getUID(); + options[0]="3,1867,true"; + } else { + selectLinkageDatas[2]="3,resourceId,1867,3,17,"+user.getUID(); + options[0]="0,140,false"; + options[3]="3,1867,true"; + } + } + wrg = hrmAdvancedSearchUtil.getAdvanceCondition("viewScope","34102",options,selectLinkageDatas,user); + wrg.setLabelcol(3); + wrg.setFieldcol(20); + lsCondition.add(wrg); + + WeaRadioGroup wrg1 = new WeaRadioGroup(); + + ChgPasswdReminder reminder = new ChgPasswdReminder(); + RemindSettings settings = reminder.getRemindSettings(); + String checkUnJob = Util.null2String(settings.getCheckUnJob(), "0"); + List statusList = Lists.newArrayList(); + if ("1".equals(checkUnJob)) {//启用后,只有有“离职人员查看”权限的用户才能检索非在职人员 + if (HrmUserVarify.checkUserRight("hrm:departureView", user)) { + statusList.add("9,332,false"); + } + } else { + statusList.add("9,332,false"); + } + statusList.add("0,15710,false"); + statusList.add("1,15711,false"); + statusList.add("2,480,false"); + statusList.add("3,15844,false"); + if ("1".equals(checkUnJob)) {//启用后,只有有“离职人员查看”权限的用户才能检索非在职人员 + if (HrmUserVarify.checkUserRight("hrm:departureView", user)) { + statusList.add("4,6094,false"); + statusList.add("5,6091,false"); + statusList.add("6,6092,false"); + statusList.add("7,2245,false"); + } + } else { + statusList.add("4,6094,false"); + statusList.add("5,6091,false"); + statusList.add("6,6092,false"); + statusList.add("7,2245,false"); + } + statusList.add("8,1831,true"); + options = new String[statusList.size()]; + for(int i = 0 ; i < statusList.size() ; i++){ + String statusStr = statusList.get(i); + options[i] = statusStr; + } + + wrg1 = hrmAdvancedSearchUtil.getAdvanceCondition("status","602",options,null,user); + wrg1.setLabelcol(3); + wrg1.setFieldcol(20); + lsCondition.add(wrg1); + + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + List showColumns = new ArrayList<>(); + String cascadekey = ""; + List> selectOptions = new ArrayList<>(); + Map selectOption = null; + + Map mapShowColumns = new HashMap<>(); + List lsCascadekey = null; + if(reportType.equals("month")){ + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()){ + if(!kqReportFieldComInfo.getIsDefinedColumn().equals("1"))continue; + if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))continue; + if("overtime_nonleave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname()) || "overtime_4leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())){ + continue; + } + if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){ + continue; + } + lsCascadekey = null; + if(Util.null2String(kqReportFieldComInfo.getCascadekey()).length()>0){ + lsCascadekey = Util.splitString2List(kqReportFieldComInfo.getCascadekey(),","); + } + if(lsCascadekey !=null && lsCascadekey.size()>0) { + mapShowColumns.put(kqReportFieldComInfo.getFieldname(), lsCascadekey); + } + } + retmap.put("showColumns", mapShowColumns); + }else{ + //考勤日历考 + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()){ + if(!kqReportFieldComInfo.getIsDefinedColumn().equals("1"))continue; + if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("daily"))continue; + if("overtime_nonleave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname()) || "overtime_4leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())){ + continue; + } + if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){ + continue; + } + cascadekey = ""; + if(kqReportFieldComInfo.getFieldname().equals("beLate")){ + showColumns.add(selectOptions); + selectOptions = new ArrayList<>(); + cascadekey = "beLateMins"; + }else if(kqReportFieldComInfo.getFieldname().equals("leaveEearly")){ + cascadekey = "leaveEarlyMins"; + }else if(kqReportFieldComInfo.getFieldname().equals("graveBeLate")){ + cascadekey = "graveBeLateMins"; + }else if(kqReportFieldComInfo.getFieldname().equals("graveLeaveEarly")){ + cascadekey = "graveLeaveEarlyMins"; + }else if(kqReportFieldComInfo.getFieldname().equals("absenteeism")){ + cascadekey = "absenteeismMins"; + }else if(kqReportFieldComInfo.getFieldname().equals("signin1")){ + cascadekey = "signout1"; + }else if(kqReportFieldComInfo.getFieldname().equals("signin2")){ + cascadekey = "signout2"; + }else if(kqReportFieldComInfo.getFieldname().equals("signin3")){ + cascadekey = "signout3"; + } + + selectOption = new HashMap<>(); + selectOption.put("key",kqReportFieldComInfo.getFieldname()); + selectOption.put("cascadekey",cascadekey); + selectOption.put("showname",SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())); + selectOption.put("selected",kqReportFieldComInfo.getDefaultShow().equals("1")); + selectOptions.add(selectOption); + } + showColumns.add(selectOptions); + retmap.put("showColumns", showColumns); + } + + createSearchConditionItemList(cusCondition); + + retmap.put("status", "1"); + retmap.put("conditions", lsCondition); + retmap.put("cusCondition", cusCondition); + }catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", ""+ SystemEnv.getHtmlLabelName(10004510,weaver.general.ThreadVarLanguage.getLang())+""); + } + return retmap; + } + + /** + * 这里只处理非下拉框字段 + * @param cusCondition + */ + public void createSearchConditionItemList(List cusCondition) { + + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/report4E/GetBalanceInfoCmd.java b/src/com/engine/kq/cmd/report4E/GetBalanceInfoCmd.java new file mode 100644 index 0000000..3c4174f --- /dev/null +++ b/src/com/engine/kq/cmd/report4E/GetBalanceInfoCmd.java @@ -0,0 +1,59 @@ +package com.engine.kq.cmd.report4E; + +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.KQBalanceOfLeaveBiz; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.log.KQLog; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 小e 我的假期情况 + */ +public class GetBalanceInfoCmd extends AbstractCommonCommand> { + private KQLog kqLog = new KQLog(); + private HttpServletRequest request; + + public GetBalanceInfoCmd(HttpServletRequest request,Map params, User user) { + this.request = request; + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + String resourceId = Util.null2String(params.get("resourceId")); + User curUser = new User(Util.getIntValue(resourceId)); + List datas = KQBalanceOfLeaveBiz.getBalanceInfo(resourceId,curUser.getLanguage()); + kqLog.info("GetBalanceInfoCmd:params:"+params+":datas:"+datas); + retmap.put("balanceinfo", datas); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/report4E/GetScheduleDataCmd.java b/src/com/engine/kq/cmd/report4E/GetScheduleDataCmd.java new file mode 100644 index 0000000..0a6d703 --- /dev/null +++ b/src/com/engine/kq/cmd/report4E/GetScheduleDataCmd.java @@ -0,0 +1,332 @@ +package com.engine.kq.cmd.report4E; + +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.KQLeaveRulesBiz; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 小E 获取我的考勤情况 + */ +public class GetScheduleDataCmd extends AbstractCommonCommand> { + private KQLog kqLog = new KQLog(); + private HttpServletRequest request; + + public GetScheduleDataCmd(HttpServletRequest request,Map params, User user) { + this.request = request; + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + getScheduleData(retmap); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + public void getScheduleData(Map retmap) throws Exception{ + kqLog.info("GetScheduleDataCmd:params:"+params); + RecordSet rs = new RecordSet(); + DateTimeFormatter datefullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + //当前用户 + String curResourceId = Util.null2String(params.get("curResourceId")); + User curUser = new User(Util.getIntValue(curResourceId)); + //查询用户 + String resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + LocalDateTime nowDateTIme = LocalDateTime.now(); + LocalDateTime localFromDateTime = LocalDateTime.parse(fromDate,datefullFormatter); + LocalDateTime localToDateTime = LocalDateTime.parse(toDate,datefullFormatter); + fromDate = localFromDateTime.format(dateFormatter); + toDate = localToDateTime.format(dateFormatter); +// if(localToDateTime.isAfter(nowDateTIme)){ +// toDate = nowDateTIme.format(dateFormatter); +// } + + if(fromDate.equalsIgnoreCase(toDate)){ + retmap.put("title", fromDate); + }else{ + retmap.put("title", fromDate+""+weaver.systeminfo.SystemEnv.getHtmlLabelName(15322,weaver.general.ThreadVarLanguage.getLang())+""+toDate); + } + + KQReportBiz kqReportBiz = new KQReportBiz(); + String rightSql = kqReportBiz.getReportRight("1",""+curUser.getUID(),"a"); + + String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,b.subcompanyid,b.departmentid,b.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.absenteeismMins) as absenteeismMins, sum(b.forgotCheck) as forgotCheck "; + String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >=? and b.kqdate <=? "; + String sqlWhere = rightSql; + String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,b.subcompanyid,b.departmentid,b.jobtitle "; + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + String sql = "select "+ backFields + sqlFrom+sqlWhere +groupBy; + rs.executeQuery(sql,fromDate,toDate); + + Map params = new HashMap<>(); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("fromDate", fromDate); + jsonObject.put("toDate", toDate); + jsonObject.put("resourceId", resourceId); + jsonObject.put("typeselect", "6"); + params.put("data", jsonObject); + + //请假 + List> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules(); + Map flowData = kqReportBiz.getFlowData(params,curUser); + + List infoLists = new ArrayList<>(); + Map infoMaps = new LinkedHashMap<>(); + while (rs.next()){ + String id = rs.getString("id"); + String workdays = Util.null2o(rs.getString("workdays")); + String workMins = Util.null2o(rs.getString("workMins")); + String workHours = Util.round(Util.null2String(Util.getDoubleValue(workMins,0.0)/60.0),2); + String beLate = rs.getString("beLate"); + String graveBeLate = rs.getString("graveBeLate"); + String leaveEearly = rs.getString("leaveEearly"); + String graveLeaveEarly = rs.getString("graveLeaveEarly"); + String absenteeism = rs.getString("absenteeism"); + String forgotCheck = rs.getString("forgotCheck"); + + //加班 + String overtimeValue = ""; + //出差 + String businessLeaveValue = ""; + //外出 + String officialBusinessValue = ""; + List infoList = new ArrayList<>(); + Map infoMap = new LinkedHashMap<>(); + Map dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(132056,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(383378,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", workdays); + infoList.add(dataMap); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(390053,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(391,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", workHours); + infoList.add(dataMap); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(20081,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(18083,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", beLate); + infoList.add(dataMap); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(500546,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(18083,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", graveBeLate); + infoList.add(dataMap); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(20082,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(18083,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", leaveEearly); + infoList.add(dataMap); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(500547,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(18083,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", graveLeaveEarly); + infoList.add(dataMap); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(20085,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(18083,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", absenteeism); + infoList.add(dataMap); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(20086,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(18083,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", forgotCheck); + infoList.add(dataMap); + + infoMap.put("title", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005335,weaver.general.ThreadVarLanguage.getLang())+""); + infoMap.put("detail", infoList); + infoLists.add(infoMap); + + infoList = new ArrayList<>(); + infoMap = new LinkedHashMap<>(); + Map leaveRule = null; + for(int i=0;allLeaveRules!=null&&i)allLeaveRules.get(i); + String flowType = Util.null2String("leaveType_"+leaveRule.get("id")); + String flowTypeName = Util.null2String(leaveRule.get("name")); + dataMap = new LinkedHashMap<>(); + dataMap.put("name", flowTypeName); + dataMap.put("value", Util.null2s(Util.null2String(flowData.get(id+"|"+flowType)),"0")); + infoList.add(dataMap); + } + infoMap.put("title", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005336,weaver.general.ThreadVarLanguage.getLang())+""); + infoMap.put("detail", infoList); + infoLists.add(infoMap); + + infoList = new ArrayList<>(); + infoMap = new LinkedHashMap<>(); + double workingDayOvertime = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime"))); + workingDayOvertime = workingDayOvertime<0?0:workingDayOvertime; + double restDayOvertime = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime"))); + restDayOvertime = restDayOvertime<0?0:restDayOvertime; + double holidayOvertime = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime"))); + holidayOvertime = holidayOvertime<0?0:holidayOvertime; + overtimeValue = KQDurationCalculatorUtil + .getDurationRound(String.valueOf(workingDayOvertime+restDayOvertime+holidayOvertime)); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(6151,weaver.general.ThreadVarLanguage.getLang())+""); + dataMap.put("value", Util.null2s(overtimeValue,"0")); + infoList.add(dataMap); + + infoMap.put("title", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005337,weaver.general.ThreadVarLanguage.getLang())+""); + infoMap.put("detail", infoList); + infoLists.add(infoMap); + + infoList = new ArrayList<>(); + infoMap = new LinkedHashMap<>(); + businessLeaveValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id+"|businessLeave"))); + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(20084,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(383378,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", Util.null2s(businessLeaveValue,"0")); + infoList.add(dataMap); + + officialBusinessValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id+"|officialBusiness"))); + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(24058,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(383378,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", Util.null2s(officialBusinessValue,"0")); + infoList.add(dataMap); + + infoMap.put("title", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(375,weaver.general.ThreadVarLanguage.getLang())+""); + infoMap.put("detail", infoList); + infoLists.add(infoMap); + } + if(infoLists.isEmpty()){ + fillBlank(allLeaveRules,infoLists); + } + retmap.put("data", infoLists); + kqLog.info("GetScheduleDataCmd:infoLists:"+ JSON.toJSONString(infoLists)); + } + + /** + * 需要给一个默认值 + * @param allLeaveRules + * @param infoLists + */ + public void fillBlank( + List> allLeaveRules, + List infoLists) { + List infoList = new ArrayList<>(); + Map infoMap = new LinkedHashMap<>(); + Map dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(132056,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(383378,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", "0"); + infoList.add(dataMap); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(390053,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(391,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", "0"); + infoList.add(dataMap); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(20081,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(18083,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", "0"); + infoList.add(dataMap); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(20082,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(18083,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", "0"); + infoList.add(dataMap); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(20085,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(18083,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", "0"); + infoList.add(dataMap); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(20086,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(18083,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", "0"); + infoList.add(dataMap); + + infoMap.put("title", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005335,weaver.general.ThreadVarLanguage.getLang())+""); + infoMap.put("detail", infoList); + infoLists.add(infoMap); + + infoList = new ArrayList<>(); + infoMap = new LinkedHashMap<>(); + Map leaveRule = null; + for(int i=0;allLeaveRules!=null&&i)allLeaveRules.get(i); + String flowType = Util.null2String("leaveType_"+leaveRule.get("id")); + String flowTypeName = Util.null2String(leaveRule.get("name")); + dataMap = new LinkedHashMap<>(); + dataMap.put("name", flowTypeName); + dataMap.put("value", "0"); + infoList.add(dataMap); + } + infoMap.put("title", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005336,weaver.general.ThreadVarLanguage.getLang())+""); + infoMap.put("detail", infoList); + infoLists.add(infoMap); + + infoList = new ArrayList<>(); + infoMap = new LinkedHashMap<>(); + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(6151,weaver.general.ThreadVarLanguage.getLang())+""); + dataMap.put("value", "0"); + infoList.add(dataMap); + + infoMap.put("title", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005337,weaver.general.ThreadVarLanguage.getLang())+""); + infoMap.put("detail", infoList); + infoLists.add(infoMap); + + infoList = new ArrayList<>(); + infoMap = new LinkedHashMap<>(); + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(20084,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(383378,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", "0"); + infoList.add(dataMap); + + dataMap = new LinkedHashMap<>(); + dataMap.put("name", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(24058,weaver.general.ThreadVarLanguage.getLang())+"("+weaver.systeminfo.SystemEnv.getHtmlLabelName(383378,weaver.general.ThreadVarLanguage.getLang())+")"); + dataMap.put("value", "0"); + infoList.add(dataMap); + + infoMap.put("title", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(375,weaver.general.ThreadVarLanguage.getLang())+""); + infoMap.put("detail", infoList); + infoLists.add(infoMap); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/report4E/PunchButton4ECmd.java b/src/com/engine/kq/cmd/report4E/PunchButton4ECmd.java new file mode 100644 index 0000000..21c2c14 --- /dev/null +++ b/src/com/engine/kq/cmd/report4E/PunchButton4ECmd.java @@ -0,0 +1,344 @@ +package com.engine.kq.cmd.report4E; + +import com.alibaba.fastjson.JSON; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQFormatBiz; +import com.engine.kq.biz.KQFormatData; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.timer.KQQueue; +import com.engine.kq.timer.KQTaskBean; +import com.engine.kq.util.KQDurationCalculatorUtil; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.net.URL; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import javax.servlet.http.HttpServletRequest; +import net.sf.json.JSONObject; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.dateformat.TimeZoneVar; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 小E 签到签退 + * 针对正式系统 没有处理跨天和多班次的情况 + * 没有处理加班的情况 + */ +public class PunchButton4ECmd extends AbstractCommonCommand> { + private KQLog kqLog = new KQLog(); + private HttpServletRequest request; + + public PunchButton4ECmd(HttpServletRequest request,Map params, User user) { + this.request = request; + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + kqLog.info(user.getLastname()+":PunchButton4ECmd:params:"+params); + insertSign(retmap); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + kqLog.info("PunchButton4ECmd报错::"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + return retmap; + } + + public void insertSign(Map retmap) throws Exception{ + + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + LocalDateTime localDateTime = LocalDateTime.now(); + + String curDate = localDateTime.format(dateFormatter); + + Map todayLineMap = KQDurationCalculatorUtil.getWorkButton(user, curDate,false); + + RecordSet rs = new RecordSet(); + KQFormatData kqFormatData = new KQFormatData(); + int userId = user.getUID(); + //小e的不考虑跨天 + String belongdate = ""; + + String signDate = curDate; + String signTime =localDateTime.format(dateTimeFormatter); + + String userType = user.getLogintype(); + String clientAddress = Util.getIpAddr(request); + String isInCom = "1"; + String timeZone = Util.null2String(TimeZoneVar.getTimeZone(),""); + + String signType = Util.null2String(params.get("signtype")); + String signStatus = ButtonStatusEnum.NORMAL.getStatusCode();; + //手机打卡部分 + String longitude = Util.null2String(params.get("longitude")); + String latitude = Util.null2String(params.get("latitude")); + + String position = request.getParameter("position"); + if(Util.null2String(position).length() > 0){ +// String decode_pos = java.net.URLDecoder.decode(position, "UTF-8"); +// //小E 是get方式请求的,中文的话addr是乱码,需要decode+byte处理下 +// String byte_decode_pos = new String(decode_pos.getBytes("ISO-8859-1"),"UTF-8"); +// position = byte_decode_pos; + }else{ + position = getPosition(longitude,latitude); + } + + String deviceInfo = Util.null2String(params.get("deviceInfo")); + com.alibaba.fastjson.JSONObject jsonObject = null; + if(deviceInfo.length() > 0){ + jsonObject = JSON.parseObject(deviceInfo); + com.alibaba.fastjson.JSONObject jsonObject1 = new com.alibaba.fastjson.JSONObject(); + Set> jsonSet = jsonObject.entrySet(); + for(Entry js : jsonSet){ + String key = js.getKey(); + String value = Util.null2String(js.getValue()); + jsonObject1.put(key, value); + } + if(!jsonObject1.isEmpty()){ + deviceInfo = jsonObject1.toJSONString(); + } + } + +// String addr = Util.null2String(params.get("position")); + + //记录下是来自于E9的小e签到 + String signfrom = "e9e"; + //打卡所属的工作时段 + String worksection = Util.null2String(params.get("worksection")); + String belongtime = Util.null2String(params.get("belongtime")); + + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map locationMap = kqGroupBiz.checkLocationScope(userId+"",longitude,latitude); + String locationNeedCheck = Util.null2String(locationMap.get("needCheck")); + boolean locationInScope = Boolean.parseBoolean(Util.null2String(locationMap.get("inScope"))); + if("1".equalsIgnoreCase(locationNeedCheck)){ + if(!locationInScope){ + retmap.put("status", "2"); + retmap.put("message", SystemEnv.getHtmlLabelName(500510, user.getLanguage())); + isInCom = "0"; + } + } + + if(todayLineMap.get("timelineList") != null){ + List todayLine = (List)todayLineMap.get("timelineList"); + if(todayLine != null && !todayLine.isEmpty() && todayLine.size() >= 2){ + Map onTimelineMap = (Map)todayLine.get(0); + Map offTimelineMap = (Map)todayLine.get(1); + + String onTime = Util.null2String(onTimelineMap.get("time")); + String offTime = Util.null2String(offTimelineMap.get("time")); + + LocalTime onTimeLocal = LocalTime.parse(onTime+":00", dateTimeFormatter); + LocalTime offTimeLocal = LocalTime.parse(offTime+":00", dateTimeFormatter); + + int onMin = Util.getIntValue(Util.null2String(onTimelineMap.get("min")),60); + LocalTime onCanTimeLocal = LocalTime.parse(onTime+":00", dateTimeFormatter).minusMinutes(onMin); + int offMin = Util.getIntValue(Util.null2String(offTimelineMap.get("min")),60); + LocalTime offCanTimeLocal = LocalTime.parse(offTime+":59", dateTimeFormatter).plusMinutes(offMin); + + String signOnDateTime = curDate+" 00:00:00"; + String signOffDateTime = curDate+" 23:59:59"; + + if(onCanTimeLocal.isBefore(onTimeLocal) && offCanTimeLocal.isAfter(offTimeLocal)){ + LocalTime nowLocal = localDateTime.toLocalTime(); + if(onCanTimeLocal != null && nowLocal.isBefore(onCanTimeLocal) && "1".equalsIgnoreCase(signType)){ + retmap.put("status", "2"); + retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005338,weaver.general.ThreadVarLanguage.getLang())+""); + isInCom = "0"; + } + if(offCanTimeLocal != null && nowLocal.isAfter(offCanTimeLocal)){ + if("1".equalsIgnoreCase(signType)){ + retmap.put("status", "2"); + retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005339,weaver.general.ThreadVarLanguage.getLang())+""); + isInCom = "0"; + } + if("2".equalsIgnoreCase(signType)){ + retmap.put("status", "2"); + retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005340,weaver.general.ThreadVarLanguage.getLang())+""); + isInCom = "0"; + } + } + signOnDateTime = curDate+" "+onCanTimeLocal.format(dateTimeFormatter); + signOffDateTime = curDate+" "+offCanTimeLocal.format(dateTimeFormatter); + } + String signedMsg = signedMsg(userId+"",signType,user, signOnDateTime, signOffDateTime); + if(signedMsg != null && signedMsg.length() > 0){ + retmap.put("status", "2"); + retmap.put("message", signedMsg); + isInCom = "0"; + } + + //打卡所属的工作时段 + worksection = onTime+"-"+offTime; + + if("1".equalsIgnoreCase(signType)){ + belongtime = onTime; + }else{ + belongtime = offTime; + } + signStatus = getSignStatus(signType,onTime,offTime,signTime); + belongdate = curDate; + }else{ + kqLog.info("PunchButton4ECmd:userid"+userId+":curDate:"+curDate+":todayLine:"+todayLine); + } + }else{ + kqLog.info("PunchButton4ECmd:userid"+userId+":curDate:"+curDate+":todayLineMap:"+todayLineMap); + } + + String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo) "+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + boolean isOk = rs.executeUpdate(punchSql,userId,userType,signType,signDate,signTime,clientAddress,isInCom, + timeZone,belongdate,signfrom,longitude,latitude,position,deviceInfo); + if(!isOk){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + return ; + } + kqLog.info("PunchButton4ECmd:user.getLastname():"+user.getLastname()+":isOk:"+isOk+":punchSql:"+punchSql); + + //打卡提醒处理 还有微信企业钉钉打卡checkin4e.jsp别忘了 + String remindSql = "insert into hrmschedulesign_remind(userId,signType,signDate,signTime,belongdate) values(?,?,?,?,?)"; + isOk = rs.executeUpdate(remindSql, userId,signType,signDate,signTime,belongdate); + kqLog.info(user.getLastname()+":PunchButtonCmd:remindSql:"+remindSql+":isOk:"+isOk); + + String messageDateTime = signDate+" "+signTime; + if("".equalsIgnoreCase(Util.null2String(retmap.get("message")))){ + if("1".equalsIgnoreCase(signType)){ + retmap.put("message", SystemEnv.getHtmlLabelName(10000832,weaver.general.Util.getIntValue(user.getLanguage()))+"
"+messageDateTime); + }else if("2".equalsIgnoreCase(signType)){ + retmap.put("message", SystemEnv.getHtmlLabelName(10000833,weaver.general.Util.getIntValue(user.getLanguage()))+"
"+messageDateTime); + } + } + retmap.put("status", "1"); + retmap.put("signdate", signDate); + retmap.put("signtime", signTime); + retmap.put("position", position); + + //同步更新考勤数据到考勤报表 + new KQFormatBiz().formatDate(""+userId,(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate)); + } + + public String getPosition(String longitude, String latitude) { + String addrStr = ""; + try{ + String url="https://restapi.amap.com/v3/geocode/regeo?output=json&location="+longitude+","+latitude+"&key=fbe499c6f3d6d39af9fea6ff9971a7c8&radius=1000&extensions=all"; + + URL tirc = new URL(url); + BufferedReader in = new BufferedReader(new InputStreamReader(tirc.openStream(),"UTF-8")); + String res; + StringBuilder sb = new StringBuilder(""); + while((res = in.readLine())!=null){ + sb.append(res.trim()); + } + String str = sb.toString(); + JSONObject jsonResult=JSONObject.fromObject(str); + JSONObject detail = jsonResult.getJSONObject("regeocode"); + + addrStr = detail.getString("formatted_address"); + }catch (Exception e){ + kqLog.info("PunchButton4ECmd getPosition:"+e.getMessage()); + } + return addrStr; + } + + /** + * 校验是否已经签到过 + * @param userid + * @param signtype + * @param curUser + * @param signOnDateTime + * @param signOffDateTime + * @return + */ + public String signedMsg(String userid, String signtype, User curUser,String signOnDateTime,String signOffDateTime) throws Exception{ + String signedMsg = ""; + RecordSet rs = new RecordSet(); + boolean hasSigned = false; + if(signOnDateTime.length() > 0 && signOffDateTime.length() > 0){ + String hasSign = "select 1 from hrmschedulesign where 1 = 1 and isInCom = '1' and userid = ? "; + + StringBuffer sql = new StringBuffer(); + if(rs.getDBType().equals("oracle")||rs.getDBType().equals("postgresql")){ + sql.append(" AND signDate||' '||signTime>=? "); + sql.append(" AND signDate||' '||signTime<=? "); + }else if(rs.getDBType().equals("mysql")){ + sql.append(" AND concat(signDate,' ',signTime)>=? "); + sql.append(" AND concat(signDate,' ',signTime)<=? "); + }else{ + sql.append(" AND signDate+' '+signTime>=? "); + sql.append(" AND signDate+' '+signTime<=? "); + } + hasSign += sql.toString(); + rs.executeQuery(hasSign, userid,signOnDateTime,signOffDateTime); + if(rs.next()){ + hasSigned = true; + } + if("1".equalsIgnoreCase(signtype)){ + if(hasSigned){ + signedMsg = SystemEnv.getHtmlLabelName(523888, curUser.getLanguage()); + } + }else if("2".equalsIgnoreCase(signtype)){ + if(!hasSigned){ + signedMsg = SystemEnv.getHtmlLabelName(501301, curUser.getLanguage()); + } + } + } + return signedMsg; + } + + /** + * 在签到签退的时候先根据打卡数据 + * 粗步 得到打卡状态 正常,迟到,早退 + * @return + */ + private String getSignStatus(String signType, String onTime, String offTime, + String signTime) { + String signStatus = ""; + onTime = onTime + ":00"; + offTime = offTime + ":00"; + if("1".equalsIgnoreCase(signType)){ + if(signTime.compareTo(onTime) > 0){ + signStatus = ButtonStatusEnum.BELATE.getStatusCode(); + }else{ + signStatus = ButtonStatusEnum.NORMAL.getStatusCode(); + } + } + if("2".equalsIgnoreCase(signType)){ + if(signTime.compareTo(offTime) < 0){ + signStatus = ButtonStatusEnum.LEAVEERALY.getStatusCode(); + }else{ + signStatus = ButtonStatusEnum.NORMAL.getStatusCode(); + } + } + return signStatus; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportdetial/GetAbsenteeismInfoCmd.java b/src/com/engine/kq/cmd/reportdetial/GetAbsenteeismInfoCmd.java new file mode 100644 index 0000000..6aa1f46 --- /dev/null +++ b/src/com/engine/kq/cmd/reportdetial/GetAbsenteeismInfoCmd.java @@ -0,0 +1,161 @@ +package com.engine.kq.cmd.reportdetial; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.hrm.util.HrmUtil; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.enums.ReportColumnEnum; +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.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/*** + * 旷工明细 + */ +public class GetAbsenteeismInfoCmd extends AbstractCommonCommand> { + + public GetAbsenteeismInfoCmd(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 dialogTitle = SystemEnv.getHtmlLabelName(20090,user.getLanguage()); + String resourceId = Util.null2String(params.get("resourceId")); + String keyWord = Util.null2String(params.get("keyWord")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.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 viewScope = Util.null2String(params.get("viewScope")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + + String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid, serialid as serialid1," + + " workbegintime,workendtime, signintime,signouttime,absenteeismmins " ; + + String sqlFrom = "from hrmresource a, kq_format_detail b "; + String sqlWhere = " where a.id = b.resourceid and absenteeismMins>0 "; + String orderby = " kqdate asc, workbegintime asc " ; + String tableString = ""; + + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a"); + if(rightSql.length()>0){ + sqlWhere += rightSql; + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if (fromDate.length() > 0){ + sqlWhere += " and kqdate >= '"+fromDate+"'"; + } + + if (toDate.length() > 0){ + sqlWhere += " and kqdate <= '"+toDate+"'"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if (resourceId.length() > 0){ + sqlWhere += " and b.resourceid in ( "+resourceId+")"; + } + + if(resourceStatus.length()>0){ + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sqlWhere += " and a.status = "+resourceStatus+ ""; + }else if (resourceStatus.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + 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<>'' "); + } + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList"); + + tableString=""+ + ""+ + ""+ + ""+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + ""+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + retmap.put("dialogTitle",dialogTitle); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportdetial/GetBeLateInfoCmd.java b/src/com/engine/kq/cmd/reportdetial/GetBeLateInfoCmd.java new file mode 100644 index 0000000..f6370fc --- /dev/null +++ b/src/com/engine/kq/cmd/reportdetial/GetBeLateInfoCmd.java @@ -0,0 +1,177 @@ +package com.engine.kq.cmd.reportdetial; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.hrm.util.HrmUtil; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.enums.ReportColumnEnum; +import com.engine.kq.util.PageUidFactory; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/*** + * 迟到相关信息 + */ +public class GetBeLateInfoCmd extends AbstractCommonCommand> { + + public GetBeLateInfoCmd(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 dialogTitle = SystemEnv.getHtmlLabelName(20088, user.getLanguage()); + String tabKey = Util.null2String(params.get("tabKey")); + String resourceId = Util.null2String(params.get("resourceId")); + String keyWord = Util.null2String(params.get("keyWord")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.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 viewScope = Util.null2String(params.get("viewScope")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + String formula = Util.null2String(params.get("formula")); + + String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid, serialid as serialid1," + + " workbegintime,workendtime, signintime,signouttime, beLateMins, graveBeLateMins "; + String sqlFrom = "from hrmresource a, kq_format_detail b "; + String sqlWhere = " where a.id = b.resourceid"; + String orderby = " kqdate asc, workbegintime asc, a.id asc " ; + String tableString = ""; + + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a"); + if(rightSql.length()>0){ + sqlWhere += rightSql; + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if (fromDate.length() > 0){ + sqlWhere += " and kqdate >= '"+fromDate+"'"; + } + + if (toDate.length() > 0){ + sqlWhere += " and kqdate <= '"+toDate+"'"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if (resourceId.length() > 0){ + sqlWhere += " and b.resourceid in ( "+resourceId+")"; + } + + if(resourceStatus.length()>0){ + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sqlWhere += " and a.status = "+resourceStatus+ ""; + }else if (resourceStatus.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + 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<>'' "); + } + + if(tabKey.equals("2")){ + sqlWhere += " and graveBeLateMins>0 "; + }else{ + sqlWhere += " and beLateMins>0 "; + } + + if(formula.length()>0){ + formula = formula.replace("${beLateMins}>","").replace("${beLateMins}<=","").replace("?1:0","").replace(" && ","-"); + String[] tmpValue = Util.splitString(formula,"-"); + sqlWhere += " and beLateMins>"+tmpValue[0]+" and beLateMins<= "+tmpValue[1]; + } + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList"); + + tableString=""+ + ""+ + ""+ + ""+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "; + if(tabKey.equals("2")){ + tableString += " "; + }else{ + tableString += " "; + } + tableString += ""+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + retmap.put("dialogTitle",dialogTitle); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportdetial/GetDailyDetialInfoCmd.java b/src/com/engine/kq/cmd/reportdetial/GetDailyDetialInfoCmd.java new file mode 100644 index 0000000..3129bbe --- /dev/null +++ b/src/com/engine/kq/cmd/reportdetial/GetDailyDetialInfoCmd.java @@ -0,0 +1,436 @@ +package com.engine.kq.cmd.reportdetial; + +import com.alibaba.fastjson.JSON; +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.KQTransMethod; +import com.engine.kq.util.TransMethod; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/*** + * 考勤报表日明细 + */ +public class GetDailyDetialInfoCmd extends AbstractCommonCommand> { + + public GetDailyDetialInfoCmd(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 { + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + TransMethod transMethod = new TransMethod(); + KQTransMethod kqTransMethod = new KQTransMethod(); + String dialogTitle = ""; + Map userInfo = new HashMap<>(); + Map signInfo = new HashMap<>(); + Map table = new HashMap<>(); + List columns = new ArrayList(); + Map column = null; + List datas = new ArrayList(); + Map data = null; + Map signStatusInfo = null; + List logList = null; + + String resourceId = Util.null2String(params.get("resourceId")); + String kqDate = Util.null2String(params.get("kqDate")); + String lastname = resourceComInfo.getLastname(resourceId); + + dialogTitle = lastname + " " + kqDate + " " + new KQTransMethod().getRelatedDayName(kqDate, "" + user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(25988, user.getLanguage()); + + userInfo.put("lastname", lastname); + userInfo.put("shortname", User.getLastname(Util.null2String(Util.formatMultiLang(lastname, "" + user.getLanguage())))); + userInfo.put("messagerurl", resourceComInfo.getMessagerUrls(resourceId)); + + String groupId = ""; + String kqType = ""; + int attendanceMins = 0; + sql = "select groupid, attendanceMins from kq_format_total where resourceid=? and kqdate=? "; + rs.executeQuery(sql, resourceId, kqDate); + if (rs.next()) { + groupId = Util.null2String(rs.getString("groupid")); + kqType = kqGroupComInfo.getKqtype(groupId); + attendanceMins += rs.getInt("attendanceMins"); + if (attendanceMins < 0) attendanceMins = 0; + } + + if (kqType.equals("3")) { + column = new HashMap<>(); + column.put("title", SystemEnv.getHtmlLabelName(413, user.getLanguage())); + column.put("dataIndex", "lastname"); + column.put("key", "lastname"); + columns.add(column); + + column = new HashMap<>(); + column.put("title", SystemEnv.getHtmlLabelName(18949, user.getLanguage())); + column.put("dataIndex", "signtime"); + column.put("key", "signtime"); + columns.add(column); + + column = new HashMap<>(); + column.put("title", SystemEnv.getHtmlLabelName(506115, user.getLanguage())); + column.put("dataIndex", "signfrom"); + column.put("key", "signfrom"); + columns.add(column); + + column = new HashMap<>(); + column.put("title", SystemEnv.getHtmlLabelName(390501, user.getLanguage())); + column.put("dataIndex", "addr"); + column.put("key", "addr"); + columns.add(column); + + column = new HashMap<>(); + column.put("title", SystemEnv.getHtmlLabelName(32531, user.getLanguage())); + column.put("dataIndex", "clientaddress"); + column.put("key", "clientaddress"); + columns.add(column); + + String serailName = SystemEnv.getHtmlLabelName(16039, user.getLanguage()) + kqGroupComInfo.getSignstart(groupId) + "," + + SystemEnv.getHtmlLabelName(390053, user.getLanguage()) + kqGroupComInfo.getWorkhour(groupId) + SystemEnv.getHtmlLabelName(391, user.getLanguage()); + +// 弹性工作制是否可以跨天 + boolean isFreezeAcross = KQSettingsBiz.is_freeAcross(); + + String signBeginDateTime = kqDate + " " + kqGroupComInfo.getSignstart(groupId) + ":00"; + String signEndDateTime = kqDate + " " + "23:59:59"; + if (isFreezeAcross) { + signEndDateTime = DateUtil.addDate(kqDate, 1) + " " + kqGroupComInfo.getSignstart(groupId) + ":00"; + } + String sqlwhere = " where userid = ? and signdate= ? "; + if (rs.getDBType().equals("oracle")) { + sqlwhere = " where userid = ? and signdate||' '||signtime >= ? and signdate||' '||signtime <= ? "; + } else if ("sqlserver".equals(rs.getDBType())) { + sqlwhere = " where userid = ? and signdate + ' ' + signtime >= ? and signdate + ' ' + signtime <= ? "; + } else { + sqlwhere = " where userid = ? and concat(signdate,' ',signtime) >= ? and concat(signdate,' ',signtime) <= ? "; + } + String groupName = ""; + int signCount = 0; + sql = " select * from hrmschedulesign " + sqlwhere + + " order by signdate asc, signtime asc "; + rs.executeQuery(sql, resourceId, signBeginDateTime, signEndDateTime); + signCount = rs.getCounts(); + while (rs.next()) { + data = new HashMap<>(); + data.put("lastname", lastname); + data.put("signtime", Util.null2String(rs.getString("signtime"))); + String signfrom = Util.null2String(rs.getString("signfrom")); + data.put("signfrom", kqTransMethod.getSignFromShow(signfrom, "" + user.getLanguage())); + data.put("addr", Util.null2String(rs.getString("addr"))); + data.put("clientaddress", Util.null2String(rs.getString("clientaddress"))); + datas.add(data); + + } + groupName = kqGroupComInfo.getGroupname(groupId); + userInfo.put("schedual", SystemEnv.getHtmlLabelName(390221, user.getLanguage()) + ":" + groupName); + signInfo.put("signInfo", SystemEnv.getHtmlLabelName(519601, user.getLanguage()). + replace("$signCount$", "" + signCount).replace("$workHour$", transMethod.getReportDetialMinToHour("" + attendanceMins)).replace("\"", "")); + userInfo.put("shiftInfo", SystemEnv.getHtmlLabelName(24803, user.getLanguage()) + ":" + serailName); + } else { + column = new HashMap<>(); + column.put("title", SystemEnv.getHtmlLabelName(27961, user.getLanguage())); + column.put("dataIndex", "workTime"); + column.put("key", "workTime"); + columns.add(column); + + column = new HashMap<>(); + column.put("title", SystemEnv.getHtmlLabelName(18949, user.getLanguage())); + column.put("dataIndex", "signTime"); + column.put("key", "signTime"); + columns.add(column); + + column = new HashMap<>(); + column.put("title", SystemEnv.getHtmlLabelName(506115, user.getLanguage())); + column.put("dataIndex", "signfrom"); + column.put("key", "signfrom"); + columns.add(column); + + column = new HashMap<>(); + column.put("title", SystemEnv.getHtmlLabelName(525243, user.getLanguage())); + column.put("dataIndex", "signStatus"); + column.put("key", "signStatus"); + columns.add(column); + + column = new HashMap<>(); + column.put("title", SystemEnv.getHtmlLabelName(390501, user.getLanguage())); + column.put("dataIndex", "addr"); + column.put("key", "addr"); + columns.add(column); + + String serailName = ""; + String workSections = ""; + String groupName = ""; + int signCount = 0; + sql = " select kqdate, resourceid,groupid,day_type,serialid,serialnumber,workbegindate,workbegintime, " + + " workenddate,workendtime,workmins,signindate,signintime,signinid,signoutdate,signouttime,signoutid, " + + " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins," + + " forgotcheckmins,forgotBeginWorkCheckMins,leaveMins,leaveInfo,evectionMins,outMins,otherinfo,flowinfo,on_absenteeismmins,off_absenteeismmins " + + " from kq_format_detail b " + + " where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' " + + " order by serialnumber "; + rs.execute(sql); + while (rs.next()) { + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + String resourceid = Util.null2String(rs.getString("resourceid")); + String kqdate = Util.null2String(rs.getString("kqdate")); + String groupid = Util.null2String(rs.getString("groupid")); + String serialid = Util.null2String(rs.getString("serialid")); + String workbegindate = Util.null2String(rs.getString("workbegindate")).trim(); + String workbegintime = Util.null2String(rs.getString("workbegintime")).trim(); + String workenddate = Util.null2String(rs.getString("workenddate")).trim(); + String workendtime = Util.null2String(rs.getString("workendtime")).trim(); + int workMins = rs.getInt("workMins"); + String signinid = Util.null2String(rs.getString("signinid")).trim(); + String signintime = Util.null2String(rs.getString("signintime")).trim(); + String signoutid = Util.null2String(rs.getString("signoutid")).trim(); + String signouttime = Util.null2String(rs.getString("signouttime")).trim(); + //attendanceMins += rs.getInt("attendanceMins"); + String beLateMins = Util.null2String(rs.getString("beLateMins")).trim(); + String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")).trim(); + String leaveEarlyMins = Util.null2String(rs.getString("leaveEarlyMins")).trim(); + String graveLeaveEarlyMins = Util.null2String(rs.getString("graveLeaveEarlyMins")).trim(); + String absenteeismMins = Util.null2String(rs.getString("absenteeismMins")).trim(); + String forgotCheckMins = Util.null2String(rs.getString("forgotCheckMins")).trim(); + String forgotBeginWorkCheckMins = Util.null2String(rs.getString("forgotBeginWorkCheckMins")).trim(); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = Util.null2String(rs.getString("leaveInfo")); + String otherinfo = Util.null2String(rs.getString("otherinfo")); + String dayType = Util.null2s(rs.getString("day_type"), ""); + String flowinfo = Util.null2String(rs.getString("flowinfo")); + String on_absenteeismmins = Util.null2String(rs.getString("on_absenteeismmins")); + String off_absenteeismmins = Util.null2String(rs.getString("off_absenteeismmins")); + boolean isNonWork = false; + if (dayType.length() > 0) { + if ("holiday".equals(dayType) || "playday".equals(dayType)) { + isNonWork = true; + } + } else { + if (workMins <= 0) { + isNonWork = true; + } else { + if (serialid.length() > 0) { + String isRest = Util.null2s(kqShiftManagementComInfo.getIsRest(serialid), ""); + if ("1".equals(isRest)) { + isNonWork = true; + } + } + } + } + if (otherinfo.length() > 0) { + Map jsonObject = JSON.parseObject(otherinfo); + if (jsonObject.containsKey("logList")) { + logList = (List) jsonObject.get("logList"); + } + } + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + + serailName = kqShiftManagementComInfo.getSerial(serialid); + if (workbegintime.length() > 0 && workendtime.length() > 0) { + workSections += workbegintime + "-" + workendtime; + } + groupName = kqGroupComInfo.getGroupname(groupid); + userInfo.put("schedual", SystemEnv.getHtmlLabelName(390221, user.getLanguage()) + ":" + groupName); + + + if (signintime.length() > 0) signCount++; + if (signouttime.length() > 0) signCount++; + + if (!isNonWork) { + if (workbegintime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("workdate", workbegindate); + signStatusInfo.put("worktime", workbegintime); + signStatusInfo.put("signtime", signintime); + signStatusInfo.put("beLateMins", beLateMins); + signStatusInfo.put("forgotBeginWorkCheckMins", forgotBeginWorkCheckMins); + signStatusInfo.put("graveBeLateMins", graveBeLateMins); + signStatusInfo.put("absenteeismMins", absenteeismMins); + signStatusInfo.put("leaveMins", leaveMins); + signStatusInfo.put("leaveInfo", leaveInfo); + signStatusInfo.put("evectionMins", evectionMins); + signStatusInfo.put("outMins", outMins); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("on_absenteeismmins",on_absenteeismmins); + signStatusInfo.put("off_absenteeismmins",off_absenteeismmins); + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); + + data = new HashMap<>(); + data.put("workTime", workbegintime); + data.put("signTime", signintime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signintime); + data.put("signStatus", KQReportBiz.getSignStatus(signStatusInfo, user, "on")); + Map signDetailInfo = getSignDetailInfo(signinid); + data.put("signfrom", kqTransMethod.getSignFromShow(Util.null2String(signDetailInfo.get("signfrom")), "" + user.getLanguage())); + data.put("addr", Util.null2String(signDetailInfo.get("addr"))); + datas.add(data); + } + + if (workendtime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("workdate", workenddate); + signStatusInfo.put("worktime", kqTimesArrayComInfo.turn48to24Time(workendtime)); + signStatusInfo.put("signtime", signouttime); + signStatusInfo.put("leaveEarlyMins", leaveEarlyMins); + signStatusInfo.put("graveLeaveEarlyMins", graveLeaveEarlyMins); + signStatusInfo.put("forgotCheckMins", forgotCheckMins); + signStatusInfo.put("absenteeismMins", absenteeismMins); + signStatusInfo.put("leaveMins", leaveMins); + signStatusInfo.put("leaveInfo", leaveInfo); + signStatusInfo.put("evectionMins", evectionMins); + signStatusInfo.put("outMins", outMins); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("on_absenteeismmins",on_absenteeismmins); + signStatusInfo.put("off_absenteeismmins",off_absenteeismmins); + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); + + data = new HashMap<>(); + data.put("workTime", kqTimesArrayComInfo.turn48to24Time(workendtime)); + data.put("signTime", signouttime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signouttime); + data.put("signStatus", KQReportBiz.getSignStatus(signStatusInfo, user, "off")); + Map signDetailInfo = getSignDetailInfo(signoutid); + data.put("signfrom", kqTransMethod.getSignFromShow(Util.null2String(signDetailInfo.get("signfrom")), "" + user.getLanguage())); + data.put("addr", Util.null2String(signDetailInfo.get("addr"))); + datas.add(data); + } + } else { + signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("leaveMins", leaveMins); + signStatusInfo.put("leaveInfo", leaveInfo); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("evectionMins", evectionMins); + signStatusInfo.put("outMins", outMins); + signStatusInfo.put("on_absenteeismmins",on_absenteeismmins); + signStatusInfo.put("off_absenteeismmins",off_absenteeismmins); + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); + signStatusInfo.put("isNonWork",isNonWork); + + if (signinid.length() > 0) { + data = new HashMap<>(); + data.put("signStatus", KQReportBiz.getSignStatus(signStatusInfo, user, "on")); + data.put("signTime", signintime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signintime); + Map signDetailInfo = getSignDetailInfo(signinid); + data.put("signfrom", kqTransMethod.getSignFromShow(Util.null2String(signDetailInfo.get("signfrom")), "" + user.getLanguage())); + data.put("addr", Util.null2String(signDetailInfo.get("addr"))); + datas.add(data); + if (signoutid.length() > 0) { + data = new HashMap<>(); + data.put("signStatus", KQReportBiz.getSignStatus(signStatusInfo, user, "off")); + data.put("signTime", signouttime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signouttime); + signDetailInfo = getSignDetailInfo(signoutid); + data.put("signfrom", kqTransMethod.getSignFromShow(Util.null2String(signDetailInfo.get("signfrom")), "" + user.getLanguage())); + data.put("addr", Util.null2String(signDetailInfo.get("addr"))); + datas.add(data); + }else{ + data = new HashMap<>(); + data.put("signStatus", KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + datas.add(data); + } + } else if (signoutid.length() > 0) { + data = new HashMap<>(); + data.put("signStatus", KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + datas.add(data); + data = new HashMap<>(); + data.put("signStatus", KQReportBiz.getSignStatus(signStatusInfo, user, "off")); + data.put("signTime", signouttime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signouttime); + Map signDetailInfo = getSignDetailInfo(signoutid); + data.put("signfrom", kqTransMethod.getSignFromShow(Util.null2String(signDetailInfo.get("signfrom")), "" + user.getLanguage())); + data.put("addr", Util.null2String(signDetailInfo.get("addr"))); + datas.add(data); + } else { + data = new HashMap<>(); + data.put("signStatus", KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + datas.add(data); + data = new HashMap<>(); + data.put("signStatus", KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + datas.add(data); +// data = new HashMap<>(); +// String signStatus = KQReportBiz.getSignStatus(signStatusInfo, user, "on"); +// if (StringUtil.isNotNull(signStatus)) { +// data.put("signStatus", signStatus); +// datas.add(data); +// } + } + } + } + if (workSections.length() > 0) { + serailName += "(" + workSections + ")"; + } + String minToHour = transMethod.getReportDetialMinToHour("" + attendanceMins); + signInfo.put("signInfo", SystemEnv.getHtmlLabelName(519601, user.getLanguage()).toLowerCase(). + replace("$signcount$", "" + signCount). + replace("$signcount $", "" + signCount). + replace("$workhour$", minToHour).replace("$workhour $", minToHour).replace("\"", "")); + userInfo.put("shiftInfo", SystemEnv.getHtmlLabelName(24803, user.getLanguage()) + ":" + serailName); + } + + table.put("columns", columns); + table.put("datas", datas); + + retmap.put("dialogTitle", dialogTitle); + retmap.put("userInfo", userInfo); + retmap.put("signInfo", signInfo); + retmap.put("table", table); + if (logList != null) { + retmap.put("logList", logList); + } + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private Map getSignDetailInfo(String id) { + Map resultMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + sql = " select signfrom,addr from hrmschedulesign where id = ? "; + rs.executeQuery(sql, id); + if (rs.next()) { + resultMap.put("addr", Util.null2String(rs.getString("addr"))); + resultMap.put("signfrom", Util.null2String(rs.getString("signfrom"))); + } + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportdetial/GetForgotCheckInfoCmd.java b/src/com/engine/kq/cmd/reportdetial/GetForgotCheckInfoCmd.java new file mode 100644 index 0000000..f1b65ea --- /dev/null +++ b/src/com/engine/kq/cmd/reportdetial/GetForgotCheckInfoCmd.java @@ -0,0 +1,162 @@ +package com.engine.kq.cmd.reportdetial; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.hrm.util.HrmUtil; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.enums.ReportColumnEnum; +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.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/*** + * 漏签明细 + */ +public class GetForgotCheckInfoCmd extends AbstractCommonCommand> { + + public GetForgotCheckInfoCmd(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 dialogTitle = SystemEnv.getHtmlLabelName(20091,user.getLanguage()); + String resourceId = Util.null2String(params.get("resourceId")); + String keyWord = Util.null2String(params.get("keyWord")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.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 viewScope = Util.null2String(params.get("viewScope")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + + String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid, serialid as serialid1, serialid as serialid2," + + " workbegintime,workendtime, signintime,signouttime,case when forgotcheckmins> 0 then 1 when forgotBeginWorkCheckMins> 0 then 1 else 0 end as forgotcheck " ; + + String sqlFrom = "from hrmresource a, kq_format_detail b "; + String sqlWhere = " where a.id = b.resourceid and (forgotCheckMins>0 or forgotBeginWorkCheckMins>0)"; + String orderby = " b.resourceid,b.kqdate asc,b.serialnumber, b.workbegintime asc " ; + String tableString = ""; + + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a"); + if(rightSql.length()>0){ + sqlWhere += rightSql; + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if (fromDate.length() > 0){ + sqlWhere += " and kqdate >= '"+fromDate+"'"; + } + + if (toDate.length() > 0){ + sqlWhere += " and kqdate <= '"+toDate+"'"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if (resourceId.length() > 0){ + sqlWhere += " and b.resourceid in ( "+resourceId+")"; + } + + if(resourceStatus.length()>0){ + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sqlWhere += " and a.status = "+resourceStatus+ ""; + }else if (resourceStatus.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + 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<>'' "); + } + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList"); + + tableString=""+ + ""+ + ""+ + ""+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + ""+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + retmap.put("dialogTitle",dialogTitle); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportdetial/GetLeaveEearlyInfoCmd.java b/src/com/engine/kq/cmd/reportdetial/GetLeaveEearlyInfoCmd.java new file mode 100644 index 0000000..723a05e --- /dev/null +++ b/src/com/engine/kq/cmd/reportdetial/GetLeaveEearlyInfoCmd.java @@ -0,0 +1,177 @@ +package com.engine.kq.cmd.reportdetial; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.hrm.util.HrmUtil; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.enums.ReportColumnEnum; +import com.engine.kq.util.PageUidFactory; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/*** + * 早退相关信息 + */ +public class GetLeaveEearlyInfoCmd extends AbstractCommonCommand> { + + public GetLeaveEearlyInfoCmd(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 dialogTitle = SystemEnv.getHtmlLabelName(20089, user.getLanguage()); + String tabKey = Util.null2String(params.get("tabKey")); + String resourceId = Util.null2String(params.get("resourceId")); + String keyWord = Util.null2String(params.get("keyWord")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.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 viewScope = Util.null2String(params.get("viewScope")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + String formula = Util.null2String(params.get("formula")); + + String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid, serialid as serialid1," + + " workbegintime,workendtime, signintime,signouttime, leaveEarlyMins, graveLeaveEarlyMins "; + String sqlFrom = "from hrmresource a, kq_format_detail b "; + String sqlWhere = " where a.id = b.resourceid"; + String orderby = " kqdate asc, workbegintime asc " ; + String tableString = ""; + + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a"); + if(rightSql.length()>0){ + sqlWhere += rightSql; + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if (fromDate.length() > 0){ + sqlWhere += " and kqdate >= '"+fromDate+"'"; + } + + if (toDate.length() > 0){ + sqlWhere += " and kqdate <= '"+toDate+"'"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if (resourceId.length() > 0){ + sqlWhere += " and b.resourceid in ( "+resourceId+")"; + } + + if(resourceStatus.length()>0){ + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sqlWhere += " and a.status = "+resourceStatus+ ""; + }else if (resourceStatus.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + 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<>'' "); + } + + if(tabKey.equals("2")){ + sqlWhere += " and graveLeaveEarlyMins>0 "; + }else{ + sqlWhere += " and leaveEarlyMins>0 "; + } + + if(formula.length()>0){ + formula = formula.replace("${leaveEarlyMins}>","").replace("${leaveEarlyMins}<=","").replace("?1:0","").replace(" && ","-"); + String[] tmpValue = Util.splitString(formula,"-"); + sqlWhere += " and leaveEarlyMins>"+tmpValue[0]+" and leaveEarlyMins<= "+tmpValue[1]; + } + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList"); + + tableString=""+ + ""+ + ""+ + ""+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "; + if(tabKey.equals("2")){ + tableString += " "; + }else{ + tableString += " "; + } + tableString += ""+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + retmap.put("dialogTitle",dialogTitle); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportdetial/GetLeaveInfoCmd.java b/src/com/engine/kq/cmd/reportdetial/GetLeaveInfoCmd.java new file mode 100644 index 0000000..941b406 --- /dev/null +++ b/src/com/engine/kq/cmd/reportdetial/GetLeaveInfoCmd.java @@ -0,0 +1,86 @@ +package com.engine.kq.cmd.reportdetial; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQAttFlowSetBiz; +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.enums.ReportColumnEnum; +import com.engine.kq.util.PageUidFactory; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/*** + * 请假信息 + */ +public class GetLeaveInfoCmd extends AbstractCommonCommand> { + + public GetLeaveInfoCmd(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 dialogTitle = ""; + String type = Util.null2String(params.get("type")); + if(type.equals("leave")||type.startsWith("leaveType_")){//请假 + dialogTitle = SystemEnv.getHtmlLabelName(20092, user.getLanguage()); + if(type.startsWith("leaveType_")) { + String[] typeInfo = Util.splitString(type, "_"); + if (typeInfo[0].equals("leaveType")) { + params.put("kqtype", KqSplitFlowTypeEnum.LEAVE.getFlowtype()); + } + params.put("newleavetype", typeInfo[1]); + }else{ + params.put("kqtype", KqSplitFlowTypeEnum.LEAVE.getFlowtype()); + } + }else{ + if(type.equals("overtimeTotal")){//加班 + dialogTitle = SystemEnv.getHtmlLabelName(33501, user.getLanguage()); + params.put("kqtype",KqSplitFlowTypeEnum.OVERTIME.getFlowtype()); + }else if(type.equals("businessLeave")){//出差 + dialogTitle = SystemEnv.getHtmlLabelName(20093, user.getLanguage()); + params.put("kqtype",KqSplitFlowTypeEnum.EVECTION.getFlowtype()); + }else if(type.equals("officialBusiness")){//公出 + dialogTitle = SystemEnv.getHtmlLabelName(20094, user.getLanguage()); + params.put("kqtype",KqSplitFlowTypeEnum.OUT.getFlowtype()); + }else if(type.equals("leaveDeduction")){//异常冲抵 + dialogTitle = SystemEnv.getHtmlLabelName(391404, user.getLanguage()); + params.put("kqtype",KqSplitFlowTypeEnum.OTHER.getFlowtype()); + } + } + + retmap.put("dialogTitle",dialogTitle); + retmap.put("sessionkey",new KQAttFlowSetBiz().buildFlowSetTableString(params, user)); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportdetial/GetNeedSignInfoCmd.java b/src/com/engine/kq/cmd/reportdetial/GetNeedSignInfoCmd.java new file mode 100644 index 0000000..a901f8c --- /dev/null +++ b/src/com/engine/kq/cmd/reportdetial/GetNeedSignInfoCmd.java @@ -0,0 +1,236 @@ +package com.engine.kq.cmd.reportdetial; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.enums.ReportColumnEnum; +import com.engine.kq.util.PageUidFactory; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/*** + * 应出勤 + */ +public class GetNeedSignInfoCmd extends AbstractCommonCommand> { + + public GetNeedSignInfoCmd(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{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("BohaiInsuranceScheduleReport:View",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String dataIndex = Util.null2String(params.get("dataIndex")); + + Map tableInfo = new HashMap(); + String dialogTitle = ""; + List tabs =new ArrayList(); + List sessionKeys = new ArrayList(); + dialogTitle = SystemEnv.getHtmlLabelName(20088, user.getLanguage()); + if(dataIndex.equals(ReportColumnEnum.BELATE.getName())){ + tabs.add(SystemEnv.getHtmlLabelName(20088, user.getLanguage())); + tabs.add(SystemEnv.getHtmlLabelName(390520, user.getLanguage())); + sessionKeys.add(getBeLateInfo()); + sessionKeys.add(getGraveBeLateMinsInfo()); + } + + tableInfo.put("dialogTitle",dialogTitle); + tableInfo.put("tabs",tabs); + tableInfo.put("sessionkeys",sessionKeys); + retmap.put("tableInfo", tableInfo); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + + private String getBeLateInfo(){ + String sessionkey = ""; + try{ + String dataIndex = Util.null2String(params.get("dataIndex")); + String resourceId = Util.null2String(params.get("resourceId")); + String keyWord = Util.null2String(params.get("keyWord")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.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 backFields = " id, resourceid,departmentid, lastname, workcode, status, dsporder, kqdate, serialid, workbegindate1,workbegintime1,workbegindate2,workbegintime2,workbegindate3,workbegintime3, signdate,signtime,beLateMins "; + String sqlFrom = " (select b.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, b.kqdate, b.serialid, b.workbegindate1 as workbegindate,b.workbegintime1 as workbegintime,b.signindate1 as signdate,b.signintime1 as signtime,beLateMins1 as beLateMins " + + " from hrmresource a, kq_format b where a.id = b.resourceid and kqdate >= '"+fromDate+"' and kqdate <= '"+toDate+"' and beLateMins1>0 " + + " UNION ALL " + + " select b.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, b.kqdate, b.serialid, b.workbegindate2 as workbegindate,b.workbegintime2,b.signindate2 as signdate,b.signintime2 as signtime,beLateMins2 as beLateMins " + + " from hrmresource a, kq_format b where a.id = b.resourceid and kqdate >= '"+fromDate+"' and kqdate <= '"+toDate+"' and beLateMins2>0 " + + " UNION ALL " + + " select b.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, b.kqdate, b.serialid, b.workbegindate3 as workbegindate,b.workbegintime3,b.signindate3 as signdate,b.signintime3 as signtime,beLateMins3 as beLateMins " + + " from hrmresource a, kq_format b where a.id = b.resourceid and kqdate >= '"+fromDate+"' and kqdate <= '"+toDate+"' and beLateMins3>0 ) t"; + String sqlWhere = " where 1=1 "; + String orderby = " dsporder " ; + String tableString = ""; + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if (fromDate.length() > 0){ + sqlWhere += " and kqdate >= '"+fromDate+"'"; + } + + if (toDate.length() > 0){ + sqlWhere += " and kqdate <= '"+toDate+"'"; + } + + if (resourceId.length() > 0){ + sqlWhere += " and resourceid in ( "+resourceId+")"; + } + + String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList"); + + String operateString= ""; + operateString+=" "; + operateString+=" "; + operateString+=" "; + operateString+=""; + tableString=""+ + ""+ + ""+ + //operateString+ + ""+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + ""+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + }catch (Exception e){ + writeLog(e); + } + return sessionkey; + } + + private String getGraveBeLateMinsInfo(){ + String sessionkey = ""; + try{ + String dataIndex = Util.null2String(params.get("dataIndex")); + String resourceId = Util.null2String(params.get("resourceId")); + String keyWord = Util.null2String(params.get("keyWord")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.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 backFields = " id, resourceid,departmentid, lastname, workcode, status, dsporder, kqdate, serialid, workbegindate1,workbegintime1,workbegindate2,workbegintime2,workbegindate3,workbegintime3, signdate,signtime,beLateMins "; + String sqlFrom = " (select b.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, b.kqdate, b.serialid, b.workbegindate1,b.workbegintime1,b.workbegindate2,b.workbegintime2,b.workbegindate3,b.workbegintime3,b.signindate1 as signdate,b.signintime1 as signtime,beLateMins1 as beLateMins " + + " from hrmresource a, kq_format b where a.id = b.resourceid and kqdate >= '"+fromDate+"' and kqdate <= '"+toDate+"' and graveBeLateMins>0 " + + " UNION ALL " + + " select b.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, b.kqdate, b.serialid, b.workbegindate1,b.workbegintime1,b.workbegindate2,b.workbegintime2,b.workbegindate3,b.workbegintime3,b.signindate2 as signdate,b.signintime2 as signtime,beLateMins2 as beLateMins " + + " from hrmresource a, kq_format b where a.id = b.resourceid and kqdate >= '"+fromDate+"' and kqdate <= '"+toDate+"' and graveBeLateMins>0 " + + " UNION ALL " + + " select b.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, b.kqdate, b.serialid, b.workbegindate1,b.workbegintime1,b.workbegindate2,b.workbegintime2,b.workbegindate3,b.workbegintime3,b.signindate3 as signdate,b.signintime3 as signtime,beLateMins3 as beLateMins " + + " from hrmresource a, kq_format b where a.id = b.resourceid and kqdate >= '"+fromDate+"' and kqdate <= '"+toDate+"' and graveBeLateMins>0 ) t"; + String sqlWhere = " where 1=1 "; + String orderby = " dsporder " ; + String tableString = ""; + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if (fromDate.length() > 0){ + sqlWhere += " and kqdate >= '"+fromDate+"'"; + } + + if (toDate.length() > 0){ + sqlWhere += " and kqdate <= '"+toDate+"'"; + } + + if (resourceId.length() > 0){ + sqlWhere += " and resourceid = "+resourceId; + } + + String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList"); + + String operateString= ""; + operateString+=" "; + operateString+=" "; + operateString+=" "; + operateString+=""; + tableString=""+ + ""+ + ""+ + //operateString+ + ""+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + ""+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + }catch (Exception e){ + writeLog(e); + } + return sessionkey; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportdetial/GetSignInfoCmd.java b/src/com/engine/kq/cmd/reportdetial/GetSignInfoCmd.java new file mode 100644 index 0000000..9122521 --- /dev/null +++ b/src/com/engine/kq/cmd/reportdetial/GetSignInfoCmd.java @@ -0,0 +1,167 @@ +package com.engine.kq.cmd.reportdetial; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.hrm.util.HrmUtil; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.enums.ReportColumnEnum; +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.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/*** + * 应出勤明细 + */ +public class GetSignInfoCmd extends AbstractCommonCommand> { + + public GetSignInfoCmd(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 dialogTitle = SystemEnv.getHtmlLabelName(391409,user.getLanguage()); + String resourceId = Util.null2String(params.get("resourceId")); + String keyWord = Util.null2String(params.get("keyWord")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.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 viewScope = Util.null2String(params.get("viewScope")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + String type = Util.null2String(params.get("type")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + + String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid,serialid as serialid1, serialid as serialid2," + + " workbegintime,workendtime,signintime,signouttime, attendanceMins, signMins "; + String sqlFrom = "from hrmresource a, kq_format_detail b "; + String sqlWhere = " where a.id = b.resourceid and (attendanceMins>0 or signMins>0)"; + String orderby = " kqdate asc, workbegintime asc " ; + String tableString = ""; + + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a"); + if(rightSql.length()>0){ + sqlWhere += rightSql; + } + + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if (fromDate.length() > 0){ + sqlWhere += " and kqdate >= '"+fromDate+"'"; + } + + if (toDate.length() > 0){ + sqlWhere += " and kqdate <= '"+toDate+"'"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if (resourceId.length() > 0){ + sqlWhere += " and b.resourceid in ( "+resourceId+")"; + } + + if(resourceStatus.length()>0){ + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sqlWhere += " and a.status = "+resourceStatus+ ""; + }else if (resourceStatus.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + 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<>'' "); + } + + if (type.equals("signdays")||type.equals("signmins")) { + sqlWhere += " and signmins >0 "; + } + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList"); + + tableString=""+ + ""+ + ""+ + ""+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + ""+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + retmap.put("dialogTitle",dialogTitle); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportdetial/GetTabsCmd.java b/src/com/engine/kq/cmd/reportdetial/GetTabsCmd.java new file mode 100644 index 0000000..92f0010 --- /dev/null +++ b/src/com/engine/kq/cmd/reportdetial/GetTabsCmd.java @@ -0,0 +1,109 @@ +package com.engine.kq.cmd.reportdetial; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.enums.OverTimeComputingModeEnum; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 考勤报表明细tabs + * @author pzy + * + */ +public class GetTabsCmd extends AbstractCommonCommand>{ + + public GetTabsCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try { + List> tabs = new ArrayList>(); + Map tab = null; + + //必要的权限判断 +// if(!HrmUserVarify.checkUserRight("BohaiInsuranceScheduleReport:View",user)) { +// retmap.put("status", "-1"); +// retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); +// return retmap; +// } + + String type = Util.null2String(params.get("type")); + + if(type.equals("beLate")||type.equals("beLateMins")|| + type.equals("graveBeLate")||type.equals("graveBeLateMins")){ + tab = new HashMap(); + tab.put("key", "1"); + tab.put("selected",type.equals("beLate")||type.equals("beLateMins")); + tab.put("title", SystemEnv.getHtmlLabelName(20088,user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", "2"); + tab.put("selected",type.equals("graveBeLate")||type.equals("graveBeLateMins")); + tab.put("title", SystemEnv.getHtmlLabelName(390520,user.getLanguage())); + tabs.add(tab); + }else if(type.equals("leaveEearly")||type.equals("leaveEarlyMins")|| + type.equals("graveLeaveEarly")||type.equals("graveLeaveEarlyMins")){ + tab = new HashMap(); + tab.put("key", "1"); + tab.put("selected",type.equals("leaveEearly")||type.equals("leaveEarlyMins")); + tab.put("title", SystemEnv.getHtmlLabelName(20089,user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", "2"); + tab.put("selected",type.equals("graveLeaveEarly")||type.equals("graveLeaveEarlyMins")); + tab.put("title", SystemEnv.getHtmlLabelName(391415,user.getLanguage())); + tabs.add(tab); + }else if(type.startsWith("leaveType_")|| + type.equals("businessLeave")||type.equals("officialBusiness")||type.equals("leave")){ + tab = new HashMap(); + tab.put("key", "1"); + tab.put("title", SystemEnv.getHtmlLabelName(18800,user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", "2"); + tab.put("title", SystemEnv.getHtmlLabelName(17999,user.getLanguage())); + tabs.add(tab); + }else if("overtimeTotal".equalsIgnoreCase(type)){ + OverTimeComputingModeEnum[] enums = OverTimeComputingModeEnum.values(); + for(int i = 0 ; enums != null && i < enums.length; i++){ + OverTimeComputingModeEnum overTimeComputingModeEnums = enums[i]; + tab = new HashMap(); + tab.put("key", overTimeComputingModeEnums.getComputingMode()); + tab.put("title", SystemEnv.getHtmlLabelNames(overTimeComputingModeEnums.getLabel(),user.getLanguage())); + tabs.add(tab); + } + } + + retmap.put("status", "1"); + retmap.put("tabs", tabs); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportdetial/GetWorkDayInfoCmd.java b/src/com/engine/kq/cmd/reportdetial/GetWorkDayInfoCmd.java new file mode 100644 index 0000000..59a9666 --- /dev/null +++ b/src/com/engine/kq/cmd/reportdetial/GetWorkDayInfoCmd.java @@ -0,0 +1,157 @@ +package com.engine.kq.cmd.reportdetial; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.hrm.util.HrmUtil; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.enums.ReportColumnEnum; +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.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/*** + * 应出勤明细 + */ +public class GetWorkDayInfoCmd extends AbstractCommonCommand> { + + public GetWorkDayInfoCmd(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 dialogTitle = SystemEnv.getHtmlLabelName(390956,user.getLanguage()); + String resourceId = Util.null2String(params.get("resourceId")); + String keyWord = Util.null2String(params.get("keyWord")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect =Util.null2String(params.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 viewScope = Util.null2String(params.get("viewScope")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + + String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, " + + " serialid, workmins, workbegintime,workendtime "; + String sqlFrom = "from hrmresource a, kq_format_detail b "; + String sqlWhere = " where a.id = b.resourceid and workmins>0 "; + String orderby = " kqdate asc, workbegintime asc " ; + String tableString = ""; + String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a"); + if(rightSql.length()>0){ + sqlWhere += rightSql; + } + if (keyWord.length() > 0){ + sqlWhere += " and lastname = "+keyWord; + } + + if (fromDate.length() > 0){ + sqlWhere += " and kqdate >= '"+fromDate+"'"; + } + + if (toDate.length() > 0){ + sqlWhere += " and kqdate <= '"+toDate+"'"; + } + + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if (resourceId.length() > 0){ + sqlWhere += " and b.resourceid in ( "+resourceId+")"; + } + + if(resourceStatus.length()>0){ + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sqlWhere += " and a.status = "+resourceStatus+ ""; + }else if (resourceStatus.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + 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<>'' "); + } + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求 + String transMethodString = HrmUtil.getKqDepartmentTransMethod(); + + String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList"); + + tableString=""+ + ""+ + ""+ + ""+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + ""+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + retmap.put("dialogTitle",dialogTitle); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/ChangeFieldGroupCmd.java b/src/com/engine/kq/cmd/reportfielddefine/ChangeFieldGroupCmd.java new file mode 100644 index 0000000..a4ff497 --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/ChangeFieldGroupCmd.java @@ -0,0 +1,82 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportFieldComInfo; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class ChangeFieldGroupCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + public ChangeFieldGroupCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQREPORT_DEFINED); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQREPORT_DEFINED); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String ids = Util.null2String(params.get("ids")); + String mainSql = " select * from kq_report_field where id in ("+ids+")"; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getLabelName"); + logger.setMethodOtherParams("column:fieldlabel+" + user.getLanguage()); + logger.before(logContext); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String sql = ""; + RecordSet rs = new RecordSet(); + try { + if (!HrmUserVarify.checkUserRight("KQReportFieldDefine:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String ids = Util.null2String(params.get("ids")); + List sqlParams = new ArrayList(); + Object[] objects= DBUtil.transListIn(ids,sqlParams); + String groupid = Util.null2String(params.get("groupid")); + if (ids.length() > 0 && groupid.length() > 0) { + sql = " update kq_report_field set groupid=? where id in ("+objects[0]+")"; + rs.executeUpdate(sql, groupid, sqlParams); + new KQReportFieldComInfo().removeCache(); + } + retmap.put("status", "1"); + } catch (Exception e) { + this.writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, this.user.getLanguage())); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/DeleteFieldDefineCmd.java b/src/com/engine/kq/cmd/reportfielddefine/DeleteFieldDefineCmd.java new file mode 100644 index 0000000..fb4c59c --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/DeleteFieldDefineCmd.java @@ -0,0 +1,97 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportFieldComInfo; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class DeleteFieldDefineCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + public DeleteFieldDefineCmd(Map params, User user) { + this.user = user; + this.params = params; + + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQREPORT_DEFINED); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQREPORT_DEFINED); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String ids = Util.null2String(params.get("ids")); + String mainSql = " select * from kq_report_field where id in ("+ids+")"; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getLabelName"); + logger.setMethodOtherParams("column:fieldlabel+" + user.getLanguage()); + logger.before(logContext); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String sql = ""; + RecordSet rs = new RecordSet(); + try { + if (!HrmUserVarify.checkUserRight("KQReportFieldDefine:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + String[] ids = Util.splitString(Util.null2String(params.get("ids")),","); + + for(int i=0;i getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/DeleteGroupCmd.java b/src/com/engine/kq/cmd/reportfielddefine/DeleteGroupCmd.java new file mode 100644 index 0000000..d0c3f48 --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/DeleteGroupCmd.java @@ -0,0 +1,98 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportFieldComInfo; +import com.engine.kq.biz.KQReportFieldGroupComInfo; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class DeleteGroupCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + SimpleBizLogger.SubLogInfo subLogInfo; + public DeleteGroupCmd(Map params, User user) { + this.user = user; + this.params = params; + + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQREPORT_DEFINED); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQREPORT_DEFINED); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String ids = Util.null2String(params.get("ids")); + String mainSql = " select * from kq_report_field_group where id in ("+ids+")"; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("groupname"); + + subLogInfo = logger.getNewSubLogInfo(); + String subSql = " select * from kq_report_field where groupid in ("+ids+")"; + subLogInfo.setSubSql(subSql); + subLogInfo.setSubPrimarykey("id"); + subLogInfo.setSubTargetNameMethod("com.engine.kq.util.KQTransMethod.getLabelName"); + subLogInfo.setSubMethodOtherParams("column:fieldlabel+" + user.getLanguage()); + subLogInfo.setGroupId("1"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo.setSubGroupNameLabel(33943); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo); + + logger.before(logContext); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String sql = ""; + RecordSet rs = new RecordSet(); + try { + if (!HrmUserVarify.checkUserRight("KQReportFieldDefine:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String ids = Util.null2String(params.get("ids")); + List sqlParams = new ArrayList(); + Object[] objects= DBUtil.transListIn(ids,sqlParams); + + sql = " update kq_report_field set groupid=null where groupid in ("+objects[0]+")"; + rs.executeUpdate(sql, sqlParams); + + sql = " delete from kq_report_field_group where id in ("+objects[0]+")"; + rs.executeUpdate(sql, sqlParams); + + new KQReportFieldComInfo().removeCache(); + new KQReportFieldGroupComInfo().removeCache(); + retmap.put("status", "1"); + } catch (Exception e) { + this.writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, this.user.getLanguage())); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/DeleteReportMoudleCmd.java b/src/com/engine/kq/cmd/reportfielddefine/DeleteReportMoudleCmd.java new file mode 100644 index 0000000..d0807c0 --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/DeleteReportMoudleCmd.java @@ -0,0 +1,54 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DeleteReportMoudleCmd extends AbstractCommonCommand> { + + public DeleteReportMoudleCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String sql = ""; + RecordSet rs = new RecordSet(); + try { + + String ids = Util.null2String(params.get("ids")); + + List sqlParams = new ArrayList(); + Object[] objects= DBUtil.transListIn(ids,sqlParams); + + sql = " delete from kq_report_moudle where id in ("+objects[0]+")"; + rs.executeUpdate(sql, sqlParams); + + retmap.put("status", "1"); + } catch (Exception e) { + this.writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, this.user.getLanguage())); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/GetFieldDefineFormCmd.java b/src/com/engine/kq/cmd/reportfielddefine/GetFieldDefineFormCmd.java new file mode 100644 index 0000000..7ab71ba --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/GetFieldDefineFormCmd.java @@ -0,0 +1,160 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.LabelUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class GetFieldDefineFormCmd extends AbstractCommonCommand> { + + public GetFieldDefineFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + RecordSet rs = new RecordSet(); + String sql = ""; + try { + //必要的权限判断 + if (!HrmUserVarify.checkUserRight("KQReportFieldDefine:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String id = Util.null2String(params.get("id")); + Map> fieldGroups = new LinkedHashMap>(); + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + List options = null; + + String fieldname = "";//字段名 + String fieldlabel = "";//展示列名称 + String fieldtype = "1";//类型 + String fieldvalue = "";//区间(分钟) + + if (id.length() > 0) { + sql = "select * from kq_report_field where id=?"; + rs.executeQuery(sql, id); + if (rs.next()) { + fieldname = Util.null2String(rs.getString("fieldname")); + fieldlabel = Util.null2String(rs.getString("fieldlabel")); + fieldtype = Util.null2String(rs.getString("formula")).indexOf("beLateMins")>-1?"1":"2"; + fieldvalue = Util.null2String(rs.getString("formula")); + fieldvalue = fieldvalue.replace("${beLateMins}>","").replace("${beLateMins}<=","").replace("?1:0","").replace(" && ","-"); + fieldvalue = fieldvalue.replace("${leaveEarlyMins}>","").replace("${leaveEarlyMins}<=","").replace("?1:0","").replace(" && ","-"); + } + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("fieldlabel"); + hrmFieldBean.setFieldlabel("516154"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(LabelUtil.getMultiLangLabel(fieldlabel)); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setMultilang(true); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setRules("required|string"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("fieldname"); + hrmFieldBean.setFieldlabel("685"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(fieldname); + hrmFieldBean.setViewAttr(id.length()>0?1:3); + hrmFieldBean.setMultilang(false); + hrmFieldBean.setRules("required|string"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("fieldtype"); + hrmFieldBean.setFieldlabel("63"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(fieldtype); + + options = new ArrayList(); + options.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(20081, user.getLanguage()), fieldtype.equals("1"))); + options.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(20082, user.getLanguage()), fieldtype.equals("2"))); + hrmFieldBean.setSelectOption(options); + hrmFieldBean.setViewAttr(2); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("fieldvalue"); + hrmFieldBean.setFieldlabel("516156"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(fieldvalue); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setMultilang(false); + hrmFieldBean.setRules("required|string"); + lsField.add(hrmFieldBean); + fieldGroups.put("20331", lsField); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("msg"); + hrmFieldBean.setFieldlabel("85"); + hrmFieldBean.setFieldhtmltype("8"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(SystemEnv.getHtmlLabelName(516157, user.getLanguage())); + lsField.add(hrmFieldBean); + fieldGroups.put("20331", lsField); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + Iterator>> iter = fieldGroups.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry> entry = iter.next(); + String grouplabel = entry.getKey(); + List fields = entry.getValue(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("defaultshow", true); + + itemlist = new ArrayList(); + for (int j = 0; j < fields.size(); j++) { + hrmFieldBean = fields.get(j); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + retmap.put("formField", grouplist); + retmap.put("id", id); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/GetFieldDefineListCmd.java b/src/com/engine/kq/cmd/reportfielddefine/GetFieldDefineListCmd.java new file mode 100644 index 0000000..d60adba --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/GetFieldDefineListCmd.java @@ -0,0 +1,182 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportFieldComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetFieldDefineListCmd extends AbstractCommonCommand> { + + public GetFieldDefineListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + if (!HrmUserVarify.checkUserRight("KQReportFieldDefine:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + RecordSet rs = new RecordSet(); + String sql = ""; + Map groupitem = null; + List itemlist = null; + try { + itemlist = new ArrayList(); + groupitem = new HashMap(); + + //生成字段的集合 + Map mapFields = new HashMap(); + mapFields.put("showTitle", false); + mapFields.put("draggable", true); + mapFields.put("columns", getColumns()); + mapFields.put("datas", getDatas()); + + groupitem.put("title", SystemEnv.getHtmlLabelName(1361, Util.getIntValue(user.getLanguage()))); + groupitem.put("table", mapFields); + itemlist.add(groupitem); + + retmap.put("items", itemlist); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + + return retmap; + } + + private List> getDatas() { + List> datasList = new ArrayList>(); + Map data = new HashMap(); + + String groupid = Util.null2String(params.get("groupid")); + if (groupid.equals("other")) groupid = ""; + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()) { + if (!kqReportFieldComInfo.getIsDefinedColumn().equals("1")) continue; + if (!Util.null2String(kqReportFieldComInfo.getGroupid()).equals(groupid)) continue; + if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month")) + continue; + if (Util.null2String(kqReportFieldComInfo.getParentid()).length() > 0) continue; + String id = kqReportFieldComInfo.getId(); + String fieldname = kqReportFieldComInfo.getFieldname(); + String fieldlabel = kqReportFieldComInfo.getFieldlabel(); + String isenable = kqReportFieldComInfo.getIsenable(); + String defaultshow = kqReportFieldComInfo.getDefaultShow(); + // #1276494 概述:满足薪酬指标项关联考勤报表列数据需求 By T.W +// String ifSalaryNeed = kqReportFieldComInfo.getIfSalaryNeed(); + String formula = kqReportFieldComInfo.getFormula(); + + String td0 = "id"; + String td1 = "fieldname"; + String td1span = "fieldnamespan"; + String td2 = "isenable"; + String td3 = "defaultshow"; +// String td5 = "ifSalaryNeed"; + String td4 = "formulaspan"; + + data = new HashMap(); + data.put("disabled", kqReportFieldComInfo.getIsSystem().equals("1")); + data.put(td0, id); + data.put(td1, fieldname); + data.put(td1span, SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage())); + data.put(td2, isenable); + data.put(td3, defaultshow); +// data.put(td5, ifSalaryNeed); + String formulaInfo = ""; + if (formula.length() > 0) { + formulaInfo = SystemEnv.getHtmlLabelName(63, user.getLanguage()) + ":"; + if (formula.indexOf("beLateMins") > -1) { + formulaInfo += SystemEnv.getHtmlLabelName(20081, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(516156, user.getLanguage()) + ":"; + } else { + formulaInfo += SystemEnv.getHtmlLabelName(20082, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(516156, user.getLanguage()) + ":"; + } + formula = formula.replace("${beLateMins}>", "").replace("${beLateMins}<=", "").replace("?1:0", "").replace(" && ", "-"); + formula = formula.replace("${leaveEarlyMins}>", "").replace("${leaveEarlyMins}<=", "").replace("?1:0", "").replace(" && ", "-"); + formulaInfo += formula; + } + data.put(td4, formulaInfo); + datasList.add(data); + } + + return datasList; + } + + private List> getColumns() { + List> columns = new ArrayList>(); + //显示列 + String td1 = "fieldnamespan,516154,1,1"; + //启用 + String td2 = "isenable,18095,4,1"; + //默认 + String td3 = "defaultshow,149,4,1"; + //是否作为薪资项 + // #1276494 概述:满足薪酬指标项关联考勤报表列数据需求 By T.W +// String td4 = "ifSalaryNeed,534579,4,1"; + //自定义显示列规则 + String td5 = "formulaspan,516134,1,1"; + + String[] fields = new String[]{td1, td2, td3, td5}; + Map col = null; + List comLists = new ArrayList(); + Map comMap = new HashMap(); + for (int i = 0; i < fields.length; i++) { + col = new HashMap(); + comMap = new HashMap(); + comLists = new ArrayList(); + String[] fieldinfo = fields[i].split(","); + String tmpkey = fieldinfo[0]; + + + col.put("title", SystemEnv.getHtmlLabelNames(fieldinfo[1], user.getLanguage())); + col.put("key", tmpkey); + col.put("dataIndex", tmpkey); + col.put("colSpan", 1); + if ("isenable".equals(fieldinfo[0]) || "defaultshow".equals(fieldinfo[0]) || "ifSalaryNeed".equals(fieldinfo[0])) { + comMap.put("label", ""); + comMap.put("type", "checkbox"); + comMap.put("key", tmpkey); + comMap.put("viewAttr", "2"); + comLists.add(comMap); + String[] checkVauleTypes = new String[]{"1", "0"}; + col.put("showCheckAll", true); + col.put("checkVauleType", checkVauleTypes); + col.put("width", "20%"); + col.put("com", comLists); + } + + if ("fieldnamespan".equals(fieldinfo[0]) || "formulaspan".equals(fieldinfo[0])) { + comMap.put("label", ""); + comMap.put("type", "TEXT"); + comMap.put("key", tmpkey); + comLists.add(comMap); + col.put("width", "formulaspan".equals(fieldinfo[0]) ? "40%" : "20%"); + col.put("com", comLists); + } + columns.add(col); + } + return columns; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/GetFieldDefineTabsCmd.java b/src/com/engine/kq/cmd/reportfielddefine/GetFieldDefineTabsCmd.java new file mode 100644 index 0000000..3f2a499 --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/GetFieldDefineTabsCmd.java @@ -0,0 +1,63 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportFieldGroupComInfo; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetFieldDefineTabsCmd extends AbstractCommonCommand> { + + public GetFieldDefineTabsCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + HashMap retmap = new HashMap(); + try { + if (!HrmUserVarify.checkUserRight("KQReportFieldDefine:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + List> tabs = new ArrayList(); + Map tab = null; + KQReportFieldGroupComInfo kqReportFieldGroupComInfo = new KQReportFieldGroupComInfo(); + while(kqReportFieldGroupComInfo.next()){ + if(!kqReportFieldGroupComInfo.getIsshow().equals("1"))continue; + tab = new HashMap(); + tab.put("key", kqReportFieldGroupComInfo.getId()); + tab.put("title", kqReportFieldGroupComInfo.getGroupname()); + tab.put("editable", true); + tabs.add(tab); + } + tab = new HashMap(); + tab.put("key", "other"); + tab.put("title", SystemEnv.getHtmlLabelName(81307, this.user.getLanguage())); + tabs.add(tab); + retmap.put("status", "1"); + retmap.put("tabs", tabs); + } catch (Exception e) { + this.writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, this.user.getLanguage())); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/GetFieldOrderDefineCmd.java b/src/com/engine/kq/cmd/reportfielddefine/GetFieldOrderDefineCmd.java new file mode 100644 index 0000000..0fc0836 --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/GetFieldOrderDefineCmd.java @@ -0,0 +1,118 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetFieldOrderDefineCmd extends AbstractCommonCommand> { + + public GetFieldOrderDefineCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + RecordSet recordSet = new RecordSet(); + List> srcdatasList = new ArrayList>(); + List> destdatasList = new ArrayList>(); + + String dataIndex = ""; + String labelId = ""; + String sort = ""; + String ascOrDesc = ""; + + String sql = "select * from kq_report_order where userid=? order by sort DESC, orders ASC"; + recordSet.executeQuery(sql, user.getUID()); + if (recordSet.getCounts() <= 0) { + sql = "select * from kq_report_order where userId=0 order by sort DESC, orders ASC"; + recordSet.executeQuery(sql); + } + while (recordSet.next()) { + dataIndex = recordSet.getString("dataIndex"); + labelId = recordSet.getString("labelId"); + sort = recordSet.getString("sort"); + ascOrDesc = recordSet.getString("ascOrDesc"); + + Map dataMap = new HashMap(); + if (sort.equals("1")) { + dataMap.put("dataIndex", dataIndex); + dataMap.put("labelId", labelId); + dataMap.put("title", SystemEnv.getHtmlLabelNames(labelId, user.getLanguage())); + dataMap.put("ascOrDesc", ascOrDesc); + dataMap.put("sort", sort); + + destdatasList.add(dataMap); + } else { + dataMap.put("dataIndex", dataIndex); + dataMap.put("labelId", labelId); + dataMap.put("title", SystemEnv.getHtmlLabelNames(labelId, user.getLanguage())); + dataMap.put("ascOrDesc", ascOrDesc); + dataMap.put("sort", sort); + + srcdatasList.add(dataMap); + } + } + + if (destdatasList.size() == 0 && srcdatasList.size() == 0) { + String[] defaultCol = new String[]{"hrmresource.dspOrder,390525,1,ASC", "dept.deptShowOrder,25036,0,ASC", "subcom.subcomShowOrder,506847,0,ASC", "dept.deptName,15390,0,ASC", "subcom.subcomName,1878,0,ASC", "hrmresource.lastName,81812,0,ASC","organization,376,0,ASC"}; + for (int i = 0; i < defaultCol.length; i++) { + String colInfo = defaultCol[i]; + + String[] colInfoArr = colInfo.split(","); + + dataIndex = colInfoArr[0]; + labelId = colInfoArr[1]; + sort = colInfoArr[2]; + ascOrDesc = colInfoArr[3]; + + Map dataMap = new HashMap(); + if (sort.equals("1")) { + dataMap.put("dataIndex", dataIndex); + dataMap.put("labelId", labelId); + dataMap.put("title", SystemEnv.getHtmlLabelNames(labelId, user.getLanguage())); + dataMap.put("ascOrDesc", ascOrDesc); + dataMap.put("sort", sort); + + destdatasList.add(dataMap); + } else { + dataMap.put("dataIndex", dataIndex); + dataMap.put("labelId", labelId); + dataMap.put("title", SystemEnv.getHtmlLabelNames(labelId, user.getLanguage())); + dataMap.put("ascOrDesc", ascOrDesc); + dataMap.put("sort", sort); + + srcdatasList.add(dataMap); + } + } + } + + resultMap.put("status", "1"); + resultMap.put("totalPage", "1"); + resultMap.put("currentPage", "1"); + resultMap.put("destdatas", destdatasList); + resultMap.put("srcdatas", srcdatasList); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", e.getMessage()); + } + return resultMap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/GetGroupFormCmd.java b/src/com/engine/kq/cmd/reportfielddefine/GetGroupFormCmd.java new file mode 100644 index 0000000..304d5ae --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/GetGroupFormCmd.java @@ -0,0 +1,106 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class GetGroupFormCmd extends AbstractCommonCommand> { + + public GetGroupFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + RecordSet rs = new RecordSet(); + String sql = ""; + try { + //必要的权限判断 + if (!HrmUserVarify.checkUserRight("KQReportFieldDefine:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String id = Util.null2String(params.get("id")); + Map> fieldGroups = new LinkedHashMap>(); + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + List options = null; + + String groupname = ""; + if (id.length() > 0) { + sql = "select * from kq_report_field_group where id=?"; + rs.executeQuery(sql, id); + if (rs.next()) { + groupname = Util.formatMultiLang(Util.null2String(rs.getString("groupname")), ""+user.getLanguage()); + } + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("groupname"); + hrmFieldBean.setFieldlabel("30127"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(groupname); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setMultilang(true); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setRules("required|string"); + lsField.add(hrmFieldBean); + fieldGroups.put("20331", lsField); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + Iterator>> iter = fieldGroups.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry> entry = iter.next(); + String grouplabel = entry.getKey(); + List fields = entry.getValue(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("defaultshow", true); + + itemlist = new ArrayList(); + for (int j = 0; j < fields.size(); j++) { + hrmFieldBean = fields.get(j); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + } + + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + retmap.put("formField", grouplist); + retmap.put("id", id); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/GetGroupListCmd.java b/src/com/engine/kq/cmd/reportfielddefine/GetGroupListCmd.java new file mode 100644 index 0000000..727e322 --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/GetGroupListCmd.java @@ -0,0 +1,150 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.cloudstore.dev.api.util.TextUtil; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportFieldGroupComInfo; +import weaver.conn.RecordSet; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetGroupListCmd extends AbstractCommonCommand> { + + public GetGroupListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + Map groupitem = null; + List itemlist = null; + try { + if (!HrmUserVarify.checkUserRight("KQReportFieldDefine:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + RecordSet rs = new RecordSet(); + itemlist = new ArrayList(); + groupitem = new HashMap(); + + //生成字段的集合 + Map infoMap = new HashMap(); + List> datasList = new ArrayList>(); + List> columnsList = new ArrayList>(); + + columnsList = setColumns(); + datasList = setDatas(); + + infoMap.put("showTitle", false); + infoMap.put("draggable", true); + infoMap.put("columns", columnsList); + infoMap.put("datas", datasList); + + groupitem.put("title", SystemEnv.getHtmlLabelName(1361,weaver.general.Util.getIntValue(user.getLanguage()))); + groupitem.put("table", infoMap); + itemlist.add(groupitem); + + retmap.put("items", itemlist); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + + private List> setColumns() { + List> columns = new ArrayList>(); + String td1 = "groupname,30127,1,1";//字段 + String td3 = "isshow,89,4,1";//显示 + + String[] fields = new String[]{td1,td3}; + Map col = null; + List comLists = new ArrayList(); + Map comMap = new HashMap(); + for(int i=0;i(); + comMap = new HashMap(); + comLists = new ArrayList(); + String[] fieldinfo = fields[i].split(","); + String tmpkey = fieldinfo[0]; + + col.put("title", SystemEnv.getHtmlLabelNames(fieldinfo[1],user.getLanguage())); + col.put("key", tmpkey); + col.put("dataIndex", tmpkey); + col.put("colSpan", 1); + + if("groupname".equals(fieldinfo[0])){ + comMap.put("label", ""); + comMap.put("type", "INPUT"); + comMap.put("key", tmpkey); + comMap.put("viewAttr", "3"); + Map otherParams = new HashMap(); + otherParams.put("isBase64", true); + otherParams.put("inputType", "multilang"); + comMap.put("otherParams",otherParams); + comLists.add(comMap); + col.put("width", "60%"); + col.put("com", comLists); + }else if("isshow".equals(fieldinfo[0])){ + comMap.put("label", ""); + comMap.put("type", "checkbox"); + comMap.put("key", tmpkey); + comMap.put("viewAttr", "2"); + comLists.add(comMap); + + String[] checkVauleTypes = new String[]{"1","0"}; + col.put("showCheckAll", true); + col.put("checkVauleType", checkVauleTypes); + col.put("width", "40%"); + col.put("com", comLists); + } + columns.add(col); + } + return columns; + } + + private List> setDatas() { + List> datasList = new ArrayList>(); + Map data = new HashMap(); + + KQReportFieldGroupComInfo kqReportFieldGroupComInfo = new KQReportFieldGroupComInfo(); + while(kqReportFieldGroupComInfo.next()){ + String id = kqReportFieldGroupComInfo.getId(); + String groupname = kqReportFieldGroupComInfo.getGroupname(); + String isshow = kqReportFieldGroupComInfo.getIsshow(); + + String td0 = "id"; + String td1 = "groupname"; + String td2 = "isshow"; + + data = new HashMap(); + data.put(td0, id); + data.put(td1, TextUtil.toBase64ForMultilang(groupname)); + data.put(td2, isshow); + + datasList.add(data); + } + + return datasList; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/GetReportMoudleFormCmd.java b/src/com/engine/kq/cmd/reportfielddefine/GetReportMoudleFormCmd.java new file mode 100644 index 0000000..2c45f07 --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/GetReportMoudleFormCmd.java @@ -0,0 +1,99 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class GetReportMoudleFormCmd extends AbstractCommonCommand> { + + public GetReportMoudleFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + RecordSet rs = new RecordSet(); + String sql = ""; + try { + String id = Util.null2String(params.get("id")); + Map> fieldGroups = new LinkedHashMap>(); + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + List options = null; + + String moudlename = ""; + if (id.length() > 0) { + sql = "select * from kq_report_moudle where id=?"; + rs.executeQuery(sql, id); + if (rs.next()) { + moudlename = Util.null2String(rs.getString("moudlename")); + } + } + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("moudlename"); + hrmFieldBean.setFieldlabel("18151"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(moudlename); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setMultilang(true); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setRules("required|string"); + lsField.add(hrmFieldBean); + fieldGroups.put("20331", lsField); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + Iterator>> iter = fieldGroups.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry> entry = iter.next(); + String grouplabel = entry.getKey(); + List fields = entry.getValue(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("defaultshow", true); + + itemlist = new ArrayList(); + for (int j = 0; j < fields.size(); j++) { + hrmFieldBean = fields.get(j); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + } + + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + retmap.put("formField", grouplist); + retmap.put("id", id); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/GetReportMoudleTabsCmd.java b/src/com/engine/kq/cmd/reportfielddefine/GetReportMoudleTabsCmd.java new file mode 100644 index 0000000..8733790 --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/GetReportMoudleTabsCmd.java @@ -0,0 +1,157 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQReportFieldComInfo; +import com.engine.kq.biz.KQReportFieldGroupComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetReportMoudleTabsCmd extends AbstractCommonCommand> { + + public GetReportMoudleTabsCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + HashMap retmap = new HashMap(); + String sql = ""; + RecordSet rs = new RecordSet(); + try { + List> tabs = new ArrayList(); + Map tab = null; + //默认条件 + tab = new HashMap(); + tab.put("key", "0"); + tab.put("title", SystemEnv.getHtmlLabelName(149, this.user.getLanguage())); + tab.put("moudledata", getDisplaySetting()); + tabs.add(tab); + + sql = "select * from kq_report_moudle where resourceid=? order by showorder "; + rs.executeQuery(sql,user.getUID()); + while (rs.next()) { + tab = new HashMap(); + tab.put("key", rs.getString("id")); + tab.put("title", rs.getString("moudlename")); + tab.put("moudledata", rs.getString("moudledata")); + tab.put("editable", true); + tabs.add(tab); + } + + retmap.put("status", "1"); + retmap.put("tabs", tabs); + } catch (Exception e) { + this.writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, this.user.getLanguage())); + } + return retmap; + } + + + public Map getDisplaySetting() { + Map retmap = new HashMap(); + Map displaySetting = new HashMap<>(); + List groups = new ArrayList<>(); + Map group = null; + List options = null; + Map option = null; + String value = ""; + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + KQReportFieldGroupComInfo kqReportFieldGroupComInfo = new KQReportFieldGroupComInfo(); + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while(kqReportFieldGroupComInfo.next()){ + if(!kqReportFieldGroupComInfo.getIsshow().equals("1"))continue; + group = new HashMap<>(); + options = new ArrayList<>(); + value = ""; + + kqReportFieldComInfo.setTofirstRow(); + while (kqReportFieldComInfo.next()){ + if(kqReportFieldComInfo.getGroupid().equals(kqReportFieldGroupComInfo.getId())){ + if(!kqReportFieldComInfo.getIsenable().equals("1"))continue; + if(!kqReportFieldComInfo.getIsDefinedColumn().equals("1"))continue; + if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))continue; + if("overtime_nonleave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname()) || "overtime_4leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())){ + continue; + } + if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){ + continue; + } + option = new HashMap<>(); + option.put("key",kqReportFieldComInfo.getFieldname()); + option.put("label",kqReportFieldComInfo.getFieldlabel()); + option.put("name",kqReportFieldComInfo.getFieldname()); + option.put("showname",SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(),user.getLanguage())); + options.add(option); + if(kqReportFieldComInfo.getDefaultShow().equals("1")) { + if(value.length()>0)value+=","; + value += kqReportFieldComInfo.getFieldname(); + } + } + } + group.put("groupname", Util.formatMultiLang(kqReportFieldGroupComInfo.getGroupname(),""+user.getLanguage())); + group.put("options",options); + group.put("value",value); + if(options.size()==0)continue; + groups.add(group); + } + + //加入未分组数据 + group = new HashMap<>(); + options = new ArrayList<>(); + value = ""; + kqReportFieldComInfo.setTofirstRow(); + while (kqReportFieldComInfo.next()){ + if(Util.null2String(kqReportFieldComInfo.getGroupid()).equals("")){ + if(!kqReportFieldComInfo.getIsenable().equals("1"))continue; + if(!kqReportFieldComInfo.getIsDefinedColumn().equals("1"))continue; + if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))continue; + if("overtime_nonleave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname()) || "overtime_4leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())){ + continue; + } + if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){ + continue; + } + option = new HashMap<>(); + option.put("key",kqReportFieldComInfo.getFieldname()); + option.put("label",kqReportFieldComInfo.getFieldlabel()); + option.put("name",kqReportFieldComInfo.getFieldname()); + option.put("showname",SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(),user.getLanguage())); + options.add(option); + if(kqReportFieldComInfo.getDefaultShow().equals("1")) { + if(value.length()>0)value+=","; + value += kqReportFieldComInfo.getFieldname(); + } + } + } + group.put("groupname", SystemEnv.getHtmlLabelName(81307,user.getLanguage())); + group.put("options",options); + group.put("value",value); + if(options.size()>0) { + groups.add(group); + } + + displaySetting.put("groups",groups); + retmap.put("displaySetting",displaySetting); + return retmap; + } + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/GetRightMenuCmd.java b/src/com/engine/kq/cmd/reportfielddefine/GetRightMenuCmd.java new file mode 100644 index 0000000..d1395d9 --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/GetRightMenuCmd.java @@ -0,0 +1,47 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + RightMenu rightMenu = null; + + rightMenu = new RightMenu(user.getLanguage(), RightMenuType.BTN_Save, "saveGroup", true);//保存 + rightMenuList.add(rightMenu); + + rightMenu = new RightMenu(user.getLanguage(), RightMenuType.BTN_CREATE_GROUP, "createGroup", true); + rightMenuList.add(rightMenu); + + rightMenu = new RightMenu(user.getLanguage(), RightMenuType.BTN_EDIT_GROUP, "editGroup", true); + rightMenuList.add(rightMenu); + + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/SaveFieldDefineCmd.java b/src/com/engine/kq/cmd/reportfielddefine/SaveFieldDefineCmd.java new file mode 100644 index 0000000..a7043c8 --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/SaveFieldDefineCmd.java @@ -0,0 +1,213 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportFieldComInfo; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.LabelUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + + +public class SaveFieldDefineCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + public SaveFieldDefineCmd(Map params, User user) { + this.user = user; + this.params = params; + + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQREPORT_DEFINED); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQREPORT_DEFINED); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String id = Util.null2String(params.get("id")); + if(id.length()==0)id="-1"; + String mainSql = " select * from kq_report_field where id= " + id; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getLabelName"); + logger.setMethodOtherParams("column:fieldlabel+" + user.getLanguage()); + logger.before(logContext); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + if (!HrmUserVarify.checkUserRight("KQReportFieldDefine:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String id = Util.null2String(params.get("id")); + String strFieldlabel = Util.null2String(params.get("fieldlabel"));//展示列名称 + if(this.isDuplicate(strFieldlabel,id)){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(10000834,weaver.general.Util.getIntValue(user.getLanguage()))); + return retmap; + } + String fieldname = Util.null2String(params.get("fieldname")); + String fieldnameMins = fieldname+"Mins"; + String fielddbtype = Util.null2String(params.get("fielddbtype")); + fielddbtype = "int"; + int fieldlabel = new LabelUtil().getLabelId(strFieldlabel); + int fieldlabelMins = fieldlabel;//new LabelUtil().getLabelId(SystemEnv.getHtmlLabelName(fieldlabel, 7)+"时长"); + String fieldtype = Util.null2String(params.get("fieldtype"));//类型 + String fieldvalue = Util.null2String(params.get("fieldvalue"));//区间(分钟) + String[] arrFieldvalue = Util.splitString(fieldvalue, "-"); + String formula = ""; + String groupid = Util.null2String(params.get("groupid")); + if(groupid.equals("other")){ + groupid = null; + } + boolean validate = true; + + if(arrFieldvalue.length==2) { + try { + Integer.parseInt(arrFieldvalue[0].trim()); + } catch (Exception e) { + validate = false; + } + + if(validate) { + try { + Integer.parseInt(arrFieldvalue[1].trim()); + } catch (Exception e) { + validate = false; + } + } + }else{ + validate = false; + } + + if(validate) { + if (fieldtype.equals("1")) { + formula = "${beLateMins}>" + arrFieldvalue[0].trim() + " && ${beLateMins}<=" + arrFieldvalue[1].trim() + "?1:0"; + } else if (fieldtype.equals("2")) { + formula = "${leaveEarlyMins}>" + arrFieldvalue[0].trim() + " && ${leaveEarlyMins}<=" + arrFieldvalue[1].trim() + "?1:0"; + } + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(517153, user.getLanguage())); + return retmap; + } + + + + if(id.length()>0){ + sql = "update kq_report_field set fieldlabel=?,formula=? where id=?"; + rs.executeUpdate(sql, fieldlabel, formula, id); + + sql = "update kq_report_field set fieldlabel=? where fieldname=?"; + rs.executeUpdate(sql, fieldlabelMins, fieldnameMins); + }else{ + boolean flag = false; + sql = "alter table kq_format_detail add "+fieldname+" "+fielddbtype; + flag = rs.executeUpdate(sql); + + sql = "alter table kq_format_detail add "+fieldnameMins+" "+fielddbtype; + flag = rs.executeUpdate(sql); + + sql = "alter table kq_format_total add "+fieldname+" "+fielddbtype; + flag = rs.executeUpdate(sql); + + sql = "alter table kq_format_total add "+fieldnameMins+" "+fielddbtype; + flag = rs.executeUpdate(sql); + + if(flag) { + sql = " insert into kq_report_field(" + + " fieldname,fieldlabel,width,unittype,parentid,isDefinedColumn,defaultShow,isLeaveType,reportType,isdataColumn,showDetial,groupid,isenable,formula,cascadekey) " + + " values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + rs.executeUpdate(sql, fieldname, fieldlabel, 65, 3, null, 1, 0, 0, "month", 1, 1, groupid, 1, formula,fieldnameMins); + + rs.executeQuery("select max(id) from kq_report_field") ; + if(rs.next()){ + id = rs.getString(1); + } + + String mainSql = " select * from kq_report_field where id= " + id; + logger.setMainSql(mainSql);//主表sql + + rs.executeUpdate("update kq_report_field set showorder = ? where id= ?",id,id) ; + + sql = " insert into kq_report_field(" + + " fieldname,fieldlabel,width,unittype,parentid,isDefinedColumn,defaultShow,isLeaveType,reportType,isdataColumn,showDetial,groupid,isenable,formula) " + + " values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + rs.executeUpdate(sql, fieldnameMins, fieldlabelMins, 65, 2, null, 0, 0, 0, "month", 1, 1, groupid, 1, null); + + rs.executeQuery("select max(id) from kq_report_field") ; + if(rs.next()){ + id = rs.getString(1); + } + + rs.executeUpdate("update kq_report_field set showorder = ? where id= ?",id,id) ; + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(83470, user.getLanguage())); + return retmap; + } + } + + + new KQReportFieldComInfo().removeCache(); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(517153, user.getLanguage())); + writeLog(e); + } + + return retmap; + } + + + private boolean isDuplicate(String fieldlabelname, String id){ + boolean isDuplicate = false; + String sql = ""; + RecordSet rs = new RecordSet(); + List lsFieldlabelName = new ArrayList<>(); + sql = " SELECT fieldlabel,issystem from kq_report_field where reporttype in('all','month') " + + " and fieldname not in('workingDayOvertime_4leave','restDayOvertime_4leave','holidayOvertime_4leave') and fieldname not like '%Mins'"; + if(id.length()>0){ + sql +=" and id !=?"; + rs.executeQuery(sql,id); + }else{ + rs.executeQuery(sql); + } + while(rs.next()){ + if(Util.null2String(rs.getString("issystem")).equals("1"))continue; + lsFieldlabelName.add(SystemEnv.getHtmlLabelName(rs.getInt("fieldlabel"), user.getLanguage())); + } + if(lsFieldlabelName.contains(fieldlabelname)){ + isDuplicate = true; + } + return isDuplicate; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/SaveFieldDefineListCmd.java b/src/com/engine/kq/cmd/reportfielddefine/SaveFieldDefineListCmd.java new file mode 100644 index 0000000..ed1ae94 --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/SaveFieldDefineListCmd.java @@ -0,0 +1,109 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportFieldComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class SaveFieldDefineListCmd extends AbstractCommonCommand> { + private SimpleBizLogger logger; + public SaveFieldDefineListCmd(Map params, User user) { + this.user = user; + this.params = params; + + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQREPORT_DEFINED); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQREPORT_DEFINED); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String ids = ""; + String datas = Util.null2String(params.get("datas")); + JSONArray jArray = JSON.parseArray(datas); + for (int i = 0; i < jArray.size(); i++) { + JSONObject jObject = (JSONObject) jArray.get(i); + String id = Util.null2String(jObject.get("id")); + if(ids.length()>0)ids+=","; + ids+=id; + } + + String mainSql = " select * from kq_report_field where id in("+ids+")"; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getLabelName"); + logger.setMethodOtherParams("column:fieldlabel+" + user.getLanguage()); + logger.before(logContext); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + if (!HrmUserVarify.checkUserRight("KQReportFieldDefine:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String datas = Util.null2String(params.get("datas")); + JSONArray jArray = JSON.parseArray(datas); + + if (jArray != null) { + for (int i = 0; i < jArray.size(); i++) { + JSONObject jObject = (JSONObject) jArray.get(i); + String id = Util.null2String(jObject.get("id")); + String isenable = Util.null2String(jObject.get("isenable")); + String defaultshow = Util.null2String(jObject.get("defaultshow")); + String fieldOrder = Util.null2String(jObject.get("fieldOrder")); + // #1276494 概述:满足薪酬指标项关联考勤报表列数据需求 By T.W + String ifSalaryNeed = Util.null2String(jObject.get("ifSalaryNeed")); +// sql = "update kq_report_field set isenable=?,defaultshow=?,showorder=?,if_salary_need=? where id = ? "; +// rs.executeUpdate(sql, isenable, defaultshow, fieldOrder, ifSalaryNeed, id); + + sql = "update kq_report_field set isenable=?,defaultshow=?,showorder=? where id = ? "; + rs.executeUpdate(sql,isenable,defaultshow,fieldOrder,id); + } + new KQReportFieldComInfo().removeCache(); + } + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/SaveFieldOrderDefineCmd.java b/src/com/engine/kq/cmd/reportfielddefine/SaveFieldOrderDefineCmd.java new file mode 100644 index 0000000..5dcf2ff --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/SaveFieldOrderDefineCmd.java @@ -0,0 +1,102 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SaveFieldOrderDefineCmd extends AbstractCommonCommand> { + + public SaveFieldOrderDefineCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + JSONArray destdatas = JSONArray.parseArray((String) params.get("destdatas")); + + List valueList = new ArrayList();//每一个记录使用记录SQL操作的参数集合 + List paramList = new ArrayList();//所有记录使用记录SQL操作的参数集合 + + int destIndex = 0;//已选列的顺序 + int srcIndex = 0;//待选列的顺序 + + String[] defaultCol = new String[]{"hrmresource.dspOrder,390525,0,ASC", "dept.deptShowOrder,25036,0,ASC", "subcom.subcomShowOrder,506847,0,ASC", "dept.deptName,15390,0,ASC", "subcom.subcomName,1878,0,ASC", "hrmresource.lastName,81812,0,ASC","organization,376,0,ASC"}; + if(destdatas.size()==0){ + defaultCol = new String[]{"hrmresource.dspOrder,390525,1,ASC", "dept.deptShowOrder,25036,0,ASC", "subcom.subcomShowOrder,506847,0,ASC", "dept.deptName,15390,0,ASC", "subcom.subcomName,1878,0,ASC", "hrmresource.lastName,81812,0,ASC","organization,376,0,ASC"}; + } + for (int i = 0; i < defaultCol.length; i++) { + String colInfo = defaultCol[i]; + + String[] colInfoArr = colInfo.split(","); + + String dataIndex = colInfoArr[0]; + String labelId = colInfoArr[1]; + String sort = colInfoArr[2]; + String ascOrDesc = colInfoArr[3]; + + for (int j = 0; j < destdatas.size(); j++) { + JSONObject jsonObject = destdatas.getJSONObject(j); + String _dataIndex = jsonObject.getString("dataIndex"); + String _ascOrDesc = jsonObject.getString("ascOrDesc"); + if (dataIndex.equals(_dataIndex)) { + ascOrDesc = _ascOrDesc; + sort = "1"; + destIndex = j; + } + } + + + valueList = new ArrayList(); + valueList.add(user.getUID()); + valueList.add(dataIndex); + valueList.add(labelId); + valueList.add(sort); + valueList.add(ascOrDesc); + valueList.add(sort.equals("1") ? destIndex : srcIndex++); + paramList.add(valueList); + } + + RecordSet recordSet = new RecordSet(); + String clearSql = "delete from kq_report_order where userId=?"; + boolean flag = recordSet.executeUpdate(clearSql,user.getUID()); + if (!flag) { + throw new Exception(); + } + + String insertSql = "INSERT INTO kq_report_order(userId,dataIndex,labelId,sort,ascOrDesc,orders) values(?,?,?,?,?,?)"; + flag = recordSet.executeBatchSql(insertSql, paramList); + if (flag) { + resultMap.put("status", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } + } catch (Exception e) { + e.printStackTrace(); + resultMap.put("status", "-1"); + resultMap.put("message", " delete data of kq_report_order failed."+e.getMessage()); + } + return resultMap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/SaveGroupCmd.java b/src/com/engine/kq/cmd/reportfielddefine/SaveGroupCmd.java new file mode 100644 index 0000000..cdeac58 --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/SaveGroupCmd.java @@ -0,0 +1,188 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportFieldComInfo; +import com.engine.kq.biz.KQReportFieldGroupComInfo; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class SaveGroupCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + SimpleBizLogger.SubLogInfo subLogInfo; + public SaveGroupCmd(Map params, User user) { + this.user = user; + this.params = params; + + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQREPORT_DEFINED); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQREPORT_DEFINED); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String cmd = Util.null2String(params.get("cmd")); + String mainSql = ""; + if(cmd.equals("save")){ + String id = Util.null2String(params.get("id")); + if(id.length()==0)id="-1"; + mainSql = " select * from kq_report_field_group where id= " + id; + }else{ + mainSql = " select * from kq_report_field_group"; + } + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("groupname"); + + subLogInfo = logger.getNewSubLogInfo(); + String subSql = " select * from kq_report_field"; + subLogInfo.setSubSql(subSql); + subLogInfo.setSubPrimarykey("id"); + subLogInfo.setSubTargetNameMethod("com.engine.kq.util.KQTransMethod.getLabelName"); + subLogInfo.setSubMethodOtherParams("column:fieldlabel+" + user.getLanguage()); + subLogInfo.setGroupId("1"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo.setSubGroupNameLabel(33943); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo); + + logger.before(logContext); + + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String sql = ""; + RecordSetTrans rst = new RecordSetTrans(); + try { + if (!HrmUserVarify.checkUserRight("KQReportFieldDefine:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String cmd = Util.null2String(params.get("cmd")); + if(cmd.equals("save")){ + String id = Util.null2String(params.get("id")); + if(id.length()>0) { + sql = " update kq_report_field_group set groupname=? where id=?"; + rst.executeUpdate(sql,id); + }else{ + String groupname = Util.null2String(params.get("groupname")); + String isshow = "1"; + sql = "insert into kq_report_field_group (groupname, isshow) values (?,?)"; + rst.executeUpdate(sql,groupname, isshow); + + rst.executeQuery("select max(id) from kq_report_field_group"); + if (rst.next()) { + id = rst.getString(1); + } + sql = " update kq_report_field_group set showorder=id where id = ? "; + rst.executeUpdate(sql,id); + } + String mainSql = " select * from kq_report_field_group where id= " + id; + logger.setMainSql(mainSql);//主表sql + retmap.put("id", id); + }else if(cmd.equals("savebatch")){ + List lsDelGroupId = new ArrayList(); + sql = " select id from kq_report_field_group "; + rst.executeQuery(sql); + while(rst.next()){ + lsDelGroupId.add(rst.getString("id")); + } + String datas = Util.null2String(params.get("datas")); + JSONArray jArray = JSON.parseArray(datas); + if(jArray != null){ + for(int i=0;i0) { + lsDelGroupId.remove(id); + sql = "update kq_report_field_group set groupname=?,isshow=?,showorder=? where id = ?"; + rst.executeUpdate(sql,groupname, isshow, showorder,id); + }else{ + sql = "insert into kq_report_field_group (groupname, isshow, showorder) values (?,?,?)"; + rst.executeUpdate(sql,groupname, isshow, showorder); + } + } + } + String delGroupIds = ""; + for(int i=0;i0){ + delGroupIds+=","; + } + delGroupIds+=lsDelGroupId.get(i); + } + if(delGroupIds.length()>0){ + List sqlParams = new ArrayList(); + Object[] objects= DBUtil.transListIn(delGroupIds,sqlParams); + + sql = " update kq_report_field set groupid=null where groupid in ("+objects[0]+")"; + rst.executeUpdate(sql, sqlParams); + + sql = "delete from kq_report_field_group where id in("+objects[0]+") "; + rst.executeUpdate(sql, sqlParams); + } + } + + boolean duplicate = false; + List lsGroupname = new ArrayList<>(); + sql = " SELECT groupname from kq_report_field_group"; + rst.executeQuery(sql); + while(rst.next()){ + String groupname = Util.formatMultiLang(rst.getString("groupname"),""+user.getLanguage()); + if(lsGroupname.contains(groupname)){ + duplicate = true; + break; + } + lsGroupname.add(groupname); + } + + if(duplicate){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(10000835,weaver.general.Util.getIntValue(user.getLanguage()))+"("+rst.getString("groupname")+")"); + rst.rollback(); + }else{ + rst.commit(); + new KQReportFieldComInfo().removeCache(); + new KQReportFieldGroupComInfo().removeCache(); + retmap.put("status", "1"); + } + } catch (Exception e) { + rst.rollback(); + this.writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, this.user.getLanguage())); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/reportfielddefine/SaveReportMoudleCmd.java b/src/com/engine/kq/cmd/reportfielddefine/SaveReportMoudleCmd.java new file mode 100644 index 0000000..c6bfcb2 --- /dev/null +++ b/src/com/engine/kq/cmd/reportfielddefine/SaveReportMoudleCmd.java @@ -0,0 +1,58 @@ +package com.engine.kq.cmd.reportfielddefine; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; +import java.util.HashMap; +import java.util.Map; + +public class SaveReportMoudleCmd extends AbstractCommonCommand> { + + public SaveReportMoudleCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String sql = ""; + RecordSet rs = new RecordSet(); + try { + String id = Util.null2String(params.get("id")); + String moudlename = Util.null2String(params.get("moudlename")); + String moudledata = Util.null2String(params.get("moudledata")); + if (id.length() > 0) { + sql = " update kq_report_moudle set moudledata=? where id=?"; + rs.executeUpdate(sql, moudledata, id); + } else { + sql = "insert into kq_report_moudle (moudlename, moudledata,resourceid) values (?,?,?)"; + rs.executeUpdate(sql, moudlename, moudledata, user.getUID()); + + rs.executeQuery("select max(id) from kq_report_moudle"); + if (rs.next()) { + id = rs.getString(1); + } + sql = " update kq_report_moudle set showorder=id where id = ? "; + rs.executeUpdate(sql, id); + } + retmap.put("id", id); + retmap.put("status", "1"); + } catch (Exception e) { + this.writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, this.user.getLanguage())); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/reportshare/DeleteReportShareCmd.java b/src/com/engine/kq/cmd/reportshare/DeleteReportShareCmd.java new file mode 100644 index 0000000..13a191f --- /dev/null +++ b/src/com/engine/kq/cmd/reportshare/DeleteReportShareCmd.java @@ -0,0 +1,86 @@ +package com.engine.kq.cmd.reportshare; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 考勤报表共享设置--删除 + */ +public class DeleteReportShareCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public DeleteReportShareCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String ids = Util.null2String(params.get("ids")); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_REPORTSHARE);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_REPORTSHARE);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_ReportShare where id in ("+ids+")"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4ReportShare","column:reportName+column:resourceType+column:resourceId+"+user.getLanguage()); + + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + boolean canDelete = HrmUserVarify.checkUserRight("KQ:ReportShare", user);//是否具有删除的权限 + if (!canDelete) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));//没有权限 + return resultMap; + } + try { + String ids = Util.null2String(params.get("ids")); + + boolean flag = true; + String sql = "delete from kq_ReportShare where id in (" + ids + ")"; + RecordSet recordSet = new RecordSet(); + flag = recordSet.executeUpdate(sql); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } + } catch (Exception e) { + writeLog(e); + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/reportshare/GetReportShareFormCmd.java b/src/com/engine/kq/cmd/reportshare/GetReportShareFormCmd.java new file mode 100644 index 0000000..fb8f889 --- /dev/null +++ b/src/com/engine/kq/cmd/reportshare/GetReportShareFormCmd.java @@ -0,0 +1,183 @@ +package com.engine.kq.cmd.reportshare; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 考勤报表共享设置--新建的表单 + */ +public class GetReportShareFormCmd extends AbstractCommonCommand> { + + public GetReportShareFormCmd(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(); + + String id = Util.null2String(params.get("id")); + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("reportName");//报表名称 + hrmFieldBean.setFieldlabel("15517"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(332, user.getLanguage()), true)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(390351, user.getLanguage()))); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(390352, user.getLanguage()))); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(390248, user.getLanguage()))); + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(389441, user.getLanguage()))); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean isUseManageDetach = manageDetachComInfo.isUseManageDetach();//是否开启了管理分权 + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("resourceType");//对象类型:1-人力资源、7-分权管理员、8-系统管理员 + hrmFieldBean.setFieldlabel("21956"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(179, user.getLanguage()), true)); + if (isUseManageDetach) { + optionsList.add(new SearchConditionOption("7", SystemEnv.getHtmlLabelName(33495, user.getLanguage()))); + } + if (user.getUID() == 1) { + optionsList.add(new SearchConditionOption("8", SystemEnv.getHtmlLabelName(16139, user.getLanguage()))); + } + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("resourceIds");//对象--人力资源 + hrmFieldBean.setFieldlabel("106"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("17"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("resourceManagerIds");//对象--分权管理员 + hrmFieldBean.setFieldlabel("106"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("adminAccount"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + searchConditionItem.getBrowserConditionParam().setIsSingle(false); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("shareLevel");//共享级别 + hrmFieldBean.setFieldlabel("3005"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(33553, user.getLanguage()), true));//分部 + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(27511, user.getLanguage())));//部门 + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(179, user.getLanguage())));//人员 + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(6086, user.getLanguage())));//岗位 + if(!new ManageDetachComInfo().appDetachDisableAll(user)) { + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(1340, user.getLanguage())));//所有人 + } + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("subcomId");//分部 + hrmFieldBean.setFieldlabel("33553"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("194"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("deptId");//部门 + hrmFieldBean.setFieldlabel("27511"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("57"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("jobtitleId");//岗位 + hrmFieldBean.setFieldlabel("6086"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("278"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("userId");//人力资源 + hrmFieldBean.setFieldlabel("179"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("17"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/reportshare/GetRightMenuCmd.java b/src/com/engine/kq/cmd/reportshare/GetRightMenuCmd.java new file mode 100644 index 0000000..e3b4959 --- /dev/null +++ b/src/com/engine/kq/cmd/reportshare/GetRightMenuCmd.java @@ -0,0 +1,55 @@ +package com.engine.kq.cmd.reportshare; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 考勤报表共享设置--右键菜单 + */ +public class GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(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(); + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + int languageId = user.getLanguage();//用户选择的语言 + RightMenu rightMenu = null; + + boolean canAdd = HrmUserVarify.checkUserRight("KQ:ReportShare",user); + + if(canAdd){ + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Addnew, "new", true);//新建 + rightMenuList.add(rightMenu); + + rightMenu = new RightMenu(languageId, RightMenuType.BTN_BatchDelete, "batchDelete", true, true);//批量删除 + rightMenuList.add(rightMenu); + + rightMenu = new RightMenu(languageId, RightMenuType.BTN_log, "log", false);//日志 + rightMenuList.add(rightMenu); + } + rightMenu = new RightMenu(languageId, RightMenuType.BTN_COLUMN, "custom", false); //显示列定制 + rightMenuList.add(rightMenu); + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/reportshare/GetSearchConditionCmd.java b/src/com/engine/kq/cmd/reportshare/GetSearchConditionCmd.java new file mode 100644 index 0000000..9529da6 --- /dev/null +++ b/src/com/engine/kq/cmd/reportshare/GetSearchConditionCmd.java @@ -0,0 +1,65 @@ +package com.engine.kq.cmd.reportshare; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 考勤报表共享设置--获取查询条件 + */ +public class GetSearchConditionCmd extends AbstractCommonCommand> { + + public GetSearchConditionCmd(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(); + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("reportName");//报表名称 + hrmFieldBean.setFieldlabel("15517"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(332, user.getLanguage()),true)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(390351, user.getLanguage()))); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(390352, user.getLanguage()))); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(390248, user.getLanguage()))); + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(389441, user.getLanguage()))); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/reportshare/GetSearchListCmd.java b/src/com/engine/kq/cmd/reportshare/GetSearchListCmd.java new file mode 100644 index 0000000..c589c47 --- /dev/null +++ b/src/com/engine/kq/cmd/reportshare/GetSearchListCmd.java @@ -0,0 +1,76 @@ +package com.engine.kq.cmd.reportshare; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.general.PageIdConst; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * 考勤报表共享设置--获取查询结果 + */ +public class GetSearchListCmd extends AbstractCommonCommand> { + + 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(); + + boolean canDelete = HrmUserVarify.checkUserRight("KQ:ReportShare", user); + boolean canLog = HrmUserVarify.checkUserRight("KQ:ReportShare", user); + + String resourceName = Util.null2String(params.get("resourceName"));//对象姓名 + String reportName = Util.null2String(params.get("reportName"));//报表名称 + + String backFields = " * "; + String sqlFrom = " from kq_ReportShare "; + String sqlWhere = " where 1=1 "; + if (!resourceName.equals("")) { + sqlWhere += " and (resourceId in (select id from HrmResource where lastname like '%" + resourceName + "%') " + + " or resourceId in (select id from HrmResourceManager where lastname like '%" + resourceName + "%'))"; + } + if (!reportName.equals("") && !reportName.equals("0")) { + sqlWhere += " and reportName='" + reportName + "'"; + } + String orderBy = " id "; + + String pageUid = "340e42fa-a02c-fb7c-9c0a-5b3738d6c284"; + String operateString = ""; + operateString = ""; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += ""; + String tableString = "" + + "" + + "" + + operateString + + " " + + " " + + " " + + " " + + " " + + " " + + "
"; + String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionKey, tableString); + resultMap.put("sessionkey", sessionKey); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/reportshare/SaveReportShareCmd.java b/src/com/engine/kq/cmd/reportshare/SaveReportShareCmd.java new file mode 100644 index 0000000..d4d7d18 --- /dev/null +++ b/src/com/engine/kq/cmd/reportshare/SaveReportShareCmd.java @@ -0,0 +1,127 @@ +package com.engine.kq.cmd.reportshare; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 考勤报表共享设置--保存 + */ +public class SaveReportShareCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public SaveReportShareCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String resourceType = Util.null2String(params.get("resourceType"));//类型:1-人力资源、7-分权管理员、8-系统管理员 + String resourceIds = Util.null2String(params.get("resourceIds"));//对象(类型为人力资源时) + String resourceManagerIds = Util.null2String(params.get("resourceManagerIds"));//对象(类型为分权管理员时) + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_REPORTSHARE);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_REPORTSHARE);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_ReportShare where resourceType="+resourceType; + if(resourceType.equals("1")){ + mainSql += " and resourceId in ("+resourceIds+")"; + }else if(resourceType.equals("7")){ + mainSql += " and resourceId in ("+resourceManagerIds+")"; + } + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4ReportShare","column:reportName+column:resourceType+column:resourceId+"+user.getLanguage()); + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + boolean canSave = HrmUserVarify.checkUserRight("KQ:ReportShare", user);//是否具有保存的权限 + if (!canSave) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));//没有权限 + return resultMap; + } + try { + String reportName = Util.null2String(params.get("reportName"));//报表名称:0-全部、1-考勤报表、2-月日历考勤报表、3-原始打卡记录、4-员工假期余额 + String resourceType = Util.null2String(params.get("resourceType"));//类型:1-人力资源、7-分权管理员、8-系统管理员 + String resourceIds = Util.null2String(params.get("resourceIds"));//对象(类型为人力资源时) + String resourceManagerIds = Util.null2String(params.get("resourceManagerIds"));//对象(类型为分权管理员时) + String shareLevel = Util.null2String(params.get("shareLevel"));//共享级别:分部、部门、人力资源、岗位、所有人 + String subcomId = Util.null2String(params.get("subcomId"));//分部ID + String deptId = Util.null2String(params.get("deptId"));//部门ID + String jobtitleId = Util.null2String(params.get("jobtitleId"));//岗位ID + String userId = Util.null2String(params.get("userId"));//人力资源ID + String forAllUser = shareLevel.equals("4") ? "1" : "0"; + + boolean flag = true;//SQL语句是否执行成功 + RecordSet recordSet = new RecordSet(); + List reportList = new ArrayList(); + if (reportName.equals("0")) { + reportList.add("1"); + reportList.add("2"); + reportList.add("3"); + reportList.add("4"); + } else { + reportList.add(reportName); + } + + if (resourceType.equals("7")) { + resourceIds = resourceManagerIds; + } else if (resourceType.equals("8")) { + resourceIds = "1"; + } else { + resourceIds = resourceIds; + } + + for (int x = 0; x < reportList.size(); x++) { + List resourceIdList = Util.TokenizerString(resourceIds, ","); + for (int i = 0; i < resourceIdList.size(); i++) { + String sql = "insert into kq_ReportShare(reportName,resourceType,resourceId,shareLevel,subcomId,deptId,jobtitleId,userId,forAllUser) " + + "values(?,?,?,?,?,?,?,?,?)"; + flag = recordSet.executeUpdate(sql, reportList.get(x), resourceType, resourceIdList.get(i), shareLevel, subcomId, deptId, jobtitleId, userId, forAllUser); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(534532, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } + } catch (Exception e) { + writeLog(e); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/schedulecode/DelScheduleDeviceCmd.java b/src/com/engine/kq/cmd/schedulecode/DelScheduleDeviceCmd.java new file mode 100644 index 0000000..cc61353 --- /dev/null +++ b/src/com/engine/kq/cmd/schedulecode/DelScheduleDeviceCmd.java @@ -0,0 +1,86 @@ +package com.engine.kq.cmd.schedulecode; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class DelScheduleDeviceCmd extends AbstractCommonCommand>{ + + private SimpleBizLogger logger; + public DelScheduleDeviceCmd(Map params, User user) { + this.user = user; + this.params = params; + + this.logger = new SimpleBizLogger(); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_SCHEDULEDEVICE); + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_SCHEDULEDEVICE);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + + String ids = Util.null2String(params.get("ids")); + String mainSql = "select * from kq_schedule_device where id in("+ids+") "; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("devicename"); + logger.before(bizLogContext); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("ScheduleCode:Edit",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String ids = Util.null2String(params.get("ids")); + List sqlParams = new ArrayList(); + Object[] objects= DBUtil.transListIn(ids,sqlParams); + sql = "delete from kq_schedule_device where id in ("+objects[0]+") "; + rs.executeUpdate(sql, sqlParams); + + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(20461, user.getLanguage())); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/schedulecode/GetScheduleCodeConditionCmd.java b/src/com/engine/kq/cmd/schedulecode/GetScheduleCodeConditionCmd.java new file mode 100644 index 0000000..5c69108 --- /dev/null +++ b/src/com/engine/kq/cmd/schedulecode/GetScheduleCodeConditionCmd.java @@ -0,0 +1,120 @@ +package com.engine.kq.cmd.schedulecode; + +import java.util.*; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + + +public class GetScheduleCodeConditionCmd extends AbstractCommonCommand>{ + + public GetScheduleCodeConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("ScheduleCode:Edit",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + Map> fieldGroups= new LinkedHashMap>(); + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + List options = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("lastname"); + hrmFieldBean.setFieldlabel("413"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("schedulecode"); + hrmFieldBean.setFieldlabel("27960"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("subcompanyid"); + hrmFieldBean.setFieldlabel("141"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("194"); + lsField.add(hrmFieldBean); + fieldGroups.put("1361", lsField); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("departmentid"); + hrmFieldBean.setFieldlabel("124"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("57"); + lsField.add(hrmFieldBean); + fieldGroups.put("1361", lsField); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("jobtitle"); + hrmFieldBean.setFieldlabel("6086"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("278"); + lsField.add(hrmFieldBean); + fieldGroups.put("1361", lsField); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + Iterator>> iter = fieldGroups.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry> entry = iter.next(); + String grouplabel = entry.getKey(); + List fields = entry.getValue(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("defaultshow", true); + + itemlist = new ArrayList(); + for (int j = 0; j < fields.size(); j++) { + hrmFieldBean = fields.get(j); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + + retmap.put("status", "1"); + retmap.put("conditions", grouplist); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + +} diff --git a/src/com/engine/kq/cmd/schedulecode/GetScheduleCodeFormCmd.java b/src/com/engine/kq/cmd/schedulecode/GetScheduleCodeFormCmd.java new file mode 100644 index 0000000..cb9d037 --- /dev/null +++ b/src/com/engine/kq/cmd/schedulecode/GetScheduleCodeFormCmd.java @@ -0,0 +1,137 @@ +package com.engine.kq.cmd.schedulecode; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +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.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldUtil; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + + +public class GetScheduleCodeFormCmd extends AbstractCommonCommand>{ + + public GetScheduleCodeFormCmd(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 { + if (!HrmUserVarify.checkUserRight("ScheduleCode:Edit", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String id = Util.null2String(params.get("id")); + Map table = new HashMap(); + List> columns = new ArrayList<>(); + List> datas = new ArrayList<>(); + Map data = null; + List titles = new ArrayList<>(); + + HrmFieldBean hrmFieldBean = null; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("deviceid"); + hrmFieldBean.setFieldlabel("511397"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("scheduledevice"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setWidth("200"); + Map dataParams = new HashMap(); + dataParams.put("subcompanyid",resourceComInfo.getSubCompanyID(id)); + hrmFieldBean.setDataParams(dataParams); + titles.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("schedulecode"); + hrmFieldBean.setFieldlabel("27960"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setWidth("200"); + hrmFieldBean.setMultilang(false); + titles.add(hrmFieldBean); + + Map scheduledeviceMap = new HashMap<>(); + sql = " select * from kq_schedule_device "; + rs.executeQuery(sql); + while(rs.next()){ + scheduledeviceMap.put(rs.getString("id"),rs.getString("devicename")); + } + + columns = HrmFieldUtil.getHrmDetailTable(titles, null, user); + table.put("columns", columns); + sql = " select * from kq_schedule_code where resourceid = ? "; + rs.executeQuery(sql,id); + while(rs.next()){ + data = new HashMap<>(); + data.put("id", rs.getString("id")); + data.put("deviceid", Util.getIntValue(rs.getString("deviceid"))>0?rs.getString("deviceid"):""); + data.put("deviceidspan", scheduledeviceMap.get(rs.getString("deviceid"))); + data.put("schedulecode", rs.getString("schedulecode")); + datas.add(data); + } + table.put("datas",datas); + + retmap.put("status", "1"); + retmap.put("table", table); + + int operatelevel = -1; + String subcompanyid = resourceComInfo.getSubCompanyID(id); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + if(hrmdetachable){ + if(subcompanyid.length()>0 && !subcompanyid.equalsIgnoreCase("0")){ + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + operatelevel=checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"ScheduleCode:Edit",Util.getIntValue(subcompanyid,-1)); + } + }else{ + operatelevel = 2; + } + + if(user.getUID() == 1){ + operatelevel = 2; + } + if(operatelevel > 0){ + retmap.put("canAdd", true); + }else{ + retmap.put("canAdd", false); + } + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + +} diff --git a/src/com/engine/kq/cmd/schedulecode/GetScheduleCodeImportFormCmd.java b/src/com/engine/kq/cmd/schedulecode/GetScheduleCodeImportFormCmd.java new file mode 100644 index 0000000..ddbee52 --- /dev/null +++ b/src/com/engine/kq/cmd/schedulecode/GetScheduleCodeImportFormCmd.java @@ -0,0 +1,118 @@ +package com.engine.kq.cmd.schedulecode; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +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 weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + + +public class GetScheduleCodeImportFormCmd extends AbstractCommonCommand>{ + + public GetScheduleCodeImportFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + SearchConditionItem searchConditionItem = null; + + try { + if (!HrmUserVarify.checkUserRight("ScheduleCode:Edit", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + ConditionFactory conditionFactory = new ConditionFactory(user); + + String excelpath = "/hrm/schedule/inputexcellfile/inputScheduleCodeE9.xls"; + itemlist = new ArrayList(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage())); + groupitem.put("defaultshow", true); + + //重复验证字段 + List statusOptions = new ArrayList(); + statusOptions.add(new SearchConditionOption("lastname",SystemEnv.getHtmlLabelName(413, user.getLanguage()))); + statusOptions.add(new SearchConditionOption("workcode",SystemEnv.getHtmlLabelName(714, user.getLanguage()),true)); + searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 33582,"keyField",statusOptions); + searchConditionItem.setValue("workcode"); + itemlist.add(searchConditionItem); + + //模板文件 + searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT,28576,"templet"); + searchConditionItem.setValue(excelpath); + itemlist.add(searchConditionItem); + + //Excel文件 + searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, 16630, "excelfile"); + itemlist.add(searchConditionItem); + + groupitem.put("items", itemlist); + lsGroup.add(groupitem); + + + itemlist = new ArrayList(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(33803,weaver.general.Util.getIntValue(user.getLanguage()))); + groupitem.put("defaultshow", true); + List lsPromptLabel = new ArrayList(); //提示信息 + lsPromptLabel.add("511420"); + lsPromptLabel.add("511421"); + lsPromptLabel.add("511422"); + lsPromptLabel.add("511423"); + + for(int i=0;i item = new HashMap(); + item.put("index", (i+1)); + String value = ""; + String[] label = Util.splitString(lsPromptLabel.get(i), ","); + value = Util.toScreen(SystemEnv.getHtmlLabelNames(label[0], user.getLanguage()), user.getLanguage()); + if(label.length>1){ + value = Util.toScreen(SystemEnv.getHtmlLabelNames(label[1], user.getLanguage()), user.getLanguage()); + } + if(i==0){ + value += SystemEnv.getHtmlLabelName(28576, user.getLanguage()); + item.put("link",excelpath); + } + item.put("value",value); + itemlist.add(item); + } + groupitem.put("items", itemlist); + lsGroup.add(groupitem); + + retmap.put("status", "1"); + retmap.put("condition", lsGroup); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + +} diff --git a/src/com/engine/kq/cmd/schedulecode/GetScheduleCodeListCmd.java b/src/com/engine/kq/cmd/schedulecode/GetScheduleCodeListCmd.java new file mode 100644 index 0000000..f3fa769 --- /dev/null +++ b/src/com/engine/kq/cmd/schedulecode/GetScheduleCodeListCmd.java @@ -0,0 +1,214 @@ +package com.engine.kq.cmd.schedulecode; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +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_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.util.PageUidFactory; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.appdetach.AppDetachComInfo; +import weaver.hrm.common.Tools; +import weaver.hrm.common.database.dialect.DialectUtil; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + + +public class GetScheduleCodeListCmd extends AbstractCommonCommand>{ + + public GetScheduleCodeListCmd(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 { + if(!HrmUserVarify.checkUserRight("ScheduleCode:Edit",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + int operatelevel = -1; + + String lastname = Util.null2String(params.get("lastname")); + String subcompanyid = Util.null2String(params.get("subcompanyid")); + String departmentid = Util.null2String(params.get("departmentid")); + String jobtitle = Util.null2String(params.get("jobtitle")); + String schedulecode = Util.null2String(params.get("schedulecode")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + String showAllLevel = Util.null2String(params.get("showAllLevel")); + + boolean isOneDevice = true; + sql = " select count(1) from kq_schedule_device "; + rs.executeQuery(sql); + if(rs.next()){ + if(rs.getInt(1)>1){ + isOneDevice = false; + } + } + + String backfields = " id,lastname,subcompanyid1,departmentid,jobtitle, id as id1 , id as id2"; + String fromSql = " HrmResource "; + String sqlWhere = " 1=1 "; + String orderby = " dsporder,lastname " ; + + if(hrmdetachable){ + int[] arrSubcompanyids = checkSubCompanyRight.getSubComByUserRightId(user.getUID(),"ScheduleCode:Edit"); + operatelevel=checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"ScheduleCode:Edit",Util.getIntValue(subcompanyid,-1)); + String subcompanyids = ""; + if(user.getUID() != 1){ + for(int i=0;arrSubcompanyids!=null&&i0)subcompanyids+=","; + subcompanyids += arrSubcompanyids[i]; + } + if(subcompanyids.length() > 0 ){ + sqlWhere += " and subcompanyid1 in("+subcompanyids+")"; + }else{ + sqlWhere += " and 1=2 "; + } + } + }else{ + operatelevel = 2; + } + + if(user.getUID() == 1){ + operatelevel = 2; + } + + if(lastname.length()>0){ + String mysqlEscope = "/" ; + if(DialectUtil.isMySql()){ + sqlWhere += " and (lastname like '%"+ Util.StringReplace(lastname, "_", mysqlEscope+"_") +"%' escape '"+mysqlEscope+"' or pinyinlastname like '%"+Util.StringReplace(lastname.toLowerCase(), "_", mysqlEscope+"_")+"%' escape '"+mysqlEscope+"' )"; + }else{ + sqlWhere += " and (lastname like '%"+ Util.StringReplace(lastname, "_", "\\_") +"%' escape '\\' or pinyinlastname like '%"+Util.StringReplace(lastname.toLowerCase(), "_", "\\_")+"%' escape '\\' )"; + } + } + + if(subcompanyid.length() > 0){ + String subcompanyAll = ""; + String[] sub = subcompanyid.split(","); + if (sub != null) { + for (int cx = 0; cx < sub.length; cx++) { + String subid_ = sub[cx]; + if (subid_ != null && !"".equals(subid_) && showAllLevel.equals("1")) { + subcompanyAll = SubCompanyComInfo.getAllChildSubcompanyId(subid_, subcompanyAll); + } + } + } + if (!"".equals(subcompanyAll)) { + subcompanyAll = subcompanyid + subcompanyAll.trim(); + } else { + subcompanyAll = subcompanyid; + } + sqlWhere += " and "+Tools.getOracleSQLIn(subcompanyAll, "subcompanyid1"); + } + if(departmentid.length() > 0){ + String departmentAll = ""; + String[] dep = departmentid.split(","); + if (dep != null) { + for (int cx = 0; cx < dep.length; cx++) { + String depid_ = dep[cx]; + if (depid_ != null && !"".equals(depid_) && showAllLevel.equals("1")) { + departmentAll = DepartmentComInfo.getAllChildDepartId(depid_, departmentAll); + } + } + } + if (!"".equals(departmentAll)) { + departmentAll = departmentid + departmentAll.trim(); + } else { + departmentAll = departmentid; + } + sqlWhere += " and "+Tools.getOracleSQLIn(departmentAll, "departmentid"); + } + if(jobtitle.length() >0){ + sqlWhere += " and jobtitle in("+jobtitle+")"; + } + + if (!"1".equals(isNoAccount)) { + sqlWhere += " and loginid is not null "+(rs.getDBType().equals("oracle")?"":" and loginid<>'' "); + } + + if(schedulecode.length() >0){ + sqlWhere += " and id in(SELECT DISTINCT resourceid FROM kq_schedule_code WHERE schedulecode LIKE '%"+schedulecode+"%')"; + } + + AppDetachComInfo adci = new AppDetachComInfo(); + String appdetawhere = adci.getScopeSqlByHrmResourceSearch(user.getUID()+""); + sqlWhere += (appdetawhere!=null&&!"".equals(appdetawhere)?(" and " + appdetawhere):""); + + String pageUid = PageUidFactory.getHrmPageUid("ScheduleCodeList"); + + String operateString= ""; + operateString+=" "; + if(!isOneDevice){ + operateString+=" "; + } + operateString+=" "; + operateString+=""; + String tableString =" "+ + " "+ + operateString+ + " "+ + " "+ + " "+ + " "+ + " "; + if(isOneDevice){ + tableString+=" "; + }else{ + tableString+=" "; + } + tableString+=" "+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + retmap.put("sessionkey", sessionkey); + retmap.put("isOneDevice", isOneDevice); + retmap.put("status", "1"); + if(operatelevel > 0){ + retmap.put("canAdd", true); + }else{ + retmap.put("canAdd", false); + } + if(operatelevel > 1){ + retmap.put("canDel", true); + }else{ + retmap.put("canDel", false); + } + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/schedulecode/GetScheduleDeviceConditionCmd.java b/src/com/engine/kq/cmd/schedulecode/GetScheduleDeviceConditionCmd.java new file mode 100644 index 0000000..d481e2e --- /dev/null +++ b/src/com/engine/kq/cmd/schedulecode/GetScheduleDeviceConditionCmd.java @@ -0,0 +1,102 @@ +package com.engine.kq.cmd.schedulecode; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + + +public class GetScheduleDeviceConditionCmd extends AbstractCommonCommand>{ + + public GetScheduleDeviceConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("ScheduleCode:Edit",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + Map> fieldGroups= new LinkedHashMap>(); + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + List options = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("devicename"); + hrmFieldBean.setFieldlabel("512449"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("devicecode"); + hrmFieldBean.setFieldlabel("512448"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("subcompanyids"); + hrmFieldBean.setFieldlabel("506413"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("164"); + lsField.add(hrmFieldBean); + fieldGroups.put("1361", lsField); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + Iterator>> iter = fieldGroups.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry> entry = iter.next(); + String grouplabel = entry.getKey(); + List fields = entry.getValue(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelNames(grouplabel, user.getLanguage())); + groupitem.put("defaultshow", true); + + itemlist = new ArrayList(); + for (int j = 0; j < fields.size(); j++) { + hrmFieldBean = fields.get(j); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + } + + retmap.put("status", "1"); + retmap.put("conditions", grouplist); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/com/engine/kq/cmd/schedulecode/GetScheduleDeviceFormCmd.java b/src/com/engine/kq/cmd/schedulecode/GetScheduleDeviceFormCmd.java new file mode 100644 index 0000000..b634024 --- /dev/null +++ b/src/com/engine/kq/cmd/schedulecode/GetScheduleDeviceFormCmd.java @@ -0,0 +1,134 @@ +package com.engine.kq.cmd.schedulecode; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + + +public class GetScheduleDeviceFormCmd extends AbstractCommonCommand>{ + + public GetScheduleDeviceFormCmd(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 { + if (!HrmUserVarify.checkUserRight("ScheduleCode:Edit", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + + String id = Util.null2String(params.get("id")); + String devicename = ""; + String devicecode = ""; + String ip = ""; + String subcompanyids = ""; + + sql = " select * from kq_schedule_device where id = ? "; + rs.executeQuery(sql,id); + if(rs.next()){ + devicename = Util.null2String(rs.getString("devicename")); + devicecode = Util.null2String(rs.getString("devicecode")); + ip = Util.null2String(rs.getString("ip")); + subcompanyids = Util.null2String(rs.getString("subcompanyids")); + } + + HrmFieldBean hrmFieldBean = null; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("id"); + hrmFieldBean.setFieldlabel("512449"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(id); + Map otherParams = new HashMap(); + otherParams.put("hide", true); + hrmFieldBean.setOtherparam(otherParams); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("devicename"); + hrmFieldBean.setFieldlabel("512449"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(devicename); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("devicecode"); + hrmFieldBean.setFieldlabel("512448"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(devicecode); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("ip"); + hrmFieldBean.setFieldlabel("32531"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(ip); + hrmFieldBean.setViewAttr(2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("subcompanyids"); + hrmFieldBean.setFieldlabel("506413"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("194"); + hrmFieldBean.setFieldvalue(subcompanyids); + hrmFieldBean.setViewAttr(2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + retmap.put("condition", groupList); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + +} diff --git a/src/com/engine/kq/cmd/schedulecode/GetScheduleDeviceListCmd.java b/src/com/engine/kq/cmd/schedulecode/GetScheduleDeviceListCmd.java new file mode 100644 index 0000000..dac5b72 --- /dev/null +++ b/src/com/engine/kq/cmd/schedulecode/GetScheduleDeviceListCmd.java @@ -0,0 +1,112 @@ +package com.engine.kq.cmd.schedulecode; + +import java.util.HashMap; +import java.util.Map; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.util.PageUidFactory; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.common.database.dialect.DbDialectFactory; +import weaver.hrm.common.database.dialect.DialectUtil; +import weaver.hrm.common.database.dialect.IDbDialectSql; +import weaver.systeminfo.SystemEnv; + + +public class GetScheduleDeviceListCmd extends AbstractCommonCommand>{ + + public GetScheduleDeviceListCmd(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 { + if(!HrmUserVarify.checkUserRight("ScheduleCode:Edit",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String devicename = Util.null2String(params.get("devicename")); + String devicecode = Util.null2String(params.get("devicecode")); + String subcompanyid = Util.null2String(params.get("subcompanyids")); + + String backfields = " * "; + String fromSql = " kq_schedule_device "; + String sqlWhere = " 1=1 "; + String orderby = " id " ; + + if (!subcompanyid.equals("")) { + if (rs.getDBType().equals("oracle")) { + sqlWhere += " and ','||cast(subcompanyids as VARCHAR(4000))||',' like '%," + subcompanyid + ",%'"; + } else if (DialectUtil.isMySql()) { + IDbDialectSql dialect = DbDialectFactory.get(rs.getDBType()); + String castCondition = dialect.castToChar("subcompanyids", 4000); + String dot = "','"; + String t0FieldConcat = dialect.concatStr(dot, castCondition, dot); + sqlWhere += " and " + t0FieldConcat + " like '%," + subcompanyid + ",%'"; + } else { + sqlWhere += " and ','+cast(subcompanyids as NVARCHAR(4000))+',' like '%," + subcompanyid + ",%'"; + } + } + + if (!devicename.equals("")) { + sqlWhere += " and devicename like '%"; + sqlWhere += devicename; + sqlWhere += "%'"; + } + if (!devicecode.equals("")) { + sqlWhere += " and devicecode like '%"; + sqlWhere += devicecode; + sqlWhere += "%'"; + } + String pageUid = PageUidFactory.getHrmPageUid("ScheduleDeviceList"); + + String operateString= ""; + operateString+=" "; + operateString+=" "; + operateString+=" "; + operateString+=" "; + operateString+=""; + String tableString =" "+ + " "+ + " "+ + operateString+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "; + tableString+=" "+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/schedulecode/SaveScheduleCodeCmd.java b/src/com/engine/kq/cmd/schedulecode/SaveScheduleCodeCmd.java new file mode 100644 index 0000000..d462d1c --- /dev/null +++ b/src/com/engine/kq/cmd/schedulecode/SaveScheduleCodeCmd.java @@ -0,0 +1,233 @@ +package com.engine.kq.cmd.schedulecode; + +import java.util.*; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.api.hrm.util.ServiceUtil; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.hrm.util.face.HrmFaceCheckManager; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.common.DbFunctionUtil; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + + +public class SaveScheduleCodeCmd extends AbstractCommonCommand>{ + + private SimpleBizLogger logger; + public SaveScheduleCodeCmd(Map params, User user) { + this.user = user; + this.params = params; + +// this.logger = new SimpleBizLogger(); +// BizLogContext bizLogContext = new BizLogContext(); +// bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 +// bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_SCHEDULECODE); +// bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_SCHEDULECODE);//当前小类型 +// bizLogContext.setParams(params);//当前request请求参数 +// logger.setUser(user);//当前操作人 +// String cmd = Util.null2String(params.get("cmd")).trim(); +// String resourceids = ""; +// if(cmd.equals("batch")) { +// resourceids = Util.null2String(params.get("resourceids")).trim().replace(";",","); +// }else{ +// String data = Util.null2String(params.get("data")); +// JSONObject jsonObj = JSON.parseObject(data); +// resourceids = Util.null2String(jsonObj.get("resourceid")).replace(";",","); +// } +// String mainSql = "select * from hrmresource where id in ("+resourceids+") "; +// logger.setMainSql(mainSql, "id");//主表sql +// logger.setMainPrimarykey("id");//主日志表唯一key +// logger.setMainTargetNameColumn("lastname"); +// SimpleBizLogger.SubLogInfo subLogInfo = logger.getNewSubLogInfo(); +// String subSql = "select * from kq_schedule_code where resourceid in ("+resourceids+")"; +// subLogInfo.setSubSql(subSql,"id"); +// logger.addSubLogInfo(subLogInfo); +// logger.before(bizLogContext); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSetTrans rst = new RecordSetTrans(); + String sql = ""; + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); +// retmap = this.check(); +// if(!retmap.isEmpty()){ +// return retmap; +// } + rst.setAutoCommit(false); + String cmd = Util.null2String(params.get("cmd")).trim(); + if(cmd.equals("batch")){ + String deviceid = ""; + sql = " select id from kq_schedule_device "; + rst.executeQuery(sql); + if(rst.next()){ + deviceid = rst.getString("id"); + } + + String resourceids = Util.null2String(params.get("resourceids")).trim(); + String schedulecodes = Util.null2String(params.get("schedulecodes")).trim(); + String[] arrResourceIds = Util.splitString(resourceids, ";"); + String[] arrScheduleCodes = Util.splitString(schedulecodes, ";"); + for(int i=0;i tmpArrScheduleCodes = Util.splitString2List(arrScheduleCodes[i], ","); + for(int j=0;j check = new ArrayList<>(); + for(int i=0;i tmpArrScheduleCodes = Util.splitString2List(schedulecode, ","); + check.add(deviceid+"_"+schedulecode); + for(int j=0;j check() { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + if(!HrmUserVarify.checkUserRight("ScheduleCode:Edit",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String cmd = Util.null2String(params.get("cmd")).trim(); + if(cmd.equals("batch")){ + String resourceids = Util.null2String(params.get("resourceids")).trim(); + String schedulecodes = Util.null2String(params.get("schedulecodes")).trim(); + String[] arrResourceIds = Util.splitString(resourceids, ";"); + String[] arrScheduleCodes = Util.splitString(schedulecodes, ";"); + List lsScheduleCodes = new ArrayList<>(); + for(int i=0;i tmpArrScheduleCodes = Util.splitString2List(arrScheduleCodes[i], ","); + lsScheduleCodes.addAll(tmpArrScheduleCodes); + for(int j=0;jshowColumn.trim().equals("")); + if(lsScheduleCodes.size() != new HashSet(lsScheduleCodes).size()){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(10000836,weaver.general.Util.getIntValue(user.getLanguage()))); + } + }else{ + String data = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(data); + String resourceid = Util.null2String(jsonObj.get("resourceid")); + JSONArray datas = jsonObj.getJSONArray("datas"); + List check = new ArrayList<>(); + for(int i=0;i tmpArrScheduleCodes = Util.splitString2List(schedulecode, ","); + if(tmpArrScheduleCodes.size() != new HashSet(tmpArrScheduleCodes).size()||check.contains(deviceid+"_"+schedulecode)){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(10000836,weaver.general.Util.getIntValue(user.getLanguage()))); + break; + } + check.add(deviceid+"_"+schedulecode); + for(int j=0;j getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/schedulecode/SaveScheduleCodeImportCmd.java b/src/com/engine/kq/cmd/schedulecode/SaveScheduleCodeImportCmd.java new file mode 100644 index 0000000..d9d0a51 --- /dev/null +++ b/src/com/engine/kq/cmd/schedulecode/SaveScheduleCodeImportCmd.java @@ -0,0 +1,63 @@ +package com.engine.kq.cmd.schedulecode; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; + +import java.util.*; + +import com.engine.kq.util.ImportProcessUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; + +public class SaveScheduleCodeImportCmd extends AbstractCommonCommand> { + private HttpServletRequest request; + + public SaveScheduleCodeImportCmd(Map params, User user, HttpServletRequest request) { + this.user = user; + this.params = params; + this.request = request; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("ScheduleCode:Edit", user);//是否具有新建权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + List errorInfoList = new ArrayList(); + ImportProcessUtil importProcessUtil = new ImportProcessUtil(); + List errorInfo = importProcessUtil.importXls(params, user, request); + if (errorInfo != null && !errorInfo.isEmpty()) { + Map error = null; + for (int i = 0; i < errorInfo.size(); i++) { + error = new HashMap(); + error.put("message", Util.null2String(errorInfo.get(i))); + errorInfoList.add(error); + } + } + resultMap.put("errorInfo", errorInfoList); + resultMap.put("status", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(24645, user.getLanguage())); + } catch (Exception e) { + writeLog("导入人员考勤编号失败:" + e); + resultMap.put("status", "-1"); + resultMap.put("message", e.getMessage()); + } + resultMap.put("pId", request.getSession(true).getAttribute("kqScheduleCodePId")); + return resultMap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} \ No newline at end of file diff --git a/src/com/engine/kq/cmd/schedulecode/SaveScheduleDeviceCmd.java b/src/com/engine/kq/cmd/schedulecode/SaveScheduleDeviceCmd.java new file mode 100644 index 0000000..c6f10c6 --- /dev/null +++ b/src/com/engine/kq/cmd/schedulecode/SaveScheduleDeviceCmd.java @@ -0,0 +1,106 @@ +package com.engine.kq.cmd.schedulecode; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + + +public class SaveScheduleDeviceCmd extends AbstractCommonCommand>{ + + private SimpleBizLogger logger; + public SaveScheduleDeviceCmd(Map params, User user) { + this.user = user; + this.params = params; + + this.logger = new SimpleBizLogger(); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_SCHEDULEDEVICE); + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_SCHEDULEDEVICE);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + + String id = Util.null2String(params.get("id")); + String devicecode = Util.null2String(params.get("devicecode")); + String mainSql = ""; + if(id.length()>0){ + mainSql = "select * from kq_schedule_device where id = "+id; + }else{ + mainSql = "select * from kq_schedule_device where devicecode = '"+devicecode+"'"; + } + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("devicename"); + logger.before(bizLogContext); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String checkSql = ""; + String sql = ""; + try { + if(!HrmUserVarify.checkUserRight("ScheduleCode:Edit",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String id = Util.null2String(params.get("id")); + String devicename = Util.null2String(params.get("devicename")); + String devicecode = Util.null2String(params.get("devicecode")); + String ip = Util.null2String(params.get("ip")); + String subcompanyids = Util.null2String(params.get("subcompanyids")); + + + if(id.length()>0){ + checkSql = "select count(1) from kq_schedule_device where devicecode='"+devicecode+"' and id != "+id; + sql = "update kq_schedule_device set devicename = '"+devicename+"',devicecode='"+devicecode+"',ip='"+ip+"',subcompanyids='"+subcompanyids+"' where id = "+id; + }else{ + checkSql = "select count(1) from kq_schedule_device where devicecode='"+devicecode+"'"; + sql = "INSERT INTO kq_schedule_device( devicename ,devicecode ,ip,subcompanyids ) VALUES ( '"+devicename+"' ,'"+devicecode+"' ,'"+ip+"','"+subcompanyids+"')"; + } + if(rs.executeQuery(checkSql)){ + if(rs.next() ) { + if (rs.getInt(1) > 0) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(513267, user.getLanguage())); + return retmap; + } + } + } + rs.executeUpdate(sql); + retmap.put("status", "1"); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/schedulesignimport/GetImportFormCmd.java b/src/com/engine/kq/cmd/schedulesignimport/GetImportFormCmd.java new file mode 100644 index 0000000..487d01f --- /dev/null +++ b/src/com/engine/kq/cmd/schedulesignimport/GetImportFormCmd.java @@ -0,0 +1,125 @@ +package com.engine.kq.cmd.schedulesignimport; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +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 weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + + +public class GetImportFormCmd extends AbstractCommonCommand>{ + + public GetImportFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + SearchConditionItem searchConditionItem = null; + + try { + if (!HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + ConditionFactory conditionFactory = new ConditionFactory(user); + + String excelpath = "/hrm/schedule/inputexcellfile/inputE9.xls"; + itemlist = new ArrayList(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage())); + groupitem.put("defaultshow", true); + + //重复验证字段 + List statusOptions = new ArrayList(); + statusOptions.add(new SearchConditionOption("loginid",SystemEnv.getHtmlLabelName( 412, user.getLanguage()))); + statusOptions.add(new SearchConditionOption("workcode",SystemEnv.getHtmlLabelName(714, user.getLanguage()),true)); + statusOptions.add(new SearchConditionOption("lastname",SystemEnv.getHtmlLabelName(413, user.getLanguage()))); + searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 33582,"keyField",statusOptions); + searchConditionItem.setValue("workcode"); + itemlist.add(searchConditionItem); + + //模板文件 + searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT,28576,"templet"); + searchConditionItem.setValue(excelpath); + itemlist.add(searchConditionItem); + + //Excel文件 + searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, 16630, "excelfile"); + itemlist.add(searchConditionItem); + + groupitem.put("items", itemlist); + lsGroup.add(groupitem); + + + itemlist = new ArrayList(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(33803,weaver.general.Util.getIntValue(user.getLanguage()))); + groupitem.put("defaultshow", true); + List lsPromptLabel = new ArrayList(); //提示信息 + lsPromptLabel.add("124999"); + lsPromptLabel.add("125000"); + lsPromptLabel.add("125001"); + lsPromptLabel.add("125002"); + lsPromptLabel.add("503604"); + lsPromptLabel.add("390316"); + lsPromptLabel.add("390317"); + lsPromptLabel.add("33456,125006"); + lsPromptLabel.add("27961,125007"); + lsPromptLabel.add("33586,125008"); + + for(int i=0;i item = new HashMap(); + item.put("index", (i+1)); + String value = ""; + String[] label = Util.splitString(lsPromptLabel.get(i), ","); + value = Util.toScreen(SystemEnv.getHtmlLabelNames(label[0], user.getLanguage()), user.getLanguage()); + if(label.length>1){ + value = Util.toScreen(SystemEnv.getHtmlLabelNames(label[1], user.getLanguage()), user.getLanguage()); + } + if(i==0){ + value += SystemEnv.getHtmlLabelName(28576, user.getLanguage()); + item.put("link",excelpath); + } + item.put("value",value); + itemlist.add(item); + } + groupitem.put("items", itemlist); + lsGroup.add(groupitem); + + retmap.put("status", "1"); + retmap.put("condition", lsGroup); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + +} diff --git a/src/com/engine/kq/cmd/schedulesignimport/GetImportSetFormCmd.java b/src/com/engine/kq/cmd/schedulesignimport/GetImportSetFormCmd.java new file mode 100644 index 0000000..23f72e3 --- /dev/null +++ b/src/com/engine/kq/cmd/schedulesignimport/GetImportSetFormCmd.java @@ -0,0 +1,275 @@ +package com.engine.kq.cmd.schedulesignimport; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldUtil; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.servicefiles.DataSourceXML; +import weaver.servicefiles.ScheduleXML; +import weaver.systeminfo.SystemEnv; + +public class GetImportSetFormCmd extends AbstractCommonCommand> { + + public GetImportSetFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List lsGroup = new ArrayList(); + Map groupitem = null; + List itemlist = null; + Map item = null; + RecordSet rs = new RecordSet(); + String sql = ""; + + try { + if (!HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + itemlist = new ArrayList(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(33537, user.getLanguage())); + groupitem.put("defaultshow", true); + boolean oldisinvald = false; + ScheduleXML ScheduleXML = new ScheduleXML(); + if (ScheduleXML.getPointArrayList().indexOf("KQScheduleSignImport") > -1){ + oldisinvald = true; + } + item = new HashMap(); + item.put("isVaild", oldisinvald); + item.put("tips", SystemEnv.getHtmlLabelName(125962,user.getLanguage())); + itemlist.add(item); + item = new HashMap(); + item.put("tips", SystemEnv.getHtmlLabelName(33544,user.getLanguage())); + itemlist.add(item); + groupitem.put("items", itemlist); + lsGroup.add(groupitem); + + itemlist = new ArrayList(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(33538, user.getLanguage())); + groupitem.put("defaultshow", true); + List titles = null; + Map table = null; + HrmFieldBean hrmFieldBean = null; + List> columns = null; + List> datas = null; + Map data = null; + + titles = new ArrayList(); + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("datasourceid"); + hrmFieldBean.setFieldlabel("23963"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + List options = null; + DataSourceXML DataSourceXML = new DataSourceXML(); + ArrayList pointArrayList = DataSourceXML.getPointArrayList(); + options = new ArrayList(); + for(int i=0;pointArrayList!=null&&i(); + columns = HrmFieldUtil.getHrmDetailTable(titles, null, user); + table.put("columns", columns); + + datas = new ArrayList>(); + sql = " select datasourceid, tablename, loginid, workcode, lastname, signdate, signtime, clientaddress,longitude,latitude,addr,memo " + + " from HrmScheduleSignSet " + + " order by datasourceid desc "; + rs.executeSql(sql); + StringBuffer ajaxData = new StringBuffer(); + ajaxData.append("["); + while (rs.next()) { + data = new HashMap(); + String[] fieldnames = new String[] { "datasourceid", "tablename", "loginid","workcode", "lastname", "signdate", "signtime", "clientaddress", "longitude", "latitude", "addr", "memo" }; + for (int i = 0; i < fieldnames.length; i++) { + data.put(fieldnames[i], Util.null2String(rs.getString(fieldnames[i]))); + } + datas.add(data); + } + table.put("datas", datas); + item = new HashMap(); + item.put("table", table); + itemlist.add(item); + groupitem.put("items", itemlist); + lsGroup.add(groupitem); + + itemlist = new ArrayList(); + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(10000655,weaver.general.Util.getIntValue(user.getLanguage()))); + groupitem.put("defaultshow", true); + List lsPromptLabel = new ArrayList(); //提示信息 + lsPromptLabel.add("23963,124881"); + lsPromptLabel.add("23574,124882"); + lsPromptLabel.add("503606"); + lsPromptLabel.add("503607"); + lsPromptLabel.add("503608"); + lsPromptLabel.add("33563,124885"); + lsPromptLabel.add("20035,124886"); + lsPromptLabel.add("20045,124887"); + + for(int i=0;i(); + item.put("index", (i+1)); + String value = ""; + String[] label = Util.splitString(lsPromptLabel.get(i), ","); + value = Util.toScreen(SystemEnv.getHtmlLabelNames(label[0], user.getLanguage()), user.getLanguage()); + if(label.length>1){ + value = Util.toScreen(SystemEnv.getHtmlLabelNames(label[1], user.getLanguage()), user.getLanguage()); + } + item.put("value",value); + itemlist.add(item); + } + groupitem.put("items", itemlist); + lsGroup.add(groupitem); + +// itemlist = new ArrayList(); +// groupitem = new HashMap(); +// groupitem.put("title", SystemEnv.getHtmlLabelNames("33587,85", user.getLanguage())); +// groupitem.put("defaultshow", true); +// lsPromptLabel = new ArrayList(); //提示信息 +// lsPromptLabel.add("124888"); +// +// for(int i=0;i(); +// item.put("index", (i+1)); +// String value = ""; +// String[] label = Util.splitString(lsPromptLabel.get(i), ","); +// value = Util.toScreen(SystemEnv.getHtmlLabelNames(label[0], user.getLanguage()), user.getLanguage()); +// if(label.length>1){ +// value = Util.toScreen(SystemEnv.getHtmlLabelNames(label[1], user.getLanguage()), user.getLanguage()); +// } +// item.put("value",value); +// itemlist.add(item); +// } +// groupitem.put("items", itemlist); +// lsGroup.add(groupitem); + + retmap.put("group", lsGroup); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/com/engine/kq/cmd/schedulesignimport/SaveImportCmd.java b/src/com/engine/kq/cmd/schedulesignimport/SaveImportCmd.java new file mode 100644 index 0000000..d8676ca --- /dev/null +++ b/src/com/engine/kq/cmd/schedulesignimport/SaveImportCmd.java @@ -0,0 +1,104 @@ +package com.engine.kq.cmd.schedulesignimport; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import com.engine.kq.biz.KQScheduleSignImport; +import weaver.systeminfo.SystemEnv; + +public class SaveImportCmd extends AbstractCommonCommand> { + protected HttpServletRequest request; + + private SimpleBizLogger logger; + + public SaveImportCmd() { + + } + + public SaveImportCmd(Map params, User user) { + this.user = user; + this.params = params; +// this.logger = new SimpleBizLogger(); +// BizLogContext logContext = new BizLogContext(); +// logContext.setDateObject(new Date()); +// logContext.setLogType(BizLogType.HRM_ENGINE); +// logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_HRM_SCHEDULESIGN_IMPORT); +// logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_HRM_SCHEDULESIGN_IMPORT); +// logContext.setParams(params); +// logger.setUser(user);//当前操作人 +// +// String mainSql = "select a.* from hrmschedulesign a "; +// logger.setMainSql(mainSql);//主表sql +// logger.setMainPrimarykey("id");//主日志表唯一key +// logger.setMainTargetNameMethod(this.getClass().getName() + ".getTargetName", "column:userid"); +// logger.before(logContext); + } + + /** + * 获取日志对象的名称 + * @param id + * @param para2 + * @return + */ + public String getTargetName(String id,String para2){ + ResourceComInfo rc = null; + String userid = Util.null2s(para2, ""); + try { + rc = new ResourceComInfo(); + return rc.getLastname(userid); + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try { + if (!HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + KQScheduleSignImport kqScheduleSignImport = new KQScheduleSignImport(params); + kqScheduleSignImport.setUserlanguage(user.getLanguage()); + List errorInfo =kqScheduleSignImport.ScanFile(); + kqScheduleSignImport.ExcelToDB(); + if(errorInfo.isEmpty()){ + errorInfo.add(SystemEnv.getHtmlLabelName(28450,user.getLanguage())); + } + retmap.put("errorInfo", errorInfo); + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(24645, user.getLanguage())); + } catch (Exception e) { + writeLog("导入外部考勤数据失败:" + e); + retmap.put("status", "-1"); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/schedulesignimport/SaveImportSetCmd.java b/src/com/engine/kq/cmd/schedulesignimport/SaveImportSetCmd.java new file mode 100644 index 0000000..aab2f34 --- /dev/null +++ b/src/com/engine/kq/cmd/schedulesignimport/SaveImportSetCmd.java @@ -0,0 +1,156 @@ +package com.engine.kq.cmd.schedulesignimport; + +import com.api.hrm.bean.HrmFieldBean; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.servicefiles.ScheduleXML; +import weaver.systeminfo.SystemEnv; + +public class SaveImportSetCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public SaveImportSetCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_HRM_SCHEDULESIGN_IMPORT); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_HRM_SCHEDULESIGN_IMPORT); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + ScheduleXML ScheduleXML = new ScheduleXML(); + + String mainSql = " select a.*,"+(ScheduleXML.getPointArrayList().indexOf("KQScheduleSignImport") > -1?"1":"0")+" as isVaild from HrmScheduleSignSet a "; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("datasourceid");//主日志表唯一key + logger.setMainTargetNameColumn("tablename"); + logger.before(logContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + if (!HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + + ScheduleXML ScheduleXML = new ScheduleXML(); + //保存是否启用 + String isVaild = Util.null2String(params.get("isVaild")); + ArrayList pointArrayList = ScheduleXML.getPointArrayList(); + ArrayList hstarr = new ArrayList(); + Hashtable dataHST = ScheduleXML.getDataHST(); + int idx = pointArrayList.indexOf("KQScheduleSignImport"); + for(Object pointid : pointArrayList){ + hstarr.add(dataHST.get(pointid)); + } + + if(isVaild.equals("1")){ + //启用 + if(idx==-1){ + Hashtable datadetailHST = new Hashtable(); + datadetailHST.put("construct","com.engine.kq.biz.KQScheduleSignImportJob"); + datadetailHST.put("cronExpr","0 0 1 * * ?"); + ScheduleXML.writeToScheduleXMLAdd("KQScheduleSignImport",datadetailHST); + pointArrayList.add("KQScheduleSignImport"); + + if(pointArrayList.indexOf("HrmScheduleSignImport")!=-1){ + /*ArrayList parapointids = new ArrayList(); + parapointids.add("HrmScheduleSignImport");*/ + ScheduleXML.deleteSchedule("HrmScheduleSignImport"); + pointArrayList.remove("HrmScheduleSignImport"); + } + } + }else{ + //停用 + if(idx!=-1){ + /*ArrayList parapointids = new ArrayList(); + parapointids.add("KQScheduleSignImport");*/ + ScheduleXML.deleteSchedule("KQScheduleSignImport"); + pointArrayList.remove("KQScheduleSignImport"); + } + } + + String[] datasourceids = Util.splitString(Util.null2String(params.get("datasourceid")), ",") ; + String[] tablenames = Util.splitString(Util.null2String(params.get("tablename")), ",") ; + String[] loginids = Util.splitString(Util.null2String(params.get("loginid")), ",") ; + String[] workcodes = Util.splitString(Util.null2String(params.get("workcode")), ",") ; + String[] lastnames = Util.splitString(Util.null2String(params.get("lastname")), ",") ; + String[] signdates = Util.splitString(Util.null2String(params.get("signdate")), ",") ; + String[] signtimes = Util.splitString(Util.null2String(params.get("signtime")), ",") ; + String[] clientaddresss = Util.splitString(Util.null2String(params.get("clientaddress")), ",") ; + String[] longitudes = Util.splitString(Util.null2String(params.get("longitude")), ",") ; + String[] latitudes = Util.splitString(Util.null2String(params.get("latitude")), ",") ; + String[] addrs = Util.splitString(Util.null2String(params.get("addr")), ",") ; + String[] memos = Util.splitString(Util.null2String(params.get("memo")), ",") ; + + rs.executeUpdate("delete from HrmScheduleSignSet"); + for(int i=0;datasourceids!=null&&i> { + protected HttpServletRequest request; + + private SimpleBizLogger logger; + public SynDataCmd() { + + } + + public SynDataCmd(Map params, User user) { + this.user = user; + this.params = params; +// this.logger = new SimpleBizLogger(); +// BizLogContext logContext = new BizLogContext(); +// logContext.setDateObject(new Date()); +// logContext.setLogType(BizLogType.HRM_ENGINE); +// logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_HRM_SCHEDULESIGN_IMPORT); +// logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_HRM_SCHEDULESIGN_IMPORT); +// logContext.setParams(params); +// logger.setUser(user);//当前操作人 +// +// String mainSql = "select a.* from hrmschedulesign a "; +// logger.setMainSql(mainSql);//主表sql +// logger.setMainPrimarykey("id");//主日志表唯一key +// logger.setMainTargetNameMethod(this.getClass().getName() + ".getTargetName", "column:userid"); +// logger.before(logContext); + } + + /** + * 获取日志对象的名称 + * @param id + * @param para2 + * @return + */ + public String getTargetName(String id,String para2){ + ResourceComInfo rc = null; + String userid = Util.null2s(para2, ""); + try { + rc = new ResourceComInfo(); + return rc.getLastname(userid); + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try { + if (!HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + String fromdate = Util.null2String(params.get("fromdate")); + String enddate = Util.null2String(params.get("enddate")); + //手工同步 + new KQScheduleSignImport().importData(fromdate, enddate,true); + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(30109,user.getLanguage())); + } catch (Exception e) { + writeLog("同步外部考勤数据:" + e); + retmap.put("status", "-1"); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + +} diff --git a/src/com/engine/kq/cmd/schedulesignimport/SynDataOpenCmd.java b/src/com/engine/kq/cmd/schedulesignimport/SynDataOpenCmd.java new file mode 100644 index 0000000..b60d733 --- /dev/null +++ b/src/com/engine/kq/cmd/schedulesignimport/SynDataOpenCmd.java @@ -0,0 +1,246 @@ +package com.engine.kq.cmd.schedulesignimport; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +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.KQFormatBiz; +import com.engine.kq.biz.KqFormatPoolRecordBiz; +import com.engine.kq.timer.KQQueue; +import com.engine.kq.timer.KQTaskBean; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import javax.servlet.http.HttpServletRequest; +import weaver.common.DateUtil; +import weaver.conn.BatchRecordSet; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.common.Tools; +import weaver.systeminfo.SystemEnv; + +/** + * 外部系统调用这个接口同步到考勤系统里 + */ +public class SynDataOpenCmd extends AbstractCommonCommand> { + + protected HttpServletRequest request; + protected Map params; + + public SynDataOpenCmd() { + + } + + public SynDataOpenCmd(Map params) { + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + DateFormat df = new SimpleDateFormat("HH:mm:ss"); + String sql = ""; + RecordSet rs = new RecordSet(); + BatchRecordSet bRs = new BatchRecordSet(); + List> lsParams = new ArrayList<>(); + List params = null; + + List lsFormatData = new ArrayList<>(); + List> lsFormatParams = new ArrayList<>(); + List formatParams = null; + + List> lsDelParams = new ArrayList<>(); + List delParams = null; + + JSONObject jsonObj = JSON.parseObject(Util.null2String(this.params.get("data"))); + JSONArray scheduleInfo = jsonObj.getJSONArray("scheduleInfo"); + writeLog("jsonObj.toJSONString()"+jsonObj.toJSONString()); + try { + for (int i = 0; i < scheduleInfo.size(); i++) { + JSONObject obj = (JSONObject)scheduleInfo.get(i); + + String machineCode = Util.null2String(obj.get("machineCode")).trim(); + String userCodeMachine = Util.null2String(obj.get("userCode_machine")).trim(); + String userCode = Util.null2String(obj.get("userCode")).trim(); + String signdate = Util.null2String(obj.get("checkDate")).trim(); + String signtime = Util.null2String(obj.get("checkTime")).trim(); + String clientaddress = Util.null2String(obj.get("clientAddress")).trim(); + String longitude = Util.null2String(obj.get("longitude")).trim(); + String latitude = Util.null2String(obj.get("latitude")).trim(); + String addr = Util.null2String(obj.get("addr")).trim(); + String memo = Util.null2String(obj.get("memo")).trim(); + + //判断tmpSigntime格式 08:21:11 如果为长格式需要格式化 + if (signtime.length() > 8) { + signtime = df.format(Timestamp.valueOf(signtime)); + } else if (signtime.length() < 8) { + //不带秒的情况 自动补齐 + signtime += ":00"; + } + + if (signdate.length() > 10) { + //如果时间为长格式,从signdate字段中格式化时间 + if (signdate.length() == 16) { + //不带秒的情况 自动补齐 + signdate += ":00"; + } + if (signtime.length() == 0) {//以signtime字段为有限 + signtime = df.format(Timestamp.valueOf(signdate)); + ; + } + signdate = Tools.formatDate(signdate, "yyyy-MM-dd"); + } + + //如果时间格式不带秒补齐 + if (signtime.length() <= 5) { + signtime += ":00"; + } + int userid = 0; + if (Util.null2String(userCodeMachine).length() > 0) { + //machineCode、userCode转userid + userid = getUserId(userCodeMachine,machineCode); + }else{ + userid = getUserIdByCode(userCode); + } + + if(userid<=0||signdate.length()<=0||signtime.length()<=0){ + continue; + } + params = new ArrayList<>(); + params.add(userid); + params.add(1); + params.add(signdate); + params.add(signtime); + params.add(clientaddress); + params.add(1); + params.add(1); + params.add("OutDataSourceSyn"); + params.add(longitude); + params.add(latitude); + params.add(addr); + params.add(memo); + lsParams.add(params); + + String formatData = userid+"|"+signdate+"|"+signtime; + if(!lsFormatData.contains(formatData)){ + lsFormatData.add(formatData); + } + } + + Map> overtimeMap = Maps.newHashMap(); + List overtimeList = Lists.newArrayList(); + String batchid = UUID.randomUUID().toString(); + //刷新报表数据 + for(int i=0;lsFormatData!=null&&i(); + String[] formatData = Util.splitString(lsFormatData.get(i),"|"); + String date_1 = DateUtil.addDate(formatData[1], -1); + formatParams.add(formatData[0]); + formatParams.add(date_1); + formatParams.add(batchid); + lsFormatParams.add(formatParams); + + formatParams = new ArrayList<>(); + formatParams.add(formatData[0]); + formatParams.add(formatData[1]); + formatParams.add(batchid); + lsFormatParams.add(formatParams); + + delParams = new ArrayList<>(); + delParams.add(formatData[0]); + delParams.add(formatData[1]); + delParams.add(formatData[2]); + lsDelParams.add(delParams); + + String resourceId = formatData[0]; + String kqdate = formatData[1]; + if(overtimeMap.containsKey(resourceId)){ + List tmp_overtimeList = overtimeMap.get(resourceId); + if(!tmp_overtimeList.contains(kqdate)){ + tmp_overtimeList.add(kqdate); + } + }else{ + if(!overtimeList.contains(kqdate)){ + overtimeList.add(kqdate); + } + overtimeMap.put(resourceId, overtimeList); + } + } + + //删除本次同步数据 + sql = " delete from hrmschedulesign where signfrom='OutDataSourceSyn' and userid =? and signdate = ? and signtime = ? "; + bRs.executeBatchSql(sql, lsDelParams); + + sql = " insert into HrmScheduleSign (userid, usertype, signdate, signtime, clientaddress, isincom, isimport, signfrom, longitude, latitude, addr,memo) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?)"; + bRs.executeBatchSql(sql,lsParams); + + int creator = user != null ? user.getUID() : 1; + Long formatCount = Long.valueOf(lsFormatParams.size()); + KqFormatPoolRecordBiz.poolRecord(creator,"syndataopen",formatCount,batchid); + new KQFormatBiz().formatWithBatchId(lsFormatParams); + + //处理加班生成 + List tasks = new ArrayList<>(); + for(Map.Entry> mme: overtimeMap.entrySet()){ + String resid = mme.getKey(); + List overList = mme.getValue(); + for(String date : overList){ + SplitActionUtil.pushOverTimeTasks(date,date,resid,tasks); + } + } + if(!tasks.isEmpty()){ + KQQueue.writeTasks(tasks); + } + + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName( 83885,7)); + } catch (Exception e) { + writeLog("上传考勤数据:" + e); + retmap.put("status", "-1"); + } + return retmap; + } + + public int getUserIdByCode(String userCode) { + int userid = 0; + RecordSet rs = new RecordSet(); + String sql = ""; + sql = "select id from hrmresource where workcode='" + userCode + "'"; + rs.execute(sql); + if (rs.next()) { + userid = rs.getInt("id"); + } + return userid; + } + + public static int getUserId(String userCode, String machineCode) { + int userid = 0; + RecordSet rs = new RecordSet(); + String sql = ""; + sql = "select resourceid from kq_schedule_code where schedulecode='" + userCode + "'"; + if(machineCode.length()>0){ + sql+=" and deviceid = (select id from kq_schedule_device where devicecode='"+machineCode+"')"; + } + rs.execute(sql); + if (rs.next()) { + userid = rs.getInt("resourceid"); + } + return userid; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/schedulesignimport/SynDingTalkDataCmd.java b/src/com/engine/kq/cmd/schedulesignimport/SynDingTalkDataCmd.java new file mode 100644 index 0000000..d7399ed --- /dev/null +++ b/src/com/engine/kq/cmd/schedulesignimport/SynDingTalkDataCmd.java @@ -0,0 +1,168 @@ +package com.engine.kq.cmd.schedulesignimport; + +import com.dingtalk.api.DefaultDingTalkClient; +import com.dingtalk.api.DingTalkClient; +import com.dingtalk.api.request.OapiAttendanceListRequest; +import com.dingtalk.api.request.OapiGettokenRequest; +import com.dingtalk.api.response.OapiAttendanceListResponse; +import com.dingtalk.api.response.OapiGettokenResponse; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQFormatBiz; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import weaver.common.StringUtil; +import weaver.conn.BatchRecordSet; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.Util; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; + +public class SynDingTalkDataCmd extends AbstractCommonCommand> { + private SimpleBizLogger logger; + public SynDingTalkDataCmd(Map params) { + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String sql = ""; + RecordSet rs = new RecordSet(); + BatchRecordSet bRs = new BatchRecordSet(); + RecordSet rs1 = new RecordSet(); + List lsFormatData = new ArrayList<>(); + List> lsFormatParams = new ArrayList<>(); + List formatParams = null; + + rs.executeUpdate("delete HrmScheduleSign where isimport=1 and signdate>='"+fromDate+"' and signdate<='"+toDate+"'"); + + Map resourceIdMap = new HashMap(); + rs.executeQuery("select id,workcode from hrmresource where workcode is not null and workcode<>''"); + while(rs.next()){ + resourceIdMap.put(Util.formatMultiLang(rs.getString("workcode")), StringUtil.vString(rs.getString("id"))); + } + + String corpId = StringUtil.vString(Prop.getInstance().getPropValue("HrmSynDDInfo", "corpId")); + String corpSecret = StringUtil.vString(Prop.getInstance().getPropValue("HrmSynDDInfo", "corpSecret")); + if(corpId.length()==0||corpSecret.length()==0){ + writeLog("获取钉钉考勤数据失败:corpId=="+corpId+" corpSecret=="+corpSecret); + retmap.put("status", "-1"); + retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005341,weaver.general.ThreadVarLanguage.getLang())+"corpId=="+corpId+" corpSecret=="+corpSecret); + return retmap; + } + DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken"); + OapiGettokenRequest request1 = new OapiGettokenRequest(); + request1.setAppkey(corpId); + request1.setAppsecret(corpSecret); + request1.setHttpMethod("GET"); + OapiGettokenResponse response1 = client.execute(request1); + String accessToken = response1.getAccessToken(); + + client = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/list"); + OapiAttendanceListRequest request = new OapiAttendanceListRequest(); + request.setWorkDateFrom(fromDate+" 00:00:00"); + request.setWorkDateTo(toDate+" 23:59:59"); + request.setOffset(0L); + request.setLimit(50L); + List resourceList = new ArrayList(); + int ni = 0; + rs.executeQuery("select workcode from hrmresource where workcode is not null and workcode<>''"); + while(rs.next()){ + ni++; + resourceList.add(Util.formatMultiLang(rs.getString("workcode"))); + if(ni%10==0 || ni==rs.getCounts()){ + try { + request.setUserIdList(resourceList); + OapiAttendanceListResponse response = client.execute(request, accessToken); + JSONObject jsonData = JSONObject.fromObject(response); + if(!"0".equals(StringUtil.vString(jsonData.get("errcode")))){ + writeLog("获取钉钉考勤数据失败:"+jsonData.get("errmsg")); + retmap.put("status", "-1"); + retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005341,weaver.general.ThreadVarLanguage.getLang())+""+jsonData.get("errmsg")); + return retmap; + } + Calendar calendar = Calendar.getInstance(); + DateFormat formatterDate = new SimpleDateFormat("yyyy-MM-dd"); + DateFormat formatterTime = new SimpleDateFormat("HH:mm:ss"); + JSONArray jsonList = JSONArray.fromObject(jsonData.get("recordresult")); + for(int i=0;i(); + } catch (Exception e) { + writeLog(this.getClass().getName(),e); + } + } + } + + //刷新报表数据 + for(int i=0;lsFormatData!=null&&i(); + String[] formatData = Util.splitString(lsFormatData.get(i),"|"); + formatParams.add(formatData[0]); + formatParams.add(formatData[1]); + lsFormatParams.add(formatParams); + } + new KQFormatBiz().format(lsFormatParams,13); + } catch (Exception e) { + writeLog("同步钉钉考勤数据:" + e); + retmap.put("status", "-1"); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + +} diff --git a/src/com/engine/kq/cmd/schedulesignimport/UpLoadDataCmd.java b/src/com/engine/kq/cmd/schedulesignimport/UpLoadDataCmd.java new file mode 100644 index 0000000..f5d1952 --- /dev/null +++ b/src/com/engine/kq/cmd/schedulesignimport/UpLoadDataCmd.java @@ -0,0 +1,212 @@ +package com.engine.kq.cmd.schedulesignimport; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +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.KQFormatBiz; +import com.engine.kq.timer.KQQueue; +import com.engine.kq.timer.KQTaskBean; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import weaver.common.DateUtil; +import weaver.conn.BatchRecordSet; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.common.Tools; +import weaver.systeminfo.SystemEnv; + +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class UpLoadDataCmd extends AbstractCommonCommand> { + private static DateFormat df = new SimpleDateFormat("HH:mm:ss"); + + public UpLoadDataCmd(Map params, User user) { + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String sql = ""; + RecordSet rs = new RecordSet(); + BatchRecordSet bRs = new BatchRecordSet(); + List> lsParams = new ArrayList<>(); + List params = null; + + List lsFormatData = new ArrayList<>(); + List> lsFormatParams = new ArrayList<>(); + List formatParams = null; + + List> lsDelParams = new ArrayList<>(); + List delParams = null; + + JSONObject jsonObj = JSON.parseObject(Util.null2String(this.params.get("data"))); + JSONArray scheduleInfo = jsonObj.getJSONArray("scheduleInfo"); + writeLog("jsonObj.toJSONString()"+jsonObj.toJSONString()); + try { + for (int i = 0; i < scheduleInfo.size(); i++) { + JSONObject obj = (JSONObject)scheduleInfo.get(i); + + String machineCode = Util.null2String(obj.get("machineCode")).trim(); + String userCode = Util.null2String(obj.get("userCode")).trim(); + String signdate = Util.null2String(obj.get("checkDate")).trim(); + String signtime = Util.null2String(obj.get("checkTime")).trim(); + String clientaddress = Util.null2String(obj.get("clientAddress")).trim(); + String longitude = Util.null2String(obj.get("longitude")).trim(); + String latitude = Util.null2String(obj.get("latitude")).trim(); + String addr = Util.null2String(obj.get("addr")).trim(); + String memo = Util.null2String(obj.get("memo")).trim(); + + //判断tmpSigntime格式 08:21:11 如果为长格式需要格式化 + if (signtime.length() > 8) { + signtime = df.format(Timestamp.valueOf(signtime)); + } else if (signtime.length() < 8) { + //不带秒的情况 自动补齐 + signtime += ":00"; + } + + if (signdate.length() > 10) { + //如果时间为长格式,从signdate字段中格式化时间 + if (signdate.length() == 16) { + //不带秒的情况 自动补齐 + signdate += ":00"; + } + if (signtime.length() == 0) {//以signtime字段为有限 + signtime = df.format(Timestamp.valueOf(signdate)); + ; + } + signdate = Tools.formatDate(signdate, "yyyy-MM-dd"); + } + + //如果时间格式不带秒补齐 + if (signtime.length() <= 5) { + signtime += ":00"; + } + int userid = 0; + if (Util.null2String(userCode).length() > 0) { + //machineCode、userCode转userid + userid = getUserId(userCode,machineCode); + } + + if(userid<=0||signdate.length()<=0||signtime.length()<=0)continue; + params = new ArrayList<>(); + params.add(userid); + params.add(1); + params.add(signdate); + params.add(signtime); + params.add(clientaddress); + params.add(1); + params.add(1); + params.add("OutDataSourceSyn"); + params.add(longitude); + params.add(latitude); + params.add(addr); + params.add(memo); + lsParams.add(params); + + String formatData = userid+"|"+signdate+"|"+signtime; + if(!lsFormatData.contains(formatData)){ + lsFormatData.add(formatData); + } + } + + Map> overtimeMap = Maps.newHashMap(); + List overtimeList = Lists.newArrayList(); + //刷新报表数据 + for(int i=0;lsFormatData!=null&&i(); + String[] formatData = Util.splitString(lsFormatData.get(i),"|"); + String date_1 = DateUtil.addDate(formatData[1], -1); + formatParams.add(formatData[0]); + formatParams.add(date_1); + lsFormatParams.add(formatParams); + + formatParams = new ArrayList<>(); + formatParams.add(formatData[0]); + formatParams.add(formatData[1]); + lsFormatParams.add(formatParams); + + delParams = new ArrayList<>(); + delParams.add(formatData[0]); + delParams.add(formatData[1]); + delParams.add(formatData[2]); + lsDelParams.add(delParams); + + String resourceId = formatData[0]; + String kqdate = formatData[1]; + if(overtimeMap.containsKey(resourceId)){ + List tmp_overtimeList = overtimeMap.get(resourceId); + if(!tmp_overtimeList.contains(kqdate)){ + tmp_overtimeList.add(kqdate); + } + }else{ + if(!overtimeList.contains(kqdate)){ + overtimeList.add(kqdate); + } + overtimeMap.put(resourceId, overtimeList); + } + } + + //删除本次同步数据 + sql = " delete from hrmschedulesign where signfrom='OutDataSourceSyn' and userid =? and signdate = ? and signtime = ? "; + bRs.executeBatchSql(sql, lsDelParams); + + sql = " insert into HrmScheduleSign (userid, usertype, signdate, signtime, clientaddress, isincom, isimport, signfrom, longitude, latitude, addr,memo) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?)"; + bRs.executeBatchSql(sql,lsParams); + + new KQFormatBiz().format(lsFormatParams,13); + + //处理加班生成 + List tasks = new ArrayList<>(); + for(Map.Entry> mme: overtimeMap.entrySet()){ + String resid = mme.getKey(); + List overList = mme.getValue(); + for(String date : overList){ + SplitActionUtil.pushOverTimeTasks(date,date,resid,tasks); + } + } + if(!tasks.isEmpty()){ + KQQueue.writeTasks(tasks); + } + + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName( 83885,7)); + } catch (Exception e) { + writeLog("上传考勤数据:" + e); + retmap.put("status", "-1"); + } + return retmap; + } + + public static int getUserId(String userCode, String machineCode) { + int userid = 0; + RecordSet rs = new RecordSet(); + String sql = ""; + sql = "select resourceid from kq_schedule_code where schedulecode='" + userCode + "'"; + if(machineCode.length()>0){ + sql+=" and deviceid = (select id from kq_schedule_device where devicecode='"+machineCode+"')"; + } + rs.execute(sql); + if (rs.next()) { + userid = rs.getInt("resourceid"); + } + return userid; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/settings/GetRightMenuCmd.java b/src/com/engine/kq/cmd/settings/GetRightMenuCmd.java new file mode 100644 index 0000000..bf6e9ac --- /dev/null +++ b/src/com/engine/kq/cmd/settings/GetRightMenuCmd.java @@ -0,0 +1,46 @@ +package com.engine.kq.cmd.settings; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 应用设置--右键菜单 + */ +public class GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(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(); + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + int languageId = user.getLanguage();//用户选择的语言 + RightMenu rightMenu = null; + + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Save, "save", true);//新建 + rightMenuList.add(rightMenu); + + /*rightMenu = new RightMenu(languageId, RightMenuType.BTN_log, "log", false);//日志 + rightMenuList.add(rightMenu);*/ + + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/settings/GetSettingsFormCmd.java b/src/com/engine/kq/cmd/settings/GetSettingsFormCmd.java new file mode 100644 index 0000000..d8e0ccc --- /dev/null +++ b/src/com/engine/kq/cmd/settings/GetSettingsFormCmd.java @@ -0,0 +1,82 @@ +package com.engine.kq.cmd.settings; + +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 应用设置--获取设置表单 + */ +public class GetSettingsFormCmd extends AbstractCommonCommand> { + + public GetSettingsFormCmd(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(); + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + String sql = "select * from kq_settings where isHide is null or isHide<>1 order by showOrder,id"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String label = recordSet.getString("label"); + String main_key = Util.null2String(recordSet.getString("main_key")); + String main_value = Util.null2String(recordSet.getString("main_val")); + String main_desc_label = Util.null2String(recordSet.getString("main_desc_label")); + if (main_desc_label.equals("524116")) { + main_desc_label = "539264"; + } + if("overtime_point".equals(main_key)){ + main_desc_label = "546315"; + } + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(main_key); + hrmFieldBean.setFieldlabel(label); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(main_value); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + Map otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + if (!"".equals(main_desc_label)) { + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelNames(main_desc_label, user.getLanguage())); + } + itemList.add(searchConditionItem); + } + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/settings/SaveSettingsCmd.java b/src/com/engine/kq/cmd/settings/SaveSettingsCmd.java new file mode 100644 index 0000000..9ee8aab --- /dev/null +++ b/src/com/engine/kq/cmd/settings/SaveSettingsCmd.java @@ -0,0 +1,82 @@ +package com.engine.kq.cmd.settings; + +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.KQSettingsComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SaveSettingsCmd extends AbstractCommonCommand> { + + public SaveSettingsCmd(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(); + String datas = Util.null2String(params.get("datas")); + JSONObject jsonObject = JSONObject.parseObject(datas); + + List valueList = new ArrayList(); + List paramList = new ArrayList(); + boolean kqReportHalfValidate = false; + if (jsonObject != null) { + for (Map.Entry entry : jsonObject.entrySet()) { + valueList = new ArrayList(); + String key = entry.getKey(); + if("kq_report_half".equals(key)) { + String value = Util.null2String(entry.getValue()); + kqReportHalfValidate = "1".equalsIgnoreCase(value); + } + valueList.add(entry.getValue()); + valueList.add(entry.getKey()); + paramList.add(valueList); + } + } + if(kqReportHalfValidate) { + RecordSet rs = new RecordSet(); + String sql = "select * from kq_ShiftManagement where (isDelete is null or isDelete<>1) and shiftonoffworkcount in('2','3')"; + rs.executeQuery(sql); + if(rs.next()) { + resultMap.put("sign", "-1"); + resultMap.put("api_status", false); + resultMap.put("api_errormsg", SystemEnv.getHtmlLabelName(547559, user.getLanguage())); + resultMap.put("message", SystemEnv.getHtmlLabelName(547559, user.getLanguage())); + return resultMap; + } + } + + boolean flag = true; + if (paramList.size() > 0) { + String sql = "UPDATE KQ_Settings SET main_val=? where main_key=?"; + RecordSet recordSet = new RecordSet(); + flag = recordSet.executeBatchSql(sql, paramList); + } + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + kqSettingsComInfo.removeCache(); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage())); + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage())); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/setupwizard/CheckNeedInitCmd.java b/src/com/engine/kq/cmd/setupwizard/CheckNeedInitCmd.java new file mode 100644 index 0000000..39f40a8 --- /dev/null +++ b/src/com/engine/kq/cmd/setupwizard/CheckNeedInitCmd.java @@ -0,0 +1,70 @@ +package com.engine.kq.cmd.setupwizard; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 判断是否需要做一键初始化,检测如果存在历史一般工作时间等老考勤设置,给出提示让客户选择是否使用考勤设置升级 + */ +public class CheckNeedInitCmd extends AbstractCommonCommand> { + + public CheckNeedInitCmd(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(); + boolean canInit = HrmUserVarify.checkUserRight("KQ:SetupWizard", user);//是否具有初始化的权限 + if (!canInit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));//没有权限 + return resultMap; + } + boolean needInit = true; + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + RecordSet rs3 = new RecordSet(); + //3个判断条件,如果检测到含有一般工作时间,或者设置了排班,或者有考勤流程设置,都给出提示 + String hasSchedule = "select * from hrmschedule "; + rs1.executeQuery(hasSchedule); + if(rs1.next()){ + needInit = false; + }else{ + String hasShift = "select * from hrm_schedule_set_detail "; + rs2.executeQuery(hasShift); + if(rs2.next()){ + needInit = false; + }else{ + String hasFlowset = "select * from hrm_att_proc_set "; + rs3.executeQuery(hasFlowset); + if(rs3.next()){ + needInit = false; + } + } + } + if(!needInit){ + resultMap.put("status", "2"); + String link = ""+SystemEnv.getHtmlLabelName(504038, user.getLanguage())+""; + resultMap.put("message", SystemEnv.getHtmlLabelName(516922, user.getLanguage())+"【"+link+"】"+SystemEnv.getHtmlLabelName(516923, user.getLanguage())); + }else{ + resultMap.put("status", "1"); + } + + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/setupwizard/GetRightMenuCmd.java b/src/com/engine/kq/cmd/setupwizard/GetRightMenuCmd.java new file mode 100644 index 0000000..950fca6 --- /dev/null +++ b/src/com/engine/kq/cmd/setupwizard/GetRightMenuCmd.java @@ -0,0 +1,51 @@ +package com.engine.kq.cmd.setupwizard; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +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 GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(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(); + + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + int languageId = user.getLanguage();//用户选择的语言 + RightMenu rightMenu = null; + + String isInitResult = Util.null2String(params.get("isInitResult"));//是否是初始化结果页签,是的话没有初始化按钮 + + if(!isInitResult.equalsIgnoreCase("true")){ + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Initialization, "startInit", true);//开始初始化 + rightMenuList.add(rightMenu); + + rightMenu = new RightMenu(languageId, RightMenuType.BTN_log, "log", false);//日志 + rightMenuList.add(rightMenu); + } + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/setupwizard/GetSetupFormCmd.java b/src/com/engine/kq/cmd/setupwizard/GetSetupFormCmd.java new file mode 100644 index 0000000..a87ed8d --- /dev/null +++ b/src/com/engine/kq/cmd/setupwizard/GetSetupFormCmd.java @@ -0,0 +1,235 @@ +package com.engine.kq.cmd.setupwizard; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 一键启用考勤--获取表单 + */ +public class GetSetupFormCmd extends AbstractCommonCommand> { + + public GetSetupFormCmd(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(); + + boolean canInit = HrmUserVarify.checkUserRight("KQ:SetupWizard", user);//是否具有初始化的权限 + if (!canInit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));//没有权限 + return resultMap; + } + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("workTime");//上班时间 + hrmFieldBean.setFieldlabel("125809"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("19"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("restTime");//下班时间 + hrmFieldBean.setFieldlabel("125810"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("19"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("excludeRestTime");//排除休息时间 + hrmFieldBean.setFieldlabel("388565"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + Map otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("restTime");//休息时间 + hrmFieldBean.setFieldlabel("388417"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("TIMERANGEPICKER"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("workDate");//工作日期 + hrmFieldBean.setFieldlabel("16221"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setFieldvalue("0,1,2,3,4"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List statusOptions = new ArrayList(); + statusOptions.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(392, user.getLanguage()))); + statusOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(393, user.getLanguage()))); + statusOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(394, user.getLanguage()))); + statusOptions.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(395, user.getLanguage()))); + statusOptions.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(396, user.getLanguage()))); + statusOptions.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(397, user.getLanguage()))); + statusOptions.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(398, user.getLanguage()))); + searchConditionItem.setOptions(statusOptions); + searchConditionItem.setDetailtype(2); + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + + Map dataMap = new HashMap(); + List> datasList = new ArrayList>(); + List descList = new ArrayList(); + + dataMap = new HashMap(); + dataMap.put("key","1"); + dataMap.put("title",SystemEnv.getHtmlLabelName(24803, user.getLanguage()));//班次 + descList = new ArrayList(); + //本次初始化将新建一个【班次】,所新建的班次的上班时间、下班时间、休息时段均取自本页面的上班时间、下班时间、休息时段;若此前已经初始化过,则根据本次设置的上班时间、下班时间、休息时段更新此前新建过的【班次】 + descList.add(SystemEnv.getHtmlLabelName(505627, user.getLanguage())); + dataMap.put("desc",descList); + datasList.add(dataMap); + + dataMap = new HashMap(); + dataMap.put("key","2"); + dataMap.put("title",SystemEnv.getHtmlLabelName(390221, user.getLanguage()));//考勤组 + descList = new ArrayList(); + // 本次初始化将新建一个【考勤组】,所新建的考勤组的考勤类型为固定班制(即每周的工作日固定,且每一个工作日的工作时间也固定) + // 工作日的设置取自本页面所勾选的工作日期,每个工作日的工作时间取自上一步的【班次】 + // 考勤组成员默认取全公司所有人(即默认设置所有人按照此考勤组的工作日以及工作时间进行考勤) + // 若此前已经初始化过,将根据本次的设置更新此前新建的【考勤组】 + descList.add(SystemEnv.getHtmlLabelName(505629, user.getLanguage())); + dataMap.put("desc",descList); + datasList.add(dataMap); + + dataMap = new HashMap(); + dataMap.put("key","3"); + dataMap.put("title",SystemEnv.getHtmlLabelName(28386, user.getLanguage()));//节假日 + descList = new ArrayList(); + //本次初始化将根据国家规定,自动为上一步新建的【考勤组】设置本年度的公众假日、调配工作日和调配休息日 + descList.add(SystemEnv.getHtmlLabelName(505630, user.getLanguage())); + //注:此功能需服务器能够链接外网,否则获取不到网络数据,无法自动生成节假日数据 + descList.add(SystemEnv.getHtmlLabelName(505631, user.getLanguage())); + dataMap.put("desc",descList); + datasList.add(dataMap); + + dataMap = new HashMap(); + dataMap.put("key","4"); + dataMap.put("title",SystemEnv.getHtmlLabelName(500272, user.getLanguage()));//考勤流程 + descList = new ArrayList(); + //本次初始化将新建如下几条考勤流程:请假流程、出差流程、公出流程、加班流程、排班流程、补卡流程、销假流程、考勤变更流程,并且会自动完成与考勤的字段对应(如若没有将流程与考勤字段正确对应,则无法将流程数据统计为考勤数据) + descList.add(SystemEnv.getHtmlLabelName(514749, user.getLanguage())); + //注:因每个公司的流程流转节点以及流程的节假操作者各有不同,所以初始化无法为考勤流程设置好节点以及节点操作者,如若想正常启用考勤流程,还需要设置好考勤流程的考勤节点以及节点操作者 + descList.add(SystemEnv.getHtmlLabelName(505633, user.getLanguage())); + dataMap.put("desc",descList); + datasList.add(dataMap); + + dataMap = new HashMap(); + dataMap.put("key","5"); + dataMap.put("title",SystemEnv.getHtmlLabelName(388881, user.getLanguage()));//加班规则 + descList = new ArrayList(); + //本次初始化将新建一个【加班规则】,并关联本次初始化所新建的【考勤组】(即考勤内的成员会按照此加班规则的规则内容生成加班调休数据)。具体规则如下所示: + descList.add(SystemEnv.getHtmlLabelName(505634, user.getLanguage())); + //允许工作日加班,但是需审批,以加班流程为准,下班后30分钟开始计算加班,最小加班时长为30分钟,允许加班转调休,加班时长与调休时长的比例为1:1 + descList.add(SystemEnv.getHtmlLabelName(505635, user.getLanguage())); + //允许休息日加班,但是需审批,以加班流程为准,最小加班时长为30分钟,允许加班转调休,加班时长与调休时长的比例为1:1 + descList.add(SystemEnv.getHtmlLabelName(505636, user.getLanguage())); + //允许节假日加班,但是需审批,以加班流程为准,最小加班时长为30分钟,允许加班转调休,加班时长与调休时长的比例为1:1 + descList.add(SystemEnv.getHtmlLabelName(505637, user.getLanguage())); + dataMap.put("desc",descList); + datasList.add(dataMap); + + dataMap = new HashMap(); + dataMap.put("key","6"); + dataMap.put("title",SystemEnv.getHtmlLabelName(390004, user.getLanguage()));//公出出差规则 + descList = new ArrayList(); + //本次初始化将更新出差规则为:按天出差,按工作日计算出差时长 + descList.add(SystemEnv.getHtmlLabelName(505638, user.getLanguage())); + //本次初始化将更新公出规则为:按天公出,按工作日计算公出规则 + descList.add(SystemEnv.getHtmlLabelName(505639, user.getLanguage())); + dataMap.put("desc",descList); + datasList.add(dataMap); + + dataMap = new HashMap(); + dataMap.put("key","7"); + dataMap.put("title",SystemEnv.getHtmlLabelName(388996, user.getLanguage()));//假期规则 + descList = new ArrayList(); + //年假-初始化:按照国家规定职工工龄已满1年不满10年的,年休假5天;已满10年不满20年的,年休假10天;已满20年的,年休假15天 + descList.add(SystemEnv.getHtmlLabelName(505640, user.getLanguage())); + //带薪事假-初始化:不限制余额,按天请假,按照工作日计算请假时长 + descList.add(SystemEnv.getHtmlLabelName(505641, user.getLanguage())); + //带薪病假-初始化:不限制余额,按天请假,按照工作日计算请假时长 + descList.add(SystemEnv.getHtmlLabelName(505642, user.getLanguage())); + //调休-初始化:根据加班时长自动累加 + descList.add(SystemEnv.getHtmlLabelName(505643, user.getLanguage())); + //事假-初始化:不限制余额,按天请假,按照工作日计算请假时长 + descList.add(SystemEnv.getHtmlLabelName(505644, user.getLanguage())); + //病假-初始化:不限制余额,按天请假,按照工作日计算请假时长 + descList.add(SystemEnv.getHtmlLabelName(505645, user.getLanguage())); + //产假-初始化:不限制余额,按天请假,按照自然日计算请假时长 + descList.add(SystemEnv.getHtmlLabelName(505646, user.getLanguage())); + //陪产假-初始化:不限制余额,按天请假,按照自然日计算请假时长 + descList.add(SystemEnv.getHtmlLabelName(505647, user.getLanguage())); + //婚假-初始化:不限制余额,按天请假,按照工作日计算请假时长 + descList.add(SystemEnv.getHtmlLabelName(505648, user.getLanguage())); + //丧假-初始化:不限制余额,按天请假,按照工作日计算请假时长 + descList.add(SystemEnv.getHtmlLabelName(505649, user.getLanguage())); + //哺乳假-初始化:不限制余额,按天请假,按照工作日计算请假时长 + descList.add(SystemEnv.getHtmlLabelName(505650, user.getLanguage())); + dataMap.put("desc",descList); + datasList.add(dataMap); + + dataMap = new HashMap(); + dataMap.put("key","8"); + dataMap.put("title",SystemEnv.getHtmlLabelName(390297, user.getLanguage()));//假期余额 + descList = new ArrayList(); + //根据年假-初始化的假期规则为全公司的人批量生成的本年度的假期余额数据 + descList.add(SystemEnv.getHtmlLabelName(505651, user.getLanguage())); + dataMap.put("desc",descList); + datasList.add(dataMap); + + resultMap.put("datas",datasList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/setupwizard/GetSetupStepsCmd.java b/src/com/engine/kq/cmd/setupwizard/GetSetupStepsCmd.java new file mode 100644 index 0000000..1b342c1 --- /dev/null +++ b/src/com/engine/kq/cmd/setupwizard/GetSetupStepsCmd.java @@ -0,0 +1,75 @@ +package com.engine.kq.cmd.setupwizard; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * + */ +public class GetSetupStepsCmd extends AbstractCommonCommand> { + + public GetSetupStepsCmd(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(); + boolean canInit = HrmUserVarify.checkUserRight("KQ:SetupWizard", user);//是否具有初始化的权限 + if (!canInit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));//没有权限 + return resultMap; + } + List> stepList = new ArrayList>(); + Map stepMap = new HashMap(); + stepMap.put("title",SystemEnv.getHtmlLabelName(24803, user.getLanguage())); + stepList.add(stepMap);//初始化班次 + + stepMap = new HashMap(); + stepMap.put("title",SystemEnv.getHtmlLabelName(390221, user.getLanguage())); + stepList.add(stepMap);//初始化考勤组 + + stepMap = new HashMap(); + stepMap.put("title",SystemEnv.getHtmlLabelName(500272, user.getLanguage())); + stepList.add(stepMap);//初始化考勤流程 + + stepMap = new HashMap(); + stepMap.put("title",SystemEnv.getHtmlLabelName(28386, user.getLanguage())); + stepList.add(stepMap);//初始化节假日 + + stepMap = new HashMap(); + stepMap.put("title",SystemEnv.getHtmlLabelName(388881, user.getLanguage())); + stepList.add(stepMap);//初始化加班规则 + + stepMap = new HashMap(); + stepMap.put("title",SystemEnv.getHtmlLabelName(390004, user.getLanguage())); + stepList.add(stepMap);//初始出差公出规则 + + stepMap = new HashMap(); + stepMap.put("title",SystemEnv.getHtmlLabelName(388996, user.getLanguage())); + stepList.add(stepMap);//初始化假期规则 + + stepMap = new HashMap(); + stepMap.put("title",SystemEnv.getHtmlLabelName(390297, user.getLanguage())); + stepList.add(stepMap);//初始化假期余额 + + resultMap.put("items", stepList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/setupwizard/PerformInitializationCmd.java b/src/com/engine/kq/cmd/setupwizard/PerformInitializationCmd.java new file mode 100644 index 0000000..aec87fd --- /dev/null +++ b/src/com/engine/kq/cmd/setupwizard/PerformInitializationCmd.java @@ -0,0 +1,94 @@ +package com.engine.kq.cmd.setupwizard; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.constant.*; +import com.engine.common.entity.BizLogContext; +import com.engine.common.util.LogUtil; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQInitializationBiz; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.Calendar; +import java.util.HashMap; +import java.util.Map; + +/** + * 执行初始化 + */ +public class PerformInitializationCmd extends AbstractCommonCommand> { + + public PerformInitializationCmd(Map params, User user) { + this.user = user; + this.params = params; + + //获取当前日期,当前时间 + Calendar today = Calendar.getInstance(); + //当前日期 + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + //当前时间 + String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" + + Util.add0(today.get(Calendar.MINUTE), 2) + ":" + + Util.add0(today.get(Calendar.SECOND), 2); + + int index = Util.getIntValue((String) params.get("index"), -1);//索引值 + if (index == 0) { + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setDate(currentDate); + bizLogContext.setTime(currentTime); + bizLogContext.setUserid(user.getUID()); + bizLogContext.setUsertype(Util.getIntValue(user.getLogintype(), 1)); + bizLogContext.setTargetId(""); + bizLogContext.setTargetName(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(505591,weaver.general.ThreadVarLanguage.getLang())+""); + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_SETUPWIZARD);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_SETUPWIZARD);//所属大类型下的小类型 + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setClientIp(""); + bizLogContext.setDesc(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(505591,weaver.general.ThreadVarLanguage.getLang())+""); + bizLogContext.setParams(params); + bizLogContext.setOperateType(BizLogOperateType.START); + bizLogContext.setOperateAuditType(BizLogOperateAuditType.INFO); + bizLogContext.setDeviceType(BizLogDeviceType.PC); + LogUtil.writeBizLog(bizLogContext); + } + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + boolean canInit = HrmUserVarify.checkUserRight("KQ:SetupWizard", user);//是否具有初始化的权限 + if (!canInit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));//没有权限 + return resultMap; + } + int index = Util.getIntValue((String) params.get("index"), -1);//索引值 + if (index == 0) { + resultMap = KQInitializationBiz.initShift(params, user); + } else if (index == 1) { + resultMap = KQInitializationBiz.initGroup(params,user); + } else if (index == 2) { + resultMap = KQInitializationBiz.initWorkflow(params, user); + } else if (index == 3) { + resultMap = KQInitializationBiz.initHolidaySet(params,user); + } else if (index == 4) { + resultMap = KQInitializationBiz.initOvertimeRules(params,user); + } else if (index == 5) { + resultMap = KQInitializationBiz.initTravelRules(params,user); + } else if (index == 6) { + resultMap = KQInitializationBiz.initLeaveRules(params,user); + } else if (index == 7) { + resultMap = KQInitializationBiz.initBalanceOfLeave(params,user); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/DelShiftManagementFormCmd.java b/src/com/engine/kq/cmd/shiftmanagement/DelShiftManagementFormCmd.java new file mode 100644 index 0000000..b65a608 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/DelShiftManagementFormCmd.java @@ -0,0 +1,147 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQShiftManagementComInfo; +import com.engine.kq.biz.KQShiftOnOffWorkSectionComInfo; +import com.engine.kq.biz.KQShiftRestTimeSectionComInfo; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 删除班次管理 + * @author pzy + * + */ +public class DelShiftManagementFormCmd extends AbstractCommonCommand>{ + + private SimpleBizLogger logger; + + public DelShiftManagementFormCmd() { + } + + public DelShiftManagementFormCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_SHIFTMANAGER); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_SHIFTMANAGER); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + String ids = Util.null2String(params.get("ids")); + + if(ids.length() > 0){ + String mainSql = " select * from kq_ShiftManagement where "+Util.getSubINClause(ids, "id", "in") +" "; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod(this.getClass().getName() + ".getTargetName", "column:serial"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_ShiftOnOffWorkSections where "+Util.getSubINClause(ids, "serialid", "in") ; + subLogInfo1.setSubTargetNameColumn("times"); + subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(27961); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + SimpleBizLogger.SubLogInfo subLogInfo = logger.getNewSubLogInfo(); + String subSql = " select * from kq_ShiftRestTimeSections where "+Util.getSubINClause(ids, "serialid", "in"); + subLogInfo.setSubSql(subSql); + subLogInfo.setSubTargetNameColumn("time"); + subLogInfo.setGroupId("1"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo.setSubGroupNameLabel(505603); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo); + } + logger.before(logContext); + + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + /** + * 获取日志对象的名称 + * @param id + * @param para2 + * @return + */ + public String getTargetName(String id,String para2){ + try { + return para2; + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String ids = Util.null2String(params.get("ids")); + RecordSetTrans rst = new RecordSetTrans(); + if(!HrmUserVarify.checkUserRight("KQClass:Management",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + try{ + if(ids.length() > 0){ + rst.setAutoCommit(false); + String[] idArr = ids.split(","); + for(String id : idArr){ + //删除基本信息表 + String delBaseSql = "update kq_ShiftManagement set isdelete = '1',overtime_rule_id=null where id = ? "; + boolean isUpdated = rst.executeUpdate(delBaseSql,id); + //删除基本信息上班时间表 + String delBaseSql1 = "update kq_ShiftOnOffWorkSections set isdelete = '1' where serialid = ? "; + rst.executeUpdate(delBaseSql1,id); + //删除基本信息休息时间表 + String delBaseSql2 = "update kq_ShiftRestTimeSections set isdelete = '1' where serialid = ? "; + rst.executeUpdate(delBaseSql2,id); + //删除个性化信息表 + String delPersonalizedSql = "update kq_ShiftPersonalizedRule set isdelete = '1' where serialid = ? "; + rst.executeUpdate(delPersonalizedSql,id); + //删除个性化信息规则表 + String delPersonalizedSql1 = "update kq_ShiftPersonalizedRuleDetail set isdelete = '1' where personalizedruleid in (select id from kq_ShiftPersonalizedRule where serialid = ?)"; + rst.executeUpdate(delPersonalizedSql1,id); + } + rst.commit(); + } + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + kqShiftManagementComInfo.removeShiftManagementCache(); + retmap.put("status", "1"); + }catch (Exception e){ + rst.rollback(); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/GetDetachOperatelevelCmd.java b/src/com/engine/kq/cmd/shiftmanagement/GetDetachOperatelevelCmd.java new file mode 100644 index 0000000..01d548e --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/GetDetachOperatelevelCmd.java @@ -0,0 +1,60 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.HashMap; +import java.util.Map; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +/** + * 获取班次管理 分权操作级别 + * @author pzy + * + */ +public class GetDetachOperatelevelCmd extends AbstractCommonCommand>{ + + public GetDetachOperatelevelCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String subcompanyid = Util.null2String((String)params.get("subcompanyid")); + try { + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + int operatelevel = -1; + if(hrmdetachable){ + operatelevel=checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"KQClass:Management",Util.getIntValue(subcompanyid,-1)); + }else{ + operatelevel = 2; + } + if(user.getUID() == 1){ + operatelevel = 2; + } + + retmap.put("operatelevel", operatelevel); + retmap.put("status", "1"); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/GetEmailRemindFormCmd.java b/src/com/engine/kq/cmd/shiftmanagement/GetEmailRemindFormCmd.java new file mode 100644 index 0000000..f3e7c23 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/GetEmailRemindFormCmd.java @@ -0,0 +1,126 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldUtil; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 获取邮件提醒的表单 + */ +public class GetEmailRemindFormCmd extends AbstractCommonCommand> { + + public GetEmailRemindFormCmd(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(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQClass:Management", user); + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + String serialId = Util.null2String(params.get("serialId"));//班次ID + + List> dataList = null; + Map dataMap = null; + + String emailTitle_signIn = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005295,weaver.general.ThreadVarLanguage.getLang())+""; + String emailContent_signIn = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005295,weaver.general.ThreadVarLanguage.getLang())+""; + String availableParams_signIn = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(18843,weaver.general.ThreadVarLanguage.getLang())+""; + + String emailTitle_signOut = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005296,weaver.general.ThreadVarLanguage.getLang())+""; + String emailContent_signOut = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005296,weaver.general.ThreadVarLanguage.getLang())+""; + String availableParams_signOut = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005342,weaver.general.ThreadVarLanguage.getLang())+""; + + dataList = new ArrayList>(); + dataMap = new HashMap(); + dataMap.put("id", "0"); + dataMap.put("radio", "1"); + dataMap.put("type", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(507835,weaver.general.ThreadVarLanguage.getLang())+""); + dataMap.put("title", emailTitle_signIn); + dataMap.put("content", emailContent_signIn); + dataMap.put("params", new String[]{availableParams_signIn}); + dataList.add(dataMap); + + dataMap = new HashMap(); + dataMap.put("id", "1"); + dataMap.put("radio", "0"); + dataMap.put("type", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(507837,weaver.general.ThreadVarLanguage.getLang())+""); + dataMap.put("title", emailTitle_signOut); + dataMap.put("content", emailContent_signOut); + dataMap.put("params", new String[]{availableParams_signOut}); + dataList.add(dataMap); + + resultMap.put("defaultDatas", dataList); + resultMap.put("signInParams", new String[]{availableParams_signIn}); + resultMap.put("signOutParams", new String[]{availableParams_signOut}); + + if (!"".equals(serialId)) { + String sql = "select * from kq_emailRemindTemplate where serialId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, serialId); + while (recordSet.next()) { + String signInOrSignOut = Util.null2String(recordSet.getString("signInOrSignOut")); + String emailTitle = Util.null2String(recordSet.getString("emailTitle")); + String emailContent = Util.null2String(recordSet.getString("emailContent")); + + if (signInOrSignOut.equals("1")) { + emailTitle_signIn = emailTitle; + emailContent_signIn = emailContent; + } else { + emailTitle_signOut = emailTitle; + emailContent_signOut = emailContent; + } + } + } + + dataList = new ArrayList>(); + dataMap = new HashMap(); + dataMap.put("id", "0"); + dataMap.put("radio", "1"); + dataMap.put("type", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(507835,weaver.general.ThreadVarLanguage.getLang())+""); + dataMap.put("title", emailTitle_signIn); + dataMap.put("content", emailContent_signIn); + dataMap.put("params", new String[]{availableParams_signIn}); + dataList.add(dataMap); + + dataMap = new HashMap(); + dataMap.put("id", "1"); + dataMap.put("radio", "0"); + dataMap.put("type", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(507837,weaver.general.ThreadVarLanguage.getLang())+""); + dataMap.put("title", emailTitle_signOut); + dataMap.put("content", emailContent_signOut); + dataMap.put("params", new String[]{availableParams_signOut}); + dataList.add(dataMap); + + resultMap.put("datas", dataList); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", e.getMessage()); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/GetMessageRemindFormCmd.java b/src/com/engine/kq/cmd/shiftmanagement/GetMessageRemindFormCmd.java new file mode 100644 index 0000000..78b4393 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/GetMessageRemindFormCmd.java @@ -0,0 +1,114 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldUtil; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetMessageRemindFormCmd extends AbstractCommonCommand> { + + public GetMessageRemindFormCmd(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(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQClass:Management", user); + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + String serialId = Util.null2String(params.get("serialId"));//班次ID + + List> dataList = null; + Map dataMap = null; + + String messageContent_signIn = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005295,weaver.general.ThreadVarLanguage.getLang())+""; + String availableParams_signIn = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(18843,weaver.general.ThreadVarLanguage.getLang())+""; + + String messageContent_signOut = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005296,weaver.general.ThreadVarLanguage.getLang())+""; + String availableParams_signOut = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005342,weaver.general.ThreadVarLanguage.getLang())+""; + + dataList = new ArrayList>(); + dataMap = new HashMap(); + dataMap.put("id", "0"); + dataMap.put("radio", "1"); + dataMap.put("type", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(507835,weaver.general.ThreadVarLanguage.getLang())+""); + dataMap.put("content", messageContent_signIn); + dataMap.put("params", new String[]{availableParams_signIn}); + dataList.add(dataMap); + + dataMap = new HashMap(); + dataMap.put("id", "1"); + dataMap.put("radio", "0"); + dataMap.put("type", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(507837,weaver.general.ThreadVarLanguage.getLang())+""); + dataMap.put("content", messageContent_signOut); + dataMap.put("params", new String[]{availableParams_signOut}); + dataList.add(dataMap); + + resultMap.put("defaultDatas", dataList); + resultMap.put("signInParams", new String[]{availableParams_signIn}); + resultMap.put("signOutParams", new String[]{availableParams_signOut}); + + if (!"".equals(serialId)) { + String sql = "select * from kq_messageRemindTemplate where serialId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, serialId); + while (recordSet.next()) { + String signInOrSignOut = Util.null2String(recordSet.getString("signInOrSignOut")); + String messageContent = Util.null2String(recordSet.getString("messageContent")); + + if (signInOrSignOut.equals("1")) { + messageContent_signIn = messageContent; + } else { + messageContent_signOut = messageContent; + } + } + } + + dataList = new ArrayList>(); + dataMap = new HashMap(); + dataMap.put("id", "0"); + dataMap.put("radio", "1"); + dataMap.put("type", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(507835,weaver.general.ThreadVarLanguage.getLang())+""); + dataMap.put("content", messageContent_signIn); + dataMap.put("params", new String[]{availableParams_signIn}); + dataList.add(dataMap); + + dataMap = new HashMap(); + dataMap.put("id", "1"); + dataMap.put("radio", "0"); + dataMap.put("type", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(507837,weaver.general.ThreadVarLanguage.getLang())+""); + dataMap.put("content", messageContent_signOut); + dataMap.put("params", new String[]{availableParams_signOut}); + dataList.add(dataMap); + + resultMap.put("datas", dataList); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", e.getMessage()); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/GetRightMenuCmd.java b/src/com/engine/kq/cmd/shiftmanagement/GetRightMenuCmd.java new file mode 100644 index 0000000..6e543c8 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/GetRightMenuCmd.java @@ -0,0 +1,54 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.general.Util; +import weaver.hrm.User; + +/** + * 获取班次管理右键菜单 + * @author pzy + * + */ +public class GetRightMenuCmd extends AbstractCommonCommand>{ + + public GetRightMenuCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + int id = Util.getIntValue((String)params.get("id")); + String pageid = Util.null2String(params.get("pageid"));//页面标识 + List rightMenu = new ArrayList(); + try { + //编辑\人性化班次设置\删除 + rightMenu.add(new RightMenu(user.getLanguage(), RightMenuType.BTN_EDIT, "doEdit")); + rightMenu.add(new RightMenu(user.getLanguage(), RightMenuType.BTN_Delete, "doPersonalized")); + rightMenu.add(new RightMenu(user.getLanguage(), RightMenuType.BTN_Delete, "doDelete")); + } catch (Exception e) { + writeLog(e); + } + retmap.put("status", "1"); + retmap.put("rightMenu", rightMenu); + retmap.put("hasDpIcon", true); + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementBaseFormCmd.java b/src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementBaseFormCmd.java new file mode 100644 index 0000000..dfa9ed1 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementBaseFormCmd.java @@ -0,0 +1,481 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.collections.CollectionUtils; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +/** + * 获取班次管理基本信息表单 + * @author pzy + * + */ +public class GetShiftManagementBaseFormCmd extends AbstractCommonCommand>{ + + public GetShiftManagementBaseFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String sql = ""; + try { + if(!HrmUserVarify.checkUserRight("KQClass:Management",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + CheckSubCompanyRight newCheck=new CheckSubCompanyRight(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + String hrmdftsubcomid = manageDetachComInfo.getHrmdftsubcomid();//分权默认分部 + + SubCompanyComInfo sc = new SubCompanyComInfo(); + String _id = Util.null2String(params.get("id")); + String subcompanyid = Util.null2String(params.get("subcompanyid")); + boolean isEdit = false; + + List workSectionList = new ArrayList<>(); + Map groupSectionMaps = new HashMap<>();//分组用的map + Map sectionMaps = new HashMap<>(); + Map sectionMap = new HashMap<>(); + + //现在休息时段还是只能设置一个的,对于以后可能出现的多个休息时段预留这个map + List restSectionsList = new ArrayList<>(); + Map restSectionsMap = new HashMap<>(); + + String[] fields = new String[]{"serial,125818,1,1","subcompanyid,141,3,169","shiftonoffworkcount,388563,5,3","convert_attend_day,546327,1,2","punchsettings,388564,4,1", + "signoutOnlyoff,546744,4,2", + "isresttimeopen,388565,4,2","restbeigin,388566,3,19","restend,388567,3,19","halfcalrule,513090,5,1","cardRemind,507833,4,2","cardRemOfSignIn,507835,5,1", + "minsBeforeSignIn,510106,1,2","cardRemOfSignOut,507837,5,1","minsAfterSignOut,510108,1,2","remindMode,501471,5,3","remindOnPC,513233,4,2", + "isoffdutyfreecheck,388568,4,2","halfcalpoint,513145,3,19","halfcalpoint2cross,513090,5,1", + "is_rest,546275,4,2","overtime_rule_id,388881,3,kqovertimerule"}; + + Map shiftValMap = new HashMap<>(); + List> overReplaceDatas = new ArrayList>(); + if(_id.length() > 0){ + String getShiftInfo = "select * from kq_ShiftManagement where (isdelete is null or isdelete <> '1') and id = ?"; + rs.executeQuery(getShiftInfo, _id); + if(rs.next()){ + for(int i = 0 ; i < fields.length ; i++){ + String[] tmpField = Util.null2String(fields[i]).split(","); + String fieldname = tmpField[0]; + String fieldvalue = rs.getString(fieldname); + if("shiftonoffworkcount".equalsIgnoreCase(fieldname) || + "punchsettings".equalsIgnoreCase(fieldname) || + "cardRemOfSignIn".equalsIgnoreCase(fieldname) || + "cardRemOfSignOut".equalsIgnoreCase(fieldname) || + "remindMode".equalsIgnoreCase(fieldname)){ + fieldvalue = Util.null2s(fieldvalue, "1"); + }else if("isresttimeopen".equalsIgnoreCase(fieldname) || + "halfcalrule".equalsIgnoreCase(fieldname) || + "cardRemind".equalsIgnoreCase(fieldname) || + "minsAfterSignOut".equalsIgnoreCase(fieldname) || + "remindOnPC".equalsIgnoreCase(fieldname) || + "isoffdutyfreecheck".equalsIgnoreCase(fieldname) || + "halfcalpoint".equalsIgnoreCase(fieldname) || + "halfcalpoint2cross".equalsIgnoreCase(fieldname) || + "signoutOnlyoff".equalsIgnoreCase(fieldname) || + "is_rest".equalsIgnoreCase(fieldname)){ + fieldvalue = Util.null2s(fieldvalue, "0"); + }else if("minsBeforeSignIn".equalsIgnoreCase(fieldname)){ + fieldvalue = Util.null2s(fieldvalue, "10"); + }else if("subcompanyid".equalsIgnoreCase(fieldname)){ + subcompanyid = fieldvalue; + }else if("convert_attend_day".equalsIgnoreCase(fieldname)){ + fieldvalue = Util.null2s(fieldvalue,"1.0"); + }else if("overtime_rule_id".equalsIgnoreCase(fieldname)){ + fieldvalue = Util.null2s(fieldvalue, ""); + if(StringUtil.isNotNull(fieldvalue)){ + String overSql = "select * from kq_overtimerules where id = "+fieldvalue+" and (isDelete is null or isDelete!=1) "; + rs.execute(overSql); + if(rs.next()){ + String overName = rs.getString("name"); + Map replaceData = new HashMap(); + replaceData.put("id", fieldvalue); + replaceData.put("name", overName); + overReplaceDatas.add(replaceData); + } + } + } + shiftValMap.put(fieldname, fieldvalue); + } + } + + String getWorkSections = "select * from kq_ShiftOnOffWorkSections where (isdelete is null or isdelete <> '1') and serialid = ? order by record "; + rs.executeQuery(getWorkSections, _id); + while(rs.next()){ + String record = rs.getString("record"); + if(record.length() == 0) { + continue; + } + + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + String across = Util.null2String(rs.getString("across")); + String times = Util.null2String(rs.getString("times")); + String mins = Util.null2String(rs.getString("mins")); + String mins_next = Util.null2String(rs.getString("mins_next")); + String clockinnot = Util.null2String(rs.getString("clockinnot")); + sectionMap = new HashMap<>(); + sectionMaps = new HashMap<>(); + sectionMap.put("across", across); + sectionMap.put("times", times); + sectionMap.put("mins", mins); + sectionMap.put("mins_next", mins_next); + sectionMap.put("clockinnot", clockinnot); + sectionMaps.put(onoffworktype, sectionMap); + if(groupSectionMaps.get(record) != null){ + List tmpSections = (List) groupSectionMaps.get(record); + ((Map)tmpSections.get(tmpSections.size()-1)).putAll(sectionMaps); + }else{ + sectionMaps.put("record", record); + workSectionList.add(sectionMaps); + groupSectionMaps.put(record, workSectionList); + } + } + + groupSectionMaps = new HashMap<>(); + sectionMaps = new HashMap<>(); + String getRestSections = "select * from kq_ShiftRestTimeSections where (isdelete is null or isdelete <> '1') and serialid = ? order by orderId "; + rs.executeQuery(getRestSections, _id); + while(rs.next()){ + String resttype = Util.null2String(rs.getString("resttype")); + String across = Util.null2String(rs.getString("across")); + String times = Util.null2String(rs.getString("time")); + String record = Util.null2String(rs.getString("record1")); + String orderId = Util.null2String(rs.getString("orderId")); + restSectionsMap = new HashMap<>(); + sectionMaps = new HashMap<>(); + restSectionsMap.put("resttype", resttype); + restSectionsMap.put("time", times); + restSectionsMap.put("across", across); + restSectionsMap.put("record", record); + restSectionsMap.put("orderId", orderId); + sectionMaps.put(resttype, restSectionsMap); + if(groupSectionMaps.get(record) != null){ + List tmpSections = (List) groupSectionMaps.get(record); + ((Map)tmpSections.get(tmpSections.size()-1)).putAll(sectionMaps); + }else{ + sectionMaps.put("record", record); + restSectionsList.add(sectionMaps); + groupSectionMaps.put(record, restSectionsList); + } + } + isEdit = true; + } + + //班次名称 所属机构(开启分权有所属机构) 一天内上下班次数 打卡时段是否开启 排除休息时间是否开启 休息开始时间 休息结束时间 允许下班不打卡 + HrmFieldBean hrmFieldBean = null; + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + List options = new ArrayList(); + + groupitem = new HashMap(); + + itemlist = new ArrayList(); + for (int j = 0; j < fields.length; j++) { + options = new ArrayList(); + String[] tmpField = Util.null2String(fields[j]).split(","); + String fieldname = tmpField[0]; + String beanVal = Util.null2String(shiftValMap.get(fieldname)); + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(fieldname); + hrmFieldBean.setFieldlabel(tmpField[1]); + hrmFieldBean.setFieldhtmltype(tmpField[2]); + hrmFieldBean.setType(tmpField[3]); + hrmFieldBean.setIsFormField(true); + + if("serial".equalsIgnoreCase(tmpField[0]) || "restbeigin".equalsIgnoreCase(tmpField[0]) || "restend".equalsIgnoreCase(tmpField[0])){ + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + } + if("shiftonoffworkcount".equalsIgnoreCase(tmpField[0]) || "restbeigin".equalsIgnoreCase(tmpField[0]) || "restend".equalsIgnoreCase(tmpField[0])){ + hrmFieldBean.setRules("required|string"); + if(!isEdit){ + if("restbeigin".equalsIgnoreCase(tmpField[0])){ + hrmFieldBean.setFieldvalue("12:00"); + } + if("restend".equalsIgnoreCase(tmpField[0])){ + hrmFieldBean.setFieldvalue("13:00"); + } + } + } + if("convert_attend_day".equalsIgnoreCase(tmpField[0])){ + hrmFieldBean.setViewAttr(3); + Map otherparam = new HashMap(); + otherparam.put("min","0"); + otherparam.put("precision",2); + hrmFieldBean.setOtherparam(otherparam); + hrmFieldBean.setRules("required|string"); + } + +// if("color".equalsIgnoreCase(tmpField[0])){ +// hrmFieldBean.setTip(SystemEnv.getHtmlLabelName(389509, user.getLanguage())); +// } + if(!isEdit){ + if("isresttimeopen".equalsIgnoreCase(tmpField[0])){ + hrmFieldBean.setFieldvalue("0"); + } + if("isoffdutyfreecheck".equalsIgnoreCase(tmpField[0])){ + hrmFieldBean.setFieldvalue("0"); + } + if("punchsettings".equalsIgnoreCase(tmpField[0])){ + hrmFieldBean.setFieldvalue("1"); + } +// if("color".equalsIgnoreCase(tmpField[0])){ +// hrmFieldBean.setFieldvalue("#000"); +// } + if("cardRemOfSignIn".equals(hrmFieldBean.getFieldname())){ + beanVal = "1"; + } + if("minsBeforeSignIn".equals(hrmFieldBean.getFieldname())){ + beanVal = "10"; + } + if("cardRemOfSignOut".equals(hrmFieldBean.getFieldname())){ + beanVal = "1"; + } + if("minsAfterSignOut".equals(hrmFieldBean.getFieldname())){ + beanVal = "0"; + } + if("remindMode".equals(hrmFieldBean.getFieldname())){ + beanVal = "1"; + } + if("halfcalrule".equals(hrmFieldBean.getFieldname())){ + hrmFieldBean.setFieldvalue("0"); + } + if("halfcalpoint2cross".equals(hrmFieldBean.getFieldname())){ + hrmFieldBean.setFieldvalue("0"); + } + if("signoutOnlyoff".equals(hrmFieldBean.getFieldname())){ + hrmFieldBean.setFieldvalue("0"); + } + if("is_rest".equals(hrmFieldBean.getFieldname())){ + hrmFieldBean.setFieldvalue("0"); + } + if("convert_attend_day".equals(hrmFieldBean.getFieldname())){ + hrmFieldBean.setFieldvalue("1.0"); + } + } + + if("shiftonoffworkcount".equals(tmpField[0])){ + SearchConditionOption SearchConditionOption_1 = new SearchConditionOption("1",SystemEnv.getHtmlLabelName(388569, user.getLanguage())); + SearchConditionOption SearchConditionOption_2 = new SearchConditionOption("2",SystemEnv.getHtmlLabelName(388570, user.getLanguage())); + SearchConditionOption SearchConditionOption_3 = new SearchConditionOption("3",SystemEnv.getHtmlLabelName(388571, user.getLanguage())); + if(isEdit){ + if("1".equalsIgnoreCase(beanVal)){ + SearchConditionOption_1.setSelected(true); + }else if("2".equalsIgnoreCase(beanVal)){ + SearchConditionOption_2.setSelected(true); + }else if("3".equalsIgnoreCase(beanVal)){ + SearchConditionOption_3.setSelected(true); + } + }else{ + SearchConditionOption_1.setSelected(true); + } + options.add(SearchConditionOption_1); + options.add(SearchConditionOption_2); + options.add(SearchConditionOption_3); + hrmFieldBean.setSelectOption(options); + } + if(isEdit){ + hrmFieldBean.setFieldvalue(beanVal); + } + if("subcompanyid".equals(tmpField[0])){ + if(hrmdetachable){ + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + String defaultSubcompanyid = ""; + int[] subcomids = newCheck.getSubComByUserRightId(user.getUID(),"KQClass:Management",0); + ManageDetachComInfo detachComInfo = new ManageDetachComInfo(); + if(detachComInfo.isUseHrmManageDetach()){ + defaultSubcompanyid = detachComInfo.getHrmdftsubcomid(); + }else{ + rs.executeProc("SystemSet_Select",""); + if(rs.next()){ + if(subcompanyid.length()==0||subcompanyid.equals("0")){ + defaultSubcompanyid = Util.null2String(rs.getString("dftsubcomid")); + } + } + } + + boolean hasRight = false; + for (int i = 0; subcomids!=null&& i < subcomids.length; i++) { + if((""+subcomids[i]).equals(defaultSubcompanyid)){ + hasRight = true; + break; + } + } + + if(!hasRight){ + defaultSubcompanyid = ""; + } + //表示左侧分部树选择了 + if(Util.getIntValue(Util.null2String(subcompanyid)) > 0){ + hrmFieldBean.setFieldvalue(subcompanyid); + }else{ + hrmFieldBean.setFieldvalue(defaultSubcompanyid); + } + + }else{ + //不开启分权的话,不显示分部 + continue; + } + } + if("punchsettings".equalsIgnoreCase(tmpField[0])){ + hrmFieldBean.setFieldvalue("1"); + } + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + if("overtime_rule_id".equals(tmpField[0])){ + if(CollectionUtils.isNotEmpty(overReplaceDatas)){ + searchConditionItem.getBrowserConditionParam().setReplaceDatas(overReplaceDatas); + } + } + if("shiftonoffworkcount".equals(tmpField[0])){ +// searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(388574, user.getLanguage())); + } + if("isoffdutyfreecheck".equals(tmpField[0])){ + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(388573, user.getLanguage())); + } + if(hrmdetachable && "subcompanyid".equals(tmpField[0])){ + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "KQClass:Management"); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("rightStr", "KQClass:Management"); + } + if("convert_attend_day".equals(hrmFieldBean.getFieldname())){ + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(1); + } + + if("cardRemOfSignIn".equals(hrmFieldBean.getFieldname())){ + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(19782, user.getLanguage()), "0".equals(beanVal))); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(510106, user.getLanguage()), "1".equals(beanVal))); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setValue(beanVal); + } + if("minsBeforeSignIn".equals(hrmFieldBean.getFieldname())||"minsAfterSignOut".equals(hrmFieldBean.getFieldname())){ + searchConditionItem.setValue(beanVal); + searchConditionItem.setMin("0"); + searchConditionItem.setViewAttr(3); + searchConditionItem.setRules("required|integer"); + } + if("cardRemOfSignOut".equals(hrmFieldBean.getFieldname())){ + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(19782, user.getLanguage()), "0".equals(beanVal))); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(510108, user.getLanguage()), "1".equals(beanVal))); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setValue(beanVal); + } + if("remindMode".equals(hrmFieldBean.getFieldname())){ + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(383607, user.getLanguage()), "1".equals(beanVal))); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(18845, user.getLanguage()), "2".equals(beanVal))); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(17586, user.getLanguage()), "3".equals(beanVal))); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setValue(beanVal); + } + if("halfcalrule".equals(hrmFieldBean.getFieldname())){ + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(513091, user.getLanguage()), "0".equals(beanVal))); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(513092, user.getLanguage()), "1".equals(beanVal))); + searchConditionItem.setOptions(optionsList); + } + if("halfcalpoint2cross".equals(hrmFieldBean.getFieldname())){ + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(509159, user.getLanguage()), "0".equals(beanVal))); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388785, user.getLanguage()), "1".equals(beanVal))); + searchConditionItem.setOptions(optionsList); + } + searchConditionItem.setColSpan(1); + + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + int operatelevel = -1; + if(hrmdetachable){ + if(subcompanyid.length()>0 && !subcompanyid.equalsIgnoreCase("0")){ + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + operatelevel=checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"KQClass:Management",Util.getIntValue(subcompanyid,-1)); + } + }else{ + operatelevel = 2; + } + if(!isEdit){ + operatelevel = 2; + } + + if(user.getUID() == 1){ + operatelevel = 2; + } + if(operatelevel > 0){ + retmap.put("canAdd", true); + }else{ + retmap.put("canAdd", false); + } + retmap.put("status", "1"); + retmap.put("condition", grouplist); + retmap.put("workSections", workSectionList); + retmap.put("restTimeSections", restSectionsList); + if(shift_24()){ + retmap.put("shift_24", "1"); + }else{ + retmap.put("shift_24", "0"); + } + retmap.put("id", _id); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + /** + * 班次是否放开24小时制 + * @return + */ + public boolean shift_24() { + boolean shift_24 = false; + RecordSet rs = new RecordSet(); + String settingSql = "select * from KQ_SETTINGS where main_key='shift_24'"; + rs.executeQuery(settingSql); + if(rs.next()){ + String main_val = rs.getString("main_val"); + if("1".equalsIgnoreCase(main_val)){ + shift_24 = true; + } + } + return shift_24; + } +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementPersonalizedFormCmd.java b/src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementPersonalizedFormCmd.java new file mode 100644 index 0000000..d5045bd --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementPersonalizedFormCmd.java @@ -0,0 +1,256 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; + +/** + * 获取班次管理个性化表单 + * @author pzy + * + */ +public class GetShiftManagementPersonalizedFormCmd extends AbstractCommonCommand>{ + + public GetShiftManagementPersonalizedFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String sql = ""; + try { + if(!HrmUserVarify.checkUserRight("KQClass:Management",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + ManageDetachComInfo ManageDetachComInfo = new ManageDetachComInfo(); + String detachable = ManageDetachComInfo.getDetachable(); + String _id = Util.null2String(params.get("id")); + boolean isEdit = false; + + Map fieldOtherMap = new HashMap<>(); + Object[] fieldVal = new Object[8]; + Object[] fieldEnableVal = new Object[6]; + Map ruleMaps = new HashMap<>(); + Map ruleMap = new HashMap<>(); + Map groupRuleMaps = new HashMap<>();//分组用的map + List ruleList = new ArrayList<>(); + if(_id.length() > 0){ + int personalizedRuleid = 0; + String idSql = "select * from kq_ShiftPersonalizedRule where (isdelete is null or isdelete <> '1') and serialid=? "; + rs = new RecordSet(); + rs.executeQuery(idSql,_id); + if(rs.next()) { + isEdit = true; + personalizedRuleid = rs.getInt("id"); + String permitlateminutes = rs.getString("permitlateminutes"); + String seriouslateminutes = rs.getString("seriouslateminutes"); + String lateabsentminutes = rs.getString("lateabsentminutes"); + String permitleaveearlyminutes = rs.getString("permitleaveearlyminutes"); + String seriousleaveearlyminutes = rs.getString("seriousleaveearlyminutes"); + String leaveearlyabsentminutes = rs.getString("leaveearlyabsentminutes"); + + String permitlatestatus = rs.getString("permitlatestatus"); + String seriouslatestatus = rs.getString("seriouslatestatus"); + String lateabsentstatus = rs.getString("lateabsentstatus"); + String permitleaveearlystatus = rs.getString("permitleaveearlystatus"); + String seriousleaveearlystatus = rs.getString("seriousleaveearlystatus"); + String leaveearlyabsentstatus = rs.getString("leaveearlyabsentstatus"); + + String enableexcludelate = rs.getString("enableexcludelate"); + String enableexcludeleaveearly = rs.getString("enableexcludeleaveearly"); + + fieldVal[0] = permitlateminutes; + fieldVal[1] = permitleaveearlyminutes; + fieldVal[2] = seriouslateminutes; + fieldVal[3] = seriousleaveearlyminutes; + fieldVal[4] = lateabsentminutes; + fieldVal[5] = leaveearlyabsentminutes; + fieldVal[6] = Util.null2s(enableexcludelate,"0"); + fieldVal[7] = Util.null2s(enableexcludeleaveearly,"0"); + + fieldEnableVal[0] = permitlatestatus; + fieldEnableVal[1] = permitleaveearlystatus; + fieldEnableVal[2] = seriouslatestatus; + fieldEnableVal[3] = seriousleaveearlystatus; + fieldEnableVal[4] = lateabsentstatus; + fieldEnableVal[5] = leaveearlyabsentstatus; + } + if(personalizedRuleid > 0){ + + String ruleSql = "select * from kq_ShiftPersonalizedRuleDetail where (isdelete is null or isdelete <> '1') and personalizedruleid =? order by ruledetailtype,record "; + rs = new RecordSet(); + rs.executeQuery(ruleSql,personalizedRuleid); + while(rs.next()){ + String enable = rs.getString("enable"); + String enablesame = rs.getString("enablesame"); + String advancetime = rs.getString("advancetime"); + String postponetime = rs.getString("postponetime"); + String ruledetailtype = rs.getString("ruledetailtype"); + String record = rs.getString("record"); + ruleMap = new HashMap<>(); + ruleMap.put("advancetime", advancetime); + ruleMap.put("postponetime", postponetime); + + fieldOtherMap.put(ruledetailtype, enable); + fieldOtherMap.put(ruledetailtype+"same", enablesame); + + if(!"lateoutlatein".equalsIgnoreCase(ruledetailtype)){ + ruleMaps.put(ruledetailtype, ruleMap); + }else{ + ruleMap.put("record", record); + if(groupRuleMaps.get(record) != null){ + List tmpRuleList = (List)groupRuleMaps.get(record); + tmpRuleList.add(ruleMap); + }else{ + ruleList.add(ruleMap); + groupRuleMaps.put(record, ruleList); + } + } + } + if(!ruleList.isEmpty()){ + ruleMaps.put("lateoutlatein", ruleList); + } + } + } + //允许迟到分钟数 允许早退分钟数 严重迟到分钟数 严重早退分钟数 迟到*分钟算旷工 早退早*分钟算旷工 是否排除迟到分钟数 是否排除早退分钟数 + HrmFieldBean hrmFieldBean = null; + String[] fieldrules = new String[]{"permitlateminutes,388578,1,2","permitleaveearlyminutes,388579,1,2","seriouslateminutes,388580,1,2", + "seriousleaveearlyminutes,388581,1,2","lateabsentminutes,20081,1,2","leaveearlyabsentminutes,20082,1,2", + "enableexcludelate,508515,4,1","enableexcludeleaveearly,508516,4,1"}; + //允许迟到是否开启 严重迟到是否开启 迟到视作旷工是否开启 允许早退是否开启 严重早退是否开启 早退视作旷工是否开启 +// "permitlatestatus,388578,4,1","seriouslatestatus,388579,4,1","lateabsentstatus,388582,4,1", +// "permitleaveearlystatus,388579,4,1","seriousleaveearlystatus,388581,4,1","leaveearlyabsentstatus,388582,4,1" + + //允许早到早走 允许晚到晚走 允许晚走晚到 + String[] fieldothers = new String[]{"earlyinearlyout,388586,4,2","earlyinearlyoutsame,513620,4,1","lateinlateout,388589,4,2","lateinlateoutsame,513620,4,1","lateoutlatein,388590,4,2","lateoutlateinsame,513620,4,1"}; + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + List options = new ArrayList(); + + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(388576,weaver.general.Util.getIntValue(user.getLanguage()))); + groupitem.put("defaultshow", true); + + itemlist = new ArrayList(); + for (int j = 0; j < fieldrules.length; j++) { + options = new ArrayList(); + String[] tmpField = Util.null2String(fieldrules[j]).split(","); + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(tmpField[0]); + hrmFieldBean.setFieldlabel(tmpField[1]); + hrmFieldBean.setFieldhtmltype(tmpField[2]); + hrmFieldBean.setType(tmpField[3]); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setIsFormField(true); + boolean is_exclude = false; + if("enableexcludelate".equalsIgnoreCase(tmpField[0]) || "enableexcludeleaveearly".equalsIgnoreCase(tmpField[0])){ + is_exclude = true; + } + + if(isEdit){ + hrmFieldBean.setFieldvalue(fieldVal[j]); + }else{ + if(is_exclude){ + hrmFieldBean.setFieldvalue("0"); + } + } + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setColSpan(2); + if(!is_exclude){ + searchConditionItem.setCheckbox(true); + } + Map otherParams = new HashMap(); + otherParams.put("min",0); + searchConditionItem.setOtherParams(otherParams); + + if("lateabsentminutes".equalsIgnoreCase(tmpField[0]) || "leaveearlyabsentminutes".equalsIgnoreCase(tmpField[0])){ + searchConditionItem.setTip(SystemEnv.getHtmlLabelName(388582, user.getLanguage())); + } + + if(isEdit){ + if(!is_exclude){ + searchConditionItem.setCheckboxValue("1".equals(fieldEnableVal[j])); + } + }else{ + searchConditionItem.setCheckboxValue(false); + } + searchConditionItem.setRules("required|integer"); + + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + + groupitem = new HashMap(); + groupitem.put("title", SystemEnv.getHtmlLabelName(10000837,weaver.general.Util.getIntValue(user.getLanguage()))); + groupitem.put("defaultshow", true); + itemlist = new ArrayList(); + for (int j = 0; j < fieldothers.length; j++) { + options = new ArrayList(); + String[] tmpField = Util.null2String(fieldothers[j]).split(","); + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname(tmpField[0]); + hrmFieldBean.setFieldlabel(tmpField[1]); + hrmFieldBean.setFieldhtmltype(tmpField[2]); + hrmFieldBean.setType(tmpField[3]); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setIsFormField(true); + + if(isEdit){ + if(!fieldOtherMap.isEmpty() && fieldOtherMap.get(tmpField[0]) != null){ + hrmFieldBean.setFieldvalue(fieldOtherMap.get(tmpField[0])); + } + }else{ + hrmFieldBean.setFieldvalue(0); + } + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); +// searchConditionItem.setRules("required|string"); + + itemlist.add(searchConditionItem); + } + groupitem.put("items", itemlist); + grouplist.add(groupitem); + + retmap.put("status", "1"); + retmap.put("condition", grouplist); + retmap.put("personalizedRuleDetails", ruleMaps); + retmap.put("id", _id); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementSearchConditionCmd.java b/src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementSearchConditionCmd.java new file mode 100644 index 0000000..f637070 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementSearchConditionCmd.java @@ -0,0 +1,71 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取班次管理查询条件条件 + * @author pzy + * + */ +public class GetShiftManagementSearchConditionCmd extends AbstractCommonCommand>{ + + public GetShiftManagementSearchConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> grouplist = new ArrayList>(); + Map groupitem = null; + List itemlist = null; + if(!HrmUserVarify.checkUserRight("KQClass:Management",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + try{ + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + itemlist = new ArrayList(); + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("serial"); + hrmFieldBean.setFieldlabel("125818"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsQuickSearch(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setViewAttr(2); + itemlist.add(searchConditionItem); + retmap.put("status", "1"); + retmap.put("conditions", itemlist); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementSearchListCmd.java b/src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementSearchListCmd.java new file mode 100644 index 0000000..b04e940 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/GetShiftManagementSearchListCmd.java @@ -0,0 +1,145 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.api.hrm.util.PageUidFactory; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.HashMap; +import java.util.Map; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +/** + * 获取班次管理查询结果列表 + * @author pzy + * + */ +public class GetShiftManagementSearchListCmd extends AbstractCommonCommand>{ + + public GetShiftManagementSearchListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + if(!HrmUserVarify.checkUserRight("KQClass:Management",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + try { + String type = Util.null2String(params.get("type")); + String id = Util.null2String(params.get("id")); + + String serial = Util.null2String(params.get("serial")); + String subcompanyid=Util.null2String(params.get("subcompanyid")); + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + int operatelevel = -1; + + String backfields = " * "; + String fromSql = " kq_ShiftManagement "; + String sqlWhere = " where 1=1 and (isdelete is null or isdelete <> '1') "; + if(hrmdetachable){ + int[] arrSubcompanyids = checkSubCompanyRight.getSubComByUserRightId(user.getUID(),"KQClass:Management"); + String subcompanyids = ""; + if(user.getUID() != 1){ + for(int i=0;arrSubcompanyids!=null&&i0)subcompanyids+=","; + subcompanyids += arrSubcompanyids[i]; + } + if(subcompanyids.length() > 0 ){ + sqlWhere += " and subcompanyid in("+subcompanyids+")"; + }else{ + sqlWhere += " and 1=2 "; + } + } + }else{ + operatelevel = 2; + } + String orderby = " id " ; + String tableString = ""; + + if(subcompanyid.length()>0 && !subcompanyid.equalsIgnoreCase("0")){ + sqlWhere += " and subcompanyid = " + subcompanyid; + if(hrmdetachable){ + operatelevel=checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"KQClass:Management",Util.getIntValue(subcompanyid,-1)); + } + } + if(user.getUID() == 1){ + operatelevel = 2; + } + + if(serial.length() > 0){ + sqlWhere += " and serial like '%"+serial+"%'"; + } + + //操作字符串 + String operateString= ""; + operateString = ""; + operateString+=" "; + if(operatelevel > 0){ + operateString+=" "; + operateString+=" "; + } + if(operatelevel > 1){ + operateString+=" "; + } + operateString+=" "; + operateString+=""; + String tabletype="checkbox"; + if(HrmUserVarify.checkUserRight("KQClass:Management", user)){ + tabletype = "checkbox"; + } + String pageUid = PageUidFactory.getHrmPageUid("ShiftManagementSearchList"); + + tableString =" "+ + " "+ + " "+ + operateString+ + " "+ + " "+ + " "+ + " "+ + " "+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + if(operatelevel > 0){ + retmap.put("canAdd", true); + }else{ + retmap.put("canAdd", false); + } + if(operatelevel > 1){ + retmap.put("canDel", true); + }else{ + retmap.put("canDel", false); + } + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/GetTabsCmd.java b/src/com/engine/kq/cmd/shiftmanagement/GetTabsCmd.java new file mode 100644 index 0000000..37d5666 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/GetTabsCmd.java @@ -0,0 +1,69 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取班次管理表单tab页签 + * @author pzy + * + */ +public class GetTabsCmd extends AbstractCommonCommand>{ + + public GetTabsCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + String pageid = Util.null2String(params.get("pageid"));//页面标识 + List rightMenu = new ArrayList(); + try { + if(!HrmUserVarify.checkUserRight("KQClass:Management",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + List> tabs = new ArrayList>(); + Map tab = null; + + tab = new HashMap(); + tab.put("key", "1"); + tab.put("title", SystemEnv.getHtmlLabelName(1361,user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", "2"); + tab.put("title", SystemEnv.getHtmlLabelName(388528,user.getLanguage())); + tabs.add(tab); + + retmap.put("status", "1"); + retmap.put("tabs", tabs); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/SaveEmailRemindCmd.java b/src/com/engine/kq/cmd/shiftmanagement/SaveEmailRemindCmd.java new file mode 100644 index 0000000..0a2b31f --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/SaveEmailRemindCmd.java @@ -0,0 +1,85 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +public class SaveEmailRemindCmd extends AbstractCommonCommand> { + + public SaveEmailRemindCmd(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(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQClass:Management", user); + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + String serialId = Util.null2String(params.get("serialId"));//班次ID + String datas = Util.null2String(params.get("datas"));//数据 + if (serialId.equals("") || datas.equals("")) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage())); + return resultMap; + } + + String sql = "delete from kq_emailRemindTemplate where serialId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeUpdate(sql, serialId); + + JSONArray jsonArray = JSONArray.parseArray(datas); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + String id = jsonObject.getString("id"); + String radio = jsonObject.getString("radio"); + String type = jsonObject.getString("type"); + String title = jsonObject.getString("title"); + String content = jsonObject.getString("content"); + String signInOrSignOut = ""; + String availableParams = ""; + if ("1".equals(id)) { + signInOrSignOut = "2"; + availableParams = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005342,weaver.general.ThreadVarLanguage.getLang())+""; + } else { + signInOrSignOut = "1"; + availableParams = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(18843,weaver.general.ThreadVarLanguage.getLang())+""; + } + + sql = "insert into kq_emailRemindTemplate(serialId,signInOrSignOut,emailTitle,emailContent,availableParams) values(?,?,?,?,?)"; + boolean flag = recordSet.executeUpdate(sql, serialId, signInOrSignOut, title, content, availableParams); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/SaveMessageRemindCmd.java b/src/com/engine/kq/cmd/shiftmanagement/SaveMessageRemindCmd.java new file mode 100644 index 0000000..c8440e9 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/SaveMessageRemindCmd.java @@ -0,0 +1,87 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * + */ +public class SaveMessageRemindCmd extends AbstractCommonCommand> { + + public SaveMessageRemindCmd(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(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQClass:Management", user); + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + String serialId = Util.null2String(params.get("serialId"));//班次ID + String datas = Util.null2String(params.get("datas"));//数据 + if (serialId.equals("") || datas.equals("")) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage())); + return resultMap; + } + + String sql = "delete from kq_messageRemindTemplate where serialId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeUpdate(sql, serialId); + + JSONArray jsonArray = JSONArray.parseArray(datas); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + String id = jsonObject.getString("id"); + String radio = jsonObject.getString("radio"); + String type = jsonObject.getString("signType"); + String content = jsonObject.getString("content"); + String signInOrSignOut = ""; + String availableParams = ""; + if ("1".equals(id)) { + signInOrSignOut = "2"; + availableParams = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005342,weaver.general.ThreadVarLanguage.getLang())+""; + } else { + signInOrSignOut = "1"; + availableParams = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(18843,weaver.general.ThreadVarLanguage.getLang())+""; + } + + sql = "insert into kq_messageRemindTemplate(serialId,signInOrSignOut,messageContent,availableParams) values(?,?,?,?)"; + boolean flag = recordSet.executeUpdate(sql, serialId, signInOrSignOut, content, availableParams); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/SaveShiftManagementBaseFormCmd.java b/src/com/engine/kq/cmd/shiftmanagement/SaveShiftManagementBaseFormCmd.java new file mode 100644 index 0000000..0587f3b --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/SaveShiftManagementBaseFormCmd.java @@ -0,0 +1,535 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.UUID; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.Reminder.KQAutoCardTask; +import weaver.hrm.User; +import weaver.hrm.common.database.dialect.DbDialectFactory; +import weaver.hrm.common.database.dialect.IDbDialectSql; +import weaver.systeminfo.SystemEnv; + +/** + * 保存班次管理基本信息表单 + * @author pzy + * + */ +public class SaveShiftManagementBaseFormCmd extends AbstractCommonCommand>{ + + private SimpleBizLogger logger; + + public SaveShiftManagementBaseFormCmd() { + } + + public SaveShiftManagementBaseFormCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_SHIFTMANAGER); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_SHIFTMANAGER); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + if(params != null && params.containsKey("data")){ + String datas = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(datas); + String serialid = Util.null2String(jsonObj.get("id")); + + if(serialid.length() > 0){ + String mainSql = " select * from kq_ShiftManagement where id= "+serialid +" "; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("serial"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_ShiftOnOffWorkSections where serialid="+serialid; + subLogInfo1.setSubTargetNameColumn("times"); + subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(27961); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + SimpleBizLogger.SubLogInfo subLogInfo = logger.getNewSubLogInfo(); + String subSql = " select * from kq_ShiftRestTimeSections where serialid = "+serialid; + subLogInfo.setSubSql(subSql); + subLogInfo.setSubTargetNameColumn("time"); + subLogInfo.setGroupId("1"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo.setSubGroupNameLabel(505603); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo); + logger.before(logContext); + } + } + + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + /** + * 获取日志对象的名称 + * @param id + * @param para2 + * @return + */ + public String getTargetName(String id,String para2){ + try { + return para2; + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String datas = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(datas); + String serialid = Util.null2String(jsonObj.get("id")); + if(!HrmUserVarify.checkUserRight("KQClass:Management",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + try{ + if(serialid.length() > 0){ + edit(retmap,jsonObj); + }else{ + add(retmap,jsonObj); + } + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + kqShiftManagementComInfo.removeShiftManagementCache(); + + if(retmap.containsKey("id")){ + KQConfigComInfo kqConfigComInfo = new KQConfigComInfo(); + String auto_card_cominfo = Util.null2String(kqConfigComInfo.getValue("auto_card_cominfo"),"0"); + if("1".equalsIgnoreCase(auto_card_cominfo)){ + String serial_id = Util.null2String(retmap.get("id")); + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + List groupList = kqGroupBiz.getGroupIdByUesedSerialId(serial_id); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + if(!groupList.isEmpty()){ + for(String groupId : groupList){ + String auto_checkin = kqGroupComInfo.getAuto_checkin(groupId); + String auto_checkout = kqGroupComInfo.getAuto_checkout(groupId); + if("1".equalsIgnoreCase(auto_checkout) || "1".equalsIgnoreCase(auto_checkin)){ + //当前班次存在自动打卡设置,修改班次后,不影响当天的自动打卡时间,变更后的班次自动打卡需要第二天才起作用 + retmap.put("message", "当前班次存在自动打卡设置,修改班次后,不影响当天的自动打卡时间,变更后的班次自动打卡需要第二天才起作用"); + break; + } + } + } + } + } + + }catch (Exception e){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + + /** + * 编辑班次基本信息 + * @param retmap + * @param jsonObj + */ + public void edit(Map retmap,JSONObject jsonObj) throws Exception{ + RecordSetTrans rst = new RecordSetTrans(); + rst.setAutoCommit(true); + RecordSet rs = new RecordSet(); + String serialid = Util.null2String(jsonObj.get("id")); + String serial = Util.null2String(jsonObj.get("serial"));//班次名称 + float convertAttendDay = Util.getFloatValue(Util.null2s(Util.null2String(jsonObj.get("convert_attend_day")),"1.0"));//应出勤折算天数 + String subcompanyid = Util.null2o(Util.null2String(jsonObj.get("subcompanyid"))); + String shiftOnOffWorkCount = Util.null2o(Util.null2String(jsonObj.get("shiftonoffworkcount")));//一天内上下班次数 + if("3".equals(shiftOnOffWorkCount) || "2".equals(shiftOnOffWorkCount)) { + boolean isKqReportHalfOpen = "1".equals(new KQSettingsComInfo().getMain_val("kq_report_half")); + if(isKqReportHalfOpen) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(547560,user.getLanguage())); + return ; + } + } + String punchSettings = "1";//打卡时段是否开启 1表示开启 + String isOffDutyFreeCheck = Util.null2o(Util.null2String(jsonObj.get("isoffdutyfreecheck")));//允许下班不打卡 1表示开启 + String isRestTimeOpen = Util.null2o(Util.null2String(jsonObj.get("isresttimeopen")));//排除休息时间是否开启 1表示开启 + String worktime = Util.null2o(Util.null2String(jsonObj.get("worktime")));//工作时长 +// String color = Util.null2o(Util.null2String(jsonObj.get("color")));//工作时长 + String color = "#000"; + String cardRemind = Util.null2s(jsonObj.getString("cardRemind"),"0");//是否开启打卡提醒:0-不开启、1-开启。默认不开启 + String cardRemOfSignIn = Util.null2s(jsonObj.getString("cardRemOfSignIn"),"1");//上班打卡提醒:0-不提醒、1-自定义提前提醒分钟数。默认为1 + String minsBeforeSignIn = Util.null2s(jsonObj.getString("minsBeforeSignIn"),"10");//自定义提前提醒分钟数。默认10分钟 + String cardRemOfSignOut = Util.null2s(jsonObj.getString("cardRemOfSignOut"),"1");//下班打卡提醒:0-不提醒、1-自定义延后提醒分钟数。默认为1 + String minsAfterSignOut = Util.null2s(jsonObj.getString("minsAfterSignOut"),"0");//自定义延后提醒分钟数。默认0分钟 + String remindMode = Util.null2s(jsonObj.getString("remindMode"),"1");//提醒方式:1-消息中心提醒、2-邮件提醒、3-短信提醒。默认消息中心提醒 + String remindOnPC = Util.null2s(jsonObj.getString("remindOnPC"),"0");//登陆PC端弹窗提醒:0-不开启、1-开启 + + String halfcalrule = Util.null2s(jsonObj.getString("halfcalrule"),"0");//半天计算规则 + String halfcalpoint = Util.null2s(jsonObj.getString("halfcalpoint"),"");//半天分界点 + String halfcalpoint2cross = Util.null2s(jsonObj.getString("halfcalpoint2cross"),"0");//当日 + int signoutOnlyoff = StringUtil.parseToInt(jsonObj.getString("signoutOnlyoff"),0);//下班后只允许签退 + int is_rest = Util.getIntValue(Util.null2s(jsonObj.getString("is_rest"),"0"));//非工作日班次 + int overtime_rule_id = Util.getIntValue(Util.null2s(jsonObj.getString("overtime_rule_id"),"0"));//加班规则 + + if(duplicationCheck(serial,serialid)){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(389019,user.getLanguage())); + return ; + } + String[] works = new String[]{"start","end"}; + JSONArray workSections = (JSONArray)jsonObj.get("workSections"); + checkRule(retmap,workSections,works); + + if(!retmap.isEmpty()){ + return ; + } + + String mainSql = "update kq_ShiftManagement set serial=?,subcompanyid=?,shiftonoffworkcount=?,punchsettings=?,isoffdutyfreecheck=?,isresttimeopen=?,worktime=?,color=?," + + "cardRemind=? ,cardRemOfSignIn=? ,minsBeforeSignIn=? ,cardRemOfSignOut=? ,minsAfterSignOut=? ,remindMode=? ,remindOnPC=?,halfcalrule=?,halfcalpoint=?," + + "halfcalpoint2cross=?,signoutOnlyoff=?,is_rest=?,overtime_rule_id=?,convert_attend_day=? where id = ? "; + + boolean isUpdated = rst.executeUpdate(mainSql, serial,subcompanyid,shiftOnOffWorkCount,punchSettings,isOffDutyFreeCheck,isRestTimeOpen,worktime,color, + cardRemind ,cardRemOfSignIn ,minsBeforeSignIn ,cardRemOfSignOut ,minsAfterSignOut ,remindMode ,remindOnPC,halfcalrule,halfcalpoint,halfcalpoint2cross,signoutOnlyoff,is_rest, + overtime_rule_id,convertAttendDay,serialid); + + if(isUpdated){ + //对于休息时间和工作时间,直接删除后重新创建 + String delRestSql = "delete from kq_ShiftRestTimeSections where serialid = ? "; + rs = new RecordSet(); + rst.executeUpdate(delRestSql, serialid); + String delWorkSql = "delete from kq_ShiftOnOffWorkSections where serialid = ? "; + rs = new RecordSet(); + rst.executeUpdate(delWorkSql, serialid); + + //休息时间 resttype:start开始时间,end结束时间 + JSONArray restTimeSections = (JSONArray)jsonObj.get("restTimeSections"); + //工作时间 across是否跨天,1表示跨天;beginMin上班前分钟数开始签到,endMin下班后分钟数停止签退;times具体上下班时间;onOffWorkType:start开始时间,end结束时间 + + String restSql = "insert into kq_ShiftRestTimeSections(serialid,resttype,time,across,record1,orderId) values(?,?,?,?,?,?)"; + int restCount = restTimeSections.size(); + rs = new RecordSet(); + for(int i = 0 ; i < restCount ; i++){ + JSONObject jsonRest = ((JSONObject)restTimeSections.get(i)); + if(jsonRest.containsKey("start") && jsonRest.containsKey("end")){ + String record=Util.null2String(jsonRest.get("record")); + String orderId=Util.null2String(jsonRest.get("orderId")); + + JSONObject start_jsonRest = (JSONObject) jsonRest.get("start"); + String time=Util.null2String(start_jsonRest.get("time")); + String resttype="start"; + String across=Util.null2String(start_jsonRest.get("accross")); + rst.executeUpdate(restSql, serialid,resttype,time,across,record,orderId); + + JSONObject end_jsonRest = (JSONObject) jsonRest.get("end"); + time=Util.null2String(end_jsonRest.get("time")); + resttype="end"; + across=Util.null2String(end_jsonRest.get("accross")); + rst.executeUpdate(restSql, serialid,resttype,time,across,record,orderId); + } + } + rs = new RecordSet(); + String workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,mins_next,clockinnot) values(?,?,?,?,?,?,?,?)"; + int workCount = workSections.size(); + for(int i = 0 ; i < workCount ; i++){ + JSONObject jsonWork = ((JSONObject)workSections.get(i)); + String record = Util.null2String(jsonWork.get("record")); + for(int j = 0 ; j < works.length ; j++){ + String onOffWorkType=works[j]; + JSONObject inWork=(JSONObject)jsonWork.get(onOffWorkType); + String across=Util.null2String(inWork.get("across")); + String mins = Util.null2s(Util.null2String(inWork.get("mins")),"0"); + String times=Util.null2String(inWork.get("times")); + String mins_next=Util.null2String(inWork.get("mins_next")); + String clockinnot=Util.null2s(Util.null2String(inWork.get("clockinnot")),"0"); + rst.executeUpdate(workSql, serialid,across,mins,times,onOffWorkType,record,mins_next,clockinnot); + } + } + retmap.put("id", serialid); + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(18758, user.getLanguage())); + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + + } + + /** + * 新增班次基本信息 + * @param retmap + * @param jsonObj + */ + public void add(Map retmap,JSONObject jsonObj) throws Exception{ + RecordSetTrans rst = new RecordSetTrans(); + rst.setAutoCommit(true); + RecordSet rs = new RecordSet(); + String subcompanyid = Util.null2o(Util.null2String(jsonObj.get("subcompanyid"))); + String serial = Util.null2String(jsonObj.get("serial"));//班次名称 + float convertAttendDay = Util.getFloatValue(Util.null2s(Util.null2String(jsonObj.get("convert_attend_day")),"1.0"));//应出勤折算天数 + String shiftOnOffWorkCount = Util.null2o(Util.null2String(jsonObj.get("shiftonoffworkcount")));//一天内上下班次数 + if("3".equals(shiftOnOffWorkCount) || "2".equals(shiftOnOffWorkCount)) { + boolean isKqReportHalfOpen = "1".equals(new KQSettingsComInfo().getMain_val("kq_report_half")); + if(isKqReportHalfOpen) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(547560,user.getLanguage())); + return ; + } + } + String punchSettings = "1";//打卡时段是否开启 1表示开启 + String isOffDutyFreeCheck = Util.null2o(Util.null2String(jsonObj.get("isoffdutyfreecheck")));//允许下班不打卡 1表示开启 + String isRestTimeOpen = Util.null2o(Util.null2String(jsonObj.get("isresttimeopen")));//排除休息时间是否开启 1表示开启 + String worktime = Util.null2o(Util.null2String(jsonObj.get("worktime")));//工作时长 +// String color = Util.null2o(Util.null2String(jsonObj.get("color")));//工作时长 + String color = "#000"; + String uuid = UUID.randomUUID().toString();//uuid供查询使用 + String cardRemind = Util.null2s(jsonObj.getString("cardRemind"),"0");//是否开启打卡提醒:0-不开启、1-开启。默认不开启 + String cardRemOfSignIn = Util.null2s(jsonObj.getString("cardRemOfSignIn"),"1");//上班打卡提醒:0-不提醒、1-自定义提前提醒分钟数。默认为1 + String minsBeforeSignIn = Util.null2s(jsonObj.getString("minsBeforeSignIn"),"10");//自定义提前提醒分钟数。默认10分钟 + String cardRemOfSignOut = Util.null2s(jsonObj.getString("cardRemOfSignOut"),"1");//下班打卡提醒:0-不提醒、1-自定义延后提醒分钟数。默认为1 + String minsAfterSignOut = Util.null2s(jsonObj.getString("minsAfterSignOut"),"0");//自定义延后提醒分钟数。默认0分钟 + String remindMode = Util.null2s(jsonObj.getString("remindMode"),"1");//提醒方式:1-消息中心提醒、2-邮件提醒、3-短信提醒。默认消息中心提醒 + String remindOnPC = Util.null2s(jsonObj.getString("remindOnPC"),"0");//登陆PC端弹窗提醒:0-不开启、1-开启 + + String halfcalrule = Util.null2s(jsonObj.getString("halfcalrule"),"0");//半天计算规则 + String halfcalpoint = Util.null2s(jsonObj.getString("halfcalpoint"),"");//半天分界点 + String halfcalpoint2cross = Util.null2s(jsonObj.getString("halfcalpoint2cross"),"0");//当日 + int signoutOnlyoff = StringUtil.parseToInt(jsonObj.getString("signoutOnlyoff"),0); + int is_rest = Util.getIntValue(Util.null2s(jsonObj.getString("is_rest"),"0"));//非工作日班次 + int overtime_rule_id = Util.getIntValue(Util.null2s(jsonObj.getString("overtime_rule_id"),"0"));//加班规则 + + if(duplicationCheck(serial,"")){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(389019,user.getLanguage())); + return ; + } + //工作时间 across是否跨天,1表示跨天;beginMin上班前分钟数开始签到,endMin下班后分钟数停止签退;times具体上下班时间;onOffWorkType:start开始时间,end结束时间 + + JSONArray workSections = (JSONArray)jsonObj.get("workSections"); + String[] works = new String[]{"start","end"}; + checkRule(retmap,workSections,works); + + if(!retmap.isEmpty()){ + return ; + } + //color改为前台获取 +// String color = getRandomColor(); + boforeLog(uuid); + + String mainSql = "insert into kq_ShiftManagement(serial,subcompanyid,shiftonoffworkcount,punchsettings,isoffdutyfreecheck,isresttimeopen,worktime,uuid,color," + + "cardRemind ,cardRemOfSignIn ,minsBeforeSignIn ,cardRemOfSignOut ,minsAfterSignOut ,remindMode ,remindOnPC,halfcalrule,halfcalpoint,halfcalpoint2cross,signoutOnlyoff,is_rest,overtime_rule_id,convert_attend_day)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + + boolean isUpdated = rst.executeUpdate(mainSql, serial,subcompanyid,shiftOnOffWorkCount,punchSettings,isOffDutyFreeCheck,isRestTimeOpen,worktime,uuid,color, + cardRemind ,cardRemOfSignIn ,minsBeforeSignIn ,cardRemOfSignOut ,minsAfterSignOut ,remindMode ,remindOnPC,halfcalrule,halfcalpoint,halfcalpoint2cross,signoutOnlyoff,is_rest,overtime_rule_id,convertAttendDay); + + if(isUpdated){ + int serialid = 0; + String idSql = "select id from kq_ShiftManagement where uuid=? and (isdelete is null or isdelete <> '1') "; + rs = new RecordSet(); + rs.executeQuery(idSql,uuid); + if(rs.next()) { + serialid = rs.getInt("id"); + } + + if(serialid > 0){ + + //休息时间 resttype:start开始时间,end结束时间 + JSONArray restTimeSections = (JSONArray)jsonObj.get("restTimeSections"); + + String restSql = "insert into kq_ShiftRestTimeSections(serialid,resttype,time,across,record1,orderId) values(?,?,?,?,?,?)"; + int restCount = restTimeSections.size(); + rs = new RecordSet(); + for(int i = 0 ; i < restCount ; i++){ + JSONObject jsonRest = ((JSONObject)restTimeSections.get(i)); + if(jsonRest.containsKey("start") && jsonRest.containsKey("end")){ + String record=Util.null2String(jsonRest.get("record")); + String orderId=Util.null2String(jsonRest.get("orderId")); + JSONObject start_jsonRest = (JSONObject) jsonRest.get("start"); + String time=Util.null2String(start_jsonRest.get("time")); + String resttype="start"; + String across=Util.null2String(start_jsonRest.get("accross")); + rst.executeUpdate(restSql, serialid,resttype,time,across,record,orderId); + + JSONObject end_jsonRest = (JSONObject) jsonRest.get("end"); + time=Util.null2String(end_jsonRest.get("time")); + resttype="end"; + across=Util.null2String(end_jsonRest.get("accross")); + rst.executeUpdate(restSql, serialid,resttype,time,across,record,orderId); + } + } + rs = new RecordSet(); + String workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,mins_next,clockinnot) values(?,?,?,?,?,?,?,?)"; + int workCount = workSections.size(); + for(int i = 0 ; i < workCount ; i++){ + JSONObject jsonWork = ((JSONObject)workSections.get(i)); + String record = Util.null2String(jsonWork.get("record")); + for(int j = 0 ; j < works.length ; j++){ + String onOffWorkType=works[j]; + JSONObject inWork=(JSONObject)jsonWork.get(onOffWorkType); + String across=Util.null2String(inWork.get("across")); + String mins = Util.null2s(Util.null2String(inWork.get("mins")),"1"); + String times=Util.null2String(inWork.get("times")); + String mins_next=Util.null2String(inWork.get("mins_next")); + String clockinnot = Util.null2s(Util.null2String(inWork.get("clockinnot")),"0"); + rst.executeUpdate(workSql, serialid,across,mins,times,onOffWorkType,record,mins_next,clockinnot); + } + } + retmap.put("status", "1"); + retmap.put("id", serialid); + retmap.put("message", SystemEnv.getHtmlLabelName(18758, user.getLanguage())); + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + } + + private void checkRule(Map retmap, + JSONArray workSections, String[] works) { + for(int i = 0 ; i < workSections.size() ; i++) { + JSONObject jsonWork = ((JSONObject) workSections.get(i)); + for(int j = 0 ; j < works.length ; j++){ + String onOffWorkType=works[j]; + JSONObject inWork=(JSONObject)jsonWork.get(onOffWorkType); + String mins = Util.null2String(inWork.get("mins")); + if(mins.length() == 0 || Util.getIntValue(mins) == 0){ + retmap.put("status", "-1"); + retmap.put("message", ""+ SystemEnv.getHtmlLabelName(10005343,weaver.general.ThreadVarLanguage.getLang())+""); + break; + } + } + } + } + + /** + * 判断是否重名 + * @param serial + * @param serialid 为空表示新增 + * @return + */ + private boolean duplicationCheck(String serial,String serialid){ + boolean isDuplicated = false; + RecordSet rs = new RecordSet(); + String checkSql = "select 1 from kq_ShiftManagement where serial=? and (isdelete is null or isdelete <> '1') "; + if(serialid.length() > 0){ + checkSql += " and id != "+serialid; + } + rs.executeQuery(checkSql, Util.null2s(serial, "").trim()); + if(rs.next()){ + isDuplicated = true; + } + return isDuplicated; + } + + /** + * 生成随机的颜色 + * @return + */ + private String getRandomColor(){ + + RecordSet rs = new RecordSet(); + List colorLists = new ArrayList<>(); + String hasSameColor = "select color from kq_ShiftManagement group by color "; + rs.executeQuery(hasSameColor); + while (rs.next()){ + colorLists.add(rs.getString("color")); + } + + String color = ""; + Random random = null; + + int i = 0 ; +// while(true){ +// random = new Random(); +// //颜色就要深色的 +// String[] colors = new String[]{"0","1","2","3","4","5","6"}; +// int not_r = random.nextInt(16); +// int not_g = random.nextInt(16); +// int not_b = random.nextInt(16); +// int not_r1 = random.nextInt(16); +// int not_g1 = random.nextInt(16); +// int not_b1 = random.nextInt(16); +// color = "#"+colors[not_r]+colors[not_g]+colors[not_b]+colors[not_r1]+colors[not_g1]+colors[not_b1]; +// //以防死锁 +// if(i > 1000){ +// break; +// } +// if(!colorLists.contains(color)){ +// break; +// } +// i++; +// } + + return color; + } + + public void boforeLog(String uuid){ + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_SHIFTMANAGER); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_SHIFTMANAGER); + logContext.setParams(params); + + String log_mainSql = " select * from kq_ShiftManagement where uuid in('"+uuid+"')"; + logger.setMainSql(log_mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("serial"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_ShiftOnOffWorkSections where serialid in (select id from kq_ShiftManagement where uuid in('"+uuid+"'))" ; + subLogInfo1.setSubTargetNameColumn("times"); + subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(27961); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + SimpleBizLogger.SubLogInfo subLogInfo = logger.getNewSubLogInfo(); + String subSql = " select * from kq_ShiftRestTimeSections where serialid in (select id from kq_ShiftManagement where uuid in('"+uuid+"'))" ; + subLogInfo.setSubSql(subSql); + subLogInfo.setSubTargetNameColumn("time"); + subLogInfo.setGroupId("1"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo.setSubGroupNameLabel(505603); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo); + logger.before(logContext); + } +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/SaveShiftManagementPersonalizedFormCmd.java b/src/com/engine/kq/cmd/shiftmanagement/SaveShiftManagementPersonalizedFormCmd.java new file mode 100644 index 0000000..1104b30 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/SaveShiftManagementPersonalizedFormCmd.java @@ -0,0 +1,376 @@ +package com.engine.kq.cmd.shiftmanagement; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQShiftManagementComInfo; +import com.engine.kq.biz.KQShiftPersonalizedRuleCominfo; +import com.engine.kq.biz.KQShiftPersonalizedRuleDetailComInfo; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 保存班次管理个性化表单 + * @author pzy + * + */ +public class SaveShiftManagementPersonalizedFormCmd extends AbstractCommonCommand>{ + + private SimpleBizLogger logger; + + public SaveShiftManagementPersonalizedFormCmd() { + } + + public SaveShiftManagementPersonalizedFormCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_SHIFTMANAGER); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_SHIFTMANAGER); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + String datas = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(datas); + String serialid = Util.null2String(jsonObj.get("id")); + + if(serialid.length() > 0){ + String mainSql = " select * from kq_ShiftManagement where id= "+serialid +" "; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod(this.getClass().getName() + ".getTargetName", "column:serial"); + + SimpleBizLogger.SubLogInfo subLogInfo = logger.getNewSubLogInfo(); + String subSql = " select * from kq_ShiftPersonalizedRule where serialid= "+serialid +" "; + subLogInfo.setSubSql(subSql); + subLogInfo.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo.setSubGroupNameLabel(18166); //在详情中显示的分组名称,不设置默认显示明细x + logger.addSubLogInfo(subLogInfo); + + int personalizedRuleid = 0; + String idSql = "select id from kq_ShiftPersonalizedRule where serialid=? "; + RecordSet rs = new RecordSet(); + rs.executeQuery(idSql,serialid); + if(rs.next()) { + personalizedRuleid = rs.getInt("id"); + } + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_ShiftPersonalizedRuleDetail where personalizedruleid="+personalizedRuleid; + subLogInfo1.setGroupId("1"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(388585); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + } + logger.before(logContext); + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + /** + * 获取日志对象的名称 + * @param id + * @param para2 + * @return + */ + public String getTargetName(String id,String para2){ + try { + return para2; + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String datas = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(datas); + String serialid = Util.null2String(jsonObj.get("id")); + if(!HrmUserVarify.checkUserRight("KQClass:Management",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + int personalizedRuleid = 0; + String idSql = "select id from kq_ShiftPersonalizedRule where serialid=? "; + rs = new RecordSet(); + rs.executeQuery(idSql,serialid); + if(rs.next()) personalizedRuleid = rs.getInt("id"); + + try{ + if(personalizedRuleid > 0){ + edit(retmap,jsonObj,personalizedRuleid); + }else{ + add(retmap,jsonObj); + } + KQShiftPersonalizedRuleCominfo kqShiftPersonalizedRuleCominfo = new KQShiftPersonalizedRuleCominfo(); + KQShiftPersonalizedRuleDetailComInfo ruleDetailComInfo = new KQShiftPersonalizedRuleDetailComInfo(); + + kqShiftPersonalizedRuleCominfo.removeCache(); + ruleDetailComInfo.removePersonalizedRuleDetailCache(); + }catch (Exception e){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + + /** + * 编辑个性化信息 + * @param retmap + * @param jsonObj + * @param personalizedRuleid + */ + private void edit(Map retmap,JSONObject jsonObj,int personalizedRuleid) throws Exception{ + RecordSetTrans rst = new RecordSetTrans(); + String dbType = rst.getDBType(); + rst.setAutoCommit(true); + RecordSet rs = new RecordSet(); + String serialid = Util.null2String(jsonObj.get("id"));//本信息id + String permitLateMinutes= Util.null2String(jsonObj.get("permitlateminutes"));//允许迟到分钟数 + String seriousLateMinutes = Util.null2String(jsonObj.get("seriouslateminutes"));//严重迟到分钟数 + String lateAbsentMinutes= Util.null2String(jsonObj.get("lateabsentminutes"));//迟到视作旷工分钟数 + String permitLeaveEarlyMinutes= Util.null2String(jsonObj.get("permitleaveearlyminutes"));//允许早退分钟数 + String seriousLeaveEarlyMinutes = Util.null2String(jsonObj.get("seriousleaveearlyminutes"));//严重早退分钟数 + String leaveEarlyAbsentMinutes= Util.null2String(jsonObj.get("leaveearlyabsentminutes"));//早退视作旷工分钟数 + String enableexcludelate = Util.null2String(jsonObj.get("enableexcludelate"));//是否排除迟到分钟数 + String enableexcludeleaveearly= Util.null2String(jsonObj.get("enableexcludeleaveearly"));//是否排除早退分钟数 + + String permitlateminutesenable = Util.null2String(jsonObj.get("permitlateminutesenable"));//允许迟到是否开启 + String seriouslateminutesenable= Util.null2String(jsonObj.get("seriouslateminutesenable"));///严重迟到是否开启 + String lateabsentminutesenable = Util.null2String(jsonObj.get("lateabsentminutesenable"));//迟到视作旷工是否开启 + String permitleaveearlyminutesenable = Util.null2String(jsonObj.get("permitleaveearlyminutesenable"));///允许早退是否开启 + String seriousleaveearlyminutesenable= Util.null2String(jsonObj.get("seriousleaveearlyminutesenable"));//严重早退是否开启 + String leaveearlyabsentminutesenable = Util.null2String(jsonObj.get("leaveearlyabsentminutesenable"));//早退视作旷工是否开启 + + String earlyinearlyout = Util.null2String(jsonObj.get("earlyinearlyout"));//允许早到早走是否开启 + String lateinlateout = Util.null2String(jsonObj.get("lateinlateout"));//允许晚到晚走是否开启 + String lateoutlatein = Util.null2String(jsonObj.get("lateoutlatein"));//允许晚走晚到是否开启 + + JSONObject personalizedRuleDetails = (JSONObject)jsonObj.get("personalizedRuleDetails"); + checkRule(personalizedRuleDetails,retmap,jsonObj); + if(!retmap.isEmpty()){ + return ; + } + + String mainSql = "update kq_ShiftPersonalizedRule set permitlateminutes=?,seriouslateminutes=?,lateabsentminutes=?, " + + "permitleaveearlyminutes=?,seriousleaveearlyminutes=?,leaveearlyabsentminutes=?,permitlatestatus=?, " + + "seriouslatestatus=?,lateabsentstatus=?,permitleaveearlystatus=?,seriousleaveearlystatus=?,leaveearlyabsentstatus=?, " + + "enableexcludelate=?,enableexcludeleaveearly=? " + + " where serialid = ? "; + + boolean isUpdated = rs.executeUpdate(mainSql, permitLateMinutes,seriousLateMinutes,lateAbsentMinutes,permitLeaveEarlyMinutes, + seriousLeaveEarlyMinutes,leaveEarlyAbsentMinutes,permitlateminutesenable,seriouslateminutesenable,lateabsentminutesenable, + permitleaveearlyminutesenable,seriousleaveearlyminutesenable,leaveearlyabsentminutesenable, + enableexcludelate,enableexcludeleaveearly,serialid); + + if(isUpdated){ + //对于个性化规则,直接删除重新创建 + String delRuleSql = "delete from kq_ShiftPersonalizedRuleDetail where personalizedruleid = ? "; + rst.executeUpdate(delRuleSql, personalizedRuleid); + + String ruleSql = "insert into kq_ShiftPersonalizedRuleDetail(personalizedruleid,enable,enablesame,advancetime,postponetime,ruledetailtype,record) values(?,?,?,?,?,?,?)"; + String[] rules = new String[]{"earlyinearlyout","lateinlateout","lateoutlatein"}; + for(int j = 0 ; j < rules.length ; j++){ + String ruledetailtype=rules[j]; + if(!"lateoutlatein".equalsIgnoreCase(ruledetailtype)){ + JSONObject ruledetail = (JSONObject)personalizedRuleDetails.get(ruledetailtype); + String enable=Util.null2String(jsonObj.get(ruledetailtype)); + String enablesame=Util.null2String(jsonObj.get(ruledetailtype+"same")); + String advanceTime=Util.null2String(ruledetail.get("advancetime")); + String postponeTime=Util.null2String(ruledetail.get("postponetime")); + if(enablesame.equals("1")){ + postponeTime = advanceTime; + } + String record=Util.null2s(Util.null2String(ruledetail.get("record")),"0"); + if("mysql".equals(dbType) && "".equals(enablesame)){ + enablesame = null; + } + rst.executeUpdate(ruleSql, personalizedRuleid,enable,enablesame,advanceTime,postponeTime,ruledetailtype,record); + }else{ + JSONArray ruledetails = (JSONArray)personalizedRuleDetails.get(ruledetailtype); + for(int k =0 ; k < ruledetails.size() ; k ++){ + JSONObject ruledetail = (JSONObject)ruledetails.get(k); + String enable=Util.null2String(jsonObj.get(ruledetailtype)); + String enablesame=Util.null2String(jsonObj.get(ruledetailtype+"same")); + String advanceTime=Util.null2String(ruledetail.get("advancetime")); + String postponeTime=Util.null2String(ruledetail.get("postponetime")); + if(enablesame.equals("1")){ + postponeTime = advanceTime; + } + String record=Util.null2s(Util.null2String(ruledetail.get("record")),"0"); + if("mysql".equals(dbType) && "".equals(enablesame)){ + enablesame = null; + } + rst.executeUpdate(ruleSql, personalizedRuleid,enable,enablesame,advanceTime,postponeTime,ruledetailtype,record); + } + } + } + retmap.put("status", "1"); + retmap.put("id", serialid); + retmap.put("message", SystemEnv.getHtmlLabelName(18758, user.getLanguage())); + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + } + + private void checkRule(JSONObject personalizedRuleDetails, + Map retmap, JSONObject jsonObj) { + Map checkRule = new HashMap<>(); + JSONArray lateoutlatein_ruledetail = (JSONArray)personalizedRuleDetails.get("lateoutlatein"); + for(int k =0 ; k < lateoutlatein_ruledetail.size() ; k ++){ + JSONObject ruledetail = (JSONObject)lateoutlatein_ruledetail.get(k); + String enable=Util.null2String(jsonObj.get("lateoutlatein")); + if("1".equalsIgnoreCase(enable)){ + String advancetime=Util.null2String(ruledetail.get("advancetime")); + if(checkRule.containsKey(advancetime)){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(514788,user.getLanguage())); + break; + }else{ + checkRule.put(advancetime, advancetime); + } + } + } + } + + /** + * 新增个性化信息 + * @param retmap + * @param jsonObj + */ + private void add(Map retmap,JSONObject jsonObj) throws Exception{ + RecordSetTrans rst = new RecordSetTrans(); + String dbType = rst.getDBType(); + rst.setAutoCommit(true); + RecordSet rs = new RecordSet(); + String serialid = Util.null2String(jsonObj.get("id"));//本信息id + String permitLateMinutes= Util.null2String(jsonObj.get("permitlateminutes"));//允许迟到分钟数 + String seriousLateMinutes = Util.null2String(jsonObj.get("seriouslateminutes"));//严重迟到分钟数 + String lateAbsentMinutes= Util.null2String(jsonObj.get("lateabsentminutes"));//迟到视作旷工分钟数 + String permitLeaveEarlyMinutes= Util.null2String(jsonObj.get("permitleaveearlyminutes"));//允许早退分钟数 + String seriousLeaveEarlyMinutes = Util.null2String(jsonObj.get("seriousleaveearlyminutes"));//严重早退分钟数 + String leaveEarlyAbsentMinutes= Util.null2String(jsonObj.get("leaveearlyabsentminutes"));//早退视作旷工分钟数 + String enableexcludelate = Util.null2String(jsonObj.get("enableexcludelate"));//是否排除迟到分钟数 + String enableexcludeleaveearly= Util.null2String(jsonObj.get("enableexcludeleaveearly"));//是否排除早退分钟数 + + String permitlateminutesenable = Util.null2String(jsonObj.get("permitlateminutesenable"));//允许迟到是否开启 + String seriouslateminutesenable= Util.null2String(jsonObj.get("seriouslateminutesenable"));///严重迟到是否开启 + String lateabsentminutesenable = Util.null2String(jsonObj.get("lateabsentminutesenable"));//迟到视作旷工是否开启 + String permitleaveearlyminutesenable = Util.null2String(jsonObj.get("permitleaveearlyminutesenable"));///允许早退是否开启 + String seriousleaveearlyminutesenable= Util.null2String(jsonObj.get("seriousleaveearlyminutesenable"));//严重早退是否开启 + String leaveearlyabsentminutesenable = Util.null2String(jsonObj.get("leaveearlyabsentminutesenable"));//早退视作旷工是否开启 + + String earlyinearlyout = Util.null2String(jsonObj.get("earlyinearlyout"));//允许早到早走是否开启 + String lateinlateout = Util.null2String(jsonObj.get("lateinlateout"));//允许晚到晚走是否开启 + String lateoutlatein = Util.null2String(jsonObj.get("lateoutlatein"));//允许晚走晚到是否开启 + + JSONObject personalizedRuleDetails = (JSONObject)jsonObj.get("personalizedRuleDetails"); + checkRule(personalizedRuleDetails,retmap,jsonObj); + + if(!retmap.isEmpty()){ + return ; + } + String uuid = UUID.randomUUID().toString();//uuid供查询使用 + + String mainSql = "insert into kq_ShiftPersonalizedRule(serialid,permitlateminutes,seriouslateminutes,lateabsentminutes, " + + "permitleaveearlyminutes,seriousleaveearlyminutes,leaveearlyabsentminutes,permitlatestatus, " + + "seriouslatestatus,lateabsentstatus,permitleaveearlystatus,seriousleaveearlystatus,leaveearlyabsentstatus,uuid,enableexcludelate,enableexcludeleaveearly) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + + boolean isUpdated = rst.executeUpdate(mainSql,serialid,permitLateMinutes,seriousLateMinutes,lateAbsentMinutes,permitLeaveEarlyMinutes, + seriousLeaveEarlyMinutes,leaveEarlyAbsentMinutes,permitlateminutesenable,seriouslateminutesenable,lateabsentminutesenable, + permitleaveearlyminutesenable,seriousleaveearlyminutesenable,leaveearlyabsentminutesenable,uuid,enableexcludelate,enableexcludeleaveearly); + + if(isUpdated){ + int personalizedRuleid = 0; + String idSql = "select id from kq_ShiftPersonalizedRule where uuid=? "; + rs = new RecordSet(); + rs.executeQuery(idSql,uuid); + if(rs.next()) personalizedRuleid = rs.getInt("id"); + + if(personalizedRuleid > 0){ + + String ruleSql = "insert into kq_ShiftPersonalizedRuleDetail(personalizedruleid,enable,enablesame,advancetime,postponetime,ruledetailtype,record) values(?,?,?,?,?,?,?)"; + String[] rules = new String[]{"earlyinearlyout","lateinlateout","lateoutlatein"}; + for(int j = 0 ; j < rules.length ; j++){ + String ruledetailtype=rules[j]; + if(!"lateoutlatein".equalsIgnoreCase(ruledetailtype)){ + JSONObject ruledetail = (JSONObject)personalizedRuleDetails.get(ruledetailtype); + String enable=Util.null2String(jsonObj.get(ruledetailtype)); + String enablesame=Util.null2String(jsonObj.get(ruledetailtype+"same")); + String advanceTime=Util.null2String(ruledetail.get("advancetime")); + String postponeTime=Util.null2String(ruledetail.get("postponetime")); + if(enablesame.equals("1")){ + postponeTime = advanceTime; + } + String record=Util.null2s(Util.null2String(ruledetail.get("record")),"0"); + if("mysql".equals(dbType) && "".equals(enablesame)){ + enablesame = null; + } + rst.executeUpdate(ruleSql, personalizedRuleid,enable,enablesame,advanceTime,postponeTime,ruledetailtype,record); + }else{ + JSONArray ruledetails = (JSONArray)personalizedRuleDetails.get(ruledetailtype); + for(int k =0 ; k < ruledetails.size() ; k ++){ + JSONObject ruledetail = (JSONObject)ruledetails.get(k); + String enable=Util.null2String(jsonObj.get(ruledetailtype)); + String enablesame=Util.null2String(jsonObj.get(ruledetailtype+"same")); + String advanceTime=Util.null2String(ruledetail.get("advancetime")); + String postponeTime=Util.null2String(ruledetail.get("postponetime")); + if(enablesame.equals("1")){ + postponeTime = advanceTime; + } + String record=Util.null2s(Util.null2String(ruledetail.get("record")),"0"); + if("mysql".equals(dbType) && "".equals(enablesame)){ + enablesame = null; + } + rst.executeUpdate(ruleSql, personalizedRuleid,enable,enablesame,advanceTime,postponeTime,ruledetailtype,record); + } + } + } + retmap.put("status", "1"); + retmap.put("id", serialid); + retmap.put("message", SystemEnv.getHtmlLabelName(18758, user.getLanguage())); + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + }else{ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + } +} diff --git a/src/com/engine/kq/cmd/shiftmanagement/toolkit/ShiftManagementToolKit.java b/src/com/engine/kq/cmd/shiftmanagement/toolkit/ShiftManagementToolKit.java new file mode 100644 index 0000000..3616feb --- /dev/null +++ b/src/com/engine/kq/cmd/shiftmanagement/toolkit/ShiftManagementToolKit.java @@ -0,0 +1,405 @@ +package com.engine.kq.cmd.shiftmanagement.toolkit; + +import com.engine.kq.biz.*; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; + +import java.util.*; + +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + + + +public class ShiftManagementToolKit { + private static KQLog kqLog = new KQLog(); + + /** + * 判断班次列表里是否显示checkbox + * @param id + * @return + */ + public String getCheckbox(String id){ + KQGroupBiz groupBiz = new KQGroupBiz(); + boolean serialIdUesed = groupBiz.serialIdIsUesed(id); + + if(serialIdUesed){ + return "false"; + }else{ + return "true"; + } + } + + /** + * 判断班次列表右侧操作按钮是否显示删除 + * @param id + * @return + */ + public ArrayList getShiftListOperate(String id){ + ArrayList resultList = new ArrayList(); + KQGroupBiz groupBiz = new KQGroupBiz(); + boolean serialIdUesed = groupBiz.serialIdIsUesed(id); + + resultList.add("true"); + resultList.add("true"); + + if(serialIdUesed){ + resultList.add("false"); + }else{ + resultList.add("true"); + } + + resultList.add("true"); + return resultList; + } + + /** + * 获取工作时段 + * @param id + * @return + */ + public String getShiftOnOffWorkSection(String id){ + if(id.length() == 0) { + return ""; + } + String workSections = ""; + KQShiftOnOffWorkSectionComInfo workSectionComInfo = new KQShiftOnOffWorkSectionComInfo(); + List workSectionList = workSectionComInfo.getWorkSectionTimes(id); + if(workSectionList != null){ + for(int i = 0; i < workSectionList.size() ;i++){ + List workTimes = (List) workSectionList.get(i); + if(workTimes != null && !workTimes.isEmpty() && (workTimes.size() % 2 ==0)){ + Map onWorkMap = (Map) workTimes.get(0); + Map offWorkMap = (Map) workTimes.get(1); + String ontime = onWorkMap.get("times"); + String offtime = offWorkMap.get("times"); + if(workSections.length() > 0){ + workSections += " "; + } + workSections += ontime+"-"+offtime; + } + } + } + + return Util.null2String(workSections); + } + + public String getShiftOnOffWorkSections(String id,String langid){ + return getShiftOnOffWorkSections(id,Util.getIntValue(langid,7)); + } + /** + * 获取工作时段+班次名称 + * @param id + * @return + */ + public String getShiftOnOffWorkSections(String id,int langid){ + String serials = ""; + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + String[] ids = id.split(","); + for(int i = 0 ; i < ids.length ; i++){ + String serialInfo = ""; + String serial = kqShiftManagementComInfo.getSerial(ids[i]); + if(serial.length() > 0){ + String workSection = getShiftOnOffWorkSection(ids[i]); + if(workSection.length()>0){ + serialInfo = serial+"("+workSection+")"; + } + }else{ + serialInfo = SystemEnv.getHtmlLabelName(26593, langid); + } + if(serials.length()>0){ + serials+=" "; + } + serials+=serialInfo; + } + return serials; + } + + + /** + * 获取工作时段+班次名称--yz + * --加入自由班制的班次判断 + * @param id + * @return + */ + public String getShiftOnOffWorkSections(String id, int langid, String date, String resourceid) { + return getShiftOnOffWorkSections(id, langid, date, resourceid, false); + } + + public String getShiftOnOffWorkSections(String id,int langid,String date,String resourceid,boolean isMobile){ + String serials = ""; + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + String[] ids = id.split(","); + for(int i = 0 ; i < ids.length ; i++){ + String serialInfo = ""; + String serial = kqShiftManagementComInfo.getSerial(ids[i]); + if(serial.length() > 0){ + String workSection = getShiftOnOffWorkSection(ids[i]); + if(workSection.length()>0){ + serialInfo = serial+"("+workSection+")"; + } + }else{ + try{ + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceid, date); + kqLog.info("fc--考勤排班信息--date=" + date + ",resourceid=" + resourceid + ",WorkTimeEntity=" + workTime.toString()); + if("3".equals(workTime.getKQType())){ + if("0".equals(Util.null2String(workTime.getWorkMins()))){ + serialInfo = SystemEnv.getHtmlLabelName(26593, langid); + }else{ + serialInfo = SystemEnv.getHtmlLabelName(389129, langid); + } + }else{ + if (Objects.nonNull(workTime.getSerialId()) && isMobile) { + serial = kqShiftManagementComInfo.getSerial(workTime.getSerialId()); + kqLog.info("fc--考勤排班信息--date=" + date + ",resourceid=" + resourceid + ",SerialId=" + workTime.getSerialId() + ",serial=" + serial); + if (serial.length() > 0) { + String workSection = getShiftOnOffWorkSection(workTime.getSerialId()); + if (workSection.length() > 0) { + serialInfo = serial + "(" + workSection + ")"; + } + } + } else { + serialInfo = SystemEnv.getHtmlLabelName(26593, langid); + } + } + }catch (Exception e){ + e.printStackTrace(); + } + } + if(serials.length()>0){ + serials+=" "; + } + serials+=serialInfo; + } + return serials; + } + + /** + * 获取班次里个性化设置配置信息 + * @param serialid + * @param isFormat 为true表示自己查询数据库 + * @return + * key:ruleDetail + * val:返回的是个性化设置里的其他规则,是个map结果集 + * map里存着三种类型:允许早到早走 earlyinearlyout 允许晚到晚走 lateinlateout 允许晚走晚到 lateoutlatein + * map.get("earlyinearlyout") 返回的是个list,list里放的是 + * sectionMap.put("enable", enable); + * sectionMap.put("advancetime", advancetime); + * sectionMap.put("postponetime", postponetime); + * sectionMap.put("record", record); + * sectionMap.put("isoffdutyfreecheck", 0); + */ + public static Map getShiftRuleInfo(String serialid,boolean isFormat){ + Map shiftRuleMap = new HashMap<>(); + if("".equalsIgnoreCase(serialid)){ + //kqLog.info("getShiftRuleInfo:serialid is null "); + return shiftRuleMap; + } + if(isFormat){ + String shiftonoffworkcount = ""; + RecordSet rs = new RecordSet(); + String sql = "select * from kq_ShiftManagement where 1=1 and id="+serialid+" order by id "; + rs.executeQuery(sql); + if(rs.next()){ + //是否开启下班不用打卡 1表示下班不用打卡 + String isoffdutyfreecheck = rs.getString("isoffdutyfreecheck"); + shiftonoffworkcount = Util.null2String(rs.getString("shiftonoffworkcount")); + if("1".equalsIgnoreCase(isoffdutyfreecheck)){ + shiftRuleMap.put("isoffdutyfreecheck", "1"); + }else{ + shiftRuleMap.put("isoffdutyfreecheck", "0"); + } + } + +// 允许迟到是否开启 + sql = "select * from kq_ShiftPersonalizedRule where 1=1 and serialid="+serialid+" order by id "; + rs.executeQuery(sql); + if(rs.next()){ + String permitlatestatus = Util.null2String(rs.getString("permitlatestatus")); + String permitlateminutes = Util.null2String(rs.getString("permitlateminutes")); + String permitleaveearlystatus = Util.null2String(rs.getString("permitleaveearlystatus")); + String permitleaveearlyminutes = Util.null2String(rs.getString("permitleaveearlyminutes")); + String seriouslatestatus = Util.null2String(rs.getString("seriouslatestatus")); + String seriouslateminutes = Util.null2String(rs.getString("seriouslateminutes")); + String seriousleaveearlystatus = Util.null2String(rs.getString("seriousleaveearlystatus")); + String seriousleaveearlyminutes = Util.null2String(rs.getString("seriousleaveearlyminutes")); + String lateabsentstatus = Util.null2String(rs.getString("lateabsentstatus")); + String lateabsentminutes = Util.null2String(rs.getString("lateabsentminutes")); + String leaveearlyabsentstatus = Util.null2String(rs.getString("leaveearlyabsentstatus")); + String leaveearlyabsentminutes = Util.null2String(rs.getString("leaveearlyabsentminutes")); + String personalizedruleid = Util.null2String(rs.getString("id")); + String enableexcludelate = Util.null2String(rs.getString("enableexcludelate")); + String enableexcludeleaveearly = Util.null2String(rs.getString("enableexcludeleaveearly")); + + if("1".equalsIgnoreCase(permitlatestatus)){ + shiftRuleMap.put("permitlateminutes", permitlateminutes); + shiftRuleMap.put("permitlatestatus", "1"); + }else{ + shiftRuleMap.put("permitlatestatus", "0"); + } + +// 允许早退是否开启 + if("1".equalsIgnoreCase(permitleaveearlystatus)){ + shiftRuleMap.put("permitleaveearlyminutes", permitleaveearlyminutes); + shiftRuleMap.put("permitleaveearlystatus", "1"); + }else{ + shiftRuleMap.put("permitleaveearlystatus", "0"); + } +// 严重迟到是否开启 + if("1".equalsIgnoreCase(seriouslatestatus)){ + shiftRuleMap.put("seriouslateminutes", seriouslateminutes); + shiftRuleMap.put("seriouslatestatus", "1"); + }else{ + shiftRuleMap.put("seriouslatestatus", "0"); + } + +// 严重早退是否开启 + if("1".equalsIgnoreCase(seriousleaveearlystatus)){ + shiftRuleMap.put("seriousleaveearlyminutes", seriousleaveearlyminutes); + shiftRuleMap.put("seriousleaveearlystatus", "1"); + }else{ + shiftRuleMap.put("seriousleaveearlystatus", "0"); + } + +// 迟到视作旷工是否开启 + if("1".equalsIgnoreCase(lateabsentstatus)){ + shiftRuleMap.put("lateabsentminutes", lateabsentminutes); + shiftRuleMap.put("lateabsentstatus", "1"); + }else{ + shiftRuleMap.put("lateabsentstatus", "0"); + } +// 早退视作旷工是否开启 + if("1".equalsIgnoreCase(leaveearlyabsentstatus)){ + shiftRuleMap.put("leaveearlyabsentminutes", leaveearlyabsentminutes); + shiftRuleMap.put("leaveearlyabsentstatus", "1"); + }else{ + shiftRuleMap.put("leaveearlyabsentstatus", "0"); + } + if (personalizedruleid.length() >0){ + if("1".equalsIgnoreCase(shiftonoffworkcount)){ + KQShiftPersonalizedRuleDetailComInfo ruleDetailComInfo = new KQShiftPersonalizedRuleDetailComInfo(); + //只有一次签到签退才有个性化的这些设置 + Map ruleDetailMap = ruleDetailComInfo.getPersonalizedRuleDetail_sql(personalizedruleid); + if(ruleDetailMap != null && !ruleDetailMap.isEmpty()){ + shiftRuleMap.put("ruleDetail", ruleDetailMap); + } + } + } + + +// 是否排除迟到分钟数 + if("1".equalsIgnoreCase(enableexcludelate)){ + shiftRuleMap.put("enableexcludelate", "1"); + }else{ + shiftRuleMap.put("enableexcludelate", "0"); + } + +// 是否排除早退分钟数 + if("1".equalsIgnoreCase(enableexcludeleaveearly)){ + shiftRuleMap.put("enableexcludeleaveearly", "1"); + }else{ + shiftRuleMap.put("enableexcludeleaveearly", "0"); + } + + } + }else{ + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + KQShiftPersonalizedRuleCominfo ruleCominfo = new KQShiftPersonalizedRuleCominfo(); + KQShiftPersonalizedRuleDetailComInfo ruleDetailComInfo = new KQShiftPersonalizedRuleDetailComInfo(); + //是否开启下班不用打卡 1表示下班不用打卡 + String isoffdutyfreecheck = Util.null2String(kqShiftManagementComInfo.getIsoffdutyfreecheck(serialid)); + if("1".equalsIgnoreCase(isoffdutyfreecheck)){ + shiftRuleMap.put("isoffdutyfreecheck", "1"); + }else{ + shiftRuleMap.put("isoffdutyfreecheck", "0"); + } + +// 允许迟到是否开启 + String permitlatestatus = Util.null2String(ruleCominfo.getPermitlatestatus(serialid)); + if("1".equalsIgnoreCase(permitlatestatus)){ + String permitlateminutes = ruleCominfo.getPermitlateminutes(serialid); + shiftRuleMap.put("permitlateminutes", permitlateminutes); + shiftRuleMap.put("permitlatestatus", "1"); + }else{ + shiftRuleMap.put("permitlatestatus", "0"); + } +// 允许早退是否开启 + String permitleaveearlystatus = Util.null2String(ruleCominfo.getPermitleaveearlystatus(serialid)); + if("1".equalsIgnoreCase(permitleaveearlystatus)){ + String permitleaveearlyminutes = ruleCominfo.getPermitleaveearlyminutes(serialid); + shiftRuleMap.put("permitleaveearlyminutes", permitleaveearlyminutes); + shiftRuleMap.put("permitleaveearlystatus", "1"); + }else{ + shiftRuleMap.put("permitleaveearlystatus", "0"); + } +// 严重迟到是否开启 + String seriouslatestatus = Util.null2String(ruleCominfo.getSeriouslatestatus(serialid)); + if("1".equalsIgnoreCase(seriouslatestatus)){ + String seriouslateminutes = ruleCominfo.getSeriouslateminutes(serialid); + shiftRuleMap.put("seriouslateminutes", seriouslateminutes); + shiftRuleMap.put("seriouslatestatus", "1"); + }else{ + shiftRuleMap.put("seriouslatestatus", "0"); + } +// 严重早退是否开启 + String seriousleaveearlystatus = Util.null2String(ruleCominfo.getSeriousleaveearlystatus(serialid)); + if("1".equalsIgnoreCase(seriousleaveearlystatus)){ + String seriousleaveearlyminutes = ruleCominfo.getSeriousleaveearlyminutes(serialid); + shiftRuleMap.put("seriousleaveearlyminutes", seriousleaveearlyminutes); + shiftRuleMap.put("seriousleaveearlystatus", "1"); + }else{ + shiftRuleMap.put("seriousleaveearlystatus", "0"); + } +// 迟到视作旷工是否开启 + String lateabsentstatus = Util.null2String(ruleCominfo.getLateabsentstatus(serialid)); + if("1".equalsIgnoreCase(lateabsentstatus)){ + String lateabsentminutes = ruleCominfo.getLateabsentminutes(serialid); + shiftRuleMap.put("lateabsentminutes", lateabsentminutes); + shiftRuleMap.put("lateabsentstatus", "1"); + }else{ + shiftRuleMap.put("lateabsentstatus", "0"); + } +// 早退视作旷工是否开启 + String leaveearlyabsentstatus = Util.null2String(ruleCominfo.getLeaveearlyabsentstatus(serialid)); + if("1".equalsIgnoreCase(leaveearlyabsentstatus)){ + String leaveearlyabsentminutes = ruleCominfo.getLeaveearlyabsentminutes(serialid); + shiftRuleMap.put("leaveearlyabsentminutes", leaveearlyabsentminutes); + shiftRuleMap.put("leaveearlyabsentstatus", "1"); + }else{ + shiftRuleMap.put("leaveearlyabsentstatus", "0"); + } + String personalizedruleid = ruleCominfo.getID(serialid); + if (personalizedruleid.length() >0){ + String shiftonoffworkcount = Util.null2String(kqShiftManagementComInfo.getShiftonoffworkcounts(serialid)); + if("1".equalsIgnoreCase(shiftonoffworkcount)){ + //只有一次签到签退才有个性化的这些设置 + Map ruleDetailMap = ruleDetailComInfo.getPersonalizedRuleDetail(personalizedruleid); + if(ruleDetailMap != null && !ruleDetailMap.isEmpty()){ + shiftRuleMap.put("ruleDetail", ruleDetailMap); + } + } + } + +// 是否排除迟到分钟数 + String enableexcludelate = Util.null2String(ruleCominfo.getEnableexcludelate(serialid)); + if("1".equalsIgnoreCase(enableexcludelate)){ + shiftRuleMap.put("enableexcludelate", "1"); + }else{ + shiftRuleMap.put("enableexcludelate", "0"); + } + +// 是否排除早退分钟数 + String enableexcludeleaveearly = Util.null2String(ruleCominfo.getEnableexcludeleaveearly(serialid)); + if("1".equalsIgnoreCase(enableexcludeleaveearly)){ + shiftRuleMap.put("enableexcludeleaveearly", "1"); + }else{ + shiftRuleMap.put("enableexcludeleaveearly", "0"); + } + } + + return shiftRuleMap; + } + +} diff --git a/src/com/engine/kq/cmd/shiftschedule/DelShiftScheduleCmd.java b/src/com/engine/kq/cmd/shiftschedule/DelShiftScheduleCmd.java new file mode 100644 index 0000000..83b45d8 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/DelShiftScheduleCmd.java @@ -0,0 +1,177 @@ +package com.engine.kq.cmd.shiftschedule; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.KqShiftscheduleOperateLog; +import com.engine.kq.biz.KQFormatBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQShiftManagementComInfo; +import com.engine.kq.biz.KQShiftScheduleComInfo; +import weaver.common.DateUtil; +import weaver.conn.BatchRecordSet; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.Reminder.KQAutoCardTask; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class DelShiftScheduleCmd extends AbstractCommonCommand> { + private SimpleBizLogger logger; + // 添加日志功能 + private List> operateLogParams = new ArrayList<>(); + // 操作类型 操作人 考勤组名称+id 被修改人 被修改班次日期 被修改班次+id 排班设置行id + private List operateLogParam = null; + public DelShiftScheduleCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + BatchRecordSet bRs = new BatchRecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + List> lsFormatParams = new ArrayList<>(); + List formatParams = null; + KqShiftscheduleOperateLog bean = null; + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + ResourceComInfo rci = new ResourceComInfo(); + KQShiftManagementComInfo kqShiftScheduleComInfo = new KQShiftManagementComInfo(); + String id = Util.null2String(params.get("id"));//考勤组id + String resourceids = Util.null2String(params.get("resourceids"));//人员id + String groupId = Util.null2String(params.get("groupId"));//考勤组ID + String month = Util.null2String(params.get("month"));//考勤组月份 + if(id.length()>0){ + sql = "select * from kq_shiftschedule where id = ? "; + rs.executeQuery(sql,id); + String resourceid = ""; + String shiftScheduleDate = ""; + String oldSerialid = ""; + if(rs.next()){ + formatParams = new ArrayList<>(); + resourceid = Util.null2String(rs.getString("resourceid")); + shiftScheduleDate = Util.null2String(rs.getString("kqdate")); + formatParams.add(resourceid); + formatParams.add(shiftScheduleDate); + oldSerialid = Util.null2String(rs.getString("serialid")); + lsFormatParams.add(formatParams); + } + sql = "update kq_shiftschedule set isdelete = 1 where id= ? "; + rs.executeUpdate(sql,id); + if(!"".equals(resourceid) && !"".equals(shiftScheduleDate) && !"".equals(oldSerialid)) { + bean = new KqShiftscheduleOperateLog(2,user.getLastname(),kqGroupComInfo.getGroupname(groupId)+"(id:"+groupId+")",rci.getLastname(resourceid), + shiftScheduleDate, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(oldSerialid)+"(id:"+oldSerialid+")"), id, "", user.getLanguage()); + addLog(bean); + } + }else{ + String beginDate = DateUtil.getFirstDayOfMonth(month+"-01"); + String endDate = DateUtil.getLastDayOfMonth(month+"-01"); + List lsDate = new ArrayList<>(); + String today = DateUtil.getCurrentDate(); + Calendar cal = DateUtil.getCalendar(); + boolean isEnd = false; + for(String date=beginDate; !isEnd;) { + if(date.equals(endDate)) isEnd = true; + lsDate.add(date); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + + List lsResource = Util.splitString2List(resourceids,","); + for(int i=0;i= 0) { + formatParams = new ArrayList<>(); + formatParams.add(resourceid); + formatParams.add(date); + lsFormatParams.add(formatParams); + } + } + } + List sqlParams = new ArrayList(); + Object[] objects= DBUtil.transListIn(resourceids,sqlParams); + sql = "select * from kq_shiftschedule where resourceid in("+objects[0]+") and groupid=? and kqdate>=? and kqdate<=? and (isdelete is null or isdelete <> '1')"; + rs.executeQuery(sql, sqlParams,groupId, beginDate,endDate); + while (rs.next()) { + String oldId = Util.null2String(rs.getString("id")); + String resourceid = Util.null2String(rs.getString("resourceid")); + String shiftScheduleDate = Util.null2String(rs.getString("kqdate")); + String oldSerialid = Util.null2String(rs.getString("serialid")); + if(!"".equals(oldSerialid)) { + bean = new KqShiftscheduleOperateLog(2,user.getLastname(),kqGroupComInfo.getGroupname(groupId)+"(id:"+groupId+")",rci.getLastname(resourceid), + shiftScheduleDate, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(oldSerialid)+"(id:"+oldSerialid+")"), oldId, "", user.getLanguage()); + addLog(bean); + } + } + + sql = "update kq_shiftschedule set isdelete = 1 where resourceid in("+objects[0]+") and groupid=? and kqdate>=? and kqdate<=? and (isdelete is null or isdelete <> '1')"; + rs.executeUpdate(sql,sqlParams,groupId, beginDate,endDate); + } + + sql = "insert into kq_shiftscheduleoperate_log(operatetype,operator,kqgroupname,changeduser,changedshiftdate,changedshiftname,kqshiftid) values(?,?,?,?,?,?,?)"; + bRs.executeBatchSqlNew(sql, operateLogParams); + + new KQShiftScheduleComInfo().removeCache(); + //刷新报表数据 + new KQFormatBiz().format(lsFormatParams,16); + + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + String auto_checkout = kQGroupComInfo.getAuto_checkout(groupId); + String auto_checkin = kQGroupComInfo.getAuto_checkin(groupId); + if("1".equalsIgnoreCase(auto_checkin) || "1".equalsIgnoreCase(auto_checkout)){ + //如果开启了自动打卡,保存考勤组成员之后需要格式化下缓存 + KQAutoCardTask kqAutoCardTask = new KQAutoCardTask(); + kqAutoCardTask.initAutoCardTask(groupId); + } + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(20461, user.getLanguage())); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private void addLog(KqShiftscheduleOperateLog bean) { + operateLogParam = new ArrayList<>(); + operateLogParam.add(bean.getOperatetype()); + operateLogParam.add(bean.getOperator()); + operateLogParam.add(bean.getKqgroupname()); + operateLogParam.add(bean.getChangeduser()); + operateLogParam.add(bean.getChangedshiftdate()); + operateLogParam.add(bean.getChangedshiftname()); + operateLogParam.add(bean.getKqshiftid()); + operateLogParams.add(operateLogParam); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + +} diff --git a/src/com/engine/kq/cmd/shiftschedule/ExportExcelCmd.java b/src/com/engine/kq/cmd/shiftschedule/ExportExcelCmd.java new file mode 100644 index 0000000..78b0b7d --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/ExportExcelCmd.java @@ -0,0 +1,342 @@ +package com.engine.kq.cmd.shiftschedule; + +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.KQGroupComInfo; +import com.engine.kq.biz.KQShiftManagementComInfo; +import com.engine.kq.biz.KqMembersValidateBiz; +import com.engine.kq.biz.KqShiftScheduleRoleBiz; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.ExcelUtil; +import org.apache.commons.lang.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.*; + +public class ExportExcelCmd extends AbstractCommonCommand> { + + private HttpServletRequest request; + private HttpServletResponse response; + + public ExportExcelCmd(Map params, HttpServletRequest request, HttpServletResponse response, User user) { + this.user = user; + this.params = params; + this.request = request; + this.response = response; + } + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String status = Util.null2String(jsonObj.get("status")); + String groupId = Util.null2String(jsonObj.get("groupId"));//考勤组id + List managerRoleUserIdList = new KqShiftScheduleRoleBiz().getUfKqShiftScheduleRoleValue(""+user.getUID(), groupId); + KqMembersValidateBiz kqMembersValidateBiz = new KqMembersValidateBiz(jsonObjectToMap(jsonObj), user); + List> membersValidateResult = kqMembersValidateBiz.getKqMembersValidate(); + String kqMonth = Util.null2String(jsonObj.get("kqMonth"));//年月 + String viewscope = Util.null2String(jsonObj.get("viewscope")); + String startDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01"); + String endDate = DateUtil.getLastDayOfMonth(kqMonth+"-01"); + + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + LinkedHashMap workbook = new LinkedHashMap<>(); + List lsSheet = new ArrayList<>(); + Map sheet = null; + List titleList = null; + Map title = null; + List> dataList = null; + List data = null; + List> constraintList = null; + Map constraint = null; + + sheet = new HashMap<>(); + sheet.put("sheetName", SystemEnv.getHtmlLabelName(389516, user.getLanguage())); + sheet.put("sheetTitle", Util.formatMultiLang(kqGroupComInfo.getGroupname(groupId), user.getLanguage() + "")+SystemEnv.getHtmlLabelName(389516, user.getLanguage())); + boolean isEnd = false; + Calendar cal = DateUtil.getCalendar(); + + //部门 工号 姓名 + titleList = new ArrayList<>(); + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelName(124, user.getLanguage())); + title.put("width",30*256); + titleList.add(title); + + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelName(714, user.getLanguage())); + title.put("width",15*256); + titleList.add(title); + + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelName(413, user.getLanguage())); + title.put("width",15*256); + titleList.add(title); + + int firstRow = 6; + int endRow = 0; + int firstCol = 3; + int endCol = 0; + + for(String date=startDate; !isEnd;) { + if (date.equals(endDate)) isEnd = true; + title = new HashMap<>(); + int week = DateUtil.getWeek(date); + title.put("title",date+String.valueOf((char)10)+getWeekStr(week)); + title.put("width",16*256); + titleList.add(title); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + endCol = titleList.size()+firstCol; + sheet.put("titleList", titleList); + + Map mapShiftSchedule = new HashMap<>(); + String tmpSerialids = ""; + sql = " select serialid, resourceid, kqdate from kq_shiftschedule where (isdelete is null or isdelete <> '1') and groupid=? "; + rs.executeQuery(sql,groupId); + while(rs.next()){ + mapShiftSchedule.put(rs.getString("kqdate")+"|"+rs.getString("resourceid"),rs.getString("serialid")); + if((","+tmpSerialids+",").indexOf(","+rs.getString("serialid")+",")==-1 && rs.getInt("serialid")>0) { + if (tmpSerialids.length() > 0) tmpSerialids += ","; + tmpSerialids += rs.getString("serialid"); + } + } + List sheetMemo = new ArrayList<>(); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + sheetMemo.add(SystemEnv.getHtmlLabelName(390620, user.getLanguage())); + List tmpserialids = Util.splitString2List( Util.null2String(kqGroupComInfo.getSerialids(groupId)),","); + tmpSerialids = "" ; + if(tmpSerialids != null){ + for(String ts : tmpserialids){ + if(tmpSerialids.length() > 0) tmpSerialids += "," ; + tmpSerialids += ts ; + } + } + sheetMemo.add( Util.formatMultiLang(shiftManagementToolKit.getShiftOnOffWorkSections(tmpSerialids,user.getLanguage()), user.getLanguage()+"")+" "+SystemEnv.getHtmlLabelName(390605, user.getLanguage())); + sheet.put("sheetMemo",sheetMemo); + + + String sqlWhere = " "; + if(viewscope.length()>0){ + if(viewscope.equals("1")){//分部 + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + sqlWhere += " and t.subcompanyid1 in ("+subCompanyId+") "; + }else if(viewscope.equals("2")){//部门 + String departmentId = Util.null2String(jsonObj.get("departmentId")); + sqlWhere += " and t.departmentid in ("+departmentId+") "; + }else if(viewscope.equals("3")){//人员 + String resourceId = Util.null2String(jsonObj.get("resourceId")); + sqlWhere += " and t.resourceid in ("+resourceId+") "; + } + } + + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));// 是否显示无账号人员 + if (!"1".equals(isNoAccount)) { + sqlWhere += " and t.status in(0,1,2,3) and t.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and t.loginid<>'' "); + } + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and t.status = "+status+ ""; + }else if (status.equals("8")) { + sqlWhere += " and (t.status = 0 or t.status = 1 or t.status = 2 or t.status = 3) "; + } + } + + if(!Util.null2String(kqGroupComInfo.getExcludecount(groupId)).equals("1")) { + //剔除无需排班人员 + String excludeid = Util.null2String(kqGroupComInfo.getExcludeid(groupId)); + if (excludeid.length() > 0) { + sqlWhere += " and t.resourceid not in (" + excludeid + ")"; + } + } + + dataList = new ArrayList<>(); + List resList = new ArrayList<>(); + + if(!managerRoleUserIdList.isEmpty()) { + String allUserIds = StringUtils.join(managerRoleUserIdList, ','); + sqlWhere += " and "+Util.getSubINClause(allUserIds, "t.resourceid", "in"); + } + + sql = " select b.id, b.kqdate, b.serialid, t.resourceid, t.subcompanyid1, t.departmentid, t.loginid from (\n" + + " SELECT distinct t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid FROM ( \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE (a.id=b.typevalue and b.type =1) and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE (a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2) and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE (a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3) and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE (a.jobtitle = b.typevalue AND b.type=5 and (b.isdelete is null or b.isdelete <> '1') AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue)))) \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1'))t) t left join kq_shiftschedule b on t.resourceid=b.resourceid " + + " and t.groupid=b.groupid and (b.isdelete is null or b.isdelete <> '1') and b.kqdate>=? and b.kqdate<=? where t.groupid=? \n " + + sqlWhere + + " order by t.dsporder,t.lastname"; + new KQLog().info("ExportExcelCmd:"+sql); + rs.executeQuery(sql,startDate,startDate,groupId); + while(rs.next()){ + data = new ArrayList<>(); + String resourceid = rs.getString("resourceid"); + if(resList.contains(resourceid)){ + continue; + } + + String validatefrom = "2000-01-01"; + String validateto = "2999-12-31"; + List> validateList = new ArrayList<>(); + for(Map membersValidate : membersValidateResult) { + String memberId = membersValidate.get("resourceId"); + if(resourceid.equals(memberId)) { + validatefrom = membersValidate.get("validatefrom"); + validateto = membersValidate.get("validateto"); + Map validateMap = new HashMap<>(); + validateMap.put("validatefrom",validatefrom); + validateMap.put("validateto",validateto); + validateList.add(validateMap); + } + } + boolean isInRangeFianl = false; + for(Map validateDate : validateList) { + String from = validateDate.get("validatefrom"); + String to = validateDate.get("validateto"); + boolean isInRange = kqMembersValidateBiz.isInRange(startDate, endDate, from, to); + if(isInRange) { + isInRangeFianl = true; + break; + } + } + if(!isInRangeFianl) { + continue; + } + + resList.add(resourceid); + data.add(Util.formatMultiLang(departmentComInfo.getDepartmentName(resourceComInfo.getDepartmentID(resourceid)),""+user.getLanguage())); + data.add(Util.formatMultiLang(resourceComInfo.getWorkcode(resourceid),""+user.getLanguage())); + data.add(Util.formatMultiLang(resourceComInfo.getLastname(resourceid),""+user.getLanguage())); + isEnd = false; + for(String date=startDate; !isEnd;) { + if (date.equals(endDate)) isEnd = true; + String serialId = Util.null2String(mapShiftSchedule.get(date+"|"+resourceid)); + String serialName = ""; + if(serialId.equals("-1")){ + serialName = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + }else{ + serialName = Util.formatMultiLang(kqShiftManagementComInfo.getSerial(serialId),""+user.getLanguage()); + } + data.add(serialName); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + dataList.add(data); + } + endRow = dataList.size()+firstRow; + sheet.put("dataList", dataList); + + //增加数据有效性校验 + constraintList = new ArrayList<>(); + constraint = new HashMap<>(); + constraint.put("firstRow",firstRow); + constraint.put("endRow",endRow); + constraint.put("firstCol",firstCol); + constraint.put("endCol",endCol); + List serialids = Util.splitString2List( Util.null2String(kqGroupComInfo.getSerialids(groupId)),","); + serialids.add("-1"); + String[] serialnames = new String[serialids.size()]; + for(int i=0;i exportMap = ExcelUtil.export(workbook,request,response,false,true); + retmap.putAll(exportMap); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private String getWeekStr(int week) { + String label2 = SystemEnv.getHtmlLabelName(392, user.getLanguage()); // 星期一 + String label3 = SystemEnv.getHtmlLabelName(393, user.getLanguage()); // 星期二 + String label4 = SystemEnv.getHtmlLabelName(394, user.getLanguage()); // 星期三 + String label5 = SystemEnv.getHtmlLabelName(395, user.getLanguage()); // 星期四 + String label6 = SystemEnv.getHtmlLabelName(396, user.getLanguage()); // 星期五 + String label7 = SystemEnv.getHtmlLabelName(397, user.getLanguage()); // 星期六 + String label8 = SystemEnv.getHtmlLabelName(398, user.getLanguage()); // 星期日 + switch (week) { + case 1: + return label2; + case 2: + return label3; + case 3: + return label4; + case 4: + return label5; + case 5: + return label6; + case 6: + return label7; + case 7: + return label8; + } + return label2; + } + + public Map jsonObjectToMap(JSONObject jsonObject) { + Map map = new HashMap<>(); + for (String key : jsonObject.keySet()) { + map.put(key, jsonObject.get(key)); + } + return map; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/shiftschedule/GetBatchShiftScheduleFromCmd.java b/src/com/engine/kq/cmd/shiftschedule/GetBatchShiftScheduleFromCmd.java new file mode 100644 index 0000000..f6a53a5 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/GetBatchShiftScheduleFromCmd.java @@ -0,0 +1,278 @@ +package com.engine.kq.cmd.shiftschedule; + +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.api.hrm.bean.HrmFieldBean; +import com.api.hrm.bean.SelectOption; +import com.api.hrm.bean.WeaRadioGroup; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQHolidaySetBiz; +import com.engine.kq.biz.KQShiftManagementComInfo; +import com.engine.kq.util.PageUidFactory; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.filter.XssUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class GetBatchShiftScheduleFromCmd extends AbstractCommonCommand> { + + public GetBatchShiftScheduleFromCmd(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 = ""; + List lsField = new ArrayList(); + HrmFieldBean hrmFieldBean = null; + List options = null; + Map mapItem = new HashMap<>(); + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); + String groupId = Util.null2String(params.get("groupId"));//考勤组id + + //排班类型、排班日期、排班人员、班次 + //排班类型、排班开始日期、排班人员、遇节假日、排班周期 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("shiftScheduleType"); + hrmFieldBean.setFieldlabel("389494"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue("1"); + options = new ArrayList(); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(389506, user.getLanguage()),true)); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(389507, user.getLanguage()))); + hrmFieldBean.setSelectOption(options); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("shiftScheduleDate"); + hrmFieldBean.setFieldlabel("16694"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("shiftScheduleBeginDate"); + hrmFieldBean.setFieldlabel("16694"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setIsFormField(true); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("shiftScheduleEndDate"); + hrmFieldBean.setFieldlabel("16694"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setIsFormField(true); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("shiftScheduleMember"); + hrmFieldBean.setFieldlabel("125839"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("17"); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("holidayType"); + hrmFieldBean.setFieldlabel("500436"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + options = new ArrayList(); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(125899, user.getLanguage()),true)); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(125837, user.getLanguage()))); + hrmFieldBean.setSelectOption(options); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("meetHolidays"); + hrmFieldBean.setFieldlabel("529182"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + options = new ArrayList(); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(125899, user.getLanguage()),true)); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(125837, user.getLanguage()))); + hrmFieldBean.setSelectOption(options); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("meetRestDays"); + hrmFieldBean.setFieldlabel("528922"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + options = new ArrayList(); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(125899, user.getLanguage()),true)); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(125837, user.getLanguage()))); + hrmFieldBean.setSelectOption(options); + lsField.add(hrmFieldBean); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("serialId"); + hrmFieldBean.setFieldlabel("24803"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + options = new ArrayList(); + String[] serialids = Util.splitString(Util.null2String(kQGroupComInfo.getSerialids(groupId)),","); + for(int i=0;serialids!=null&&i(); + sql = "select id,shiftcyclename,shiftcycleserialids from kq_group_shiftcycle where groupid = ? order by id asc "; + rs.executeQuery(sql,groupId); + while(rs.next()){ + options.add(new SearchConditionOption(Util.null2String(rs.getString("id")),Util.null2String(rs.getString("shiftcyclename")),true)); + hrmFieldBean.setSelectOption(options); + } + lsField.add(hrmFieldBean); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + for (int i = 0; i < lsField.size(); i++) { + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(lsField.get(i), user); + if(lsField.get(i).getFieldname().equals("shiftScheduleMember")){ + XssUtil xssUtil = new XssUtil(); + Map tmpParams = new HashMap<>(); + tmpParams.put("groupId",groupId); + tmpParams.put("isNoAccount",1); + String groupMemberSql = new KQGroupBiz().getGroupMemberSql(tmpParams); + String inSqlWhere = " hr.id in (select resourceid from (" + groupMemberSql + ") t1)"; + String inSqlWhere1 = " t1.id in (select resourceid from (" + groupMemberSql + ") t1)"; + if(!Util.null2String(kQGroupComInfo.getExcludecount(groupId)).equals("1")) { + //剔除无需排班人员 + String excludeid = Util.null2String(kQGroupComInfo.getExcludeid(groupId)); + if (excludeid.length() > 0) { + inSqlWhere += " and hr.id not in (" + excludeid + ")"; + inSqlWhere1 += " and t1.id not in (" + excludeid + ")"; + } + } + searchConditionItem.getBrowserConditionParam().getDataParams().put("sqlwhere", xssUtil.put(inSqlWhere)); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("sqlwhere", xssUtil.put(inSqlWhere1)); + } + mapItem.put(lsField.get(i).getFieldname(),searchConditionItem); + } + + //下拉 + List condition = new ArrayList(); + condition.add(mapItem.get("shiftScheduleType")); + + //按天排班 + Map conditionMap = new HashMap(); + List conditionlist = null; + List conditionlist2 = null; + + conditionlist = new ArrayList(); + conditionlist2 = new ArrayList(); + conditionlist2.add(mapItem.get("shiftScheduleDate")); + conditionlist.add(conditionlist2); + + conditionlist2 = new ArrayList(); + WeaRadioGroup wrg = new WeaRadioGroup(); + wrg.setLabel(SystemEnv.getHtmlLabelName(125839, user.getLanguage())); + List option = new ArrayList<>(); + Map selectLinkageDatas = new HashMap(); + selectLinkageDatas.put("2" ,mapItem.get("shiftScheduleMember")); + wrg.setSelectLinkageDatas(selectLinkageDatas); + option.add(new SelectOption("1",SystemEnv.getHtmlLabelName(389496, user.getLanguage()),true)); + option.add(new SelectOption("2",SystemEnv.getHtmlLabelName(33210, user.getLanguage()))); + + List domkey = new ArrayList(); + wrg.setOptions(option); + wrg.setConditionType("SELECT_LINKAGE"); + wrg.setFieldcol(18); + wrg.setLabelcol(6); + domkey.add("shiftScheduleMemberType"); + wrg.setDomkey(domkey); + conditionlist2.add(wrg); + conditionlist.add(conditionlist2); + + conditionlist2 = new ArrayList(); + conditionlist2.add(mapItem.get("serialId")); + conditionlist.add(conditionlist2); + conditionMap.put("1",conditionlist); + + //按周期排班 + conditionlist = new ArrayList(); + conditionlist2 = new ArrayList(); + conditionlist2.add(mapItem.get("shiftScheduleBeginDate")); + conditionlist2.add(mapItem.get("shiftScheduleEndDate")); + conditionlist.add(conditionlist2); + + conditionlist2 = new ArrayList(); + conditionlist2.add(wrg); + conditionlist.add(conditionlist2); + + conditionlist2 = new ArrayList(); + conditionlist2.add(mapItem.get("holidayType")); + conditionlist.add(conditionlist2); + + conditionlist2 = new ArrayList(); + conditionlist2.add(mapItem.get("meetHolidays")); + conditionlist.add(conditionlist2); + + conditionlist2 = new ArrayList(); + conditionlist2.add(mapItem.get("meetRestDays")); + conditionlist.add(conditionlist2); + + conditionlist2 = new ArrayList(); + conditionlist2.add(mapItem.get("shiftcycleId")); + conditionlist.add(conditionlist2); + conditionMap.put("2",conditionlist); + condition.add(conditionMap); + + retmap.put("conditions", condition); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/shiftschedule/GetHrmScheduleReportInfoCmd.java b/src/com/engine/kq/cmd/shiftschedule/GetHrmScheduleReportInfoCmd.java new file mode 100644 index 0000000..b55048c --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/GetHrmScheduleReportInfoCmd.java @@ -0,0 +1,147 @@ +package com.engine.kq.cmd.shiftschedule; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQHolidaySetBiz; +import com.engine.kq.biz.KQShiftManagementComInfo; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class GetHrmScheduleReportInfoCmd extends AbstractCommonCommand> { + + public GetHrmScheduleReportInfoCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map result = new HashMap(); + RecordSet rs = new RecordSet(); + Map data = null; + + try{ + ResourceComInfo ResourceComInfo = new ResourceComInfo(); + String fromDate = "", toDate = "", year = "", month = ""; + int type = Util.getIntValue(Util.null2String(params.get("type")), 1); + String kqDate = Util.null2String(params.get("kqDate"));//月份 + String resourceId = Util.null2String(params.get("resourceId")); + //添加级别控制的权限 + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0);//指定查看的人员的所属分部 + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0);//指定查看的人员的所属部门 + + if(resourceId.length()==0){ + resourceId = "" + user.getUID(); + } + if(type == 1){ + if(kqDate.length() == 0 || kqDate.length() != 4){//不合法数据转当前年 + kqDate = DateUtil.getYear(); + } + year = kqDate; + month = ""; + fromDate = kqDate + "-01-01"; + toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate)); + }else{ + if(kqDate.length() == 0 || kqDate.length() != 7){//不合法数据转当前年月 + kqDate = DateUtil.getYear() + "-" + DateUtil.getMonth(); + } + String [] arr = kqDate.split("-"); + year = arr[0]; + month = arr[1]; + fromDate = kqDate + "-01"; + toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate)); + } + boolean isAdmin = user.isAdmin(); + boolean canSearch = HrmUserVarify.checkUserRight("HrmScheduling:set", user); + //QC 607268 yz 修改我的排班默认展示左侧树 + canSearch = true; + //QC 607268 yz 修改我的排班,点击下属 提示无权限查看,改为从数据库查询判断 + String allmanagerids = ""; + rs.executeQuery("select managerstr from hrmresource where id = ?",resourceId); + if(rs.next()){ + allmanagerids = rs.getString("managerstr"); + } + //添加级别控制的权限 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + if (subCompanyId == 0 || departmentId == 0) { + subCompanyId = Util.getIntValue(resourceComInfo.getSubCompanyID(resourceId), 0); + departmentId = Util.getIntValue(resourceComInfo.getDepartmentID(resourceId), 0); + } + //boolean shiftRight = HrmUserVarify.checkUserRight("HrmScheduling:set", user); + boolean shiftRight = HrmUserVarify.checkUserRight("HrmScheduling:set", user, departmentId); + + if(!shiftRight&&!isAdmin && !resourceId.equals("" + user.getUID()) && allmanagerids.indexOf("," + user.getUID() + ",") == -1) { + result.put("status", "-1"); + result.put("hasRight", false); + return result; + } + + result.put("canSearch", canSearch); + + List> holidays = KQHolidaySetBiz.getKQHolidaySetList(resourceId, year, month); + Map holidayMap = new HashMap<>(); + for(Map h : holidays){ + data = new HashMap<>(); + String tip = ""; + boolean isWorkday = false; + int dateType = Integer.parseInt(h.get("type").toString()); + if(dateType == 2) { + tip = SystemEnv.getHtmlLabelName(125807, user.getLanguage()); + isWorkday = true; + } else if(dateType != 0) { + tip = SystemEnv.getHtmlLabelName(125806, user.getLanguage()); + } + data.put("tip", tip); + data.put("isWorkday", isWorkday); + + holidayMap.put(h.get("date").toString(), data); + } + //result.put("holiday", holidayMap); + //QC 607268 yz 修改我的排班中,不显示节假日相关信息 + result.put("holiday", ""); + + + StringBuffer sql = new StringBuffer("SELECT kqdate, serialid, color FROM kq_shiftschedule a, kq_shiftmanagement b " + + "WHERE a.serialid = b.id AND (a.isdelete is null or a.isdelete <> '1') AND a.kqdate >= ? AND a.kqdate <= ? AND a.resourceid = ? ORDER BY kqdate"); + rs.executeQuery(sql.toString(), fromDate, toDate, resourceId); + result.put("result", new HashMap()); + HashMap rsMap = (HashMap) result.get("result"); + while(rs.next()){ + String date = Util.null2String(rs.getString("kqdate")); + String serialid = Util.null2String(rs.getString("serialid")); + String color = Util.null2String(rs.getString("color")); + + String serial = new ShiftManagementToolKit().getShiftOnOffWorkSections(serialid,user.getLanguage()); + + data = new HashMap<>(); + data.put("serial", serial); + data.put("color", color); + + rsMap.put(date, data); + } + result.put("status", "1"); + }catch (Exception ex){ + result.put("status", "-1"); + result.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(ex); + } + return result; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/shiftschedule/GetSearchConditionCmd.java b/src/com/engine/kq/cmd/shiftschedule/GetSearchConditionCmd.java new file mode 100644 index 0000000..f1e8651 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/GetSearchConditionCmd.java @@ -0,0 +1,117 @@ +package com.engine.kq.cmd.shiftschedule; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.api.hrm.bean.WeaRadioGroup; +import com.api.hrm.util.HrmAdvancedSearchUtil; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.google.common.collect.Lists; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.settings.ChgPasswdReminder; +import weaver.hrm.settings.RemindSettings; +import weaver.systeminfo.SystemEnv; + +/** + * 获取排班查询条件 + * @author pzy + * + */ +public class GetSearchConditionCmd extends AbstractCommonCommand>{ + + public GetSearchConditionCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) {Map retmap = new HashMap(); + List lsCondition = new ArrayList(); + String[] options = null; + String[] selectLinkageDatas = null; + try{ + HrmAdvancedSearchUtil hrmAdvancedSearchUtil = new HrmAdvancedSearchUtil(); + + boolean hasViewAllRight=false; + if(HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)){ + hasViewAllRight=true; + } + String _level = ""; + if(hasViewAllRight){ + _level = Util.null2String(HrmUserVarify.getRightLevel("HrmKQGroup:Add", user)); + } + + //查看范围、数据范围 + options = new String[]{"0,140,true","1,141,false","2,124,false","3,1867,false"}; + selectLinkageDatas = new String[]{"1,subCompanyId,141,3,194","2,departmentId,124,3,57","3,resourceId,1867,3,17"}; + WeaRadioGroup wrg = hrmAdvancedSearchUtil.getAdvanceCondition("viewscope","34102",options,selectLinkageDatas,user); + wrg.setLabelcol(3); + wrg.setFieldcol(20); + lsCondition.add(wrg); + + WeaRadioGroup wrg1 = new WeaRadioGroup(); + + ChgPasswdReminder reminder = new ChgPasswdReminder(); + RemindSettings settings = reminder.getRemindSettings(); + String checkUnJob = Util.null2String(settings.getCheckUnJob(), "0"); + List statusList = Lists.newArrayList(); + if ("1".equals(checkUnJob)) {//启用后,只有有“离职人员查看”权限的用户才能检索非在职人员 + if (HrmUserVarify.checkUserRight("hrm:departureView", user)) { + statusList.add("9,332,false"); + } + } else { + statusList.add("9,332,false"); + } + statusList.add("0,15710,false"); + statusList.add("1,15711,false"); + statusList.add("2,480,false"); + statusList.add("3,15844,false"); + if ("1".equals(checkUnJob)) {//启用后,只有有“离职人员查看”权限的用户才能检索非在职人员 + if (HrmUserVarify.checkUserRight("hrm:departureView", user)) { + statusList.add("4,6094,false"); + statusList.add("5,6091,false"); + statusList.add("6,6092,false"); + statusList.add("7,2245,false"); + } + } else { + statusList.add("4,6094,false"); + statusList.add("5,6091,false"); + statusList.add("6,6092,false"); + statusList.add("7,2245,false"); + } + statusList.add("8,1831,true"); + options = new String[statusList.size()]; + for(int i = 0 ; i < statusList.size() ; i++){ + String statusStr = statusList.get(i); + options[i] = statusStr; + } + + wrg1 = hrmAdvancedSearchUtil.getAdvanceCondition("status","602",options,null,user); + wrg1.setLabelcol(3); + wrg1.setFieldcol(20); + lsCondition.add(wrg1); + + retmap.put("status", "1"); + retmap.put("conditions", lsCondition); + }catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10004510,weaver.general.ThreadVarLanguage.getLang())+""); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleCmd.java b/src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleCmd.java new file mode 100644 index 0000000..a8917ee --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleCmd.java @@ -0,0 +1,363 @@ +package com.engine.kq.cmd.shiftschedule; + +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.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.log.KQLog; +import org.apache.commons.lang.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class GetShiftScheduleCmd extends AbstractCommonCommand> { + + public GetShiftScheduleCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + Map shiftSchedule = new HashMap(); + List lsDatas = null; + List lsKeyDatas = null; + Map data = null; + RecordSet rs = new RecordSet(); + + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + int count = 0; + int pageCount = 0; + int isHavePre = 0; + int isHaveNext = 0; + + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + String status = Util.null2String(params.get("status")); + + String groupId = Util.null2String(params.get("groupId"));//考勤组id + List managerRoleUserIdList = new KqShiftScheduleRoleBiz().getUfKqShiftScheduleRoleValue(""+user.getUID(), groupId); + KqMembersValidateBiz kqMembersValidateBiz = new KqMembersValidateBiz(params, user); + List> membersValidateResult = kqMembersValidateBiz.getKqMembersValidate(); + String kqMonth = Util.null2String(params.get("kqMonth"));//月份 + String viewscope = Util.null2String(params.get("viewscope"));//0:总部 1:分部 2:部门 3:人员 4:我的下属 + int pageIndex = Util.getIntValue(Util.null2String(params.get("pageIndex")), 1); + int pageSize = Util.getIntValue(Util.null2String(params.get("pageSize")), 20); + String year = kqMonth.substring(0,4); + String month = kqMonth.substring(5,7); + String monthBeginDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01"); + String monthEndDate = DateUtil.getLastDayOfMonth(kqMonth+"-01"); + + String serialidStr = Util.null2String(kQGroupComInfo.getSerialids(groupId)); + List serialids = new ArrayList<>(); + List lsSerialDatas = new ArrayList<>(); + if(serialidStr.length() > 0){ + serialids = Util.splitString2List(serialidStr,","); + for(int i=0;i(); + data.put("id",serialids.get(i)); + data.put("name",shiftManagementToolKit.getShiftOnOffWorkSections(serialids.get(i),user.getLanguage())); + data.put("bgColor",kQShiftManagementComInfo.getColor(serialids.get(i))); + lsSerialDatas.add(data); + } + } + + lsDatas = new ArrayList<>(); + sql = "select id,shiftcyclename,shiftcycleserialids from kq_group_shiftcycle where groupid = ? order by id asc "; + rs.executeQuery(sql,groupId); + while(rs.next()){ + data = new HashMap<>(); + data.put("name",Util.null2String(rs.getString("shiftcyclename")));//周期名称, + data.put("serial",Util.splitString(Util.null2String(rs.getString("shiftcycleserialids")),","));//周期顺序,例7天一周期 + lsDatas.add(data); + } + retmap.put("serialInfo", lsDatas); + lsDatas = KQHolidaySetBiz.getGroupHolidaySetList(groupId,year,month); + retmap.put("holidays", lsDatas); + + String sqlWhere = " "; + if(viewscope.length()>0){ + if(viewscope.equals("1")){//分部 + String subCompanyId = Util.null2String(params.get("subCompanyId")); + sqlWhere += " and t.subcompanyid1 in ("+subCompanyId+") "; + }else if(viewscope.equals("2")){//部门 + String departmentId = Util.null2String(params.get("departmentId")); + sqlWhere += " and t.departmentid in ("+departmentId+") "; + }else if(viewscope.equals("3")){//人员 + String resourceId = Util.null2String(params.get("resourceId")); + sqlWhere += " and t.resourceid in ("+resourceId+") "; + } + } + + String isNoAccount = Util.null2String(params.get("isNoAccount"));// 是否显示无账号人员 + if (!"1".equals(isNoAccount)) { + sqlWhere += " and t.status in(0,1,2,3) and t.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and t.loginid<>'' "); + } + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and t.status = "+status+ ""; + }else if (status.equals("8")) { + sqlWhere += " and (t.status = 0 or t.status = 1 or t.status = 2 or t.status = 3) "; + } + } + + if(!Util.null2String(kQGroupComInfo.getExcludecount(groupId)).equals("1")) { + //剔除无需排班人员 + String excludeid = Util.null2String(kQGroupComInfo.getExcludeid(groupId)); + if (excludeid.length() > 0) { + sqlWhere += " and t.resourceid not in (" + excludeid + ")"; + } + } + + + String backFields = " t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid "; + String sqlFrom = " from (SELECT distinct t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid FROM ( \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE (a.jobtitle = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=5 and (b.isdelete is null or b.isdelete <> '1') AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue)))) \n" + + " UNION ALL " + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1')" + + " )t ) t where t.groupid = "+groupId; + if(!managerRoleUserIdList.isEmpty()) { + String allUserIds = StringUtils.join(managerRoleUserIdList, ','); + sqlFrom += " and "+Util.getSubINClause(allUserIds, "t.resourceid", "in"); + } + String groupBy = " "; + + //add by yvcy + String tmpsql = " select " + backFields + sqlFrom + sqlWhere + groupBy; + new KQLog().info("GetShiftScheduleCmd0:"+tmpsql); + rs.executeQuery(tmpsql); + String tmp_ids = ""; + while(rs.next()){ + String resourceid = Util.null2String(rs.getString("resourceid")); + data = new HashMap<>(); + data.put("resourceid",resourceid); + String validatefrom = "2000-01-01"; + String validateto = "2999-12-31"; + List> validateList = new ArrayList<>(); + for(Map membersValidate : membersValidateResult) { + String memberId = membersValidate.get("resourceId"); + if(resourceid.equals(memberId)) { + validatefrom = membersValidate.get("validatefrom"); + validateto = membersValidate.get("validateto"); + Map validateMap = new HashMap<>(); + validateMap.put("validatefrom",validatefrom); + validateMap.put("validateto",validateto); + validateList.add(validateMap); + } + } + boolean isInRangeFianl = false; + for(Map validateDate : validateList) { + String from = validateDate.get("validatefrom"); + String to = validateDate.get("validateto"); + boolean isInRange = kqMembersValidateBiz.isInRange(monthBeginDate, monthEndDate, from, to); + if(isInRange) { + isInRangeFianl = true; + break; + } + } + if(!isInRangeFianl) { + tmp_ids += ","+resourceid; + } + } + if(!"".equals(tmp_ids) && tmp_ids.length()>0){ + tmp_ids = tmp_ids.startsWith(",")?tmp_ids.substring(1):tmp_ids; + sqlWhere += " and t.resourceid not in (" + tmp_ids + ")"; + } + + + lsKeyDatas = new ArrayList<>(); + lsDatas = new ArrayList<>(); + 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 "; + + 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 if (rs.getDBType().equals("postgresql")) { + sql = " select * from (select " + sql+") t "+orderBy; + sql = "select t1.* from (" + sql + ") t1 limit " +pageSize + " offset " + ((pageIndex - 1) * 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; + } + new KQLog().info("GetShiftScheduleCmd:"+sql); + rs.executeQuery(sql); + while(rs.next()){ + String resourceid = Util.null2String(rs.getString("resourceid")); + data = new HashMap<>(); + data.put("resourceid",resourceid); + String validatefrom = "2000-01-01"; + String validateto = "2999-12-31"; + List> validateList = new ArrayList<>(); + for(Map membersValidate : membersValidateResult) { + String memberId = membersValidate.get("resourceId"); + if(resourceid.equals(memberId)) { + validatefrom = membersValidate.get("validatefrom"); + validateto = membersValidate.get("validateto"); + boolean isInRange = kqMembersValidateBiz.isInRange(monthBeginDate, monthEndDate, validatefrom, validateto); + if(isInRange) { + Map validateMap = new HashMap<>(); + validateMap.put("validatefrom",validatefrom); + validateMap.put("validateto",validateto); + validateList.add(validateMap); + } + } + } + boolean isInRangeFianl = false; + for(Map validateDate : validateList) { + String from = validateDate.get("validatefrom"); + String to = validateDate.get("validateto"); + boolean isInRange = kqMembersValidateBiz.isInRange(monthBeginDate, monthEndDate, from, to); + if(isInRange) { + isInRangeFianl = true; + break; + } + } + if(!isInRangeFianl) { + continue; + } + data.put("validateList",validateList); + data.put("name",resourceComInfo.getLastname(resourceid)); + data.put("department",departmentComInfo.getDepartmentname(resourceComInfo.getDepartmentID(resourceid))); + data.put("workcode",resourceComInfo.getWorkcode(resourceid)); + List shiftScheduleDatas = this.getShiftSchedule(groupId, resourceid, monthBeginDate,monthEndDate); + for(int i=0;shiftScheduleDatas!=null&&i shiftScheduleData = (Map)shiftScheduleDatas.get(i); + String id = Util.null2String(shiftScheduleData.get("id")); + String kqdate = Util.null2String(shiftScheduleData.get("kqdate")); + String serialid = Util.null2String(shiftScheduleData.get("serialid")); + if(!serialids.contains(serialid) && !serialid.equals("-1")){ + serialids.add(serialid); + Map serialdata = new HashMap<>(); + serialdata.put("id",serialid); + serialdata.put("name",shiftManagementToolKit.getShiftOnOffWorkSections(serialid,user.getLanguage())); + serialdata.put("bgColor",kQShiftManagementComInfo.getColor(serialid)); + serialdata.put("isDelete",1); + lsSerialDatas.add(serialdata); + } + data.put(kqdate,serialid); + lsKeyDatas.add(resourceid+"|"+kqdate+"|"+id); + } + lsDatas.add(data); + } + retmap.put("pagesize", pageSize); + retmap.put("pageindex", pageIndex); + retmap.put("count", count); + retmap.put("pagecount", pageCount); + retmap.put("ishavepre", isHavePre); + retmap.put("ishavenext", isHaveNext); + retmap.put("datas", lsDatas); + retmap.put("keyDatas", lsKeyDatas); + retmap.put("shiftList", lsSerialDatas); + retmap.put("groupName", kQGroupComInfo.getGroupname(groupId)); + retmap.put("today", DateUtil.getCurrentDate()); + if(Util.null2String(kQGroupComInfo.getValidity(groupId)).equals("1")){//考勤组设置了有效期 + retmap.put("validityFromDate", kQGroupComInfo.getValidityfromdate(groupId)); + retmap.put("validityEndDate", kQGroupComInfo.getValidityenddate(groupId)); + } + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private List getShiftSchedule(String groupid, String resourceid, String monthBeginDate,String monthEndDate){ + List datas = new ArrayList<>(); + Map data = null; + String sql = ""; + RecordSet rs = new RecordSet(); + sql = " select id,kqdate, serialid from kq_shiftschedule where groupid= '"+groupid+"' and resourceid="+resourceid+" " + + " and kqdate>='"+monthBeginDate+"' and kqdate<='"+monthEndDate+"' and (isdelete is null or isdelete <> '1')"; + rs.executeQuery(sql); + while(rs.next()){ + String id = Util.null2String(rs.getString("id")); + String kqdate = Util.null2String(rs.getString("kqdate")); + String serialid = Util.null2String(rs.getString("serialid")); + + data = new HashMap<>(); + data.put("id",id); + data.put("kqdate",kqdate); + data.put("serialid",serialid); + datas.add(data); + } + return datas; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleMembersValidateCmd.java b/src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleMembersValidateCmd.java new file mode 100644 index 0000000..00d161b --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleMembersValidateCmd.java @@ -0,0 +1,50 @@ +package com.engine.kq.cmd.shiftschedule; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KqMembersValidateBiz; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetShiftScheduleMembersValidateCmd extends AbstractCommonCommand> { + + public GetShiftScheduleMembersValidateCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + List> result = new KqMembersValidateBiz(params, user).getKqMembersValidate(); + retmap.put("data", result); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleTotalCmd.java b/src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleTotalCmd.java new file mode 100644 index 0000000..7e1d56b --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleTotalCmd.java @@ -0,0 +1,127 @@ +package com.engine.kq.cmd.shiftschedule; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQHolidaySetBiz; +import com.engine.kq.biz.KQShiftManagementComInfo; +import com.engine.kq.biz.KqShiftScheduleRoleBiz; +import org.apache.commons.lang.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class GetShiftScheduleTotalCmd extends AbstractCommonCommand> { + + public GetShiftScheduleTotalCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List lsColumns = new ArrayList<>(); + Map column = null; + List lsDatas = null; + Map data = null; + String sql = ""; + RecordSet rs = new RecordSet(); + + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + Calendar cal = DateUtil.getCalendar(); + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); + String groupId = Util.null2String(params.get("groupId"));//考勤组id + List managerRoleUserIdList = new KqShiftScheduleRoleBiz().getUfKqShiftScheduleRoleValue(""+user.getUID(), groupId); + String kqMonth = Util.null2String(params.get("kqMonth"));//月份 + String monthBeginDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01"); + String monthEndDate = DateUtil.getLastDayOfMonth(kqMonth+"-01"); + + String sqlWhere = ""; + if(!managerRoleUserIdList.isEmpty()) { + String allUserIds = StringUtils.join(managerRoleUserIdList, ','); + sqlWhere += " and "+Util.getSubINClause(allUserIds, "resourceid", "in"); + } + boolean hasRestShift = false; + Map mapShiftSchedule = new HashMap<>(); + sql = " select kqdate,serialid,count(resourceid) as num from kq_shiftschedule " + + " where (isdelete is null or isdelete <> '1') and kqdate>=? and kqdate<=? and groupid=? " +sqlWhere+ + " group by kqdate,serialid "; + rs.executeQuery(sql,monthBeginDate,monthEndDate,groupId); + while(rs.next()){ + if(Util.null2String(rs.getString("serialid")).equals("-1")){ + hasRestShift=true; + } + mapShiftSchedule.put(rs.getString("kqdate")+"|"+rs.getInt("serialid"),rs.getInt("num")); + } + + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelName(389646,user.getLanguage())); + column.put("dataIndex", "serialName"); + lsColumns.add(column); + boolean isEnd = false; + for(String date=monthBeginDate; !isEnd;) { + if (date.equals(monthEndDate)) isEnd = true; + column = new HashMap(); + column.put("title", date); + column.put("dataIndex", date); + lsColumns.add(column); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + + List lsSerialId = Util.splitString2List(Util.null2String(kQGroupComInfo.getSerialids(groupId)),","); + if(hasRestShift && !lsSerialId.contains("-1"))lsSerialId.add("-1");//统计休息班 + lsDatas = new ArrayList<>(); + for(int i=0;lsSerialId!=null&&i(); + data.put("serialId",lsSerialId.get(i)); + if(lsSerialId.get(i).equals("-1")){ + data.put("serialName",SystemEnv.getHtmlLabelName(26593,user.getLanguage())); + }else{ + data.put("serialName",kQShiftManagementComInfo.getSerial(lsSerialId.get(i))); + } + data.put("bgColor",kQShiftManagementComInfo.getColor(lsSerialId.get(i))); + isEnd = false; + for(String date=monthBeginDate; !isEnd;) { + if (date.equals(monthEndDate)) isEnd = true; + data.put(date,mapShiftSchedule.get(date+"|"+lsSerialId.get(i))); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + lsDatas.add(data); + } + retmap.put("columns", lsColumns); + retmap.put("datas", lsDatas); + retmap.put("groupName", kQGroupComInfo.getGroupname(groupId)); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/shiftschedule/GetTabsCmd.java b/src/com/engine/kq/cmd/shiftschedule/GetTabsCmd.java new file mode 100644 index 0000000..3f013a0 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/GetTabsCmd.java @@ -0,0 +1,64 @@ +package com.engine.kq.cmd.shiftschedule; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取排班tab页签 + * @author pzy + * + */ +public class GetTabsCmd extends AbstractCommonCommand>{ + + public GetTabsCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try { + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + List> tabs = new ArrayList>(); + Map tab = null; + + tab = new HashMap(); + tab.put("key", "1"); + tab.put("title", SystemEnv.getHtmlLabelName(16695,user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", "2"); + tab.put("title", SystemEnv.getHtmlLabelName(389465,user.getLanguage())); + tabs.add(tab); + + retmap.put("status", "1"); + retmap.put("tabs", tabs); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/shiftschedule/ImportExcelCmd.java b/src/com/engine/kq/cmd/shiftschedule/ImportExcelCmd.java new file mode 100644 index 0000000..024384a --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/ImportExcelCmd.java @@ -0,0 +1,380 @@ +package com.engine.kq.cmd.shiftschedule; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.KqShiftscheduleOperateLog; +import com.engine.kq.biz.*; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import weaver.conn.BatchRecordSet; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.Reminder.KQAutoCardTask; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ImportExcelCmd extends AbstractCommonCommand> { + private String today = weaver.common.DateUtil.getCurrentDate(); + private SimpleBizLogger logger; + + // 添加日志功能 + private List> operateLogParams = new ArrayList<>(); + // 操作类型 操作人 考勤组名称+id 被修改人 被修改班次日期 被修改班次+id 排班设置行id + private List operateLogParam = null; + + public ImportExcelCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + BatchRecordSet bRs = new BatchRecordSet(); + String sql = ""; + try { + //必要的权限判断 + if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + ResourceComInfo resourceComInfo = new ResourceComInfo(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + + String groupId = Util.null2String(params.get("groupId")); + List managerRoleUserIdList = new KqShiftScheduleRoleBiz().getUfKqShiftScheduleRoleValue(""+user.getUID(), groupId); + + String filename = Util.null2String(params.get("filename")); + + List lsColumn = null; + List> paramInsert = new ArrayList>(); + List> paramUpdate = new ArrayList>(); + List param = null; + List> lsFormatParams = new ArrayList<>(); + List formatParams = null; + + List> delValidateParams = new ArrayList<>(); + List validateParams = null; + + List> lscheckSerialParams = new ArrayList<>(); + List checkSerialParams = null; + + Map mapShiftSchedule = new HashMap<>(); + Map mapSerial = new HashMap<>(); + Map mapGroupMembersWorkCode = new HashMap<>(); + Map mapGroupMembersLastName = new HashMap<>(); + List serialids=Util.splitString2List(kqGroupComInfo.getSerialids(groupId),","); + if(!serialids.contains("-1"))serialids.add("-1"); + for(String serialid : serialids){ + if(serialid.equals("-1")){ + String restLabel = SystemEnv.getHtmlLabelName(26593, user.getLanguage()).trim(); + mapSerial.put(restLabel,serialid); + }else{ + mapSerial.put(Util.formatMultiLang(kqShiftManagementComInfo.getSerial(serialid),""+user.getLanguage()),serialid); + } + } + + Map params = new HashMap<>(); + params.put("groupId",groupId); + params.put("isNoAccount","1"); + List kqGroupMembers = kqGroupBiz.getGroupMembers(params); + + KqMembersValidateBiz kqMembersValidateBiz = new KqMembersValidateBiz(); + + Map> validateResult = new KqMembersValidateBiz(params, user).getKqMembersValidateList(); + + List excludeidList = new ArrayList<>(); + KqShiftscheduleOperateLog bean = null; + boolean needChange = false; + ResourceComInfo rci = new ResourceComInfo(); + if(!Util.null2String(kqGroupComInfo.getExcludecount(groupId)).equals("1")) { + String excludeid = Util.null2String(kqGroupComInfo.getExcludeid(groupId)); + if (excludeid.length() > 0) { + excludeidList = Util.splitString2List(excludeid,","); + } + } + for(String resourceid : kqGroupMembers){ + // 排除无需考勤人员 + if(excludeidList != null && excludeidList.contains(resourceid)) { + continue; + } + String workCode = Util.formatMultiLang(Util.null2String(resourceComInfo.getWorkcode(resourceid)),""+user.getLanguage()); + String lastName = Util.formatMultiLang(Util.null2String(resourceComInfo.getLastname(resourceid)),""+user.getLanguage()); + if(workCode.length()>0){ + mapGroupMembersWorkCode.put(workCode,resourceid); + }else if(lastName.length()>0){ + mapGroupMembersLastName.put(lastName,resourceid); + } + } + + sql = " select id, resourceid, kqdate, serialid from kq_shiftschedule where groupid=? and (isdelete is null or isdelete <> '1') "; + rs.executeQuery(sql,groupId); + while(rs.next()){ + mapShiftSchedule.put(rs.getString("kqdate")+"|"+rs.getString("resourceid"),Util.null2String(rs.getString("id"))+"#"+Util.null2String(rs.getString("serialid"))); + } + + int firstRow = 6; + int firstCol = 3; + ImageFileManager manager = new ImageFileManager(); + manager.getImageFileInfoById(Util.getIntValue(filename)); + //Workbook workbook = WorkbookFactory.create(manager.getInputStream()); + Workbook workbook = new XSSFWorkbook(manager.getInputStream()); + for (int idx = 0; idx < workbook.getNumberOfSheets(); idx++) { + Sheet sheet = workbook.getSheetAt(idx); + if(sheet.getSheetName().indexOf("constraintDataSheet")>-1)continue; + Row row = null; + Cell cell = null; + + row = sheet.getRow(firstRow); + lsColumn = new ArrayList(); + for (int cellIndex = firstCol; cellIndex < row.getLastCellNum(); cellIndex++) { + cell = row.getCell((short) cellIndex); + lsColumn.add(Util.null2String(getCellValue(cell)).trim()); + } + firstRow++; + + for (int i = firstRow; firstRow<=sheet.getLastRowNum() && i <= sheet.getLastRowNum(); i++) { + row = sheet.getRow(i); + if (row == null) { + continue; + } + String workCode = Util.null2String(row.getCell(1));//编号 + String lastName = Util.null2String(row.getCell(2));//姓名 + if(workCode.length()==0 && lastName.length()==0){ + continue; + } + String resourceId = Util.null2String(mapGroupMembersWorkCode.get(workCode));//人员id + if(resourceId.length()==0){ + resourceId = Util.null2String(mapGroupMembersLastName.get(lastName));//人员id + } + if(resourceId.length()==0)continue; + if(!managerRoleUserIdList.isEmpty()) { + if(!managerRoleUserIdList.contains(resourceId)) continue; + } + for (int cellIndex = firstCol; cellIndex < row.getLastCellNum(); cellIndex++) { + cell = row.getCell((short) cellIndex); + if (cell == null) continue; + String serialId = ""; + String serialName = Util.null2String(getCellValue(cell)).trim(); + if(serialName.length()==0)continue; + String kqdate = Util.null2String(lsColumn.get(cellIndex-firstCol)); + kqdate = kqdate.trim().replace(String.valueOf((char)10), "#"); + kqdate = kqdate.split("#")[0]; + if(!SaveShiftScheduleCmd.isDate(kqdate)) { + continue; + } + //if(weaver.common.DateUtil.timeInterval(kqdate,today)>0)continue;//今天之前的无需处理 + serialId = Util.null2String(mapSerial.get(serialName)); + if(serialId.length()==0)continue; + + String shiftScheduleValue = Util.null2String(mapShiftSchedule.get(kqdate+"|"+resourceId)); + String id = ""; + String oldSerialid = ""; + if(!"".equals(shiftScheduleValue)) { + id = shiftScheduleValue.split("#")[0]; + oldSerialid = shiftScheduleValue.split("#")[1]; + } + + // 如果超过了有效期,就不存储数据 + List validateList = validateResult.get(resourceId); + boolean isInRange = kqMembersValidateBiz.isInRange(kqdate, validateList); + if(!isInRange) { + if (oldSerialid.length() > 0) { + validateParams = new ArrayList<>(); + validateParams.add(resourceId); + validateParams.add(kqdate); + delValidateParams.add(validateParams); + lsFormatParams.add(validateParams); + bean = new KqShiftscheduleOperateLog(2, user.getLastname(), kqGroupComInfo.getGroupname(groupId) + "(id:" + groupId + ")", rci.getLastname(resourceId), + kqdate, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftManagementComInfo.getSerial(oldSerialid) + "(id:" + oldSerialid + ")"), id, "", user.getLanguage()); + addLog(bean); + } + continue; + } + + if(id.length()>0 && !oldSerialid.equals(serialId) && oldSerialid.length() > 0){ + needChange = true; + param = new ArrayList(); + param.add(serialId); + param.add(id); + paramUpdate.add(param); + bean = new KqShiftscheduleOperateLog(1, user.getLastname(), kqGroupComInfo.getGroupname(groupId) + "(id:" + groupId + ")", rci.getLastname(resourceId), + kqdate, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftManagementComInfo.getSerial(oldSerialid) + "(id:" + oldSerialid + ")"), id, ("-1".equals(serialId) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftManagementComInfo.getSerial(serialId) + "(id:" + serialId + ")"),user.getLanguage()); + addLog(bean); + }else{ + if(!oldSerialid.equals(serialId)) { + needChange = true; + param = new ArrayList(); + param.add(kqdate); + param.add(serialId); + param.add(resourceId); + param.add(groupId); + paramInsert.add(param); + bean = new KqShiftscheduleOperateLog(0, user.getLastname(), kqGroupComInfo.getGroupname(groupId) + "(id:" + groupId + ")", rci.getLastname(resourceId), + kqdate, "", id, ("-1".equals(serialId) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftManagementComInfo.getSerial(serialId) + "(id:" + serialId + ")"), user.getLanguage()); + addLog(bean); + } + } + if(needChange) { + formatParams = new ArrayList<>(); + formatParams.add(resourceId); + formatParams.add(kqdate); + lsFormatParams.add(formatParams); + + checkSerialParams = new ArrayList<>(); + checkSerialParams.add(resourceId); + checkSerialParams.add(kqdate); + checkSerialParams.add(serialId); + lscheckSerialParams.add(checkSerialParams); + } + + } + } + + sql = " update kq_shiftschedule set serialid=?, isDelete=0 where id = ? "; + for (int i = 0; paramUpdate != null && i < paramUpdate.size(); i++) { + List update_params = paramUpdate.get(i); + String serialid = Util.null2String(update_params.get(0)); + String id = Util.null2String(update_params.get(1)); + rs.executeUpdate(sql, serialid,id); + } + + sql = "insert into kq_shiftschedule (kqdate,serialid,resourceid,groupid,isDelete) values(?,?,?,?,0)"; + for (int i = 0; paramInsert != null && i < paramInsert.size(); i++) { + List insert_params = paramInsert.get(i); + String kqdate = Util.null2String(insert_params.get(0)); + String serialid = Util.null2String(insert_params.get(1)); + String resourceid = Util.null2String(insert_params.get(2)); + String groupid = Util.null2String(insert_params.get(3)); + rs.executeUpdate(sql, kqdate,serialid,resourceid,groupid); + } + } + + // 删除一些有效期之后的排班 + sql = " update kq_shiftschedule set isdelete =1 where resourceid = ? and kqdate = ? and groupid = "+groupId; + for (List delete_params : delValidateParams) { + String resourceid = Util.null2String(delete_params.get(0)); + String kqdate = Util.null2String(delete_params.get(1)); + rs.executeUpdate(sql, resourceid, kqdate); + } + + //删除之前的排的班次,一天只能有一个班次 + sql = " update kq_shiftschedule set isdelete =1 where (isdelete is null or isdelete <> '1') and resourceid = ? and kqdate = ? and groupid != "+groupId; + for (int i = 0; lsFormatParams != null && i < lsFormatParams.size(); i++) { + List delete_params = lsFormatParams.get(i); + String resourceid = Util.null2String(delete_params.get(0)); + String kqdate = Util.null2String(delete_params.get(1)); + rs.executeUpdate(sql, resourceid,kqdate); + } + + sql = " update kq_shiftschedule set isdelete =1 where (isdelete is null or isdelete <> '1') and resourceid = ? and kqdate = ? and serialid != ? "; + for (int i = 0; lscheckSerialParams != null && i < lscheckSerialParams.size(); i++) { + List check_params = lscheckSerialParams.get(i); + String resourceid = Util.null2String(check_params.get(0)); + String kqdate = Util.null2String(check_params.get(1)); + String serialid = Util.null2String(check_params.get(2)); + rs.executeUpdate(sql, resourceid,kqdate,serialid); + } + + sql = "insert into kq_shiftscheduleoperate_log(operatetype,operator,kqgroupname,changeduser,changedshiftdate,changedshiftname,kqshiftid) values(?,?,?,?,?,?,?)"; + bRs.executeBatchSqlNew(sql, operateLogParams); + + new KQShiftScheduleComInfo().removeCache(); + + //刷新报表数据 +// sql = " insert into kq_format_pool (resourceid, kqdate) values (?,?)"; +// bRs.executeBatchSql(sql, lsFormatParams); + new KQFormatBiz().format(lsFormatParams,16); + + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + String auto_checkout = kQGroupComInfo.getAuto_checkout(groupId); + String auto_checkin = kQGroupComInfo.getAuto_checkin(groupId); + if("1".equalsIgnoreCase(auto_checkin) || "1".equalsIgnoreCase(auto_checkout)){ + //如果开启了自动打卡,保存考勤组成员之后需要格式化下缓存 + KQAutoCardTask kqAutoCardTask = new KQAutoCardTask(); + kqAutoCardTask.initAutoCardTask(groupId); + } + + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + /** + * /** + * 获取excel单元格值 + * + * @param cell 要读取的单元格对象 + * @return + */ + public String getCellValue(Cell cell) { + String cellValue = ""; + if (cell == null) + return ""; + switch (cell.getCellType()) { + case BOOLEAN: // 得到Boolean对象的方法 + cellValue = String.valueOf(cell.getBooleanCellValue()); + break; + case NUMERIC: + if (DateUtil.isCellDateFormatted(cell)) {// 先看是否是日期格式 + SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd"); + cellValue = String.valueOf(sft.format(cell.getDateCellValue())); // 读取日期格式 + } else { + cellValue = String.valueOf(new Double(cell.getNumericCellValue())); // 读取数字 + if (cellValue.endsWith(".0")) + cellValue = cellValue.substring(0, cellValue.indexOf(".")); + } + break; + case FORMULA: // 读取公式 + cellValue = cell.getCellFormula(); + break; + case STRING: // 读取String + cellValue = cell.getStringCellValue(); + break; + } + + return cellValue; + } + + private void addLog(KqShiftscheduleOperateLog bean) { + operateLogParam = new ArrayList<>(); + operateLogParam.add(bean.getOperatetype()); + operateLogParam.add(bean.getOperator()); + operateLogParam.add(bean.getKqgroupname()); + operateLogParam.add(bean.getChangeduser()); + operateLogParam.add(bean.getChangedshiftdate()); + operateLogParam.add(bean.getChangedshiftname()); + operateLogParam.add(bean.getKqshiftid()); + operateLogParams.add(operateLogParam); + } +} diff --git a/src/com/engine/kq/cmd/shiftschedule/SaveBatchShiftScheduleCmd.java b/src/com/engine/kq/cmd/shiftschedule/SaveBatchShiftScheduleCmd.java new file mode 100644 index 0000000..cffd6f7 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/SaveBatchShiftScheduleCmd.java @@ -0,0 +1,475 @@ +package com.engine.kq.cmd.shiftschedule; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.KqShiftscheduleOperateLog; +import com.engine.kq.biz.*; +import weaver.common.DateUtil; +import weaver.conn.BatchRecordSet; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class SaveBatchShiftScheduleCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + // 添加日志功能 + private List> operateLogParams = new ArrayList<>(); + // 操作类型 操作人 考勤组名称+id 被修改人 被修改班次日期 被修改班次+id 排班设置行id + private List operateLogParam = null; + + public SaveBatchShiftScheduleCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + BatchRecordSet bRs = new BatchRecordSet(); + String today = DateUtil.getCurrentDate(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + ResourceComInfo resourceComInfo = new ResourceComInfo(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + String data = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(data); + String groupId = Util.null2String(jsonObj.get("groupId"));//考勤组id + String shiftScheduleType = Util.null2String(jsonObj.get("shiftScheduleType"));//排班类型 + String shiftScheduleDate = Util.null2String(jsonObj.get("shiftScheduleDate"));//排班日期 + String shiftScheduleBeginDate = Util.null2String(jsonObj.get("shiftScheduleBeginDate"));//排班开始日期 + String shiftScheduleEndDate = Util.null2String(jsonObj.get("shiftScheduleEndDate"));//排班结束日期 + String shiftScheduleMemberType = Util.null2String(jsonObj.get("shiftScheduleMemberType"));//排班人员类型 + String shiftScheduleMember = Util.null2String(jsonObj.get("shiftScheduleMember"));//排班人员 + String holidayType = Util.null2String(jsonObj.get("holidayType"));//遇双休日 + String meetHolidays = Util.null2String(jsonObj.get("meetHolidays"));//遇节假日 + String meetRestDays = Util.null2String(jsonObj.get("meetRestDays"));//遇调配休息日 + String serialId = Util.null2String(jsonObj.get("serialId"));//班次 + String shiftcycleId = Util.null2String(jsonObj.get("shiftcycleId"));//排班周期Id + + // 某个管理员所拥有的维护人员的权限 + List managerRoleUserIdList = new KqShiftScheduleRoleBiz().getUfKqShiftScheduleRoleValue(""+user.getUID(), groupId); + KqMembersValidateBiz kqMembersValidateBiz = new KqMembersValidateBiz(); + Map paramsValidate = new HashMap<>(); + paramsValidate.put("groupId",groupId); + paramsValidate.put("isNoAccount","1"); + if("2".equals(shiftScheduleMemberType)) { // 按人员排班 + paramsValidate.put("resourceId",shiftScheduleMember); + } + Map> validateResult = new KqMembersValidateBiz(paramsValidate, user).getKqMembersValidateList(); + + List> paramInsert = new ArrayList>(); + List> paramUpdate = new ArrayList>(); + List params = null; + String delIds = ""; + + List> lsFormatParams = new ArrayList<>(); + List formatParams = new ArrayList<>(); + + List> lsDeleteParams = new ArrayList<>(); + List deleteParams = null; + + List> lscheckSerialParams = new ArrayList<>(); + List checkSerialParams = new ArrayList<>(); + + List> lsDeleteCancelParams = new ArrayList<>(); + List deleteCancelParams = null; + + List lsGroupMembers = null; + if(shiftScheduleMemberType.equals("1")){//所有考勤组成员 + lsGroupMembers = kqGroupBiz.getGroupMembers(groupId); + }else{//考勤组成员 + lsGroupMembers = Util.splitString2List(shiftScheduleMember,","); + } + List excludeidList = new ArrayList<>(); + if(!Util.null2String(kqGroupComInfo.getExcludecount(groupId)).equals("1")) { + String excludeid = Util.null2String(kqGroupComInfo.getExcludeid(groupId)); + if (excludeid.length() > 0) { + excludeidList = Util.splitString2List(excludeid,","); + } + } + Map mapShiftSchedule = new HashMap<>(); + sql = " select id, resourceid, kqdate, serialid from kq_shiftschedule where (isdelete is null or isdelete <> '1') and groupid=? "; + //有客户提下面的sql有性能问题,在表数据较多,并且该表数据改动较为频率不适合建索引,所以对mapShiftSchedule先缓存的数据范围过滤下,没必要全表缓存 + if("1".equals(shiftScheduleType)){//按天排班 + sql += " and kqdate='"+shiftScheduleDate+"' "; + }else if("2".equals(shiftScheduleType)){ + sql += " and kqdate>='"+shiftScheduleBeginDate+"' and kqdate<='"+shiftScheduleEndDate+"' "; + } + rs.executeQuery(sql,groupId); + while(rs.next()){ + mapShiftSchedule.put(rs.getString("kqdate")+"|"+Util.null2String(rs.getString("resourceid")), Util.null2String(rs.getString("id"))+"#"+Util.null2String(rs.getString("serialid"))); + } + String id = ""; + String oldSerialid = ""; + boolean needChange = false; + KQShiftManagementComInfo kqShiftScheduleComInfo = new KQShiftManagementComInfo(); + ResourceComInfo rci = new ResourceComInfo(); + KqShiftscheduleOperateLog bean = null; + if(shiftScheduleType.equals("1")){//按天排班 + if(SaveShiftScheduleCmd.isDate(shiftScheduleDate)) { + for (String resourceid : lsGroupMembers) { + // 排除无需考勤人员 + if (excludeidList != null && excludeidList.contains(resourceid)) { + continue; + } + if (!managerRoleUserIdList.isEmpty()) { + if (!managerRoleUserIdList.contains(resourceid)) { + continue; + } + } + String shiftScheduleValue = Util.null2String(mapShiftSchedule.get(shiftScheduleDate + "|" + resourceid)); + if (!"".equals(shiftScheduleValue)) { + id = shiftScheduleValue.split("#")[0]; + oldSerialid = shiftScheduleValue.split("#")[1]; + } + // 如果超过了有效期,就不存储数据 + List validateList = validateResult.get(resourceid); + boolean isInRange = kqMembersValidateBiz.isInRange(shiftScheduleDate, validateList); + if (!isInRange && oldSerialid.length() > 0) { + if (delIds.length() > 0) { + delIds += ","; + } + delIds += id; + bean = new KqShiftscheduleOperateLog(2, user.getLastname(), kqGroupComInfo.getGroupname(groupId) + "(id:" + groupId + ")", rci.getLastname(resourceid), + shiftScheduleDate, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(oldSerialid) + "(id:" + oldSerialid + ")"), id, "", user.getLanguage()); + addLog(bean); + continue; + } + //if(weaver.common.DateUtil.timeInterval(shiftScheduleDate,today)>0)continue;//今天之前的无需处理 + if (id.length() > 0) { + if (serialId.length() == 0 && oldSerialid.length() > 0) { + if (delIds.length() > 0) { + delIds += ","; + } + delIds += id; + bean = new KqShiftscheduleOperateLog(2, user.getLastname(), kqGroupComInfo.getGroupname(groupId) + "(id:" + groupId + ")", rci.getLastname(resourceid), + shiftScheduleDate, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(oldSerialid) + "(id:" + oldSerialid + ")"), id, "", user.getLanguage()); + addLog(bean); + } else { + if (!oldSerialid.equals(serialId) && oldSerialid.length() > 0) { + needChange = true; + params = new ArrayList(); + params.add(serialId); + params.add(id); + paramUpdate.add(params); + bean = new KqShiftscheduleOperateLog(1, user.getLastname(), kqGroupComInfo.getGroupname(groupId) + "(id:" + groupId + ")", rci.getLastname(resourceid), + shiftScheduleDate, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(oldSerialid) + "(id:" + oldSerialid + ")"), id, ("-1".equals(serialId) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(serialId) + "(id:" + serialId + ")"), user.getLanguage()); + addLog(bean); + } + } + } else { + if (serialId.length() == 0) continue; + if(!oldSerialid.equals(serialId)) { + needChange = true; + params = new ArrayList(); + params.add(shiftScheduleDate); + params.add(serialId); + params.add(resourceid); + params.add(groupId); + paramInsert.add(params); + bean = new KqShiftscheduleOperateLog(0, user.getLastname(), kqGroupComInfo.getGroupname(groupId) + "(id:" + groupId + ")", rci.getLastname(resourceid), + shiftScheduleDate, "", id, ("-1".equals(serialId) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(serialId) + "(id:" + serialId + ")"), user.getLanguage()); + addLog(bean); + } + } + if (needChange) { + if (DateUtil.timeInterval(shiftScheduleDate, today) >= 0) { + formatParams = new ArrayList<>(); + formatParams.add(resourceid); + formatParams.add(shiftScheduleDate); + lsFormatParams.add(formatParams); + } + + deleteParams = new ArrayList<>(); + deleteParams.add(resourceid); + deleteParams.add(shiftScheduleDate); + lsDeleteParams.add(deleteParams); + + checkSerialParams = new ArrayList<>(); + checkSerialParams.add(resourceid); + checkSerialParams.add(shiftScheduleDate); + checkSerialParams.add(serialId); + lscheckSerialParams.add(checkSerialParams); + } + } + } + }else if(shiftScheduleType.equals("2")){//按周期排班 + List lsDate = new ArrayList<>(); + Calendar cal = DateUtil.getCalendar(); + writeLog("shiftScheduleBeginDate==" + shiftScheduleBeginDate + "shiftScheduleEndDate==" + shiftScheduleEndDate); + if (DateUtil.timeInterval(shiftScheduleEndDate, shiftScheduleBeginDate) > 0) + { + retmap.put("status", "-1"); + retmap.put("message", ""+ SystemEnv.getHtmlLabelName(10005344,weaver.general.ThreadVarLanguage.getLang())+""); + return retmap; + } + + int shiftcycleday = 0; + String[] shiftcycleserialids = null; + sql = "select shiftcycleday,shiftcycleserialids from kq_group_shiftcycle where id = ? order by id asc "; + rs.executeQuery(sql,shiftcycleId); + if(rs.next()){ + shiftcycleday = rs.getInt("shiftcycleday"); + shiftcycleserialids = Util.splitString(Util.null2String(rs.getString("shiftcycleserialids")), ","); + } + + boolean isEnd = false; + for(String date=shiftScheduleBeginDate; !isEnd;) { + if(date.equals(shiftScheduleEndDate)) isEnd = true; + lsDate.add(date); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + + for(String resourceid:lsGroupMembers){ + // 排除无需考勤人员 + if(excludeidList != null && excludeidList.contains(resourceid)) { + continue; + } + if(!managerRoleUserIdList.isEmpty()) { + if(!managerRoleUserIdList.contains(resourceid)) { + continue; + } + } + boolean needShiftSchedule = false; + int dayCount = 0; + for(int i=0;i0)continue;//今天之前的无需处理 + String date = lsDate.get(i); + if(!SaveShiftScheduleCmd.isDate(date)) { + continue; + } + String shiftScheduleValue = Util.null2String(mapShiftSchedule.get(date+"|"+resourceid)); + if(!"".equals(shiftScheduleValue)) { + id = shiftScheduleValue.split("#")[0]; + oldSerialid = shiftScheduleValue.split("#")[1]; + } + + // 如果超过了有效期,就不存储数据 + List validateList = validateResult.get(resourceid); + boolean isInRange = kqMembersValidateBiz.isInRange(date, validateList); + if(!isInRange) { + if(oldSerialid.length() > 0) { + if (delIds.length() > 0) { + delIds += ","; + } + delIds += id; + bean = new KqShiftscheduleOperateLog(2, user.getLastname(), kqGroupComInfo.getGroupname(groupId) + "(id:" + groupId + ")", rci.getLastname(resourceid), + date, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(oldSerialid) + "(id:" + oldSerialid + ")"), id, "", user.getLanguage()); + addLog(bean); + } + continue; + } + + needShiftSchedule = true; + int changeType= KQHolidaySetBiz.getChangeType(groupId, date); + if (changeType != 1 && changeType != 3 && !holidayType.equals("1")) {//遇双休日继续排班 + int weekDay = DateUtil.getWeek(date); + if(weekDay>5){ + needShiftSchedule = false; + } + } + if(!meetHolidays.equals("1")){//遇节假日继续排班 + if(changeType==1){ + needShiftSchedule = false; + } + } + if(!meetRestDays.equals("1")){//遇调配休息日继续排班 + if(changeType==3){ + needShiftSchedule = false; + } + } + + if(needShiftSchedule){ + dayCount++; + int idx = dayCount % shiftcycleday; + if (idx == 0) {//周期最后一天 + serialId = Util.null2String(shiftcycleserialids[shiftcycleserialids.length - 1]); + } else { + serialId = Util.null2String(shiftcycleserialids[idx-1]); + } + if(id.length()>0){ + if(serialId.length()==0 && oldSerialid.length() > 0){ + if(delIds.length()>0) { + delIds+=","; + } + delIds+=id; + bean = new KqShiftscheduleOperateLog(2, user.getLastname(), kqGroupComInfo.getGroupname(groupId) + "(id:" + groupId + ")", rci.getLastname(resourceid), + date, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(oldSerialid) + "(id:" + oldSerialid + ")"), id, "",user.getLanguage()); + addLog(bean); + }else { + if(!oldSerialid.equals(serialId) && oldSerialid.length() > 0) { + needChange = true; + params = new ArrayList(); + params.add(serialId); + params.add(id); + paramUpdate.add(params); + bean = new KqShiftscheduleOperateLog(1,user.getLastname(),kqGroupComInfo.getGroupname(groupId)+"(id:"+groupId+")",rci.getLastname(resourceid), + date, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(oldSerialid)+"(id:"+oldSerialid+")"), id, ("-1".equals(serialId) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(serialId)+"(id:"+serialId+")"),user.getLanguage()); + addLog(bean); + } + } + }else{ + if(serialId.length()>0){ + if(!oldSerialid.equals(serialId)) { + needChange = true; + params = new ArrayList(); + params.add(date); + params.add(serialId); + params.add(resourceid); + params.add(groupId); + paramInsert.add(params); + bean = new KqShiftscheduleOperateLog(0, user.getLastname(), kqGroupComInfo.getGroupname(groupId) + "(id:" + groupId + ")", rci.getLastname(resourceid), + date, "", id, ("-1".equals(serialId) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(serialId) + "(id:" + serialId + ")"), user.getLanguage()); + addLog(bean); + } + } + } + }else{ + if(oldSerialid.length() > 0) { + deleteCancelParams = new ArrayList<>(); + deleteCancelParams.add(resourceid); + deleteCancelParams.add(date); + lsDeleteCancelParams.add(deleteCancelParams); + bean = new KqShiftscheduleOperateLog(2, user.getLastname(), kqGroupComInfo.getGroupname(groupId) + "(id:" + groupId + ")", rci.getLastname(resourceid), + date, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(oldSerialid) + "(id:" + oldSerialid + ")"), id, "",user.getLanguage()); + addLog(bean); + } + } + if(needChange) { + if(DateUtil.timeInterval(date,today)>=0) { + formatParams = new ArrayList<>(); + formatParams.add(resourceid); + formatParams.add(date); + lsFormatParams.add(formatParams); + } + + deleteParams = new ArrayList<>(); + deleteParams.add(resourceid); + deleteParams.add(date); + lsDeleteParams.add(deleteParams); + + checkSerialParams = new ArrayList<>(); + checkSerialParams.add(resourceid); + checkSerialParams.add(shiftScheduleDate); + checkSerialParams.add(serialId); + lscheckSerialParams.add(checkSerialParams); + } + } + } + } + + sql = " update kq_shiftschedule set serialid=?,isDelete=0 where id = ? "; + for (int i = 0; paramUpdate != null && i < paramUpdate.size(); i++) { + List update_params = paramUpdate.get(i); + String serialid = Util.null2String(update_params.get(0)); + String tmp_id = Util.null2String(update_params.get(1)); + rs.executeUpdate(sql, serialid,tmp_id); + } + + sql = "insert into kq_shiftschedule (kqdate,serialid,resourceid,groupid,isDelete) values(?,?,?,?,0)"; + for (int i = 0; paramInsert != null && i < paramInsert.size(); i++) { + List insert_params = paramInsert.get(i); + String kqdate = Util.null2String(insert_params.get(0)); + String serialid = Util.null2String(insert_params.get(1)); + String resourceid = Util.null2String(insert_params.get(2)); + String groupid = Util.null2String(insert_params.get(3)); + rs.executeUpdate(sql, kqdate,serialid,resourceid,groupid); + } + + if(delIds.length()>0){ + List sqlParams = new ArrayList(); + Object[] objects= DBUtil.transListIn(delIds,sqlParams); + sql = "update kq_shiftschedule set isdelete =1 where id in("+objects[0]+") "; + rs.executeUpdate(sql, sqlParams); + } + //删除批量排班,遇双休日、节假日、调配工作日的取消排班 + sql = " update kq_shiftschedule set isdelete =1 where (isdelete is null or isdelete <> '1') and resourceid = ? and kqdate = ? "; + for (int i = 0; lsDeleteCancelParams != null && i < lsDeleteCancelParams.size(); i++) { + List delete_params = lsDeleteCancelParams.get(i); + String resourceid = Util.null2String(delete_params.get(0)); + String kqdate = Util.null2String(delete_params.get(1)); + rs.executeUpdate(sql, resourceid,kqdate); + } + + //删除之前的排的班次,一天只能有一个班次 + sql = " update kq_shiftschedule set isdelete =1 where (isdelete is null or isdelete <> '1') and resourceid = ? and kqdate = ? and groupid != "+groupId; + for (int i = 0; lsDeleteParams != null && i < lsDeleteParams.size(); i++) { + List delete_params = lsDeleteParams.get(i); + String resourceid = Util.null2String(delete_params.get(0)); + String kqdate = Util.null2String(delete_params.get(1)); + rs.executeUpdate(sql, resourceid,kqdate); + } + + sql = " update kq_shiftschedule set isdelete =1 where (isdelete is null or isdelete <> '1') and resourceid = ? and kqdate = ? and serialid != ? "; + for (int i = 0; lscheckSerialParams != null && i < lscheckSerialParams.size(); i++) { + List check_params = lscheckSerialParams.get(i); + String resourceid = Util.null2String(check_params.get(0)); + String kqdate = Util.null2String(check_params.get(1)); + String serialid = Util.null2String(check_params.get(2)); + rs.executeUpdate(sql, resourceid,kqdate,serialid); + } + + sql = "insert into kq_shiftscheduleoperate_log(operatetype,operator,kqgroupname,changeduser,changedshiftdate,changedshiftname,kqshiftid) values(?,?,?,?,?,?,?)"; + bRs.executeBatchSqlNew(sql, operateLogParams); + + new KQShiftScheduleComInfo().removeCache(); + + //刷新报表数据 + new KQFormatBiz().format(lsFormatParams,16); + + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(18758, user.getLanguage())); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private void addLog(KqShiftscheduleOperateLog bean) { + operateLogParam = new ArrayList<>(); + operateLogParam.add(bean.getOperatetype()); + operateLogParam.add(bean.getOperator()); + operateLogParam.add(bean.getKqgroupname()); + operateLogParam.add(bean.getChangeduser()); + operateLogParam.add(bean.getChangedshiftdate()); + operateLogParam.add(bean.getChangedshiftname()); + operateLogParam.add(bean.getKqshiftid()); + operateLogParams.add(operateLogParam); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/shiftschedule/SaveShiftScheduleCmd.java b/src/com/engine/kq/cmd/shiftschedule/SaveShiftScheduleCmd.java new file mode 100644 index 0000000..92f3e9a --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/SaveShiftScheduleCmd.java @@ -0,0 +1,258 @@ +package com.engine.kq.cmd.shiftschedule; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.KqShiftscheduleOperateLog; +import com.engine.kq.biz.*; +import weaver.common.DateUtil; +import weaver.conn.BatchRecordSet; +import weaver.conn.DBUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.Reminder.KQAutoCardTask; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +public class SaveShiftScheduleCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + // 添加日志功能 + private List> operateLogParams = new ArrayList<>(); + // 操作类型 操作人 考勤组名称+id 被修改人 被修改班次日期 被修改班次+id 排班设置行id + private List operateLogParam = null; + + public SaveShiftScheduleCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + BatchRecordSet bRs = new BatchRecordSet(); + String today = DateUtil.getCurrentDate(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + String data = Util.null2String(params.get("data")); + JSONObject jsonObj = JSON.parseObject(data); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQShiftManagementComInfo kqShiftScheduleComInfo = new KQShiftManagementComInfo(); + ResourceComInfo rci = new ResourceComInfo(); + String groupId = Util.null2String(jsonObj.get("groupId")); + JSONArray datas = jsonObj.getJSONArray("datas"); + + List> paramInsert = new ArrayList>(); + List> paramUpdate = new ArrayList>(); + List params = null; + String delIds = ""; + List> lsFormatParams = new ArrayList<>(); + List formatParams = null; + List> lsDeleteParams = new ArrayList<>(); + List deleteParams = null; + List> lscheckSerialParams = new ArrayList<>(); + List checkSerialParams = null; + + JSONObject resourceDataObj = null; + JSONArray arrKqDataObj = null; + JSONObject kqDataObj = null; + KqShiftscheduleOperateLog bean = null; + for(int i=0;datas!=null&&i0)continue;//今天之前的无需处理 + if(id.length()>0){ // 更新 + if(serialid.length()==0 && oldSerialid.length() > 0){ //删除 + if(delIds.length()>0) { + delIds+=","; + } + delIds+=id; + bean = new KqShiftscheduleOperateLog(2,user.getLastname(),kqGroupComInfo.getGroupname(groupId)+"(id:"+groupId+")",rci.getLastname(resourceid), + date, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(oldSerialid)+"(id:"+oldSerialid+")"), id, "", user.getLanguage()); + addLog(bean); + }else { + if(!oldSerialid.equals(serialid) && oldSerialid.length() > 0) { + needChange = true; + params = new ArrayList(); + params.add(serialid); + params.add(id); + paramUpdate.add(params); + bean = new KqShiftscheduleOperateLog(1,user.getLastname(),kqGroupComInfo.getGroupname(groupId)+"(id:"+groupId+")",rci.getLastname(resourceid), + date, ("-1".equals(oldSerialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(oldSerialid)+"(id:"+oldSerialid+")"), id, ("-1".equals(serialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(serialid)+"(id:"+serialid+")"), user.getLanguage()); + addLog(bean); + } + } + }else{ //新建 + if(serialid.length()==0)continue; + if(!oldSerialid.equals(serialid)) { + needChange = true; + params = new ArrayList(); + params.add(date); + params.add(serialid); + params.add(resourceid); + params.add(groupId); + paramInsert.add(params); + bean = new KqShiftscheduleOperateLog(0,user.getLastname(),kqGroupComInfo.getGroupname(groupId)+"(id:"+groupId+")",rci.getLastname(resourceid), + date, "", id, ("-1".equals(serialid) ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : kqShiftScheduleComInfo.getSerial(serialid)+"(id:"+serialid+")"), user.getLanguage()); + addLog(bean); + } + } + if(needChange) { + deleteParams = new ArrayList<>(); + deleteParams.add(resourceid); + deleteParams.add(date); + lsDeleteParams.add(deleteParams); + + checkSerialParams = new ArrayList<>(); + checkSerialParams.add(resourceid); + checkSerialParams.add(date); + checkSerialParams.add(serialid); + lscheckSerialParams.add(checkSerialParams); + + if(DateUtil.timeInterval(date,today)>=0) { + formatParams = new ArrayList<>(); + formatParams.add(resourceid); + formatParams.add(date); + lsFormatParams.add(formatParams); + } + } + } + } + + sql = " update kq_shiftschedule set serialid=?,isDelete=0 where id = ? "; + for (int i = 0; paramUpdate != null && i < paramUpdate.size(); i++) { + List update_params = paramUpdate.get(i); + String serialid = Util.null2String(update_params.get(0)); + String id = Util.null2String(update_params.get(1)); + rs.executeUpdate(sql, serialid,id); + } + + sql = "insert into kq_shiftschedule (kqdate,serialid,resourceid,groupid,isDelete) values(?,?,?,?,0)"; + for (int i = 0; paramInsert != null && i < paramInsert.size(); i++) { + List insert_params = paramInsert.get(i); + String kqdate = Util.null2String(insert_params.get(0)); + String serialid = Util.null2String(insert_params.get(1)); + String resourceid = Util.null2String(insert_params.get(2)); + String groupid = Util.null2String(insert_params.get(3)); + rs.executeUpdate(sql, kqdate,serialid,resourceid,groupid); + } + + if(delIds.length()>0){ + List sqlParams = new ArrayList(); + Object[] objects= DBUtil.transListIn(delIds,sqlParams); + sql = "update kq_shiftschedule set isdelete =1 where id in("+objects[0]+") "; + rs.executeUpdate(sql, sqlParams); + } + + //删除之前的排的班次,一天只能有一个班次 + sql = " update kq_shiftschedule set isdelete =1 where (isdelete is null or isdelete <> '1') and resourceid = ? and kqdate = ? and groupid != "+groupId; + for (int i = 0; lsDeleteParams != null && i < lsDeleteParams.size(); i++) { + List delete_params = lsDeleteParams.get(i); + String resourceid = Util.null2String(delete_params.get(0)); + String kqdate = Util.null2String(delete_params.get(1)); + rs.executeUpdate(sql, resourceid,kqdate); + } + + sql = " update kq_shiftschedule set isdelete =1 where (isdelete is null or isdelete <> '1') and resourceid = ? and kqdate = ? and serialid != ? "; + for (int i = 0; lscheckSerialParams != null && i < lscheckSerialParams.size(); i++) { + List check_params = lscheckSerialParams.get(i); + String resourceid = Util.null2String(check_params.get(0)); + String kqdate = Util.null2String(check_params.get(1)); + String serialid = Util.null2String(check_params.get(2)); + rs.executeUpdate(sql, resourceid,kqdate,serialid); + } + + sql = "insert into kq_shiftscheduleoperate_log(operatetype,operator,kqgroupname,changeduser,changedshiftdate,changedshiftname,kqshiftid) values(?,?,?,?,?,?,?)"; + bRs.executeBatchSqlNew(sql, operateLogParams); + + new KQShiftScheduleComInfo().removeCache(); + + //刷新报表数据 + new KQFormatBiz().format(lsFormatParams,16); + + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + String auto_checkout = kQGroupComInfo.getAuto_checkout(groupId); + String auto_checkin = kQGroupComInfo.getAuto_checkin(groupId); + if("1".equalsIgnoreCase(auto_checkin) || "1".equalsIgnoreCase(auto_checkout)){ + //如果开启了自动打卡,保存考勤组成员之后需要格式化下缓存 + KQAutoCardTask kqAutoCardTask = new KQAutoCardTask(); + kqAutoCardTask.initAutoCardTask(groupId); + } + + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(18758, user.getLanguage())); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private void addLog(KqShiftscheduleOperateLog bean) { + operateLogParam = new ArrayList<>(); + operateLogParam.add(bean.getOperatetype()); + operateLogParam.add(bean.getOperator()); + operateLogParam.add(bean.getKqgroupname()); + operateLogParam.add(bean.getChangeduser()); + operateLogParam.add(bean.getChangedshiftdate()); + operateLogParam.add(bean.getChangedshiftname()); + operateLogParam.add(bean.getKqshiftid()); + operateLogParams.add(operateLogParam); + } + + public static boolean isDate(String str) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + sdf.setLenient(false); // 严格匹配 + try { + sdf.parse(str); + return true; + } catch (ParseException e) { + return false; + } + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/cmd/travelrules/GetRightMenuCmd.java b/src/com/engine/kq/cmd/travelrules/GetRightMenuCmd.java new file mode 100644 index 0000000..bfa4898 --- /dev/null +++ b/src/com/engine/kq/cmd/travelrules/GetRightMenuCmd.java @@ -0,0 +1,52 @@ +package com.engine.kq.cmd.travelrules; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.bean.RightMenu; +import com.engine.kq.bean.RightMenuType; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 出差公出规则--获取右键菜单 + */ +public class GetRightMenuCmd extends AbstractCommonCommand> { + + public GetRightMenuCmd(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(); + List rightMenuList = new ArrayList();//表示有权限可以看见的菜单List集合 + int languageId = user.getLanguage();//用户选择的语言 + RightMenu rightMenu = null; + + boolean canAdd = HrmUserVarify.checkUserRight("KQTravelRulesAdd:Add", user);//是否具有新建权限 + boolean canLog = HrmUserVarify.checkUserRight("KQTravelRules:Log", user);//是否具有查看日志的权限 + + if(canAdd){ + rightMenu = new RightMenu(languageId, RightMenuType.BTN_Save, "save", true);//保存 + rightMenuList.add(rightMenu); + } + if(canLog){ + rightMenu = new RightMenu(languageId, RightMenuType.BTN_log, "log", false);//日志 + rightMenuList.add(rightMenu); + } + resultMap.put("btnMenu", rightMenuList); + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/travelrules/GetTravelRulesFormCmd.java b/src/com/engine/kq/cmd/travelrules/GetTravelRulesFormCmd.java new file mode 100644 index 0000000..0c0ef13 --- /dev/null +++ b/src/com/engine/kq/cmd/travelrules/GetTravelRulesFormCmd.java @@ -0,0 +1,280 @@ +package com.engine.kq.cmd.travelrules; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 出差规则--获取表单 + */ +public class GetTravelRulesFormCmd extends AbstractCommonCommand> { + + public GetTravelRulesFormCmd(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(); + try{ + boolean canAdd = HrmUserVarify.checkUserRight("KQTravelRulesAdd:Add", user);//是否具有新建的权限; + boolean canEdit = HrmUserVarify.checkUserRight("KQTravelRulesEdit:Edit", user);//是否具有编辑的权限; + if (!canAdd && !canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + /*出差规则 start*/ + String ruleId = "1";//暂为备用字段,规则ID,固定为1 + String name = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(20084,weaver.general.ThreadVarLanguage.getLang())+"";//暂为备用字段,规则名称,目前固定为出差 + int minimumUnit = 1;//最小出差单位:1-按天出差、2-按半天出差、3-按小时出差、4-按整天出差 + double proportion = 8.00;//换算比例 + int computingMode = 1;//计算公出时长方式:1-按工作日计算出差时长、2-按自然日计算出差时长 + double hoursToDay = 8.00;//日折算时长 + + //半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + int travel_timeselection = 1; + //半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + int exit_timeselection = 1; + + String sql = "select * from kq_travelRules where (isDelete is null or isDelete != 1) and id=" + ruleId; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + minimumUnit = recordSet.getInt("minimumUnit"); + computingMode = recordSet.getInt("computingMode"); + hoursToDay = Util.getDoubleValue(recordSet.getString("hoursToday"),8.00); + travel_timeselection = recordSet.getInt("timeselection"); + travel_timeselection = travel_timeselection < 1 ? 1 : travel_timeselection; + } + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("minimumUnit");//最小出差单位 + hrmFieldBean.setFieldlabel("389789"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(389899, user.getLanguage()), minimumUnit == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(389900, user.getLanguage()), minimumUnit == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(389901, user.getLanguage()), minimumUnit == 3)); + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(389902, user.getLanguage()), minimumUnit == 4)); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + List minimumUnitTips = new ArrayList(); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(390372, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389733, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389734, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389732, user.getLanguage())); + resultMap.put("minimumUnit", minimumUnitTips); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("proportion");//换算比例 + hrmFieldBean.setFieldlabel("390754"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(proportion); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("1"); + itemList.add(searchConditionItem); + resultMap.put("proportion_Tips",SystemEnv.getHtmlLabelName(500947, user.getLanguage())); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("travel_timeselection");//时间选择方式 + hrmFieldBean.setFieldlabel("513304"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(travel_timeselection+""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(513301, user.getLanguage()), travel_timeselection == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(513302, user.getLanguage()), travel_timeselection == 2)); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("computingMode");//计算出差时长方式 + hrmFieldBean.setFieldlabel("389790"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(389903, user.getLanguage()), computingMode == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(389904, user.getLanguage()), computingMode == 2)); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("hoursToDay");//日折算时长 + hrmFieldBean.setFieldlabel("388907"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(hoursToDay); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2);//保留两位小数 + itemList.add(searchConditionItem); + resultMap.put("hoursToDay_Tips",SystemEnv.getHtmlLabelName(506369, user.getLanguage())); + + groupItem.put("title", SystemEnv.getHtmlLabelName(389801, user.getLanguage()));//出差规则 + groupItem.put("defaultshow",true); + groupItem.put("items", itemList); + groupList.add(groupItem); + /*出差规则 end*/ + + /*公出规则 start*/ + String exit_ruleId = "1";//暂为备用字段,规则ID,固定为1 + String exit_name = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(24058,weaver.general.ThreadVarLanguage.getLang())+"";//暂为备用字段,规则名称,目前固定为公出 + int exit_minimumUnit = 1;//最小公出单位:1-按天公出、2-按半天公出、3-按小时公出、4-按整天公出 + double exit_proportion = 8.00;//换算比例 + int exit_computingMode = 1;//计算公出时长方式:1-按工作日计算公出时长、2-按自然日计算公出时长 + double exit_hoursToDay = 8.00;//日折算时长 + + sql = "select * from kq_exitRules where (isDelete is null or isDelete != 1) and id=" + exit_ruleId; + recordSet.executeQuery(sql); + if (recordSet.next()) { + exit_minimumUnit = recordSet.getInt("minimumUnit"); + exit_proportion = Util.getDoubleValue(recordSet.getString("proportion"),8.00); + exit_computingMode = recordSet.getInt("computingMode"); + exit_hoursToDay = Util.getDoubleValue(recordSet.getString("hoursToday"),8.00); + exit_timeselection = recordSet.getInt("timeselection"); + exit_timeselection = exit_timeselection < 1 ? 1 : exit_timeselection; + } + + groupItem = new HashMap(); + itemList = new ArrayList(); + hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + searchConditionItem = null; + hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("exit_minimumUnit");//最小出差单位 + hrmFieldBean.setFieldlabel("389787"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(389905, user.getLanguage()), exit_minimumUnit == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(389906, user.getLanguage()), exit_minimumUnit == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(389907, user.getLanguage()), exit_minimumUnit == 3)); + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(389908, user.getLanguage()), exit_minimumUnit == 4)); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + minimumUnitTips = new ArrayList(); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(390372, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389733, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389734, user.getLanguage())); + minimumUnitTips.add(SystemEnv.getHtmlLabelName(389732, user.getLanguage())); + resultMap.put("exit_minimumUnit", minimumUnitTips); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("exit_timeselection");//时间选择方式 + hrmFieldBean.setFieldlabel("513304"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(exit_timeselection+""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(513301, user.getLanguage()), exit_timeselection == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(513302, user.getLanguage()), exit_timeselection == 2)); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("exit_proportion");//换算比例 + hrmFieldBean.setFieldlabel("390754"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(proportion); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("1"); + itemList.add(searchConditionItem); + resultMap.put("exit_proportion_Tips",SystemEnv.getHtmlLabelName(500949, user.getLanguage())); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("exit_computingMode");//计算公出时长方式 + hrmFieldBean.setFieldlabel("389788"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(389909, user.getLanguage()), exit_computingMode == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(389910, user.getLanguage()), exit_computingMode == 2)); + searchConditionItem.setOptions(optionsList); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("exit_hoursToDay");//日折算时长 + hrmFieldBean.setFieldlabel("388907"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(exit_hoursToDay); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2);//保留两位有效数字 + itemList.add(searchConditionItem); + resultMap.put("exit_hoursToDay_Tips",SystemEnv.getHtmlLabelName(506368, user.getLanguage())); + + groupItem.put("title", SystemEnv.getHtmlLabelName(389808, user.getLanguage()));//公出规则 + groupItem.put("defaultshow",true); + groupItem.put("items", itemList); + groupList.add(groupItem); + /*公出规则 end*/ + + resultMap.put("condition", groupList); + }catch (Exception e){ + writeLog(e); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/travelrules/SaveTravelRulesCmd.java b/src/com/engine/kq/cmd/travelrules/SaveTravelRulesCmd.java new file mode 100644 index 0000000..7cf2539 --- /dev/null +++ b/src/com/engine/kq/cmd/travelrules/SaveTravelRulesCmd.java @@ -0,0 +1,136 @@ +package com.engine.kq.cmd.travelrules; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQAttFlowSetComInfo; +import com.engine.kq.biz.KQExitRulesComInfo; +import com.engine.kq.biz.KQTravelRulesComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 出差规则--保存 + */ +public class SaveTravelRulesCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public SaveTravelRulesCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_TRAVELRULES);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_TRAVELRULES);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select 1 as id,minimumUnit,proportion,computingMode,hoursToDay from kq_travelRules union all " + + " select 2 as id,minimumUnit,proportion,computingMode,hoursToDay from kq_exitRules"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4TravelRules",""+user.getLanguage()); + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try{ + boolean canAdd = HrmUserVarify.checkUserRight("KQTravelRulesAdd:Add", user);//是否具有新建的权限; + boolean canEdit = HrmUserVarify.checkUserRight("KQTravelRulesEdit:Edit", user);//是否具有编辑的权限; + if (!canAdd && !canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + + /*出差规则*/ + String ruleId = "1";//暂为备用字段,规则ID,固定为1 + String name = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(20084,weaver.general.ThreadVarLanguage.getLang())+"";//暂为备用字段,规则名称,目前固定为出差 + int minimumUnit = Util.getIntValue((String) params.get("minimumUnit"), 1);//最小出差单位:1-按天出差、2-按半天出差、3-按小时出差、4-按整天出差 + double proportion = Util.getDoubleValue((String) params.get("proportion"), 8.00);//换算比例(当单位由天、半天、整天切换成小时或者由小时切换成天、半天、整天时,历史数据的转换比例) + int computingMode = Util.getIntValue((String) params.get("computingMode"), 1);//计算公出时长方式:1-按工作日计算出差时长、2-按自然日计算出差时长 + double hoursToDay = Util.getDoubleValue((String) params.get("hoursToDay"), 8.00);//日折算时长 + int travel_timeselection = Util.getIntValue((String) params.get("travel_timeselection"), 1);//半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + + if(minimumUnit != 2){ + RecordSet rs = new RecordSet(); + //如果出差单位不再是半天了,需要删除原半天设置 + String del_2_sql = "delete from kq_timeselection where selectiontype=1 and minimumUnit=2"; + boolean is_2_del = rs.executeUpdate(del_2_sql); + System.out.println("is_2_del:"+is_2_del); + } + + boolean flag = true; + String sql = "update kq_travelRules set minimumUnit=?,proportion=?,computingMode=?,hoursToDay=?,timeselection=? where id=?"; + RecordSet recordSet = new RecordSet(); + flag = recordSet.executeUpdate(sql, minimumUnit, proportion, computingMode, hoursToDay,travel_timeselection, ruleId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + + /*公出规则*/ + String exit_ruleId = "1";//暂为备用字段,规则ID,固定为1 + String exit_name = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(20084,weaver.general.ThreadVarLanguage.getLang())+"";//暂为备用字段,规则名称,目前固定为出差 + int exit_minimumUnit = Util.getIntValue((String) params.get("exit_minimumUnit"), 1);//最小公出单位:1-按天公出、2-按半天公出、3-按小时公出、4-按整天公出 + double exit_proportion = Util.getDoubleValue((String) params.get("exit_proportion"), 8.00);//换算比例(当单位由天、半天、整天切换成小时或者由小时切换成天、半天、整天时,历史数据的转换比例) + int exit_computingMode = Util.getIntValue((String) params.get("exit_computingMode"), 1);//计算公出时长方式:1-按工作日计算公出时长、2-按自然日计算公出时长 + double exit_hoursToDay = Util.getDoubleValue((String) params.get("exit_hoursToDay"), 8.00);//日折算时长 + int exit_timeselection = Util.getIntValue((String) params.get("exit_timeselection"), 1);//半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + + if(exit_minimumUnit != 2){ + RecordSet rs = new RecordSet(); + //如果出差单位不再是半天了,需要删除原半天设置 + String del_2_sql = "delete from kq_timeselection where selectiontype=2 and minimumUnit=2"; + boolean is_2_del = rs.executeUpdate(del_2_sql); + System.out.println("is_2_del:"+is_2_del); + } + + sql = "update kq_exitRules set minimumUnit=?,proportion=?,computingMode=?,hoursToDay=?,timeselection=? where id=?"; + flag = recordSet.executeUpdate(sql, exit_minimumUnit, exit_proportion, exit_computingMode, exit_hoursToDay,exit_timeselection, exit_ruleId); + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } else { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } + }catch (Exception e){ + e.printStackTrace(); + }finally { + KQExitRulesComInfo kqExitRulesComInfo = new KQExitRulesComInfo(); + KQTravelRulesComInfo kqTravelRulesComInfo = new KQTravelRulesComInfo(); + KQAttFlowSetComInfo kqAttFlowSetComInfo = new KQAttFlowSetComInfo(); + + kqExitRulesComInfo.removeCache(); + kqTravelRulesComInfo.removeCache(); + kqAttFlowSetComInfo.removeKQAttFlowSetComInfoCache(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/upgrade/DoUpgrade10Cmd.java b/src/com/engine/kq/cmd/upgrade/DoUpgrade10Cmd.java new file mode 100644 index 0000000..0d2e245 --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/DoUpgrade10Cmd.java @@ -0,0 +1,167 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQOneStopUp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; +import weaver.workflow.workflow.WorkflowRequestComInfo; + +/** + * 历史考勤流程数据升级 + * @author pzy + * + */ +public class DoUpgrade10Cmd extends AbstractCommonCommand>{ + + public DoUpgrade10Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List items = new ArrayList<>(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + try { + String startdate = Util.null2String(params.get("startdate")); + String enddate = Util.null2String(params.get("enddate")); + if(startdate.length() == 0 || enddate.length() ==0 ){ + retmap.put("status", "1"); + retmap.put("items", items); + return retmap; + } + KQOneStopUp kqOneStopUp = new KQOneStopUp(); + kqOneStopUp.clearFlowData(startdate, enddate); + kqOneStopUp.upFlowData(startdate, enddate); + + WorkflowRequestComInfo workflowRequestComInfo = new WorkflowRequestComInfo(); + + Map splitmap = new HashMap(); + List splitList = new ArrayList<>(); + List params = new ArrayList<>(); + String batchSql = " insert into hrm_to_flow_split(splitid,flowtype) values(?,?) "; + + String getsplit_leaveSql = "select distinct requestid,fromdatedb,fromtimedb,todatedb,totimedb,durationdb from kq_flow_split_leave where fromdate >='"+startdate+"' and todate <='"+enddate+"' "; + rs.executeQuery(getsplit_leaveSql); + while (rs.next()){ + String typename = SystemEnv.getHtmlLabelName(83393, user.getLanguage()); + String requestid = rs.getString("requestid"); + String fromdatedb = rs.getString("fromdatedb"); + String fromtimedb = rs.getString("fromtimedb"); + String todatedb = rs.getString("todatedb"); + String totimedb = rs.getString("totimedb"); + String durationdb = rs.getString("durationdb"); + String desc = typename+" "+workflowRequestComInfo.getRequestName(requestid)+" "+fromdatedb+" "+fromtimedb+" "+todatedb+" "+totimedb+" "+durationdb; + splitList.add(desc); + List beanParams = new ArrayList(); + beanParams.add(requestid); + beanParams.add("leave"); + params.add(beanParams); + } + + String getsplit_evectionSql = "select distinct requestid,fromdatedb,fromtimedb,todatedb,totimedb,durationdb from kq_flow_split_evection where fromdate >='"+startdate+"' and todate <='"+enddate+"' "; + rs.executeQuery(getsplit_evectionSql); + while (rs.next()){ + String typename = SystemEnv.getHtmlLabelName(83394, user.getLanguage()); + String requestid = rs.getString("requestid"); + String fromdatedb = rs.getString("fromdatedb"); + String fromtimedb = rs.getString("fromtimedb"); + String todatedb = rs.getString("todatedb"); + String totimedb = rs.getString("totimedb"); + String durationdb = rs.getString("durationdb"); + String desc = typename+" "+workflowRequestComInfo.getRequestName(requestid)+" "+fromdatedb+" "+fromtimedb+" "+todatedb+" "+totimedb+" "+durationdb; + splitList.add(desc); + List beanParams = new ArrayList(); + beanParams.add(requestid); + beanParams.add("evection"); + params.add(beanParams); + } + + String getsplit_outSql = "select distinct requestid,fromdatedb,fromtimedb,todatedb,totimedb,durationdb from kq_flow_split_out where fromdate >='"+startdate+"' and todate <='"+enddate+"' "; + rs.executeQuery(getsplit_outSql); + while (rs.next()){ + String typename = SystemEnv.getHtmlLabelName(83395, user.getLanguage()); + String requestid = rs.getString("requestid"); + String fromdatedb = rs.getString("fromdatedb"); + String fromtimedb = rs.getString("fromtimedb"); + String todatedb = rs.getString("todatedb"); + String totimedb = rs.getString("totimedb"); + String durationdb = rs.getString("durationdb"); + String desc = typename+" "+workflowRequestComInfo.getRequestName(requestid)+" "+fromdatedb+" "+fromtimedb+" "+todatedb+" "+totimedb+" "+durationdb; + splitList.add(desc); + List beanParams = new ArrayList(); + beanParams.add(requestid); + beanParams.add("out"); + params.add(beanParams); + } + + String getsplit_overtimeSql = "select distinct requestid,fromdatedb,fromtimedb,todatedb,totimedb,durationdb from kq_flow_split_overtime where fromdate >='"+startdate+"' and todate <='"+enddate+"' "; + rs.executeQuery(getsplit_overtimeSql); + while (rs.next()){ + String typename = SystemEnv.getHtmlLabelName(83396, user.getLanguage()); + String requestid = rs.getString("requestid"); + String fromdatedb = rs.getString("fromdatedb"); + String fromtimedb = rs.getString("fromtimedb"); + String todatedb = rs.getString("todatedb"); + String totimedb = rs.getString("totimedb"); + String durationdb = rs.getString("durationdb"); + String desc = typename+" "+workflowRequestComInfo.getRequestName(requestid)+" "+fromdatedb+" "+fromtimedb+" "+todatedb+" "+totimedb+" "+durationdb; + splitList.add(desc); + List beanParams = new ArrayList(); + beanParams.add(requestid); + beanParams.add("overtime"); + params.add(beanParams); + } + + String getsplit_otherSql = "select distinct requestid,fromdatedb,fromtimedb,todatedb,totimedb,durationdb from kq_flow_split_other where fromdate >='"+startdate+"' and todate <='"+enddate+"' "; + rs.executeQuery(getsplit_otherSql); + while (rs.next()){ + String typename = SystemEnv.getHtmlLabelName(127655, user.getLanguage()); + String requestid = rs.getString("requestid"); + String fromdatedb = rs.getString("fromdatedb"); + String fromtimedb = rs.getString("fromtimedb"); + String todatedb = rs.getString("todatedb"); + String totimedb = rs.getString("totimedb"); + String durationdb = rs.getString("durationdb"); + String desc = typename+" "+workflowRequestComInfo.getRequestName(requestid)+" "+fromdatedb+" "+fromtimedb+" "+todatedb+" "+totimedb+" "+durationdb; + splitList.add(desc); + List beanParams = new ArrayList(); + beanParams.add(requestid); + beanParams.add("other"); + params.add(beanParams); + } + splitmap.put("label", SystemEnv.getHtmlLabelName(505747, user.getLanguage())); + splitmap.put("status", "1"); + splitmap.put("results", splitList); + items.add(splitmap); + + boolean isOk = rs1.executeBatchSql(batchSql, params); + + + retmap.put("status", "1"); + retmap.put("items", items); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/DoUpgrade12Cmd.java b/src/com/engine/kq/cmd/upgrade/DoUpgrade12Cmd.java new file mode 100644 index 0000000..179821e --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/DoUpgrade12Cmd.java @@ -0,0 +1,78 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQFormatData; +import com.engine.kq.log.KQLog; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.Calendar; +import java.util.HashMap; +import java.util.Map; + +/** + * 考勤报表数据升级 + * @author pzy + * + */ +public class DoUpgrade12Cmd extends AbstractCommonCommand>{ + + public DoUpgrade12Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + KQLog kqLog = new KQLog(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + try { + Calendar cal = DateUtil.getCalendar(); + KQFormatData kqFormatData = new KQFormatData(); + String startdate = Util.null2String(params.get("startdate")); + String enddate = Util.null2String(params.get("enddate")); + if (DateUtil.timeInterval(enddate, startdate) > 0) { + retmap.put("status", "-1"); + return retmap; + } + System.out.println("in"); + String sql = "select id from hrmresource where status in (0,1,2,3)"; + rs1.execute(sql); + while (rs1.next()){ + String resourceid = Util.null2String(rs1.getString("id")); + boolean isEnd = false; + for (String date = startdate; !isEnd; ) { + if (date.equals(enddate)) isEnd = true; + kqLog.info("KQScheduleFormatJob:resourceid:"+resourceid+":date:"+date); + new KQFormatData().formatKqDateByLock(resourceid, date,19); + kqFormatData.formatKqDateByLock(resourceid, date,19); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + } + System.out.println("out"); + + retmap.put("status", "1"); + retmap.put("message", SystemEnv.getHtmlLabelName(505759,user.getLanguage())); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/DoUpgrade1Cmd.java b/src/com/engine/kq/cmd/upgrade/DoUpgrade1Cmd.java new file mode 100644 index 0000000..a497d2d --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/DoUpgrade1Cmd.java @@ -0,0 +1,91 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQOneStopUp; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 一般工作时间升级 + * @author pzy + * + */ +public class DoUpgrade1Cmd extends AbstractCommonCommand>{ + + public DoUpgrade1Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List items = new ArrayList<>(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + try { + + KQOneStopUp kqOneStopUp = new KQOneStopUp(); + kqOneStopUp.clearCommonGroupData(); + kqOneStopUp.upCommonGroupData(); + String groupids = ""; + String groupidSql = "select kqid from hrm_to_kq_group where groupfrom = 'scheduleset'"; + rs.executeQuery(groupidSql); + while (rs.next()){ + String tmp_kqid = rs.getString("kqid"); + groupids += ","+tmp_kqid; + } + if(groupids.length() > 0){ + kqOneStopUp.upOvertimeRule(groupids, user,"scheduleset"); + } + + Map serialmap = new HashMap(); + List serialList = new ArrayList<>(); + Map groupmap = new HashMap(); + List groupList = new ArrayList<>(); + + String getSerialSql = "select * from kq_shiftmanagement where id in( select kqid from hrm_to_kq_serial where serialfrom ='scheduleset')"; + rs.executeQuery(getSerialSql); + while (rs.next()){ + serialList.add(rs.getString("serial")); + } + serialmap.put("label", SystemEnv.getHtmlLabelName(10000838,weaver.general.Util.getIntValue(user.getLanguage()))); + serialmap.put("status", "1"); + serialmap.put("results", serialList); + items.add(serialmap); + + String getGroupSql = "select * from kq_group where id in(select kqid from hrm_to_kq_group where groupfrom = 'scheduleset')"; + rs1.executeQuery(getGroupSql); + while (rs1.next()){ + groupList.add(rs1.getString("groupname")); + } + groupmap.put("label", SystemEnv.getHtmlLabelName(10000839,weaver.general.Util.getIntValue(user.getLanguage()))); + groupmap.put("status", "1"); + groupmap.put("results", groupList); + items.add(groupmap); + + retmap.put("status", "1"); + retmap.put("items", items); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/DoUpgrade2Cmd.java b/src/com/engine/kq/cmd/upgrade/DoUpgrade2Cmd.java new file mode 100644 index 0000000..b9d698f --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/DoUpgrade2Cmd.java @@ -0,0 +1,90 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQOneStopUp; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 排班设置升级 + * @author pzy + * + */ +public class DoUpgrade2Cmd extends AbstractCommonCommand>{ + + public DoUpgrade2Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List items = new ArrayList<>(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + try { + KQOneStopUp kqOneStopUp = new KQOneStopUp(); + kqOneStopUp.clearScheduleGroupData(); + kqOneStopUp.upScheduleGroupData(); + String groupids = ""; + String groupidSql = "select kqid from hrm_to_kq_group where groupfrom = 'shiftset'"; + rs.executeQuery(groupidSql); + while (rs.next()){ + String tmp_kqid = rs.getString("kqid"); + groupids += ","+tmp_kqid; + } + if(groupids.length() > 0){ + kqOneStopUp.upOvertimeRule(groupids, user,"shiftset"); + } + + Map serialmap = new HashMap(); + List serialList = new ArrayList<>(); + Map groupmap = new HashMap(); + List groupList = new ArrayList<>(); + + String getSerialSql = "select * from kq_shiftmanagement where id in( select kqid from hrm_to_kq_serial where serialfrom ='shiftset')"; + rs.executeQuery(getSerialSql); + while (rs.next()){ + serialList.add(rs.getString("serial")); + } + serialmap.put("label", SystemEnv.getHtmlLabelName(10000838,weaver.general.Util.getIntValue(user.getLanguage()))); + serialmap.put("status", "1"); + serialmap.put("results", serialList); + items.add(serialmap); + + String getGroupSql = "select * from kq_group where id in(select kqid from hrm_to_kq_group where groupfrom = 'shiftset')"; + rs1.executeQuery(getGroupSql); + while (rs1.next()){ + groupList.add(rs1.getString("groupname")); + } + groupmap.put("label", SystemEnv.getHtmlLabelName(10000839,weaver.general.Util.getIntValue(user.getLanguage()))); + groupmap.put("status", "1"); + groupmap.put("results", groupList); + items.add(groupmap); + + retmap.put("status", "1"); + retmap.put("items", items); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/DoUpgrade3Cmd.java b/src/com/engine/kq/cmd/upgrade/DoUpgrade3Cmd.java new file mode 100644 index 0000000..625f6eb --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/DoUpgrade3Cmd.java @@ -0,0 +1,67 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQOneStopUp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 请假类型升级 + * @author pzy + * + */ +public class DoUpgrade3Cmd extends AbstractCommonCommand>{ + + public DoUpgrade3Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List items = new ArrayList<>(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + try { + KQOneStopUp kqOneStopUp = new KQOneStopUp(); + kqOneStopUp.clearLeaveRule(); + kqOneStopUp.upLeaveRule(); + + Map leavemap = new HashMap(); + List leaveList = new ArrayList<>(); + + String getLeaveSql = "select * from kq_LeaveRules where id in(select kqid from hrm_to_kq_LeaveRules) "; + rs.executeQuery(getLeaveSql); + while (rs.next()){ + leaveList.add(rs.getString("leavename")); + } + leavemap.put("label", SystemEnv.getHtmlLabelName(10000840,weaver.general.Util.getIntValue(user.getLanguage()))); + leavemap.put("status", "1"); + leavemap.put("results", leaveList); + items.add(leavemap); + + retmap.put("status", "1"); + retmap.put("items", items); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/DoUpgrade4Cmd.java b/src/com/engine/kq/cmd/upgrade/DoUpgrade4Cmd.java new file mode 100644 index 0000000..9d5c168 --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/DoUpgrade4Cmd.java @@ -0,0 +1,73 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQOneStopUp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 工作日期调整升级 + * @author pzy + * + */ +public class DoUpgrade4Cmd extends AbstractCommonCommand>{ + + public DoUpgrade4Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List items = new ArrayList<>(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + try { + KQOneStopUp kqOneStopUp = new KQOneStopUp(); + kqOneStopUp.clearPub(); + kqOneStopUp.upPub(); + + Map pubmap = new HashMap(); + List pubList = new ArrayList<>(); + + String getPubSql = "select * from KQ_HOLIDAYSET where id in(select kqid from hrm_to_kq_pub) "; + rs.executeQuery(getPubSql); + while (rs.next()){ + String holidaydate = rs.getString("holidaydate"); + String holidaydesc = rs.getString("holidaydesc"); + String changetype = rs.getString("changetype"); +// 1-公众假日、2-调配工作日、3-调配休息日 + String changetypeDesc = "1".equals(changetype)?"公众假日":("2".equals(changetype)?"调配工作日":"调配休息日"); + String desc = holidaydate+" "+holidaydesc+"("+changetypeDesc+")"; + pubList.add(desc); + } + pubmap.put("label", SystemEnv.getHtmlLabelName(10000841,weaver.general.Util.getIntValue(user.getLanguage()))); + pubmap.put("status", "1"); + pubmap.put("results", pubList); + items.add(pubmap); + + retmap.put("status", "1"); + retmap.put("items", items); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/DoUpgrade5Cmd.java b/src/com/engine/kq/cmd/upgrade/DoUpgrade5Cmd.java new file mode 100644 index 0000000..0d1a2be --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/DoUpgrade5Cmd.java @@ -0,0 +1,79 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQOneStopUp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +/** + * 年假数据升级 + * @author pzy + * + */ +public class DoUpgrade5Cmd extends AbstractCommonCommand>{ + + public DoUpgrade5Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List items = new ArrayList<>(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + try { + ResourceComInfo rci = new ResourceComInfo(); + SubCompanyComInfo sci = new SubCompanyComInfo(); + DepartmentComInfo dci = new DepartmentComInfo(); + KQOneStopUp kqOneStopUp = new KQOneStopUp(); + kqOneStopUp.clearBalance("-6"); + kqOneStopUp.upAnnual(); + + Map annualmap = new HashMap(); + List annualList = new ArrayList<>(); + + String getAnnualSql = "select* from kq_BalanceOfLeave where leaverulesid = -6 "; + rs.executeQuery(getAnnualSql); + while (rs.next()){ + String resourceid = rs.getString("resourceid"); + String lastname = rci.getLastname(resourceid); + String subname = sci.getSubCompanyname(rci.getSubCompanyID(resourceid)); + String deptname = dci.getDepartmentname(rci.getDepartmentID(resourceid)); + String extraamount = rs.getString("extraamount"); + String desc = lastname+" "+subname+" "+deptname+" "+extraamount; + annualList.add(desc); + } + annualmap.put("label", SystemEnv.getHtmlLabelName(10000842,weaver.general.Util.getIntValue(user.getLanguage()))); + annualmap.put("status", "1"); + annualmap.put("results", annualList); + items.add(annualmap); + + retmap.put("status", "1"); + retmap.put("items", items); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/DoUpgrade6Cmd.java b/src/com/engine/kq/cmd/upgrade/DoUpgrade6Cmd.java new file mode 100644 index 0000000..c0c3064 --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/DoUpgrade6Cmd.java @@ -0,0 +1,86 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQOneStopUp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +/** + * 带薪假数据升级 + * @author pzy + * + */ +public class DoUpgrade6Cmd extends AbstractCommonCommand>{ + + public DoUpgrade6Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List items = new ArrayList<>(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + try { + ResourceComInfo rci = new ResourceComInfo(); + SubCompanyComInfo sci = new SubCompanyComInfo(); + DepartmentComInfo dci = new DepartmentComInfo(); + KQOneStopUp kqOneStopUp = new KQOneStopUp(); + String sql = "select distinct leavetype from hrmpslmanagement where status = 1"; + if (rs.getDBType().equalsIgnoreCase("sqlserver") + || rs.getDBType().equalsIgnoreCase("mysql")) { + sql += " and (leavetype is not null and leavetype<>'')"; + } else { + sql += " and (leavetype is not null)"; + } + kqOneStopUp.clearBalance(sql); + kqOneStopUp.upPaid(); + + Map paidmap = new HashMap(); + List paidList = new ArrayList<>(); + + String getPaidSql = "select* from kq_BalanceOfLeave where leaverulesid in(select distinct leavetype from hrmpslmanagement where status = 1) order by leaverulesid "; + rs.executeQuery(getPaidSql); + while (rs.next()){ + String resourceid = rs.getString("resourceid"); + String lastname = rci.getLastname(resourceid); + String subname = sci.getSubCompanyname(rci.getSubCompanyID(resourceid)); + String deptname = dci.getDepartmentname(rci.getDepartmentID(resourceid)); + String extraamount = rs.getString("extraamount"); + String desc = lastname+" "+subname+" "+deptname+" "+extraamount; + paidList.add(desc); + } + paidmap.put("label", SystemEnv.getHtmlLabelName(10000843,weaver.general.Util.getIntValue(user.getLanguage()))); + paidmap.put("status", "1"); + paidmap.put("results", paidList); + items.add(paidmap); + + retmap.put("status", "1"); + retmap.put("items", items); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/DoUpgrade7Cmd.java b/src/com/engine/kq/cmd/upgrade/DoUpgrade7Cmd.java new file mode 100644 index 0000000..1e61c2c --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/DoUpgrade7Cmd.java @@ -0,0 +1,79 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQOneStopUp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +/** + * 调休数据升级 + * @author pzy + * + */ +public class DoUpgrade7Cmd extends AbstractCommonCommand>{ + + public DoUpgrade7Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List items = new ArrayList<>(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + try { + ResourceComInfo rci = new ResourceComInfo(); + SubCompanyComInfo sci = new SubCompanyComInfo(); + DepartmentComInfo dci = new DepartmentComInfo(); + KQOneStopUp kqOneStopUp = new KQOneStopUp(); + kqOneStopUp.clearBalance("-13"); + kqOneStopUp.upOvertimePiad(); + + Map overtimepaidmap = new HashMap(); + List overtimepaidList = new ArrayList<>(); + + String getOvertimepaidSql = "select* from kq_BalanceOfLeave where leaverulesid in(-13) order by leaverulesid "; + rs.executeQuery(getOvertimepaidSql); + while (rs.next()){ + String resourceid = rs.getString("resourceid"); + String lastname = rci.getLastname(resourceid); + String subname = sci.getSubCompanyname(rci.getSubCompanyID(resourceid)); + String deptname = dci.getDepartmentname(rci.getDepartmentID(resourceid)); + String extraamount = rs.getString("extraamount"); + String desc = lastname+" "+subname+" "+deptname+" "+extraamount; + overtimepaidList.add(desc); + } + overtimepaidmap.put("label", SystemEnv.getHtmlLabelName(10000844,weaver.general.Util.getIntValue(user.getLanguage()))); + overtimepaidmap.put("status", "1"); + overtimepaidmap.put("results", overtimepaidList); + items.add(overtimepaidmap); + + retmap.put("status", "1"); + retmap.put("items", items); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/DoUpgrade8Cmd.java b/src/com/engine/kq/cmd/upgrade/DoUpgrade8Cmd.java new file mode 100644 index 0000000..0e4c96d --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/DoUpgrade8Cmd.java @@ -0,0 +1,70 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQOneStopUp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; +import weaver.workflow.workflow.WorkflowComInfo; + +/** + * 考勤流程设置升级 + * @author pzy + * + */ +public class DoUpgrade8Cmd extends AbstractCommonCommand>{ + + public DoUpgrade8Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List items = new ArrayList<>(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + try { + WorkflowComInfo workflowComInfo = new WorkflowComInfo(); + KQOneStopUp kqOneStopUp = new KQOneStopUp(); + kqOneStopUp.clearAttSet(); + kqOneStopUp.upAttSet(); + + Map attSetmap = new HashMap(); + List attSetList = new ArrayList<>(); + + String getAttSetSql = "select* from kq_ATT_PROC_SET where id in(select kqid from hrm_to_attSet) "; + rs.executeQuery(getAttSetSql); + while (rs.next()){ + String workflowname = workflowComInfo.getWorkflowname(rs.getString("field001")); + attSetList.add(workflowname); + } + attSetmap.put("label", SystemEnv.getHtmlLabelName(10000845,weaver.general.Util.getIntValue(user.getLanguage()))); + attSetmap.put("status", "1"); + attSetmap.put("results", attSetList); + items.add(attSetmap); + + retmap.put("status", "1"); + retmap.put("items", items); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/DoUpgrade9Cmd.java b/src/com/engine/kq/cmd/upgrade/DoUpgrade9Cmd.java new file mode 100644 index 0000000..8fcb6eb --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/DoUpgrade9Cmd.java @@ -0,0 +1,62 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQOneStopUp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 外部集成考勤设置升级 + * @author pzy + * + */ +public class DoUpgrade9Cmd extends AbstractCommonCommand>{ + + public DoUpgrade9Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + try { + KQOneStopUp kqOneStopUp = new KQOneStopUp(); +// kqOneStopUp.upAttSet(); + + List signSetList = new ArrayList<>(); + + String getSignSetSql = "select* from HrmScheduleSignSet "; + rs.executeQuery(getSignSetSql); + while (rs.next()){ + Map signSetMap = new HashMap<>(); + signSetMap.put("datasourceid",rs.getString("datasourceid")); + signSetMap.put("tablename",rs.getString("tablename")); + signSetList.add(signSetMap); + } + retmap.put("status", "1"); + retmap.put("data", signSetList); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/GetTreeTabsCmd.java b/src/com/engine/kq/cmd/upgrade/GetTreeTabsCmd.java new file mode 100644 index 0000000..e391f6c --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/GetTreeTabsCmd.java @@ -0,0 +1,111 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取左侧Tab信息 + * @author pzy + * + */ +public class GetTreeTabsCmd extends AbstractCommonCommand>{ + + public GetTreeTabsCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try { + + List> tabs = new ArrayList>(); + Map tab = null; + + tab = new HashMap(); + tab.put("key", KQUpgradeTabEnum.Upgrade1.getTabtype()); + tab.put("title", SystemEnv.getHtmlLabelName(KQUpgradeTabEnum.Upgrade1.getTablabel(),user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", KQUpgradeTabEnum.Upgrade2.getTabtype()); + tab.put("title", SystemEnv.getHtmlLabelName(KQUpgradeTabEnum.Upgrade2.getTablabel(),user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", KQUpgradeTabEnum.Upgrade3.getTabtype()); + tab.put("title", SystemEnv.getHtmlLabelName(KQUpgradeTabEnum.Upgrade3.getTablabel(),user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", KQUpgradeTabEnum.Upgrade4.getTabtype()); + tab.put("title", SystemEnv.getHtmlLabelName(KQUpgradeTabEnum.Upgrade4.getTablabel(),user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", KQUpgradeTabEnum.Upgrade5.getTabtype()); + tab.put("title", SystemEnv.getHtmlLabelName(KQUpgradeTabEnum.Upgrade5.getTablabel(),user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", KQUpgradeTabEnum.Upgrade6.getTabtype()); + tab.put("title", SystemEnv.getHtmlLabelName(KQUpgradeTabEnum.Upgrade6.getTablabel(),user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", KQUpgradeTabEnum.Upgrade7.getTabtype()); + tab.put("title", SystemEnv.getHtmlLabelName(KQUpgradeTabEnum.Upgrade7.getTablabel(),user.getLanguage())); + tabs.add(tab); + + tab = new HashMap(); + tab.put("key", KQUpgradeTabEnum.Upgrade8.getTabtype()); + tab.put("title", SystemEnv.getHtmlLabelName(KQUpgradeTabEnum.Upgrade8.getTablabel(),user.getLanguage())); + tabs.add(tab); + +// tab = new HashMap(); +// tab.put("key", KQUpgradeTabEnum.Upgrade9.getTabtype()); +// tab.put("title", SystemEnv.getHtmlLabelName(KQUpgradeTabEnum.Upgrade9.getTablabel(),user.getLanguage())); +// tabs.add(tab); + + tab = new HashMap(); + tab.put("key", KQUpgradeTabEnum.Upgrade10.getTabtype()); + tab.put("title", SystemEnv.getHtmlLabelName(KQUpgradeTabEnum.Upgrade10.getTablabel(),user.getLanguage())); + tabs.add(tab); + +// tab = new HashMap(); +// tab.put("key", KQUpgradeTabEnum.Upgrade11.getTabtype()); +// tab.put("title", SystemEnv.getHtmlLabelName(KQUpgradeTabEnum.Upgrade11.getTablabel(),user.getLanguage())); +// tabs.add(tab); + + tab = new HashMap(); + tab.put("key", KQUpgradeTabEnum.Upgrade12.getTabtype()); + tab.put("title", SystemEnv.getHtmlLabelName(KQUpgradeTabEnum.Upgrade12.getTablabel(),user.getLanguage())); + tabs.add(tab); + + retmap.put("status", "1"); + retmap.put("tabs", tabs); + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/GetUpgrade10Cmd.java b/src/com/engine/kq/cmd/upgrade/GetUpgrade10Cmd.java new file mode 100644 index 0000000..22346c8 --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/GetUpgrade10Cmd.java @@ -0,0 +1,132 @@ +package com.engine.kq.cmd.upgrade; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.attendance.manager.HrmAttProcSetManager; +import weaver.systeminfo.SystemEnv; + +/** + * 历史考勤流程数据升级 准备 + * @author pzy + * + */ +public class GetUpgrade10Cmd extends AbstractCommonCommand>{ + + public GetUpgrade10Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + int signSetCntInt = 0; + Map signMap = new HashMap<>(); + List itemList = new ArrayList(); + KQUpgradeTabEnum kqUpgradeTabEnum = KQUpgradeTabEnum.Upgrade10; + try { +// if(type.equalsIgnoreCase(kqUpgradeTabEnum.getTabtype())){ +// String attSql = "select * from hrm_att_proc_set"; +// rs.executeQuery(attSql); +// while (rs.next()){ +// String flowtype = rs.getString("field006"); +// String flowsql = getFlowSql(flowtype); +// if(flowsql.length() > 0){ +// rs1.executeQuery(flowsql); +// int tmpSignCnt = rs1.getCounts(); +// signSetCntInt += tmpSignCnt; +// if(signMap.containsKey(flowtype)){ +// int tmpCnt = signMap.get(flowtype); +// signMap.put(flowtype, (tmpCnt+tmpSignCnt)); +// }else{ +// signMap.put(flowtype, (tmpSignCnt)); +// } +// } +// } +// } + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("startdate"); + hrmFieldBean.setFieldlabel("740"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("enddate"); + hrmFieldBean.setFieldlabel("740"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + } catch (Exception e) { + writeLog(e); + } +// retmap.put("count", UpgradeUtil.formatMsg(kqUpgradeTabEnum, user.getLanguage(), signSetCntInt+"") ); +// retmap.put("title", SystemEnv.getHtmlLabelName(kqUpgradeTabEnum.getTablabel(), user.getLanguage())+SystemEnv.getHtmlLabelName(17530, user.getLanguage())); + retmap.put("itemList", itemList); + retmap.put("status", "1"); + retmap.put("title", SystemEnv.getHtmlLabelName(17530,user.getLanguage())); + retmap.put("tipMessage", SystemEnv.getHtmlLabelName(547877,user.getLanguage())); + return retmap; + } + + private String getFlowSql(String flowtype) { + int type = Util.getIntValue(flowtype); + Map paramMap = new HashMap(); + String fromDate = ""; + String toDate = ""; + String _fromdate = "fromDate", _fromtime = "fromTime", _todate = "toDate", _totime = "toTime"; + switch (flowtype) { + case "0"://请假 + break; + case "3"://加班 + _fromdate = "fromdate"; + _fromtime = "fromtime"; + _todate = "tilldate"; + _totime = "tilltime"; + paramMap.put("oType", " and t.otype in ('0', '1')"); + break; + } +// String paramDate = " and (t." + _fromdate + " between '" + fromDate + "' and '" + toDate + "' or t." + _todate + " between '" + fromDate + "' and '" + toDate + "' or '" + fromDate + "' between t." + _fromdate + " and t." + _todate + " or '" + toDate + "' between t." + _fromdate + " and t." + _todate + ")"; +// if(StringUtil.isNotNull(fromDate) && StringUtil.isNotNull(toDate)) paramMap.put("fromDate", paramDate); +// else if(StringUtil.isNotNull(fromDate)) paramMap.put("fromDate", " and (t." + _fromdate + " >= '" + fromDate + "' or '" + fromDate + "' between t." + _fromdate + " and t." + _todate + ")"); +// else if(StringUtil.isNotNull(toDate)) paramMap.put("toDate", " and (t." + _todate + " <= '" + toDate + "' or '" + toDate + "' between t." + _fromdate + " and t." + _todate + ")"); + paramMap.put("status", " and c.status in (0,1,2,3)"); + String sql = new HrmAttProcSetManager().getSQLByField006(type, paramMap, true, true); + return sql; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/GetUpgrade12Cmd.java b/src/com/engine/kq/cmd/upgrade/GetUpgrade12Cmd.java new file mode 100644 index 0000000..7f8d0ac --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/GetUpgrade12Cmd.java @@ -0,0 +1,84 @@ +package com.engine.kq.cmd.upgrade; + +import com.api.browser.bean.SearchConditionItem; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 考勤报表数据升级 准备 + * @author pzy + * + */ +public class GetUpgrade12Cmd extends AbstractCommonCommand>{ + + public GetUpgrade12Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + RecordSet rs = new RecordSet(); + String signSetCnt = "0"; + List itemList = new ArrayList(); + KQUpgradeTabEnum kqUpgradeTabEnum = KQUpgradeTabEnum.Upgrade12; + try { + if(type.equalsIgnoreCase(kqUpgradeTabEnum.getTabtype())){ + } + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("startdate"); + hrmFieldBean.setFieldlabel("740"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("enddate"); + hrmFieldBean.setFieldlabel("740"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setRules("required|string"); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemList.add(searchConditionItem); + } catch (Exception e) { + writeLog(e); + } +// retmap.put("count", UpgradeUtil.formatMsg(kqUpgradeTabEnum, user.getLanguage(), signSetCnt) ); +// retmap.put("title", SystemEnv.getHtmlLabelName(kqUpgradeTabEnum.getTablabel(), user.getLanguage())+SystemEnv.getHtmlLabelName(17530, user.getLanguage())); + retmap.put("itemList", itemList); + retmap.put("status", "1"); + retmap.put("title", SystemEnv.getHtmlLabelName(17530,user.getLanguage())); + retmap.put("tipMessage", SystemEnv.getHtmlLabelName(547877,user.getLanguage())); + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/GetUpgrade12DataCmd.java b/src/com/engine/kq/cmd/upgrade/GetUpgrade12DataCmd.java new file mode 100644 index 0000000..a90b5f2 --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/GetUpgrade12DataCmd.java @@ -0,0 +1,55 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQFormatJob; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 获取考考勤报表剩余数据 + * @author pzy + * + */ +public class GetUpgrade12DataCmd extends AbstractCommonCommand>{ + + public GetUpgrade12DataCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + String startdate = Util.null2String(params.get("startdate")); + String enddate = Util.null2String(params.get("enddate")); + RecordSet rs = new RecordSet(); + try { + String sql = "select *from kq_format_pool where status in (0) and kqdate between '"+startdate+"' and '"+enddate+"'"; + rs.executeQuery(sql); + retmap.put("status", "1"); + retmap.put("data", rs.getCounts()); + + } catch (Exception e) { + writeLog(e); + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + } + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/GetUpgrade1Cmd.java b/src/com/engine/kq/cmd/upgrade/GetUpgrade1Cmd.java new file mode 100644 index 0000000..35ca4dd --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/GetUpgrade1Cmd.java @@ -0,0 +1,56 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 一般工作时间升级 准备 + * @author pzy + * + */ +public class GetUpgrade1Cmd extends AbstractCommonCommand>{ + + public GetUpgrade1Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + RecordSet rs = new RecordSet(); + String scheduleCnt = "0"; + KQUpgradeTabEnum kqUpgradeTabEnum = KQUpgradeTabEnum.Upgrade1; + try { + if(type.equalsIgnoreCase(kqUpgradeTabEnum.getTabtype())){ + String scheduleSql = "select count(1) from hrmschedule "; + rs.executeQuery(scheduleSql); + if(rs.next()){ + scheduleCnt = ""+rs.getInt(1); + } + } + } catch (Exception e) { + writeLog(e); + } + retmap.put("count", UpgradeUtil.formatMsg(kqUpgradeTabEnum, user.getLanguage(), scheduleCnt) ); + retmap.put("title", SystemEnv.getHtmlLabelName(17530,user.getLanguage())); + retmap.put("status", "1"); + retmap.put("tipMessage", SystemEnv.getHtmlLabelName(547877,user.getLanguage())); + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/GetUpgrade2Cmd.java b/src/com/engine/kq/cmd/upgrade/GetUpgrade2Cmd.java new file mode 100644 index 0000000..6d58412 --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/GetUpgrade2Cmd.java @@ -0,0 +1,62 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 排班设置升级 准备 + * @author pzy + * + */ +public class GetUpgrade2Cmd extends AbstractCommonCommand>{ + + public GetUpgrade2Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + RecordSet rs = new RecordSet(); + String worktimeCnt = "0"; + String shiftsCnt = "0"; + KQUpgradeTabEnum kqUpgradeTabEnum = KQUpgradeTabEnum.Upgrade2; + try { + if(type.equalsIgnoreCase(kqUpgradeTabEnum.getTabtype())){ + String worktimeSql = " select count(1) from hrm_schedule_worktime where delflag=0 "; + rs.executeQuery(worktimeSql); + if(rs.next()){ + worktimeCnt = ""+rs.getInt(1); + } + String shiftsSql = " select count(1) from hrm_schedule_shifts_set where delflag=0 "; + rs.executeQuery(shiftsSql); + if(rs.next()){ + shiftsCnt = ""+rs.getInt(1); + } + } + } catch (Exception e) { + writeLog(e); + } + retmap.put("count", UpgradeUtil.formatMsg(kqUpgradeTabEnum, user.getLanguage(), worktimeCnt, shiftsCnt) ); + retmap.put("title", SystemEnv.getHtmlLabelName(17530,user.getLanguage())); + retmap.put("status", "1"); + retmap.put("tipMessage", SystemEnv.getHtmlLabelName(547877,user.getLanguage())); + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/GetUpgrade3Cmd.java b/src/com/engine/kq/cmd/upgrade/GetUpgrade3Cmd.java new file mode 100644 index 0000000..271a76f --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/GetUpgrade3Cmd.java @@ -0,0 +1,56 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 请假类型升级 准备 + * @author pzy + * + */ +public class GetUpgrade3Cmd extends AbstractCommonCommand>{ + + public GetUpgrade3Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + RecordSet rs = new RecordSet(); + String leavetypeCnt = "0"; + KQUpgradeTabEnum kqUpgradeTabEnum = KQUpgradeTabEnum.Upgrade3; + try { + if(type.equalsIgnoreCase(kqUpgradeTabEnum.getTabtype())){ + String leavetypeSql = " select count(1) from hrmleavetypecolor "; + rs.executeQuery(leavetypeSql); + if(rs.next()){ + leavetypeCnt = ""+rs.getInt(1); + } + } + } catch (Exception e) { + writeLog(e); + } + retmap.put("count", UpgradeUtil.formatMsg(kqUpgradeTabEnum, user.getLanguage(), leavetypeCnt) ); + retmap.put("title", SystemEnv.getHtmlLabelName(17530,user.getLanguage())); + retmap.put("status", "1"); + retmap.put("tipMessage", SystemEnv.getHtmlLabelName(547877,user.getLanguage())); + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/GetUpgrade4Cmd.java b/src/com/engine/kq/cmd/upgrade/GetUpgrade4Cmd.java new file mode 100644 index 0000000..28688ad --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/GetUpgrade4Cmd.java @@ -0,0 +1,56 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 工作日期调整升级 准备 + * @author pzy + * + */ +public class GetUpgrade4Cmd extends AbstractCommonCommand>{ + + public GetUpgrade4Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + RecordSet rs = new RecordSet(); + String holidayCnt = "0"; + KQUpgradeTabEnum kqUpgradeTabEnum = KQUpgradeTabEnum.Upgrade4; + try { + if(type.equalsIgnoreCase(kqUpgradeTabEnum.getTabtype())){ + String holidaySql = " select count(1) from hrmpubholiday "; + rs.executeQuery(holidaySql); + if(rs.next()){ + holidayCnt = ""+rs.getInt(1); + } + } + } catch (Exception e) { + writeLog(e); + } + retmap.put("count", UpgradeUtil.formatMsg(kqUpgradeTabEnum, user.getLanguage(), holidayCnt) ); + retmap.put("title", SystemEnv.getHtmlLabelName(17530,user.getLanguage())); + retmap.put("status", "1"); + retmap.put("tipMessage", SystemEnv.getHtmlLabelName(547877,user.getLanguage())); + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/GetUpgrade5Cmd.java b/src/com/engine/kq/cmd/upgrade/GetUpgrade5Cmd.java new file mode 100644 index 0000000..95e7d63 --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/GetUpgrade5Cmd.java @@ -0,0 +1,56 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 年假数据升级 准备 + * @author pzy + * + */ +public class GetUpgrade5Cmd extends AbstractCommonCommand>{ + + public GetUpgrade5Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + RecordSet rs = new RecordSet(); + String annualCnt = "0"; + KQUpgradeTabEnum kqUpgradeTabEnum = KQUpgradeTabEnum.Upgrade5; + try { + if(type.equalsIgnoreCase(kqUpgradeTabEnum.getTabtype())){ + String annualSql = " select count(1) from hrmannualmanagement where status = 1 "; + rs.executeQuery(annualSql); + if(rs.next()){ + annualCnt = ""+rs.getInt(1); + } + } + } catch (Exception e) { + writeLog(e); + } + retmap.put("count", UpgradeUtil.formatMsg(kqUpgradeTabEnum, user.getLanguage(), annualCnt) ); + retmap.put("title", SystemEnv.getHtmlLabelName(17530,user.getLanguage())); + retmap.put("status", "1"); + retmap.put("tipMessage", SystemEnv.getHtmlLabelName(547877,user.getLanguage())); + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/GetUpgrade6Cmd.java b/src/com/engine/kq/cmd/upgrade/GetUpgrade6Cmd.java new file mode 100644 index 0000000..69fd12e --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/GetUpgrade6Cmd.java @@ -0,0 +1,56 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 带薪假数据升级 准备 + * @author pzy + * + */ +public class GetUpgrade6Cmd extends AbstractCommonCommand>{ + + public GetUpgrade6Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + RecordSet rs = new RecordSet(); + String pslCnt = "0"; + KQUpgradeTabEnum kqUpgradeTabEnum = KQUpgradeTabEnum.Upgrade6; + try { + if(type.equalsIgnoreCase(kqUpgradeTabEnum.getTabtype())){ + String pslSql = " select count(1) from hrmpslmanagement where status = 1 and leavetype in(select field004 from hrmleavetypecolor where ispaidleave=1) "; + rs.executeQuery(pslSql); + if(rs.next()){ + pslCnt = ""+rs.getInt(1); + } + } + } catch (Exception e) { + writeLog(e); + } + retmap.put("count", UpgradeUtil.formatMsg(kqUpgradeTabEnum, user.getLanguage(), pslCnt) ); + retmap.put("title", SystemEnv.getHtmlLabelName(17530,user.getLanguage())); + retmap.put("status", "1"); + retmap.put("tipMessage", SystemEnv.getHtmlLabelName(547877,user.getLanguage())); + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/GetUpgrade7Cmd.java b/src/com/engine/kq/cmd/upgrade/GetUpgrade7Cmd.java new file mode 100644 index 0000000..67a4e97 --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/GetUpgrade7Cmd.java @@ -0,0 +1,77 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.attendance.domain.HrmPaidLeaveTime; +import weaver.hrm.attendance.manager.HrmPaidLeaveTimeManager; +import weaver.systeminfo.SystemEnv; + +/** + * 调休数据升级 准备 + * @author pzy + * + */ +public class GetUpgrade7Cmd extends AbstractCommonCommand>{ + + public GetUpgrade7Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + RecordSet rs = new RecordSet(); + String paidCnt = "0"; + KQUpgradeTabEnum kqUpgradeTabEnum = KQUpgradeTabEnum.Upgrade7; + try { + if(type.equalsIgnoreCase(kqUpgradeTabEnum.getTabtype())){ + String firstdate = DateUtil.getFirstDayOfYear(DateUtil.getCurrentDate()); + String enddate = DateUtil.getLastDayOfYear(DateUtil.getCurrentDate()); + HrmPaidLeaveTimeManager paidLeaveTimeManager = new HrmPaidLeaveTimeManager(); + Map otherparams = new HashMap<>(); + otherparams.put("fromdate", firstdate); + otherparams.put("enddate", enddate); + otherparams.put("sql_field001", " and field001 >0 "); + Map paramMap = new HashMap(); + Iterator it = otherparams.entrySet().iterator(); + while(it.hasNext()){ + Map.Entry entry = (Map.Entry) it.next(); + paramMap.put((String)entry.getKey(), (String)entry.getValue()); + } + List tList = paidLeaveTimeManager.find(paramMap); + + String paidSql = " select count(1) from hrm_paid_leave "; + rs.executeQuery(paidSql); + if(rs.next()){ + paidCnt = ""+rs.getInt(1); + } + paidCnt = tList != null && !tList.isEmpty() ? ""+tList.size() : "0"; + } + } catch (Exception e) { + writeLog(e); + } + retmap.put("count", UpgradeUtil.formatMsg(kqUpgradeTabEnum, user.getLanguage(), paidCnt) ); + retmap.put("title", SystemEnv.getHtmlLabelName(17530,user.getLanguage())); + retmap.put("status", "1"); + retmap.put("tipMessage", SystemEnv.getHtmlLabelName(547877,user.getLanguage())); + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/GetUpgrade8Cmd.java b/src/com/engine/kq/cmd/upgrade/GetUpgrade8Cmd.java new file mode 100644 index 0000000..db31646 --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/GetUpgrade8Cmd.java @@ -0,0 +1,56 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 考勤流程设置升级 准备 + * @author pzy + * + */ +public class GetUpgrade8Cmd extends AbstractCommonCommand>{ + + public GetUpgrade8Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + RecordSet rs = new RecordSet(); + String attCnt = "0"; + KQUpgradeTabEnum kqUpgradeTabEnum = KQUpgradeTabEnum.Upgrade8; + try { + if(type.equalsIgnoreCase(kqUpgradeTabEnum.getTabtype())){ + String attSql = " select count(1) from hrm_att_proc_set "; + rs.executeQuery(attSql); + if(rs.next()){ + attCnt = ""+rs.getInt(1); + } + } + } catch (Exception e) { + writeLog(e); + } + retmap.put("count", UpgradeUtil.formatMsg(kqUpgradeTabEnum, user.getLanguage(), attCnt) ); + retmap.put("title", SystemEnv.getHtmlLabelName(17530,user.getLanguage())); + retmap.put("status", "1"); + retmap.put("tipMessage", SystemEnv.getHtmlLabelName(547877,user.getLanguage())); + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/GetUpgrade9Cmd.java b/src/com/engine/kq/cmd/upgrade/GetUpgrade9Cmd.java new file mode 100644 index 0000000..8f6156f --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/GetUpgrade9Cmd.java @@ -0,0 +1,56 @@ +package com.engine.kq.cmd.upgrade; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * 外部集成考勤设置升级 准备 + * @author pzy + * + */ +public class GetUpgrade9Cmd extends AbstractCommonCommand>{ + + public GetUpgrade9Cmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + String type = Util.null2String((String)params.get("type")); + RecordSet rs = new RecordSet(); + String signSetCnt = "0"; + KQUpgradeTabEnum kqUpgradeTabEnum = KQUpgradeTabEnum.Upgrade9; + try { + if(type.equalsIgnoreCase(kqUpgradeTabEnum.getTabtype())){ + String signSetSql = " select count(1) from HrmScheduleSignSet "; + rs.executeQuery(signSetSql); + if(rs.next()){ + signSetCnt = ""+rs.getInt(1); + } + } + } catch (Exception e) { + writeLog(e); + } + retmap.put("count", UpgradeUtil.formatMsg(kqUpgradeTabEnum, user.getLanguage(), signSetCnt) ); + retmap.put("title", SystemEnv.getHtmlLabelName(17530,user.getLanguage())); + retmap.put("status", "1"); + retmap.put("tipMessage", SystemEnv.getHtmlLabelName(547877,user.getLanguage())); + return retmap; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/KQUpgradeTabEnum.java b/src/com/engine/kq/cmd/upgrade/KQUpgradeTabEnum.java new file mode 100644 index 0000000..082847f --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/KQUpgradeTabEnum.java @@ -0,0 +1,112 @@ +package com.engine.kq.cmd.upgrade; + +/** + * 考勤数据升级类型枚举 + */ +public enum KQUpgradeTabEnum { + + /** + * 一般工作时间 + */ + Upgrade1("Upgrade1",16687,"一般工作时间",503292), + /** + * 排班设置,排班人员数据 + */ + Upgrade2("Upgrade2",503229,"排班设置,排班人员数据",503293), + /** + * 请假类型 + */ + Upgrade3("Upgrade3",1881,"请假类型",503294), + /** + * 工作日期调整 + */ + Upgrade4("Upgrade4",16750,"工作日期调整",503295), + /** + * 年假数据 + */ + Upgrade5("Upgrade5",503233,"年假数据",503296), + /** + * 带薪假数据 + */ + Upgrade6("Upgrade6",503234,"带薪假数据",503297), + /** + * 调休数据 + */ + Upgrade7("Upgrade7",503235,"调休数据",503298), + /** + * 考勤流程设置 + */ + Upgrade8("Upgrade8",82797,"考勤流程设置",503299), + /** + * 外部集成考勤设置 + */ + Upgrade9("Upgrade9",503265,"外部集成考勤设置",503300), + /** + * 历史考勤流程数据 + */ + Upgrade10("Upgrade10",503266,"历史考勤流程数据",503301), + /** + * 历史签到签退数据 + */ + Upgrade11("Upgrade11",503267,"历史签到签退数据",503302), + /** + * 考勤报表数据 + */ + Upgrade12("Upgrade12",503268,"考勤报表数据",503303); + + private String tabtype; + + private int tablabel; + + private String memo; + + /** + * 每种升级情况的页面描述标签 + * 比如 + 共找到 122 条历史签到签退数据 + */ + private int countDescLabel; + /** + * + * @param tabtype 升级类型 + */ + KQUpgradeTabEnum(String tabtype,int tablabel,String memo,int countDescLabel) { + this.tabtype = tabtype; + this.tablabel = tablabel; + this.memo = memo; + this.countDescLabel = countDescLabel; + } + + public String getTabtype() { + return tabtype; + } + + public void setTabtype(String tabtype) { + this.tabtype = tabtype; + } + + public int getTablabel() { + return tablabel; + } + + public void setTablabel(int tablabel) { + this.tablabel = tablabel; + } + + public String getMemo() { + return memo; + } + + public void setMemo(String memo) { + this.memo = memo; + } + + public int getCountDescLabel() { + return countDescLabel; + } + + public void setCountDescLabel(int countDescLabel) { + this.countDescLabel = countDescLabel; + } + +} diff --git a/src/com/engine/kq/cmd/upgrade/UpgradeUtil.java b/src/com/engine/kq/cmd/upgrade/UpgradeUtil.java new file mode 100644 index 0000000..7017560 --- /dev/null +++ b/src/com/engine/kq/cmd/upgrade/UpgradeUtil.java @@ -0,0 +1,24 @@ +package com.engine.kq.cmd.upgrade; + +import java.text.MessageFormat; +import weaver.systeminfo.SystemEnv; + +public class UpgradeUtil { + + /** + * 按照要求格式化文字 + * @param kqUpgradeTabEnum + * @param lanid + * @param counts + * @return + */ + public static String formatMsg(KQUpgradeTabEnum kqUpgradeTabEnum,int lanid, Object ... counts){ + String msg = ""; + try{ + msg = MessageFormat.format(SystemEnv.getHtmlLabelName(kqUpgradeTabEnum.getCountDescLabel(),lanid),counts); + }catch (Exception e){ + e.printStackTrace(); + } + return msg; + } +} diff --git a/src/com/engine/kq/entity/KQBalanceOfLeaveEntity.java b/src/com/engine/kq/entity/KQBalanceOfLeaveEntity.java new file mode 100644 index 0000000..3d6144d --- /dev/null +++ b/src/com/engine/kq/entity/KQBalanceOfLeaveEntity.java @@ -0,0 +1,234 @@ +package com.engine.kq.entity; + +/** + * 假期余额 + */ +public class KQBalanceOfLeaveEntity { + /** + * 主键ID + */ + int id; + /** + * 假期规则ID + */ + int leaveRulesId; + /** + * 人员ID + */ + int resourceId; + /** + * 所属年份 + * 数据格式:yyyy + */ + String belongYear; + /** + * 假期余额基数 + * 混合模式下为法定年假的基数 + */ + double baseAmount = 0.00; + /** + * 已用的假期余额 + * 混合模式下为已用的法定年假的数量 + */ + double usedAmount = 0.00; + /** + * 额外的假期余额 + * 混合模式下为额外的法定年假的数量 + */ + double extraAmount = 0.00; + /** + * 仅用于混合模式下的福利年假的基数 + */ + double baseAmount2 = 0.00; + /** + * 仅用于混合模式下的已用的福利年假的数量 + */ + double usedAmount2 = 0.00; + /** + * 仅用于混合模式下的额外的福利年假的数量 + */ + double extraAmount2 = 0.00; + /** + * 是有有效:0-有效、1-无效 + */ + int status; + /** + * 失效日期 + */ + String expirationDate; + /** + * 生效日期 + */ + String effectiveDate; + /** + * 最小请假单位 + */ + int minimumUnit; + + public KQBalanceOfLeaveEntity() { + } + + public KQBalanceOfLeaveEntity(int id, int leaveRulesId, int resourceId, String belongYear, double baseAmount, double usedAmount, double extraAmount, double baseAmount2, double usedAmount2, double extraAmount2, int status, String expirationDate) { + this.id = id; + this.leaveRulesId = leaveRulesId; + this.resourceId = resourceId; + this.belongYear = belongYear; + this.baseAmount = baseAmount; + this.usedAmount = usedAmount; + this.extraAmount = extraAmount; + this.baseAmount2 = baseAmount2; + this.usedAmount2 = usedAmount2; + this.extraAmount2 = extraAmount2; + this.status = status; + this.expirationDate = expirationDate; + } + public KQBalanceOfLeaveEntity(int id, int leaveRulesId, int resourceId, String belongYear, double baseAmount, double usedAmount, double extraAmount, double baseAmount2, double usedAmount2, double extraAmount2, int status, String expirationDate ,String effectiveDate) { + this.id = id; + this.leaveRulesId = leaveRulesId; + this.resourceId = resourceId; + this.belongYear = belongYear; + this.baseAmount = baseAmount; + this.usedAmount = usedAmount; + this.extraAmount = extraAmount; + this.baseAmount2 = baseAmount2; + this.usedAmount2 = usedAmount2; + this.extraAmount2 = extraAmount2; + this.status = status; + this.expirationDate = expirationDate; + this.effectiveDate = effectiveDate; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getLeaveRulesId() { + return leaveRulesId; + } + + public void setLeaveRulesId(int leaveRulesId) { + this.leaveRulesId = leaveRulesId; + } + + public int getResourceId() { + return resourceId; + } + + public void setResourceId(int resourceId) { + this.resourceId = resourceId; + } + + public String getBelongYear() { + return belongYear; + } + + public void setBelongYear(String belongYear) { + this.belongYear = belongYear; + } + + public double getBaseAmount() { + return baseAmount; + } + + public void setBaseAmount(double baseAmount) { + this.baseAmount = baseAmount; + } + + public double getUsedAmount() { + return usedAmount; + } + + public void setUsedAmount(double usedAmount) { + this.usedAmount = usedAmount; + } + + public double getExtraAmount() { + return extraAmount; + } + + public void setExtraAmount(double extraAmount) { + this.extraAmount = extraAmount; + } + + public double getBaseAmount2() { + return baseAmount2; + } + + public void setBaseAmount2(double baseAmount2) { + this.baseAmount2 = baseAmount2; + } + + public double getUsedAmount2() { + return usedAmount2; + } + + public void setUsedAmount2(double usedAmount2) { + this.usedAmount2 = usedAmount2; + } + + public double getExtraAmount2() { + return extraAmount2; + } + + public void setExtraAmount2(double extraAmount2) { + this.extraAmount2 = extraAmount2; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(String expirationDate) { + this.expirationDate = expirationDate; + } + + public String getEffectiveDate() { + return effectiveDate; + } + + public void setEffectiveDate(String effectiveDate) { + this.effectiveDate = effectiveDate; + } + + public int getMinimumUnit() { + return minimumUnit; + } + + public void setMinimumUnit(int minimumUnit) { + this.minimumUnit = minimumUnit; + } + + public boolean equals(KQBalanceOfLeaveEntity entity) { + if (this.baseAmount != entity.getBaseAmount() + || this.extraAmount != entity.getExtraAmount() + || this.usedAmount != entity.getUsedAmount() + || this.baseAmount2 != entity.getBaseAmount2() + || this.extraAmount2 != entity.getExtraAmount2() + || this.usedAmount2 != entity.getUsedAmount2()) { + return false; + } else { + return true; + } + } + + public boolean equalsByBaseAmount(KQBalanceOfLeaveEntity entity) { + if (this.baseAmount != entity.getBaseAmount() + || this.baseAmount2 != entity.getBaseAmount2()) { + return false; + } else { + return true; + } + } +} diff --git a/src/com/engine/kq/entity/KQGroupEntity.java b/src/com/engine/kq/entity/KQGroupEntity.java new file mode 100644 index 0000000..605255e --- /dev/null +++ b/src/com/engine/kq/entity/KQGroupEntity.java @@ -0,0 +1,235 @@ +package com.engine.kq.entity; + +public class KQGroupEntity { + private String id; + private String groupname; + private String excludeid; + private String excludecount; + private String subcompanyid; + private String kqtype; + private String serialids; + private String weekday; + private String signstart; + private String workhour; + private String isdelete; + private String signintype; + private String ipscope; + private String locationcheck; + private String locationcheckscope; + private String wificheck; + private String outsidesign; + + private String outsignapprove; + private String validity; + private String validityfromdate; + private String validityenddate; + private String locationfacecheck; + private String locationshowaddress; + private String wififacecheck; + private String calmethod; + private String abnormalremind; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getGroupname() { + return groupname; + } + + public void setGroupname(String groupname) { + this.groupname = groupname; + } + + public String getExcludeid() { + return excludeid; + } + + public void setExcludeid(String excludeid) { + this.excludeid = excludeid; + } + + public String getExcludecount() { + return excludecount; + } + + public void setExcludecount(String excludecount) { + this.excludecount = excludecount; + } + + public String getSubcompanyid() { + return subcompanyid; + } + + public void setSubcompanyid(String subcompanyid) { + this.subcompanyid = subcompanyid; + } + + public String getKqtype() { + return kqtype; + } + + public void setKqtype(String kqtype) { + this.kqtype = kqtype; + } + + public String getSerialids() { + return serialids; + } + + public void setSerialids(String serialids) { + this.serialids = serialids; + } + + public String getWeekday() { + return weekday; + } + + public void setWeekday(String weekday) { + this.weekday = weekday; + } + + public String getSignstart() { + return signstart; + } + + public void setSignstart(String signstart) { + this.signstart = signstart; + } + + public String getWorkhour() { + return workhour; + } + + public void setWorkhour(String workhour) { + this.workhour = workhour; + } + + public String getIsdelete() { + return isdelete; + } + + public void setIsdelete(String isdelete) { + this.isdelete = isdelete; + } + + public String getSignintype() { + return signintype; + } + + public void setSignintype(String signintype) { + this.signintype = signintype; + } + + public String getIpscope() { + return ipscope; + } + + public void setIpscope(String ipscope) { + this.ipscope = ipscope; + } + + public String getLocationcheck() { + return locationcheck; + } + + public void setLocationcheck(String locationcheck) { + this.locationcheck = locationcheck; + } + + public String getLocationcheckscope() { + return locationcheckscope; + } + + public void setLocationcheckscope(String locationcheckscope) { + this.locationcheckscope = locationcheckscope; + } + + public String getOutsidesign() { + return outsidesign; + } + + public String getOutsignapprove() {return outsignapprove;} + + public String getValidity() { + return validity; + } + + public void setValidity(String validity) { + this.validity = validity; + } + + public String getValidityfromdate() { + return validityfromdate; + } + + public void setValidityfromdate(String validityfromdate) { + this.validityfromdate = validityfromdate; + } + + public String getValidityenddate() { + return validityenddate; + } + + public void setValidityenddate(String validityenddate) { + this.validityenddate = validityenddate; + } + + public void setOutsidesign(String outsidesign) {this.outsidesign = outsidesign;} + public void setOutsignapprove(String outsignapprove) { + this.outsignapprove = outsignapprove; + } + + public String getWificheck() { + return wificheck; + } + + public void setWificheck(String wificheck) { + this.wificheck = wificheck; + } + + public String getLocationfacecheck() { + return locationfacecheck; + } + + public void setLocationfacecheck(String locationfacecheck) { + this.locationfacecheck = locationfacecheck; + } + + public String getLocationshowaddress() { + return locationshowaddress; + } + + public void setLocationshowaddress(String locationshowaddress) { + this.locationshowaddress = locationshowaddress; + } + + public String getWififacecheck() { + return wififacecheck; + } + + public void setWififacecheck(String wififacecheck) { + this.wififacecheck = wififacecheck; + } + + public String getCalmethod() { + return calmethod; + } + + public void setCalmethod(String calmethod) { + this.calmethod = calmethod; + } + + public String getAbnormalremind() { + return this.abnormalremind; + } + + public void setAbnormalremind( String abnormalremind) { + this.abnormalremind = abnormalremind; + } + +} diff --git a/src/com/engine/kq/entity/KQLeaveInfoEntity.java b/src/com/engine/kq/entity/KQLeaveInfoEntity.java new file mode 100644 index 0000000..fb27fcb --- /dev/null +++ b/src/com/engine/kq/entity/KQLeaveInfoEntity.java @@ -0,0 +1,26 @@ +package com.engine.kq.entity; + +import java.math.BigDecimal; + +public class KQLeaveInfoEntity { + private String balanceOfLeaveId; + private String durationType; + private BigDecimal usedAmount; + private BigDecimal usedAmount2; + + // 无参构造 + public KQLeaveInfoEntity() {} + + // Getter/Setter + public String getBalanceOfLeaveId() { return balanceOfLeaveId; } + public void setBalanceOfLeaveId(String balanceOfLeaveId) { this.balanceOfLeaveId = balanceOfLeaveId; } + + public String getDurationType() { return durationType; } + public void setDurationType(String durationType) { this.durationType = durationType; } + + public BigDecimal getUsedAmount() { return usedAmount; } + public void setUsedAmount(BigDecimal usedAmount) { this.usedAmount = usedAmount; } + + public BigDecimal getUsedAmount2() { return usedAmount2; } + public void setUsedAmount2(BigDecimal usedAmount2) { this.usedAmount2 = usedAmount2; } +} diff --git a/src/com/engine/kq/entity/KQOvertimeRulesDetailEntity.java b/src/com/engine/kq/entity/KQOvertimeRulesDetailEntity.java new file mode 100644 index 0000000..0437b68 --- /dev/null +++ b/src/com/engine/kq/entity/KQOvertimeRulesDetailEntity.java @@ -0,0 +1,253 @@ +package com.engine.kq.entity; + +/** + * 加班规则明细 + */ +public class KQOvertimeRulesDetailEntity { + /** + * 加班规则明细表的ID + */ + int id; + /** + * 加班规则主表的ID + */ + int ruleId; + /** + * 日期类型:1-节假日、2-工作日、3-休息日 + */ + int dayType; + /** + * 是否允许加班:0-不允许、1-允许 + */ + int overtimeEnable = 0; + /** + * 加班计算方式: + * 1-需审批,以审批单为准 + * 2-需审批,以打卡为准,但是不能超过审批时长 + * 3-无需审批,根据打卡时间计算加班时长 + * 4-需审批,打卡和流程均统计,取两者的交集 + */ + int computingMode = -1; + /** + * 加班起算时间 + */ + int startTime = -1; + /** + * 最小加班时长 + */ + int minimumLen = -1; + + int maxmumLen = -1; + /** + * 是否允许加班转调休:0-不允许、1-允许 + */ + int paidLeaveEnable = 0; + /** + * 加班时长转调休时长的比例中的加班时长 + */ + double lenOfOvertime = -1; + /** + * 加班时长转调休时长的比例中的调休时长 + */ + double lenOfLeave = -1; + + /** + * 是否排除休息时间 + */ + int hasRestTime = 0; + /** + * 上班前 加班起算时间 + */ + int before_startTime = 0; + + /** + * 是否开启加班归属临界点 + */ + int has_cut_point = 0; + + /** + * 是否开启午休时间算加班 + */ + int isovertimecal=0; + /** + * 加班归属 临界点 + */ + String cut_point = ""; + /** + * 加班补偿方式 1-默认加班补偿规则、2-根据员工在加班流程上选择的加班补偿类型进行补偿两种 + */ + int paidLeaveEnableType = 1; + /** + * 默认加班补偿方式 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长 + */ + int paidLeaveEnableDefaultType = 1; + /** + * 根据员工在加班流程上选择的加班补偿类型进行补偿 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长 + */ + int paidLeaveEnableFlowType = 1; + /** + * 排除休息时间: 1-设置休息时间、2-根据加班时长扣除 + */ + int restTimeType = 1; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getRuleId() { + return ruleId; + } + + public void setRuleId(int ruleId) { + this.ruleId = ruleId; + } + + public int getDayType() { + return dayType; + } + + public void setDayType(int dayType) { + this.dayType = dayType; + } + + public int getOvertimeEnable() { + return overtimeEnable; + } + + public void setOvertimeEnable(int overtimeEnable) { + this.overtimeEnable = overtimeEnable; + } + + public int getComputingMode() { + return computingMode; + } + + public void setComputingMode(int computingMode) { + this.computingMode = computingMode; + } + + public int getStartTime() { + return startTime; + } + + public void setStartTime(int startTime) { + this.startTime = startTime; + } + + public int getMinimumLen() { + return minimumLen; + } + + public void setMinimumLen(int minimumLen) { + this.minimumLen = minimumLen; + } + + + public int getMaxmumLen() { + return maxmumLen; + } + + public void setMaxmumLen(int maxmumLen) { + this.maxmumLen = maxmumLen; + } + + public int getPaidLeaveEnable() { + return paidLeaveEnable; + } + + public void setPaidLeaveEnable(int paidLeaveEnable) { + this.paidLeaveEnable = paidLeaveEnable; + } + + public double getLenOfOvertime() { + return lenOfOvertime; + } + + public void setLenOfOvertime(double lenOfOvertime) { + this.lenOfOvertime = lenOfOvertime; + } + + public double getLenOfLeave() { + return lenOfLeave; + } + + public void setLenOfLeave(double lenOfLeave) { + this.lenOfLeave = lenOfLeave; + } + + public int getHasRestTime() { + return hasRestTime; + } + + public void setHasRestTime(int hasRestTime) { + this.hasRestTime = hasRestTime; + } + + public int getBefore_startTime() { + return before_startTime; + } + + public void setBefore_startTime(int before_startTime) { + this.before_startTime = before_startTime; + } + + public String getCut_point() { + return cut_point; + } + + public void setCut_point(String cut_point) { + this.cut_point = cut_point; + } + + public int getHas_cut_point() { + return has_cut_point; + } + + public void setHas_cut_point(int has_cut_point) { + this.has_cut_point = has_cut_point; + } + + public int getIsOvertimeCal() { + return isovertimecal; + } + + public void setIsOvertimeCal(int isovertimecal) { + this.isovertimecal = isovertimecal; + } + + public int getPaidLeaveEnableType() { + return paidLeaveEnableType; + } + + public void setPaidLeaveEnableType(int paidLeaveEnableType) { + this.paidLeaveEnableType = paidLeaveEnableType; + } + + public int getPaidLeaveEnableDefaultType() { + return paidLeaveEnableDefaultType; + } + + public void setPaidLeaveEnableDefaultType(int paidLeaveEnableDefaultType) { + this.paidLeaveEnableDefaultType = paidLeaveEnableDefaultType; + } + + public int getPaidLeaveEnableFlowType() { + return paidLeaveEnableFlowType; + } + + public void setPaidLeaveEnableFlowType(int paidLeaveEnableFlowType) { + this.paidLeaveEnableFlowType = paidLeaveEnableFlowType; + } + + public int getRestTimeType() { + return restTimeType; + } + + public void setRestTimeType(int restTimeType) { + this.restTimeType = restTimeType; + } +} diff --git a/src/com/engine/kq/entity/KQReportEntity.java b/src/com/engine/kq/entity/KQReportEntity.java new file mode 100644 index 0000000..fb3e14c --- /dev/null +++ b/src/com/engine/kq/entity/KQReportEntity.java @@ -0,0 +1,178 @@ +package com.engine.kq.entity; + +/** + * 考勤报表实体类 + */ +public class KQReportEntity { + private String resourceid=null; + private String kqdate=null; + private String groupid=null; + private String serialid=null; + private String workdays=null; + private String workmins=null; + private String attendancedays=null; + private String attendancemins=null; + private String belate=null; + private String belatemins=null; + private String gravebelate=null; + private String gravebelatemins=null; + private String leaveeearly=null; + private String leaveearlymins=null; + private String graveleaveearly=null; + private String graveleaveearlymins=null; + private String absenteeism=null; + private String absenteeismmins=null; + private String forgotcheck=null; + + public String getResourceid() { + return resourceid; + } + + public void setResourceid(String resourceid) { + this.resourceid = resourceid; + } + + public String getKqdate() { + return kqdate; + } + + public void setKqdate(String kqdate) { + this.kqdate = kqdate; + } + + public String getGroupid() { + return groupid; + } + + public void setGroupid(String groupid) { + this.groupid = groupid; + } + + public String getSerialid() { + return serialid; + } + + public void setSerialid(String serialid) { + this.serialid = serialid; + } + + public String getWorkdays() { + return workdays; + } + + public void setWorkdays(String workdays) { + this.workdays = workdays; + } + + public String getWorkmins() { + return workmins; + } + + public void setWorkmins(String workmins) { + this.workmins = workmins; + } + + public String getAttendancedays() { + return attendancedays; + } + + public void setAttendancedays(String attendancedays) { + this.attendancedays = attendancedays; + } + + public String getAttendancemins() { + return attendancemins; + } + + public void setAttendancemins(String attendancemins) { + this.attendancemins = attendancemins; + } + + public String getBelate() { + return belate; + } + + public void setBelate(String belate) { + this.belate = belate; + } + + public String getBelatemins() { + return belatemins; + } + + public void setBelatemins(String belatemins) { + this.belatemins = belatemins; + } + + public String getGravebelate() { + return gravebelate; + } + + public void setGravebelate(String gravebelate) { + this.gravebelate = gravebelate; + } + + public String getGravebelatemins() { + return gravebelatemins; + } + + public void setGravebelatemins(String gravebelatemins) { + this.gravebelatemins = gravebelatemins; + } + + public String getLeaveeearly() { + return leaveeearly; + } + + public void setLeaveeearly(String leaveeearly) { + this.leaveeearly = leaveeearly; + } + + public String getLeaveearlymins() { + return leaveearlymins; + } + + public void setLeaveearlymins(String leaveearlymins) { + this.leaveearlymins = leaveearlymins; + } + + public String getGraveleaveearly() { + return graveleaveearly; + } + + public void setGraveleaveearly(String graveleaveearly) { + this.graveleaveearly = graveleaveearly; + } + + public String getGraveleaveearlymins() { + return graveleaveearlymins; + } + + public void setGraveleaveearlymins(String graveleaveearlymins) { + this.graveleaveearlymins = graveleaveearlymins; + } + + public String getAbsenteeism() { + return absenteeism; + } + + public void setAbsenteeism(String absenteeism) { + this.absenteeism = absenteeism; + } + + public String getAbsenteeismmins() { + return absenteeismmins; + } + + public void setAbsenteeismmins(String absenteeismmins) { + this.absenteeismmins = absenteeismmins; + } + + public String getForgotcheck() { + return forgotcheck; + } + + public void setForgotcheck(String forgotcheck) { + this.forgotcheck = forgotcheck; + } +} diff --git a/src/com/engine/kq/entity/KQScheduleSignEntity.java b/src/com/engine/kq/entity/KQScheduleSignEntity.java new file mode 100644 index 0000000..b9ceea7 --- /dev/null +++ b/src/com/engine/kq/entity/KQScheduleSignEntity.java @@ -0,0 +1,98 @@ +package com.engine.kq.entity; + +/** + * 考勤同步实体 + */ +public class KQScheduleSignEntity { + String loginid = ""; + String workcode = ""; + String lastname = ""; + String signdate = ""; + String signtime = ""; + String clientaddress = ""; + String longitude = ""; + String latitude = ""; + + public String getLoginid() { + return loginid; + } + + public void setLoginid(String loginid) { + this.loginid = loginid; + } + + public String getWorkcode() { + return workcode; + } + + public void setWorkcode(String workcode) { + this.workcode = workcode; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public String getSigndate() { + return signdate; + } + + public void setSigndate(String signdate) { + this.signdate = signdate; + } + + public String getSigntime() { + return signtime; + } + + public void setSigntime(String signtime) { + this.signtime = signtime; + } + + public String getClientaddress() { + return clientaddress; + } + + public void setClientaddress(String clientaddress) { + this.clientaddress = clientaddress; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getAddr() { + return addr; + } + + public void setAddr(String addr) { + this.addr = addr; + } + + public String getMemo() { + return memo; + } + + public void setMemo(String memo) { + this.memo = memo; + } + + String addr = ""; + String memo = ""; +} diff --git a/src/com/engine/kq/entity/KQShiftRuleEntity.java b/src/com/engine/kq/entity/KQShiftRuleEntity.java new file mode 100644 index 0000000..6efc3a4 --- /dev/null +++ b/src/com/engine/kq/entity/KQShiftRuleEntity.java @@ -0,0 +1,189 @@ +package com.engine.kq.entity; + +/** + * 考勤报表明细实体类 + */ +public class KQShiftRuleEntity { + private String userId = ""; + private String kqDate = ""; + private int belatemins = 0; + private int gravebelatemins = 0; + private int leaveearlymins = 0; + private int graveleaveearlymins = 0; + private int absenteeismmins = 0; + private int forgotcheckmins = 0; + private int forgotBeginWorkCheckMins = 0;//上班漏签 + private int earlyInMins = 0;//早到分钟数 + private int lateOutMins = 0;//晚走分钟数 + private String nosign_is_absent = "1"; + private String nosign_ishandle = "0"; + private String signInTime; + private String signOutTime; + private String early_one_mins; + //上午旷工 + private boolean isAMAbsent = false; + //下午旷工 + private boolean isPMAbsent = false; + private int on_absenteeismMins; + private int off_absenteeismMins; + + public int getForgotBeginWorkCheckMins() { + return forgotBeginWorkCheckMins; + } + + public void setForgotBeginWorkCheckMins(int forgotBeginWorkCheckMins) { + this.forgotBeginWorkCheckMins = forgotBeginWorkCheckMins; + } + + public int getBelatemins() { + return belatemins; + } + + public void setBelatemins(int belatemins) { + this.belatemins = belatemins; + } + + public int getGravebelatemins() { + return gravebelatemins; + } + + public void setGravebelatemins(int gravebelatemins) { + this.gravebelatemins = gravebelatemins; + } + + public int getLeaveearlymins() { + return leaveearlymins; + } + + public void setLeaveearlymins(int leaveearlymins) { + this.leaveearlymins = leaveearlymins; + } + + public int getGraveleaveearlymins() { + return graveleaveearlymins; + } + + public void setGraveleaveearlymins(int graveleaveearlymins) { + this.graveleaveearlymins = graveleaveearlymins; + } + + public int getAbsenteeismmins() { + return absenteeismmins; + } + + public void setAbsenteeismmins(int absenteeismmins) { + this.absenteeismmins = absenteeismmins; + } + + public int getForgotcheckmins() { + return forgotcheckmins; + } + + public void setForgotcheckmins(int forgotcheckmins) { + this.forgotcheckmins = forgotcheckmins; + } + + public int getEarlyInMins() { + return earlyInMins; + } + + public void setEarlyInMins(int earlyInMins) { + this.earlyInMins = earlyInMins; + } + + public int getLateOutMins() { + return lateOutMins; + } + + public void setLateOutMins(int lateOutMins) { + this.lateOutMins = lateOutMins; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getKqDate() { + return kqDate; + } + + public void setKqDate(String kqDate) { + this.kqDate = kqDate; + } + + public String getNosign_is_absent() { + return nosign_is_absent; + } + + public void setNosign_is_absent(String nosign_is_absent) { + this.nosign_is_absent = nosign_is_absent; + } + + public String getNosign_ishandle() { + return nosign_ishandle; + } + + public void setNosign_ishandle(String nosign_ishandle) { + this.nosign_ishandle = nosign_ishandle; + } + + public String getSignInTime() { + return signInTime; + } + + public void setSignInTime(String signInTime) { + this.signInTime = signInTime; + } + + public String getSignOutTime() { + return signOutTime; + } + + public void setSignOutTime(String signOutTime) { + this.signOutTime = signOutTime; + } + + public String getEarly_one_mins() { + return early_one_mins; + } + + public void setEarly_one_mins(String early_one_mins) { + this.early_one_mins = early_one_mins; + } + + public boolean isAMAbsent() { + return isAMAbsent; + } + + public void setAMAbsent(boolean AMAbsent) { + isAMAbsent = AMAbsent; + } + + public boolean isPMAbsent() { + return isPMAbsent; + } + + public void setPMAbsent(boolean PMAbsent) { + isPMAbsent = PMAbsent; + } + + public int getOn_absenteeismMins() { + return on_absenteeismMins; + } + + public void setOn_absenteeismMins(int on_absenteeismMins) { + this.on_absenteeismMins = on_absenteeismMins; + } + + public int getOff_absenteeismMins() { + return off_absenteeismMins; + } + + public void setOff_absenteeismMins(int off_absenteeismMins) { + this.off_absenteeismMins = off_absenteeismMins; + } +} diff --git a/src/com/engine/kq/entity/KQUsageHistoryEntity.java b/src/com/engine/kq/entity/KQUsageHistoryEntity.java new file mode 100644 index 0000000..65714f6 --- /dev/null +++ b/src/com/engine/kq/entity/KQUsageHistoryEntity.java @@ -0,0 +1,386 @@ +package com.engine.kq.entity; + +/** + * @Auther: Administrator + * @Date: 2019-03-11 20:30 + * @Description:员工假期余额实体类 + */ +public class KQUsageHistoryEntity { + + /** + * 假期类型的ID + */ + private String leaveRulesId; + /** + * 假期余额被修改的人员ID + */ + private String relatedId; + /** + * 流程的requestId + */ + private String wfRequestId = "0"; + /** + * 操作者 + */ + private String operator; + /** + * 操作日期 + */ + private String operateDate; + /** + * 操作时间 + */ + private String operateTime; + /** + * 操作类型: + * 0--单位变更 + * 1--请假流程 + * 2--销假流程 + * 3--加班流程生成调休 + * 4--打卡数据生成调休 + * 5--管理员修改员工假期余额 + * 6--批处理(管理员手动批处理或者系统凌晨自动批处理) + * 7--管理员Excel导入 + */ + private String operateType; + /** + * 员工假期余额的所属年份 + */ + private String belongYear; + /** + * 操作之前的员工假期余额基数 + */ + private String oldBaseAmount = "0.00"; + /** + * 操作之后的员工假期余额基数 + */ + private String newBaseAmount = "0.00"; + /** + * 操作之前的员工额外假期余额 + */ + private String oldExtraAmount = "0.00"; + /** + * 操作之后的员工额外假期余额 + */ + private String newExtraAmount = "0.00"; + /** + * 操作之前的员工已休假期余额 + */ + private String oldUsedAmount = "0.00"; + /** + * 操作之后的员工已休假期余额 + */ + private String newUsedAmount = "0.00"; + + /** + * 操作之前的员工福利年假基数 + */ + private String oldBaseAmount2 = "0.00"; + /** + * 操作之后的员工福利年假基数 + */ + private String newBaseAmount2 = "0.00"; + /** + * 操作之前的员工额外福利年假 + */ + private String oldExtraAmount2 = "0.00"; + /** + * 操作之后的员工额外福利年假 + */ + private String newExtraAmount2 = "0.00"; + /** + * 操作之前的员工已休福利年假 + */ + private String oldUsedAmount2 = "0.00"; + /** + * 操作之后的员工已休福利年假 + */ + private String newUsedAmount2 = "0.00"; + + /** + * 操作之前的员工假期余额单位: + * 1-按天(单位:天) + * 2-按半天(单位:天) + * 3-按小时(单位:小时) + * 4-按整天(单位:天) + */ + private String oldMinimumUnit; + /** + * 操作之后的员工假期余额单位: + * 1-按天(单位:天) + * 2-按半天(单位:天) + * 3-按小时(单位:小时) + * 4-按整天(单位:天) + */ + private String newMinimumUnit; + /** + * 是新增的员工假期余额还是更新员工假期余额 + */ + private String insertOrUpdate; + + /** + * 员工假期余额的ID + * 暂时只有加班生成调休记录了这个 + */ + private String balanceOfLeaveId; + + /** + * 流程的workflowid + */ + private String workflowid; + private String belongdate ; + private String duration ; + + public KQUsageHistoryEntity() { + } + + public KQUsageHistoryEntity(String leaveRulesId, String relatedId, String wfRequestId, String operator, String operateDate, String operateTime, String operateType, String belongYear, String oldBaseAmount, String newBaseAmount, String oldExtraAmount, String newExtraAmount, String oldUsedAmount, String newUsedAmount, + String oldBaseAmount2, String newBaseAmount2, String oldExtraAmount2, String newExtraAmount2, String oldUsedAmount2, String newUsedAmount2, String oldMinimumUnit, String newMinimumUnit, String insertOrUpdate, String balanceOfLeaveId,String workflowid,String belongdate,String duration) { + this.leaveRulesId = leaveRulesId; + this.relatedId = relatedId; + this.wfRequestId = wfRequestId; + this.operator = operator; + this.operateDate = operateDate; + this.operateTime = operateTime; + this.operateType = operateType; + this.belongYear = belongYear; + this.oldBaseAmount = oldBaseAmount; + this.newBaseAmount = newBaseAmount; + this.oldExtraAmount = oldExtraAmount; + this.newExtraAmount = newExtraAmount; + this.oldUsedAmount = oldUsedAmount; + this.newUsedAmount = newUsedAmount; + this.oldBaseAmount2 = oldBaseAmount2; + this.newBaseAmount2 = newBaseAmount2; + this.oldExtraAmount2 = oldExtraAmount2; + this.newExtraAmount2 = newExtraAmount2; + this.oldUsedAmount2 = oldUsedAmount2; + this.newUsedAmount2 = newUsedAmount2; + this.oldMinimumUnit = oldMinimumUnit; + this.newMinimumUnit = newMinimumUnit; + this.insertOrUpdate = insertOrUpdate; + this.balanceOfLeaveId = balanceOfLeaveId; + this.workflowid = workflowid; + this.belongdate = belongdate; + this.duration = duration; + } + + public String getLeaveRulesId() { + return leaveRulesId; + } + + public void setLeaveRulesId(String leaveRulesId) { + this.leaveRulesId = leaveRulesId; + } + + public String getRelatedId() { + return relatedId; + } + + public void setRelatedId(String relatedId) { + this.relatedId = relatedId; + } + + public String getWfRequestId() { + return wfRequestId; + } + + public void setWfRequestId(String wfRequestId) { + if(wfRequestId.equals("")){ + wfRequestId = "0"; + } + this.wfRequestId = wfRequestId; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getOperateDate() { + return operateDate; + } + + public void setOperateDate(String operateDate) { + this.operateDate = operateDate; + } + + public String getOperateTime() { + return operateTime; + } + + public void setOperateTime(String operateTime) { + this.operateTime = operateTime; + } + + public String getOperateType() { + return operateType; + } + + public void setOperateType(String operateType) { + this.operateType = operateType; + } + + public String getBelongYear() { + return belongYear; + } + + public void setBelongYear(String belongYear) { + this.belongYear = belongYear; + } + + public String getOldBaseAmount() { + return oldBaseAmount; + } + + public void setOldBaseAmount(String oldBaseAmount) { + this.oldBaseAmount = oldBaseAmount; + } + + public String getNewBaseAmount() { + return newBaseAmount; + } + + public void setNewBaseAmount(String newBaseAmount) { + this.newBaseAmount = newBaseAmount; + } + + public String getOldExtraAmount() { + return oldExtraAmount; + } + + public void setOldExtraAmount(String oldExtraAmount) { + this.oldExtraAmount = oldExtraAmount; + } + + public String getNewExtraAmount() { + return newExtraAmount; + } + + public void setNewExtraAmount(String newExtraAmount) { + this.newExtraAmount = newExtraAmount; + } + + public String getOldUsedAmount() { + return oldUsedAmount; + } + + public void setOldUsedAmount(String oldUsedAmount) { + this.oldUsedAmount = oldUsedAmount; + } + + public String getNewUsedAmount() { + return newUsedAmount; + } + + public void setNewUsedAmount(String newUsedAmount) { + this.newUsedAmount = newUsedAmount; + } + + public String getOldBaseAmount2() { + return oldBaseAmount2; + } + + public void setOldBaseAmount2(String oldBaseAmount2) { + this.oldBaseAmount2 = oldBaseAmount2; + } + + public String getNewBaseAmount2() { + return newBaseAmount2; + } + + public void setNewBaseAmount2(String newBaseAmount2) { + this.newBaseAmount2 = newBaseAmount2; + } + + public String getOldExtraAmount2() { + return oldExtraAmount2; + } + + public void setOldExtraAmount2(String oldExtraAmount2) { + this.oldExtraAmount2 = oldExtraAmount2; + } + + public String getNewExtraAmount2() { + return newExtraAmount2; + } + + public void setNewExtraAmount2(String newExtraAmount2) { + this.newExtraAmount2 = newExtraAmount2; + } + + public String getOldUsedAmount2() { + return oldUsedAmount2; + } + + public void setOldUsedAmount2(String oldUsedAmount2) { + this.oldUsedAmount2 = oldUsedAmount2; + } + + public String getNewUsedAmount2() { + return newUsedAmount2; + } + + public void setNewUsedAmount2(String newUsedAmount2) { + this.newUsedAmount2 = newUsedAmount2; + } + + public String getOldMinimumUnit() { + return oldMinimumUnit; + } + + public void setOldMinimumUnit(String oldMinimumUnit) { + this.oldMinimumUnit = oldMinimumUnit; + } + + public String getNewMinimumUnit() { + return newMinimumUnit; + } + + public void setNewMinimumUnit(String newMinimumUnit) { + this.newMinimumUnit = newMinimumUnit; + } + + public String getInsertOrUpdate() { + return insertOrUpdate; + } + + public void setInsertOrUpdate(String insertOrUpdate) { + this.insertOrUpdate = insertOrUpdate; + } + + public String getBalanceOfLeaveId() { + return balanceOfLeaveId; + } + + public void setBalanceOfLeaveId(String balanceOfLeaveId) { + this.balanceOfLeaveId = balanceOfLeaveId; + } + + public String getWorkflowid() { + return workflowid; + } + + public void setWorkflowid(String workflowid) { + this.workflowid = workflowid; + } + + public String getBelongdate() { + return belongdate; + } + + public void setBelongdate(String belongdate) { + this.belongdate = belongdate; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } +} diff --git a/src/com/engine/kq/entity/TimeScopeEntity.java b/src/com/engine/kq/entity/TimeScopeEntity.java new file mode 100644 index 0000000..804584e --- /dev/null +++ b/src/com/engine/kq/entity/TimeScopeEntity.java @@ -0,0 +1,76 @@ +package com.engine.kq.entity; + +/*** + * 工作时间范围 + */ +public class TimeScopeEntity { + private String beginTime; + /** + * 是否跨天到后一天 + */ + private boolean beginTimeAcross; + /** + * 是否跨天到前一天 + */ + private boolean beginTimePreAcross; + private String endTime; + private boolean endTimeAcross; + private int workMins; + private TimeSignScopeEntity timeSignScopeEntity; + + public String getBeginTime() { + return beginTime; + } + + public void setBeginTime(String beginTime) { + this.beginTime = beginTime; + } + + public boolean getBeginTimeAcross() { + return beginTimeAcross; + } + + public void setBeginTimeAcross(boolean beginTimeAcross) { + this.beginTimeAcross = beginTimeAcross; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public boolean getEndTimeAcross() { + return endTimeAcross; + } + + public void setEndTimeAcross(boolean endTimeAcross) { + this.endTimeAcross = endTimeAcross; + } + + public int getWorkMins() { + return workMins; + } + + public void setWorkMins(int workMins) { + this.workMins = workMins; + } + + public TimeSignScopeEntity getTimeSignScopeEntity() { + return timeSignScopeEntity; + } + + public void setTimeSignScopeEntity(TimeSignScopeEntity timeSignScopeEntity) { + this.timeSignScopeEntity = timeSignScopeEntity; + } + + public boolean isBeginTimePreAcross() { + return beginTimePreAcross; + } + + public void setBeginTimePreAcross(boolean beginTimePreAcross) { + this.beginTimePreAcross = beginTimePreAcross; + } +} diff --git a/src/com/engine/kq/entity/TimeSignScopeEntity.java b/src/com/engine/kq/entity/TimeSignScopeEntity.java new file mode 100644 index 0000000..156b5b1 --- /dev/null +++ b/src/com/engine/kq/entity/TimeSignScopeEntity.java @@ -0,0 +1,56 @@ +package com.engine.kq.entity; + +/*** + * 打卡区间范围 + * 增加了上班后多久停止打卡和下班前多久开始打卡的控制 + */ +public class TimeSignScopeEntity { + private String beginTimeEnd; + private boolean beginTimeEndAcross; + /** + * 是否跨天到前一天 + */ + private boolean beginTimePreAcross; + private String endTimeStart; + private boolean endTimeStartAcross; + + public String getBeginTimeEnd() { + return beginTimeEnd; + } + + public void setBeginTimeEnd(String beginTimeEnd) { + this.beginTimeEnd = beginTimeEnd; + } + + public boolean isBeginTimeEndAcross() { + return beginTimeEndAcross; + } + + public void setBeginTimeEndAcross(boolean beginTimeEndAcross) { + this.beginTimeEndAcross = beginTimeEndAcross; + } + + public String getEndTimeStart() { + return endTimeStart; + } + + public void setEndTimeStart(String endTimeStart) { + this.endTimeStart = endTimeStart; + } + + public boolean isEndTimeStartAcross() { + return endTimeStartAcross; + } + + public void setEndTimeStartAcross(boolean endTimeStartAcross) { + this.endTimeStartAcross = endTimeStartAcross; + } + + public boolean isBeginTimePreAcross() { + return beginTimePreAcross; + } + + public void setBeginTimePreAcross(boolean beginTimePreAcross) { + this.beginTimePreAcross = beginTimePreAcross; + } +} diff --git a/src/com/engine/kq/entity/WorkTimeEntity.java b/src/com/engine/kq/entity/WorkTimeEntity.java new file mode 100644 index 0000000..dfaae29 --- /dev/null +++ b/src/com/engine/kq/entity/WorkTimeEntity.java @@ -0,0 +1,220 @@ +package com.engine.kq.entity; + +import java.util.List; +import java.util.Map; + +/*** + * 工作时间 + */ +public class WorkTimeEntity { + private String groupId;//所属考勤组 + private String groupName;//所属考勤组 + private String kqType;//考勤类型 + private String serialId;//班次 + private Map shiftRuleInfo;//班次人性化规则 + private List signTime;//允许打卡时间 + private List workTime;//工作时间 + private List restTime;//休息时间 + private int workMins;//工作时长 + private String isAcross;//是否跨天 + private String signstart;//自由工时开始打卡时间 + private boolean isExclude;//无需考勤人员 + private String calmethod;//自由班制计算方式 + private int signoutOnlyoff; + + private List halfWorkTime;//半天 + + private List halfWorkIndex; + + /** + * 是否是非工作日 1表示是非工作日班次 + */ + private int nonWorkShift; + /** + * 当前日期类型 + * playday 休息日 + * work 工作日 + * holiday 节假日 + */ + private String dayType; + + /** + * 应出勤折算天数 + */ + private String convertAttendDay = ""; + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String getKQType() { + return kqType; + } + + public void setKQType(String kqType) { + this.kqType = kqType; + } + + public String getSerialId() { + return serialId; + } + + public void setSerialId(String serialId) { + this.serialId = serialId; + } + + public Map getShiftRuleInfo() { + return shiftRuleInfo; + } + + public void setShiftRuleInfo(Map shiftRuleInfo) { + this.shiftRuleInfo = shiftRuleInfo; + } + + public List getWorkTime() { + return workTime; + } + + public void setWorkTime(List workTime) { + this.workTime = workTime; + } + + public List getRestTime() { + return restTime; + } + + public void setRestTime(List restTime) { + this.restTime = restTime; + } + + public int getWorkMins() { + return workMins; + } + + public void setWorkMins(int workMins) { + this.workMins = workMins; + } + + public String getIsAcross() { + return isAcross; + } + + public void setIsAcross(String isAcross) { + this.isAcross = isAcross; + } + + public String getSignStart() { + return signstart; + } + + public void setSignStart(String signstart) { + this.signstart = signstart; + } + + public List getSignTime() { + return signTime; + } + + public void setSignTime(List signTime) { + this.signTime = signTime; + } + + public boolean getIsExclude() { + return isExclude; + } + + public void setIsExclude(boolean isExclude) { + this.isExclude = isExclude; + } + + public String getCalmethod() { + return calmethod; + } + + public void setCalmethod(String calmethod) { + this.calmethod = calmethod; + } + + public int getNonWorkShift() { + return nonWorkShift; + } + + public void setNonWorkShift(int restShift) { + this.nonWorkShift = restShift; + } + + public String getDayType() { + return dayType; + } + + public void setDayType(String dayType) { + this.dayType = dayType; + } + + public String getConvertAttendDay() { + return convertAttendDay; + } + + public void setConvertAttendDay(String convertAttendDay) { + this.convertAttendDay = convertAttendDay; + } + + public int getSignoutOnlyoff() { + return signoutOnlyoff; + } + + public void setSignoutOnlyoff(int signoutOnlyoff) { + this.signoutOnlyoff = signoutOnlyoff; + } + + public List getHalfWorkTime() { + return halfWorkTime; + } + + public void setHalfWorkTime(List halfWorkTime) { + this.halfWorkTime = halfWorkTime; + } + + public List getHalfWorkIndex() { + return halfWorkIndex; + } + + public void setHalfWorkIndex(List halfWorkIndex) { + this.halfWorkIndex = halfWorkIndex; + } + + @Override + public String toString() { + return "WorkTimeEntity{" + + "groupId='" + groupId + '\'' + + ", groupName='" + groupName + '\'' + + ", kqType='" + kqType + '\'' + + ", serialId='" + serialId + '\'' + + ", shiftRuleInfo=" + shiftRuleInfo + + ", signTime=" + signTime + + ", workTime=" + workTime + + ", restTime=" + restTime + + ", workMins=" + workMins + + ", isAcross='" + isAcross + '\'' + + ", signstart='" + signstart + '\'' + + ", isExclude=" + isExclude + + ", calmethod='" + calmethod + '\'' + + ", signoutOnlyoff=" + signoutOnlyoff + + ", nonWorkShift=" + nonWorkShift + + ", dayType='" + dayType + '\'' + + ", convertAttendDay='" + convertAttendDay + '\'' + + '}'; + } +} diff --git a/src/com/engine/kq/enums/DurationTypeEnum.java b/src/com/engine/kq/enums/DurationTypeEnum.java new file mode 100644 index 0000000..0364350 --- /dev/null +++ b/src/com/engine/kq/enums/DurationTypeEnum.java @@ -0,0 +1,57 @@ +package com.engine.kq.enums; + +/** + * 时长计算类型 请假,出差,公出这些都有自己的规则,单独增加个时长计算类型 + */ +public enum DurationTypeEnum { + + /** + * 请假 + */ + LEAVE("LEAVE"), + /** + * 出差 + */ + EVECTION("EVECTION"), + /** + * 公出 + */ + OUT("OUT"), + /** + * 异常流程 + */ + OVERTIME("OVERTIME"), + /** + * 加班 + */ + OTHER("OTHER"), + /** + * 销假 + */ + LEAVEBACK("LEAVEBACK"), + /** + * 普通计算 + */ + COMMON_CAL("COMMON_CAL"), + /** + * 考勤变更 + */ + PROCESSCHANGE("PROCESSCHANGE"); + + private String durationType; + /** + * + * @param durationType 时长规则类型 + */ + DurationTypeEnum(String durationType) { + this.durationType = durationType; + } + + public String getDurationType() { + return durationType; + } + + public void setDurationType(String durationType) { + this.durationType = durationType; + } +} diff --git a/src/com/engine/kq/enums/FlowReportTypeEnum.java b/src/com/engine/kq/enums/FlowReportTypeEnum.java new file mode 100644 index 0000000..9bbaa73 --- /dev/null +++ b/src/com/engine/kq/enums/FlowReportTypeEnum.java @@ -0,0 +1,100 @@ +package com.engine.kq.enums; + +/** + * 考勤报表使用的 流程类型对应关系 + */ +public enum FlowReportTypeEnum { + + /** + * 年假 + */ + annualLeave("annualLeave"), + /** + * 带薪事假 + */ + paidCompassionateLeave("paidCompassionateLeave"), + /** + * 带薪病假 + */ + paidSickLeave("paidSickLeave"), + /** + * 事假 + */ + compassionateLeave("compassionateLeave"), + /** + * 病假 + */ + sickLeave("sickLeave"), + /** + * 调休 + */ + vacationLeave("vacationLeave"), + + /** + * 产假 + */ + maternityLeave("maternityLeave"), + /** + * 陪产假 + */ + paternityLeave("paternityLeave"), + /** + * 工作日加班 + */ + workingDayOvertime("workingDayOvertime"), + /** + * 休息日加班 + */ + restDayOvertime("restDayOvertime"), + /** + * 节假日加班 + */ + holidayOvertime("holidayOvertime"), + /** + * 出差 + */ + businessLeave("businessLeave"), + + /** + * 公出 + */ + officialBusiness("officialBusiness"), + + /** + * 流程的大类型,请假 + */ + LEAVE("LEAVE"), + /** + * + * 流程的大类型,出差 + */ + EVECTION("EVECTION"), + /** + * + * 流程的大类型,公出 + */ + OUT("OUT"), + /** + * + * 流程的大类型,加班 + */ + OVERTIME("OVERTIME"); + + private String flowType; + /** + * + * @param flowType 考勤报表需要的流程类型映射 + */ + FlowReportTypeEnum(String flowType) { + this.flowType = flowType; + } + + public String getFlowType() { + return flowType; + } + + public void setFlowType(String flowType) { + this.flowType = flowType; + } + +} diff --git a/src/com/engine/kq/enums/KQSettingsEnum.java b/src/com/engine/kq/enums/KQSettingsEnum.java new file mode 100644 index 0000000..29b8157 --- /dev/null +++ b/src/com/engine/kq/enums/KQSettingsEnum.java @@ -0,0 +1,106 @@ +package com.engine.kq.enums; + +/** + * 考勤自定义配置枚举 + */ +public enum KQSettingsEnum { + + /** + * 控制是否显示 请假类型里的单位 + */ + LEAVETYPE_UNIT("leavetype_unit","1", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005345,weaver.general.ThreadVarLanguage.getLang())+",1"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005346,weaver.general.ThreadVarLanguage.getLang())+"","","",""); + + /** + * 全局设置key + */ + private String main_key; + + /** + * 全局设置val + */ + private String main_val; + + /** + * 全局设置文字描述 + */ + private String main_desc; + + /** + * 全局设置下的具体页面 key + */ + private String sub_fun_key; + + /** + * 全局设置下的具体页面 val + */ + private String sub_fun_val; + + /** + * 全局设置下的具体页面 文字描述 + */ + private String sub_fun_desc; + /** + * + * @param main_key + * @param main_val + * @param main_desc + * @param sub_fun_key + * @param sub_fun_val + * @param sub_fun_desc + */ + KQSettingsEnum(String main_key,String main_val,String main_desc, String sub_fun_key,String sub_fun_val,String sub_fun_desc) { + this.main_key = main_key; + this.main_val = main_val; + this.main_desc = main_desc; + this.sub_fun_key = sub_fun_key; + this.sub_fun_val = sub_fun_val; + this.sub_fun_desc = sub_fun_desc; + } + + public String getMain_key() { + return main_key; + } + + public void setMain_key(String main_key) { + this.main_key = main_key; + } + + public String getMain_val() { + return main_val; + } + + public void setMain_val(String main_val) { + this.main_val = main_val; + } + + public String getMain_desc() { + return main_desc; + } + + public void setMain_desc(String main_desc) { + this.main_desc = main_desc; + } + + public String getSub_fun_key() { + return sub_fun_key; + } + + public void setSub_fun_key(String sub_fun_key) { + this.sub_fun_key = sub_fun_key; + } + + public String getSub_fun_val() { + return sub_fun_val; + } + + public void setSub_fun_val(String sub_fun_val) { + this.sub_fun_val = sub_fun_val; + } + + public String getSub_fun_desc() { + return sub_fun_desc; + } + + public void setSub_fun_desc(String sub_fun_desc) { + this.sub_fun_desc = sub_fun_desc; + }} diff --git a/src/com/engine/kq/enums/KqSplitFlowTypeEnum.java b/src/com/engine/kq/enums/KqSplitFlowTypeEnum.java new file mode 100644 index 0000000..00724ba --- /dev/null +++ b/src/com/engine/kq/enums/KqSplitFlowTypeEnum.java @@ -0,0 +1,82 @@ +package com.engine.kq.enums; + +public enum KqSplitFlowTypeEnum { + + /** + * 请假 + */ + LEAVE("kq_flow_split_leave","kq_flow_freeze_leave", 0), + /** + * 出差 + */ + EVECTION("kq_flow_split_evection","kq_flow_freeze_evection", 1), + /** + * 公出 + */ + OUT("kq_flow_split_out","kq_flow_freeze_out", 2), + /** + * 加班 + */ + OVERTIME("kq_flow_split_overtime","kq_flow_freeze_overtime", 3), + /** + * 异常流程 + */ + OTHER("kq_flow_split_other","kq_flow_freeze_other", 4), + /** + * 排班 + */ + SHIFT("","", 5), + /** + * 销假 + */ + LEAVEBACK("kq_flow_split_leaveback","kq_flow_freeze_leaveback", 6), + /** + * 补卡 补卡直接就读取的明细数据 + * 补卡直接插入签到签退表里 + */ + CARD("hrmschedulesign","", 7), + /** + * 考勤流程变更 + */ + PROCESSCHANGE("kq_flow_split_processchange","", 8); + + private String tablename; + private String freezeTablename; + private int flowtype; + + /** + * + * @param tablename 拆分表 + * @param freezeTablename 冻结表 + * @param flowtype 类型标识 + */ + KqSplitFlowTypeEnum(String tablename,String freezeTablename, int flowtype) { + this.tablename = tablename; + this.freezeTablename = freezeTablename; + this.flowtype = flowtype; + } + + public String getTablename() { + return tablename; + } + + public void setTablename(String tablename) { + this.tablename = tablename; + } + + public int getFlowtype() { + return flowtype; + } + + public void setFlowtype(int flowtype) { + this.flowtype = flowtype; + } + + public String getFreezeTablename() { + return freezeTablename; + } + + public void setFreezeTablename(String freezeTablename) { + this.freezeTablename = freezeTablename; + } +} diff --git a/src/com/engine/kq/enums/OverTimeComputingModeEnum.java b/src/com/engine/kq/enums/OverTimeComputingModeEnum.java new file mode 100644 index 0000000..786d25d --- /dev/null +++ b/src/com/engine/kq/enums/OverTimeComputingModeEnum.java @@ -0,0 +1,66 @@ +package com.engine.kq.enums; + +/** + * 加班类型枚举类 + * 1-需审批,以审批单为准 + * 2-需审批,以打卡为准,但是不能超过审批时长 + * 3-无需审批,根据打卡时间计算加班时长 + */ +public enum OverTimeComputingModeEnum { + + /** + * 需审批,以审批单为准 + */ + FLOW("1","需审批,以加班流程为准","500382"), + /** + * 需审批,以打卡为准,但是不能超过审批时长 + */ + FLOW2CARD("2","需审批,以打卡为准,但不能超过加班流程时长","500383"), + /** + * 无需审批,根据打卡时间计算加班时长 + */ + FLOWINCARD("4","需审批,打卡和流程均统计,取两者的交集","524827"), + /** + * 无需审批,根据打卡时间计算加班时长 + */ + CARD("3","无需审批,根据打卡时间计算加班时长","390837"); + + private String computingMode; + private String title; + private String label; + + /** + * + * @param computingMode + */ + OverTimeComputingModeEnum(String computingMode,String title,String label) { + this.computingMode = computingMode; + this.title = title; + this.label = label; + } + + public String getComputingMode() { + return computingMode; + } + + public void setComputingMode(String computingMode) { + this.computingMode = computingMode; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + +} diff --git a/src/com/engine/kq/enums/ReportColumnEnum.java b/src/com/engine/kq/enums/ReportColumnEnum.java new file mode 100644 index 0000000..178632c --- /dev/null +++ b/src/com/engine/kq/enums/ReportColumnEnum.java @@ -0,0 +1,42 @@ +package com.engine.kq.enums; + +public enum ReportColumnEnum { + + /** + * 迟到 + */ + BELATE("beLate", "2"), + /** + * 严重迟到迟到时长 + */ + GRAVEBELATEMINS("graveBeLateMins", "2"), + + /** + * 早退 + */ + LEAVEEARLY("leaveEarly", "2"); + + private String name; + private String value; + + ReportColumnEnum(String name, String value) { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public void getName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void getValue(String value) { + this.value = value; + } +} diff --git a/src/com/engine/kq/jucailin/cmd/calendar/GetCalendarSettingFormCmd.java b/src/com/engine/kq/jucailin/cmd/calendar/GetCalendarSettingFormCmd.java new file mode 100644 index 0000000..c99f70c --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/calendar/GetCalendarSettingFormCmd.java @@ -0,0 +1,132 @@ +package com.engine.kq.jucailin.cmd.calendar; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.jucailin.enums.FieldHtmlTypeEnum; +import com.engine.kq.jucailin.util.DbTools; +import com.google.common.collect.Maps; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author: sy + * @Description: 日历设置表单新建编辑返回 + * @Date: 2024/2/27 + **/ +public class GetCalendarSettingFormCmd extends AbstractCommonCommand> { + + public GetCalendarSettingFormCmd(Map params, User user){ + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List optionsList = new ArrayList(); + List itemList = new ArrayList(); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + + String billid = Util.null2String(params.get("billid")); + boolean hasFieldvalue = false; + Map dateMap = Maps.newHashMap(); + if (billid.length() != 0) { + dateMap = DbTools.getSqlToMap("select * from kq_calendar_name where id=?",billid); + if (dateMap.size() > 0) { + hasFieldvalue = true; + } + } + + HrmFieldBean hrmFieldBean = null; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("affiliation");//所属机构 + hrmFieldBean.setFieldlabel("17868"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.BROWSER.getKey()); + hrmFieldBean.setType("164"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("affiliation")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("calendar_name");//日历名称 + hrmFieldBean.setFieldlabel("531231"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.CHECKBOX.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("calendar_name")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("default_calendar");//默认日历 + hrmFieldBean.setFieldlabel("546298"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.INPUT.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("default_calendar")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules(""); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("attendance_organization");//适用范围 + hrmFieldBean.setFieldlabel("511548"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.TEXTAREA.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("attendance_organization")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + //searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("calendar_desc");//日历说明 + hrmFieldBean.setFieldlabel("546299"); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("calendar_desc")) : ""); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.TEXTAREA.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules(""); + itemList.add(searchConditionItem); + + + groupItem.put("items", itemList); + groupList.add(groupItem); + retmap.put("condition", groupList); + return retmap; + } +} diff --git a/src/com/engine/kq/jucailin/cmd/calendar/GetCalendarSettingListCmd.java b/src/com/engine/kq/jucailin/cmd/calendar/GetCalendarSettingListCmd.java new file mode 100644 index 0000000..5186b1c --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/calendar/GetCalendarSettingListCmd.java @@ -0,0 +1,88 @@ +package com.engine.kq.jucailin.cmd.calendar; + +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +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.kq.util.PageUidFactory; +import weaver.general.PageIdConst; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author: sy + * @Description: 日历设置列表 + * @Date: 2024/2/27 + **/ +public class GetCalendarSettingListCmd extends AbstractCommonCommand> { + + public GetCalendarSettingListCmd(Map params, User user){ + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + String backFields = "a.id,a.calendar_name,a.default_calendar,a.calendar_desc"; + String sqlFrom = " kq_calendar_name a"; + String sqlWhere = " (a.delete_type is null or a.delete_type <> '1') "; + String orderby = " id "; + String tableString = ""; + + String pageId = PageUidFactory.getHrmPageUid("KQCalendarSettingList"); + WeaTable table = new WeaTable(); + table.setPageID(pageId); + table.setPageUID(pageId + "_" + user.getUID()); + String pageSize = PageIdConst.getPageSize(pageId, user.getUID()); + table.setPagesize(pageSize); + + table.setBackfields(backFields); + table.setSqlform(sqlFrom); + table.setSqlwhere(sqlWhere); + table.setSqlprimarykey("id"); + table.setSqlorderby("id"); + table.getColumns().addAll(tableFields()); + + //主要用于 显示定制列以及 表格 每页展示记录数选择 +// String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); +// Util_TableMap.setVal(sessionkey, tableString); +// retmap.put("sessionkey", sessionkey); +// retmap.put("status", "1"); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + retmap.putAll(result.getResultMap()); + + return retmap; + } + /** + * 构建表格字段 + */ + private List tableFields() { + return new ArrayList() {{ + add(new WeaTableColumn("id").setDisplay(WeaBoolAttr.FALSE)); + add(new WeaTableColumn("10%", SystemEnv.getHtmlLabelName(531231, user.getLanguage()), "calendar_name"));//日历名称 + add(new WeaTableColumn("10%", SystemEnv.getHtmlLabelName(546298, user.getLanguage()), "default_calendar"));//默认日历 + add(new WeaTableColumn("10%", SystemEnv.getHtmlLabelName(546299, user.getLanguage()), "calendar_desc"));//日历说明 + + }}; + } + +// +} diff --git a/src/com/engine/kq/jucailin/cmd/common/DeleteDataCommonCmd.java b/src/com/engine/kq/jucailin/cmd/common/DeleteDataCommonCmd.java new file mode 100644 index 0000000..f5a1fcf --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/common/DeleteDataCommonCmd.java @@ -0,0 +1,42 @@ +package com.engine.kq.jucailin.cmd.common; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.jucailin.util.DateUtil; +import com.engine.kq.jucailin.util.DbTools; +import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.Map; + +@Slf4j +public class DeleteDataCommonCmd extends AbstractCommonCommand> { + + public DeleteDataCommonCmd(Map params, User user){ + this.params=params; + this.user=user; + } + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = Maps.newHashMap(); + String tableNames = Util.null2String(params.get("tableName")); + String billids = Util.null2String(params.get("billids")); + String deleteType = Util.null2String(params.get("deleteType")); + if ("".equals(deleteType)){ + deleteType = "delete_type"; + } + String sql = "update "+tableNames +" set "+deleteType+"=1,update_time=? where id in ("+billids+")"; +// log.info("DeleteDataCommonCmd sql : [{}]",sql); + resultMap.put("result", DbTools.update(sql,DateUtil.getCurrentTime())); + + return resultMap; + } +} diff --git a/src/com/engine/kq/jucailin/cmd/common/InsertDataCommonCmd.java b/src/com/engine/kq/jucailin/cmd/common/InsertDataCommonCmd.java new file mode 100644 index 0000000..0308140 --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/common/InsertDataCommonCmd.java @@ -0,0 +1,70 @@ +package com.engine.kq.jucailin.cmd.common; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.jucailin.genid.IdGenerator; +import com.engine.kq.jucailin.util.CommonUtil; +import com.engine.kq.jucailin.util.DbTools; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.List; +import java.util.Map; + +public class InsertDataCommonCmd extends AbstractCommonCommand> { + + public InsertDataCommonCmd(Map params, User user){ + this.params=params; + this.user=user; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + String tableName = Util.null2String(params.get("tableName")); + Map dataMap = (Map)params.get("data"); + Map mainMap = Maps.newHashMap(); + Map>> detailMap = Maps.newHashMap(); + for (Map.Entry entry: dataMap.entrySet()){ + String key = entry.getKey(); + if (key.startsWith("dt") && entry.getValue() instanceof List){ + detailMap.put(key,(List>)entry.getValue()); + }else { + mainMap.put(entry.getKey(),entry.getValue()); + } + } + long mainid = IdGenerator.generate(); + mainMap.put("id",mainid); + Map resultMap = Maps.newHashMap(); + resultMap.put("billid",mainid); + for (Map.Entry>> detail: detailMap.entrySet()){ + String detailTableName = tableName+"_"+detail.getKey(); + List> dataList = detail.getValue(); + if (dataList.size() > 0){ + List billids = Lists.newArrayList(); + for (Map data : dataList){ + long detailId = IdGenerator.generate(); + data.put("id",detailId); + data.put("mainid",mainid); + billids.add(detailId); + CommonUtil.fillSaveData(data,user); + } + resultMap.put("detailIds",billids); + if (!CommonUtil.insertBatch(dataList,detailTableName)){ + resultMap.put(detailTableName,"fail"); + } + } + } + if (!DbTools.update(CommonUtil.makeInsertSql(tableName,mainMap,user))){ + resultMap.put(tableName,"fail"); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/jucailin/cmd/common/QueryDataCommonCmd.java b/src/com/engine/kq/jucailin/cmd/common/QueryDataCommonCmd.java new file mode 100644 index 0000000..8502bbc --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/common/QueryDataCommonCmd.java @@ -0,0 +1,41 @@ +package com.engine.kq.jucailin.cmd.common; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.jucailin.util.DbTools; +import com.google.common.collect.Maps; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.Map; + +public class QueryDataCommonCmd extends AbstractCommonCommand> { + + public QueryDataCommonCmd(Map params, User user){ + this.params=params; + this.user=user; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + String tableNames = Util.null2String(params.get("tableNames")); + String billid = Util.null2String(params.get("billid")); + Map resultMap = Maps.newHashMap(); + for (String tableName :tableNames.split(",")){ + String sql = "select * from "+tableName+" where 1=1"; + if (tableName.contains("_dt")){ + sql += " and mainid="+billid; + }else { + sql += " and id="+billid; + } + resultMap.put(tableName,DbTools.getSqlToList(sql)); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/jucailin/cmd/common/UpdateDataCommonCmd.java b/src/com/engine/kq/jucailin/cmd/common/UpdateDataCommonCmd.java new file mode 100644 index 0000000..fd047b8 --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/common/UpdateDataCommonCmd.java @@ -0,0 +1,74 @@ +package com.engine.kq.jucailin.cmd.common; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.jucailin.genid.IdGenerator; +import com.engine.kq.jucailin.util.CommonUtil; +import com.engine.kq.jucailin.util.DbTools; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.List; +import java.util.Map; + +public class UpdateDataCommonCmd extends AbstractCommonCommand> { + + public UpdateDataCommonCmd(Map params, User user){ + this.params=params; + this.user=user; + } + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + String tableName = Util.null2String(params.get("tableName")); + Map dataMap = (Map)params.get("data"); + String billid = Util.null2String(params.get("billid")); + Map>> detailMap = Maps.newHashMap(); + Map mainMap = Maps.newHashMap(); + for (Map.Entry entry: dataMap.entrySet()){ + String key = entry.getKey(); + if (key.startsWith("dt") && entry.getValue() instanceof List){ + detailMap.put(key,(List>)entry.getValue()); + }else { + mainMap.put(entry.getKey(),entry.getValue()); + } + } + Map conditionMap = Maps.newHashMap(); + conditionMap.put("id",billid); + Map resultMap = Maps.newHashMap(); + resultMap.put("billid",billid); + if (!DbTools.update(CommonUtil.makeUpdateSql(tableName,mainMap,conditionMap))){ + resultMap.put(tableName,"fail"); + } + + for (Map.Entry>> detail: detailMap.entrySet()){ + String detailTableName = tableName+"_"+detail.getKey(); + List> dataList = detail.getValue(); + List resultList = Lists.newArrayList(); + for (Map data : dataList){ + String id = Util.null2String(data.get("dtid")); + data.remove("dtid"); + conditionMap.put("mainid",billid); + if (id.equals("")){ + conditionMap.put("id",IdGenerator.generate()); + }else { + conditionMap.put("id",Long.valueOf(id)); + } + if (!DbTools.update(CommonUtil.makeUpdateSql(detailTableName,data,conditionMap))){ + resultList.add(conditionMap.get("id").toString()); + } + } + if (resultList.size() > 0){ + resultMap.put(detailTableName,resultList); + } + } + return resultMap; + } +} diff --git a/src/com/engine/kq/jucailin/cmd/cycle/GetCycleFormCmd.java b/src/com/engine/kq/jucailin/cmd/cycle/GetCycleFormCmd.java new file mode 100644 index 0000000..84110e9 --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/cycle/GetCycleFormCmd.java @@ -0,0 +1,219 @@ +package com.engine.kq.jucailin.cmd.cycle; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.pc.table.WeaTableOperate; +import com.cloudstore.eccom.pc.table.WeaTableOperates; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.jucailin.enums.FieldHtmlTypeEnum; +import com.engine.kq.jucailin.util.DbTools; +import com.engine.kq.util.PageUidFactory; +import com.google.common.collect.Maps; +import weaver.general.PageIdConst; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetCycleFormCmd extends AbstractCommonCommand> { + + public GetCycleFormCmd(Map params, User user){ + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List optionsList = new ArrayList(); + List itemList = new ArrayList(); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + + String billid = Util.null2String(params.get("billid")); + boolean hasFieldvalue = false; + Map dateMap = Maps.newHashMap(); + if (billid.length() != 0) { + dateMap = DbTools.getSqlToMap("select * from kq_cycle where id=?",billid); + if (dateMap.size() > 0) { + hasFieldvalue = true; + } + } + + HrmFieldBean hrmFieldBean = null; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("organzation");//所属机构 + hrmFieldBean.setFieldlabel("17868"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.BROWSER.getKey()); + hrmFieldBean.setType("164"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("organzation")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + //searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("cyclename");//周期名称 + hrmFieldBean.setFieldlabel("388722"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.BROWSER.getKey()); + hrmFieldBean.setType("cycleset"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("cyclename")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + //searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("attendcycle");//考勤周期 + hrmFieldBean.setFieldlabel("15386"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.INPUT.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("attendcycle")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + //searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules(""); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("yearly");//年度 + hrmFieldBean.setFieldlabel("17138"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.INPUT.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("yearly")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + //searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("months");//月份 + hrmFieldBean.setFieldlabel("887"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.INPUT.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("months")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + //searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("startdate");// 开始日期 + hrmFieldBean.setFieldlabel("85"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.BROWSER.getKey()); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("startdate")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + //searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("enddate");// 结束日期 + hrmFieldBean.setFieldlabel("1323"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.BROWSER.getKey()); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("enddate")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + //searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("cyclestate");// 状态 + hrmFieldBean.setFieldlabel("602"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.SELECT.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("cyclestate")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", "待关账", true));//待关账 + optionsList.add(new SearchConditionOption("1", "已关账"));//部门 + optionsList.add(new SearchConditionOption("2", "已结账"));//已结账 + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules(""); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("closedate");// 关账日期 + hrmFieldBean.setFieldlabel("85"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.BROWSER.getKey()); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("closedate")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + //searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules(""); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("closetime");// 关账时间 + hrmFieldBean.setFieldlabel("85"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.BROWSER.getKey()); + hrmFieldBean.setType("19"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("closetime")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + //searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules(""); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("memo");// 备注 + hrmFieldBean.setFieldlabel("454"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.TEXTAREA.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("memo")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + //searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + + groupItem.put("items", itemList); + groupList.add(groupItem); + retmap.put("condition", groupList); + return retmap; + } + +} diff --git a/src/com/engine/kq/jucailin/cmd/cycle/GetCycleListCmd.java b/src/com/engine/kq/jucailin/cmd/cycle/GetCycleListCmd.java new file mode 100644 index 0000000..46b28da --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/cycle/GetCycleListCmd.java @@ -0,0 +1,113 @@ +package com.engine.kq.jucailin.cmd.cycle; + +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.pc.table.WeaTableOperate; +import com.cloudstore.eccom.pc.table.WeaTableOperates; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.util.PageUidFactory; +import weaver.general.PageIdConst; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetCycleListCmd extends AbstractCommonCommand> { + + public GetCycleListCmd(Map params, User user){ + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + String cyclename = Util.null2String(params.get("cyclename")); + String year = Util.null2String(params.get("year")); + + String backFields = "a.id,a.cyclename,a.attendcycle,a.yearly,a.months,a.startdate,a.enddate,a.cyclestate,a.closedate,a.closetime,a.memo"; + String sqlFrom = " kq_cycle a"; + String sqlWhere = " (a.delete_type is null or a.delete_type <> '1') "; + String orderby = " id "; + String tableString = ""; + + if (cyclename.length() > 0) { + sqlWhere += " and a.cyclename = "+cyclename ; + } + if (year.length() > 0){ + sqlWhere += "a.yearly = "+year; + } + + String pageId = PageUidFactory.getHrmPageUid("KQCycleList"); + WeaTable table = new WeaTable(); + table.setPageID(pageId); + table.setPageUID(pageId + "_" + user.getUID()); + String pageSize = PageIdConst.getPageSize(pageId, user.getUID()); + table.setPagesize(pageSize); + + table.setBackfields(backFields); + table.setSqlform(sqlFrom); + table.setSqlwhere(sqlWhere); + table.setSqlprimarykey("id"); + table.setSqlorderby("id"); + table.getColumns().addAll(tableFields()); + table.setOperates(getWeaTableOperates()); + + //主要用于 显示定制列以及 表格 每页展示记录数选择 +// String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); +// Util_TableMap.setVal(sessionkey, tableString); +// retmap.put("sessionkey", sessionkey); +// retmap.put("status", "1"); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + retmap.putAll(result.getResultMap()); + + return retmap; + } + /** + * 构建表格字段 + */ + private List tableFields() { + return new ArrayList() {{ + add(new WeaTableColumn("id").setDisplay(WeaBoolAttr.FALSE)); + add(new WeaTableColumn("10%", "周期名称", "cyclename","cyclename").setTransmethod("com.engine.kq.jucailin.util.ListConversionMethod.getCycleName").setOtherpara(user.getLanguage()+"").setColumn("cyclename"));//周期名称 + add(new WeaTableColumn("10%", "考勤周期", "attendcycle"));//考勤周期 + add(new WeaTableColumn("10%", "年度", "yearly"));//年度 + add(new WeaTableColumn("10%", "月份", "months"));//月份 + add(new WeaTableColumn("10%", "开始日期", "startdate"));//开始日期 + add(new WeaTableColumn("10%", "结束日期", "enddate"));//结束日期 + add(new WeaTableColumn("10%", "状态", "cyclestate","cyclestate").setTransmethod("com.engine.kq.jucailin.util.ListConversionMethod.getCyclestate").setOtherpara(user.getLanguage()+"").setColumn("cyclestate"));//状态 + add(new WeaTableColumn("10%", "关账日期", "closedate"));//关账日期 + add(new WeaTableColumn("10%", "关账时间", "closedate"));//关账时间 + add(new WeaTableColumn("10%", "备注", "memo"));//备注 + }}; + } + + /** + * 设置表格右侧操作按钮 + */ + private WeaTableOperates getWeaTableOperates() { + WeaTableOperates weaTableOperates = new WeaTableOperates(); + weaTableOperates.setOperate(new ArrayList() {{ + add(new WeaTableOperate(SystemEnv.getHtmlLabelName(91, user.getLanguage()), "javascript:doDel()", "1")); + add(new WeaTableOperate(SystemEnv.getHtmlLabelName(83, user.getLanguage()), "javascript:onLog()", "2")); + }}); + return weaTableOperates; + } +} diff --git a/src/com/engine/kq/jucailin/cmd/cycle/GetCycleSearchConditionCmd.java b/src/com/engine/kq/jucailin/cmd/cycle/GetCycleSearchConditionCmd.java new file mode 100644 index 0000000..3013962 --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/cycle/GetCycleSearchConditionCmd.java @@ -0,0 +1,95 @@ +package com.engine.kq.jucailin.cmd.cycle; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.jucailin.enums.FieldHtmlTypeEnum; +import com.engine.kq.jucailin.util.DbTools; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class GetCycleSearchConditionCmd extends AbstractCommonCommand> { + + public GetCycleSearchConditionCmd(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(); + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("reportName");//年度 + hrmFieldBean.setFieldlabel("17138"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.SELECT.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList = new ArrayList(); + String sql = "select yearly from kq_cycle where (delete_type is null or delete_type <> '1') group by yearly"; + List> dataList = DbTools.getSqlToList(sql); + if (dataList.size() > 0){ + optionsList.add(new SearchConditionOption(dataList.get(0).get("yearly"), dataList.get(0).get("yearly"),true)); + for (int i=1;i cycleMap = getCycleNameMap(); + List cycleOptionsList = new ArrayList(); + sql = "select cyclename from kq_cycle where (delete_type is null or delete_type <> '1') group by cyclename"; + List> cyclenames = DbTools.getSqlToList(sql); + if (cyclenames.size() > 0){ + cycleOptionsList.add(new SearchConditionOption(cyclenames.get(0).get("cyclename"), cycleMap.get(cyclenames.get(0).get("yearly")),true)); + for (int i=1;i getCycleNameMap(){ + String sql = "select id,cyclename from kq_cycle_setting where (delete_type is null or delete_type <> '1') "; + List> dataList = DbTools.getSqlToList(sql); + Map reusltMap = dataList.stream().collect(Collectors.toMap(e->e.get("id"),e->e.get("cyclename"))); + return reusltMap; + } +} diff --git a/src/com/engine/kq/jucailin/cmd/cycle/GetCycleSettingFormCmd.java b/src/com/engine/kq/jucailin/cmd/cycle/GetCycleSettingFormCmd.java new file mode 100644 index 0000000..0402e54 --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/cycle/GetCycleSettingFormCmd.java @@ -0,0 +1,136 @@ +package com.engine.kq.jucailin.cmd.cycle; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.pc.table.WeaTableOperate; +import com.cloudstore.eccom.pc.table.WeaTableOperates; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.jucailin.enums.FieldHtmlTypeEnum; +import com.engine.kq.jucailin.util.DbTools; +import com.engine.kq.util.PageUidFactory; +import com.google.common.collect.Maps; +import weaver.general.PageIdConst; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetCycleSettingFormCmd extends AbstractCommonCommand> { + + public GetCycleSettingFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List optionsList = new ArrayList(); + List itemList = new ArrayList(); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + + String billid = Util.null2String(params.get("billid")); + boolean hasFieldvalue = false; + Map dateMap = Maps.newHashMap(); + if (billid.length() != 0) { + dateMap = DbTools.getSqlToMap("select * from kq_cycle_setting where id=?",billid); + if (dateMap.size() > 0) { + hasFieldvalue = true; + } + } + + HrmFieldBean hrmFieldBean = null; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("organzation");//所属机构 + hrmFieldBean.setFieldlabel("17868"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.BROWSER.getKey()); + hrmFieldBean.setType("164"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("organzation")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("attendance_organization");//适用对象 + hrmFieldBean.setFieldlabel("18126"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.TEXTAREA.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("attendance_organization")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + //searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("cyclename");//周期名称 + hrmFieldBean.setFieldlabel("388722"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.INPUT.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("cyclename")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("ifdefault");//默认周期 + hrmFieldBean.setFieldlabel("149"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.CHECKBOX.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("ifdefault")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("memo");//说明 + hrmFieldBean.setFieldlabel("85"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.TEXTAREA.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("memo")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + + groupItem.put("items", itemList); + groupList.add(groupItem); + retmap.put("condition", groupList); + return retmap; + } + +} diff --git a/src/com/engine/kq/jucailin/cmd/cycle/GetCycleSettingListCmd.java b/src/com/engine/kq/jucailin/cmd/cycle/GetCycleSettingListCmd.java new file mode 100644 index 0000000..4ef6864 --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/cycle/GetCycleSettingListCmd.java @@ -0,0 +1,102 @@ +package com.engine.kq.jucailin.cmd.cycle; + +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.pc.table.WeaTableOperate; +import com.cloudstore.eccom.pc.table.WeaTableOperates; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.util.PageUidFactory; +import weaver.general.PageIdConst; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetCycleSettingListCmd extends AbstractCommonCommand> { + + public GetCycleSettingListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + String cyclename = Util.null2String(params.get("cyclename")); + + String backFields = "a.id,a.ifdefault,a.cyclename,a.memo"; + String sqlFrom = " kq_cycle_setting a"; + String sqlWhere = " (a.delete_type is null or a.delete_type <> '1') "; + String orderby = " id "; + String tableString = ""; + + if (cyclename.length() > 0) { + sqlWhere += " and a.cyclename = like '%" + cyclename + "%' "; + } + + String pageId = PageUidFactory.getHrmPageUid("KQCycleSettingList"); + WeaTable table = new WeaTable(); + table.setPageID(pageId); + table.setPageUID(pageId + "_" + user.getUID()); + String pageSize = PageIdConst.getPageSize(pageId, user.getUID()); + table.setPagesize(pageSize); + + table.setBackfields(backFields); + table.setSqlform(sqlFrom); + table.setSqlwhere(sqlWhere); + table.setSqlprimarykey("id"); + table.setSqlorderby("id"); + table.getColumns().addAll(tableFields()); + table.setOperates(getWeaTableOperates()); + + //主要用于 显示定制列以及 表格 每页展示记录数选择 +// String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); +// Util_TableMap.setVal(sessionkey, tableString); +// retmap.put("sessionkey", sessionkey); +// retmap.put("status", "1"); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + retmap.putAll(result.getResultMap()); + + return retmap; + } + /** + * 构建表格字段 + */ + private List tableFields() { + return new ArrayList() {{ + add(new WeaTableColumn("id").setDisplay(WeaBoolAttr.FALSE)); + add(new WeaTableColumn("20%", "名称", "cyclename"));//名称 + add(new WeaTableColumn("20%", "默认周期", "ifdefault"));//默认周期 + add(new WeaTableColumn("20%", "说明", "memo"));//说明 + }}; + } + + /** + * 设置表格右侧操作按钮 + */ + private WeaTableOperates getWeaTableOperates() { + WeaTableOperates weaTableOperates = new WeaTableOperates(); + weaTableOperates.setOperate(new ArrayList() {{ + add(new WeaTableOperate(SystemEnv.getHtmlLabelName(91, user.getLanguage()), "javascript:doDel()", "1")); + add(new WeaTableOperate(SystemEnv.getHtmlLabelName(83, user.getLanguage()), "javascript:onLog()", "2")); + }}); + return weaTableOperates; + } +} diff --git a/src/com/engine/kq/jucailin/cmd/cycle/GetCycleSettingTreeCmd.java b/src/com/engine/kq/jucailin/cmd/cycle/GetCycleSettingTreeCmd.java new file mode 100644 index 0000000..25e84ff --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/cycle/GetCycleSettingTreeCmd.java @@ -0,0 +1,58 @@ +package com.engine.kq.jucailin.cmd.cycle; + +import com.api.hrm.bean.TreeNode; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.jucailin.util.DbTools; +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 GetCycleSettingTreeCmd extends AbstractCommonCommand> { + + public GetCycleSettingTreeCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + TreeNode root = new TreeNode(); + String keyword = Util.null2String(params.get("keyword")).trim().toLowerCase(); + root.setId("0"); + root.setName("考勤周期"); + root.setType("0"); + root.setIcon("icon-coms-LargeArea"); + List groups = new ArrayList(); + String sql = "select id,cyclename from kq_cycle_setting where 1=1"; + if (keyword.length() > 0){ + sql += " and cyclename like '%" + keyword + "%' "; + } + List> dataList = DbTools.getSqlToList(sql); + for (Map data:dataList){ + TreeNode group = new TreeNode(); + group.setId(data.get("id")); + group.setName(data.get("cyclename")); + group.setPid("0"); + group.setType("1"); + group.setCanClick(true); + group.setIcon("icon-coms-LargeArea"); + groups.add(group); + } + root.setIsParent(groups.size()>0); + root.setSubs(groups); + Map treeObj = new HashMap(); + treeObj.put("rootCompany", root); + return treeObj; + } +} diff --git a/src/com/engine/kq/jucailin/cmd/cycle/GetCycledetailFormCmd.java b/src/com/engine/kq/jucailin/cmd/cycle/GetCycledetailFormCmd.java new file mode 100644 index 0000000..68a5851 --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/cycle/GetCycledetailFormCmd.java @@ -0,0 +1,129 @@ +package com.engine.kq.jucailin.cmd.cycle; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.jucailin.enums.FieldHtmlTypeEnum; +import com.engine.kq.jucailin.util.DbTools; +import com.google.common.collect.Maps; +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 GetCycledetailFormCmd extends AbstractCommonCommand> { + + public GetCycledetailFormCmd(Map params, User user){ + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List optionsList = new ArrayList(); + List itemList = new ArrayList(); + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + + String billid = Util.null2String(params.get("billid")); + boolean hasFieldvalue = false; + Map dateMap = Maps.newHashMap(); + if (billid.length() != 0) { + dateMap = DbTools.getSqlToMap("select * from kq_cycle_dt1 where id=?",billid); + if (dateMap.size() > 0) { + hasFieldvalue = true; + } + } + + HrmFieldBean hrmFieldBean = null; + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("department");//特殊部门 + hrmFieldBean.setFieldlabel("124"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.BROWSER.getKey()); + hrmFieldBean.setType("4"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("department")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + //searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("cyclestate");//状态 + hrmFieldBean.setFieldlabel("602"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.TEXTAREA.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("cyclestate")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList.add(new SearchConditionOption("0","开账",true)); + optionsList.add(new SearchConditionOption("1","关账")); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("close_date");//关账日期 + hrmFieldBean.setFieldlabel("97"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.BROWSER.getKey()); + hrmFieldBean.setType("2"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("close_date")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + //searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("close_time");//关账时间 + hrmFieldBean.setFieldlabel("277"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.BROWSER.getKey()); + hrmFieldBean.setType("19"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("close_time")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + //searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("memo");//说明 + hrmFieldBean.setFieldlabel("85"); + hrmFieldBean.setFieldhtmltype(FieldHtmlTypeEnum.TEXTAREA.getKey()); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setFieldvalue(hasFieldvalue ? Util.null2String(dateMap.get("memo")) : ""); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + // searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules(""); + itemList.add(searchConditionItem); + + + groupItem.put("items", itemList); + groupList.add(groupItem); + retmap.put("condition", groupList); + return retmap; + } + +} diff --git a/src/com/engine/kq/jucailin/cmd/cycle/GetCycledetailListCmd.java b/src/com/engine/kq/jucailin/cmd/cycle/GetCycledetailListCmd.java new file mode 100644 index 0000000..f04e980 --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/cycle/GetCycledetailListCmd.java @@ -0,0 +1,104 @@ +package com.engine.kq.jucailin.cmd.cycle; + +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.pc.table.WeaTableOperate; +import com.cloudstore.eccom.pc.table.WeaTableOperates; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.util.PageUidFactory; +import weaver.general.PageIdConst; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetCycledetailListCmd extends AbstractCommonCommand> { + public GetCycledetailListCmd(Map params, User user){ + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + String department = Util.null2String(params.get("department")); + + String backFields = "a.id,a.cyclestate,a.memo,a.close_date,a.close_time,a.department"; + String sqlFrom = " kq_cycle_dt1 a"; + String sqlWhere = " (a.delete_type is null or a.delete_type <> '1') "; + String orderby = " id "; + String tableString = ""; + + if (department.length() > 0) { + sqlWhere += " and a.department = "+department ; + } + + String pageId = PageUidFactory.getHrmPageUid("KQCycledetailList"); + WeaTable table = new WeaTable(); + table.setPageID(pageId); + table.setPageUID(pageId + "_" + user.getUID()); + String pageSize = PageIdConst.getPageSize(pageId, user.getUID()); + table.setPagesize(pageSize); + + table.setBackfields(backFields); + table.setSqlform(sqlFrom); + table.setSqlwhere(sqlWhere); + table.setSqlprimarykey("id"); + table.setSqlorderby("id"); + table.getColumns().addAll(tableFields()); + table.setOperates(getWeaTableOperates()); + + //主要用于 显示定制列以及 表格 每页展示记录数选择 +// String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); +// Util_TableMap.setVal(sessionkey, tableString); +// retmap.put("sessionkey", sessionkey); +// retmap.put("status", "1"); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + retmap.putAll(result.getResultMap()); + + return retmap; + } + /** + * 构建表格字段 + */ + private List tableFields() { + return new ArrayList() {{ + add(new WeaTableColumn("id").setDisplay(WeaBoolAttr.FALSE)); + add(new WeaTableColumn("10%", "特殊部门", "department","department").setTransmethod("com.engine.kq.jucailin.util.ListConversionMethod.getCycledetailstate").setOtherpara(user.getLanguage()+"").setColumn("department"));//特殊部门 + add(new WeaTableColumn("10%", "状态", "cyclestate","cyclestate").setTransmethod("com.engine.kq.jucailin.util.ListConversionMethod.getCycledetailstate").setOtherpara(user.getLanguage()+"").setColumn("cyclestate"));//状态 + add(new WeaTableColumn("10%", "关账日期", "close_date"));//关账日期 + add(new WeaTableColumn("10%", "关账时间", "close_time"));//关账时间 + add(new WeaTableColumn("10%", "说明", "memo"));//说明 + }}; + } + + /** + * 设置表格右侧操作按钮 + */ + private WeaTableOperates getWeaTableOperates() { + WeaTableOperates weaTableOperates = new WeaTableOperates(); + weaTableOperates.setOperate(new ArrayList() {{ + add(new WeaTableOperate(SystemEnv.getHtmlLabelName(91, user.getLanguage()), "javascript:doDel()", "1")); + add(new WeaTableOperate(SystemEnv.getHtmlLabelName(83, user.getLanguage()), "javascript:onLog()", "2")); + }}); + return weaTableOperates; + } +} diff --git a/src/com/engine/kq/jucailin/cmd/personGroup/GetPersonGroupListCmd.java b/src/com/engine/kq/jucailin/cmd/personGroup/GetPersonGroupListCmd.java new file mode 100644 index 0000000..12683e1 --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/personGroup/GetPersonGroupListCmd.java @@ -0,0 +1,113 @@ +package com.engine.kq.jucailin.cmd.personGroup; + +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.pc.table.WeaTableOperate; +import com.cloudstore.eccom.pc.table.WeaTableOperates; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.util.PageUidFactory; +import weaver.general.PageIdConst; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetPersonGroupListCmd extends AbstractCommonCommand> { + + public GetPersonGroupListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + String groupname = Util.null2String(params.get("groupname")); + + String subcompanyId = Util.null2String(params.get("subcompanyid")); + + String userfor = Util.null2String(params.get("userfor")); + + String backFields = "a.id,a.organzation,a.groupname,a.userfor,a.memo"; + String sqlFrom = " kq_persongroup a"; + String sqlWhere = " (delete_type is null or delete_type <> '1') "; + String orderby = " id "; + String tableString = ""; + + if (subcompanyId.length() > 0) { + sqlWhere += " and organzation = " + subcompanyId; + } + if (groupname.length() > 0) { + sqlWhere += " and groupname like '%" + groupname + "%' "; + } + if (userfor.length() > 0) { + sqlWhere += " and userfor = " + userfor; + } + + + String pageId = PageUidFactory.getHrmPageUid("KQPersonGroupList"); + WeaTable table = new WeaTable(); + table.setPageID(pageId); + table.setPageUID(pageId + "_" + user.getUID()); + String pageSize = PageIdConst.getPageSize(pageId, user.getUID()); + table.setPagesize(pageSize); + + table.setBackfields(backFields); + table.setSqlform(sqlFrom); + table.setSqlwhere(sqlWhere); + table.setSqlprimarykey("id"); + table.setSqlorderby("id"); + table.getColumns().addAll(tableFields()); + table.setOperates(getWeaTableOperates()); + + //主要用于 显示定制列以及 表格 每页展示记录数选择 +// String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); +// Util_TableMap.setVal(sessionkey, tableString); +// retmap.put("sessionkey", sessionkey); +// retmap.put("status", "1"); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + retmap.putAll(result.getResultMap()); + + return retmap; + } + /**ListConversionMethod + * 构建表格字段 + */ + private List tableFields() { + return new ArrayList() {{ + add(new WeaTableColumn("id").setDisplay(WeaBoolAttr.FALSE)); + add(new WeaTableColumn("20%", "所属机构", "organzation"));//所属机构 + add(new WeaTableColumn("20%", "分组名称", "groupname"));//分组名称 + add(new WeaTableColumn("20%", "应用场景", "userfor","userfor").setTransmethod("com.engine.jucailin.util.ListConversionMethod.getPersonGroupUserFor").setOtherpara(user.getLanguage()+"").setColumn("userfor"));//应用场景 + add(new WeaTableColumn("20%", "说明", "memo"));//说明 + }}; + } + + /** + * 设置表格右侧操作按钮 + */ + private WeaTableOperates getWeaTableOperates() { + WeaTableOperates weaTableOperates = new WeaTableOperates(); + weaTableOperates.setOperate(new ArrayList() {{ + add(new WeaTableOperate(SystemEnv.getHtmlLabelName(91, user.getLanguage()), "javascript:doDel()", "1")); + add(new WeaTableOperate(SystemEnv.getHtmlLabelName(83, user.getLanguage()), "javascript:onLog()", "2")); + }}); + return weaTableOperates; + } +} diff --git a/src/com/engine/kq/jucailin/cmd/personGroup/GetSuitOrganzationFormCmd.java b/src/com/engine/kq/jucailin/cmd/personGroup/GetSuitOrganzationFormCmd.java new file mode 100644 index 0000000..a9be099 --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/personGroup/GetSuitOrganzationFormCmd.java @@ -0,0 +1,304 @@ +package com.engine.kq.jucailin.cmd.personGroup; + +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.api.hrm.bean.HrmFieldBean; +import com.api.hrm.bean.SelectOption; +import com.api.hrm.bean.WeaRadioGroup; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.jucailin.util.Constant; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetSuitOrganzationFormCmd extends AbstractCommonCommand> { + + public GetSuitOrganzationFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + Map groupitem = null; + List itemlist = null; + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + /*考勤组成员相关id*/ + String billid = Util.null2String(params.get("billid")); + String tableName = Util.null2String(params.get("tableName")); + String modeId = Constant.modeToTable.get(tableName); + String memberTableName = "kq_groupmember_"+modeId; + + String groupmemberId = Util.null2String(params.get("groupmemberId")); + String validateFrom = ""; + String validateTo = ""; + String type = ""; + if(!"".equals(groupmemberId)) { + String editSql = "select * from "+memberTableName+" kg where (delete_type is null or delete_type<>1) and id=?"; + rs.executeQuery(editSql, groupmemberId); + if (rs.next()) { + validateFrom = Util.null2String(rs.getString("validatefrom")); + validateTo = Util.null2String(rs.getString("validateto")); + type = Util.null2String(rs.getString("membertype")); + } + } + + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + itemlist = new ArrayList(); + groupitem = new HashMap(); + //下拉 + List condition = new ArrayList(); + if("".equals(groupmemberId)) { + //类型、对象、成员级别 + String[] fields = new String[]{"type,63,5,1", "resourceid,106,3,17", "subcompanyid,106,3,164", "departmentid,106,3,4", + "jobtitle,106,3,24", "jobtitlelevel,28169,5,1", "jobtitlesubcompany,19437,3,164", "jobtitledepartment,19438,3,4", + "seclevel,683,1,scope"}; + groupitem.put("title", SystemEnv.getHtmlLabelName(1361, Util.getIntValue(user.getLanguage()))); + groupitem.put("defaultshow", true); + for(int i=0;i statusOptions = new ArrayList(); + if(hrmFieldBean.getFieldname().equals("type")){ + statusOptions.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(179,user.getLanguage()),true)); + statusOptions.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(141,user.getLanguage()))); + statusOptions.add(new SearchConditionOption("3",SystemEnv.getHtmlLabelName(124,user.getLanguage()))); + statusOptions.add(new SearchConditionOption("5",SystemEnv.getHtmlLabelName(6086,user.getLanguage()))); + if(!new ManageDetachComInfo().appDetachDisableAll(user)) { + statusOptions.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(1340, user.getLanguage()))); + } + searchConditionItem.setOptions(statusOptions); + }else if(hrmFieldBean.getFieldname().equals("jobtitlelevel")){ + statusOptions.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(140,user.getLanguage()),true)); + statusOptions.add(new SearchConditionOption("3",SystemEnv.getHtmlLabelName(19438,user.getLanguage()))); + statusOptions.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(19437,user.getLanguage()))); + searchConditionItem.setOptions(statusOptions); + } + } + searchConditionItem.setLabelcol(6); + if(hrmFieldBean.getFieldname().equals("typevalue")||hrmFieldBean.getFieldname().equals("jobtitle") + ||hrmFieldBean.getFieldname().equals("subcompanyid") || hrmFieldBean.getFieldname().equals("departmentid")){ + searchConditionItem.setFieldcol(10); + }else{ + searchConditionItem.setFieldcol(18); + } + + if(!hrmFieldBean.getFieldname().equals("type")||!hrmFieldBean.getFieldname().equals("seclevel")){ + searchConditionItem.setViewAttr(3); + } + if (fieldinfo[2].equals("3") && !"2".equals(fieldinfo[3])) { + searchConditionItem.getBrowserConditionParam().setViewAttr(3); + searchConditionItem.getBrowserConditionParam().setIsSingle(false); + } + if(hrmFieldBean.getFieldname().equals("jobtitlesubcompany")||hrmFieldBean.getFieldname().equals("jobtitledepartment")){ + searchConditionItem.getBrowserConditionParam().setIsSingle(true); + } + if(hrmFieldBean.getFieldname().equals("seclevel")){ + List value1 = new ArrayList(); + value1.add(0); + value1.add(100); + searchConditionItem.setValue(value1); + searchConditionItem.setConditionType(ConditionType.INPUT_INTERVAL); + } + itemlist.add(searchConditionItem); + } + ConditionFactory conditionFactory = new ConditionFactory(user); + searchConditionItem = conditionFactory.createCondition(ConditionType.CHECKBOX, "125963","alllevel",true); + itemlist.add(searchConditionItem); + + condition.add(itemlist.get(0)); + + List itemList = validateItemlist(hrmFieldSearchConditionComInfo, validateFrom, validateTo); + //人力 + Map conditionMap = new HashMap(); + List conditionlist = new ArrayList(); + List conditionlist2 = new ArrayList(); + conditionlist2.add(itemlist.get(1)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(0)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(1)); + conditionlist.add(conditionlist2); + conditionMap.put("1",conditionlist); + + //分部 + conditionlist2 = new ArrayList(); + conditionlist = new ArrayList(); + conditionlist2.add(itemlist.get(2)); + //暂不支持包含下级 + //conditionlist2.add(itemlist.get(11)); + conditionlist.add(conditionlist2); + + conditionlist2 = new ArrayList(); + conditionlist2.add(itemlist.get(8)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(0)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(1)); + conditionlist.add(conditionlist2); + conditionMap.put("2",conditionlist); + + //部门 + conditionlist2 = new ArrayList(); + conditionlist = new ArrayList(); + conditionlist2.add(itemlist.get(3)); + //暂不支持包含下级 + //conditionlist2.add(itemlist.get(11)); + conditionlist.add(conditionlist2); + + conditionlist2 = new ArrayList(); + conditionlist2.add(itemlist.get(8)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(0)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(1)); + conditionlist.add(conditionlist2); + conditionMap.put("3",conditionlist); + + //岗位 + conditionlist2 = new ArrayList(); + conditionlist = new ArrayList(); + conditionlist2.add(itemlist.get(4)); + conditionlist.add(conditionlist2); + + conditionlist2 = new ArrayList(); + conditionlist2.add(itemlist.get(5)); + + WeaRadioGroup wrg = new WeaRadioGroup(); + wrg.setLabel(SystemEnv.getHtmlLabelName(28169, user.getLanguage())); + List option = new ArrayList(); + Map selectLinkageDatas = new HashMap(); + selectLinkageDatas.put("2" ,itemlist.get(6)); + selectLinkageDatas.put("3" ,itemlist.get(7)); + wrg.setSelectLinkageDatas(selectLinkageDatas); + option.add(new SelectOption("1",SystemEnv.getHtmlLabelName(140, user.getLanguage()),true)); + option.add(new SelectOption("2",SystemEnv.getHtmlLabelName(19437, user.getLanguage()))); + option.add(new SelectOption("3",SystemEnv.getHtmlLabelName(19438, user.getLanguage()))); + + List domkey = new ArrayList(); + wrg.setOptions(option); + wrg.setConditionType("SELECT_LINKAGE"); + wrg.setFieldcol(18); + wrg.setLabelcol(6); + domkey.add("jobtitlelevel"); + wrg.setDomkey(domkey); + + conditionlist2 = new ArrayList(); + conditionlist2.add(wrg); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList(); + conditionlist2.add(itemlist.get(8)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(0)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(1)); + conditionlist.add(conditionlist2); + conditionMap.put("5",conditionlist); + + //所有人 + conditionlist = new ArrayList(); + conditionlist2 = new ArrayList(); + conditionlist2.add(itemlist.get(8)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(0)); + conditionlist.add(conditionlist2); + conditionlist2 = new ArrayList<>(); + conditionlist2.add(itemList.get(1)); + conditionlist.add(conditionlist2); + conditionMap.put("6",conditionlist); + + condition.add(conditionMap); + } else { + List itemList = validateItemlist(hrmFieldSearchConditionComInfo, validateFrom, validateTo); + condition.add(itemList.get(0)); + condition.add(itemList.get(1)); + } + retmap.put("conditions", condition); + retmap.put("status", "1"); + retmap.put("type", type); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private List validateItemlist(HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo, String validateFromDate, String validateToDate) { + List itemlist = new ArrayList<>(); + HrmFieldBean hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("validateFromDate");//开始日期 + hrmFieldBean.setFieldlabel("19548"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(validateFromDate); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setTip(SystemEnv.getHtmlLabelName(546201,user.getLanguage())); + SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("validateToDate");//结束日期 + hrmFieldBean.setFieldlabel("19547"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(validateToDate); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(2); + hrmFieldBean.setTip(SystemEnv.getHtmlLabelName(546202,user.getLanguage())); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + itemlist.add(searchConditionItem); + + return itemlist; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/jucailin/cmd/personGroup/GetSuitOrganzationListCmd.java b/src/com/engine/kq/jucailin/cmd/personGroup/GetSuitOrganzationListCmd.java new file mode 100644 index 0000000..b991bcb --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/personGroup/GetSuitOrganzationListCmd.java @@ -0,0 +1,174 @@ +package com.engine.kq.jucailin.cmd.personGroup; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.WeaTable; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.pc.table.WeaTableOperate; +import com.cloudstore.eccom.pc.table.WeaTableOperates; +import com.cloudstore.eccom.result.WeaResultMsg; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.jucailin.util.Constant; +import com.engine.kq.util.PageUidFactory; +import weaver.conn.RecordSet; +import weaver.general.PageIdConst; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.systemright.CheckSubCompanyRight; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetSuitOrganzationListCmd extends AbstractCommonCommand> { + + public GetSuitOrganzationListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + + RecordSet rs = new RecordSet(); + try { + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + //String groupId = Util.null2String(params.get("groupId")); + // String subcompanyId = new KQGroupComInfo().getSubcompanyid(groupId); + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权 + //int operatelevel = -1; + int operatelevel = 2; +// if(hrmdetachable) { +// operatelevel = checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(), "HrmKQGroup:Add", Util.getIntValue(subcompanyId, -1)); +// }else{ +// operatelevel = 2; +// } +// +// if(user.getUID() == 1){ +// operatelevel = 2; +// } + + String billid = Util.null2String(params.get("billid")); + String tableName = Util.null2String(params.get("tableName")); + String modeId = Constant.modeToTable.get(tableName); + + String hrmName = Util.null2String(params.get("hrmName")); + String hrmJobtitle = Util.null2String(params.get("hrmJobtitle")); + String hrmSubcompany = Util.null2String(params.get("hrmSubcompany")); + String department = Util.null2String(params.get("department")); + + String validateFromDate = Util.null2String(params.get("validateFromDate")); + String validateToDate = Util.null2String(params.get("validateToDate")); + + String backfields = " * "; + String fromSql = " kq_groupmember_"+modeId+" a "; + String sqlWhere = " (delete_type is null "+(rs.getDBType().equals("oracle") ? "" : " or delete_type=0")+") "; + String orderby = " a.id asc " ; + + if (billid.length() > 0){ + sqlWhere += " and dataid="+billid; + } + + if(hrmName.length() > 0 ){ + sqlWhere += " and ( exists ( select 1 from hrmresource where a.typevalue=id and a.type=1 and lastname like '%"+hrmName+"%') " + + " or exists ( select 1 from hrmjobtitles where a.typevalue=id and a.type=5 and jobtitlename like '%"+hrmName+"%')" + + " or exists ( select 1 from hrmsubcompany where a.typevalue=id and a.type=2 and subcompanyname like '%"+hrmName+"%')" + + " or exists ( select 1 from hrmdepartment where a.typevalue=id and a.type=3 and departmentname like '%"+hrmName+"%')) "; + + } + if(hrmJobtitle.length() > 0){ + sqlWhere += " and a.membertype=5 and a.typevalue = "+hrmJobtitle; + } + if(hrmSubcompany.length() > 0){ + sqlWhere += " and a.membertype=2 and a.typevalue = "+hrmSubcompany; + } + if(department.length() >0){ + sqlWhere += " and a.membertype=3 and a.typevalue = "+department ; + } + + if(validateFromDate.length() >0){ + if(rs.getDBType().equalsIgnoreCase("oracle")) { + sqlWhere += " and ('"+validateFromDate+"' between nvl(a.validatefrom,'2000-01-01') and nvl(a.validateto,'2999-12-31')) "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + sqlWhere += " and ('"+validateFromDate+"' between ifnull(a.validatefrom,'2000-01-01') and ifnull(a.validateto,'2999-12-31')) "; + }else { + sqlWhere += " and ('"+validateFromDate+"' between isnull(a.validatefrom,'2000-01-01') and isnull(a.validateto,'2999-12-31')) "; + } + } + if(validateToDate.length() >0){ + if(rs.getDBType().equalsIgnoreCase("oracle")) { + sqlWhere += " and ('"+validateToDate+"' between nvl(a.validatefrom,'2000-01-01') and nvl(a.validateto,'2999-12-31')) "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + sqlWhere += " and ('"+validateToDate+"' between ifnull(a.validatefrom,'2000-01-01') and ifnull(a.validateto,'2999-12-31')) "; + }else { + sqlWhere += " and ('"+validateToDate+"' between isnull(a.validatefrom,'2000-01-01') and isnull(a.validateto,'2999-12-31')) "; + } + } + + String pageUid = PageUidFactory.getHrmPageUid("KQGroupMembersSearchList"); + + String operateString= ""; +// operateString+=" "; + //operateString+=" "; + if(operatelevel > 1) { + operateString += " "; + } + operateString+=" "; + operateString+=""; + String tableString =" "+ + " "+ +// " "+ + operateString+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + "
"; + + //主要用于 显示定制列以及 表格 每页展示记录数选择 + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + retmap.put("sessionkey", sessionkey); + retmap.put("status", "1"); + if(operatelevel > 0){ + retmap.put("canAdd", true); + }else{ + retmap.put("canAdd", false); + } + if(operatelevel > 1){ + retmap.put("canDel", true); + }else{ + retmap.put("canDel", false); + } + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + + return retmap; + } + +} diff --git a/src/com/engine/kq/jucailin/cmd/personGroup/SaveSuitOrganzationCmd.java b/src/com/engine/kq/jucailin/cmd/personGroup/SaveSuitOrganzationCmd.java new file mode 100644 index 0000000..41015be --- /dev/null +++ b/src/com/engine/kq/jucailin/cmd/personGroup/SaveSuitOrganzationCmd.java @@ -0,0 +1,296 @@ +package com.engine.kq.jucailin.cmd.personGroup; + +import com.alibaba.fastjson.JSON; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.jucailin.genid.IdGenerator; +import com.engine.kq.jucailin.util.Constant; +import com.engine.kq.log.KQLog; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.Reminder.KQAutoCardTask; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SaveSuitOrganzationCmd extends AbstractCommonCommand> { + private KQLog kqLog = new KQLog(); + private SimpleBizLogger logger; + public SaveSuitOrganzationCmd(Map params, User user) { + this.user = user; + this.params = params; +// String groupId = Util.null2String(params.get("groupId")); +// this.boforeLog(groupId); + } + + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + kqLog.info("params::::::::::::"+ JSON.toJSONString(params)); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + String tableName = Util.null2String(params.get("tableName")); + String modeid = Constant.modeToTable.get(tableName); + String billid = Util.null2String(params.get("billid")); + String memberTableName = "kq_groupmember_"+modeid; + String type = Util.null2String(params.get("type")); + String resourceid = Util.null2String(params.get("resourceid")); + String subcompanyid = Util.null2String(params.get("subcompanyid")); + String departmentid = Util.null2String(params.get("departmentid")); + String alllevel = Util.null2String(params.get("alllevel")).trim(); + String jobtitle = Util.null2String(params.get("jobtitle")).trim(); + String jobtitlelevel = Util.null2String(params.get("jobtitlelevel")).trim(); + String jobtitlesubcompany = Util.null2String(params.get("jobtitlesubcompany")).trim(); + String jobtitledepartment = Util.null2String(params.get("jobtitledepartment")).trim(); + + String groupmemberId = Util.null2String(params.get("groupmemberId")).trim(); + String validateFromDate = Util.null2String(params.get("validateFromDate")).trim(); + String validateToDate = Util.null2String(params.get("validateToDate")).trim(); + + String seclevel = Util.null2String(params.get("seclevel")).trim(); + String seclevelto = Util.null2String(params.get("seclevelto")).trim(); + + if(!"".equals(groupmemberId)) { + String searchSql = "select * from "+memberTableName+" where id="+groupmemberId; + rs.executeQuery(searchSql); + if(rs.next()) { + type = Util.null2String(rs.getString("membertype")); + if("1".equals(type)) { + resourceid = Util.null2String(rs.getString("typevalue")); + } else if("2".equals(type)) { + subcompanyid = Util.null2String(rs.getString("typevalue")); + } else if("3".equals(type)) { + departmentid = Util.null2String(rs.getString("typevalue")); + } else if("5".equals(type)) { + jobtitle = Util.null2String(rs.getString("typevalue")); + } + alllevel = Util.null2String(rs.getString("alllevel")); + jobtitlelevel = Util.null2String(rs.getString("jobtitlelevel")); + if("2".equals(jobtitlelevel)) {//岗位--分部 + jobtitlesubcompany = Util.null2String(rs.getString("jobtitlelevelvalue")); + } else if("3".equals(jobtitlelevel)) {//岗位--部门 + jobtitledepartment = Util.null2String(rs.getString("jobtitlelevelvalue")); + } + seclevel = Util.null2String(rs.getString("seclevel")); + seclevelto = Util.null2String(rs.getString("seclevelto")); + } + } + kqLog.info("validateFromDate1111>>>>>>>>"+validateFromDate+"::::validateToDate::::"+validateToDate); + if(!"".equals(validateFromDate) || !"".equals(validateToDate)) { + // 1. 查找同级别的有效期 + sql = "select * from "+memberTableName+" where membertype=" + type + " and (delete_type is null or delete_type <> '1') and dataid="+billid+" " ; + if(!"".equals(groupmemberId)) { + sql += "and id != "+groupmemberId; + } + if (rs.getDBType().equalsIgnoreCase("sqlserver") + || rs.getDBType().equalsIgnoreCase("mysql")) { + sql += " and (validatefrom is not null or validatefrom<>'')"; + sql += " and (validateto is not null or validateto<>'')"; + } else { + sql += " and ((validatefrom is not null)"; + sql += " or (validateto is not null))"; + } + switch (Util.getIntValue(type)) { + case 1: + sql += " and typevalue in(" + resourceid + ")"; + break; + case 2: + sql += " and typevalue in(" + subcompanyid + ") and (" + seclevel + " between seclevel and seclevelto or " + seclevelto + " between seclevel and seclevelto)"; + break; + case 3: + sql += " and typevalue in(" + departmentid + ") and (" + seclevel + " between seclevel and seclevelto or " + seclevelto + " between seclevel and seclevelto)"; + break; + case 5: + sql += " and typevalue in(" + jobtitle + ") and (" + seclevel + " between seclevel and seclevelto or " + + seclevelto + " between seclevel and seclevelto)"; + if("2".equals(jobtitlelevel)) { + sql += " and (jobtitlelevelvalue in("+jobtitlesubcompany+") or jobtitlelevel=1)"; + } else if("3".equals(jobtitlelevel)) { + sql += " and (jobtitlelevelvalue in("+jobtitledepartment+") or jobtitlelevel=1)"; + } + break; + case 6: + sql += " and typevalue in(0)"; + break; + default: + break; + } + rs.executeQuery(sql); + new KQLog().info("sql>>>>>>>>>>>>>>>>"+sql); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + while (rs.next()) { + String groupid = Util.null2String(rs.getString("groupid")); + String validatefrom = Util.null2String(rs.getString("validatefrom")); + validatefrom = "".equals(validatefrom) ? "2000-01-01" : validatefrom; + String validateto = Util.null2String(rs.getString("validateto")); + validateto = "".equals(validateto) ? "2999-12-31" : validateto; + if (validateFromDate.compareTo(validatefrom)<=0 && validateToDate.compareTo(validatefrom)>=0 + || validateFromDate.compareTo(validateto)<=0 && validateToDate.compareTo(validateto)>=0) { + retmap.put("status", "-1"); + String kqGroupName = kqGroupComInfo.getGroupname(groupid); + retmap.put("message", "和'"+kqGroupName+"'考勤组的考勤组成员中有效期有交叉,不允许保存"); + return retmap; + } + } + } + kqLog.info("validateFromDate2222>>>>>>>>"+validateFromDate+"::::validateToDate::::"+validateToDate+":::groupmemberId::"+groupmemberId); + if(!"".equals(groupmemberId)) { + sql = " UPDATE "+memberTableName+" set validatefrom=? ,validateto=? where id=?"; + rs.executeUpdate(sql,(validateFromDate.length() == 0 ? "null" : validateFromDate),(validateToDate.length() == 0 ? "null" : validateToDate),groupmemberId); + } else { + String jobtitlelevelvalue = ""; + if (jobtitlelevel.equals("2")) { + jobtitlelevelvalue = jobtitlesubcompany; + } else if (jobtitlelevel.equals("3")) { + jobtitlelevelvalue = jobtitledepartment; + } + + + String objId = "0"; + switch (Util.getIntValue(type)) { + case 1: + objId = resourceid; + break; + case 2: + objId = subcompanyid; + break; + case 3: + objId = departmentid; + break; + case 5: + objId = jobtitle; + break; + default: + break; + } + String[] arrObjIds = Util.splitString(objId, ","); + new KQLog().info("arrObjIds>>>>>>>>>>>>>>>>" + objId); + if("".equals(validateFromDate) && "".equals(validateToDate)) { + for (int i = 0; i < arrObjIds.length; i++) { + //考勤组成员重复判断,单条判断下 + sql = " select count(id) from "+memberTableName+" where dataid=" + billid + + " and (delete_type is null or delete_type <> '1') and typevalue = " + arrObjIds[i] + " and membertype = " + type; + if (alllevel.length() > 0) { + sql += " and alllevel = " + alllevel; + } + if (seclevel.length() > 0) { + sql += " and seclevel = " + seclevel; + } + if (seclevelto.length() > 0) { + sql += " and seclevelto = " + seclevelto; + } + if (jobtitlelevelvalue.length() > 0) { + sql += " and jobtitlelevelvalue = " + jobtitlelevelvalue; + } + if (jobtitlelevel.length() > 0) { + sql += " and jobtitlelevel = " + jobtitlelevel; + } + rs.executeQuery(sql); + new KQLog().info("sql2222>>>>>>>>>>>>>>>>" + sql); + if (rs.next() && rs.getInt(1) > 0) { + if (arrObjIds.length == 1) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(17567, user.getLanguage())); + return retmap; + } else { + continue; + } + } + } + } + + //人员类型,后面的需要替换前面的数据 + //TODO 现在有有效期,一个人是可以存在多个考勤组内的 +// if(type.equals("1")){ +// sql = "update kq_groupmember set delete_type=1 where type=1 and typevalue= ? "; +// rs.executeUpdate(sql,arrObjIds[i]); +// } + for (int i = 0; i < arrObjIds.length; i++) { + sql = " INSERT INTO "+memberTableName+" (id, dataid ,typevalue ,membertype ,alllevel ," + + " seclevel ,seclevelto ,jobtitlelevelvalue ,jobtitlelevel,validatefrom,validateto) " + + " VALUES ( "+ IdGenerator.generate()+", " + billid + ", " + arrObjIds[i] + " , '" + type + "', " + + " " + (alllevel.length() == 0 ? "null" : alllevel) + "," + (seclevel.length() == 0 ? "null" : seclevel) + "," + + " " + (seclevelto.length() == 0 ? "null" : seclevelto) + ", " + (jobtitlelevelvalue.length() == 0 ? "null" : jobtitlelevelvalue) + "," + + (jobtitlelevel.length() == 0 ? "null" : jobtitlelevel) + "," + (validateFromDate.length() == 0 ? "null" : "'" + validateFromDate + "'") + "," + + (validateToDate.length() == 0 ? "null" : "'" + validateToDate + "'") + ")"; + rs.executeUpdate(sql); + } + } + + new KQGroupMemberComInfo().removeCache(); + //格式化考勤 +// new KQFormatBiz().formatDateByGroupId(groupId, DateUtil.getCurrentDate()); + + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + String auto_checkout = kQGroupComInfo.getAuto_checkout(billid); + String auto_checkin = kQGroupComInfo.getAuto_checkin(billid); + if("1".equalsIgnoreCase(auto_checkin) || "1".equalsIgnoreCase(auto_checkout)){ + //如果开启了自动打卡,保存考勤组成员之后需要格式化下缓存 + KQAutoCardTask kqAutoCardTask = new KQAutoCardTask(); + kqAutoCardTask.initAutoCardTask(billid); + } + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private void boforeLog(String id){ + this.logger = new SimpleBizLogger(); + BizLogContext logContext = new BizLogContext(); + logContext.setDateObject(new Date()); + logContext.setLogType(BizLogType.HRM_ENGINE); + logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQGROUP); + logContext.setParams(params); + logger.setUser(user);//当前操作人 + + String mainSql = " select * from kq_group where id= " + id; + logger.setMainSql(mainSql);//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("groupname"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_groupmember where (delete_type is null or delete_type <> '1') and groupid="+id; + subLogInfo1.setSubPrimarykey("id"); + subLogInfo1.setSubTargetNameColumn("id"); + subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中, 不设置默认按照add的顺序。 + subLogInfo1.setSubGroupNameLabel(388736); //在详情中显示的分组名称,不设置默认显示明细x + subLogInfo1.setSubSql(subSql1); + logger.addSubLogInfo(subLogInfo1); + + logger.before(logContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } +} diff --git a/src/com/engine/kq/jucailin/enums/FieldHtmlTypeEnum.java b/src/com/engine/kq/jucailin/enums/FieldHtmlTypeEnum.java new file mode 100644 index 0000000..4010ba6 --- /dev/null +++ b/src/com/engine/kq/jucailin/enums/FieldHtmlTypeEnum.java @@ -0,0 +1,36 @@ +package com.engine.kq.jucailin.enums; + +import com.finance.toolkit.BaseEnum; + +/** + * 调整起算日期 + */ +public enum FieldHtmlTypeEnum implements BaseEnum { + INPUT("1","单行文本框"), + TEXTAREA("2","多行文本框"), + BROWSER("3","浏览按钮"), + CHECKBOX("4","Check框"), + SELECT("5","选择框"), + UPLOAD("6","附件"), + COLORPICKER("7","颜色选择"), + DESCRIPTION("8","描述类型"); + + private String key; + private String value; + + FieldHtmlTypeEnum(String key, String value){ + this.key=key; + this.value=value; + } + + + @Override + public String getKey() { + return this.key; + } + + @Override + public String getValue() { + return this.value; + } +} diff --git a/src/com/engine/kq/jucailin/exception/AttendanceRunTimeException.java b/src/com/engine/kq/jucailin/exception/AttendanceRunTimeException.java new file mode 100644 index 0000000..6a3a85c --- /dev/null +++ b/src/com/engine/kq/jucailin/exception/AttendanceRunTimeException.java @@ -0,0 +1,15 @@ +package com.engine.kq.jucailin.exception; + +public class AttendanceRunTimeException extends RuntimeException { + public AttendanceRunTimeException(String message) { + super(message); + } + + public AttendanceRunTimeException(Throwable cause) { + super(cause); + } + + public AttendanceRunTimeException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/src/com/engine/kq/jucailin/exception/ExceptionUtil.java b/src/com/engine/kq/jucailin/exception/ExceptionUtil.java new file mode 100644 index 0000000..2cef2ea --- /dev/null +++ b/src/com/engine/kq/jucailin/exception/ExceptionUtil.java @@ -0,0 +1,17 @@ +package com.engine.kq.jucailin.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/kq/jucailin/genid/DefaultWorker.java b/src/com/engine/kq/jucailin/genid/DefaultWorker.java new file mode 100644 index 0000000..84652f2 --- /dev/null +++ b/src/com/engine/kq/jucailin/genid/DefaultWorker.java @@ -0,0 +1,52 @@ +package com.engine.kq.jucailin.genid; + +import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.util.Enumeration; +import java.util.Random; + +public class DefaultWorker implements Worker{ + private Random random = new Random(); + + public DefaultWorker() { + } + + public long getWorkerId() { + int max = 100000; + int min = 10000; + int s = this.random.nextInt(max) % (max - min + 1) + min; + String ip = this.getHostIp(); + long workerId = 0L; + if (ip != null) { + String str = ip.replaceAll("\\.", "") + s; + workerId = Long.parseLong(str); + workerId %= 1024L; + } + + return workerId; + } + + private String getHostIp() { + try { + Enumeration allNetInterfaces = NetworkInterface.getNetworkInterfaces(); + + while(allNetInterfaces.hasMoreElements()) { + NetworkInterface netInterface = (NetworkInterface)allNetInterfaces.nextElement(); + Enumeration addresses = netInterface.getInetAddresses(); + + while(addresses.hasMoreElements()) { + InetAddress ip = (InetAddress)addresses.nextElement(); + if (ip != null && ip instanceof Inet4Address + && !ip.isLoopbackAddress() && ip.getHostAddress().indexOf(":") == -1) { + return ip.getHostAddress(); + } + } + } + } catch (Exception var5) { + var5.printStackTrace(); + } + + return "127.0.0.1"; + } +} diff --git a/src/com/engine/kq/jucailin/genid/IdGenerator.java b/src/com/engine/kq/jucailin/genid/IdGenerator.java new file mode 100644 index 0000000..2b2528f --- /dev/null +++ b/src/com/engine/kq/jucailin/genid/IdGenerator.java @@ -0,0 +1,16 @@ +package com.engine.kq.jucailin.genid; + +/** + * id生成器 + */ +public class IdGenerator { + + public static long generate() { + SnowflakeId snowflakeId = new SnowflakeId(); + return snowflakeId.get(); + } + + public static void main(String[] args) { + System.out.println(generate()); + } +} diff --git a/src/com/engine/kq/jucailin/genid/SnowflakeId.java b/src/com/engine/kq/jucailin/genid/SnowflakeId.java new file mode 100644 index 0000000..c8585d9 --- /dev/null +++ b/src/com/engine/kq/jucailin/genid/SnowflakeId.java @@ -0,0 +1,93 @@ +package com.engine.kq.jucailin.genid; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SnowflakeId { + private static final Logger logger = LoggerFactory.getLogger(SnowflakeId.class); + private DefaultWorker worker; + private long startTime = this._curSecond(); + private long time; + private long segment = 0L; + private long workerId = this.getWorker().getWorkerId(); + private long sequence = 0L; + private static final long segmentBits = 9L; + private static final long workerIdBits = 10L; + private static final long sequenceBits = 13L; + private static final long timestampShift = 32L; + private static final long segmentShift = 23L; + private static final long workerIdShift = 13L; + private static final long sequenceMask = 8191L; + private static final long maxSegment = 511L; + private long twepoch = 1483200000L; + private long _counter = 0L; + + public SnowflakeId() { + this.time = this.startTime - this.twepoch; + } + + public DefaultWorker getWorker() { + return new DefaultWorker(); + } + + public void setWorker(DefaultWorker worker) { + this.worker = worker; + } + + public synchronized long get() { + long id = this.getNextId(); + this.testSpeedLimit(); + return id; + } + + public synchronized long[] getRangeId(int sizeOfIds) { + long[] r = new long[]{this.getNextId(), 0L}; + this.sequence = this.sequence + (long)sizeOfIds - 1L - 1L; + this._counter = this._counter + (long)sizeOfIds - 1L - 1L; + if (this.sequence >> 13 > 0L) { + this.sequence &= 8191L; + if (this.segment >= 511L) { + ++this.time; + this.segment = 0L; + } else { + ++this.segment; + } + } + + r[1] = this.getNextId(); + this.testSpeedLimit(); + return r; + } + + private long getNextId() { + ++this.sequence; + ++this._counter; + if (this.sequence >> 13 > 0L) { + if (this.segment >= 511L) { + ++this.time; + } else { + this.sequence = 0L; + ++this.segment; + } + } + + return this.time << 32 | this.segment << 23 | this.workerId << 13 | this.sequence; + } + + private long _curSecond() { + return System.currentTimeMillis() / 1000L; + } + + private synchronized void testSpeedLimit() { + long spentTime = this._curSecond() - this.startTime + 1L; + if (spentTime <= 0L || spentTime << 22 <= this._counter) { + try { + this.wait(10L); + this.testSpeedLimit(); + } catch (Exception var4) { + logger.error(var4.getMessage(), var4); + } + + } + } +} diff --git a/src/com/engine/kq/jucailin/genid/Worker.java b/src/com/engine/kq/jucailin/genid/Worker.java new file mode 100644 index 0000000..421e0ab --- /dev/null +++ b/src/com/engine/kq/jucailin/genid/Worker.java @@ -0,0 +1,5 @@ +package com.engine.kq.jucailin.genid; + +public interface Worker { + long getWorkerId(); +} diff --git a/src/com/engine/kq/jucailin/service/KQCalendarSettingService.java b/src/com/engine/kq/jucailin/service/KQCalendarSettingService.java new file mode 100644 index 0000000..45ef9ea --- /dev/null +++ b/src/com/engine/kq/jucailin/service/KQCalendarSettingService.java @@ -0,0 +1,9 @@ +package com.engine.kq.jucailin.service; + +import java.util.Map; + +public interface KQCalendarSettingService { + Map getCalendarSettingList(Map params); + + Map getCalendarSettingForm(Map params); +} diff --git a/src/com/engine/kq/jucailin/service/KQCommonService.java b/src/com/engine/kq/jucailin/service/KQCommonService.java new file mode 100644 index 0000000..86ba026 --- /dev/null +++ b/src/com/engine/kq/jucailin/service/KQCommonService.java @@ -0,0 +1,12 @@ +package com.engine.kq.jucailin.service; + + +import java.util.Map; + +public interface KQCommonService { + Map saveKQData(Map param); + + Map doQueryCommon(Map param); + + Map delCommon(Map param); +} diff --git a/src/com/engine/kq/jucailin/service/KQCycleSettingService.java b/src/com/engine/kq/jucailin/service/KQCycleSettingService.java new file mode 100644 index 0000000..78c9067 --- /dev/null +++ b/src/com/engine/kq/jucailin/service/KQCycleSettingService.java @@ -0,0 +1,21 @@ +package com.engine.kq.jucailin.service; + +import java.util.Map; + +public interface KQCycleSettingService { + Map getCycleSettingList(Map params); + + Map getCycleSettingTree(Map params); + + Map getCycleSettingForm(Map params); + + Map getCycleList(Map params); + + Map getCycleForm(Map params); + + Map getCycleSearchCondition(Map params); + + Map getCycledetailList(Map params); + + Map getCycledetailForm(Map params); +} diff --git a/src/com/engine/kq/jucailin/service/KQPersonGroupService.java b/src/com/engine/kq/jucailin/service/KQPersonGroupService.java new file mode 100644 index 0000000..017bf84 --- /dev/null +++ b/src/com/engine/kq/jucailin/service/KQPersonGroupService.java @@ -0,0 +1,17 @@ +package com.engine.kq.jucailin.service; + +import weaver.hrm.User; + +import java.util.Map; + +public interface KQPersonGroupService { + Map getPersonGroupList(Map params); + + Map getSuitOrganzationList(Map params); + + Map getSuitOrganzationForm(Map params); + + Map saveSuitOrganzation(Map params); + + Map delSuitOrganzation(Map params); +} diff --git a/src/com/engine/kq/jucailin/service/impl/KQCalendarSettingServiceImpl.java b/src/com/engine/kq/jucailin/service/impl/KQCalendarSettingServiceImpl.java new file mode 100644 index 0000000..ac727d9 --- /dev/null +++ b/src/com/engine/kq/jucailin/service/impl/KQCalendarSettingServiceImpl.java @@ -0,0 +1,25 @@ +package com.engine.kq.jucailin.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.jucailin.cmd.calendar.GetCalendarSettingFormCmd; +import com.engine.kq.jucailin.cmd.calendar.GetCalendarSettingListCmd; +import com.engine.kq.jucailin.service.KQCalendarSettingService; + +import java.util.Map; + +/** + * @Author: sy + * @Description: 日历设置实现类 + * @Date: 2024/2/27 + **/ +public class KQCalendarSettingServiceImpl extends Service implements KQCalendarSettingService { + @Override + public Map getCalendarSettingList(Map params) { + return commandExecutor.execute(new GetCalendarSettingListCmd(params,user)); + } + + @Override + public Map getCalendarSettingForm(Map params) { + return commandExecutor.execute(new GetCalendarSettingFormCmd(params,user)); + } +} diff --git a/src/com/engine/kq/jucailin/service/impl/KQCommonServiceImpl.java b/src/com/engine/kq/jucailin/service/impl/KQCommonServiceImpl.java new file mode 100644 index 0000000..8fcea51 --- /dev/null +++ b/src/com/engine/kq/jucailin/service/impl/KQCommonServiceImpl.java @@ -0,0 +1,48 @@ +package com.engine.kq.jucailin.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.jucailin.cmd.common.DeleteDataCommonCmd; +import com.engine.kq.jucailin.cmd.common.InsertDataCommonCmd; +import com.engine.kq.jucailin.cmd.common.QueryDataCommonCmd; +import com.engine.kq.jucailin.cmd.common.UpdateDataCommonCmd; +import com.engine.kq.jucailin.service.KQCommonService; +import com.google.common.collect.Maps; +import com.google.gson.Gson; +import weaver.general.Util; + +import java.lang.reflect.Type; +import java.util.Map; + +public class KQCommonServiceImpl extends Service implements KQCommonService { + @Override + public Map saveKQData(Map param) { + //1:新增,2:更新 + String type = Util.null2String(param.get("type")); + String data = Util.null2String(param.get("data")); + Gson gson = new Gson(); + Map dataMap = gson.fromJson(data, (Type) Map.class); + param.put("data",dataMap); + Map resultMap = Maps.newHashMap(); + if ("1".equals(type)){ + resultMap = commandExecutor.execute(new InsertDataCommonCmd(param, user)); + }else if ("2".equals(type)){ + resultMap = commandExecutor.execute(new UpdateDataCommonCmd(param, user)); + } + if (resultMap.size() > 0){ + resultMap.put("message","保存失败"); + }else { + resultMap.put("message","保存成功"); + } + return resultMap; + } + + @Override + public Map doQueryCommon(Map param) { + return commandExecutor.execute(new QueryDataCommonCmd(param, user)); + } + + @Override + public Map delCommon(Map param) { + return commandExecutor.execute(new DeleteDataCommonCmd(param, user)); + } +} diff --git a/src/com/engine/kq/jucailin/service/impl/KQCycleSettingServiceImpl.java b/src/com/engine/kq/jucailin/service/impl/KQCycleSettingServiceImpl.java new file mode 100644 index 0000000..0d0fea6 --- /dev/null +++ b/src/com/engine/kq/jucailin/service/impl/KQCycleSettingServiceImpl.java @@ -0,0 +1,50 @@ +package com.engine.kq.jucailin.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.jucailin.cmd.cycle.*; +import com.engine.kq.jucailin.service.KQCycleSettingService; + +import java.util.Map; + +public class KQCycleSettingServiceImpl extends Service implements KQCycleSettingService { + + @Override + public Map getCycleSettingList(Map params) { + return commandExecutor.execute(new GetCycleSettingListCmd(params,user)); + } + + @Override + public Map getCycleSettingTree(Map params) { + return commandExecutor.execute(new GetCycleSettingTreeCmd(params,user)); + } + + @Override + public Map getCycleList(Map params) { + return commandExecutor.execute(new GetCycleListCmd(params,user)); + } + + @Override + public Map getCycleSettingForm(Map params) { + return commandExecutor.execute(new GetCycleSettingFormCmd(params,user)); + } + + @Override + public Map getCycleForm(Map params) { + return commandExecutor.execute(new GetCycleFormCmd(params,user)); + } + + @Override + public Map getCycleSearchCondition(Map params) { + return commandExecutor.execute(new GetCycleSearchConditionCmd(params,user)); + } + + @Override + public Map getCycledetailList(Map params) { + return commandExecutor.execute(new GetCycledetailListCmd(params,user)); + } + + @Override + public Map getCycledetailForm(Map params) { + return commandExecutor.execute(new GetCycledetailFormCmd(params,user)); + } +} diff --git a/src/com/engine/kq/jucailin/service/impl/KQPersonGroupServiceImpl.java b/src/com/engine/kq/jucailin/service/impl/KQPersonGroupServiceImpl.java new file mode 100644 index 0000000..deadb35 --- /dev/null +++ b/src/com/engine/kq/jucailin/service/impl/KQPersonGroupServiceImpl.java @@ -0,0 +1,45 @@ +package com.engine.kq.jucailin.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.jucailin.cmd.common.DeleteDataCommonCmd; +import com.engine.kq.jucailin.cmd.personGroup.GetPersonGroupListCmd; +import com.engine.kq.jucailin.cmd.personGroup.GetSuitOrganzationFormCmd; +import com.engine.kq.jucailin.cmd.personGroup.GetSuitOrganzationListCmd; +import com.engine.kq.jucailin.cmd.personGroup.SaveSuitOrganzationCmd; +import com.engine.kq.jucailin.service.KQPersonGroupService; +import com.engine.kq.jucailin.util.Constant; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.Map; + +public class KQPersonGroupServiceImpl extends Service implements KQPersonGroupService { + @Override + public Map getPersonGroupList(Map params) { + return commandExecutor.execute(new GetPersonGroupListCmd(params,user)); + } + + @Override + public Map getSuitOrganzationList(Map params) { + return commandExecutor.execute(new GetSuitOrganzationListCmd(params,user)); + } + + @Override + public Map getSuitOrganzationForm(Map params) { + return commandExecutor.execute(new GetSuitOrganzationFormCmd(params,user)); + } + + @Override + public Map saveSuitOrganzation(Map params) { + return commandExecutor.execute(new SaveSuitOrganzationCmd(params,user)); + } + + @Override + public Map delSuitOrganzation(Map params) { + String tableName = Util.null2String(params.get("tableName")); + String modeid = Constant.modeToTable.get(tableName); + String memberTableName = "kq_groupmember_"+modeid; + params.put("tableName",memberTableName); + return commandExecutor.execute(new DeleteDataCommonCmd(params,user)); + } +} diff --git a/src/com/engine/kq/jucailin/util/CommonUtil.java b/src/com/engine/kq/jucailin/util/CommonUtil.java new file mode 100644 index 0000000..4f85dbd --- /dev/null +++ b/src/com/engine/kq/jucailin/util/CommonUtil.java @@ -0,0 +1,312 @@ +package com.engine.kq.jucailin.util; + +import com.engine.kq.log.KQLog; +import com.google.common.collect.Lists; +import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; +import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; +import weaver.general.BaseBean; +import weaver.hrm.User; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.lang.reflect.Type; +import java.net.JarURLConnection; +import java.net.URL; +import java.net.URLDecoder; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.Map; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + + +public class CommonUtil { + public static KQLog log = new KQLog(); + public static Gson gson = new Gson(); + public static Type list_map_type = new TypeToken>>(){}.getType(); + public static Type map_type = new TypeToken>(){}.getType(); + public static BaseBean baseBean = new BaseBean(); + /** + * 组装insert的sql语句 + * @param tableName 表名 + * @param map 列名及对应值 + * @return + */ + public static String makeInsertSql(String tableName, Map map,User user){ + fillSaveData(map,user); + String insertSql = "insert into "+tableName; + String key = "("; + String value = "("; + for (Map.Entry e : map.entrySet()){ + key = key + e.getKey() +","; + value = value + "'"+e.getValue()+"'" +","; + } + key = key.substring(0,key.length()-1) + ")"; + value = value.substring(0,value.length()-1)+")"; + insertSql = insertSql + key +" values "+value; + log.info("makeInsertSql : "+insertSql); + return insertSql; + } + + /** + * 组装update的sql语句 + * @param tableName 表名 + * @param map 列名及对应值 + * @param condition 条件 + * @return + */ + public static String makeUpdateSql(String tableName, Map map,Map condition){ + fillUpdateData(map); + String updateSql = "update "+tableName+" set "; + for (Map.Entry e : map.entrySet()){ + if (e.getValue() !=null && !"".equals(e.getValue())){ + updateSql = updateSql + e.getKey()+"='"+e.getValue().toString()+"',"; + } + } + updateSql = updateSql.substring(0,updateSql.length()-1) + " where 1=1"; + for (Map.Entry e : condition.entrySet()){ + updateSql = updateSql + " and "+ e.getKey()+"='"+e.getValue()+"'"; + } + log.info("makeUpdateSql : "+updateSql); + + return updateSql; + + } + + /** + * 填充插入数据库固定字段数据 + * @param data + * @return + */ + public static void fillSaveData(Map data, User user){ + data.put("create_time",DateUtil.getCurrentTime()); + data.put("update_time",DateUtil.getCurrentTime()); + data.put("creator",user.getUID()); + data.put("delete_type","0"); + data.put("tenant_key","jucailin"); + } + /** + * 填充更新数据库固定字段数据 + * @param data + * @return + */ + public static void fillUpdateData(Map data){ + data.put("update_time",DateUtil.getCurrentTime()); + + } + + /** + * 批量查出 + * @param dataList + * @param tableName + * @return + */ + public static boolean insertBatch(List> dataList, String tableName){ + String sql = "insert into "+tableName; + String key = "("; + String value = "("; + for (Map.Entry data : dataList.get(0).entrySet()){ + key = key + data.getKey() +","; + value = value + "?,"; + } + key = key.substring(0,key.length()-1) + ")"; + value = value.substring(0,value.length()-1)+")"; + sql = sql + key +" values "+value; + log.info("insertBatch sql :"+sql); + List insertDataList = Lists.newArrayList(); + for (Map dataMap : dataList){ + ArrayList list = new ArrayList<>(); + for (Map.Entry entry : dataMap.entrySet()){ + list.add(entry.getValue()); + } + insertDataList.add(list); + } + log.info(insertDataList); + return DbTools.updateBatch(sql,insertDataList); + } + /** + * 解析格式为[{a:b,c:d}]格式的json + * @param json + * @return + */ + public static List> resolveList_Map(String json){ + List> list= gson.fromJson(json,list_map_type); + return list; + } + /** + * 解析格式为{a:b,c:d}格式的json + * @param json + * @return + */ + public static Map resolveMap(String json){ + Map list= gson.fromJson(json,map_type); + return list; + } + + /** + * 通过接口名取得某个接口下所有实现这个接口的类 + */ + public List getAllClassByInterface(Class c) { + List returnClassList = null; + if (c.isInterface()) { + try { + // 获取当前的包名 + String packageName = c.getPackage().getName(); + // 获取当前包下以及子包下所以的类 + List> allClass = getClasses(packageName); + if (allClass != null) { + returnClassList = new ArrayList(); + for (Class cls : allClass) { + // 判断是否是同一个接口 + if (c.isAssignableFrom(cls)) { + // 本身不加入进去 + if (!c.equals(cls)) { + returnClassList.add((T)cls.newInstance()); + } + } + } + } + }catch (Exception e){ + baseBean.writeLog(e); + } + } + + return returnClassList; + } + + + + + /** + * 从包package中获取所有的Class + * + * @param packageName + * @return + */ + @NotNull + public static List> getClasses(String packageName) { + // 第一个class类的集合 + List> classes = new ArrayList>(); + // 是否循环迭代 + boolean recursive = true; + // 获取包的名字 并进行替换 + String packageDirName = packageName.replace('.', '/'); + // 定义一个枚举的集合 并进行循环来处理这个目录下的things + Enumeration dirs; + try { + dirs = Thread.currentThread().getContextClassLoader().getResources(packageDirName); + // 循环迭代下去 + while (dirs.hasMoreElements()) { + // 获取下一个元素 + URL url = dirs.nextElement(); + // 得到协议的名称 + String protocol = url.getProtocol(); + // 如果是以文件的形式保存在服务器上 + if ("file".equals(protocol)) { + // 获取包的物理路径 + String filePath = URLDecoder.decode(url.getFile(), "UTF-8"); + // 以文件的方式扫描整个包下的文件 并添加到集合中 + findAndAddClassesInPackageByFile(packageName, filePath, recursive, classes); + } else if ("jar".equals(protocol)) { + // 如果是jar包文件 + // 定义一个JarFile + JarFile jar; + try { + // 获取jar + jar = ((JarURLConnection) url.openConnection()).getJarFile(); + // 从此jar包 得到一个枚举类 + Enumeration entries = jar.entries(); + // 同样的进行循环迭代 + while (entries.hasMoreElements()) { + // 获取jar里的一个实体 可以是目录 和一些jar包里的其他文件 如META-INF等文件 + JarEntry entry = entries.nextElement(); + String name = entry.getName(); + // 如果是以/开头的 + if (name.charAt(0) == '/') { + // 获取后面的字符串 + name = name.substring(1); + } + // 如果前半部分和定义的包名相同 + if (name.startsWith(packageDirName)) { + int idx = name.lastIndexOf('/'); + // 如果以"/"结尾 是一个包 + if (idx != -1) { + // 获取包名 把"/"替换成"." + packageName = name.substring(0, idx).replace('/', '.'); + } + // 如果可以迭代下去 并且是一个包 + if ((idx != -1) || recursive) { + // 如果是一个.class文件 而且不是目录 + if (name.endsWith(".class") && !entry.isDirectory()) { + // 去掉后面的".class" 获取真正的类名 + String className = name.substring(packageName.length() + 1, name.length() - 6); + try { + // 添加到classes + classes.add(Class.forName(packageName + '.' + className)); + } catch (ClassNotFoundException e) { + baseBean.writeLog(e); + } + } + } + } + } + } catch (IOException e) { + baseBean.writeLog(e); + } + } + + } + } catch (IOException e) { + baseBean.writeLog(e); + } + + return classes; + } + + /** + * 以文件的形式来获取包下的所有Class + * + * @param packageName + * @param packagePath + * @param recursive + * @param classes + */ + public static void findAndAddClassesInPackageByFile(String packageName, String packagePath, final boolean recursive, List> classes) { + // 获取此包的目录 建立一个File + File dir = new File(packagePath); + // 如果不存在或者 也不是目录就直接返回 + if (!dir.exists() || !dir.isDirectory()) { + return; + } + // 如果存在 就获取包下的所有文件 包括目录 + File[] dirfiles = dir.listFiles(new FileFilter() { + // 自定义过滤规则 如果可以循环(包含子目录) 或则是以.class结尾的文件(编译好的java类文件) + @Override + public boolean accept(File file) { + return (recursive && file.isDirectory()) || (file.getName().endsWith(".class")); + } + }); + // 循环所有文件 + for (File file : dirfiles) { + // 如果是目录 则继续扫描 + if (file.isDirectory()) { + findAndAddClassesInPackageByFile(packageName + "." + file.getName(), file.getAbsolutePath(), recursive, classes); + } else { + // 如果是java类文件 去掉后面的.class 只留下类名 + String className = file.getName().substring(0, file.getName().length() - 6); + try { + // 添加到集合中去 + classes.add(Class.forName(packageName + '.' + className)); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + baseBean.writeLog(e); + } + } + } + } + +} diff --git a/src/com/engine/kq/jucailin/util/Constant.java b/src/com/engine/kq/jucailin/util/Constant.java new file mode 100644 index 0000000..7ab90dc --- /dev/null +++ b/src/com/engine/kq/jucailin/util/Constant.java @@ -0,0 +1,13 @@ +package com.engine.kq.jucailin.util; + +import java.util.HashMap; +import java.util.Map; + +public class Constant { + + public static final Map modeToTable = new HashMap(){{ + //周期设置表 + put("kq_cycle_setting","1"); + put("kq_calendar_name","2"); + }}; +} diff --git a/src/com/engine/kq/jucailin/util/DateUtil.java b/src/com/engine/kq/jucailin/util/DateUtil.java new file mode 100644 index 0000000..5a32f4d --- /dev/null +++ b/src/com/engine/kq/jucailin/util/DateUtil.java @@ -0,0 +1,248 @@ +package com.engine.kq.jucailin.util; + +import weaver.general.TimeUtil; + +import java.time.*; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.util.Calendar; + +public class DateUtil { + public static DateTimeFormatter yyyyMMdd = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + public static DateTimeFormatter yyyyMMddHHmmss = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + public static DateTimeFormatter yyyyMMddHHmm = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + public static DateTimeFormatter yyyyMM = DateTimeFormatter.ofPattern("yyyy-MM"); + public static DateTimeFormatter yyyy = DateTimeFormatter.ofPattern("yyyy"); + + public static String beforeMonth(String time,int month){ + LocalDateTime localDateTime = DateUtil.getTime(time); + return localDateTime.minusMonths(month).format(yyyyMMdd); + } + public static String lastMonth(String time){ + LocalDateTime localDateTime = DateUtil.getTime(time); + + return localDateTime.plusMonths(1).format(yyyyMM); + } + public static String lastMonth(String time,DateTimeFormatter dateTimeFormatter){ + LocalDateTime localDateTime = DateUtil.getTime(time); + + return localDateTime.plusMonths(1).format(dateTimeFormatter); + } + public static String nextMonth(String time,int month,DateTimeFormatter dateTimeFormatter){ + LocalDateTime localDateTime = DateUtil.getTime(time); + + return localDateTime.plusMonths(month).format(dateTimeFormatter); + } + public static String nextYear(String time,int year,DateTimeFormatter dateTimeFormatter){ + LocalDateTime localDateTime = DateUtil.getTime(time); + + return localDateTime.plusYears(year).format(dateTimeFormatter); + } + public static String beforeYear(String time,int year,DateTimeFormatter dateTimeFormatter){ + LocalDateTime localDateTime = DateUtil.getTime(time); + + return localDateTime.minusYears(year).format(dateTimeFormatter); + } + + + public static String beforeDay(String time,long day){ + LocalDateTime localDateTime = LocalDate.parse(time, yyyyMMdd).atStartOfDay(); + return localDateTime.minusDays(day).format(yyyyMMdd); + } + public static String AfterDay(String time,long day){ + LocalDateTime localDateTime = LocalDate.parse(time, yyyyMMdd).atStartOfDay(); + + return localDateTime.plusDays(day).format(yyyyMMdd); + } + + public static String beforeMinutes(String time,long minutes){ + LocalDateTime localDateTime = DateUtil.getTime(time); + return localDateTime.minusMinutes(minutes).format(yyyyMMddHHmm); + } + + public static String AfterMinutes(String time,long minutes){ + LocalDateTime localDateTime = DateUtil.getTime(time); + return localDateTime.plusMinutes(minutes).format(yyyyMMddHHmm); + } + + public static String nowMonth(String time){ + LocalDateTime localDateTime = LocalDate.parse(time, yyyyMMdd).atStartOfDay(); + return localDateTime.format(yyyyMM); + } + + public static String getCurrentDate(){ + return LocalDateTime.now().format(yyyyMMdd); + } + public static String getCurrentTime(){ + return LocalDateTime.now().format(yyyyMMddHHmmss); + } + public static String getCurrentTime(String timeType){ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(timeType); + return LocalDateTime.now().format(formatter); + } + + //获得往后日期 + public static String getCurrentDatePlusDay(int day){ + return LocalDateTime.now().plusDays(day).format(yyyyMMdd); + } + //获得往前日期 + public static String getCurrentDateMinusDay(int day){ + return LocalDateTime.now().minusDays(day).format(yyyyMMdd); + } + + + public static LocalDateTime getTime(String time){ + int length = time.length(); + switch (length){ + case 10: + return LocalDate.parse(time, yyyyMMdd).atStartOfDay(); + case 19: + return LocalDateTime.parse(time, yyyyMMddHHmmss); + case 16: + return LocalDateTime.parse(time, yyyyMMddHHmm); + } + return null; + } + + + /** + * 获得时间与当前相差的小时 + * @param startTime 开始时间 yyyy-MM-dd HH:mm:ss + * @return + */ + public static long getBetWeenHours(String startTime){ + + Duration duration = Duration.between(LocalDateTime.parse(startTime,yyyyMMddHHmmss),LocalDateTime.now()); + + return duration.toHours(); + } + /** + * 获得两个时间相差的年份 + * @param startTime 开始时间 yyyy-MM-dd + * @return + */ + public static int getBetWeenYears(String startTime){ + Period duration = Period.between(LocalDate.parse(startTime,yyyyMMdd),LocalDateTime.now().toLocalDate()); + + return duration.getYears(); + } + + /** + * 获得两个时间相差的年份 + * @param startTime 开始时间 yyyy-MM-dd + * @return + */ + public static int getBetWeenYears(String startTime,String endTime){ + Period duration = Period.between(LocalDate.parse(startTime,yyyyMMdd),LocalDate.parse(endTime,yyyyMMdd)); + return duration.getYears(); + } + + /** + * 获得两个时间相差的月份 + * @param startTime 开始时间 yyyy-MM-dd + * @return + */ + public static int getBetWeenMonths(String startTime,String endTime){ + LocalDateTime startDate = DateUtil.getTime(startTime); + LocalDateTime endDate = DateUtil.getTime(endTime); + + YearMonth startYearMonth = YearMonth.from(startDate); + YearMonth endYearMonth = YearMonth.from(endDate); + + int betweenMonth = (int) ChronoUnit.MONTHS.between(startYearMonth, endYearMonth); + if (startDate.getDayOfMonth()>endDate.getDayOfMonth()){ + betweenMonth= betweenMonth-1; + } + return betweenMonth; + } + + /** + * 获得当前时间相差的天数 + * @param startTime 开始时间 yyyy-MM-dd + * @return + */ + public static int getBetWeenDays(String startTime){ + LocalDate startDate = LocalDate.parse(startTime); + LocalDate endDate = LocalDateTime.now().toLocalDate(); + + long daysBetween = ChronoUnit.DAYS.between(startDate, endDate); + return Math.toIntExact(daysBetween); + } + /** + * 获得当前时间相差的天数 + * @param startTime 开始时间 yyyy-MM-dd + * @return + */ + public static int getBetWeenDays(String startTime,String endTime){ + LocalDate startDate = LocalDate.parse(startTime); + LocalDate endDate = LocalDate.parse(endTime); + + long daysBetween = ChronoUnit.DAYS.between(startDate, endDate); + return Math.toIntExact(daysBetween); + } + /** + * 获得当前时间相差的分钟数 + * @param startTime 开始时间 yyyy-MM-dd + * @return + */ + public static int getBetWeenMinutes(String startTime,String endTime,DateTimeFormatter formatter){ + LocalDateTime startDate = LocalDateTime.parse(startTime,formatter); + LocalDateTime endDate = LocalDateTime.parse(endTime,formatter); + + long daysBetween = ChronoUnit.MINUTES.between(startDate, endDate); + return Math.toIntExact(daysBetween); + } + /** + * 获得当前时间相差的分钟数 + * @param startTime 开始时间 yyyy-MM-dd + * @return + */ + public static int getBetWeenMinutes(String startTime,String endTime){ + LocalDateTime startDate = DateUtil.getTime(startTime); + LocalDateTime endDate = DateUtil.getTime(endTime); + + long daysBetween = ChronoUnit.MINUTES.between(startDate, endDate); + return Math.toIntExact(daysBetween); + } + + /** + * 获得两个时间相差的小时 + * @param startTime 开始时间 yyyy-MM-dd HH:mm:ss + * @param endTime 结束时间 yyyy-MM-dd HH:mm:ss + * @return + */ + public static long getBetWeenHours(String startTime,String endTime){ + Duration duration = Duration.between(getTime(startTime),getTime(endTime)); + + return duration.toHours(); + } + + /** + * 获得两个时间相差的周 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return + */ + public static int getBetweenWeeks(String startTime,String endTime){ + int days = getBetWeenDays(startTime,endTime); + int dayOfWeek = TimeUtil.getDayOfWeek(startTime); + if (dayOfWeek == 0){ + dayOfWeek = 7; + } + days = days-(7-dayOfWeek); + + return days/7; + } + + + /** + * 获得该月份的天数 + * @param time + * @return + */ + public static int getDays(String time,int CalendarType){ + Calendar calendar = Calendar.getInstance(); + calendar.set(Integer.valueOf(time.split("-")[0]), Integer.valueOf(time.split("-")[1]) - 1, 1); + return calendar.getActualMaximum(CalendarType); + } +} diff --git a/src/com/engine/kq/jucailin/util/DbTools.java b/src/com/engine/kq/jucailin/util/DbTools.java new file mode 100644 index 0000000..b6389ef --- /dev/null +++ b/src/com/engine/kq/jucailin/util/DbTools.java @@ -0,0 +1,132 @@ +package com.engine.kq.jucailin.util; + +import com.google.common.collect.Maps; +import weaver.conn.RecordSet; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DbTools { + + private static ThreadLocal thread = ThreadLocal.withInitial(()->new RecordSet()); + + + public static List> getSqlToList(String sql,Object...value){ + RecordSet rs = thread.get(); + + List> result = new ArrayList<>(); + if (value == null || value.length <=0 || "".equals(value)){ + rs.executeQuery(sql); + }else { + rs.executeQuery(sql,value); + } + while (rs.next()){ + Map dataMap = new HashMap<>(); + String[] columns = rs.getColumnName(); + for (String column:columns){ + dataMap.put(column,rs.getString(column)); + } + result.add(dataMap); + } + return result; + } + + public static List> getSqlToListKeySmallLetter(String sql,Object...value){ + RecordSet rs = thread.get(); + + List> result = new ArrayList<>(); + if (value == null || value.length <=0 || "".equals(value)){ + rs.executeQuery(sql); + }else { + rs.executeQuery(sql,value); + } + while (rs.next()){ + Map dataMap = new HashMap<>(); + String[] columns = rs.getColumnName(); + for (String column:columns){ + dataMap.put(column.toLowerCase(),rs.getString(column)); + } + result.add(dataMap); + } + return result; + } + + + public static Map getSqlToMap(String sql,Object...value){ + RecordSet rs = thread.get(); + Map result = Maps.newHashMap(); + if (value == null || value.length <=0 || "".equals(value)){ + rs.executeQuery(sql); + }else { + rs.executeQuery(sql,value); + } + if (rs.next()){ + String[] columns = rs.getColumnName(); + for (String column:columns){ + result.put(column.toLowerCase(),rs.getString(column)); + } + } + return result; + } + + + public static Map getSqlToMapList(String sql,Object...value){ + RecordSet rs = thread.get(); + Map result = Maps.newHashMap(); + if (value == null || value.length <=0 || "".equals(value)){ + rs.executeQuery(sql); + }else { + rs.executeQuery(sql,value); + } + while (rs.next()){ + result.put(rs.getString("id"),rs.getString("name")); + } + return result; + } + + + + public static boolean update(String sql,Object...value){ + RecordSet rs = thread.get(); + if (value == null || value.length <=0 || "".equals(value)){ + return rs.executeUpdate(sql); + + }else { + return rs.executeUpdate(sql,value); + } + } + + public static boolean update(RecordSet rs,String sql,Object...value){ + if (value == null || value.length <=0 || "".equals(value)){ + return rs.executeUpdate(sql); + + }else { + return rs.executeUpdate(sql,value); + } + } + + + /** + * 获取sql语句 + * @param sql + * @param value + * @return + */ + public static String getSql(String sql,Object...value){ + RecordSet rs = thread.get(); + rs.executeQuery(sql,value); + String sentenceSql = ""; + if (rs.next()){ + sentenceSql = rs.getString("sentence"); + } + return sentenceSql; + } + + public static boolean updateBatch(String sql,List dataList){ + RecordSet rs = thread.get(); + return rs.executeBatchSql(sql,dataList); + } + +} diff --git a/src/com/engine/kq/jucailin/util/KQDateUtil.java b/src/com/engine/kq/jucailin/util/KQDateUtil.java new file mode 100644 index 0000000..3a39659 --- /dev/null +++ b/src/com/engine/kq/jucailin/util/KQDateUtil.java @@ -0,0 +1,19 @@ +package com.engine.kq.jucailin.util; + +import java.sql.Date; +import java.sql.Timestamp; + +public class KQDateUtil { + + public static Date getUpdateDate(){ + Long now = System.currentTimeMillis(); + Date date = new Date(now); + return date; + } + + public static Timestamp getUpdateTimeStamp(){ + Long now = System.currentTimeMillis(); + Timestamp timestamp = new Timestamp(now); + return timestamp; + } +} diff --git a/src/com/engine/kq/jucailin/util/ListConversionMethod.java b/src/com/engine/kq/jucailin/util/ListConversionMethod.java new file mode 100644 index 0000000..45cd390 --- /dev/null +++ b/src/com/engine/kq/jucailin/util/ListConversionMethod.java @@ -0,0 +1,83 @@ +package com.engine.kq.jucailin.util; + +import weaver.general.Util; + +import java.util.Map; + +/** + * 聚财林列表的显示转换方法 + */ +public class ListConversionMethod { + /** + * 获取人员分组应用场景显示列 + * + * @param userfor 0-分部、1-部门、2-人员、3-岗位、4-所有人 + * @param languageId + * @return + */ + public String getPersonGroupUserFor(String userfor, String languageId) { + String userforShow = ""; + int language = Util.getIntValue(languageId, 7); + if (userfor.equals("0")) { + userforShow = "通用"; + } else if (userfor.equals("1")) { + userforShow = "排班"; + } else if (userfor.equals("2")) { + userforShow = "打卡"; + } else if (userfor.equals("3")) { + userforShow = "假期额度"; + } else if (userfor.equals("4")) { + userforShow = "考勤方案"; + }else if (userfor.equals("4")) { + userforShow = "管理员权限"; + } + return userforShow; + } + + + /** + * 周期状态 + * + * @param languageId + * @return + */ + public String getCyclestate(String cyclestate, String languageId) { + String stateShow = ""; + int language = Util.getIntValue(languageId, 7); + if (cyclestate.equals("0")) { + stateShow = "待关账"; + } else if (cyclestate.equals("1")) { + stateShow = "已关账"; + } else if (cyclestate.equals("2")) { + stateShow = "已结账"; + } + return stateShow; + } + + /** + * 周期名称 + * @return + */ + public String getCycleName(String cyclename, String languageId) { + String sql = "select cyclename from kq_cycle_setting where id="+cyclename; + Map data = DbTools.getSqlToMap(sql); + return data.get("cyclename"); + } + + /** + * 明细周期状态 + * + * @param languageId + * @return + */ + public String getCycledetailstate(String cyclestate, String languageId) { + String stateShow = ""; + int language = Util.getIntValue(languageId, 7); + if (cyclestate.equals("0")) { + stateShow = "开账"; + } else if (cyclestate.equals("1")) { + stateShow = "关账"; + } + return stateShow; + } +} diff --git a/src/com/engine/kq/jucailin/util/PageUidFactory.java b/src/com/engine/kq/jucailin/util/PageUidFactory.java new file mode 100644 index 0000000..ec7411b --- /dev/null +++ b/src/com/engine/kq/jucailin/util/PageUidFactory.java @@ -0,0 +1,36 @@ +package com.engine.kq.jucailin.util; + +import java.util.UUID; + +/** + * React化分页组参考pageuid生成类 + * + * @author lvyi + */ +public class PageUidFactory { + + /** + * 获取React分页组件所需pageuid,每个分页组件唯一,直接通过Main程序生成随机UID常量即可 + * + * @return + */ + public static String getHrmPageUid(String param){ + if("KQPersonGroupList".equals(param)){ + return "d0c6abf5-b722-4187-ac6c-e8735a01c329"; + }else if("KQCycleSettingList".equals(param)){ + return "01c6e218-5d4a-4826-9e4a-d123924d58ce"; + }else if("KQCycleList".equals(param)){ + return "c1dc1669-8a8d-4c4f-b80c-c9a3e2eaa0dc"; + }else{ + return ""; + } + } + + public static void main(String[] args){ + for(int i=0; i<10; i++){ + UUID uuid = UUID.randomUUID(); + System.err.println(uuid); + } + } + +} diff --git a/src/com/engine/kq/jucailin/util/ResponseResult.java b/src/com/engine/kq/jucailin/util/ResponseResult.java new file mode 100644 index 0000000..1a60367 --- /dev/null +++ b/src/com/engine/kq/jucailin/util/ResponseResult.java @@ -0,0 +1,185 @@ +package com.engine.kq.jucailin.util; + + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.common.service.HrmCommonService; +import com.engine.common.service.impl.HrmCommonServiceImpl; +import com.engine.core.exception.ECException; +import com.engine.kq.jucailin.exception.AttendanceRunTimeException; +import com.engine.kq.jucailin.exception.ExceptionUtil; +import com.engine.kq.log.KQLog; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.gson.Gson; +import weaver.general.BaseBean; +import weaver.hrm.User; + +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 + **/ + +public class ResponseResult { + + private static final long serialVersionUID = 1L; + + private final User user; + + private final HrmCommonService hrmCommonService = new HrmCommonServiceImpl(); + + private final BaseBean baseBean = new BaseBean(); + + private final Boolean isLog = true; + + private KQLog log = new KQLog(); + + public ResponseResult(User user) { + this.user = user; + } + + private static Gson gson = new Gson(); + + + /** + * 统一返回方法 + */ + public String run(Function f, T t) { + try { + if (isLog) { + log.info("run attendance api , param "+t); + } + return Ok(f.apply(t)); + } catch (AttendanceRunTimeException e) { + log.error("attendance api run fail , param "+ t, e); + return Error(e.getMessage()); + } catch (ECException e) { + log.error("attendance 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("attendance api run fail , param "+t, e); + return Error("系统异常!"); + } + } + + /** + * 统一返回方法(有参无返回) + */ + public String run(Consumer f, T t) { + try { + if (isLog) { + log.info("run attendance api , param "+t); + } + f.accept(t); + return Ok(); + } catch (AttendanceRunTimeException e) { + log.error("attendance api run fail , param "+t, e); + return Error(e.getMessage()); + } catch (ECException e) { + log.error("attendance api run fail , param "+t, e); + return Error(ExceptionUtil.getRealMessage(e)); + } catch (Exception e) { + log.error("attendance api run fail , param "+t, e); + return Error("系统异常!", e); + } + } + + + /** + * 统一返回方法(无参有返回) + */ + public String run(Supplier f) { + try { + if (isLog) { + log.info("run attendance api"); + } + return Ok(f.get()); + } catch (AttendanceRunTimeException e) { + log.error("attendance api run fail", e); + return Error(e.getMessage()); + } catch (ECException e) { + log.error("attendance api run fail", e); + Throwable cause = e.getCause(); + return Error(cause.getMessage()); + } catch (Exception e) { + log.error("attendance api run fail", e); + return Error("系统异常!", e); + } + } + + + private static String getJsonString(Object apidatas) throws JsonProcessingException { +// ObjectMapper mapper = new ObjectMapper(); +// return mapper.writeValueAsString(apidatas); + return JSONObject.toJSONString(apidatas); + } + + /** + * 成功返回 + */ + private String Ok() throws JsonProcessingException { + Map apidatas = new HashMap<>(); + apidatas.put("api_status", true); + String success = getJsonString(apidatas); + return success; + } + + + /** + * 成功返回 + */ + private String Ok(R r) throws JsonProcessingException { + Map apidatas = new HashMap<>(); + apidatas.put("api_status", true); + apidatas.put("data", r); + String success = getJsonString(apidatas); + if (isLog) { + log.info("run attendance api success return "+success); + } + return success; + } + + + /** + * 失败返回 + */ + private static String Error(String message) { + Map apidatas = new HashMap<>(); + apidatas.put("api_status", false); + apidatas.put("api_errormsg", message); + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + + /** + * 系统异常失败返回 + */ + private static String Error(String message, Exception e) { + Map apidatas = new HashMap<>(); + apidatas.put("api_status", false); + apidatas.put("api_errormsg", message); + apidatas.put("error", e.getMessage()); + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + + +} diff --git a/src/com/engine/kq/jucailin/web/KQCalendarSettingAction.java b/src/com/engine/kq/jucailin/web/KQCalendarSettingAction.java new file mode 100644 index 0000000..26f6c39 --- /dev/null +++ b/src/com/engine/kq/jucailin/web/KQCalendarSettingAction.java @@ -0,0 +1,60 @@ +package com.engine.kq.jucailin.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.jucailin.service.KQCalendarSettingService; +import com.engine.kq.jucailin.service.impl.KQCalendarSettingServiceImpl; +import com.engine.kq.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.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * @Author: sy + * @Description: 日历设置 + * @Date: 2024/2/27 + **/ +public class KQCalendarSettingAction { + + private KQCalendarSettingService getKQCalendarSettingService(User user) { + return ServiceUtil.getService(KQCalendarSettingServiceImpl.class,user); + } + + /** + * 日历设置列表 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCalendarSettingList") + @Produces(MediaType.APPLICATION_JSON) + public String getCalendarSettingList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCalendarSettingService(user) :: getCalendarSettingList,param); + } + + /** + * 日历设置表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCalendarSettingForm") + @Produces(MediaType.APPLICATION_JSON) + public String getCalendarSettingForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCalendarSettingService(user) :: getCalendarSettingForm,param); + } +} diff --git a/src/com/engine/kq/jucailin/web/KQCommonAction.java b/src/com/engine/kq/jucailin/web/KQCommonAction.java new file mode 100644 index 0000000..1e0f453 --- /dev/null +++ b/src/com/engine/kq/jucailin/web/KQCommonAction.java @@ -0,0 +1,76 @@ +package com.engine.kq.jucailin.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.jucailin.service.KQCommonService; +import com.engine.kq.jucailin.service.impl.KQCommonServiceImpl; +import com.engine.kq.util.ResponseResult; +import lombok.extern.slf4j.Slf4j; +import oracle.jdbc.proxy.annotation.Post; +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; + +@Slf4j +public class KQCommonAction { + + private KQCommonService getKQCommonService(User user) { + return ServiceUtil.getService(KQCommonServiceImpl.class,user); + } + + /** + * 更新考勤数据 + * @param request + * @param response + * @return + */ + @Post + @Path("/doSubmit") + @Produces(MediaType.APPLICATION_JSON) + public String saveKQData(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCommonService(user) :: saveKQData,param); + } + + /** + * 查询详情页面 + * @param request + * @param response + * @return + */ + @GET + @Path("/doQueryCommon") + @Produces(MediaType.APPLICATION_JSON) + public String doQueryCommon(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCommonService(user) :: doQueryCommon,param); + } + + /** + * 删除考勤数据 + * @param request + * @param response + * @return + */ + @GET + @Path("/delCommon") + @Produces(MediaType.APPLICATION_JSON) + public String delCommon(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCommonService(user) :: delCommon,param); + } + + + +} diff --git a/src/com/engine/kq/jucailin/web/KQCycleSettingAction.java b/src/com/engine/kq/jucailin/web/KQCycleSettingAction.java new file mode 100644 index 0000000..05841df --- /dev/null +++ b/src/com/engine/kq/jucailin/web/KQCycleSettingAction.java @@ -0,0 +1,146 @@ +package com.engine.kq.jucailin.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.jucailin.service.KQCycleSettingService; +import com.engine.kq.jucailin.service.KQPersonGroupService; +import com.engine.kq.jucailin.service.impl.KQCycleSettingServiceImpl; +import com.engine.kq.jucailin.service.impl.KQPersonGroupServiceImpl; +import com.engine.kq.util.ResponseResult; +import oracle.jdbc.proxy.annotation.Post; +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; + +public class KQCycleSettingAction { + + private KQCycleSettingService getKQCycleSettingService(User user) { + return ServiceUtil.getService(KQCycleSettingServiceImpl.class,user); + } + + /** + * 周期设置列表 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCycleSettingList") + @Produces(MediaType.APPLICATION_JSON) + public String getCycleSettingList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCycleSettingService(user) :: getCycleSettingList,param); + } + + /** + * 周期设置树 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCycleSettingTree") + @Produces(MediaType.APPLICATION_JSON) + public String getCycleSettingTree(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCycleSettingService(user) :: getCycleSettingTree,param); + } + /** + * 周期设置表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCycleSettingForm") + @Produces(MediaType.APPLICATION_JSON) + public String getCycleSettingForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCycleSettingService(user) :: getCycleSettingForm,param); + } + + /** + * 考勤周期列表查询 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCycleList") + @Produces(MediaType.APPLICATION_JSON) + public String getCycleList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCycleSettingService(user) :: getCycleList,param); + } + /** + * 考勤周期表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCycleForm") + @Produces(MediaType.APPLICATION_JSON) + public String getCycleForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCycleSettingService(user) :: getCycleForm,param); + } + + /** + * 考勤周期高级搜索表单表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCycleSearchCondition") + @Produces(MediaType.APPLICATION_JSON) + public String getCycleSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCycleSettingService(user) :: getCycleSearchCondition,param); + } + + /** + * 考勤周期明细表1列表查询 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCycledetailList") + @Produces(MediaType.APPLICATION_JSON) + public String getCycledetailList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCycleSettingService(user) :: getCycledetailList,param); + } + /** + * 考勤周期明细表1新建表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCycledetailForm") + @Produces(MediaType.APPLICATION_JSON) + public String getCycledetailForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCycleSettingService(user) :: getCycledetailForm,param); + } + +} diff --git a/src/com/engine/kq/jucailin/web/KQPersonGroupAction.java b/src/com/engine/kq/jucailin/web/KQPersonGroupAction.java new file mode 100644 index 0000000..f4ad0a3 --- /dev/null +++ b/src/com/engine/kq/jucailin/web/KQPersonGroupAction.java @@ -0,0 +1,106 @@ +package com.engine.kq.jucailin.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.jucailin.service.KQCommonService; +import com.engine.kq.jucailin.service.KQPersonGroupService; +import com.engine.kq.jucailin.service.impl.KQCommonServiceImpl; +import com.engine.kq.jucailin.service.impl.KQPersonGroupServiceImpl; +import com.engine.kq.util.ResponseResult; +import lombok.extern.slf4j.Slf4j; +import oracle.jdbc.proxy.annotation.Post; +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; + +@Slf4j +public class KQPersonGroupAction { + + private KQPersonGroupService getKQCommonService(User user) { + return ServiceUtil.getService(KQPersonGroupServiceImpl.class,user); + } + + /** + * 人员分组列表查询 + * @param request + * @param response + * @return + */ + @GET + @Path("/getPersonGroupList") + @Produces(MediaType.APPLICATION_JSON) + public String getPersonGroupList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCommonService(user) :: getPersonGroupList,param); + } + + /** + * 适用组织列表查询 + * @param request + * @param response + * @return + */ + @GET + @Path("/getSuitOrganzationList") + @Produces(MediaType.APPLICATION_JSON) + public String getSuitOrganzationList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCommonService(user) :: getSuitOrganzationList,param); + } + + /** + * 适用组织表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getSuitOrganzationForm") + @Produces(MediaType.APPLICATION_JSON) + public String getSuitOrganzationForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCommonService(user) :: getSuitOrganzationForm,param); + } + /** + * 适用组织表单 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveSuitOrganzation") + @Produces(MediaType.APPLICATION_JSON) + public String saveSuitOrganzation(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCommonService(user) :: saveSuitOrganzation,param); + } + /** + * 适用组织表单 + * @param request + * @param response + * @return + */ + @POST + @Path("/delSuitOrganzation") + @Produces(MediaType.APPLICATION_JSON) + public String delSuitOrganzation(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCommonService(user) :: delSuitOrganzation,param); + } + + +} diff --git a/src/com/engine/kq/jucailin/web/common/KQCommonAction.java b/src/com/engine/kq/jucailin/web/common/KQCommonAction.java new file mode 100644 index 0000000..37f5ecc --- /dev/null +++ b/src/com/engine/kq/jucailin/web/common/KQCommonAction.java @@ -0,0 +1,59 @@ +package com.engine.kq.jucailin.web.common; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.jucailin.service.KQCommonService; +import com.engine.kq.jucailin.service.impl.KQCommonServiceImpl; +import com.engine.kq.util.ResponseResult; +import lombok.extern.slf4j.Slf4j; +import oracle.jdbc.proxy.annotation.Post; +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; + +@Slf4j +public class KQCommonAction { + + private KQCommonService getKQCommonService(User user) { + return ServiceUtil.getService(KQCommonServiceImpl.class,user); + } + + /** + * 更新考勤数据 + * @param request + * @param response + * @return + */ + @Post + @Path("/doSubmit") + @Produces(MediaType.APPLICATION_JSON) + public String saveKQData(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCommonService(user) :: saveKQData,param); + } + + /** + * 查询详情页面 + * @param request + * @param response + * @return + */ + @GET + @Path("/doQueryCommon") + @Produces(MediaType.APPLICATION_JSON) + public String doQueryCommon(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCommonService(user) :: doQueryCommon,param); + } + +} diff --git a/src/com/engine/kq/jucailin/web/persongroup/KQCycleSettingAction.java b/src/com/engine/kq/jucailin/web/persongroup/KQCycleSettingAction.java new file mode 100644 index 0000000..a4b07d3 --- /dev/null +++ b/src/com/engine/kq/jucailin/web/persongroup/KQCycleSettingAction.java @@ -0,0 +1,74 @@ +package com.engine.kq.jucailin.web.persongroup; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.jucailin.service.KQCycleSettingService; +import com.engine.kq.jucailin.service.KQPersonGroupService; +import com.engine.kq.jucailin.service.impl.KQCycleSettingServiceImpl; +import com.engine.kq.jucailin.service.impl.KQPersonGroupServiceImpl; +import com.engine.kq.util.ResponseResult; +import oracle.jdbc.proxy.annotation.Post; +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; + +public class KQCycleSettingAction { + + private KQCycleSettingService getKQCycleSettingService(User user) { + return ServiceUtil.getService(KQCycleSettingServiceImpl.class,user); + } + + /** + * 周期设置列表 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCycleSettingList") + @Produces(MediaType.APPLICATION_JSON) + public String getCycleSettingList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCycleSettingService(user) :: getCycleSettingList,param); + } + + /** + * 周期设置树 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCycleSettingTree") + @Produces(MediaType.APPLICATION_JSON) + public String getCycleSettingTree(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCycleSettingService(user) :: getCycleSettingTree,param); + } + + /** + * 考勤周期查询 + * @param request + * @param response + * @return + */ + @GET + @Path("/getCycleList") + @Produces(MediaType.APPLICATION_JSON) + public String getCycleList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCycleSettingService(user) :: getCycleList,param); + } + +} diff --git a/src/com/engine/kq/jucailin/web/persongroup/KQPersonGroupAction.java b/src/com/engine/kq/jucailin/web/persongroup/KQPersonGroupAction.java new file mode 100644 index 0000000..5f814ad --- /dev/null +++ b/src/com/engine/kq/jucailin/web/persongroup/KQPersonGroupAction.java @@ -0,0 +1,47 @@ +package com.engine.kq.jucailin.web.persongroup; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.jucailin.service.KQCommonService; +import com.engine.kq.jucailin.service.KQPersonGroupService; +import com.engine.kq.jucailin.service.impl.KQCommonServiceImpl; +import com.engine.kq.jucailin.service.impl.KQPersonGroupServiceImpl; +import com.engine.kq.util.ResponseResult; +import lombok.extern.slf4j.Slf4j; +import oracle.jdbc.proxy.annotation.Post; +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; + +@Slf4j +public class KQPersonGroupAction { + + private KQPersonGroupService getKQCommonService(User user) { + return ServiceUtil.getService(KQPersonGroupServiceImpl.class,user); + } + + /** + * 人员分组列表查询 + * @param request + * @param response + * @return + */ + @GET + @Path("/getPersonGroupList") + @Produces(MediaType.APPLICATION_JSON) + public String getPersonGroupList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getKQCommonService(user) :: getPersonGroupList,param); + } + + +} diff --git a/src/com/engine/kq/log/KQLog.java b/src/com/engine/kq/log/KQLog.java new file mode 100644 index 0000000..c1f35c1 --- /dev/null +++ b/src/com/engine/kq/log/KQLog.java @@ -0,0 +1,232 @@ +package com.engine.kq.log; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.UUID; + +import com.engine.core.exception.ECException; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import weaver.common.DateUtil; +import weaver.conn.ConnStatement; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.common.DbFunctionUtil; + +/** + * 考勤日志记录 + */ +public class KQLog extends BaseBean { + + private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("hrmkq"); + + + + /** + * 是否记录日志 + */ + private boolean isLog = true; + + public KQLog() { + String hrmkqlogOpen = Util.null2s(getPropValue("hrmkqlog", "hrmkqlogOpen"),"true"); + if("true".equalsIgnoreCase(hrmkqlogOpen)){ + isLog = true; + }else{ + isLog = false; + } + } + + public void debug(Object message) { + if(isLog){ + String msg = getLogMsg(); + log.debug(msg+message); + } + } + + public void debug(Object message, Throwable exception) { + if(isLog){ + String msg = getLogMsg(); + log.debug(msg+message, exception); + } + } + + public void info(Object message) { + if(isLog){ + String msg = getLogMsg(); + log.info(Thread.currentThread().getName()+":"+msg+message); + } + } + + public void info(Object message, Throwable exception) { + if(isLog){ + String msg = getLogMsg(); + log.info(msg+message, exception); + } + } + + public void warn(Object message) { + if(isLog){ + String msg = getLogMsg(); + log.warn(msg+message); + } + } + + public void warn(Object message, Throwable exception) { + if(isLog){ + String msg = getLogMsg(); + log.warn(msg+message, exception); + } + } + + public void error(Object message) { + if(isLog){ + String msg = getLogMsg(); + log.error(msg+message); + } + } + + public void error(Object message, Throwable exception) { + if(isLog){ + String msg = getLogMsg(); + log.error(msg+message, exception); + } + } + + @Override + public void writeLog(String classname , Object obj) { + if(isLog){ + if(obj instanceof Exception){ + log.error(classname ,(Exception)obj); + }else if(obj instanceof String){ + String msg = getLogMsg(); + log.error(msg+obj); + }else{ + log.error(obj); + } + } + } + + private String getLogMsg(){ + StackTraceElement[] arr = Thread.currentThread().getStackTrace(); + int index = arr.length-1; + boolean flag = false; + for(int i=0;iindex){ + int line = Thread.currentThread().getStackTrace()[index].getLineNumber(); + String method = Thread.currentThread().getStackTrace()[index].getMethodName(); + String classname = Thread.currentThread().getStackTrace()[index].getClassName(); + msg = classname+"."+method+"() - line:"+line+" : "; +// String curDateTime = DateUtil.getFullDate(); +// String tmpDateTime = DateUtil.getCurrentDate()+" 09:00:00"; +// if(curDateTime.compareTo(tmpDateTime) < 0){ +// StringWriter errorsWriter = new StringWriter(); +// new Exception().printStackTrace(new PrintWriter(errorsWriter)); +// msg = errorsWriter.toString(); +// } + } + return msg; + } + + @Override + public void writeLog(Object obj) { + writeLog(getClass().getName(),obj); + } + + public static void setLogLevel(String levle){ + //日志级别优先级:OFF > FATAL > ERROR > WARN > INFO > DEBUG > ALL + if("DEBUG".equals(levle)){ + log.setLevel(Level.DEBUG); + }else if("INFO".equals(levle)){ + log.setLevel(Level.INFO); + }else if("WARN".equals(levle)){ + log.setLevel(Level.WARN); + }else if("ERROR".equals(levle)){ + log.setLevel(Level.ERROR); + } + } + + public static String getLogLevel(){ + //日志级别优先级:OFF > FATAL > ERROR > WARN > INFO > DEBUG > ALL + return log.getLevel().toString(); + } + + public boolean isLog() { + return isLog; + } + + public void setLog(boolean log) { + isLog = log; + } + + /** + * 希望实现每次考勤相关操作的时候都可以记录下当时的考勤信息 + * @param resourceid + * @param groupshift_info + */ + public void log_kqchangeinfo(String resourceid,String groupshift_info){ + if(resourceid.length() == 0){ + return; + } + String uuid = UUID.randomUUID().toString(); + RecordSet rs = new RecordSet(); + + boolean isok = false; + if(rs.getDBType().equalsIgnoreCase("oracle")&&Util.null2String(rs.getOrgindbtype()).equals("oracle")){ + String sql = "insert into kq_groupshift_changeinfo(resourceid,changedatetime,groupshift_info,uuid) " + + " values("+resourceid+","+DbFunctionUtil.getCurrentFullTimeFunction(rs.getDBType())+",empty_clob(),'"+uuid+"') "; + isok = rs.executeUpdate(sql); + }else{ + String sql = "insert into kq_groupshift_changeinfo(resourceid,changedatetime,groupshift_info,uuid) " + + " values("+resourceid+","+DbFunctionUtil.getCurrentFullTimeFunction(rs.getDBType())+",?,'"+uuid+"') "; + + rs.executeUpdate(sql,groupshift_info); + } + + if(isok && rs.getDBType().equalsIgnoreCase("oracle")&&Util.null2String(rs.getOrgindbtype()).equals("oracle")){ + ConnStatement stat=null; + try { + stat = new ConnStatement(); + // 需要使用for update方法来进行更新, + // 但是,特别需要注意,如果原来CLOB字段有值,需要使用empty_clob()将其清空。 + // 如果原来是null,也不能更新,必须是empty_clob()返回的结果。 + stat.setStatementSql("select groupshift_info from kq_groupshift_changeinfo where uuid=? for update", false); + stat.setString(1,uuid); + stat.executeQuery(); + if (stat.next()) { + oracle.sql.CLOB clob = (oracle.sql.CLOB) stat.getClob("groupshift_info"); + Writer outStream = clob.getCharacterOutputStream(); + char[] c = groupshift_info.toCharArray(); + outStream.write(c, 0, c.length); + outStream.flush(); + outStream.close(); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (stat != null) { + stat.close(); + } + } + } + + } +} diff --git a/src/com/engine/kq/service/ImportLogService.java b/src/com/engine/kq/service/ImportLogService.java new file mode 100644 index 0000000..bb40820 --- /dev/null +++ b/src/com/engine/kq/service/ImportLogService.java @@ -0,0 +1,67 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +public interface ImportLogService { + /** + * 保存日志 + * @param params + * @param user + * @return + */ + public Map saveImportLog(Map params, HttpServletRequest request, User user); + + /** + * 保存明细日志 + * @param params + * @param user + * @return + */ + public Map saveImportDeitalLog(Map params, User user); + + + /** + * 保存明细日志 + * @param params + * @param user + * @return + */ + public Map saveImportLogStatus(Map params, User user); + + /** + * 获取导入结果回调数据 + * @param params + * @param user + * @return + */ + public Map getImportProcessLog(Map params, HttpServletRequest request, User user); + + /** + * 获取人员导入结果信息 + * @param params + * @param user + * @return + */ + public Map getImportResult(Map params, HttpServletRequest request, User user); + + /** + * 历史人员导入信息查询 + * @param params + * @param user + * @return + */ + public Map getImportHistory(Map params, User user); + + /** + * 高级查询条件 + */ + public Map getHistorySearchCondition(Map params, User user); + + /** + * 获取导入结果信息 + */ + public Map getImportColResultLog(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQAttendanceButtonService.java b/src/com/engine/kq/service/KQAttendanceButtonService.java new file mode 100644 index 0000000..055f3f1 --- /dev/null +++ b/src/com/engine/kq/service/KQAttendanceButtonService.java @@ -0,0 +1,136 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * 考勤流程相关的ajax请求事件 + */ +public interface KQAttendanceButtonService { + + /** + * 获取考勤组的基本信息的 + * @param params + * @param user + * @return + */ + public Map getButtonBaseInfo(Map params, User user); + + /** + * 获取签到签退按钮 + * 以及考勤流程数据 + * 以及上次签到时间 + * @param params + * @param user + * @return + */ + public Map getButtons(Map params, User user); + + /** + * 签到签退 + * @param params + * @param user + * @return + */ + public Map punchButton(HttpServletRequest request,Map params, User user); + + /** + * 小E签到签退 + * @param params + * @param user + * @return + */ + public Map punchButton4E(HttpServletRequest request,Map params, User user); + + /** + * 外勤签到签退 + * @param params + * @param user + * @return + */ + public Map getOutButtons(Map params, User user); + /** + * 外勤签到签退 关联考勤的时候,打卡范围 + * @param params + * @param user + * @return + */ + public Map getOutButtonRange(Map params, User user); + + /** + * 外勤签到签退 + * @param params + * @param user + * @return + */ + public Map punchOutButton(HttpServletRequest request,Map params, User user); + + /** + * 外勤记录 查询条件 + * @param params + * @param user + * @return + */ + public Map getOutButtonCondition(HttpServletRequest request,Map params, User user); + + /** + * 外勤记录 查询条件 + * @param params + * @param user + * @return + */ + public Map getOutSearchList(HttpServletRequest request,Map params, User user, + HttpServletResponse response); + + /** + * 获取外勤签到配置 + * @param params + * @param user + * @return + */ + public Map getOutSignSetting(Map params, User user); + /** + * 保存外勤签到配置 + * @param params + * @param user + * @return + */ + public Map saveOutSignSetting(Map params, User user); + + /** + * EM端自动打卡设置界面 + * @param params + * @param user + * @return + */ + public Map getAutoEMSet(Map params, User user); + + /** + * 保存EM端自动打卡设置界面 + * @param params + * @param user + * @return + */ + public Map saveAutoEMSet(Map params, User user); + + /** + * 移动端切换地图,保存最新的当前用户选择的地图 + * @param params + * @param user + * @return + */ + public Map resetUserMap(Map params, User user); + + public Map getUserLastMap(Map params, User user); + + /** + * 自己调整班次 + * @param params + * @param user + * @return + */ + public Map resetSerial(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQAttendanceEventService.java b/src/com/engine/kq/service/KQAttendanceEventService.java new file mode 100644 index 0000000..19e9302 --- /dev/null +++ b/src/com/engine/kq/service/KQAttendanceEventService.java @@ -0,0 +1,163 @@ +package com.engine.kq.service; + +import java.util.Map; +import weaver.hrm.User; + +/** + * 考勤流程相关的ajax请求事件 + */ +public interface KQAttendanceEventService { + + /** + * 获取工作时长 + * @param params + * @param user + * @return + */ + public Map getWorkDuration(Map params, User user); + + /** + * 获取请假工作时长 + * @param params + * @param user + * @return + */ + public Map getLeaveWorkDuration(Map params, User user); + + /** + * 获取出差工作时长 + * @param params + * @param user + * @return + */ + public Map getEvectionWorkDuration(Map params, User user); + + /** + * 获取公出工作时长 + * @param params + * @param user + * @return + */ + public Map getOutWorkDuration(Map params, User user); + + /** + * 获取加班工作时长 + * @param params + * @param user + * @return + */ + public Map getOverTimeDuration(Map params, User user); + + /** + * 获取假期信息 + * @param params + * @param user + * @return + */ + public Map getVacationInfo(Map params, User user); + + /** + * 获取补卡信息 + * @param params + * @param user + * @return + */ + public Map getAttendanceCard(Map params, User user); + + /** + * 请假校验事件 + * @param params + * @param user + * @return + */ + public Map checkLeave(Map params, User user); + + /** + * 出差校验事件 + * @param params + * @param user + * @return + */ + public Map checkEvection(Map params, User user); + + /** + * 公出校验事件 + * @param params + * @param user + * @return + */ + public Map checkOut(Map params, User user); + + /** + * 销假校验事件 + * @param params + * @param user + * @return + */ + public Map checkLeaveBack(Map params, User user); + + /** + * 排班校验事件 + * @param params + * @param user + * @return + */ + public Map checkShift(Map params, User user); + + /** + * 销假流程用的根据流程获取相应的请假信息 + * @param params + * @param user + * @return + */ + public Map getLeaveBackInfo(Map params, User user); + + /** + * 考勤变更流程根据流程获取相应的流程信息 + * @param params + * @param user + * @return + */ + public Map getProcessChangeInfo(Map params, User user); + + /** + * 考勤变更流程计算时长用的 + * @param params + * @param user + * @return + */ + public Map getProcessChangeWorkDuration(Map params, User user); + + /** + * 考勤变更流程提交校验 + * @param params + * @param user + * @return + */ + public Map checkProcessChange(Map params, User user); + + /** + * 考获取勤变更流程类型 + * @param params + * @param user + * @return + */ + public Map getProcessChangeType(Map params, User user); + + /** + * 补卡流程提交校验 + * @param params + * @param user + * @return + */ + public Map checkCard(Map params, User user); + + /** + * 加班流程提交校验 + * @param params + * @param user + * @return + */ + public Map checkOvertime(Map params, User user); + +} diff --git a/src/com/engine/kq/service/KQAttendanceSetService.java b/src/com/engine/kq/service/KQAttendanceSetService.java new file mode 100644 index 0000000..8ee2643 --- /dev/null +++ b/src/com/engine/kq/service/KQAttendanceSetService.java @@ -0,0 +1,176 @@ +package com.engine.kq.service; + +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import weaver.hrm.User; + +/** + * 考勤流程设置 + */ +public interface KQAttendanceSetService { + + /** + * 获取人员状态变更的菜单 + * @param params + * @param user + * @return + */ + Map getStateRightMenu(Map params, User user); + + /** + * 获取状态变更流程的 tab页签数据 + * @param params + * @param user + * @return + */ + Map getStateProcSetTabInfo(Map params, User user); + + /** + * 获取人员状态变更查询条件 + * @param params + * @param user + * @return + */ + public Map getStateProcSetListSearchCondition(Map params, User user); + + /** + * + * 获取状态变更流程查询列表 + * @param params + * @param user + * @return + */ + public Map getStateProcSetListSearchList(Map params, + HttpServletRequest request, User user); + + /** + * 获取状态变更流程 流程概览信息 + * @param params + * @param user + * @return + */ + Map getStateProcSetFlowForm(Map params, User user); + + /** + * 保存状态变更流程 流程概览信息 + * @param params + * @param user + * @return + */ + Map saveStateProcSetFlow(Map params, User user); + + /** + * 获取状态变更流程 字段对应信息 + * @param params + * @param user + * @return + */ + Map getStateProcSetFlowWfFields(Map params, User user); + + /** + * 保存状态变更流程 字段对应信息 + * @param params + * @param user + * @return + */ + Map saveStateProcSetFlowWfFields(Map params,HttpServletRequest request, User user); + + /** + * 获取状态变更流程 动作设置 + * @param params + * @param user + * @return + */ + Map getStateProcSetFlowWfSet(Map params, User user); + + /** + * 保存状态变更流程的 动作设置 + * @param params + * @param user + * @return + */ + Map saveStateProcSetFlowWfSet(Map params,HttpServletRequest request, + HttpServletResponse response, User user); + + /** + * 删除通用变更流程 + * @param params + * @param user + * @return + */ + Map delStateProcSet(Map params,HttpServletRequest request, User user); + + /** + * 改变通用变更流程的状态 + * @param params + * @param user + * @return + */ + Map changeStateProcSetStatus(Map params,HttpServletRequest request, User user); + + /** + * 获取状态变更流程 自动创建表单 + * @param params + * @param user + * @return + */ + Map getStateProcSetCreateForm(Map params, User user); + + /** + * 保存状态变更流程 自动创建表单 + * @param params + * @param request + * @param user + * @return + */ + Map saveStateProcSetCreateForm(Map params, HttpServletRequest request,User user); + + /** + * 根据基本信息页面的选择的下拉框同步,带出不同的模板文件 + * @param params + * @param user + * @return + */ + Map getProcSetTemplet(Map params,HttpServletRequest request, User user); + + /** + * 获取自定义考勤流程tab页签 + * @param params + * @param user + * @return + */ + Map getCustomKQFlowTab(Map params, User user); + + /** + * 考勤流程 新建校验规则 + * @param params + * @param user + * @return + */ + Map getProcSetCheckRule(Map params, User user); + + /** + * 考勤流程 校验规则列表 + * @param params + * @param user + * @return + */ + Map getStateProcSetFlowCheckRuleList(Map params, User user); + + /** + * 考勤流程 保存校验规则 + * @param params + * @param user + * @return + */ + Map saveStateProcCheckRule(Map params, User user); + + /** + * 考勤流程 删除校验规则 + * @param params + * @param user + * @return + */ + Map delStateProcCheckRule(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQBalanceDetailService.java b/src/com/engine/kq/service/KQBalanceDetailService.java new file mode 100644 index 0000000..752391e --- /dev/null +++ b/src/com/engine/kq/service/KQBalanceDetailService.java @@ -0,0 +1,49 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +public interface KQBalanceDetailService { + + /** + * 获取右键菜单 + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取查询结果列表 + * @param params + * @param user + * @return + */ + public Map getSearchList(Map params, User user); + + /** + * 获取编辑时的表单 + * @param params + * @param user + * @return + */ + public Map getBalanceForm(Map params, User user); + + /** + * 编辑 + * @param params + * @param user + * @return + */ + public Map editBalance(Map params, User user); + + /** + * 删除 + * @param params + * @param user + * @return + */ + public Map deleteBalance(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQBalanceOfLeaveRpService.java b/src/com/engine/kq/service/KQBalanceOfLeaveRpService.java new file mode 100644 index 0000000..a62614f --- /dev/null +++ b/src/com/engine/kq/service/KQBalanceOfLeaveRpService.java @@ -0,0 +1,95 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * 员工假期余额报表 + */ +public interface KQBalanceOfLeaveRpService { + + /** + * 获取右键菜单 + * + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取TAB页签 + * + * @param params + * @param user + * @return + */ + public Map getTab(Map params, User user); + + /** + * 获取查询条件 + * + * @param params + * @param user + * @return + */ + public Map getSearchCondition(Map params, User user); + + /** + * 获取查询列表 + * + * @param params + * @param user + * @return + */ + public Map getSearchList(Map params, User user); + + /** + * 获取使用记录详情 + * + * @param params + * @param user + * @return + */ + public Map getUsageRecordDetail(Map params, User user); + + /** + * 获取分页组件 + * + * @param params + * @param user + * @return + */ + public Map getPageInfo(Map params, User user); + + /** + * 获取假期使用记录的分页组件 + * + * @param params + * @param user + * @return + */ + public Map getDetailPageInfo(Map params, User user); + + /** + * 获取假期使用记录的查询条件 + * + * @param params + * @param user + * @return + */ + public Map getChangeType(Map params, User user); + + /** + * 导出Excel文件 + * + * @param params + * @param user + * @param response + * @return + */ + public Map exportExcel(Map params, User user, HttpServletRequest request, HttpServletResponse response); +} diff --git a/src/com/engine/kq/service/KQBalanceOfLeaveService.java b/src/com/engine/kq/service/KQBalanceOfLeaveService.java new file mode 100644 index 0000000..fdf6ece --- /dev/null +++ b/src/com/engine/kq/service/KQBalanceOfLeaveService.java @@ -0,0 +1,76 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +/** + * 假期余额 + */ +public interface KQBalanceOfLeaveService { + + /** + * 获取右键菜单 + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取高级搜索条件 + * @param params + * @param user + * @return + */ + public Map getSearchCondition(Map params, User user); + + /** + * 获取查询结果列表 + * @param params + * @param user + * @return + */ + public Map getSearchList(Map params, User user); + + /** + * 批处理 + * @param params + * @param user + * @return + */ + public Map batchProcessing(Map params, User user); + + /** + * 获取可见的页签 + * @param params + * @param user + * @return + */ + public Map getTabs(Map params, User user); + + /** + * 保存修改 + * @param params + * @param user + * @return + */ + public Map saveBalanceOfLeave(Map params, User user); + + /** + * 获取导入的表单 + * @param params + * @param user + * @return + */ + public Map getImportForm(Map params, User user); + + /** + * 保存导入 + * @param params + * @param user + * @return + */ + public Map saveImport(Map params, User user, HttpServletRequest request); +} diff --git a/src/com/engine/kq/service/KQGroupLocationService.java b/src/com/engine/kq/service/KQGroupLocationService.java new file mode 100644 index 0000000..84ade64 --- /dev/null +++ b/src/com/engine/kq/service/KQGroupLocationService.java @@ -0,0 +1,40 @@ +package com.engine.kq.service; + +import weaver.hrm.User; +import java.util.Map; + +public interface KQGroupLocationService { + + /** + * 保存 + * @param params + * @param user + * @return + */ + public Map save(Map params, User user); + + /** + * 删除 + * @param params + * @param user + * @return + */ + public Map del(Map params, User user); + + /** + * 新建编辑表单 + * @param params + * @param user + * @return + */ + public Map getForm(Map params, User user); + + /** + * 查列表 + * @param params + * @param user + * @return + */ + public Map getGroupLocationList(Map params, User user); + +} diff --git a/src/com/engine/kq/service/KQGroupMemberService.java b/src/com/engine/kq/service/KQGroupMemberService.java new file mode 100644 index 0000000..d50c21b --- /dev/null +++ b/src/com/engine/kq/service/KQGroupMemberService.java @@ -0,0 +1,56 @@ +package com.engine.kq.service; + +import weaver.hrm.User; +import java.util.Map; + +public interface KQGroupMemberService { + + /** + * 查询条件 + * @param params + * @param user + * @return + */ + public Map getSearchCondition(Map params, User user); + + + /** + * 查询结果 + * @param params + * @param user + * @return + */ + public Map getSearchList(Map params, User user); + + /** + * 保存 + * @param params + * @param user + * @return + */ + public Map save(Map params, User user); + + /** + * 批量修改有效期 + * @param params + * @param user + * @return + */ + public Map saveValidateDate(Map params, User user); + + /** + * 删除 + * @param params + * @param user + * @return + */ + public Map del(Map params, User user); + + /** + * 新建编辑表单 + * @param params + * @param user + * @return + */ + public Map getForm(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQGroupService.java b/src/com/engine/kq/service/KQGroupService.java new file mode 100644 index 0000000..cc7230e --- /dev/null +++ b/src/com/engine/kq/service/KQGroupService.java @@ -0,0 +1,146 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +public interface KQGroupService { + + /** + * 获取考勤组Tab页签 + * + * @param params + * @param user + * @return + */ + public Map getTabs(Map params, User user); + + /** + * 查询条件 + * + * @param params + * @param user + * @return + */ + public Map getSearchCondition(Map params, User user); + + + /** + * 查询结果 + * + * @param params + * @param user + * @return + */ + public Map getSearchList(Map params, User user); + + /** + * 保存 + * + * @param params + * @param user + * @return + */ + public Map save(Map params, User user); + + /** + * 删除 + * + * @param params + * @param user + * @return + */ + public Map del(Map params, User user); + + /** + * 新建编辑表单 + * + * @param params + * @param user + * @return + */ + public Map getForm(Map params, User user); + + /** + * 导入考勤方式 + * + * @param params + * @param user + * @return + */ + public Map importExcel(Map params, User user); + + /** + * 导出考勤方式 + * + * @param params + * @param user + * @return + */ + public Map exportExcel(Map params, HttpServletRequest request, HttpServletResponse response, User user); + + /** + * 导出考勤方式 + * + * @param params + * @param user + * @return + */ + public Map getGroupTree(Map params, User user); + + /** + * 获取排班周期新建编辑表单 + * + * @param params + * @param user + * @return + */ + public Map getShiftCycleForm(Map params, User user); + + /** + * 获取考勤组tab + * + * @param params + * @param user + * @return + */ + public Map getMainTabs(Map params, User user); + + /** + * 获取考勤组人员搜索条件 + * + * @param params + * @param user + * @return + */ + public Map getGroupMemeberCondition(Map params, User user); + + /** + * 获取添加考勤组成员表单 + * + * @param params + * @param user + * @return + */ + public Map getAddMemberCondition(Map params, User user); + + /** + * 获取考勤组人员信息 + * + * @param params + * @param user + * @return + */ + public Map getGroupMemberList(Map params, User user); + + /** + * 保存考勤组人员 + * + * @param params + * @param user + * @return + */ + public Map saveAddMenber(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQGroupWifiService.java b/src/com/engine/kq/service/KQGroupWifiService.java new file mode 100644 index 0000000..95324cb --- /dev/null +++ b/src/com/engine/kq/service/KQGroupWifiService.java @@ -0,0 +1,40 @@ +package com.engine.kq.service; + +import weaver.hrm.User; +import java.util.Map; + +public interface KQGroupWifiService { + + /** + * 保存 + * @param params + * @param user + * @return + */ + public Map save(Map params, User user); + + /** + * 删除 + * @param params + * @param user + * @return + */ + public Map del(Map params, User user); + + /** + * 新建编辑表单 + * @param params + * @param user + * @return + */ + public Map getForm(Map params, User user); + + /** + * 查列表 + * @param params + * @param user + * @return + */ + public Map getGroupWifiList(Map params, User user); + +} diff --git a/src/com/engine/kq/service/KQHolidaySetService.java b/src/com/engine/kq/service/KQHolidaySetService.java new file mode 100644 index 0000000..2aa9bf9 --- /dev/null +++ b/src/com/engine/kq/service/KQHolidaySetService.java @@ -0,0 +1,132 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +/** + * 节假日设置 + */ +public interface KQHolidaySetService { + + /** + * 获取右键菜单 + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取高级搜索查询条件 + * @param params + * @param user + * @return + */ + public Map getSearchCondition(Map params, User user); + + /** + * 节假日设置--清单列表 + * @param params + * @param user + * @return + */ + public Map getSearchList(Map params, User user); + + /** + * 获取日历数据 + * @param params + * @param user + * @return + */ + public Map getHolidaySetCalendar(Map params, User user); + + /** + * 获取新建或者编辑的表单 + * @param params + * @param user + * @return + */ + public Map getHolidaySetForm(Map params, User user); + + /** + * 新建 + * @param params + * @param user + * @return + */ + public Map addHolidaySet(Map params, User user); + + /** + * 编辑 + * @param params + * @param user + * @return + */ + public Map editHolidaySet(Map params, User user); + + /** + * 删除 + * @param params + * @param user + * @return + */ + public Map deleteHolidaySet(Map params, User user); + + /** + * 获取节假日的统计数据 + * @param params + * @param user + * @return + */ + public Map getHolidayCount(Map params, User user); + + /** + * 获取导入的表单 + * @param params + * @param user + * @return + */ + public Map getImportForm(Map params, User user); + + /** + * 保存导入的数据 + * @param params + * @param user + * @return + */ + public Map saveImport(Map params, HttpServletRequest request, User user); + + /** + * 初始化某考勤组的节假日数据 + * @param params + * @param user + * @return + */ + public Map initHolidaySet(Map params, User user); + + /** + * 新建时判断所选时间范围内是否已经设置过数据 + * @param params + * @param user + * @return + */ + public Map hasRepeactData(Map params, User user); + + /** + * 获取同步的表单 + * @param params + * @param user + * @return + */ + public Map getSyncForm(Map params, User user); + + /** + * 保存同步 + * @param params + * @param user + * @return + */ + public Map syncHolidaySet(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQLeaveParentalService.java b/src/com/engine/kq/service/KQLeaveParentalService.java new file mode 100644 index 0000000..a45d2d6 --- /dev/null +++ b/src/com/engine/kq/service/KQLeaveParentalService.java @@ -0,0 +1,21 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import java.util.Map; + +/** + * 假期规则 + */ +public interface KQLeaveParentalService { + + + /** + * 获取育儿假省份设置新建或编辑的表单 + * @param params + * @param user + * @return + */ + public Map getParentalForm(Map params, User user); + +} diff --git a/src/com/engine/kq/service/KQLeaveRulesService.java b/src/com/engine/kq/service/KQLeaveRulesService.java new file mode 100644 index 0000000..a0d5499 --- /dev/null +++ b/src/com/engine/kq/service/KQLeaveRulesService.java @@ -0,0 +1,84 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import java.util.Map; + +/** + * 假期规则 + */ +public interface KQLeaveRulesService { + + /** + * 获取右键菜单 + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取查询条件 + * @param params + * @param user + * @return + */ + public Map getSearchCondition(Map params, User user); + + /** + * 获取假期规则列表 + * @param params + * @param user + * @return + */ + public Map getSearchList(Map params, User user); + + /** + * 获取新建或编辑的表单 + * @param params + * @param user + * @return + */ + public Map getLeaveRulesForm(Map params, User user); + + /** + * 新建 + * @param params + * @param user + * @return + */ + public Map addLeaveRules(Map params, User user); + + /** + * 编辑 + * @param params + * @param user + * @return + */ + public Map editLeaveRules(Map params, User user); + + + /** + * 删除 + * @param params + * @param user + * @return + */ + public Map deleteLeaveRules(Map params, User user); + + /** + * 判断名称是否重复 + * @param params + * @param user + * @return + */ + public Map isNameRepeat(Map params, User user); + + /** + * 判断当前选择的请假类型的请假单位是天还是小时 + * @param params + * @param user + * @return + */ + public Map getUnitName(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQLeaveTypesService.java b/src/com/engine/kq/service/KQLeaveTypesService.java new file mode 100644 index 0000000..797f8be --- /dev/null +++ b/src/com/engine/kq/service/KQLeaveTypesService.java @@ -0,0 +1,94 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import java.util.Map; + +/** + * 假期类型 + */ +public interface KQLeaveTypesService { + + /** + * 获取右键菜单 + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + public Map getSearchCondition(Map params, User user); + + /** + * 获取假期类型列表 + * @param params + * @param user + * @return + */ + public Map getSearchList(Map params, User user); + + /** + * 获取新建或编辑的表单 + * @param params + * @param user + * @return + */ + public Map getLeaveTypesForm(Map params, User user); + + /** + * 新建 + * @param params + * @param user + * @return + */ + public Map addLeaveTypes(Map params, User user); + + /** + * 编辑 + * @param params + * @param user + * @return + */ + public Map editLeaveTypes(Map params, User user); + + + /** + * 删除 + * @param params + * @param user + * @return + */ + public Map deleteLeaveTypes(Map params, User user); + + /** + * 判断名称是否重复 + * @param params + * @param user + * @return + */ + public Map isNameRepeat(Map params, User user); + + /** + * 是否启用 + * @param params + * @param user + * @return + */ + public Map saveDisableLeaveTypes(Map params, User user); + + /** + * 时间选择方式表单 + * @param params + * @param user + * @return + */ + public Map getTimeSelectionForm(Map params, User user); + + /** + * 时间选择方式表单 + * @param params + * @param user + * @return + */ + public Map saveTimeSelectionForm(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQMyAttendanceService.java b/src/com/engine/kq/service/KQMyAttendanceService.java new file mode 100644 index 0000000..f5f9fea --- /dev/null +++ b/src/com/engine/kq/service/KQMyAttendanceService.java @@ -0,0 +1,59 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import java.util.Map; + +/** + * 前台--人事--我的考勤 + */ +public interface KQMyAttendanceService { + + /** + * 统计信息 + * @param params + * @param user + * @return + */ + public Map getHrmKQReportInfo(Map params, User user); + + /** + * 日历数据 + * @param params + * @param user + * @return + */ + public Map getHrmKQMonthReportInfo(Map params, User user); + + /** + * 获取明细列表 + * @param params + * @param user + * @return + */ + public Map getHrmKQReportDetialInfo(Map params, User user); + + /** + * 获取签到签退信息 + * @param params + * @param user + * @return + */ + public Map getHrmKQSignInfo(Map params, User user); + + /** + * 移动端【我的考勤】的明细的高级搜索 + * @param params + * @param user + * @return + */ + public Map getDetailCondition4Mobile(Map params, User user); + + /** + * 移动端【我的考勤】的明细 + * @param params + * @param user + * @return + */ + public Map getDetailList4Mobile(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQOriginalPunchRpService.java b/src/com/engine/kq/service/KQOriginalPunchRpService.java new file mode 100644 index 0000000..45216f6 --- /dev/null +++ b/src/com/engine/kq/service/KQOriginalPunchRpService.java @@ -0,0 +1,50 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * 原始打卡记录报表 + */ +public interface KQOriginalPunchRpService { + + /** + * 获取右键菜单 + * + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取查询条件 + * + * @param params + * @param user + * @return + */ + public Map getSearchCondition(Map params, User user); + + /** + * 获取查询结果 + * + * @param params + * @param user + * @return + */ + public Map getSearchList(Map params, User user); + + /** + * 导出Excel文件 + * + * @param params + * @param user + * @param response + * @return + */ + public Map exportExcel(Map params, User user, HttpServletRequest request, HttpServletResponse response); +} diff --git a/src/com/engine/kq/service/KQOvertimeRulesService.java b/src/com/engine/kq/service/KQOvertimeRulesService.java new file mode 100644 index 0000000..64063fd --- /dev/null +++ b/src/com/engine/kq/service/KQOvertimeRulesService.java @@ -0,0 +1,99 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import java.util.Map; + +/** + * 加班规则 + */ +public interface KQOvertimeRulesService { + + /** + * 获取右键菜单 + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取加班规则列表 + * @param params + * @param user + * @return + */ + public Map getSearchList(Map params, User user); + + /** + * 获取新建或编辑的表单 + * @param params + * @param user + * @return + */ + public Map getOvertimeRulesForm(Map params, User user); + + /** + * 新建 + * @param params + * @param user + * @return + */ + public Map addOvertimeRules(Map params, User user); + + /** + * 编辑 + * @param params + * @param user + * @return + */ + public Map editOvertimeRules(Map params, User user); + + /** + * 删除 + * @param params + * @param user + * @return + */ + public Map deleteOvertimeRules(Map params, User user); + + /** + * 保存是否默认 + * @param params + * @param user + * @return + */ + public Map saveDefault(Map params, User user); + + /** + * 判断某考勤组是否重复设置了加班规则 + * @param params + * @param user + * @return + */ + public Map isRepeatSetting(Map params, User user); + + /** + * 获取加班单位的表单 + * @param params + * @param user + * @return + */ + public Map getOvertimeUnitForm(Map params, User user); + + /** + * 加班增加高级搜索查询 + * @param params + * @param user + * @return + */ + public Map getOvertimeSearchCondition(Map params, User user); + + /** + * 加班单位--保存 + * @param params + * @param user + * @return + */ + public Map saveOvertimeUnit(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQRemindMsgService.java b/src/com/engine/kq/service/KQRemindMsgService.java new file mode 100644 index 0000000..da12784 --- /dev/null +++ b/src/com/engine/kq/service/KQRemindMsgService.java @@ -0,0 +1,13 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import java.util.Map; + +public interface KQRemindMsgService { + + public Map getSearchList(Map params, User user); + + + public Map getSearchCondition(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQRemindOnPCService.java b/src/com/engine/kq/service/KQRemindOnPCService.java new file mode 100644 index 0000000..161e9e4 --- /dev/null +++ b/src/com/engine/kq/service/KQRemindOnPCService.java @@ -0,0 +1,23 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import java.util.Map; + +/** + * 考勤提醒 + * 登录PC端后的弹窗提醒 + */ +public interface KQRemindOnPCService { + /** + * 获取提醒信息 + * @param params + * @param user + * @return + */ + public Map getRemindInfo(Map params, User user); + + public Map saveExtraMapConfig(Map params, User user); + + public Map getExtraMapConfig(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQReport4EService.java b/src/com/engine/kq/service/KQReport4EService.java new file mode 100644 index 0000000..ac78ea3 --- /dev/null +++ b/src/com/engine/kq/service/KQReport4EService.java @@ -0,0 +1,40 @@ +package com.engine.kq.service; + +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import weaver.hrm.User; + +/** + * 考勤流程相关的ajax请求事件 + */ +public interface KQReport4EService { + + /** + * 小e 签到签退 + * @param params + * @param user + * @return + */ + public Map punchButton4E(HttpServletRequest request, Map params, + User user); + + /** + * 小e 签到签退 + * @param params + * @param user + * @return + */ + public Map getScheduleData(HttpServletRequest request, Map params, + User user); + + /** + * 小e 我的假期情况 + * @param params + * @param user + * @return + */ + public Map getBalanceInfo(HttpServletRequest request, Map params, + User user); + + +} diff --git a/src/com/engine/kq/service/KQReportDetailService.java b/src/com/engine/kq/service/KQReportDetailService.java new file mode 100644 index 0000000..006a03a --- /dev/null +++ b/src/com/engine/kq/service/KQReportDetailService.java @@ -0,0 +1,83 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +public interface KQReportDetailService { + + /** + * 获取考勤报表明细Tabs + * @param params + * @param user + * @return + */ + public Map getTabs(Map params, User user); + + /** + * 获取考勤报表应出勤 + * @param params + * @param user + * @return + */ + public Map getWorkDayInfo(Map params, User user); + + /** + * 获取考勤报表签到明细 + * @param params + * @param user + * @return + */ + public Map getSignInfo(Map params, User user); + + /** + * 获取考勤报表迟到数据 + * @param params + * @param user + * @return + */ + public Map getBeLateInfo(Map params, User user); + + /** + * 获取考勤报表早退数据 + * @param params + * @param user + * @return + */ + public Map getLeaveEearlyInfo(Map params, User user); + + /** + * 获取考勤报表旷工数据 + * @param params + * @param user + * @return + */ + public Map getAbsenteeismInfo(Map params, User user); + + /** + * 获取考勤报表漏签数据 + * @param params + * @param user + * @return + */ + public Map getForgotCheckInfo(Map params, User user); + + /** + * 获取考勤报表请假明细 + * @param params + * @param user + * @return + */ + public Map getLeaveInfo(Map params, User user); + + /** + * 获取考勤报表一天明细 + * @param params + * @param user + * @return + */ + public Map getDailyDetialInfo(Map params, User user); + +} diff --git a/src/com/engine/kq/service/KQReportFieldDefineService.java b/src/com/engine/kq/service/KQReportFieldDefineService.java new file mode 100644 index 0000000..f4d8bbd --- /dev/null +++ b/src/com/engine/kq/service/KQReportFieldDefineService.java @@ -0,0 +1,152 @@ +package com.engine.kq.service; + +import weaver.hrm.User; +import java.util.Map; + + +public interface KQReportFieldDefineService { + + /** + * 获取考勤报表定制列右键菜单 + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取考勤报表定制列页签 + * @param params + * @param user + * @return + */ + public Map getFieldDefineTabs(Map params, User user); + + /** + * 获取考勤报表定制列列表 + * @param params + * @param user + * @return + */ + public Map getFieldDefineList(Map params, User user); + + /** + * 保存考勤报表定制列列表 + * @param params + * @param user + * @return + */ + public Map saveFieldDefineList(Map params, User user); + + /** + * 获取考勤报表定制列表单 + * @param params + * @param user + * @return + */ + public Map getFieldDefineForm(Map params, User user); + + /** + * 保存考勤报表定制列表单 + * @param params + * @param user + * @return + */ + public Map saveFieldDefine(Map params, User user); + + /** + * 删除考勤报表定制列 + * @param params + * @param user + * @return + */ + public Map deleteFieldDefine(Map params, User user); + + /** + * 获取考勤报表定制列分组列表 + * @param params + * @param user + * @return + */ + public Map getGroupList(Map params, User user); + + /** + * 获取考勤报表定制列分组表单 + * @param params + * @param user + * @return + */ + public Map getGroupForm(Map params, User user); + + /** + * 保存考勤报表定制列分组表单 + * @param params + * @param user + * @return + */ + public Map saveGroup(Map params, User user); + + /** + * 删除考勤报表定制列分组 + * @param params + * @param user + * @return + */ + public Map deleteGroup(Map params, User user); + + /** + * 移动考勤报表定制列分组 + * @param params + * @param user + * @return + */ + public Map changeFieldGroup(Map params, User user); + + /** + * 获取考勤报表展示列模板页签 + * @param params + * @param user + * @return + */ + public Map getReportMoudleTabs(Map params, User user); + + /** + * 获取自定义模板表单 + * @param params + * @param user + * @return + */ + public Map getReportMoudleForm(Map params, User user); + + /** + * 保存考勤报表展示列模板页签 + * @param params + * @param user + * @return + */ + public Map saveReportMoudle(Map params, User user); + + /** + * 删除考勤报表展示列模板页签 + * @param params + * @param user + * @return + */ + public Map deleteReportMoudle(Map params, User user); + + /** + * 获取考勤报表排序设置 + * @param params + * @param user + * @return + */ + public Map getFieldOrderDefine(Map params, User user); + + /** + * 保存考勤报表排序设置 + * @param params + * @param user + * @return + */ + public Map saveFieldOrderDefine(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQReportService.java b/src/com/engine/kq/service/KQReportService.java new file mode 100644 index 0000000..68c7699 --- /dev/null +++ b/src/com/engine/kq/service/KQReportService.java @@ -0,0 +1,69 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +public interface KQReportService { + + /** + * 获取考勤报表右键菜单 + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取考勤报表查询条件 + * @param params + * @param user + * @return + */ + public Map getSearchCondition(Map params, User user); + + /** + * 获取考勤日报表 + * @param params + * @param user + * @return + */ + public Map getKQDailyReport(Map params, User user); + + + /** + * 获取考勤报表 + * @param params + * @param user + * @return + */ + public Map getKQReport(Map params, User user); + + /** + * 格式化考勤报表 + * @param params + * @param user + * @return + */ + public Map formatReport(Map params, User user); + + + /** + * 导出考勤报表 + * @param params + * @param user + * @return + */ + public Map exportExcel(Map params, HttpServletRequest request, HttpServletResponse response, User user); + + /** + * 导出考勤日报表 + * @param params + * @param user + * @return + */ + public Map exportDailyExcel(Map params, HttpServletRequest request, HttpServletResponse response, User user); + +} diff --git a/src/com/engine/kq/service/KQReportShareService.java b/src/com/engine/kq/service/KQReportShareService.java new file mode 100644 index 0000000..76fe9d8 --- /dev/null +++ b/src/com/engine/kq/service/KQReportShareService.java @@ -0,0 +1,65 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import java.util.Map; + +/** + * 考勤报表权限共享 + */ +public interface KQReportShareService { + + /** + * 获取右键菜单 + * + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取查询条件 + * + * @param params + * @param user + * @return + */ + public Map getSearchCondition(Map params, User user); + + /** + * 获取查询结果 + * + * @param params + * @param user + * @return + */ + public Map getSearchList(Map params, User user); + + /** + * 获取新建的表单 + * + * @param params + * @param user + * @return + */ + public Map getReportShareForm(Map params, User user); + + /** + * 新建 + * + * @param params + * @param user + * @return + */ + public Map saveReportShare(Map params, User user); + + /** + * 删除 + * + * @param params + * @param user + * @return + */ + public Map deleteReportShare(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQScheduleCodeService.java b/src/com/engine/kq/service/KQScheduleCodeService.java new file mode 100644 index 0000000..f93dc4d --- /dev/null +++ b/src/com/engine/kq/service/KQScheduleCodeService.java @@ -0,0 +1,97 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +public interface KQScheduleCodeService { + + /** + * 获取考勤编号管理查询条件 + * @param params + * @param user + * @return + */ + public Map getScheduleCodeCondition(Map params, User user); + + /** + * 获取考勤编号管理查询列表 + * @param params + * @param user + * @return + */ + public Map getScheduleCodeList(Map params, User user); + + /** + * 获取考勤编号管理表单 + * @param params + * @param user + * @return + */ + public Map getScheduleCodeForm(Map params, User user); + + /** + * 保存考勤编号管理 + * @param params + * @param user + * @return + */ + public Map saveScheduleCode(Map params, User user); + + /** + * 获取考勤机管理查询条件 + * @param params + * @param user + * @return + */ + public Map getScheduleDeviceCondition(Map params, User user); + + /** + * 获取考勤机管理查询列表 + * @param params + * @param user + * @return + */ + public Map getScheduleDeviceList(Map params, User user); + + /** + * 获取考勤机管理表单 + * @param params + * @param user + * @return + */ + public Map getScheduleDeviceForm(Map params, User user); + + /** + * 保存考勤机管理 + * @param params + * @param user + * @return + */ + public Map saveScheduleDevice(Map params, User user); + + /** + * 删除考勤机 + * @param params + * @param user + * @return + */ + public Map delScheduleDevice(Map params, User user); + + /** + * 获取考勤编号管理导入表单 + * @param params + * @param user + * @return + */ + public Map getScheduleCodeImportForm(Map params, User user); + + /** + * 保存考勤编号管理导入 + * @param params + * @param user + * @return + */ + public Map saveScheduleCodeImport(Map params, User user, HttpServletRequest request); +} diff --git a/src/com/engine/kq/service/KQScheduleSignImportService.java b/src/com/engine/kq/service/KQScheduleSignImportService.java new file mode 100644 index 0000000..a8e1e69 --- /dev/null +++ b/src/com/engine/kq/service/KQScheduleSignImportService.java @@ -0,0 +1,70 @@ +package com.engine.kq.service; + +import java.util.Map; +import weaver.hrm.User; + +public interface KQScheduleSignImportService { + + /** + * 获取导入表单 + * @param params + * @param user + * @return + */ + public Map getImportForm(Map params, User user); + + /** + * 保存导入信息 + * @param params + * @param user + * @return + */ + public Map saveImport(Map params, User user); + + /** + * 获取导入表单 + * @param params + * @param user + * @return + */ + public Map getImportSetForm(Map params, User user); + + /** + * 同步外部集成考勤数据 + * @param params + * @param user + * @return + */ + public Map synData(Map params, User user); + + /** + * 外部系统调用这个接口同步到考勤系统里 + * @param params + * @return + */ + public Map synDataOpen(Map params); + + /** + * 保存外部集成考勤设置 + * @param params + * @param user + * @return + */ + public Map saveImportSet(Map params, User user); + + /** + * 考勤数据上传 + * @param params + * @param user + * @return + */ + public Map uploadData(Map params, User user); + + /** + * 钉钉考勤数据同步 + * @param params + * @return + */ + public Map synDingTalkData(Map params); + +} diff --git a/src/com/engine/kq/service/KQSettingsService.java b/src/com/engine/kq/service/KQSettingsService.java new file mode 100644 index 0000000..974844a --- /dev/null +++ b/src/com/engine/kq/service/KQSettingsService.java @@ -0,0 +1,38 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import java.util.Map; + +/** + * 应用设置 + */ +public interface KQSettingsService { + + /** + * 获取右键菜单 + * + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取设置的表单 + * + * @param params + * @param user + * @return + */ + public Map getSettingsForm(Map params, User user); + + /** + * 保存 + * + * @param params + * @param user + * @return + */ + public Map saveSettings(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQSetupWizardService.java b/src/com/engine/kq/service/KQSetupWizardService.java new file mode 100644 index 0000000..6f6d5b7 --- /dev/null +++ b/src/com/engine/kq/service/KQSetupWizardService.java @@ -0,0 +1,51 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import java.util.Map; + +/** + * 一键开启考勤 + */ +public interface KQSetupWizardService { + + /** + * 获取表单 + * @param params + * @param user + * @return + */ + public Map getSetupForm(Map params, User user); + + /** + * 获取右键菜单 + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取初始化考勤的步骤 + * @param params + * @param user + * @return + */ + public Map getSetupSteps(Map params, User user); + + /** + * 执行初始化 + * @param params + * @param user + * @return + */ + public Map performInitialization(Map params, User user); + + /** + * 判断是否需要做一键初始化,检测如果存在历史一般工作时间等老考勤设置,给出提示让客户选择是否使用考勤设置升级 + * @param params + * @param user + * @return + */ + public Map checkNeedInit(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQShiftManagementService.java b/src/com/engine/kq/service/KQShiftManagementService.java new file mode 100644 index 0000000..ead2f2b --- /dev/null +++ b/src/com/engine/kq/service/KQShiftManagementService.java @@ -0,0 +1,119 @@ +package com.engine.kq.service; + +import java.util.Map; +import weaver.hrm.User; + +public interface KQShiftManagementService { + + /** + * 获取tabs + * @param params + * @param user + * @return + */ + public Map getTabs(Map params, User user); + + /** + * 获取右键菜单 + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取班次管理查询条件条件 + * @param params + * @param user + * @return + */ + public Map getShiftManagementSearchCondition(Map params, User user); + + /** + * 获取班次管理查询结果列表 + * @param params + * @param user + * @return + */ + public Map getShiftManagementSearchList(Map params, User user); + + /** + * 获取班次管理基本信息表单 + * @param params + * @param user + * @return + */ + public Map getShiftManagementBaseForm(Map params, User user); + + /** + * 保存班次管理基本信息表单 + * @param params + * @param user + * @return + */ + public Map saveShiftManagementBaseForm(Map params, User user); + + /** + * 获取班次管理个性化表单 + * @param params + * @param user + * @return + */ + public Map getShiftManagementPersonalizedForm(Map params, User user); + + /** + * 保存班次管理个性化表单 + * @param params + * @param user + * @return + */ + public Map saveShiftManagementPersonalizedForm(Map params, User user); + + /** + * 删除班次管理 + * @param params + * @param user + * @return + */ + public Map delShiftManagementForm(Map params, User user); + + /** + * 获取邮件提醒内容设置 + * @param params + * @param user + * @return + */ + public Map getEmailRemindForm(Map params, User user); + + /** + * 保存邮件西提醒内容设置 + * @param params + * @param user + * @return + */ + public Map saveEmailRemind(Map params, User user); + + /** + * 获取短信提醒内容设置 + * @param params + * @param user + * @return + */ + public Map getMessageRemindForm(Map params, User user); + + /** + * 保存短信提醒内容设置 + * @param params + * @param user + * @return + */ + public Map saveMessageRemind(Map params, User user); + + /** + * 获取班次管理 分权操作级别 + * @param params + * @param user + * @return + */ + public Map getDetachOperatelevel(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQShiftScheduleService.java b/src/com/engine/kq/service/KQShiftScheduleService.java new file mode 100644 index 0000000..5752203 --- /dev/null +++ b/src/com/engine/kq/service/KQShiftScheduleService.java @@ -0,0 +1,108 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +public interface KQShiftScheduleService { + + /** + * 获取排班查询条件 + * @param params + * @param user + * @return + */ + public Map getSearchCondition(Map params, User user); + + /** + * 获取排班Tab页签 + * @param params + * @param user + * @return + */ + public Map getTabs(Map params, User user); + + + /** + * 获取排班列表 + * @param params + * @param user + * @return + */ + public Map getShiftSchedule(Map params, User user); + + /** + * 保存 + * @param params + * @param user + * @return + */ + public Map save(Map params, User user); + + /** + * 删除 + * @param params + * @param user + * @return + */ + public Map del(Map params, User user); + + + /*** + * + * @param params + * @param user + * @return + */ + public Map getShiftScheduleMembersValidate(Map params, User user); + + /*** + * + * @param params + * @param user + * @return + */ + public Map getBatchShiftScheduleFrom(Map params, User user); + + /** + * 保存 + * @param params + * @param user + * @return + */ + public Map batchSave(Map params, User user); + + /** + * 导入排班 + * @param params + * @param user + * @return + */ + public Map importExcel(Map params, User user); + + /** + * 导出排班 + * @param params + * @param user + * @return + */ + public Map exportExcel(Map params, HttpServletRequest request, HttpServletResponse response, User user); + + /** + * 导出统计 + * @param params + * @param user + * @return + */ + public Map getShiftScheduleTotal(Map params, User user); + + /** + * 获取人员排班信息 + * @param params + * @param user + * @return + */ + public Map getHrmScheduleReportInfo(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQTravelRulesService.java b/src/com/engine/kq/service/KQTravelRulesService.java new file mode 100644 index 0000000..44ef01a --- /dev/null +++ b/src/com/engine/kq/service/KQTravelRulesService.java @@ -0,0 +1,35 @@ +package com.engine.kq.service; + +import weaver.hrm.User; + +import java.util.Map; + +/** + * 出差规则 + */ +public interface KQTravelRulesService { + + /** + * 获取右键菜单 + * @param params + * @param user + * @return + */ + public Map getRightMenu(Map params, User user); + + /** + * 获取表单 + * @param params + * @param user + * @return + */ + public Map getTravelRulesForm(Map params, User user); + + /** + * 保存 + * @param params + * @param user + * @return + */ + public Map saveTravelRules(Map params, User user); +} diff --git a/src/com/engine/kq/service/KQUpgradeService.java b/src/com/engine/kq/service/KQUpgradeService.java new file mode 100644 index 0000000..238f0c7 --- /dev/null +++ b/src/com/engine/kq/service/KQUpgradeService.java @@ -0,0 +1,200 @@ +package com.engine.kq.service; + +import java.util.Map; +import weaver.hrm.User; + +public interface KQUpgradeService { + + /** + * 获取tabs + * @param params + * @param user + * @return + */ + public Map getTreeTabs(Map params, User user); + + /** + * 一般工作时间升级 准备 + * @param params + * @param user + * @return + */ + public Map getUpgrade1(Map params, User user); + + /** + * 一般工作时间升级 准备 + * @param params + * @param user + * @return + */ + public Map getUpgrade2(Map params, User user); + + /** + * 一般工作时间升级 准备 + * @param params + * @param user + * @return + */ + public Map getUpgrade3(Map params, User user); + + /** + * 一般工作时间升级 准备 + * @param params + * @param user + * @return + */ + public Map getUpgrade4(Map params, User user); + + /** + * 一般工作时间升级 准备 + * @param params + * @param user + * @return + */ + public Map getUpgrade5(Map params, User user); + + /** + * 一般工作时间升级 准备 + * @param params + * @param user + * @return + */ + public Map getUpgrade6(Map params, User user); + + /** + * 一般工作时间升级 准备 + * @param params + * @param user + * @return + */ + public Map getUpgrade7(Map params, User user); + + /** + * 一般工作时间升级 准备 + * @param params + * @param user + * @return + */ + public Map getUpgrade8(Map params, User user); + + /** + * 一般工作时间升级 准备 + * @param params + * @param user + * @return + */ + public Map getUpgrade9(Map params, User user); + + /** + * 一般工作时间升级 准备 + * @param params + * @param user + * @return + */ + public Map getUpgrade10(Map params, User user); + + /** + * 一般工作时间升级 准备 + * @param params + * @param user + * @return + */ + public Map getUpgrade12(Map params, User user); + + /** + * 一般工作时间升级 + * @param params + * @param user + * @return + */ + public Map doUpgrade1(Map params, User user); + + /** + * 一般工作时间升级 + * @param params + * @param user + * @return + */ + public Map doUpgrade2(Map params, User user); + + /** + * 一般工作时间升级 + * @param params + * @param user + * @return + */ + public Map doUpgrade3(Map params, User user); + + /** + * 一般工作时间升级 + * @param params + * @param user + * @return + */ + public Map doUpgrade4(Map params, User user); + + /** + * 一般工作时间升级 + * @param params + * @param user + * @return + */ + public Map doUpgrade5(Map params, User user); + + /** + * 一般工作时间升级 + * @param params + * @param user + * @return + */ + public Map doUpgrade6(Map params, User user); + + /** + * 一般工作时间升级 + * @param params + * @param user + * @return + */ + public Map doUpgrade7(Map params, User user); + + /** + * 一般工作时间升级 + * @param params + * @param user + * @return + */ + public Map doUpgrade8(Map params, User user); + + /** + * 一般工作时间升级 + * @param params + * @param user + * @return + */ + public Map doUpgrade9(Map params, User user); + + /** + * 一般工作时间升级 + * @param params + * @param user + * @return + */ + public Map doUpgrade10(Map params, User user); + + /** + * 一般工作时间升级 + * @param params + * @param user + * @return + */ + public Map doUpgrade12(Map params, User user); + + /** + * 获取考考勤报表剩余数据 + * @param params + * @param user + * @return + */ + public Map getUpgrade12Data(Map params, User user); + +} diff --git a/src/com/engine/kq/service/impl/ImportLogServiceImpl.java b/src/com/engine/kq/service/impl/ImportLogServiceImpl.java new file mode 100644 index 0000000..8c5107b --- /dev/null +++ b/src/com/engine/kq/service/impl/ImportLogServiceImpl.java @@ -0,0 +1,53 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.importlog.*; +import com.engine.kq.service.ImportLogService; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +public class ImportLogServiceImpl extends Service implements ImportLogService { + + + @Override + public Map saveImportLog(Map params, HttpServletRequest request, User user) { + return commandExecutor.execute(new SaveImportLogCmd(params, request, user)); + } + + @Override + public Map saveImportDeitalLog(Map params, User user) { + return commandExecutor.execute(new SaveImportDeitalLogCmd(params, user)); + } + + @Override + public Map saveImportLogStatus(Map params, User user) { + return commandExecutor.execute(new SaveImportLogStatusCmd(params, user)); + } + + @Override + public Map getImportProcessLog(Map params, HttpServletRequest request, User user) { + return commandExecutor.execute(new GetImportProcessLogCmd(params, request, user)); + } + + @Override + public Map getImportResult(Map params, HttpServletRequest request, User user) { + return commandExecutor.execute(new GetImportResultCmd(params, user)); + } + + @Override + public Map getImportHistory(Map params, User user) { + return commandExecutor.execute(new GetImportHistoryCmd(params, user)); + } + + @Override + public Map getHistorySearchCondition(Map params, User user) { + return commandExecutor.execute(new GetHistorySearchConditionCmd(params, user)); + } + + @Override + public Map getImportColResultLog(Map params, User user) { + return commandExecutor.execute(new GetImportColResultLogCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQAttendanceButtonServiceImpl.java b/src/com/engine/kq/service/impl/KQAttendanceButtonServiceImpl.java new file mode 100644 index 0000000..8e3117d --- /dev/null +++ b/src/com/engine/kq/service/impl/KQAttendanceButtonServiceImpl.java @@ -0,0 +1,96 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.attendanceButton.*; +import com.engine.kq.service.KQAttendanceButtonService; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * 考勤流程相关的ajax请求事件 + */ +public class KQAttendanceButtonServiceImpl extends Service implements KQAttendanceButtonService { + + @Override + public Map getButtonBaseInfo(Map params, User user) { + return commandExecutor.execute(new GetButtonBaseInfoCmd(params, user)); + } + + @Override + public Map getButtons(Map params, User user) { + return commandExecutor.execute(new GetButtonsCmd(params, user)); + } + + @Override + public Map punchButton(HttpServletRequest request,Map params, User user) { + return commandExecutor.execute(new PunchButtonCmd(request,params, user)); + } + + @Override + public Map punchButton4E(HttpServletRequest request,Map params, User user) { + return commandExecutor.execute(new PunchButton4E(request,params, user)); + } + + @Override + public Map getOutButtons(Map params, User user) { + return commandExecutor.execute(new GetOutButtonsCmd(params, user)); + } + + @Override + public Map getOutButtonRange(Map params, User user) { + return commandExecutor.execute(new GetOutButtonRangeCmd(params, user)); + } + + @Override + public Map punchOutButton(HttpServletRequest request,Map params, User user) { + return commandExecutor.execute(new PunchOutButtonCmd(request,params, user)); + } + + @Override + public Map getOutButtonCondition(HttpServletRequest request,Map params, User user) { + return commandExecutor.execute(new GetOutButtonConditionCmd(request,params, user)); + } + + @Override + public Map getOutSearchList(HttpServletRequest request,Map params, User user, + HttpServletResponse response) { + return commandExecutor.execute(new GetOutSearchListCmd(request,params, user,response)); + } + + @Override + public Map getOutSignSetting(Map params, User user) { + return commandExecutor.execute(new GetOutSignSetting(params, user)); + } + + @Override + public Map saveOutSignSetting(Map params, User user) { + return commandExecutor.execute(new SaveOutSignSettingCmd(params, user)); + } + + @Override + public Map getAutoEMSet(Map params, User user) { + return commandExecutor.execute(new GetAutoEMSetCmd(params, user)); + } + + @Override + public Map saveAutoEMSet(Map params, User user) { + return commandExecutor.execute(new SaveAutoEMSetCmd(params, user)); + } + + @Override + public Map resetUserMap(Map params, User user) { + return commandExecutor.execute(new ResetUserMapCmd(params, user)); + } + + @Override + public Map getUserLastMap(Map params, User user) { + return commandExecutor.execute(new GetUserLastMapCmd(params, user)); + } + @Override + public Map resetSerial(Map params, User user) { + return commandExecutor.execute(new ResetSerialCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQAttendanceEventServiceImpl.java b/src/com/engine/kq/service/impl/KQAttendanceEventServiceImpl.java new file mode 100644 index 0000000..05ddae4 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQAttendanceEventServiceImpl.java @@ -0,0 +1,124 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.attendanceEvent.CheckCardCmd; +import com.engine.kq.cmd.attendanceEvent.CheckEvectionCmd; +import com.engine.kq.cmd.attendanceEvent.CheckLeaveBackCmd; +import com.engine.kq.cmd.attendanceEvent.CheckLeaveCmd; +import com.engine.kq.cmd.attendanceEvent.CheckOutCmd; +import com.engine.kq.cmd.attendanceEvent.CheckOvertimeCmd; +import com.engine.kq.cmd.attendanceEvent.CheckProcessChangeCmd; +import com.engine.kq.cmd.attendanceEvent.CheckShiftCmd; +import com.engine.kq.cmd.attendanceEvent.GetAttendanceCardCmd; +import com.engine.kq.cmd.attendanceEvent.GetEvectionWorkDurationCmd; +import com.engine.kq.cmd.attendanceEvent.GetLeaveBackInfoCmd; +import com.engine.kq.cmd.attendanceEvent.GetLeaveWorkDurationCmd; +import com.engine.kq.cmd.attendanceEvent.GetOutWorkDurationCmd; +import com.engine.kq.cmd.attendanceEvent.GetOverTimeWorkDurationCmd; +import com.engine.kq.cmd.attendanceEvent.GetProcessChangeInfoCmd; +import com.engine.kq.cmd.attendanceEvent.GetProcessChangeTypeCmd; +import com.engine.kq.cmd.attendanceEvent.GetProcessChangeWorkDurationCmd; +import com.engine.kq.cmd.attendanceEvent.GetVacationInfoCmd; +import com.engine.kq.cmd.attendanceEvent.GetWorkDurationCmd; +import com.engine.kq.service.KQAttendanceEventService; +import java.util.Map; +import weaver.hrm.User; + +/** + * 考勤流程相关的ajax请求事件 + */ +public class KQAttendanceEventServiceImpl extends Service implements KQAttendanceEventService { + + @Override + public Map getWorkDuration(Map params, User user) { + return commandExecutor.execute(new GetWorkDurationCmd(params, user)); + } + + @Override + public Map getLeaveWorkDuration(Map params, User user) { + return commandExecutor.execute(new GetLeaveWorkDurationCmd(params, user)); + } + + @Override + public Map getEvectionWorkDuration(Map params, User user) { + return commandExecutor.execute(new GetEvectionWorkDurationCmd(params, user)); + } + + @Override + public Map getOutWorkDuration(Map params, User user) { + return commandExecutor.execute(new GetOutWorkDurationCmd(params, user)); + } + @Override + public Map getOverTimeDuration(Map params, User user) { + return commandExecutor.execute(new GetOverTimeWorkDurationCmd(params, user)); + } + + @Override + public Map getVacationInfo(Map params, User user) { + return commandExecutor.execute(new GetVacationInfoCmd(params, user)); + } + + @Override + public Map getAttendanceCard(Map params, User user) { + return commandExecutor.execute(new GetAttendanceCardCmd(params, user)); + } + + @Override + public Map checkLeave(Map params, User user) { + return commandExecutor.execute(new CheckLeaveCmd(params, user)); + } + @Override + public Map checkEvection(Map params, User user) { + return commandExecutor.execute(new CheckEvectionCmd(params, user)); + } + @Override + public Map checkOut(Map params, User user) { + return commandExecutor.execute(new CheckOutCmd(params, user)); + } + + @Override + public Map checkLeaveBack(Map params, User user) { + return commandExecutor.execute(new CheckLeaveBackCmd(params, user)); + } + + @Override + public Map checkShift(Map params, User user) { + return commandExecutor.execute(new CheckShiftCmd(params, user)); + } + + @Override + public Map getLeaveBackInfo(Map params, User user) { + return commandExecutor.execute(new GetLeaveBackInfoCmd(params, user)); + } + + @Override + public Map getProcessChangeInfo(Map params, User user) { + return commandExecutor.execute(new GetProcessChangeInfoCmd(params, user)); + } + + @Override + public Map getProcessChangeWorkDuration(Map params, User user) { + return commandExecutor.execute(new GetProcessChangeWorkDurationCmd(params, user)); + } + + @Override + public Map checkProcessChange(Map params, User user) { + return commandExecutor.execute(new CheckProcessChangeCmd(params, user)); + } + + @Override + public Map getProcessChangeType(Map params, User user) { + return commandExecutor.execute(new GetProcessChangeTypeCmd(params, user)); + } + + @Override + public Map checkCard(Map params, User user) { + return commandExecutor.execute(new CheckCardCmd(params, user)); + } + + @Override + public Map checkOvertime(Map params, User user) { + return commandExecutor.execute(new CheckOvertimeCmd(params, user)); + } + +} diff --git a/src/com/engine/kq/service/impl/KQAttendanceSetServiceImpl.java b/src/com/engine/kq/service/impl/KQAttendanceSetServiceImpl.java new file mode 100644 index 0000000..c93e433 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQAttendanceSetServiceImpl.java @@ -0,0 +1,114 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.hrmAttProcSet.*; +import com.engine.kq.service.KQAttendanceSetService; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import weaver.hrm.User; + +public class KQAttendanceSetServiceImpl extends Service implements KQAttendanceSetService { + + @Override + public Map getStateRightMenu(Map params,User user) { + return commandExecutor.execute(new GetStateRightMenuCmd(params, user)); + } + + @Override + public Map getStateProcSetListSearchCondition(Map params,User user) { + return commandExecutor.execute(new GetStateProcSetListSearchConditionCmd(params, user)); + } + + @Override + public Map getStateProcSetListSearchList(Map params, + HttpServletRequest request,User user) { + return commandExecutor.execute(new GetStateProcSetListSearchListCmd(params,request, user)); + } + + @Override + public Map saveStateProcSetFlow(Map params,User user) { + return commandExecutor.execute(new SaveStateProcSetFlowCmd(params, user)); + } + + @Override + public Map getStateProcSetFlowForm(Map params, User user) { + return commandExecutor.execute(new GetStateProcSetFlowFormCmd(params, user)); + } + + @Override + public Map getStateProcSetTabInfo(Map params, User user) { + return commandExecutor.execute(new GetStateProcSetTabInfoCmd(params, user)); + } + + @Override + public Map getStateProcSetFlowWfFields(Map params, User user) { + return commandExecutor.execute(new GetStateProcSetFlowWfFieldsCmd(params, user)); + } + + @Override + public Map saveStateProcSetFlowWfFields(Map params,HttpServletRequest request, User user) { + return commandExecutor.execute(new SaveStateProcSetFlowWfFieldsCmd(params,request, user)); + } + + @Override + public Map getStateProcSetFlowWfSet(Map params, User user) { + return commandExecutor.execute(new GetStateProcSetFlowWfSetCmd(params, user)); + } + + @Override + public Map saveStateProcSetFlowWfSet(Map params, HttpServletRequest request, + HttpServletResponse response, User user) { + return commandExecutor.execute(new SaveStateProcSetFlowWfSetCmd(params,request,response, user)); + } + + @Override + public Map getStateProcSetCreateForm(Map params, User user) { + return commandExecutor.execute(new GetStateProcSetCreateFormCmd(params, user)); + } + + @Override + public Map changeStateProcSetStatus(Map params, HttpServletRequest request, User user) { + return commandExecutor.execute(new ChangeStateProcSetStatusCmd(params, user)); + } + + @Override + public Map delStateProcSet(Map params,HttpServletRequest request, User user) { + return commandExecutor.execute(new DelStateProcSetCmd(params, user)); + } + + @Override + public Map saveStateProcSetCreateForm(Map params, HttpServletRequest request, User user) { + return commandExecutor.execute(new SaveStateProcSetCreateFormCmd(params, user)); + } + + @Override + public Map getProcSetTemplet(Map params,HttpServletRequest request, User user) { + return commandExecutor.execute(new GetProcSetTempletCmd(params,user)); + } + + @Override + public Map getCustomKQFlowTab(Map params, User user) { + return commandExecutor.execute(new GetCustomKQFlowTabCmd(params,user)); + } + + @Override + public Map getProcSetCheckRule(Map params, User user) { + return commandExecutor.execute(new GetProcSetCheckRuleCmd(params,user)); + } + + @Override + public Map getStateProcSetFlowCheckRuleList(Map params, User user) { + return commandExecutor.execute(new GetStateProcSetFlowCheckRuleListCmd(params,user)); + } + + @Override + public Map saveStateProcCheckRule(Map params, User user) { + return commandExecutor.execute(new SaveStateProcCheckRuleCmd(params,user)); + } + + @Override + public Map delStateProcCheckRule(Map params, User user) { + return commandExecutor.execute(new DelStateProcCheckRuleCmd(params,user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQBalanceDetailServiceImpl.java b/src/com/engine/kq/service/impl/KQBalanceDetailServiceImpl.java new file mode 100644 index 0000000..2dbeb00 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQBalanceDetailServiceImpl.java @@ -0,0 +1,37 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.service.KQBalanceDetailService; +import com.engine.kq.cmd.balanceofleavedetail.*; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +public class KQBalanceDetailServiceImpl extends Service implements KQBalanceDetailService { + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params,user)); + } + + @Override + public Map getSearchList(Map params, User user) { + return commandExecutor.execute(new GetSearchListCmd(params, user)); + } + + @Override + public Map getBalanceForm(Map params, User user) { + return commandExecutor.execute(new GetBalanceFormCmd(params, user)); + } + + @Override + public Map editBalance(Map params, User user) { + return commandExecutor.execute(new EditBalanceCmd(params, user)); + } + + @Override + public Map deleteBalance(Map params, User user) { + return commandExecutor.execute(new DeleteBalanceCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQBalanceOfLeaveRpServiceImpl.java b/src/com/engine/kq/service/impl/KQBalanceOfLeaveRpServiceImpl.java new file mode 100644 index 0000000..4785393 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQBalanceOfLeaveRpServiceImpl.java @@ -0,0 +1,61 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.service.KQBalanceOfLeaveRpService; +import com.engine.kq.cmd.balanceofleaverp.*; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * 员工假期余额报表 + */ +public class KQBalanceOfLeaveRpServiceImpl extends Service implements KQBalanceOfLeaveRpService { + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + @Override + public Map getTab(Map params, User user) { + return commandExecutor.execute(new GetTabCmd(params, user)); + } + + @Override + public Map getSearchCondition(Map params, User user) { + return commandExecutor.execute(new GetSearchConditionCmd(params, user)); + } + + @Override + public Map getSearchList(Map params, User user) { + return commandExecutor.execute(new GetSearchListCmd(params, user)); + } + + @Override + public Map getUsageRecordDetail(Map params, User user) { + return commandExecutor.execute(new GetUsageRecordDetailCmd(params, user)); + } + + @Override + public Map getPageInfo(Map params, User user) { + return commandExecutor.execute(new GetPageInfoCmd(params, user)); + } + + @Override + public Map getDetailPageInfo(Map params, User user) { + return commandExecutor.execute(new GetDetailPageInfoCmd(params, user)); + } + + @Override + public Map getChangeType(Map params, User user) { + return commandExecutor.execute(new GetChangeTypeCmd(params, user)); + } + + @Override + public Map exportExcel(Map params, User user, HttpServletRequest request, HttpServletResponse response) { + return commandExecutor.execute(new ExportExcelCmd(params, user, request, response)); + } +} diff --git a/src/com/engine/kq/service/impl/KQBalanceOfLeaveServiceImpl.java b/src/com/engine/kq/service/impl/KQBalanceOfLeaveServiceImpl.java new file mode 100644 index 0000000..31ace11 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQBalanceOfLeaveServiceImpl.java @@ -0,0 +1,55 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.balanceofleave.*; +import com.engine.kq.service.KQBalanceOfLeaveService; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +/** + * 余额规则 + */ +public class KQBalanceOfLeaveServiceImpl extends Service implements KQBalanceOfLeaveService { + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + @Override + public Map getSearchCondition(Map params, User user) { + return commandExecutor.execute(new GetSearchConditionCmd(params, user)); + } + + @Override + public Map getSearchList(Map params, User user) { + return commandExecutor.execute(new GetSearchListCmd(params, user)); + } + + @Override + public Map batchProcessing(Map params, User user) { + return commandExecutor.execute(new BatchProcessingCmd(params, user)); + } + + @Override + public Map getTabs(Map params, User user) { + return commandExecutor.execute(new GetTabCmd(params, user)); + } + + @Override + public Map saveBalanceOfLeave(Map params, User user) { + return commandExecutor.execute(new SaveBalanceOfLeaveCmd(params, user)); + } + + @Override + public Map getImportForm(Map params, User user) { + return commandExecutor.execute(new GetImportFormCmd(params, user)); + } + + @Override + public Map saveImport(Map params, User user, HttpServletRequest request) { + return commandExecutor.execute(new SaveImportCmd(params, user,request)); + } +} diff --git a/src/com/engine/kq/service/impl/KQGroupLocationServiceImpl.java b/src/com/engine/kq/service/impl/KQGroupLocationServiceImpl.java new file mode 100644 index 0000000..4ec5fa8 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQGroupLocationServiceImpl.java @@ -0,0 +1,33 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.grouplocation.DelGroupLocationCmd; +import com.engine.kq.cmd.grouplocation.GetGroupLocationFormCmd; +import com.engine.kq.cmd.grouplocation.GetGroupLocationListCmd; +import com.engine.kq.cmd.grouplocation.SaveGroupLocationCmd; +import com.engine.kq.service.KQGroupLocationService; +import weaver.hrm.User; + +import java.util.Map; + +public class KQGroupLocationServiceImpl extends Service implements KQGroupLocationService { + @Override + public Map save(Map params, User user) { + return commandExecutor.execute(new SaveGroupLocationCmd(params, user)); + } + + @Override + public Map del(Map params, User user) { + return commandExecutor.execute(new DelGroupLocationCmd(params, user)); + } + + @Override + public Map getForm(Map params, User user) { + return commandExecutor.execute(new GetGroupLocationFormCmd(params, user)); + } + + @Override + public Map getGroupLocationList(Map params, User user) { + return commandExecutor.execute(new GetGroupLocationListCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQGroupMemberServiceImpl.java b/src/com/engine/kq/service/impl/KQGroupMemberServiceImpl.java new file mode 100644 index 0000000..8a15f38 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQGroupMemberServiceImpl.java @@ -0,0 +1,41 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.groupmemeber.*; +import com.engine.kq.service.KQGroupMemberService; +import weaver.hrm.User; + +import java.util.Map; + +public class KQGroupMemberServiceImpl extends Service implements KQGroupMemberService { + + @Override + public Map getSearchCondition(Map params, User user) { + return commandExecutor.execute(new GetGroupMemberSearchConditionCmd(params, user)); + } + + @Override + public Map getSearchList(Map params, User user) { + return commandExecutor.execute(new GetGroupMemberSearchListCmd(params, user)); + } + + @Override + public Map save(Map params, User user) { + return commandExecutor.execute(new SaveGroupMemberCmd(params, user)); + } + + @Override + public Map saveValidateDate(Map params, User user) { + return commandExecutor.execute(new SaveValidateDateGroupMemberCmd(params, user)); + } + + @Override + public Map del(Map params, User user) { + return commandExecutor.execute(new DelGroupMemberCmd(params, user)); + } + + @Override + public Map getForm(Map params, User user) { + return commandExecutor.execute(new GetGroupMemberFormCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQGroupServiceImpl.java b/src/com/engine/kq/service/impl/KQGroupServiceImpl.java new file mode 100644 index 0000000..5a4ee16 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQGroupServiceImpl.java @@ -0,0 +1,88 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.group.*; +import com.engine.kq.service.KQGroupService; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +public class KQGroupServiceImpl extends Service implements KQGroupService { + + @Override + public Map getTabs(Map params, User user) { + return commandExecutor.execute(new GetTabsCmd(params, user)); + } + + @Override + public Map getSearchCondition(Map params, User user) { + return commandExecutor.execute(new GetGroupSearchConditionCmd(params, user)); + } + + @Override + public Map getSearchList(Map params, User user) { + return commandExecutor.execute(new GetGroupSearchListCmd(params, user)); + } + + @Override + public Map save(Map params, User user) { + return commandExecutor.execute(new SaveGroupCmd(params, user)); + } + + @Override + public Map del(Map params, User user) { + return commandExecutor.execute(new DelGroupCmd(params, user)); + } + + @Override + public Map getForm(Map params, User user) { + return commandExecutor.execute(new GetGroupFormCmd(params, user)); + } + + @Override + public Map importExcel(Map params, User user) { + return commandExecutor.execute(new ImportExcelCmd(params, user)); + } + + @Override + public Map exportExcel(Map params, HttpServletRequest request, HttpServletResponse response, User user) { + return commandExecutor.execute(new ExportExcelCmd(params, request, response, user)); + } + + @Override + public Map getGroupTree(Map params, User user) { + return commandExecutor.execute(new GetGroupTreeCmd(params, user)); + } + + @Override + public Map getShiftCycleForm(Map params, User user) { + return commandExecutor.execute(new GetShiftCycleFormCmd(params, user)); + } + + @Override + public Map getMainTabs(Map params, User user) { + return commandExecutor.execute(new GetMainTabsCmd(params, user)); + } + + @Override + public Map getGroupMemeberCondition(Map params, User user) { + return commandExecutor.execute(new GetGroupMemberConditionCmd(params, user)); + } + + @Override + public Map getAddMemberCondition(Map params, User user) { + return commandExecutor.execute(new GetAddMemberConditionCmd(params, user)); + } + + @Override + public Map getGroupMemberList(Map params, User user) { + return commandExecutor.execute(new GetGroupMemberListCmd(params, user)); + } + + @Override + public Map saveAddMenber(Map params, User user) { + return commandExecutor.execute(new SaveAddMemberCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQGroupWifiServiceImpl.java b/src/com/engine/kq/service/impl/KQGroupWifiServiceImpl.java new file mode 100644 index 0000000..2f35e38 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQGroupWifiServiceImpl.java @@ -0,0 +1,34 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.groupwifi.DelGroupWifiCmd; +import com.engine.kq.cmd.groupwifi.GetGroupWifiFormCmd; +import com.engine.kq.cmd.groupwifi.GetGroupWifiListCmd; +import com.engine.kq.cmd.groupwifi.SaveGroupWifiCmd; +import com.engine.kq.service.KQGroupWifiService; +import weaver.hrm.User; + +import java.util.Map; + +public class KQGroupWifiServiceImpl extends Service implements KQGroupWifiService { + @Override + public Map save(Map params, User user) { + return commandExecutor.execute(new SaveGroupWifiCmd(params, user)); + } + + @Override + public Map del(Map params, User user) { + return commandExecutor.execute(new DelGroupWifiCmd(params, user)); + } + + @Override + public Map getForm(Map params, User user) { + return commandExecutor.execute(new GetGroupWifiFormCmd(params, user)); + } + + @Override + public Map getGroupWifiList(Map params, User user) { + return commandExecutor.execute(new GetGroupWifiListCmd(params, user)); + } + +} diff --git a/src/com/engine/kq/service/impl/KQHolidaySetServiceImpl.java b/src/com/engine/kq/service/impl/KQHolidaySetServiceImpl.java new file mode 100644 index 0000000..a106009 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQHolidaySetServiceImpl.java @@ -0,0 +1,90 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.holidaySet.*; +import com.engine.kq.service.KQHolidaySetService; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +/** + * + */ +public class KQHolidaySetServiceImpl extends Service implements KQHolidaySetService { + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + @Override + public Map getSearchCondition(Map params, User user) { + return commandExecutor.execute(new GetSearchConditionCmd(params, user)); + } + + @Override + public Map getSearchList(Map params, User user) { + return commandExecutor.execute(new GetSearchListCmd(params, user)); + } + + @Override + public Map getHolidaySetCalendar(Map params, User user) { + return commandExecutor.execute(new GetHolidaySetCalendarCmd(params, user)); + } + + @Override + public Map getHolidaySetForm(Map params, User user) { + return commandExecutor.execute(new GetHolidaySetFormCmd(params, user)); + } + + @Override + public Map addHolidaySet(Map params, User user) { + return commandExecutor.execute(new AddHolidaySetCmd(params, user)); + } + + @Override + public Map editHolidaySet(Map params, User user) { + return commandExecutor.execute(new EditHolidaySetCmd(params, user)); + } + + @Override + public Map deleteHolidaySet(Map params, User user) { + return commandExecutor.execute(new DeleteHolidaySetCmd(params, user)); + } + + @Override + public Map getHolidayCount(Map params, User user) { + return commandExecutor.execute(new GetHolidayCountCmd(params, user)); + } + + @Override + public Map getImportForm(Map params, User user) { + return commandExecutor.execute(new GetImportFormCmd(params, user)); + } + + @Override + public Map saveImport(Map params, HttpServletRequest request, User user) { + return commandExecutor.execute(new SaveImportCmd(params, request, user)); + } + + @Override + public Map initHolidaySet(Map params, User user) { + return commandExecutor.execute(new InitHolidaySetCmd(params, user)); + } + + @Override + public Map hasRepeactData(Map params, User user) { + return commandExecutor.execute(new HasRepeatDataCmd(params, user)); + } + + @Override + public Map getSyncForm(Map params, User user) { + return commandExecutor.execute(new GetSyncFormCmd(params, user)); + } + + @Override + public Map syncHolidaySet(Map params, User user) { + return commandExecutor.execute(new SyncHolidaySetCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQLeaveParentalServiceImpl.java b/src/com/engine/kq/service/impl/KQLeaveParentalServiceImpl.java new file mode 100644 index 0000000..30576bd --- /dev/null +++ b/src/com/engine/kq/service/impl/KQLeaveParentalServiceImpl.java @@ -0,0 +1,19 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.leaveParentalrules.*; +import com.engine.kq.service.KQLeaveParentalService; +import weaver.hrm.User; + +import java.util.Map; + +public class KQLeaveParentalServiceImpl extends Service implements KQLeaveParentalService { + + + + @Override + public Map getParentalForm(Map params, User user) { + return commandExecutor.execute(new GetLeaveRulesFormCmd(params, user)); + } + +} diff --git a/src/com/engine/kq/service/impl/KQLeaveRulesServiceImpl.java b/src/com/engine/kq/service/impl/KQLeaveRulesServiceImpl.java new file mode 100644 index 0000000..d220b75 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQLeaveRulesServiceImpl.java @@ -0,0 +1,56 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.leaverules.*; +import com.engine.kq.service.KQLeaveRulesService; +import weaver.hrm.User; + +import java.util.Map; + +public class KQLeaveRulesServiceImpl extends Service implements KQLeaveRulesService { + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + @Override + public Map getSearchCondition(Map params, User user) { + return commandExecutor.execute(new GetSearchConditionCmd(params, user)); + } + + @Override + public Map getSearchList(Map params, User user) { + return commandExecutor.execute(new GetSearchListCmd(params, user)); + } + + @Override + public Map getLeaveRulesForm(Map params, User user) { + return commandExecutor.execute(new GetLeaveRulesFormCmd(params, user)); + } + + @Override + public Map addLeaveRules(Map params, User user) { + return commandExecutor.execute(new AddLeaveRulesCmd(params, user)); + } + + @Override + public Map editLeaveRules(Map params, User user) { + return commandExecutor.execute(new EditLeaveRulesCmd(params, user)); + } + + @Override + public Map deleteLeaveRules(Map params, User user) { + return commandExecutor.execute(new DeleteLeaveRulesCmd(params, user)); + } + + @Override + public Map isNameRepeat(Map params, User user) { + return commandExecutor.execute(new IsNameRepeatCmd(params, user)); + } + + @Override + public Map getUnitName(Map params, User user) { + return commandExecutor.execute(new GetUnitNameCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQLeaveTypesServiceImpl.java b/src/com/engine/kq/service/impl/KQLeaveTypesServiceImpl.java new file mode 100644 index 0000000..56f6f74 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQLeaveTypesServiceImpl.java @@ -0,0 +1,71 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.leavetypes.*; +import com.engine.kq.service.KQLeaveTypesService; +import weaver.hrm.User; + +import java.util.Map; + +/** + * @Auther: Administrator + * @Date: 2019-03-12 11:11 + * @Description: + */ +public class KQLeaveTypesServiceImpl extends Service implements KQLeaveTypesService { + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + @Override + public Map getSearchCondition(Map params, User user) { + return commandExecutor.execute(new GetSearchConditionCmd(params, user)); + } + + @Override + public Map getSearchList(Map params, User user) { + return commandExecutor.execute(new GetSearchListCmd(params, user)); + } + + @Override + public Map getLeaveTypesForm(Map params, User user) { + return commandExecutor.execute(new GetLeaveTypesFormCmd(params, user)); + } + + @Override + public Map addLeaveTypes(Map params, User user) { + return commandExecutor.execute(new AddLeaveTypesCmd(params, user)); + } + + @Override + public Map editLeaveTypes(Map params, User user) { + return commandExecutor.execute(new EditLeaveTypesCmd(params, user)); + } + + @Override + public Map deleteLeaveTypes(Map params, User user) { + return commandExecutor.execute(new DeleteLeaveTypesCmd(params, user)); + } + + @Override + public Map isNameRepeat(Map params, User user) { + return commandExecutor.execute(new IsNameRepeatCmd(params, user)); + } + + @Override + public Map saveDisableLeaveTypes(Map params, User user) { + return commandExecutor.execute(new SaveDisableLeaveTypesCmd(params, user)); + } + + @Override + public Map getTimeSelectionForm(Map params, User user) { + return commandExecutor.execute(new GetTimeSelectionFormCmd(params, user)); + } + + @Override + public Map saveTimeSelectionForm(Map params, User user) { + return commandExecutor.execute(new SaveTimeSelectionFormCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQMyAttendanceServiceImpl.java b/src/com/engine/kq/service/impl/KQMyAttendanceServiceImpl.java new file mode 100644 index 0000000..2a97e4a --- /dev/null +++ b/src/com/engine/kq/service/impl/KQMyAttendanceServiceImpl.java @@ -0,0 +1,107 @@ +package com.engine.kq.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.engine.core.impl.Service; +import com.engine.kq.cmd.report.GetKQReportCmd; +import com.engine.kq.service.KQMyAttendanceService; +import com.engine.kq.cmd.myattendance.*; +import weaver.common.DateUtil; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; + +import java.util.Calendar; +import java.util.HashMap; +import java.util.Map; + +/** + * 前台--人事--我的考勤 + */ +public class KQMyAttendanceServiceImpl extends Service implements KQMyAttendanceService { + + @Override + public Map getHrmKQReportInfo(Map params, User user) { + try{ + String type = Util.null2String(params.get("type")); + String typevalue = Util.null2String(params.get("typevalue")); + String loaddata = Util.null2String(params.get("loaddata")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"),0); + int departmentId = Util.getIntValue((String) params.get("departmentId"),0); + String resourceId = Util.null2String(params.get("resourceId")); + String status = Util.null2String(params.get("status")); + + if(resourceId.length()==0){ + resourceId = "" + user.getUID(); + } + if(type.equals("1")){//年 + if(typevalue.length()==0 || typevalue.length()!=4){ + typevalue = DateUtil.getYear(); + } + fromDate = typevalue + "-01-01"; + toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate)); + }else if(type.equals("2")){//月 + if(typevalue.length()==0){ + typevalue = DateUtil.getYear()+"-"+DateUtil.getMonth(); + } + fromDate = typevalue + "-01"; + toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate)); + } + params.put("fromDate",fromDate); + params.put("toDate",toDate); + + /**获取今天的日期*/ + Calendar today = Calendar.getInstance(); + String currentdate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + Map paramsMap = new HashMap(); + paramsMap.put("pageIndex",1); + paramsMap.put("pageSize",10); + paramsMap.put("typeselect","6"); + paramsMap.put("fromDate",fromDate); + paramsMap.put("toDate",toDate); + paramsMap.put("viewScope","3"); + paramsMap.put("resourceId",resourceId); + paramsMap.put("isNoAccount","1"); + paramsMap.put("attendanceSerial",""); + paramsMap.put("isFromMyAttendance","1"); + Map temp = new HashMap(); + temp.put("data",JSONObject.toJSONString(paramsMap)); + temp.put("reportType","month"); + + params.put("datas",commandExecutor.execute(new GetKQReportCmd(temp, user)).get("datas")); + }catch (Exception e){ + new BaseBean().writeLog(e); + } + return commandExecutor.execute(new GetHrmKQReportInfoCmd(params, user)); + } + + @Override + public Map getHrmKQMonthReportInfo(Map params, User user) { + return commandExecutor.execute(new GetHrmKQMonthReportInfoCmd(params, user)); + } + + @Override + public Map getHrmKQReportDetialInfo(Map params, User user) { + return commandExecutor.execute(new GetHrmKQReportDetialInfoCmd(params, user)); + } + + @Override + public Map getHrmKQSignInfo(Map params, User user) { + return commandExecutor.execute(new GetHrmKQSignInfoCmd(params, user)); + } + + @Override + public Map getDetailCondition4Mobile(Map params, User user) { + return commandExecutor.execute(new GetDetailCondition4MobileCmd(params, user)); + } + + @Override + public Map getDetailList4Mobile(Map params, User user) { + return commandExecutor.execute(new GetDetailList4MobileCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQOriginalPunchRpServiceImpl.java b/src/com/engine/kq/service/impl/KQOriginalPunchRpServiceImpl.java new file mode 100644 index 0000000..0cadc49 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQOriginalPunchRpServiceImpl.java @@ -0,0 +1,36 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.service.KQOriginalPunchRpService; +import com.engine.kq.cmd.originalpunchrp.*; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * 原始打卡记录报表 + */ +public class KQOriginalPunchRpServiceImpl extends Service implements KQOriginalPunchRpService { + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + @Override + public Map getSearchCondition(Map params, User user) { + return commandExecutor.execute(new GetSearchConditionCmd(params, user)); + } + + @Override + public Map getSearchList(Map params, User user) { + return commandExecutor.execute(new GetSearchListCmd(params, user)); + } + + @Override + public Map exportExcel(Map params, User user, HttpServletRequest request, HttpServletResponse response) { + return commandExecutor.execute(new com.engine.kq.cmd.balanceofleaverp.ExportExcelCmd(params, user, request, response)); + } +} diff --git a/src/com/engine/kq/service/impl/KQOvertimeRulesServiceImpl.java b/src/com/engine/kq/service/impl/KQOvertimeRulesServiceImpl.java new file mode 100644 index 0000000..143997d --- /dev/null +++ b/src/com/engine/kq/service/impl/KQOvertimeRulesServiceImpl.java @@ -0,0 +1,69 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.overtimerules.*; +import com.engine.kq.service.KQOvertimeRulesService; +import weaver.hrm.User; + +import java.util.Map; + +/** + * 加班规则 + */ +public class KQOvertimeRulesServiceImpl extends Service implements KQOvertimeRulesService { + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + @Override + public Map getSearchList(Map params, User user) { + return commandExecutor.execute(new GetSearchListCmd(params, user)); + } + + @Override + public Map getOvertimeRulesForm(Map params, User user) { + return commandExecutor.execute(new GetOvertimeRulesFormCmd(params, user)); + } + + @Override + public Map addOvertimeRules(Map params, User user) { + return commandExecutor.execute(new AddOvertimeRulesCmd(params, user)); + } + + @Override + public Map editOvertimeRules(Map params, User user) { + return commandExecutor.execute(new EditOverTimeRulesCmd(params, user)); + } + + @Override + public Map deleteOvertimeRules(Map params, User user) { + return commandExecutor.execute(new DeleteOvertimeRulesCmd(params, user)); + } + + @Override + public Map saveDefault(Map params, User user) { + return commandExecutor.execute(new SaveDefaultCmd(params, user)); + } + + @Override + public Map isRepeatSetting(Map params, User user) { + return commandExecutor.execute(new IsRepeatSettingCmd(params, user)); + } + + @Override + public Map getOvertimeUnitForm(Map params, User user) { + return commandExecutor.execute(new GetOvertimeUnitFormCmd(params, user)); + } + + @Override + public Map getOvertimeSearchCondition(Map params, User user) { + return commandExecutor.execute(new GetOvertimeSearchConditionCmd(params, user)); + } + + @Override + public Map saveOvertimeUnit(Map params, User user) { + return commandExecutor.execute(new SaveOvertimeUnitCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQRemindMsgServiceImpl.java b/src/com/engine/kq/service/impl/KQRemindMsgServiceImpl.java new file mode 100644 index 0000000..b78fbe0 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQRemindMsgServiceImpl.java @@ -0,0 +1,24 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.abnormalremind.GetAbnormalremindConditionCmd; +import com.engine.kq.cmd.abnormalremind.GetAbnormalremindInfoCmd; +import com.engine.kq.cmd.overtimerules.SaveOvertimeUnitCmd; +import com.engine.kq.service.KQRemindMsgService; +import weaver.hrm.User; + +import java.util.Map; + +public class KQRemindMsgServiceImpl extends Service implements KQRemindMsgService { + + @Override + public Map getSearchList(Map params, User user) { + return commandExecutor.execute(new GetAbnormalremindInfoCmd(params, user)); + } + + @Override + public Map getSearchCondition(Map params, User user) { + return commandExecutor.execute(new GetAbnormalremindConditionCmd(params, user)); + + } +} diff --git a/src/com/engine/kq/service/impl/KQRemindOnPCServiceImpl.java b/src/com/engine/kq/service/impl/KQRemindOnPCServiceImpl.java new file mode 100644 index 0000000..56197ee --- /dev/null +++ b/src/com/engine/kq/service/impl/KQRemindOnPCServiceImpl.java @@ -0,0 +1,28 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.attendanceButton.GetExtraMapConfigCmd; +import com.engine.kq.cmd.attendanceButton.SaveExtraMapConfigCmd; +import com.engine.kq.cmd.remindOnPC.GetRemindInfoCmd; +import com.engine.kq.service.KQRemindOnPCService; +import weaver.hrm.User; + +import java.util.Map; + +public class KQRemindOnPCServiceImpl extends Service implements KQRemindOnPCService { + + @Override + public Map getRemindInfo(Map params, User user) { + return commandExecutor.execute(new GetRemindInfoCmd(params, user)); + } + + @Override + public Map saveExtraMapConfig(Map params, User user) { + return commandExecutor.execute(new SaveExtraMapConfigCmd(params, user)); + } + + @Override + public Map getExtraMapConfig(Map params, User user) { + return commandExecutor.execute(new GetExtraMapConfigCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQReport4EServiceImpl.java b/src/com/engine/kq/service/impl/KQReport4EServiceImpl.java new file mode 100644 index 0000000..4336a2f --- /dev/null +++ b/src/com/engine/kq/service/impl/KQReport4EServiceImpl.java @@ -0,0 +1,31 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.report4E.GetBalanceInfoCmd; +import com.engine.kq.cmd.report4E.GetScheduleDataCmd; +import com.engine.kq.cmd.report4E.PunchButton4ECmd; +import com.engine.kq.service.KQReport4EService; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import weaver.hrm.User; + +/** + * 考勤流程相关的ajax请求事件 + */ +public class KQReport4EServiceImpl extends Service implements KQReport4EService { + + @Override + public Map punchButton4E(HttpServletRequest request,Map params, User user) { + return commandExecutor.execute(new PunchButton4ECmd(request,params, user)); + } + + @Override + public Map getScheduleData(HttpServletRequest request,Map params, User user) { + return commandExecutor.execute(new GetScheduleDataCmd(request,params, user)); + } + @Override + public Map getBalanceInfo(HttpServletRequest request,Map params, User user) { + return commandExecutor.execute(new GetBalanceInfoCmd(request,params, user)); + } + +} diff --git a/src/com/engine/kq/service/impl/KQReportDetailServiceImpl.java b/src/com/engine/kq/service/impl/KQReportDetailServiceImpl.java new file mode 100644 index 0000000..517a9e0 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQReportDetailServiceImpl.java @@ -0,0 +1,54 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.reportdetial.*; +import com.engine.kq.service.KQReportDetailService; +import weaver.hrm.User; +import java.util.Map; + +public class KQReportDetailServiceImpl extends Service implements KQReportDetailService { + @Override + public Map getTabs(Map params, User user) { + return commandExecutor.execute(new GetTabsCmd(params, user)); + } + + @Override + public Map getWorkDayInfo(Map params, User user) { + return commandExecutor.execute(new GetWorkDayInfoCmd(params, user)); + } + + @Override + public Map getSignInfo(Map params, User user) { + return commandExecutor.execute(new GetSignInfoCmd(params, user)); + } + + @Override + public Map getBeLateInfo(Map params, User user) { + return commandExecutor.execute(new GetBeLateInfoCmd(params, user)); + } + + @Override + public Map getLeaveEearlyInfo(Map params, User user) { + return commandExecutor.execute(new GetLeaveEearlyInfoCmd(params, user)); + } + + @Override + public Map getAbsenteeismInfo(Map params, User user) { + return commandExecutor.execute(new GetAbsenteeismInfoCmd(params, user)); + } + + @Override + public Map getForgotCheckInfo(Map params, User user) { + return commandExecutor.execute(new GetForgotCheckInfoCmd(params, user)); + } + + @Override + public Map getLeaveInfo(Map params, User user) { + return commandExecutor.execute(new GetLeaveInfoCmd(params, user)); + } + + @Override + public Map getDailyDetialInfo(Map params, User user) { + return commandExecutor.execute(new GetDailyDetialInfoCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQReportFieldDefineServiceImpl.java b/src/com/engine/kq/service/impl/KQReportFieldDefineServiceImpl.java new file mode 100644 index 0000000..8b665df --- /dev/null +++ b/src/com/engine/kq/service/impl/KQReportFieldDefineServiceImpl.java @@ -0,0 +1,226 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.reportfielddefine.*; +import com.engine.kq.service.KQReportFieldDefineService; +import weaver.hrm.User; + +import java.util.Map; + + +public class KQReportFieldDefineServiceImpl extends Service implements KQReportFieldDefineService { + + /** + * 获取考勤报表定制列右键菜单 + * + * @param params + * @param user + * @return + */ + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + /** + * 获取考勤报表定制列页签 + * + * @param params + * @param user + * @return + */ + @Override + public Map getFieldDefineTabs(Map params, User user) { + return commandExecutor.execute(new GetFieldDefineTabsCmd(params, user)); + } + + /** + * 获取考勤报表定制列列表 + * + * @param params + * @param user + * @return + */ + @Override + public Map getFieldDefineList(Map params, User user) { + return commandExecutor.execute(new GetFieldDefineListCmd(params, user)); + } + + /** + * 保存考勤报表定制列列表 + * + * @param params + * @param user + * @return + */ + @Override + public Map saveFieldDefineList(Map params, User user) { + return commandExecutor.execute(new SaveFieldDefineListCmd(params, user)); + } + + /** + * 新增考勤报表定制列表单 + * + * @param params + * @param user + * @return + */ + @Override + public Map getFieldDefineForm(Map params, User user) { + return commandExecutor.execute(new GetFieldDefineFormCmd(params, user)); + } + + /** + * 保存考勤报表定制列表单 + * + * @param params + * @param user + * @return + */ + @Override + public Map saveFieldDefine(Map params, User user) { + return commandExecutor.execute(new SaveFieldDefineCmd(params, user)); + } + + /** + * 删除考勤报表定制列 + * + * @param params + * @param user + * @return + */ + @Override + public Map deleteFieldDefine(Map params, User user) { + return commandExecutor.execute(new DeleteFieldDefineCmd(params, user)); + } + + /** + * 获取考勤报表定制列分组列表 + * + * @param params + * @param user + * @return + */ + @Override + public Map getGroupList(Map params, User user) { + return commandExecutor.execute(new GetGroupListCmd(params, user)); + } + + /** + * 获取考勤报表定制列分组表单 + * + * @param params + * @param user + * @return + */ + @Override + public Map getGroupForm(Map params, User user) { + return commandExecutor.execute(new GetGroupFormCmd(params, user)); + } + + /** + * 保存考勤报表定制列分组表单 + * + * @param params + * @param user + * @return + */ + @Override + public Map saveGroup(Map params, User user) { + return commandExecutor.execute(new SaveGroupCmd(params, user)); + } + + /** + * 删除考勤报表定制列分组 + * + * @param params + * @param user + * @return + */ + @Override + public Map deleteGroup(Map params, User user) { + return commandExecutor.execute(new DeleteGroupCmd(params, user)); + } + + /** + * 移动考勤报表定制列分组 + * + * @param params + * @param user + * @return + */ + public Map changeFieldGroup(Map params, User user) { + return commandExecutor.execute(new ChangeFieldGroupCmd(params, user)); + } + + /** + * 获取考勤报表展示列模板页签 + * + * @param params + * @param user + * @return + */ + @Override + public Map getReportMoudleTabs(Map params, User user) { + return commandExecutor.execute(new GetReportMoudleTabsCmd(params, user)); + } + + /** + * 获取自定义模板表单 + * + * @param params + * @param user + * @return + */ + @Override + public Map getReportMoudleForm(Map params, User user) { + return commandExecutor.execute(new GetReportMoudleFormCmd(params, user)); + } + + /** + * 保存考勤报表展示列模板页签 + * + * @param params + * @param user + * @return + */ + @Override + public Map saveReportMoudle(Map params, User user) { + return commandExecutor.execute(new SaveReportMoudleCmd(params, user)); + } + + /** + * 删除考勤报表展示列模板页签 + * + * @param params + * @param user + * @return + */ + @Override + public Map deleteReportMoudle(Map params, User user) { + return commandExecutor.execute(new DeleteReportMoudleCmd(params, user)); + } + + /** + * 获取考勤报表排序设置 + * + * @param params + * @param user + * @return + */ + @Override + public Map getFieldOrderDefine(Map params, User user) { + return commandExecutor.execute(new GetFieldOrderDefineCmd(params, user)); + } + + /** + * 保存考勤报表排序设置 + * + * @param params + * @param user + * @return + */ + public Map saveFieldOrderDefine(Map params, User user) { + return commandExecutor.execute(new SaveFieldOrderDefineCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQReportServiceImpl.java b/src/com/engine/kq/service/impl/KQReportServiceImpl.java new file mode 100644 index 0000000..2e946c9 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQReportServiceImpl.java @@ -0,0 +1,48 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.report.*; +import com.engine.kq.service.KQReportService; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +public class KQReportServiceImpl extends Service implements KQReportService { + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + @Override + public Map getSearchCondition(Map params, User user) { + return commandExecutor.execute(new GetSearchConditionCmd(params, user)); + } + + @Override + public Map getKQDailyReport(Map params, User user) { + return commandExecutor.execute(new GetKQDailyReportCmd(params, user)); + } + + @Override + public Map getKQReport(Map params, User user) { + return commandExecutor.execute(new GetKQReportCmd(params, user)); + } + + @Override + public Map formatReport(Map params, User user) { + return commandExecutor.execute(new FormatReportCmd(params, user)); + } + + @Override + public Map exportExcel(Map params, HttpServletRequest request, HttpServletResponse response, User user) { + return commandExecutor.execute(new ExportExcelCmd(params, request, response, user)); + } + + @Override + public Map exportDailyExcel(Map params, HttpServletRequest request, HttpServletResponse response, User user) { + return commandExecutor.execute(new ExportDailyExcelCmd(params, request, response, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQReportShareServiceImpl.java b/src/com/engine/kq/service/impl/KQReportShareServiceImpl.java new file mode 100644 index 0000000..b88b2c0 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQReportShareServiceImpl.java @@ -0,0 +1,44 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.reportshare.*; +import com.engine.kq.service.KQReportShareService; +import weaver.hrm.User; + +import java.util.Map; + +/** + * 考勤报表权限共享 + */ +public class KQReportShareServiceImpl extends Service implements KQReportShareService { + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + @Override + public Map getSearchCondition(Map params, User user) { + return commandExecutor.execute(new GetSearchConditionCmd(params, user)); + } + + @Override + public Map getSearchList(Map params, User user) { + return commandExecutor.execute(new GetSearchListCmd(params, user)); + } + + @Override + public Map getReportShareForm(Map params, User user) { + return commandExecutor.execute(new GetReportShareFormCmd(params, user)); + } + + @Override + public Map saveReportShare(Map params, User user) { + return commandExecutor.execute(new SaveReportShareCmd(params, user)); + } + + @Override + public Map deleteReportShare(Map params, User user) { + return commandExecutor.execute(new DeleteReportShareCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQScheduleCodeServiceImpl.java b/src/com/engine/kq/service/impl/KQScheduleCodeServiceImpl.java new file mode 100644 index 0000000..046cc0e --- /dev/null +++ b/src/com/engine/kq/service/impl/KQScheduleCodeServiceImpl.java @@ -0,0 +1,68 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.schedulecode.*; +import com.engine.kq.service.KQScheduleCodeService; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + + +public class KQScheduleCodeServiceImpl extends Service implements KQScheduleCodeService { + + @Override + public Map getScheduleCodeCondition(Map params, User user) { + return commandExecutor.execute(new GetScheduleCodeConditionCmd(params, user)); + } + + @Override + public Map getScheduleCodeList(Map params, User user) { + return commandExecutor.execute(new GetScheduleCodeListCmd(params, user)); + } + + @Override + public Map getScheduleCodeForm(Map params, User user) { + return commandExecutor.execute(new GetScheduleCodeFormCmd(params, user)); + } + + @Override + public Map saveScheduleCode(Map params, User user) { + return commandExecutor.execute(new SaveScheduleCodeCmd(params, user)); + } + + @Override + public Map getScheduleDeviceCondition(Map params, User user) { + return commandExecutor.execute(new GetScheduleDeviceConditionCmd(params, user)); + } + + @Override + public Map getScheduleDeviceList(Map params, User user) { + return commandExecutor.execute(new GetScheduleDeviceListCmd(params, user)); + } + + @Override + public Map getScheduleDeviceForm(Map params, User user) { + return commandExecutor.execute(new GetScheduleDeviceFormCmd(params, user)); + } + + @Override + public Map saveScheduleDevice(Map params, User user) { + return commandExecutor.execute(new SaveScheduleDeviceCmd(params, user)); + } + + @Override + public Map delScheduleDevice(Map params, User user) { + return commandExecutor.execute(new DelScheduleDeviceCmd(params, user)); + } + + @Override + public Map getScheduleCodeImportForm(Map params, User user) { + return commandExecutor.execute(new GetScheduleCodeImportFormCmd(params, user)); + } + + @Override + public Map saveScheduleCodeImport(Map params, User user, HttpServletRequest request) { + return commandExecutor.execute(new SaveScheduleCodeImportCmd(params, user, request)); + } +} diff --git a/src/com/engine/kq/service/impl/KQScheduleSignImportServiceImpl.java b/src/com/engine/kq/service/impl/KQScheduleSignImportServiceImpl.java new file mode 100644 index 0000000..a341fae --- /dev/null +++ b/src/com/engine/kq/service/impl/KQScheduleSignImportServiceImpl.java @@ -0,0 +1,51 @@ +package com.engine.kq.service.impl; + +import java.util.Map; +import weaver.hrm.User; +import com.engine.core.impl.Service; +import com.engine.kq.cmd.schedulesignimport.*; +import com.engine.kq.service.KQScheduleSignImportService; + + +public class KQScheduleSignImportServiceImpl extends Service implements KQScheduleSignImportService { + + @Override + public Map getImportForm(Map params, User user) { + return commandExecutor.execute(new GetImportFormCmd(params, user)); + } + + @Override + public Map saveImport(Map params, User user) { + return commandExecutor.execute(new SaveImportCmd(params, user)); + } + + @Override + public Map getImportSetForm(Map params, User user) { + return commandExecutor.execute(new GetImportSetFormCmd(params, user)); + } + + @Override + public Map synData(Map params, User user) { + return commandExecutor.execute(new SynDataCmd(params, user)); + } + + @Override + public Map synDataOpen(Map params) { + return commandExecutor.execute(new SynDataOpenCmd(params)); + } + + @Override + public Map saveImportSet(Map params, User user) { + return commandExecutor.execute(new SaveImportSetCmd(params, user)); + } + + @Override + public Map uploadData(Map params, User user) { + return commandExecutor.execute(new UpLoadDataCmd(params, user)); + } + + @Override + public Map synDingTalkData(Map params) { + return commandExecutor.execute(new SynDingTalkDataCmd(params)); + } +} diff --git a/src/com/engine/kq/service/impl/KQSettingsServiceImpl.java b/src/com/engine/kq/service/impl/KQSettingsServiceImpl.java new file mode 100644 index 0000000..e4cab7e --- /dev/null +++ b/src/com/engine/kq/service/impl/KQSettingsServiceImpl.java @@ -0,0 +1,26 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.service.KQSettingsService; +import com.engine.kq.cmd.settings.*; +import weaver.hrm.User; + +import java.util.Map; + +public class KQSettingsServiceImpl extends Service implements KQSettingsService { + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + @Override + public Map getSettingsForm(Map params, User user) { + return commandExecutor.execute(new GetSettingsFormCmd(params, user)); + } + + @Override + public Map saveSettings(Map params, User user) { + return commandExecutor.execute(new SaveSettingsCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQSetupWizardServiceImpl.java b/src/com/engine/kq/service/impl/KQSetupWizardServiceImpl.java new file mode 100644 index 0000000..5bc10ac --- /dev/null +++ b/src/com/engine/kq/service/impl/KQSetupWizardServiceImpl.java @@ -0,0 +1,43 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.setupwizard.CheckNeedInitCmd; +import com.engine.kq.cmd.setupwizard.GetRightMenuCmd; +import com.engine.kq.cmd.setupwizard.GetSetupFormCmd; +import com.engine.kq.cmd.setupwizard.GetSetupStepsCmd; +import com.engine.kq.cmd.setupwizard.PerformInitializationCmd; +import com.engine.kq.service.KQSetupWizardService; +import weaver.hrm.User; + +import java.util.Map; + +/** + * 一键开启考勤 + */ +public class KQSetupWizardServiceImpl extends Service implements KQSetupWizardService { + + @Override + public Map getSetupForm(Map params, User user) { + return commandExecutor.execute(new GetSetupFormCmd(params, user)); + } + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + @Override + public Map getSetupSteps(Map params, User user) { + return commandExecutor.execute(new GetSetupStepsCmd(params, user)); + } + + @Override + public Map performInitialization(Map params, User user) { + return commandExecutor.execute(new PerformInitializationCmd(params, user)); + } + + @Override + public Map checkNeedInit(Map params, User user) { + return commandExecutor.execute(new CheckNeedInitCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQShiftManagementServiceImpl.java b/src/com/engine/kq/service/impl/KQShiftManagementServiceImpl.java new file mode 100644 index 0000000..2565cc7 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQShiftManagementServiceImpl.java @@ -0,0 +1,88 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.shiftmanagement.*; +import com.engine.kq.service.KQShiftManagementService; +import java.util.Map; +import weaver.hrm.User; + +/** + * 班次管理 + */ + +public class KQShiftManagementServiceImpl extends Service implements KQShiftManagementService { + + + @Override + public Map getTabs(Map params, User user) { + return commandExecutor.execute(new GetTabsCmd(params, user)); + } + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + @Override + public Map getShiftManagementSearchCondition(Map params, + User user) { + return commandExecutor.execute(new GetShiftManagementSearchConditionCmd(params, user)); + } + + @Override + public Map getShiftManagementSearchList(Map params, User user) { + return commandExecutor.execute(new GetShiftManagementSearchListCmd(params, user)); + } + + @Override + public Map getShiftManagementBaseForm(Map params, User user) { + return commandExecutor.execute(new GetShiftManagementBaseFormCmd(params, user)); + } + + @Override + public Map saveShiftManagementBaseForm(Map params, User user) { + return commandExecutor.execute(new SaveShiftManagementBaseFormCmd(params, user)); + } + + @Override + public Map getShiftManagementPersonalizedForm(Map params, + User user) { + return commandExecutor.execute(new GetShiftManagementPersonalizedFormCmd(params, user)); + } + + @Override + public Map saveShiftManagementPersonalizedForm(Map params, + User user) { + return commandExecutor.execute(new SaveShiftManagementPersonalizedFormCmd(params, user)); + } + + @Override + public Map delShiftManagementForm(Map params, User user) { + return commandExecutor.execute(new DelShiftManagementFormCmd(params, user)); + } + + @Override + public Map getEmailRemindForm(Map params, User user) { + return commandExecutor.execute(new GetEmailRemindFormCmd(params, user)); + } + + @Override + public Map saveEmailRemind(Map params, User user) { + return commandExecutor.execute(new SaveEmailRemindCmd(params, user)); + } + + @Override + public Map getMessageRemindForm(Map params, User user) { + return commandExecutor.execute(new GetMessageRemindFormCmd(params, user)); + } + + @Override + public Map saveMessageRemind(Map params, User user) { + return commandExecutor.execute(new SaveMessageRemindCmd(params, user)); + } + + @Override + public Map getDetachOperatelevel(Map params, User user) { + return commandExecutor.execute(new GetDetachOperatelevelCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQShiftScheduleServiceImpl.java b/src/com/engine/kq/service/impl/KQShiftScheduleServiceImpl.java new file mode 100644 index 0000000..4499bcd --- /dev/null +++ b/src/com/engine/kq/service/impl/KQShiftScheduleServiceImpl.java @@ -0,0 +1,74 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.shiftschedule.GetTabsCmd; +import com.engine.kq.cmd.shiftschedule.*; +import com.engine.kq.service.KQShiftScheduleService; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +public class KQShiftScheduleServiceImpl extends Service implements KQShiftScheduleService { + + @Override + public Map getSearchCondition(Map params, User user) { + return commandExecutor.execute(new GetSearchConditionCmd(params, user)); + } + + @Override + public Map getTabs(Map params, User user) { + return commandExecutor.execute(new GetTabsCmd(params, user)); + } + + @Override + public Map getShiftSchedule(Map params, User user) { + return commandExecutor.execute(new GetShiftScheduleCmd(params, user)); + } + + @Override + public Map save(Map params, User user) { + return commandExecutor.execute(new SaveShiftScheduleCmd(params, user)); + } + + @Override + public Map del(Map params, User user) { + return commandExecutor.execute(new DelShiftScheduleCmd(params, user)); + } + + @Override + public Map getBatchShiftScheduleFrom(Map params, User user) { + return commandExecutor.execute(new GetBatchShiftScheduleFromCmd(params, user)); + } + + @Override + public Map getShiftScheduleMembersValidate(Map params, User user) { + return commandExecutor.execute(new GetShiftScheduleMembersValidateCmd(params, user)); + } + + @Override + public Map batchSave(Map params, User user) { + return commandExecutor.execute(new SaveBatchShiftScheduleCmd(params, user)); + } + + @Override + public Map importExcel(Map params, User user) { + return commandExecutor.execute(new ImportExcelCmd(params, user)); + } + + @Override + public Map exportExcel(Map params, HttpServletRequest request, HttpServletResponse response, User user) { + return commandExecutor.execute(new ExportExcelCmd(params, request, response, user)); + } + + @Override + public Map getShiftScheduleTotal(Map params, User user) { + return commandExecutor.execute(new GetShiftScheduleTotalCmd(params, user)); + } + + @Override + public Map getHrmScheduleReportInfo(Map params, User user) { + return commandExecutor.execute(new GetHrmScheduleReportInfoCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQTravelRulesServiceImpl.java b/src/com/engine/kq/service/impl/KQTravelRulesServiceImpl.java new file mode 100644 index 0000000..fbd540c --- /dev/null +++ b/src/com/engine/kq/service/impl/KQTravelRulesServiceImpl.java @@ -0,0 +1,26 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.travelrules.*; +import com.engine.kq.service.KQTravelRulesService; +import weaver.hrm.User; + +import java.util.Map; + +public class KQTravelRulesServiceImpl extends Service implements KQTravelRulesService { + + @Override + public Map getRightMenu(Map params, User user) { + return commandExecutor.execute(new GetRightMenuCmd(params, user)); + } + + @Override + public Map getTravelRulesForm(Map params, User user) { + return commandExecutor.execute(new GetTravelRulesFormCmd(params, user)); + } + + @Override + public Map saveTravelRules(Map params, User user) { + return commandExecutor.execute(new SaveTravelRulesCmd(params, user)); + } +} diff --git a/src/com/engine/kq/service/impl/KQUpgradeServiceImpl.java b/src/com/engine/kq/service/impl/KQUpgradeServiceImpl.java new file mode 100644 index 0000000..9f76429 --- /dev/null +++ b/src/com/engine/kq/service/impl/KQUpgradeServiceImpl.java @@ -0,0 +1,136 @@ +package com.engine.kq.service.impl; + +import com.engine.core.impl.Service; +import com.engine.kq.cmd.upgrade.DoUpgrade10Cmd; +import com.engine.kq.cmd.upgrade.DoUpgrade12Cmd; +import com.engine.kq.cmd.upgrade.DoUpgrade1Cmd; +import com.engine.kq.cmd.upgrade.DoUpgrade2Cmd; +import com.engine.kq.cmd.upgrade.DoUpgrade3Cmd; +import com.engine.kq.cmd.upgrade.DoUpgrade4Cmd; +import com.engine.kq.cmd.upgrade.DoUpgrade5Cmd; +import com.engine.kq.cmd.upgrade.DoUpgrade6Cmd; +import com.engine.kq.cmd.upgrade.DoUpgrade7Cmd; +import com.engine.kq.cmd.upgrade.DoUpgrade8Cmd; +import com.engine.kq.cmd.upgrade.DoUpgrade9Cmd; +import com.engine.kq.cmd.upgrade.GetTreeTabsCmd; +import com.engine.kq.cmd.upgrade.GetUpgrade10Cmd; +import com.engine.kq.cmd.upgrade.GetUpgrade12Cmd; +import com.engine.kq.cmd.upgrade.GetUpgrade12DataCmd; +import com.engine.kq.cmd.upgrade.GetUpgrade1Cmd; +import com.engine.kq.cmd.upgrade.GetUpgrade2Cmd; +import com.engine.kq.cmd.upgrade.GetUpgrade3Cmd; +import com.engine.kq.cmd.upgrade.GetUpgrade4Cmd; +import com.engine.kq.cmd.upgrade.GetUpgrade5Cmd; +import com.engine.kq.cmd.upgrade.GetUpgrade6Cmd; +import com.engine.kq.cmd.upgrade.GetUpgrade7Cmd; +import com.engine.kq.cmd.upgrade.GetUpgrade8Cmd; +import com.engine.kq.cmd.upgrade.GetUpgrade9Cmd; +import com.engine.kq.service.KQUpgradeService; +import java.util.Map; +import weaver.hrm.User; + +/** + * 班次管理 + */ + +public class KQUpgradeServiceImpl extends Service implements KQUpgradeService { + + @Override + public Map getTreeTabs(Map params, User user) { + return commandExecutor.execute(new GetTreeTabsCmd(params, user)); + } + + @Override + public Map getUpgrade1(Map params, User user) { + return commandExecutor.execute(new GetUpgrade1Cmd(params, user)); + } + @Override + public Map getUpgrade2(Map params, User user) { + return commandExecutor.execute(new GetUpgrade2Cmd(params, user)); + } + @Override + public Map getUpgrade3(Map params, User user) { + return commandExecutor.execute(new GetUpgrade3Cmd(params, user)); + } + @Override + public Map getUpgrade4(Map params, User user) { + return commandExecutor.execute(new GetUpgrade4Cmd(params, user)); + } + @Override + public Map getUpgrade5(Map params, User user) { + return commandExecutor.execute(new GetUpgrade5Cmd(params, user)); + } + @Override + public Map getUpgrade6(Map params, User user) { + return commandExecutor.execute(new GetUpgrade6Cmd(params, user)); + } + @Override + public Map getUpgrade7(Map params, User user) { + return commandExecutor.execute(new GetUpgrade7Cmd(params, user)); + } + @Override + public Map getUpgrade8(Map params, User user) { + return commandExecutor.execute(new GetUpgrade8Cmd(params, user)); + } + @Override + public Map getUpgrade9(Map params, User user) { + return commandExecutor.execute(new GetUpgrade9Cmd(params, user)); + } + @Override + public Map getUpgrade10(Map params, User user) { + return commandExecutor.execute(new GetUpgrade10Cmd(params, user)); + } + @Override + public Map getUpgrade12(Map params, User user) { + return commandExecutor.execute(new GetUpgrade12Cmd(params, user)); + } + + @Override + public Map doUpgrade1(Map params, User user) { + return commandExecutor.execute(new DoUpgrade1Cmd(params, user)); + } + @Override + public Map doUpgrade2(Map params, User user) { + return commandExecutor.execute(new DoUpgrade2Cmd(params, user)); + } + @Override + public Map doUpgrade3(Map params, User user) { + return commandExecutor.execute(new DoUpgrade3Cmd(params, user)); + } + @Override + public Map doUpgrade4(Map params, User user) { + return commandExecutor.execute(new DoUpgrade4Cmd(params, user)); + } + @Override + public Map doUpgrade5(Map params, User user) { + return commandExecutor.execute(new DoUpgrade5Cmd(params, user)); + } + @Override + public Map doUpgrade6(Map params, User user) { + return commandExecutor.execute(new DoUpgrade6Cmd(params, user)); + } + @Override + public Map doUpgrade7(Map params, User user) { + return commandExecutor.execute(new DoUpgrade7Cmd(params, user)); + } + @Override + public Map doUpgrade8(Map params, User user) { + return commandExecutor.execute(new DoUpgrade8Cmd(params, user)); + } + @Override + public Map doUpgrade9(Map params, User user) { + return commandExecutor.execute(new DoUpgrade9Cmd(params, user)); + } + @Override + public Map doUpgrade10(Map params, User user) { + return commandExecutor.execute(new DoUpgrade10Cmd(params, user)); + } + @Override + public Map doUpgrade12(Map params, User user) { + return commandExecutor.execute(new DoUpgrade12Cmd(params, user)); + } + @Override + public Map getUpgrade12Data(Map params, User user) { + return commandExecutor.execute(new GetUpgrade12DataCmd(params, user)); + } +} diff --git a/src/com/engine/kq/timer/KQOvertimeCardBean.java b/src/com/engine/kq/timer/KQOvertimeCardBean.java new file mode 100644 index 0000000..d73516a --- /dev/null +++ b/src/com/engine/kq/timer/KQOvertimeCardBean.java @@ -0,0 +1,94 @@ +package com.engine.kq.timer; + +import com.engine.kq.entity.TimeScopeEntity; +import com.google.common.collect.Lists; +import java.util.List; + +/** + * 加班的bean,主要是打卡+流程这种加班方式使用 + */ +public class KQOvertimeCardBean { + /** + * 归属日期 + */ + private String belongDate; + + /** + * 签到开始日期 + */ + private String signinDate; + /** + * 签到开始时间 + */ + private String signinTime; + /** + * 签到结束日期 + */ + private String signoutDate; + /** + * 签到结束时间 + */ + private String signoutTime; + + /** + *是否有设置打卡归属 + */ + private String has_cut_point; + + public KQOvertimeCardBean() { + this.belongDate = ""; + this.signinDate = ""; + this.signinTime = ""; + this.signoutDate = ""; + this.signoutTime = ""; + this.has_cut_point = ""; + } + + public String getSigninDate() { + return signinDate; + } + + public void setSigninDate(String signinDate) { + this.signinDate = signinDate; + } + + public String getSigninTime() { + return signinTime; + } + + public void setSigninTime(String signinTime) { + this.signinTime = signinTime; + } + + public String getSignoutDate() { + return signoutDate; + } + + public void setSignoutDate(String signoutDate) { + this.signoutDate = signoutDate; + } + + public String getSignoutTime() { + return signoutTime; + } + + public void setSignoutTime(String signoutTime) { + this.signoutTime = signoutTime; + } + + public String getBelongDate() { + return belongDate; + } + + public void setBelongDate(String belongDate) { + this.belongDate = belongDate; + } + + public String getHas_cut_point() { + return has_cut_point; + } + + public void setHas_cut_point(String has_cut_point) { + this.has_cut_point = has_cut_point; + } +} diff --git a/src/com/engine/kq/timer/KQQueue.java b/src/com/engine/kq/timer/KQQueue.java new file mode 100644 index 0000000..09777bc --- /dev/null +++ b/src/com/engine/kq/timer/KQQueue.java @@ -0,0 +1,56 @@ +package com.engine.kq.timer; + +import com.engine.common.entity.BizLogContext; +import com.engine.common.timer.BizLogQueue; +import java.util.ArrayList; +import java.util.List; +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; + +public class KQQueue { + + private static int limitNum = 3000; + public static Queue queue = new ConcurrentLinkedQueue(); + + public static List pollLimitList() { + List list = null; + KQTaskBean tmp = null; + while((tmp = queue.poll()) != null) { + if (tmp == null) { + break; + } + if (list == null) { + list = new ArrayList(limitNum); + } + list.add(tmp); + if (list.size() >= limitNum) { + break; + } + } + return list; + } + + public static void clear() { + queue.clear(); + } + + public static int getLimitNum() { + return limitNum; + } + + public static void writeTasks(List tasks) { + if (tasks== null) { + return; + } + for (KQTaskBean taskBean:tasks) { + queue.offer(taskBean); + } + } + + public static void writeTask(KQTaskBean task) { + if (task== null) { + return; + } + queue.offer(task); + } +} diff --git a/src/com/engine/kq/timer/KQTask.java b/src/com/engine/kq/timer/KQTask.java new file mode 100644 index 0000000..1a1b5a1 --- /dev/null +++ b/src/com/engine/kq/timer/KQTask.java @@ -0,0 +1,45 @@ +package com.engine.kq.timer; + +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.util.SplitActionUtil; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.List; +import java.util.TimerTask; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 拆分action数据的任务 + */ +public class KQTask extends TimerTask { + + private static Logger logger = LoggerFactory.getLogger(KQTask.class); + private KQLog kqLog = new KQLog(); + + @Override + public void run() { + boolean flag = true; + while (flag) { + List list = KQQueue.pollLimitList(); + if (list == null) { +// kqLog.info("KQTask:list is null"); + break; + } + try { + SplitActionUtil splitActionUtil = new SplitActionUtil(); + splitActionUtil.handleOverTime(list); + Thread.sleep(2000); + } catch (Exception e) { + StringWriter errorsWriter = new StringWriter(); + new Exception().printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + logger.error("加班数据生成失败", e); +// break; + } + if (list.size() < KQQueue.getLimitNum()) { + flag = false; + } + } + } +} diff --git a/src/com/engine/kq/timer/KQTaskBean.java b/src/com/engine/kq/timer/KQTaskBean.java new file mode 100644 index 0000000..997632b --- /dev/null +++ b/src/com/engine/kq/timer/KQTaskBean.java @@ -0,0 +1,229 @@ +package com.engine.kq.timer; + +import com.engine.kq.wfset.bean.SplitBean; + +public class KQTaskBean { + + private String requestId; + + private String resourceId; + + /** + * 所属日期 + */ + private String taskDate; + + /** + * 加班开始日期 + */ + private String signDate; + + /** + * 加班结束日期 + */ + private String signEndDate; + + /** + * 计算加班的结束时间 + */ + private String taskSignTime; + + private String lastWorkTime; + + /** + * 对于非工作时间来说,最后的签退时间,即加班的开始时间 + */ + private String signInTime4Out; + + /** + * 工作时长 + */ + private int workmins; + + /** + * 针对打卡 上班前还是下班后 + * before/after + */ + private String timesource; + /** + * 调休id + */ + private String tiaoxiuId; + + /** + * 流程生成加班的時候 流程数据的bean + */ + private SplitBean splitBean; + + /** + * 采用新的加班逻辑计算,统计加班的开始日期 + */ + private String overtime_fromdate; + /** + * 采用新的加班逻辑计算,统计加班的结束日期 + */ + private String overtime_todate; + + /** + * 加班来源类型 是来自由打卡还是考勤同步 + */ + private String tasktype; + + public KQTaskBean() { + this.requestId = ""; + this.resourceId = ""; + this.taskDate = ""; + this.signDate = ""; + this.signEndDate = ""; + this.taskSignTime = ""; + this.lastWorkTime = ""; + this.signInTime4Out = ""; + this.timesource = ""; + this.tiaoxiuId = ""; + this.overtime_fromdate = ""; + this.overtime_todate = ""; + this.tasktype = ""; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public String getTaskDate() { + return taskDate; + } + + public void setTaskDate(String taskDate) { + this.taskDate = taskDate; + } + + public String getTaskSignTime() { + return taskSignTime; + } + + public void setTaskSignTime(String taskSignTime) { + this.taskSignTime = taskSignTime; + } + + public String getLastWorkTime() { + return lastWorkTime; + } + + public void setLastWorkTime(String lastWorkTime) { + this.lastWorkTime = lastWorkTime; + } + + public int getWorkmins() { + return workmins; + } + + public void setWorkmins(int workmins) { + this.workmins = workmins; + } + + public String getSignInTime4Out() { + return signInTime4Out; + } + + public void setSignInTime4Out(String signInTime4Out) { + this.signInTime4Out = signInTime4Out; + } + + public String getSignDate() { + return signDate; + } + + public void setSignDate(String signDate) { + this.signDate = signDate; + } + + public SplitBean getSplitBean() { + return splitBean; + } + + public void setSplitBean(SplitBean splitBean) { + this.splitBean = splitBean; + } + + public String getTimesource() { + return timesource; + } + + public void setTimesource(String timesource) { + this.timesource = timesource; + } + + public String getSignEndDate() { + return signEndDate; + } + + public void setSignEndDate(String signEndDate) { + this.signEndDate = signEndDate; + } + + @Override + public boolean equals(Object obj) { + String cur_requestid = getRequestId(); + String obj_requestid = ((KQTaskBean)obj).getRequestId(); + boolean isEqual = toString().equals(obj.toString()); +// if(isEqual){ +// if(!cur_requestid.equalsIgnoreCase(obj_requestid)){ +// String all_requestid = cur_requestid+","+obj_requestid; +// setRequestId(all_requestid); +// ((KQTaskBean) obj).setRequestId(all_requestid); +// } +// } + return isEqual; + } + + public String getTiaoxiuId() { + return tiaoxiuId; + } + + public void setTiaoxiuId(String tiaoxiuId) { + this.tiaoxiuId = tiaoxiuId; + } + + public String getOvertime_fromdate() { + return overtime_fromdate; + } + + public void setOvertime_fromdate(String overtime_fromdate) { + this.overtime_fromdate = overtime_fromdate; + } + + public String getOvertime_todate() { + return overtime_todate; + } + + public void setOvertime_todate(String overtime_todate) { + this.overtime_todate = overtime_todate; + } + + public String getTasktype() { + return this.tasktype; + } + + public void setTasktype(final String tasktype) { + this.tasktype = tasktype; + } + + @Override + public String toString() { + return getResourceId()+"_"+getTaskDate()+"_"+ + getSignDate()+"_"+getSignEndDate()+"_"+getTaskSignTime()+"_"+ + getLastWorkTime()+"_"+getSignInTime4Out()+getTimesource(); + } +} diff --git a/src/com/engine/kq/timer/KQTaskTimerSchedule.java b/src/com/engine/kq/timer/KQTaskTimerSchedule.java new file mode 100644 index 0000000..daa21dc --- /dev/null +++ b/src/com/engine/kq/timer/KQTaskTimerSchedule.java @@ -0,0 +1,31 @@ +package com.engine.kq.timer; + +import com.engine.common.timer.LogTask; +import com.engine.kq.log.KQLog; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import java.util.Timer; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; + +/** + * 考勤相关定时触发器 + */ +public class KQTaskTimerSchedule { + private static Timer logTimer; + + public static void startTask() { + new KQLog().info("KQTaskTimerSchedule:startTask in"); + logTimer = new Timer(); + KQTask kqTask = new KQTask(); + logTimer.schedule(kqTask, 5 * 1000, 60 * 1000);// 每分钟执行一次 + new KQLog().info("KQTaskTimerSchedule:startTask out"); + } + + public static void endTask() { + new KQLog().info("KQTaskTimerSchedule:startTask in"); + logTimer.cancel(); + new KQLog().info("KQTaskTimerSchedule:startTask out"); + } +} diff --git a/src/com/engine/kq/util/ExcelUtil.java b/src/com/engine/kq/util/ExcelUtil.java new file mode 100644 index 0000000..137a079 --- /dev/null +++ b/src/com/engine/kq/util/ExcelUtil.java @@ -0,0 +1,832 @@ +package com.engine.kq.util; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.util.*; + +import com.engine.kq.biz.KQSettingsComInfo; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellRangeAddressList; +import org.apache.poi.ss.util.RegionUtil; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.GCONST; +import weaver.general.Util; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class ExcelUtil extends BaseBean { + private boolean isKqReportHalfOpen = "1".equals(new KQSettingsComInfo().getMain_val("kq_report_half")); + /* + * 导出数据 + * */ + public Map export(Map workBook, HttpServletRequest request, HttpServletResponse response) throws Exception { + return export(workBook, request, response,false); + } + public Map export(Map workBook, HttpServletRequest request, HttpServletResponse response,boolean isWrap) throws Exception { + return export(workBook, request, response,isWrap,false); + } + public Map export(Map workBook, HttpServletRequest request, HttpServletResponse response,boolean isWrap,boolean isDaily) throws Exception { + Map returnMap = new HashMap<>(); + String createFile = ""; + try { + SXSSFWorkbook workbook = new SXSSFWorkbook(); // 创建工作簿对象 + List lsSheet = (List) workBook.get("sheet"); + String fileName = Util.null2String(workBook.get("fileName")); + if (fileName.length() == 0||true) fileName = "" + UUID.randomUUID();//解决lunix下中文文件无法生成问题 + for (int sheetNum = 0; sheetNum < lsSheet.size(); sheetNum++) { + Map mySheet = (Map) lsSheet.get(sheetNum); + String mySheetName = Util.null2String(mySheet.get("sheetName")); + String sheetTitle = Util.null2String(mySheet.get("sheetTitle")); + List sheetMemo = (List) mySheet.get("sheetMemo"); + List titleList = (List) mySheet.get("titleList"); + List dataList = (List) mySheet.get("dataList"); + List> constraintList = (List>) mySheet.get("constraintList"); + createFile = Util.null2String(mySheet.get("createFile")); + int calIndex = Util.getIntValue(Util.null2String(mySheet.get("calIndex")),-1); + + Sheet sheet = workbook.createSheet(mySheetName); // 创建工作表 + + int rowIdx = 0; + // 产生表格标题行 + Row rowm = sheet.createRow(rowIdx); + Cell cellTiltle = rowm.createCell(0); + + CellStyle titleStyle = this.getTitleStyle(workbook);//获取列头样式对象 + CellStyle memoStyle = this.getMemoStyle(workbook);//获取备注样式对象 + CellStyle columnTopStyle = this.getColumnTopStyle(workbook);//获取列头样式对象 + CellStyle cellStyle = this.getCellStyle(workbook,isWrap); //单元格样式对象 + + int mergedRegion = titleList.size() - 1; + if (mergedRegion > 15) mergedRegion = 15; + mergedRegion = getColLength(titleList); + + CellRangeAddress region = new CellRangeAddress(rowIdx, ++rowIdx, 0, mergedRegion); + RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet); + sheet.addMergedRegionUnsafe(region); + cellTiltle.setCellStyle(titleStyle); + cellTiltle.setCellValue(sheetTitle); + + for (int i = 0; sheetMemo != null && i < sheetMemo.size(); i++) { + rowm = sheet.createRow(++rowIdx); + Cell cellMemo = rowm.createCell(0); + region = new CellRangeAddress(rowIdx, ++rowIdx, 0, mergedRegion); + RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet); + sheet.addMergedRegionUnsafe(region); + cellMemo.setCellStyle(memoStyle); + cellMemo.setCellValue(Util.null2String(sheetMemo.get(i))); + } + +// // 定义所需列数 +// int columnNum = titleList.size(); +// HSSFRow rowRowName = sheet.createRow(++rowIdx); // 在索引2的位置创建行(最顶端的行开始的第二行) +// +// // 将列头设置到sheet的单元格中 +// for (int n = 0; n < columnNum; n++) { +// Map title = (Map) titleList.get(n); +// +// HSSFCell cellRowName = rowRowName.createCell(n); //创建列头对应个数的单元格 +// cellRowName.setCellType(HSSFCell.CELL_TYPE_STRING); //设置列头单元格的数据类型 +// HSSFRichTextString text = new HSSFRichTextString(Util.null2String(title.get("title"))); +// cellRowName.setCellValue(text); //设置列头单元格的值 +// cellRowName.setCellStyle(columnTopStyle); //设置列头单元格样式 +// if (n == 0) { +// sheet.setColumnWidth(n, Util.getIntValue(Util.null2String(title.get("width")))); +// } else { +// sheet.setColumnWidth(n, Util.getIntValue(Util.null2String(title.get("width")))); +// } +// } + + rowIdx = this.initDynamicTitle(sheet, titleList, columnTopStyle, rowIdx); + + if(!isDaily && isKqReportHalfOpen) { + if(calIndex > -1){ + CellStyle style1 = workbook.createCellStyle(); + style1.setFillPattern(FillPatternType.SOLID_FOREGROUND); + short amColor = (short) Util.getIntValue("5"); + style1.setFillForegroundColor(amColor); + style1.setFillBackgroundColor(IndexedColors.BLUE.index); + style1.setAlignment(HorizontalAlignment.CENTER); + //设置底边框; + style1.setBorderBottom(BorderStyle.THIN); + //设置底边框颜色; + style1.setBottomBorderColor(IndexedColors.BLACK.index); + //设置左边框; + style1.setBorderLeft(BorderStyle.THIN); + //设置左边框颜色; + style1.setLeftBorderColor(IndexedColors.BLACK.index); + //设置右边框; + style1.setBorderRight(BorderStyle.THIN); + //设置右边框颜色; + style1.setRightBorderColor(IndexedColors.BLACK.index); + //设置顶边框; + style1.setBorderTop(BorderStyle.THIN); + //设置顶边框颜色; + style1.setTopBorderColor(IndexedColors.BLACK.index); + + CellStyle style2 = workbook.createCellStyle(); + style2.setFillPattern(FillPatternType.SOLID_FOREGROUND); + short pm_color = (short) Util.getIntValue("29"); + style2.setFillForegroundColor(pm_color); + style2.setFillBackgroundColor(IndexedColors.RED.index); + style2.setAlignment(HorizontalAlignment.CENTER); + //设置底边框; + style2.setBorderBottom(BorderStyle.THIN); + //设置底边框颜色; + style2.setBottomBorderColor(IndexedColors.BLACK.index); + //设置左边框; + style2.setBorderLeft(BorderStyle.THIN); + //设置左边框颜色; + style2.setLeftBorderColor(IndexedColors.BLACK.index); + //设置右边框; + style2.setBorderRight(BorderStyle.THIN); + //设置右边框颜色; + style2.setRightBorderColor(IndexedColors.BLACK.index); + //设置顶边框; + style2.setBorderTop(BorderStyle.THIN); + //设置顶边框颜色; + style2.setTopBorderColor(IndexedColors.BLACK.index); //设置单元格样式 + + //将查询出的数据设置到sheet对应的单元格中 + for (int i = 0; dataList != null && i < dataList.size(); ) { + List obj = (List) dataList.get(i);//遍历每个对象 + int rowNowIndex = i + rowIdx + 1; + Row row = sheet.createRow(rowNowIndex);//创建所需的行数 + for (int j = 0; j < obj.size(); j++) { + Cell cell = null; //设置单元格的数据类型 + cell = row.createCell(j, CellType.STRING); + if(j < calIndex){ + cell.setCellStyle(cellStyle); //设置单元格样式 + addMergedRegion(sheet, rowNowIndex, rowNowIndex+1, j, j); + }else{ + + addMergedRegion(sheet, rowNowIndex, rowNowIndex, j, j); + cell.setCellStyle(style1); //设置单元格样式 + } + String value_value = Util.null2String(obj.get(j)); + cell.setCellValue(value_value); //设置单元格的值 + } + List obj1 = (List) dataList.get(i+1);//遍历每个对象 + Row row1 = sheet.createRow(rowNowIndex + 1);//创建所需的行数 + for (int j = 0; j < obj1.size(); j++) { + Cell cell = null; //设置单元格的数据类型 + cell = row1.createCell(j, CellType.STRING); + if(j < calIndex){ + cell.setCellStyle(cellStyle); //设置单元格样式 + }else{ + addMergedRegion(sheet, rowNowIndex+1, rowNowIndex+1, j, j); + cell.setCellStyle(style2); + String value_value = Util.null2String(obj1.get(j)); + cell.setCellValue(value_value); //设置单元格的值 + } + } + i = i +2; + } + } + } else { + for (int i = 0; dataList != null && i < dataList.size(); i++) { + List obj = (List) dataList.get(i);//遍历每个对象 + Row row = sheet.createRow(i + rowIdx + 1);//创建所需的行数 + + for (int j = 0; j < obj.size(); j++) { + Cell cell = null; //设置单元格的数据类型 + cell = row.createCell(j, CellType.STRING); + cell.setCellValue(Util.null2String(obj.get(j))); //设置单元格的值 + cell.setCellStyle(cellStyle); //设置单元格样式 + } + } + } + +// int columnNum = this.getColumnLength(titleList); +// //让列宽随着导出的列长自动适应 +// for (int colNum = 0; colNum < columnNum; colNum++) { +// int columnWidth = sheet.getColumnWidth(colNum) / 256; +// for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) { +// HSSFRow currentRow; +// //当前行未被使用过 +// if (sheet.getRow(rowNum) == null) { +// currentRow = sheet.createRow(rowNum); +// } else { +// currentRow = sheet.getRow(rowNum); +// } +// if (currentRow.getCell(colNum) != null) { +// //取得当前的单元格 +// HSSFCell currentCell = currentRow.getCell(colNum); +// //如果当前单元格类型为字符串 +// if (currentCell.getCellTypeEnum() == CellType.STRING) { +// int length = currentCell.getStringCellValue().getBytes().length; +// if (columnWidth < length) { +// //将单元格里面值大小作为列宽度 +// columnWidth = length; +// } +// } +// } +// } +// //再根据不同列单独做下处理 +// if (colNum == 0) { +// sheet.setColumnWidth(colNum, (columnWidth - 2) * 256); +// } else { +// sheet.setColumnWidth(colNum, (columnWidth + 4) * 256); +// } +// } + for (int i = 0; constraintList != null && i < constraintList.size(); i++) { + Map constraint = constraintList.get(i); + int firstRow = Util.getIntValue(Util.null2String(constraint.get("firstRow")), 0); + int endRow = Util.getIntValue(Util.null2String(constraint.get("endRow")), 0); + int firstCol = Util.getIntValue(Util.null2String(constraint.get("firstCol")), 0); + int endCol = Util.getIntValue(Util.null2String(constraint.get("endCol")), 0); + //设置下拉框数据 + String[] datas = (String[]) constraint.get("constraintDatas"); + String hiddenSheetName = "constraintDataSheet"+i; + Sheet hiddenSheet = workbook.createSheet(hiddenSheetName); + workbook.setSheetHidden(workbook.getSheetIndex(hiddenSheet), true); + for (int j = 0; j< datas.length; j++) { + hiddenSheet.createRow(j).createCell(0).setCellValue(datas[j]); + } + DataValidationHelper helper = sheet.getDataValidationHelper(); + String formulaId = hiddenSheetName + "!$A$1:$A$" + datas.length; + DataValidationConstraint dataValidationConstraint = helper.createFormulaListConstraint(formulaId); + CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); + DataValidation dataValidation = helper.createValidation(dataValidationConstraint, cellRangeAddressList); + //处理Excel兼容性问题 + if (dataValidation instanceof DataValidation) { + dataValidation.setSuppressDropDownArrow(true); + dataValidation.setShowErrorBox(true); + } else { + dataValidation.setSuppressDropDownArrow(false); + } + sheet.addValidationData(dataValidation); + } + + +// for (int i = 0; constraintList != null && i < constraintList.size(); i++) { +// Map constraint = constraintList.get(i); +// int firstRow = Util.getIntValue(Util.null2String(constraint.get("firstRow")), 0); +// int endRow = Util.getIntValue(Util.null2String(constraint.get("endRow")), 0); +// int firstCol = Util.getIntValue(Util.null2String(constraint.get("firstCol")), 0); +// int endCol = Util.getIntValue(Util.null2String(constraint.get("endCol")), 0); +// +// //设置下拉框数据 +// String[] datas = (String[]) constraint.get("constraintDatas"); +// DataValidationHelper helper = sheet.getDataValidationHelper(); +// DataValidationConstraint dataValidationConstraint = helper.createExplicitListConstraint(datas); +// CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); +// DataValidation dataValidation = helper.createValidation(dataValidationConstraint, cellRangeAddressList); +// //处理Excel兼容性问题 +// if (dataValidation instanceof DataValidation) { +// dataValidation.setSuppressDropDownArrow(true); +// dataValidation.setShowErrorBox(true); +// } else { +// dataValidation.setSuppressDropDownArrow(false); +// } +// sheet.addValidationData(dataValidation); +// } + } + + if (workbook != null) { + if (createFile.equals("1")) { + String filePath = GCONST.getRootPath() + "/hrm/kq/tmpFile/"; + File file = new File(filePath); + if (!file.exists()) { + file.mkdirs(); + } + + fileName = fileName +"("+DateUtil.getNowDateTimeStr()+")"; + String url = filePath + fileName + ".xlsx"; + String realUrl = "/hrm/kq/tmpFile/" + fileName + ".xlsx"; + FileOutputStream fOut = new FileOutputStream(url); + workbook.write(fOut); + fOut.flush(); + fOut.close(); + returnMap.put("url", realUrl); + } else { + response.reset(); + response.setContentType("application/vnd.ms-excel;charset=utf-8"); + response.setCharacterEncoding("utf-8"); + String header = request.getHeader("User-Agent").toUpperCase(); + if (header.contains("MSIE") || header.contains("TRIDENT") || header.contains("EDGE")) { + fileName = URLEncoder.encode(fileName, "utf-8"); + fileName = fileName.replace("+", "%20"); //IE下载文件名空格变+号问题 + } else { + fileName = new String(fileName.getBytes("utf-8"), "ISO_8859_1"); + } + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + response.setContentType("application/msexcel"); + response.setContentType("application/x-msdownload"); + OutputStream responseOutput = response.getOutputStream(); + workbook.write(responseOutput); + responseOutput.flush(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + return returnMap; + } + + /* + * 列头单元格样式 + */ + private CellStyle getMemoStyle(SXSSFWorkbook workbook) { + // 设置字体 + Font font = workbook.createFont(); + //设置字体大小 + font.setFontHeightInPoints((short) 10); + //字体加粗 + font.setBold(true); + //设置字体名字 + font.setFontName("宋体"); + //设置样式; + CellStyle style = workbook.createCellStyle(); + //设置底边框; + style.setBorderBottom(BorderStyle.THIN); + //设置底边框颜色; + style.setBottomBorderColor(IndexedColors.BLACK.index); + //设置左边框; + style.setBorderLeft(BorderStyle.THIN); + //设置左边框颜色; + style.setLeftBorderColor(IndexedColors.BLACK.index); + //设置右边框; + style.setBorderRight(BorderStyle.THIN); + //设置右边框颜色; + style.setRightBorderColor(IndexedColors.BLACK.index); + //设置顶边框; + style.setBorderTop(BorderStyle.THIN); + //设置顶边框颜色; + style.setTopBorderColor(IndexedColors.BLACK.index); + //在样式用应用设置的字体; + style.setFont(font); + //设置自动换行; + style.setWrapText(false); + //设置水平对齐的样式为居中对齐; + style.setAlignment(HorizontalAlignment.LEFT); + //设置垂直对齐的样式为居中对齐; + style.setVerticalAlignment(VerticalAlignment.CENTER); + + return style; + + } + + /* + * 列头单元格样式 + */ + private CellStyle getTitleStyle(SXSSFWorkbook workbook) { + // 设置字体 + Font font = workbook.createFont(); + //设置字体大小 + font.setFontHeightInPoints((short) 14); + //字体加粗 + font.setBold(true); + //设置字体名字 + font.setFontName("宋体"); + //设置样式; + CellStyle style = workbook.createCellStyle(); + //设置底边框; + style.setBorderBottom(BorderStyle.THIN); + //设置底边框颜色; + style.setBottomBorderColor(IndexedColors.BLACK.index); + //设置左边框; + style.setBorderLeft(BorderStyle.THIN); + //设置左边框颜色; + style.setLeftBorderColor(IndexedColors.BLACK.index); + //设置右边框; + style.setBorderRight(BorderStyle.THIN); + //设置右边框颜色; + style.setRightBorderColor(IndexedColors.BLACK.index); + //设置顶边框; + style.setBorderTop(BorderStyle.THIN); + //设置顶边框颜色; + style.setTopBorderColor(IndexedColors.BLACK.index); + //在样式用应用设置的字体; + style.setFont(font); + //设置自动换行; + style.setWrapText(false); + //设置水平对齐的样式为居中对齐; + style.setAlignment(HorizontalAlignment.CENTER); + //设置垂直对齐的样式为居中对齐; + style.setVerticalAlignment(VerticalAlignment.CENTER); + return style; + + } + + /* + * 列头单元格样式 + */ + private CellStyle getColumnTopStyle(SXSSFWorkbook workbook) { + // 设置字体 + Font font = workbook.createFont(); + //设置字体大小 + font.setFontHeightInPoints((short) 11); + //字体加粗 + font.setBold(true); + //设置字体名字 + font.setFontName("宋体"); + //设置样式; + CellStyle style = workbook.createCellStyle(); + //设置底边框; + style.setBorderBottom(BorderStyle.THIN); + //设置底边框颜色; + style.setBottomBorderColor(IndexedColors.BLACK.index); + //设置左边框; + style.setBorderLeft(BorderStyle.THIN); + //设置左边框颜色; + style.setLeftBorderColor(IndexedColors.BLACK.index); + //设置右边框; + style.setBorderRight(BorderStyle.THIN); + //设置右边框颜色; + style.setRightBorderColor(IndexedColors.BLACK.index); + //设置顶边框; + style.setBorderTop(BorderStyle.THIN); + //设置顶边框颜色; + style.setTopBorderColor(IndexedColors.BLACK.index); + //在样式用应用设置的字体; + style.setFont(font); + //设置自动换行; + style.setWrapText(true); + //设置水平对齐的样式为居中对齐; + style.setAlignment(HorizontalAlignment.CENTER); + //设置垂直对齐的样式为居中对齐; + style.setVerticalAlignment(VerticalAlignment.CENTER); + + return style; + + } + + /* + * 列数据信息单元格样式 + */ + private CellStyle getCellStyle(SXSSFWorkbook workbook,boolean isWrap) { + // 设置字体 + Font font = workbook.createFont(); + //设置字体大小 + //font.setFontHeightInPoints((short)10); + //字体加粗 + //font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); + //设置字体名字 + font.setFontName("宋体"); + //设置样式; + CellStyle style = workbook.createCellStyle(); + //设置底边框; + style.setBorderBottom(BorderStyle.THIN); + //设置底边框颜色; + style.setBottomBorderColor(IndexedColors.BLACK.index); + //设置左边框; + style.setBorderLeft(BorderStyle.THIN); + //设置左边框颜色; + style.setLeftBorderColor(IndexedColors.BLACK.index); + //设置右边框; + style.setBorderRight(BorderStyle.THIN); + //设置右边框颜色; + style.setRightBorderColor(IndexedColors.BLACK.index); + //设置顶边框; + style.setBorderTop(BorderStyle.THIN); + //设置顶边框颜色; + style.setTopBorderColor(IndexedColors.BLACK.index); + //在样式用应用设置的字体; + style.setFont(font); + //设置自动换行; +// style.setWrapText(false); + if(isWrap){ + style.setWrapText(true); + }else{ + style.setWrapText(false); + } + //设置水平对齐的样式为居中对齐; + style.setAlignment(HorizontalAlignment.LEFT); + //设置垂直对齐的样式为居中对齐; + style.setVerticalAlignment(VerticalAlignment.CENTER); + + return style; + + } + + private CellStyle getCellStyle(SXSSFWorkbook workbook) { + // 设置字体 + Font font = workbook.createFont(); + //设置字体大小 + //font.setFontHeightInPoints((short)10); + //字体加粗 + //font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); + //设置字体名字 + font.setFontName("宋体"); + //设置样式; + CellStyle style = workbook.createCellStyle(); + //设置底边框; + style.setBorderBottom(BorderStyle.THIN); + //设置底边框颜色; + style.setBottomBorderColor(IndexedColors.BLACK.index); + //设置左边框; + style.setBorderLeft(BorderStyle.THIN); + //设置左边框颜色; + style.setLeftBorderColor(IndexedColors.BLACK.index); + //设置右边框; + style.setBorderRight(BorderStyle.THIN); + //设置右边框颜色; + style.setRightBorderColor(IndexedColors.BLACK.index); + //设置顶边框; + style.setBorderTop(BorderStyle.THIN); + //设置顶边框颜色; + style.setTopBorderColor(IndexedColors.BLACK.index); + //在样式用应用设置的字体; + style.setFont(font); + //设置自动换行; + style.setWrapText(false); + //设置水平对齐的样式为居中对齐; + style.setAlignment(HorizontalAlignment.LEFT); + //设置垂直对齐的样式为居中对齐; + style.setVerticalAlignment(VerticalAlignment.CENTER); + + return style; + + } + + public static void main(String[] args) { + String groupid = "1"; + String filename = "c://33e2a90d-3347-490c-afff-21de0ef3e3af.xlsx"; + int startRow = 3; + RecordSet rs = new RecordSet(); + String sql = ""; + try { + //必要的权限判断 + List lsParams = null; + List params = null; + + Workbook workbook = WorkbookFactory.create(new FileInputStream(filename)); + for (int idx = 0; idx < workbook.getNumberOfSheets(); idx++) { + Sheet sheet = workbook.getSheetAt(idx); + Row row = null; + Cell cell = null; + lsParams = new ArrayList(); + for (int i = startRow; startRow <= sheet.getLastRowNum() && i <= sheet.getLastRowNum(); i++) { + row = sheet.getRow(i); + if (row == null) { + continue; + } + params = new ArrayList(); + for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) { + cell = row.getCell((short) cellIndex); + if (cell == null) continue; + params.add(getCellValue(cell).trim()); + } + params.add(groupid); + if (Util.null2String(params.get(0)).length() > 0) { + lsParams.add(params); + } + } + if (idx == 0) { + sql = "insert into kq_loaction (loactionname,longitude,latitude,address,groupid) values (?,?,?,?,?) "; + } else { + sql = "insert into kq_wifi (wifiname,mac,groupid) values (?,?,?) "; + } + rs.executeBatchSql(sql, lsParams); + } + } catch (Exception e) { + new BaseBean().writeLog(e); + } + } + + public int initDynamicTitle(Sheet sheet, List columns, CellStyle columnTopStyle, int rowIdx) { + int cur_rowIndx = rowIdx+1; + //title 总行数 + int title_rows = cur_rowIndx+getRowNums(columns)-1; + createHeaderRow(sheet, cur_rowIndx, 0,columns,columnTopStyle,title_rows); + return title_rows; + } + + /** + * 创建表头 + */ + private int createHeaderRow(Sheet sheet, int index, int cellIndex, + List columnName, CellStyle columnTopStyle, int title_rows) { + Row row = sheet.getRow(index) == null ? sheet.createRow(index) : sheet.getRow(index); + int rows = getRowNums(columnName); + for (int i = 0, exportFieldTitleSize = columnName.size(); i < exportFieldTitleSize; i++) { + Map column = (Map) columnName.get(i); + String title = Util.null2String(column.get("title")); + createStringCell(row, cellIndex, title, columnTopStyle); + if (column.get("children") != null) { + List childchildColumns = (List) column.get("children"); + // 保持原来的 + int tempCellIndex = cellIndex; + cellIndex = createHeaderRow(sheet, rows == 1 ? index : index + 1, cellIndex, childchildColumns,columnTopStyle, + title_rows); + if (childchildColumns.size() > 1) { + addMergedRegion(sheet, index, index, tempCellIndex, cellIndex - 1); + } + cellIndex--; + }else{ + addMergedRegion(sheet, index, title_rows, cellIndex, cellIndex); + } + cellIndex++; + } + return cellIndex; + } + + /** + * 合并单元格 + * @param sheet + * @param firstRow + * @param lastRow + * @param firstCol + * @param lastCol + */ + public void addMergedRegion(Sheet sheet, int firstRow, int lastRow, int firstCol, int lastCol) { + try { + if(firstRow == lastRow && firstCol == lastCol){ + return ; + } + CellRangeAddress region = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol); + RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet); + sheet.addMergedRegionUnsafe(region); + } catch (Exception e) { + e.printStackTrace(); + } + } + /** + * 创建文本类型的Cell + */ + public void createStringCell(Row row, int cellIndex, String title, CellStyle columnTopStyle) { + Cell cellRowName = row.createCell(cellIndex); //创建列头对应个数的单元格 + cellRowName.setCellType(CellType.STRING); //设置列头单元格的数据类型 + cellRowName.setCellValue(title); //设置列头单元格的值 + cellRowName.setCellStyle(columnTopStyle); //设置列头单元格样式 + } + + public int initTitle(Sheet sheet, List columns, CellStyle columnTopStyle, int rowIdx) { + List lsMergedRegion = new ArrayList<>(); + Map mergedRegion = null; + int firstTitleRow = rowIdx + 1; + int lastTitleRow = rowIdx + 2; + Row rowRowName = sheet.createRow(++rowIdx); // 在索引2的位置创建行(最顶端的行开始的第二行) + Row childRowRowName = null; + // 定义所需列数 + Map column = null; + List childColumn = null; + int colIdx = 0; + for (int i = 0; i < columns.size(); i++) { + column = (Map) columns.get(i); + childColumn = (List) column.get("children"); + Cell cellRowName = rowRowName.createCell(colIdx++); //创建列头对应个数的单元格 + cellRowName.setCellType(CellType.STRING); //设置列头单元格的数据类型 + cellRowName.setCellValue(Util.null2String(column.get("title"))); //设置列头单元格的值 + cellRowName.setCellStyle(columnTopStyle); //设置列头单元格样式 + + if (Util.getIntValue(Util.null2String(column.get("rowSpan"))) == 2) { + if (childRowRowName == null) { + childRowRowName = sheet.createRow(++rowIdx); + } + mergedRegion = new HashMap(); + mergedRegion.put("startRow", firstTitleRow); + mergedRegion.put("overRow", lastTitleRow); + mergedRegion.put("startCol", colIdx - 1); + mergedRegion.put("overCol", colIdx - 1); + lsMergedRegion.add(mergedRegion); + } + + if (childColumn != null) { + colIdx--; + mergedRegion = new HashMap(); + mergedRegion.put("startRow", firstTitleRow); + mergedRegion.put("overRow", firstTitleRow); + mergedRegion.put("startCol", colIdx); + for (int j = 0; j < childColumn.size(); j++) { + column = (Map) childColumn.get(j); + cellRowName = childRowRowName.createCell(colIdx++); //创建列头对应个数的单元格 + cellRowName.setCellType(CellType.STRING); //设置列头单元格的数据类型 + cellRowName.setCellValue(Util.null2String(column.get("title"))); //设置列头单元格的值 + cellRowName.setCellStyle(columnTopStyle); + } + mergedRegion.put("overCol", colIdx - 1); + if (childColumn.size() > 1) { + lsMergedRegion.add(mergedRegion); + } + } + } + + for (int i = 0; i < lsMergedRegion.size(); i++) { + mergedRegion = (Map) lsMergedRegion.get(i); + Integer startrow = Util.getIntValue(Util.null2String(mergedRegion.get("startRow"))); + Integer overrow = Util.getIntValue(Util.null2String(mergedRegion.get("overRow"))); + Integer startcol = Util.getIntValue(Util.null2String(mergedRegion.get("startCol"))); + Integer overcol = Util.getIntValue(Util.null2String(mergedRegion.get("overCol"))); + CellRangeAddress region = new CellRangeAddress(startrow, overrow, startcol, overcol); + RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet); + RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet); + sheet.addMergedRegionUnsafe(region); + } + return rowIdx; + } + + + + /** + * 获取具体总共有多少列 + * @param columns + * @return + */ + private int getColLength(List columns) { + int length = -1;// 从0开始计算单元格的 + for(int i =0 ; i < columns.size() ; i++){ + Map column = (Map) columns.get(i); + if (column.get("children") != null) { + List childchildColumns = (List) column.get("children"); + length += getColLength(childchildColumns) + 1; + } else { + length++; + } + } + return length; + } + + /** + * 获取具体总共有多少行 + */ + public int getRowNums(List columns) { + int cnt = 1; + for (int i = 0; i < columns.size(); i++) { + Map column = (Map) columns.get(i); + if (column.get("children") != null) { + List childchildColumns = (List) column.get("children"); + int tmpcnt = 1+getRowNums(childchildColumns); + if(tmpcnt > cnt){ + cnt = tmpcnt; + } + } + } + if(cnt > 1){ + return cnt; + }else{ + return 1; + } + } + + public int getColumnLength(List columns) { + int columnLength = 0; + Map column = null; + for (int i = 0; i < columns.size(); i++) { + column = (Map) columns.get(i); + if (column.get("colSpan") != null) { + columnLength += Util.getIntValue(Util.null2String(column.get("colSpan"))); + } else { + columnLength++; + } + } + return columnLength; + } + + /** + * /** + * 获取excel单元格值 + * + * @param cell 要读取的单元格对象 + * @return + */ + public static String getCellValue(Cell cell) { + String cellValue = ""; + if (cell == null) + return ""; + switch (cell.getCellType()) { + case BOOLEAN: // 得到Boolean对象的方法 + cellValue = String.valueOf(cell.getBooleanCellValue()); + break; + case NUMERIC: + if (org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(cell)) {// 先看是否是日期格式 + SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd"); + cellValue = String.valueOf(sft.format(cell.getDateCellValue())); // 读取日期格式 + } else { + cellValue = String.valueOf(new Double(cell.getNumericCellValue())); // 读取数字 + if (cellValue.endsWith(".0")) + cellValue = cellValue.substring(0, cellValue.indexOf(".")); + } + break; + case FORMULA: // 读取公式 + cellValue = cell.getCellFormula(); + break; + case STRING: // 读取String + cellValue = cell.getStringCellValue(); + break; + } + + return cellValue; + } +} diff --git a/src/com/engine/kq/util/ImportProcessUtil.java b/src/com/engine/kq/util/ImportProcessUtil.java new file mode 100644 index 0000000..ee8fd0a --- /dev/null +++ b/src/com/engine/kq/util/ImportProcessUtil.java @@ -0,0 +1,885 @@ +package com.engine.kq.util; + +import com.engine.common.util.ServiceUtil; +import com.engine.kq.bean.*; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQLeaveRulesDetailComInfo; +import com.engine.kq.service.ImportLogService; +import com.engine.kq.service.impl.ImportLogServiceImpl; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.*; +import weaver.conn.RecordSet; +import weaver.file.ImageFileManager; +import weaver.general.*; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.common.Tools; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 节假日设置--Excel导入 + */ +public class ImportProcessUtil extends BaseBean { + + /** + * 导入类型 + */ + private String importtype; + + /** + * 文件名称 + */ + private String filename; + /** + * excel页签 + */ + private Sheet sheet; + /** + * 存储Excel的数据 + */ + private List lsImportSourceMap = new ArrayList(); + /** + * 存储报错信息 + */ + private List errorInfo = new ArrayList(); + /** + * 存储参数类型名称 + */ + private Map parameterTypes = new HashMap(); + /** + * 字段类型 + */ + private Map fieldTypes = new HashMap(); + /** + * 类名 + */ + private Map mapImportSource = new HashMap(); + /** + * 导入类型名称 + */ + private Map mapImportSourceName = new HashMap(); + /** + * excel文件中对应的字段别名 + */ + private Map mapImportSourceField = new HashMap(); + /** + * excel文件中对应的字段名称 + */ + private Map mapImportSourceFieldName = new HashMap(); + /** + * 多语言--中文 + */ + private int userlanguage = 7; + /** + * 字段名 + */ + private String voFields[]; + /** + * 类 + */ + private Class importSourceClass; + /** + * 字段标识 + */ + private String keyField = ""; + /** + * 操作人 + */ + private String creater = ""; + + private User user; + /** + * 导入记录的标识 + */ + private int pId = 0; + + /** + * 仅用于假期余额导入 + */ + private String leaveRulesId = "";//假期规则的ID + + /** + * 仅用于假期余额导入 + */ + private String belongYear = "";//所属年份 + + public ImportProcessUtil() { + mapImportSource.put("holidaySet", new String[]{KQHolidaySet.class.getName()}); + mapImportSource.put("kqScheduleCode", new String[]{KQScheduleCode.class.getName()}); + mapImportSourceName.put("holidaySet", ""+ SystemEnv.getHtmlLabelName(388727, ThreadVarLanguage.getLang())+""); + mapImportSourceName.put("kqScheduleCode", ""+ SystemEnv.getHtmlLabelName(511419, ThreadVarLanguage.getLang())+""); + mapImportSourceField.put("holidaySet", new String[]{"groupName,holidayDate,changeTypeName,holidayDesc,relatedDayName"}); + mapImportSourceField.put("kqScheduleCode", new String[]{"lastname,workcode,devicecode,schedulecode"}); + mapImportSourceFieldName.put("holidaySet", new String[]{""+ SystemEnv.getHtmlLabelName(388700, ThreadVarLanguage.getLang())+"["+ SystemEnv.getHtmlLabelName(18019, ThreadVarLanguage.getLang())+"],"+ SystemEnv.getHtmlLabelName(31131, ThreadVarLanguage.getLang())+"["+ SystemEnv.getHtmlLabelName(18019, ThreadVarLanguage.getLang())+"],"+ SystemEnv.getHtmlLabelName(22256, ThreadVarLanguage.getLang())+"["+ SystemEnv.getHtmlLabelName(18019, ThreadVarLanguage.getLang())+"],"+ SystemEnv.getHtmlLabelName(85, ThreadVarLanguage.getLang())+","+ SystemEnv.getHtmlLabelName(16754, ThreadVarLanguage.getLang())+""}); + mapImportSourceFieldName.put("kqScheduleCode", new String[]{""+ SystemEnv.getHtmlLabelName(413, ThreadVarLanguage.getLang())+","+ SystemEnv.getHtmlLabelName(714, ThreadVarLanguage.getLang())+","+ SystemEnv.getHtmlLabelName(10005347, ThreadVarLanguage.getLang())+","+ SystemEnv.getHtmlLabelName(10005348, ThreadVarLanguage.getLang())+"["+ SystemEnv.getHtmlLabelName(18019, ThreadVarLanguage.getLang())+"]"}); + } + + public List importXls(Map params, User user, HttpServletRequest request) { + ImportLogService importLogService = (ImportLogServiceImpl) ServiceUtil.getService(ImportLogServiceImpl.class, user); + try { + this.user = user; + this.filename = (String) params.get("excelfile"); + this.importtype = Util.null2String(params.get("importType")); + this.keyField = Util.null2String(params.get("keyField")); + this.creater = "" + user.getUID(); + this.userlanguage = user.getLanguage(); + + /*根据假期规则的ID加载相关模板数据*/ + if (this.importtype.equals("balanceOfLeave")) { + String ruleId = Util.null2String(params.get("ruleId"));//假期规则的ID + String searchYearSelect = Util.null2String(params.get("searchYearSelect"));//日期控件的选择值 + String searchYear = Util.null2String(params.get("searchYear"));//年份 + if (searchYearSelect.equals("5") || searchYearSelect.equals("8")) { + searchYear = TimeUtil.getDateByOption(searchYearSelect, "0").substring(0, 4); + } + this.leaveRulesId = ruleId; + this.belongYear = searchYear; + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + String leaveName = Util.formatMultiLang(rulesComInfo.getLeaveName(this.leaveRulesId), "" + this.userlanguage);//假期名称 + String UnitName = rulesComInfo.getUnitNameNew(this.leaveRulesId, user.getLanguage());//最小请假单位的单位名称,天/小时 + + /*判断该假期类型是否属于 法定年假+福利年假 的类型(暂不支持一个请假类型下既存在"按入职时长+工龄自动发放"的余额发放方式,又存在其他发放方式)*/ + boolean isMixMode = KQLeaveRulesBiz.isMixMode(this.leaveRulesId); + //判断该假期类型是否属于 调休 + boolean isTiaoXiu = KQLeaveRulesBiz.isTiaoXiu(this.leaveRulesId); + // 明细 育儿假 + boolean leaveOfParental = KQLeaveRulesBiz.isLeaveOfParentalNum(this.leaveRulesId); + + String[] mapImportSourceFieldNameArr = null; + String[] mapImportSourceFieldArr = null; + if (isMixMode) { + mapImportSourceFieldNameArr = new String[]{"ID("+ SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang())+"),"+ SystemEnv.getHtmlLabelName(714, ThreadVarLanguage.getLang())+"("+ SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang())+"),"+ SystemEnv.getHtmlLabelName(413, ThreadVarLanguage.getLang())+"("+ SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang())+"),"+ SystemEnv.getHtmlLabelName(500228, ThreadVarLanguage.getLang())+"" + UnitName + ","+ SystemEnv.getHtmlLabelName(389745, ThreadVarLanguage.getLang())+"" + UnitName + ","+ SystemEnv.getHtmlLabelName(389743, ThreadVarLanguage.getLang())+"" + UnitName + ","+ SystemEnv.getHtmlLabelName(500229, ThreadVarLanguage.getLang())+"" + UnitName + ","+ SystemEnv.getHtmlLabelName(389746, ThreadVarLanguage.getLang())+"" + UnitName + ","+ SystemEnv.getHtmlLabelName(389744, ThreadVarLanguage.getLang())+"" + UnitName}; + mapImportSourceFieldArr = new String[]{"resourceId,workcode,lastName,baseAmount,extraAmount,usedAmount,baseAmount2,extraAmount2,usedAmount2"}; + } else if (isTiaoXiu) { + mapImportSourceFieldNameArr = new String[]{"ID("+ SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang())+"),"+ SystemEnv.getHtmlLabelName(714, ThreadVarLanguage.getLang())+"("+ SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang())+"),"+ SystemEnv.getHtmlLabelName(413, ThreadVarLanguage.getLang())+"("+ SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang())+"),"+ SystemEnv.getHtmlLabelName(15933, ThreadVarLanguage.getLang())+","+ SystemEnv.getHtmlLabelName(887, ThreadVarLanguage.getLang())+","+ SystemEnv.getHtmlLabelName(130286, ThreadVarLanguage.getLang())+","+ SystemEnv.getHtmlLabelName(26642, ThreadVarLanguage.getLang())+","+ SystemEnv.getHtmlLabelName(508169, ThreadVarLanguage.getLang())+","+ SystemEnv.getHtmlLabelName(19547, ThreadVarLanguage.getLang())+""}; + mapImportSourceFieldArr = new String[]{"resourceId,workcode,lastName,belongYear,belongMonth,totalAmount,usedAmount,effectiveDate,expirationDate"}; + } else if (leaveOfParental){ + mapImportSourceFieldNameArr = new String[]{"ID("+ SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang())+"),"+ SystemEnv.getHtmlLabelName(714, ThreadVarLanguage.getLang())+"("+ SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang())+"),"+ SystemEnv.getHtmlLabelName(413, ThreadVarLanguage.getLang())+"("+ SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang())+"),"+ SystemEnv.getHtmlLabelName(15933, ThreadVarLanguage.getLang())+"," + leaveName + SystemEnv.getHtmlLabelName(17638, ThreadVarLanguage.getLang())+ UnitName + ","+ SystemEnv.getHtmlLabelName(130286, ThreadVarLanguage.getLang())+ leaveName + UnitName + ","+ SystemEnv.getHtmlLabelName(26642, ThreadVarLanguage.getLang())+ leaveName + UnitName+","+ SystemEnv.getHtmlLabelName(19548, ThreadVarLanguage.getLang())+""}; + mapImportSourceFieldArr = new String[]{"resourceId,workcode,lastName,belongYear,baseAmount,extraAmount,usedAmount,effectiveDate"}; + } else { + mapImportSourceFieldNameArr = new String[]{"ID("+ SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang())+"),"+ SystemEnv.getHtmlLabelName(714, ThreadVarLanguage.getLang())+"("+ SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang())+"),"+ SystemEnv.getHtmlLabelName(413, ThreadVarLanguage.getLang())+"("+ SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang())+")," + leaveName + ""+ SystemEnv.getHtmlLabelName(17638, ThreadVarLanguage.getLang())+"" + UnitName + ","+ SystemEnv.getHtmlLabelName(130286, ThreadVarLanguage.getLang())+"" + leaveName + UnitName + ","+ SystemEnv.getHtmlLabelName(26642, ThreadVarLanguage.getLang())+"" + leaveName + UnitName}; + mapImportSourceFieldArr = new String[]{"resourceId,workcode,lastName,baseAmount,extraAmount,usedAmount"}; + } + if (isTiaoXiu) { + mapImportSource.put("balanceOfLeave", new String[]{KQBalanceDetail.class.getName()}); + mapImportSourceName.put("balanceOfLeave", ""+ SystemEnv.getHtmlLabelName(10005350, ThreadVarLanguage.getLang())+""); + mapImportSourceField.put("balanceOfLeave", mapImportSourceFieldArr); + mapImportSourceFieldName.put("balanceOfLeave", mapImportSourceFieldNameArr); + }else if (leaveOfParental){ + mapImportSource.put("balanceOfLeave", new String[]{KQBalanceDetail2.class.getName()}); + mapImportSourceName.put("balanceOfLeave", ""+ SystemEnv.getHtmlLabelName(547742, ThreadVarLanguage.getLang())+""); + mapImportSourceField.put("balanceOfLeave", mapImportSourceFieldArr); + mapImportSourceFieldName.put("balanceOfLeave", mapImportSourceFieldNameArr); + } else { + mapImportSource.put("balanceOfLeave", new String[]{KQBalanceOfLeave.class.getName()}); + mapImportSourceName.put("balanceOfLeave", ""+ SystemEnv.getHtmlLabelName(389989, ThreadVarLanguage.getLang())+""); + mapImportSourceField.put("balanceOfLeave", mapImportSourceFieldArr); + mapImportSourceFieldName.put("balanceOfLeave", mapImportSourceFieldNameArr); + } + } + + ImageFileManager manager = new ImageFileManager(); + manager.getImageFileInfoById(Util.getIntValue(this.filename)); + Workbook workbook = WorkbookFactory.create(manager.getInputStream()); + + params.put("operateType", "add"); + Map retmap = importLogService.saveImportLog(params, request, user); + if (Util.null2String(retmap.get("status")).equals("1")) { + this.pId = Util.getIntValue(Util.null2String(retmap.get("pId"))); + String pIdName = "hrm" + this.importtype + "PId"; + request.getSession(true).setAttribute(pIdName, this.pId); + } + + String[] tmpMapImportSource = mapImportSource.get(this.importtype); + int idx = 0; + for (String tmpImportSource : tmpMapImportSource) { + idx++; + this.sheet = workbook.getSheetAt(idx); + importSourceClass = Class.forName(tmpImportSource); + voFields = mapImportSourceField.get(this.importtype)[idx - 1].split(","); + initReflectParam(); + /*校验模板有效性*/ + if (idx == 1) { + String[] importSourceFieldName = mapImportSourceFieldName.get(this.importtype); + String valExcelTempInfo = valExcelTemp(importSourceFieldName[idx - 1]); + if (valExcelTempInfo.length() > 0) { + this.errorInfo.add(valExcelTempInfo); + break; + } + } + + readexcel(); + String importSourceName = ""; + importSourceName = mapImportSourceName.get(this.importtype); + + Object obj = null; + Method method = null; + String flag = ""; + String valErrorInfo = ""; + if (lsImportSourceMap == null || lsImportSourceMap.size() == 0) { + this.errorInfo.add("【" + importSourceName + "】" + SystemEnv.getHtmlLabelName(34195, userlanguage) + "!"); + } + for (int i = 0; lsImportSourceMap != null && i < lsImportSourceMap.size(); i++) { + obj = lsImportSourceMap.get(i); + + /*设置关联的假期规则ID和所属年份*/ + if (this.importtype.equals("balanceOfLeave")) { + method = importSourceClass.getMethod("setLeaveRulesId", String.class); + method.invoke(obj, this.leaveRulesId); + + method = importSourceClass.getMethod("setBelongYear", String.class); + method.invoke(obj, this.belongYear); + + method = importSourceClass.getMethod("setOperator", String.class); + method.invoke(obj, "" + user.getUID()); + } else if (this.importtype.equals("kqScheduleCode")) { + method = importSourceClass.getMethod("setKeyField", String.class); + method.invoke(obj, "" + keyField); + } + + method = importSourceClass.getMethod("setUserLanguage", String.class); + method.invoke(obj, "" + userlanguage); + + method = importSourceClass.getMethod("valExcelData"); + try { + valErrorInfo = (String) method.invoke(obj); + } catch (Exception e) { + //验证出错返回错误信息 + params = new HashMap(); + params.put("pId", this.pId); + params.put("lineNum", (i + 1)); + params.put("relatedName", this.getRelatedName(obj)); + params.put("msg", importSourceName + ""+ SystemEnv.getHtmlLabelName(15323, ThreadVarLanguage.getLang())+"" + (i + 1) + ""+ SystemEnv.getHtmlLabelName(10005351, ThreadVarLanguage.getLang())+""); + params.put("status", "0"); + importLogService.saveImportDeitalLog(params, user); + continue; + } + if (valErrorInfo.length() == 0) { + method = importSourceClass.getMethod("save"); + flag = (String) method.invoke(obj); + params = new HashMap(); + params.put("pId", this.pId); + params.put("lineNum", (i + 1)); + params.put("relatedName", this.getRelatedName(obj)); + String msg = importSourceName + ""+ SystemEnv.getHtmlLabelName(15323, ThreadVarLanguage.getLang())+"" + (i + 1) + ""+ SystemEnv.getHtmlLabelName(10005352, ThreadVarLanguage.getLang())+"" + this.getRelatedName(obj); + params.put("msg", flag.equals("true") ? msg + SystemEnv.getHtmlLabelName(25750, ThreadVarLanguage.getLang()) : msg + SystemEnv.getHtmlLabelName(24945, ThreadVarLanguage.getLang())); + params.put("status", flag.equals("true") ? "1" : "0"); + importLogService.saveImportDeitalLog(params, user); + } else { + //验证出错返回错误信息 + params = new HashMap(); + params.put("pId", this.pId); + params.put("lineNum", (i + 1)); + params.put("relatedName", this.getRelatedName(obj)); + params.put("msg", importSourceName + ""+ SystemEnv.getHtmlLabelName(15323, ThreadVarLanguage.getLang())+"" + (i + 1) + ""+ SystemEnv.getHtmlLabelName(10005352, ThreadVarLanguage.getLang())+"" + valErrorInfo); + params.put("status", "0"); + importLogService.saveImportDeitalLog(params, user); + } + } + if (this.importtype.equals("holidaySet")) { + //加载缓存 + method = importSourceClass.getMethod("removeCache"); + if (obj != null) method.invoke(obj); + } + } + params = new HashMap(); + params.put("pId", this.pId); + params.put("status", "over"); + importLogService.saveImportLogStatus(params, user); + } catch (FileNotFoundException e) { + params = new HashMap(); + params.put("pId", this.pId); + params.put("status", "error"); + importLogService.saveImportLogStatus(params, user); + } catch (IOException e) { + this.errorInfo.add(SystemEnv.getHtmlLabelName(83618, userlanguage)); + writeLog(e); + params = new HashMap(); + params.put("pId", this.pId); + params.put("status", "error"); + importLogService.saveImportLogStatus(params, user); + } catch (IndexOutOfBoundsException e) { + this.errorInfo.add(SystemEnv.getHtmlLabelName(125871, userlanguage)); + writeLog(e); + params = new HashMap(); + params.put("pId", this.pId); + params.put("status", "error"); + importLogService.saveImportLogStatus(params, user); + } catch (Exception e) { + writeLog(e); + this.errorInfo.add(SystemEnv.getHtmlLabelName(125871, userlanguage)); + params = new HashMap(); + params.put("pId", this.pId); + params.put("status", "error"); + importLogService.saveImportLogStatus(params, user); + } + return this.errorInfo; + } + + /** + * 校验模板有效性 + * + * @param importSourceFieldName 导入文件名称 + * @return + */ + public String valExcelTemp(String importSourceFieldName) { + String valExcelTempInfo = ""; + Row row = null; + Cell cell = null; + String cellValue = ""; + try { + String[] fieldname = importSourceFieldName.split(","); + row = sheet.getRow(0); + for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) { + cell = row.getCell((short) cellIndex); + if (cell == null) continue; + cellValue = getCellValue(cell).trim(); + if (!fieldname[cellIndex].trim().equals(cellValue)) { + valExcelTempInfo = SystemEnv.getHtmlLabelName(387156, user.getLanguage()); + break; + } + } + } catch (Exception e) { + writeLog(e); + valExcelTempInfo = SystemEnv.getHtmlLabelName(387156, user.getLanguage()) + "1"; + } + + return valExcelTempInfo; + } + + /** + * 获取excel单元格值 + * + * @param cell 要读取的单元格对象 + * @return + */ + public String getCellValue(Cell cell) { + String cellValue = ""; + if (cell == null) + return ""; + switch (cell.getCellType()) { + case BOOLEAN: // 得到Boolean对象的方法 + cellValue = String.valueOf(cell.getBooleanCellValue()); + break; + case NUMERIC: + if (DateUtil.isCellDateFormatted(cell)) {// 先看是否是日期格式 + SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd"); + cellValue = String.valueOf(sft.format(cell.getDateCellValue())); // 读取日期格式 + } else { + cellValue = String.valueOf(new Double(cell.getNumericCellValue())); // 读取数字 + if (cellValue.endsWith(".0")) + cellValue = cellValue.substring(0, cellValue.indexOf(".")); + } + break; + case FORMULA: // 读取公式 + cellValue = cell.getCellFormula(); + break; + case STRING: // 读取String + cellValue = cell.getStringCellValue(); + break; + } + + return cellValue; + } + + /** + * 读excel文件内容 + */ + public void readexcel() { + try { + Row row = null; + Cell cell = null; + String cellValue = null; + int rowNum = 0; // 行号 + int cellNum = 0; // 列号 + int firstRow = 1; + lsImportSourceMap.clear(); + int lastRow = sheet.getLastRowNum(); + for (int i = firstRow; i <= lastRow; i++) { + row = sheet.getRow(i); + if (row == null) { + errorInfo.add(SystemEnv.getHtmlLabelName(15323, userlanguage) + " " + (i + 1) + " " + SystemEnv.getHtmlLabelName(83622, userlanguage)); + continue; + } + rowNum = row.getRowNum(); + + Object obj = importSourceClass.newInstance(); + for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) { + cell = row.getCell((short) cellIndex); + if (cell == null) continue; + cellValue = getCellValue(cell).trim(); + setImportSourceValue(cellIndex, cellValue, obj, null); + } + lsImportSourceMap.add(obj); + } + } catch (Exception e) { + writeLog(e); + } + } + + /** + * 通过反射为对象赋值 + * + * @param cellNum + * @param cellValue + * @param importSourceObj + * @param field + */ + public void setImportSourceValue(int cellNum, String cellValue, Object importSourceObj, String field) { + if (field == null) { + String excelField = voFields[cellNum]; + String methodName = "set" + excelField.substring(0, 1).toUpperCase() + excelField.substring(1); + Method method = (Method) parameterTypes.get(methodName); + try { + String fieldType = (String) fieldTypes.get(excelField); + if (fieldType.equals("java.lang.String")) + method.invoke(importSourceObj, new Object[]{cellValue}); + else if (fieldType.equals("java.lang.Integer") && !cellValue.equals("")) { + method.invoke(importSourceObj, new Object[]{new Integer(Integer.parseInt(cellValue))}); + } else if (fieldType.equals("java.lang.Float") && !cellValue.equals("")) + method.invoke(importSourceObj, new Object[]{new Float(Float.parseFloat(cellValue))}); + else if (fieldType.equals("java.lang.Short") && !cellValue.equals("")) { + method.invoke(importSourceObj, new Object[]{new Short(Short.parseShort(cellValue))}); + } else if (fieldType.equals("double") && !cellValue.equals("")) { + method.invoke(importSourceObj, new Object[]{new Double(Double.parseDouble(cellValue))}); + } + } catch (Exception e) { + writeLog(e); + } + } else { + String methodName = "set" + field.substring(0, 1).toUpperCase() + field.substring(1); + Method method = (Method) parameterTypes.get(methodName); + try { + method.invoke(importSourceObj, new Object[]{cellValue}); + } catch (Exception e) { + writeLog(e); + } + } + } + + /** + * 初始化反射所需要的方法和字段Map,parameterTypes,fieldTypes + */ + public void initReflectParam() { + try { + parameterTypes.clear(); + fieldTypes.clear(); + Method hrmResourceMethods[] = importSourceClass.getDeclaredMethods(); + for (int i = 0; i < hrmResourceMethods.length; i++) { + parameterTypes.put(hrmResourceMethods[i].getName(), hrmResourceMethods[i]); + } + Field importSourceFields[] = importSourceClass.getDeclaredFields(); + for (int i = 0; i < importSourceFields.length; i++) { + Class fieldTypeClass = importSourceFields[i].getType(); + if (fieldTypeClass == Integer.TYPE) { + fieldTypeClass = Integer.class; + } + fieldTypes.put(importSourceFields[i].getName(), fieldTypeClass.getName()); + } + } catch (Exception e) { + writeLog(e); + } + } + + /** + * 获取导入记录中的RelatedName + * + * @param obj + * @return + */ + private String getRelatedName(Object obj) { + String relatedName = ""; + try { + if (this.importtype.equals("holidaySet")) { + Method method = importSourceClass.getMethod("getHolidayDate"); + relatedName = Util.null2String(method.invoke(obj)); + } else if (this.importtype.equals("balanceOfLeave")) { + Method method = importSourceClass.getMethod("getLastName"); + relatedName = Util.null2String(method.invoke(obj)); + } else if (this.importtype.equals("kqScheduleCode")) { + if (this.keyField.equals("lastname")) { + Method method = importSourceClass.getMethod("getLastname"); + relatedName = Util.null2String(method.invoke(obj)); + } else if (this.keyField.equals("workcode")) { + Method method = importSourceClass.getMethod("getWorkcode"); + relatedName = Util.null2String(method.invoke(obj)); + } + Method method = importSourceClass.getMethod("getSchedulecode"); + relatedName += "|" + Util.null2String(method.invoke(obj)); + } + + } catch (Exception e) { + writeLog(e); + } + return relatedName; + } + + + /** + * 生成指定机构的指定的假期类型的指定年份下的员工假期余额的导入模板 + * + * @param leaveRulesId 指定的假期类型ID(对应于数据库kq_leaveRules表的主键ID) + * @param belongYear 指定的所属年份 + * @param organizationType 机构类型:0--总部、1--分部、2--部门 + * @param organizationIds 指定机构的ID(例如当机构类型为分部时,此变量代表分部ID) + */ + public void createTempletOfLeave(String leaveRulesId, String belongYear, String organizationType, String organizationIds,User user) { + HSSFSheet sheet = null; + HSSFRow row = null; + HSSFCell cell = null; + String cellValue = null; + try { + HSSFWorkbook workbook = new HSSFWorkbook(); + sheet = workbook.createSheet();//获取页 + workbook.setSheetName(0, ""+ SystemEnv.getHtmlLabelName(10005353, ThreadVarLanguage.getLang())+""); + + LinkedHashMap sheeetTitle = new LinkedHashMap(); + sheeetTitle.put(""+ SystemEnv.getHtmlLabelName(130664, ThreadVarLanguage.getLang())+"", ""+ SystemEnv.getHtmlLabelName(33803, ThreadVarLanguage.getLang())+""); + sheeetTitle.put("1", ""+ SystemEnv.getHtmlLabelName(389749, ThreadVarLanguage.getLang())+""); + sheeetTitle.put("2", ""+ SystemEnv.getHtmlLabelName(10005354, ThreadVarLanguage.getLang())+"ID"+ SystemEnv.getHtmlLabelName(10005355, ThreadVarLanguage.getLang())+""); + sheeetTitle.put("3", ""+ SystemEnv.getHtmlLabelName(10005356, ThreadVarLanguage.getLang())+"0"); + sheeetTitle.put("4", ""+ SystemEnv.getHtmlLabelName(509971, ThreadVarLanguage.getLang())+""); + sheeetTitle.put("5", ""+ SystemEnv.getHtmlLabelName(10005357, ThreadVarLanguage.getLang())+"yyyy,"+ SystemEnv.getHtmlLabelName(18541, ThreadVarLanguage.getLang())+"2019"); + sheeetTitle.put("6", ""+ SystemEnv.getHtmlLabelName(10005358, ThreadVarLanguage.getLang())+"MM,"+ SystemEnv.getHtmlLabelName(18541, ThreadVarLanguage.getLang())+"08"); + sheeetTitle.put("7", ""+ SystemEnv.getHtmlLabelName(10005359, ThreadVarLanguage.getLang())+"yyyy-MM-dd,"+ SystemEnv.getHtmlLabelName(18541, ThreadVarLanguage.getLang())+"2019-08-01"); + sheeetTitle.put("8", ""+SystemEnv.getHtmlLabelName(546796, ThreadVarLanguage.getLang())); + int rowIndex = 0; + Iterator> iterator = sheeetTitle.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + String key = entry.getKey(); + String value = Util.null2String(entry.getValue()); + row = sheet.createRow(rowIndex++);//获取行 + row.setHeight((short) 400); + + cell = row.createCell((short) 0);//获取单元格 + HSSFCellStyle cellStyle = workbook.createCellStyle(); + HSSFFont font = workbook.createFont(); + font.setFontName("宋体");//设置字体 + font.setFontHeightInPoints((short) 12);//设置字体大小 + cellStyle.setFont(font); + HSSFDataFormat format = workbook.createDataFormat(); + cellStyle.setDataFormat(format.getFormat("@"));//@为文本占位符 + cell.setCellStyle(cellStyle);//设置单元格样式 + cell.setCellType(CellType.STRING);//设置单元格类型 + cell.setCellValue(Util.formatMultiLang(key, "7"));//设置单元格的值 + + cell = row.createCell((short) 1);//获取该行第二列的单元格 + cell.setCellStyle(cellStyle); + cell.setCellType(CellType.STRING); + cell.setCellValue(Util.formatMultiLang(value, "7")); + } + sheet.setColumnWidth((short) 0, (short) (2 * 1000)); + sheet.setColumnWidth((short) 1, (short) (40 * 1000)); + + /**********************************************************************************************************/ + + /*假期类型的相关设置*/ + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + + /*假期类型的名称*/ + String leaveName = Util.formatMultiLang(rulesComInfo.getLeaveName(leaveRulesId), "" + ThreadVarLanguage.getLang()); + + /*最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假*/ + int minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(leaveRulesId), 1); + + /*假期类型的最小请假单位名称*/ + String unitName = rulesComInfo.getUnitNameNew(leaveRulesId, ThreadVarLanguage.getLang());//单位名称,天/小时 + + /**********************************************************************************************************/ + + /*假期规则(每个假期类型下可能存在多个假期规则)的相关设置*/ + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + + /*判断该假期类型是否属于 法定年假+福利年假 的类型(暂不支持一个请假类型下既存在"按入职时长+工龄自动发放"的余额发放方式,又存在其他发放方式)*/ + boolean isMixMode = KQLeaveRulesBiz.isMixMode(leaveRulesId); + //判断该假期类型是否属于 调休 + boolean isTiaoXiu = KQLeaveRulesBiz.isTiaoXiu(leaveRulesId); + // 育儿假 + boolean leaveOfParental = KQLeaveRulesBiz.isLeaveOfParentalNum(leaveRulesId); + /**********************************************************************************************************/ + + sheet = workbook.createSheet(); + workbook.setSheetName(1, ""+ SystemEnv.getHtmlLabelName(10005360, ThreadVarLanguage.getLang())+""); + row = sheet.createRow(0); + row.setHeightInPoints((float) 15); + HSSFCellStyle cellStyle = workbook.createCellStyle(); + HSSFFont font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 12);//设置字体大小 + font.setBold(true); + cellStyle.setFont(font); + HSSFDataFormat format = workbook.createDataFormat(); + cellStyle.setDataFormat(format.getFormat("@"));//@为文本占位符 + cellStyle.setFillForegroundColor((short) 52);// 设置背景色 + cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + cellStyle.setBorderRight(BorderStyle.THIN);//右边框 + cellStyle.setBorderBottom(BorderStyle.THIN);//下边框 + + if (isMixMode) { + String fieldNameStr = "ID(" + SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang()) + ")," + SystemEnv.getHtmlLabelName(714, ThreadVarLanguage.getLang()) + "(" + SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang()) + ")," + SystemEnv.getHtmlLabelName(413, ThreadVarLanguage.getLang()) + "(" + SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang()) + ")," + SystemEnv.getHtmlLabelName(500228, ThreadVarLanguage.getLang()) + "" + unitName + "," + SystemEnv.getHtmlLabelName(389745, ThreadVarLanguage.getLang()) + "" + unitName + "," + SystemEnv.getHtmlLabelName(389743, ThreadVarLanguage.getLang()) + "" + unitName + "," + SystemEnv.getHtmlLabelName(500229, ThreadVarLanguage.getLang()) + "" + unitName + "," + SystemEnv.getHtmlLabelName(389746, ThreadVarLanguage.getLang()) + "" + unitName + "," + SystemEnv.getHtmlLabelName(389744, ThreadVarLanguage.getLang()) + "" + unitName; + String[] fieldNameArr = fieldNameStr.split(","); + for (int i = 0; i < fieldNameArr.length; i++) { + cell = row.createCell((short) i); + cell.setCellStyle(cellStyle); + cell.setCellType(CellType.STRING); + cell.setCellValue(fieldNameArr[i]); + + sheet.setColumnWidth((short) i, (short) (6 * 1000)); + } + } else if (isTiaoXiu) { + String fieldNameStr = "ID(" + SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang()) + ")," + SystemEnv.getHtmlLabelName(714, ThreadVarLanguage.getLang()) + "(" + SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang()) + ")," + SystemEnv.getHtmlLabelName(413, ThreadVarLanguage.getLang()) + "(" + SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang()) + ")," + SystemEnv.getHtmlLabelName(15933, ThreadVarLanguage.getLang()) + "," + SystemEnv.getHtmlLabelName(887, ThreadVarLanguage.getLang()) + "," + SystemEnv.getHtmlLabelName(130286, ThreadVarLanguage.getLang()) + "," + SystemEnv.getHtmlLabelName(26642, ThreadVarLanguage.getLang()) + "," + SystemEnv.getHtmlLabelName(508169, ThreadVarLanguage.getLang()) + "," + SystemEnv.getHtmlLabelName(19547, ThreadVarLanguage.getLang()) + ""; + String[] fieldNameArr = fieldNameStr.split(","); + for (int i = 0; i < fieldNameArr.length; i++) { + cell = row.createCell((short) i); + cell.setCellStyle(cellStyle); + cell.setCellType(CellType.STRING); + cell.setCellValue(fieldNameArr[i]); + + sheet.setColumnWidth((short) i, (short) (6 * 1000)); + } + } else if (leaveOfParental) { //育儿假明细 + String fieldNameStr = "ID(" + SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang()) + ")," + SystemEnv.getHtmlLabelName(714, ThreadVarLanguage.getLang()) + "(" + SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang()) + ")," + SystemEnv.getHtmlLabelName(413, ThreadVarLanguage.getLang()) + "(" + SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang()) + ")," + SystemEnv.getHtmlLabelName(15933, ThreadVarLanguage.getLang()) + "," + leaveName + SystemEnv.getHtmlLabelName(17638, ThreadVarLanguage.getLang()) + unitName + "," + SystemEnv.getHtmlLabelName(130286, ThreadVarLanguage.getLang()) + leaveName + unitName + "," + SystemEnv.getHtmlLabelName(26642, ThreadVarLanguage.getLang()) + leaveName + unitName + "," + SystemEnv.getHtmlLabelName(19548, ThreadVarLanguage.getLang()) + ""; + String[] fieldNameArr = fieldNameStr.split(","); + for (int i = 0; i < fieldNameArr.length; i++) { + cell = row.createCell((short) i); + cell.setCellStyle(cellStyle); + cell.setCellType(CellType.STRING); + cell.setCellValue(fieldNameArr[i]); + + sheet.setColumnWidth((short) i, (short) (6 * 1000)); + } + } else { + String fieldNameStr = "ID(" + SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang()) + ")," + SystemEnv.getHtmlLabelName(714, ThreadVarLanguage.getLang()) + "(" + SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang()) + ")," + SystemEnv.getHtmlLabelName(413, ThreadVarLanguage.getLang()) + "(" + SystemEnv.getHtmlLabelName(10005349, ThreadVarLanguage.getLang()) + ")," + leaveName + "" + SystemEnv.getHtmlLabelName(17638, ThreadVarLanguage.getLang()) + "" + unitName + "," + SystemEnv.getHtmlLabelName(130286, ThreadVarLanguage.getLang()) + "" + leaveName + unitName + "," + SystemEnv.getHtmlLabelName(26642, ThreadVarLanguage.getLang()) + "" + leaveName + unitName; + String[] fieldNameArr = fieldNameStr.split(","); + for (int i = 0; i < fieldNameArr.length; i++) { + cell = row.createCell((short) i); + cell.setCellStyle(cellStyle); + cell.setCellType(CellType.STRING); + cell.setCellValue(fieldNameArr[i]); + + sheet.setColumnWidth((short) i, (short) (6 * 1000)); + } + } + String rightLevel = HrmUserVarify.getRightLevel("KQLeaveRulesEdit:Edit", user); + int departmentID = user.getUserDepartment(); + int subcompanyID = user.getUserSubCompany1(); + //是否开启了人力资源模块的管理分权 + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + boolean isUseHrmManageDetach = manageDetachComInfo.isUseHrmManageDetach(); + /*插入模板数据*/ + RecordSet recordSet = new RecordSet(); + String sql = "select a.id,a.workCode,a.lastName,b.baseAmount,b.extraAmount,b.usedAmount,b.baseAmount2,b.extraAmount2,b.usedAmount2 " + + "from HrmResource a left join kq_balanceOfLeave b on a.id=b.resourceId " + + "and b.belongYear='" + belongYear + "' and b.leaveRulesId=" + leaveRulesId + " where a.status in (0,1,2,3) "; + if (isTiaoXiu) { + sql = "select a.id,a.workCode,a.lastName,'' as baseAmount,'' as extraAmount,'' as usedAmount,'' as baseAmount2,'' as extraAmount2,'' as usedAmount2 " + + " from HrmResource a where a.status in (0,1,2,3) "; + }else if (leaveOfParental) { + // 育儿假明细 + sql = "select a.id,a.workCode,a.lastName,'' as baseAmount,'' as extraAmount,'' as usedAmount,'' as baseAmount2,'' as extraAmount2,'' as usedAmount2 " + + " from HrmResource a where a.status in (0,1,2,3) "; + } + if (organizationType.equals("1")) { + sql += " and a.subCompanyId1 in (" + organizationIds + ") "; + } else if (organizationType.equals("2")) { + sql += " and a.departmentId in (" + organizationIds + ") "; + } else if (organizationType.equals("3")) { + sql += " and ("+ Tools.getOracleSQLIn(organizationIds,"a.id")+")"; + } + if(!isUseHrmManageDetach){ + if (rightLevel.equals("2")) { + // 总部级别的,什么也不返回 + } else if (rightLevel.equals("1")) { // 分部级别的 + sql += " and a.subCompanyId1=" + subcompanyID; + } else if (rightLevel.equals("0")) { // 部门级别 + sql += " and a.departmentId=" + departmentID; + } + } + sql += " order by dspOrder,lastName "; + recordSet.executeQuery(sql); + + cellStyle = workbook.createCellStyle(); + font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 11);//设置字体大小 + font.setColor((short) 55); + cellStyle.setFont(font); + format = workbook.createDataFormat(); + cellStyle.setDataFormat(format.getFormat("@"));//@为文本占位符 + + HSSFCellStyle hssfCellStyle = workbook.createCellStyle(); + font = workbook.createFont(); + font.setFontName("宋体"); + font.setFontHeightInPoints((short) 11);//设置字体大小 + hssfCellStyle.setFont(font); + format = workbook.createDataFormat(); + hssfCellStyle.setDataFormat(format.getFormat("@"));//@为文本占位符 + + rowIndex = 1; + while (recordSet.next()) { + int cellIndex = 0; + String id = recordSet.getString("id"); + String lastName = recordSet.getString("lastName"); + String workcode = recordSet.getString("workcode"); + + row = sheet.createRow(rowIndex++); + row.setHeightInPoints(13); + cell = row.createCell((short) cellIndex++); + cell.setCellStyle(cellStyle); + cell.setCellType(CellType.STRING); + cell.setCellValue(id); + + cell = row.createCell((short) cellIndex++); + cell.setCellStyle(cellStyle); + cell.setCellType(CellType.STRING); + cell.setCellValue(Util.formatMultiLang(workcode, "7")); + + cell = row.createCell((short) cellIndex++); + cell.setCellStyle(cellStyle); + cell.setCellType(CellType.STRING); + cell.setCellValue(Util.formatMultiLang(lastName, "7")); + + if (isMixMode) { + String baseAmount = recordSet.getString("baseAmount"); + String extraAmount = recordSet.getString("extraAmount"); + String usedAmount = recordSet.getString("usedAmount"); + String baseAmount2 = recordSet.getString("baseAmount2"); + String extraAmount2 = recordSet.getString("extraAmount2"); + String usedAmount2 = recordSet.getString("usedAmount2"); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellValue(baseAmount); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellValue(extraAmount); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellValue(usedAmount); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellValue(baseAmount2); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellValue(extraAmount2); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellValue(usedAmount2); + } else if (isTiaoXiu) { + //调休的导入和其他假期类型的不太一样,调休的导入均为新增。 + String belongMonth = ""; + String totalAmount = ""; + String usedAmount = ""; + String effectiveDate = ""; + String expirationDate = ""; + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellStyle(hssfCellStyle); + cell.setCellValue(belongYear); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellStyle(hssfCellStyle); + cell.setCellValue(belongMonth); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellStyle(hssfCellStyle); + cell.setCellValue(totalAmount); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellStyle(hssfCellStyle); + cell.setCellValue(usedAmount); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellStyle(hssfCellStyle); + cell.setCellValue(effectiveDate); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellStyle(hssfCellStyle); + cell.setCellValue(expirationDate); + }else if (leaveOfParental) { + String effectiveDate = ""; + String expirationDate = ""; + + String baseAmount = recordSet.getString("baseAmount"); + String extraAmount = recordSet.getString("extraAmount"); + String usedAmount = recordSet.getString("usedAmount"); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellStyle(hssfCellStyle); + cell.setCellValue(belongYear); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellStyle(hssfCellStyle); + cell.setCellValue(baseAmount); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellStyle(hssfCellStyle); + cell.setCellValue(extraAmount); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellStyle(hssfCellStyle); + cell.setCellValue(usedAmount); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellStyle(hssfCellStyle); + cell.setCellValue(effectiveDate); + + }else { + String baseAmount = recordSet.getString("baseAmount"); + String extraAmount = recordSet.getString("extraAmount"); + String usedAmount = recordSet.getString("usedAmount"); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellValue(baseAmount); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellValue(extraAmount); + + cell = row.createCell((short) cellIndex++); + cell.setCellType(CellType.STRING); + cell.setCellValue(usedAmount); + } + } + + String filePath = GCONST.getRootPath() + "hrm" + File.separator + "import" + File.separator + "templet" + File.separator + "KQBalanceOfLeave.xls"; + FileOutputStream fileOut = new FileOutputStream(filePath); + workbook.write(fileOut); + fileOut.flush(); + fileOut.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/engine/kq/util/KQDurationCalculatorUtil.java b/src/com/engine/kq/util/KQDurationCalculatorUtil.java new file mode 100644 index 0000000..2cce760 --- /dev/null +++ b/src/com/engine/kq/util/KQDurationCalculatorUtil.java @@ -0,0 +1,616 @@ +package com.engine.kq.util; + +import com.engine.kq.bean.KQRepeatBean; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQRepeatLengthContext; +import com.engine.kq.biz.KQWorkTime; +import com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean; +import com.engine.kq.biz.chain.duration.NonDayUnitSplitChain; +import com.engine.kq.biz.chain.duration.NonHalfUnitSplitChain; +import com.engine.kq.biz.chain.duration.NonHourUnitSplitChain; +import com.engine.kq.biz.chain.duration.NonWholeUnitSplitChain; +import com.engine.kq.biz.chain.duration.NonWorkDurationChain; +import com.engine.kq.biz.chain.duration.WorkDayUnitSplitChain; +import com.engine.kq.biz.chain.duration.WorkDurationChain; +import com.engine.kq.biz.chain.duration.WorkHalfUnitSplitChain; +import com.engine.kq.biz.chain.duration.WorkHourUnitSplitChain; +import com.engine.kq.biz.chain.duration.WorkWholeUnitSplitChain; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.KQFlowUtil; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.report.schedulediff.HrmScheduleDiffUtil; + +public class KQDurationCalculatorUtil extends BaseBean { + private KQLog kqLog = new KQLog(); + + private final String resourceid; + private String fromDate; + private String toDate; + private String fromTime; + private String toTime; + private String newLeaveType; + /** + * 获取最小计算单位 + * 1-按天计算 + * 2-按半天计算 + * 3-按小时计算 + * 4-按整天计算 + */ + private String durationrule; + /** + * 1-按工作日计算计算时长 + * 2-按自然日计算计算时长 + */ + private String computingMode; + + /** + * 加班类型 + */ + private String overtime_type; + + private DurationTypeEnum durationTypeEnum; + + //外部类的构造函数 + private KQDurationCalculatorUtil(DurationParamBuilder build){ + this.resourceid = build.resourceid; + this.fromDate = build.fromDate; + this.toDate = build.toDate; + this.fromTime = build.fromTime; + this.toTime = build.toTime; + this.newLeaveType = build.newLeaveType; + this.durationrule = build.durationrule; + this.computingMode = build.computingMode; + this.durationTypeEnum = build.durationTypeEnum; + this.overtime_type = build.overtime_type; + } + + /** + * 根据人和指定的日期获取办公时段 + * @param resourceid + * @param date + * @param containYesterday + * @return + */ + public static ShiftInfoBean getWorkTime(String resourceid, String date,boolean containYesterday){ + User user = User.getUser(Util.getIntValue(resourceid), 0); + if(user == null){ + return null; + } + return getWorkTime(user, date,containYesterday); + } + + /** + * 不记录日志的,流程的超时提醒日志太大 + * @param resourceid + * @param date + * @param containYesterday + * @param isLog + * @return + */ + public static ShiftInfoBean getWorkTime(String resourceid, String date,boolean containYesterday,boolean isLog){ + User user = User.getUser(Util.getIntValue(resourceid), 0); + if(user == null){ + return null; + } + return getWorkTime(user, date,containYesterday,isLog); + } + + public static ShiftInfoCominfoBean getShiftInfoCominfoBean(String resourceid, String date){ + KQWorkTime kqWorkTime = new KQWorkTime(); + Map kqWorkTimeMap = new HashMap<>(); + ShiftInfoCominfoBean shiftInfoCominfoBean = kqWorkTime.getShiftInfoCominfoBean(resourceid, date); + return shiftInfoCominfoBean; + } + + /** + * 直接根据user来获取 + * @param user + * @param date + * @param containYesterday + * @param isLog + * @return + */ + public static ShiftInfoBean getWorkTime(User user, String date,boolean containYesterday,boolean isLog){ + KQWorkTime kqWorkTime = new KQWorkTime(); + Map kqWorkTimeMap = new HashMap<>(); + kqWorkTimeMap = kqWorkTime.getWorkDuration(""+user.getUID(), date,containYesterday,isLog); + boolean isfree = "1".equalsIgnoreCase(Util.null2String(kqWorkTimeMap.get("isfree"))); + if(isfree){ + ShiftInfoBean shiftInfoBean = new ShiftInfoBean(); + shiftInfoBean.setIsfree(true); + String signStart = Util.null2String(kqWorkTimeMap.get("signStart")); + String workMins = Util.null2String(kqWorkTimeMap.get("workMins")); + shiftInfoBean.setFreeSignStart(signStart); + shiftInfoBean.setFreeWorkMins(workMins); + shiftInfoBean.setSplitDate(date); + if(signStart.length() > 0 && workMins.length() > 0){ + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + LocalTime signLocalTime = LocalTime.parse(signStart, dateTimeFormatter); + shiftInfoBean.setFreeSignEnd(signLocalTime.plusMinutes(Util.getIntValue(workMins)).format(dateTimeFormatter)); + shiftInfoBean.setFreeSignMiddle(signLocalTime.plusMinutes(Util.getIntValue(workMins)/2).format(dateTimeFormatter)); + } + + return shiftInfoBean; + }else{ + if(kqWorkTimeMap.get("shiftInfoBean") != null){ + ShiftInfoBean shiftInfoBean = (ShiftInfoBean)kqWorkTimeMap.get("shiftInfoBean"); + return shiftInfoBean; + }else{ + return null; + } + } + } + + /** + * 直接根据user来获取 + * @param user + * @param date + * @param containYesterday + * @return + */ + public static ShiftInfoBean getWorkTime(User user, String date,boolean containYesterday){ + return getWorkTime(user, date, containYesterday, true); + } + + public static Map getWorkButton(String resourceid, String date, boolean containYesterday){ + User user = User.getUser(Util.getIntValue(resourceid), 0); + return getWorkButton(user,date,containYesterday); + } + + public static Map getWorkButton(User user, String date, boolean containYesterday){ + KQWorkTime kqWorkTime = new KQWorkTime(); + Map kqWorkTimeMap = new HashMap<>(); + kqWorkTimeMap = kqWorkTime.getWorkButton(""+user.getUID(), date,containYesterday); + + return kqWorkTimeMap; + } + + /** + * 根据传入的用户和时段返回非工作时长 + * @return + */ + public Map getNonWorkDuration(){ + + Map durationMap = new HashMap<>(); + try{ + double D_Duration = 0.0; + double Min_Duration = 0.0; + //公众假日加班时长 + double D_Pub_Duration = 0.0; + double D_Pub_Mins = 0.0; + //工作日加班时长 + double D_Work_Duration = 0.0; + double D_Work_Mins = 0.0; + //休息日加班时长 + double D_Rest_Duration = 0.0; + double D_Rest_Mins = 0.0; + + SplitBean splitBean = new SplitBean(); + splitBean.setFromDate(fromDate); + splitBean.setFromTime(fromTime); + splitBean.setToDate(toDate); + splitBean.setToTime(toTime); + splitBean.setResourceId(resourceid); + splitBean.setFromdatedb(fromDate); + splitBean.setTodatedb(toDate); + splitBean.setFromtimedb(fromTime); + splitBean.setTotimedb(toTime); + splitBean.setDurationrule(durationrule); + splitBean.setComputingMode(computingMode); + splitBean.setDurationTypeEnum(DurationTypeEnum.OVERTIME); + splitBean.setOvertime_type(overtime_type); + + List splitBeans = new ArrayList<>(); + + NonWorkDurationChain hourUnitSplitChain = new NonHourUnitSplitChain(splitBeans); + NonWorkDurationChain dayUnitSplitChain = new NonDayUnitSplitChain(splitBeans); + NonWorkDurationChain halfUnitSplitChain = new NonHalfUnitSplitChain(splitBeans); + NonWorkDurationChain wholeUnitSplitChain = new NonWholeUnitSplitChain(splitBeans); + + //设置执行链 + hourUnitSplitChain.setDurationChain(dayUnitSplitChain); + dayUnitSplitChain.setDurationChain(halfUnitSplitChain); + halfUnitSplitChain.setDurationChain(wholeUnitSplitChain); + //把初始数据设置进去 + hourUnitSplitChain.handleDuration(splitBean); + + //每一天的流程时长都在这里了,搞吧 + for(SplitBean sb : splitBeans){ +// * 1-公众假日、2-工作日、3-休息日 + int changeType = sb.getChangeType(); + double durations = Util.getDoubleValue(sb.getDuration(), 0.0); + double durationMins = sb.getD_Mins(); + if(1 == changeType){ + D_Pub_Duration += durations; + D_Pub_Mins += durationMins; + } + if(2 == changeType){ + D_Work_Duration += durations; + D_Work_Mins += durationMins; + } + if(3 == changeType){ + D_Rest_Duration += durations; + D_Rest_Mins += durationMins; + } + } + Min_Duration = D_Pub_Mins+D_Work_Mins+D_Rest_Mins; + + if("3".equalsIgnoreCase(durationrule) || "5".equalsIgnoreCase(durationrule) || "6".equalsIgnoreCase(durationrule)){ + double d_hour = Min_Duration/60.0; + durationMap.put("duration", KQDurationCalculatorUtil.getDurationRound(""+d_hour)); + }else { + double oneDayHour = KQFlowUtil.getOneDayHour(DurationTypeEnum.OVERTIME,""); + double d_day = Min_Duration/(oneDayHour * 60); + durationMap.put("duration", KQDurationCalculatorUtil.getDurationRound(""+d_day)); + } + + durationMap.put("min_duration", KQDurationCalculatorUtil.getDurationRound(""+Min_Duration)); + + }catch (Exception e){ + e.printStackTrace(); + } + return durationMap; + } + + /** + * 根据传入的用户和时段返回工作时长 + * @return + */ + public Map getWorkDuration(){ + + Map durationMap = new HashMap<>(); + try{ + if(!isValidate(fromDate,toDate,fromTime,toTime)){ + durationMap.put("duration", "0.0"); + return durationMap; + } + if(durationTypeEnum != DurationTypeEnum.COMMON_CAL){ + kqLog.info("getWorkDuration:"+durationTypeEnum.getDurationType()+":fromDate:"+fromDate+":toDate:"+toDate+":fromTime:"+fromTime+":toTime:"+toTime+":durationrule:"+durationrule+":computingMode:"+computingMode); + } + //如果是加班 + if(durationTypeEnum ==DurationTypeEnum.OVERTIME){ + return getNonWorkDuration(); + } + //时长 + double D_Duration = 0.0; + //分钟数 + double Min_Duration = 0.0; + + SplitBean splitBean = new SplitBean(); + splitBean.setFromDate(fromDate); + splitBean.setFromTime(fromTime); + splitBean.setToDate(toDate); + splitBean.setToTime(toTime); + splitBean.setResourceId(resourceid); + splitBean.setFromdatedb(fromDate); + splitBean.setTodatedb(toDate); + splitBean.setFromtimedb(fromTime); + splitBean.setTotimedb(toTime); + splitBean.setDurationrule(durationrule); + splitBean.setDurationTypeEnum(durationTypeEnum); + splitBean.setComputingMode(computingMode); + splitBean.setNewLeaveType(newLeaveType); + if("2".equalsIgnoreCase(computingMode)){ + double oneDayHour = KQFlowUtil.getOneDayHour(durationTypeEnum,newLeaveType); + splitBean.setOneDayHour(oneDayHour); + if(durationTypeEnum == DurationTypeEnum.LEAVE){ + //只有自然日 请假才有这个排除节假日、休息日的功能 + splitBean.setFilterholidays(KQLeaveRulesBiz.getFilterHolidays(splitBean.getNewLeaveType())); + } + } + if(durationTypeEnum ==DurationTypeEnum.LEAVE || durationTypeEnum ==DurationTypeEnum.LEAVEBACK){ + if(newLeaveType.length() > 0){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String conversion = kqLeaveRulesComInfo.getConversion(newLeaveType); + String repeatTime = kqLeaveRulesComInfo.getRepeatTime(newLeaveType); + splitBean.setConversion(conversion); + splitBean.setRepeatTime(repeatTime); + } + } + + List splitBeans = new ArrayList<>(); + + WorkDurationChain hourUnitSplitChain = new WorkHourUnitSplitChain(splitBeans); + WorkDurationChain dayUnitSplitChain = new WorkDayUnitSplitChain(splitBeans); + WorkDurationChain halfUnitSplitChain = new WorkHalfUnitSplitChain(splitBeans); + WorkDurationChain wholeUnitSplitChain = new WorkWholeUnitSplitChain(splitBeans); + + //设置执行链 + hourUnitSplitChain.setDurationChain(dayUnitSplitChain); + dayUnitSplitChain.setDurationChain(halfUnitSplitChain); + halfUnitSplitChain.setDurationChain(wholeUnitSplitChain); + //把初始数据设置进去 + hourUnitSplitChain.handleDuration(splitBean); + + //每一天的流程时长都在这里了,搞吧 + for(SplitBean sb : splitBeans){ + double durations = Util.getDoubleValue(sb.getDuration(), 0.0); + double min_durations = sb.getD_Mins(); + D_Duration += durations; + Min_Duration += min_durations; + } + + durationMap.put("duration", KQDurationCalculatorUtil.getDurationRound(""+D_Duration)); + durationMap.put("min_duration", KQDurationCalculatorUtil.getDurationRound(""+Min_Duration)); + + }catch (Exception e){ + e.printStackTrace(); + } + return durationMap; + } + + /** + * 校验是传入的参数数据是否正常 + * @return false 表示数据有误 + */ + private boolean isValidate(String fromDate,String toDate,String fromTime,String toTime) { + + KQRepeatBean kqRepeatBean = KQRepeatLengthContext.getRepeatBean(); + if(kqRepeatBean != null){ + return true; + } + if(fromDate.length() == 0 || toDate.length() == 0){ + return false; + } + if(fromTime.length() == 0 || toTime.length() == 0){ + return false; + } + + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + String fromDateTime = fromDate+" "+fromTime+":00"; + String toDateTime = toDate+" "+toTime+":00"; + + LocalDateTime localFromDateTime = LocalDateTime.parse(fromDateTime,fullFormatter); + LocalDateTime localToDateTime = LocalDateTime.parse(toDateTime,fullFormatter); + + if(localFromDateTime.isAfter(localToDateTime) || localFromDateTime.isEqual(localToDateTime)){ + return false; + } + return true; + } + + /** + * 得到排除非工作时间的时长 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param resourceid + * @return + */ + public Map getTotalWorkingDurations(String fromDate,String fromTime,String toDate,String toTime,String resourceid){ + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceid). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).durationRuleParam("1") + .computingModeParam("1").durationTypeEnumParam(DurationTypeEnum.COMMON_CAL).build(); + + Map durationMap = kqDurationCalculatorUtil.getWorkDuration(); + return durationMap; + } + + /** + * 得到排除非工作时间的天数 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param resourceid + * @return + */ + public String getTotalWorkingDays(String fromDate,String fromTime,String toDate,String toTime,String resourceid){ + Map durationMap = getTotalWorkingDurations(fromDate,fromTime,toDate,toTime,resourceid); + + String duration4day = Util.null2s(Util.null2String(durationMap.get("duration")),"0"); + return KQDurationCalculatorUtil.getDurationRound(duration4day); + } + + /** + * 得到排除非工作时间的小时 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param resourceid + * @return + */ + public String getTotalWorkingHours(String fromDate,String fromTime,String toDate,String toTime,String resourceid){ + Map durationMap = getTotalWorkingDurations(fromDate,fromTime,toDate,toTime,resourceid); + String duration4min = Util.null2s(Util.null2String(durationMap.get("min_duration")),"0"); + double duration4hour = Util.getDoubleValue(duration4min)/60.0; + + return KQDurationCalculatorUtil.getDurationRound(duration4hour+""); + } + + /** + * 得到排除非工作时间的分钟 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param resourceid + * @return + */ + public String getTotalWorkingMins(String fromDate,String fromTime,String toDate,String toTime,String resourceid){ + Map durationMap = getTotalWorkingDurations(fromDate,fromTime,toDate,toTime,resourceid); + String duration4min = Util.null2s(Util.null2String(durationMap.get("min_duration")),"0"); + + return KQDurationCalculatorUtil.getDurationRound(duration4min+""); + } + + /** + * 得到非工作时间的天数 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param resourceid + * @return + */ + public String getTotalNonWorkingDays(String fromDate,String fromTime,String toDate,String toTime,String resourceid){ + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceid). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).computingModeParam("1"). + durationRuleParam("1").durationTypeEnumParam(DurationTypeEnum.OVERTIME).build(); + Map durationMap = kqDurationCalculatorUtil.getNonWorkDuration(); + + String duration = Util.null2String(durationMap.get("duration")); + return KQDurationCalculatorUtil.getDurationRound(duration); + } + + /** + * 得到非工作时间的小时 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param resourceid + * @return + */ + public String getTotalNonWorkingHours(String fromDate,String fromTime,String toDate,String toTime,String resourceid){ + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceid). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).computingModeParam("1"). + durationRuleParam("3").durationTypeEnumParam(DurationTypeEnum.OVERTIME).build(); + Map durationMap = kqDurationCalculatorUtil.getNonWorkDuration(); + + String duration = Util.null2String(durationMap.get("duration")); + return KQDurationCalculatorUtil.getDurationRound(duration); + } + + /** + * 考勤通用精度 2 + * @param duration + * @return + */ + public static String getDurationRound(String duration){ + if(HrmScheduleDiffUtil.isFromFlow()){ + return Util.round(duration,5) ; + } + return Util.round(duration, 2); + } + + /** + * 考勤流程中间表精度 5 + * @param duration + * @return + */ + public static String getDurationRound5(String duration){ + return Util.round(duration, 5); + } + + /** + * 针对可能存在的多种参数类型 创建参数静态内部类Builder + */ + public static class DurationParamBuilder { + + //必选变量 人员看怎么都是需要的 + private final String resourceid; + + //可选变量 + private String fromDate = ""; + private String toDate = ""; + private String fromTime = ""; + private String toTime = ""; + /** + * 请假用的请假类型 + */ + private String newLeaveType = ""; + /** + * 单位 + * 1-按天出差 + * 2-按半天出差 + * 3-按小时出差 + * 4-按整天出差 + */ + private String durationrule = ""; + /** + * 时长计算方式 + * 1-按照工作日计算请假时长 + * 2-按照自然日计算请假时长 + */ + private String computingMode = ""; + + /** + * 加班类型 + */ + private String overtime_type = ""; + + /** + * 哪种类型的时长计算,请假还是出差还是公出还是加班 + */ + private DurationTypeEnum durationTypeEnum; + + public DurationParamBuilder(String resourceid) { + this.resourceid = resourceid; + //初始化的时候需要把其他参数先清空下 + this.fromDate = ""; + this.toDate = ""; + this.fromTime = ""; + this.toTime = ""; + this.newLeaveType = ""; + this.durationrule = ""; + this.computingMode = ""; + this.overtime_type = ""; + } + + //成员方法返回其自身,所以可以链式调用 + public DurationParamBuilder fromDateParam(final String fromDate) { + this.fromDate = fromDate; + return this; + } + + public DurationParamBuilder toDateParam(final String toDate) { + this.toDate = toDate; + return this; + } + + public DurationParamBuilder fromTimeParam(final String fromTime) { + this.fromTime = fromTime; + return this; + } + + public DurationParamBuilder toTimeParam(final String toTime) { + this.toTime = toTime; + return this; + } + + public DurationParamBuilder newLeaveTypeParam(final String newLeaveType) { + this.newLeaveType = newLeaveType; + return this; + } + + public DurationParamBuilder durationRuleParam(final String durationrule) { + this.durationrule = durationrule; + return this; + } + public DurationParamBuilder computingModeParam(final String computingMode) { + this.computingMode = computingMode; + return this; + } + public DurationParamBuilder overtime_typeParam(final String overtime_type) { + this.overtime_type = overtime_type; + return this; + } + public DurationParamBuilder durationTypeEnumParam(final DurationTypeEnum durationTypeEnum) { + this.durationTypeEnum = durationTypeEnum; + return this; + } + + //Builder的build方法,返回外部类的实例 + public KQDurationCalculatorUtil build() { + return new KQDurationCalculatorUtil(this); + } + } + +} diff --git a/src/com/engine/kq/util/KQLockAttendaUtil.java b/src/com/engine/kq/util/KQLockAttendaUtil.java new file mode 100644 index 0000000..b21b6ee --- /dev/null +++ b/src/com/engine/kq/util/KQLockAttendaUtil.java @@ -0,0 +1,1382 @@ +package com.engine.kq.util; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.bean.ImportSetting; +import com.engine.kq.bean.KqLockAttenda; +import com.engine.kq.biz.*; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.entity.KQScheduleSignEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.timer.KQQueue; +import com.engine.kq.timer.KQTaskBean; +import com.engine.kq.wfset.bean.ProcessChangeSplitBean; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.*; +import com.engine.workflow.biz.freeNode.FreeNodeBiz; +import com.engine.workflow.biz.publicApi.RequestOperateBiz; +import com.engine.workflow.biz.workflowOvertime.OvertimeBiz; +import com.engine.workflow.constant.PAResponseCode; +import com.engine.workflow.entity.core.RequestInfoEntity; +import com.engine.workflow.entity.publicApi.PAResponseEntity; +import com.engine.workflow.entity.publicApi.ReqOperateRequestEntity; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.wbi.util.StringUtil; +import weaver.conn.BatchRecordSet; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetDataSource; +import weaver.file.Prop; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.common.Tools; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.systeminfo.SystemEnv; +import weaver.wechat.util.DateUtil; +import weaver.workflow.agent.AgentManager; +import weaver.workflow.monitor.Monitor; +import weaver.workflow.monitor.MonitorDTO; +import weaver.workflow.workflow.WfForceOver; +import weaver.workflow.workflow.WfFunctionManageUtil; +import weaver.workflow.workflow.WorkflowComInfo; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + + +@SuppressWarnings("unchecked") +public class KQLockAttendaUtil { + + private static final String LOCK_TABLE = Util.null2String(Prop.getPropValue("kqLockAttenda", "LOCK_TABLE")); + private static final String LOCK_COM = Util.null2String(Prop.getPropValue("kqLockAttenda", "LOCK_COM")); + private static final String LOCK_SUBCOM = Util.null2String(Prop.getPropValue("kqLockAttenda", "LOCK_SUBCOM")); + private static final String LOCK_DEPT = Util.null2String(Prop.getPropValue("kqLockAttenda", "LOCK_DEPT")); + private static final String LOCK_RESOURCE = Util.null2String(Prop.getPropValue("kqLockAttenda", "LOCK_RESOURCE")); + private static final String LOCK_FROMDATE = Util.null2String(Prop.getPropValue("kqLockAttenda", "LOCK_FROMDATE")); + private static final String LOCK_TODATE = Util.null2String(Prop.getPropValue("kqLockAttenda", "LOCK_TODATE")); + private static final String LOCK_LOCK = Util.null2String(Prop.getPropValue("kqLockAttenda", "LOCK_LOCK")); + + private static final String LOCK_DEGREE = Util.null2String(Prop.getPropValue("kqLockAttenda", "LOCK_DEGREE")); + private static KQLog kqLog = new KQLog(); + + public List sdkqbb_map; + + public static final ExecutorService EXECUTOR_SERVICE = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(100)); + + public KQLockAttendaUtil() { + this.sdkqbb_map = this.initModuleData(); + } + + + public List initModuleData() { + List list = new ArrayList<>(); + if ("".equals(LOCK_TABLE)) { + return list; + } + RecordSet rs = new RecordSet(); + StringBuilder sql = new StringBuilder(); + sql.append("select * from " + LOCK_TABLE + " where "); + sql.append(" " + LOCK_LOCK + "=1 "); + kqLog.info("sql>>>>>>>>>>>>>>>" + sql.toString()); + + KqLockAttenda bean = null; + rs.execute(sql.toString()); + while (rs.next()) { + bean = new KqLockAttenda(); + String iscompany = Util.null2String(rs.getString(LOCK_COM)); + bean.setLOCK_COM(iscompany); + String subcompanyIds = Util.null2String(rs.getString(LOCK_SUBCOM)); + bean.setLOCK_SUBCOM(subcompanyIds); + String departmentIds = Util.null2String(rs.getString(LOCK_DEPT)); + bean.setLOCK_DEPT(departmentIds); + String resouceIds = Util.null2String(rs.getString(LOCK_RESOURCE)); + bean.setLOCK_RESOURCE(resouceIds); + String fromdate = Util.null2String(rs.getString(LOCK_FROMDATE)); + bean.setLOCK_FROMDATE(fromdate); + String todate = Util.null2String(rs.getString(LOCK_TODATE)); + bean.setLOCK_TODATE(todate); + list.add(bean); + } + + return list; + } + + public boolean checkLockStatus(String resourceId, String kqdate) { + if (!LOCK_DEGREE.equals("0")&&!LOCK_DEGREE.equals("1")) { + return false; + } + try { + RecordSet rs = new RecordSet(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + String sql = "select * from " + LOCK_TABLE + " where (" + LOCK_FROMDATE + "<='" + kqdate + "' and " + LOCK_TODATE + " >= '" + kqdate + "' ) "; + String sqlWhere = ""; + if (!"".equals(resourceId)) { + if (rs.getDBType().equals("oracle")||rs.getDBType().equals("postgresql")) { + sqlWhere=" and (','||CAST(" + LOCK_RESOURCE + " AS VARCHAR(2000))||',') like '%," + resourceId + ",%'"; + } else if (rs.getDBType().equals("mysql")) { + sqlWhere=" and concat(','," + LOCK_RESOURCE + ",',') like '%," + resourceId + ",%'" ; + } else { + sqlWhere=" and (','+CAST(" + LOCK_RESOURCE + " AS VARCHAR(2000))+',') like '%," + resourceId + ",%'" ; + } + rs.executeQuery(sql + sqlWhere); + rs.writeLog("KQLockAttendaUtil>sql="+sql + sqlWhere); + if (rs.next()) { + String lockValue = rs.getString(LOCK_LOCK); + if(lockValue.equals("1")){ + return true; + }else{ + return false; + } + } + } + if (!"".equals(departmentId)) { + if (rs.getDBType().equals("oracle")||rs.getDBType().equals("postgresql")) { + sqlWhere=" and (','||CAST(" + LOCK_DEPT + " AS VARCHAR(2000))||',') like '%," + departmentId + ",%'"; + } else if (rs.getDBType().equals("mysql")) { + sqlWhere=" and concat(','," + LOCK_DEPT + ",',') like '%," + departmentId + ",%'"; + } else { + sqlWhere=" and (','+CAST(" + LOCK_DEPT + " AS VARCHAR(2000))+',') like '%," + departmentId + ",%'"; + } + rs.writeLog("KQLockAttendaUtil>sql="+sql + sqlWhere); + rs.executeQuery(sql + sqlWhere); + if (rs.next()) { + String lockValue = rs.getString(LOCK_LOCK); + if(lockValue.equals("1")){ + return true; + }else{ + return false; + } + } + } + if (!"".equals(subcompanyId)) { + if (rs.getDBType().equals("oracle")||rs.getDBType().equals("postgresql")) { + sqlWhere=" and (','||CAST(" + LOCK_SUBCOM + " AS VARCHAR(2000))||',') like '%," + subcompanyId + ",%'"; + } else if (rs.getDBType().equals("mysql")) { + sqlWhere=" and concat(','," + LOCK_SUBCOM + ",',') like '%," + subcompanyId + ",%'"; + } else { + sqlWhere=" and (','+CAST(" + LOCK_SUBCOM + " AS VARCHAR(2000))+',') like '%," + subcompanyId + ",%'"; + } + rs.writeLog("KQLockAttendaUtil>sql="+sql + sqlWhere); + rs.executeQuery(sql + sqlWhere); + if (rs.next()) { + String lockValue = rs.getString(LOCK_LOCK); + if(lockValue.equals("1")){ + return true; + }else{ + return false; + } + } + } + sqlWhere=" and (" + LOCK_COM + "=1) "; + rs.writeLog("KQLockAttendaUtil>sql="+sql + sqlWhere); + rs.executeQuery(sql + sqlWhere); + if (rs.next()) { + String lockValue = rs.getString(LOCK_LOCK); + if(lockValue.equals("1")){ + return true; + }else{ + return false; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + /** + * 判断当前范围内是否存在已被锁定的日期 + * + * @param fromDate 开始日期 + * @param toDate 结束日期 + */ + public boolean isLockDate(String fromDate, String toDate) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + try { + Date startDate = format.parse(fromDate); + Date endDate = format.parse(toDate); + for (KqLockAttenda datas : this.sdkqbb_map) { + Date ksrqDate = format.parse(datas.getLOCK_FROMDATE()); + Date jsrqDate = format.parse(datas.getLOCK_TODATE()); + if (isInterSection(startDate, endDate, ksrqDate, jsrqDate)) { + return true; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + /** + * 两个时间段是否存在交叉 + * + * @param startDateOne 第一个时间段的开始时间 + * @param endDateOne 第一个时间段的结束时间 + * @param startDateTwo 第二个时间段的开始时间 + * @param endDateTwo 第二个时间段的结束时间 + */ + private static boolean isInterSection(Date startDateOne, Date endDateOne, Date startDateTwo, Date endDateTwo) { + Date maxStartDate = startDateOne; + if (maxStartDate.before(startDateTwo)) { + maxStartDate = startDateTwo; + } + Date minEndDate = endDateOne; + if (endDateTwo.before(minEndDate)) { + minEndDate = endDateTwo; + } + return maxStartDate.before(minEndDate) || (maxStartDate.getTime() == minEndDate.getTime()); + } + + + + public boolean isLockDate(Map params) { + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.getString("fromDate")); + String toDate = Util.null2String(jsonObj.getString("toDate")); + String typeselect = Util.null2String(jsonObj.getString("typeselect")); + if (typeselect.length() == 0) { + typeselect = "3"; + } + if (!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"); + } + } + return this.isLockDate(fromDate, toDate); + } + + /** + * 锁定日期范围内的考勤报表数据 + * + * @param params 参数 + * @param user 当前登录用户 + */ + public Map lockReport(Map params, User user) { + Map result = new HashMap<>(); + BaseBean baseBean = new BaseBean(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.getString("fromDate")); + String toDate = Util.null2String(jsonObj.getString("toDate")); + String typeselect = Util.null2String(jsonObj.getString("typeselect")); + if (typeselect.length() == 0) { + typeselect = "3"; + } + if (!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"); + } + } + boolean lockDate = this.isLockDate(fromDate, toDate); + if (lockDate) { + result.put("status", "0"); + result.put("message", "当前日期范围内存在被锁定的数据,请重新选择日期范围!"); + return result; + } + // 保存锁定周期 + RecordSet recordSet = new RecordSet(); + String formModeId = baseBean.getPropValue("qc2648525", "sdkqbb.form.mode.id"); + String sql = "insert into uf_sdkqbb (ksrq, jsrq, sfsd, formmodeid) values ('" + fromDate + "', '" + toDate + "', 1, " + formModeId + ")"; + recordSet.execute(sql); +// RunnableTask runnableTask = new RunnableTask(user, fromDate, toDate, params, null, true, true); +// EXECUTOR_SERVICE.execute(runnableTask); +// String finalFromDate = fromDate; +// String finalToDate = toDate; +// new Thread(() -> { +// // 更新初始化缓存 +// this.sdkqbb_map = this.initModuleData(); +// // 未归档流程退回到发起节点 +// this.doForceOver(user); +// // 同步数据到建模表 +// this.syncKqData(user, finalFromDate, finalToDate, params); +// }).start(); + result.put("status", "1"); + result.put("message", "锁定成功!"); + return result; + } + + /** + * 强制归档 + */ + public void doForceOver(User user) { + BaseBean baseBean = new BaseBean(); + String workflowIds = baseBean.getPropValue("qc2648525", "kq.workflow.ids"); + RecordSet recordSet = new RecordSet(); + RecordSet newRecordSet = new RecordSet(); + String newSql = "select requestid, workflowid, requestnamenew from workflow_requestbase where workflowid in (" + workflowIds + ") and (currentnodetype = 1 or currentnodetype = 2)"; + String updateSql = "update workflow_requestbase set requestnamenew = ? where requestid = ?"; + recordSet.execute(newSql); + while (recordSet.next()) { + String requestId = Util.null2String(recordSet.getString("requestid")); + String workflowId = Util.null2String(recordSet.getString("workflowid")); + String requestNameNew = Util.null2String(recordSet.getString("requestnamenew")); + if (this.canContinueWorkflow(workflowId, requestId)) { + continue; + } + Map otherParams = new HashMap<>(); + otherParams.put("ismonitor", "1"); + ReqOperateRequestEntity reqOperateRequestEntity = new ReqOperateRequestEntity(); + reqOperateRequestEntity.setRequestId(Util.getIntValue(requestId)); + reqOperateRequestEntity.setRemark("流程日期存在被锁定的考勤数据,流程强制归档且不计入考勤数据"); + reqOperateRequestEntity.setOtherParams(otherParams); + this.doForceOver(user, reqOperateRequestEntity); + requestNameNew = "(已作废)" + requestNameNew; + newRecordSet.executeUpdate(updateSql, requestNameNew, requestId); + } + } + + /** + * 考勤数据同步到建模表 + * + * @param fromDate 开始日期 + * @param toDate 结束日期 + */ + public void syncKqData(User user, String fromDate, String toDate, Map params) { + try { + BigDecimal hourMins = new BigDecimal("60"); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + RecordSet recordSet = new RecordSet(); + BatchRecordSet batchRecordSet = new BatchRecordSet(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + BaseBean baseBean = new BaseBean(); + String tableName = baseBean.getPropValue("qc2648525", "sync.table.name"); + String formModeId = baseBean.getPropValue("qc2648525", "sync.form.mode.id"); + KQReportBiz kqReportBiz = new KQReportBiz(); + List> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules(); + Map flowData = kqReportBiz.getDailyFlowData(params, user); + Date startDate = simpleDateFormat.parse(fromDate); + LocalDate l1 = LocalDate.parse(fromDate); + LocalDate l2 = LocalDate.parse(toDate); + long fromEpochDay = l1.toEpochDay(); + long toEpochDay = l2.toEpochDay(); + long diff = toEpochDay - fromEpochDay; + for (long i = 0; i <= diff; i++) { + List> values = new ArrayList<>(); + String syncDate = simpleDateFormat.format(DateUtil.addDay(startDate, (int) i)); + String newSql = "select * from kq_format_total where kqdate = ?"; + recordSet.executeQuery(newSql, syncDate); + while (recordSet.next()) { + List list = new ArrayList<>(); + list.add(formModeId); + String xm = recordSet.getString("resourceid"); + String gs = resourceComInfo.getSubCompanyID(xm); + String bm = resourceComInfo.getDepartmentID(xm); + String rq = recordSet.getString("kqdate"); + String bc = Util.null2s(recordSet.getString("serialid"), "-1"); + list.add(xm); + list.add(gs); + list.add(bm); + list.add(rq); + list.add(bc); + + Map signDetailInfo = getSignDetailInfo(xm, rq, user); + String sbdk1 = Util.null2s(Util.null2String(signDetailInfo.get("signintime1")), "-1"); + String qdkqjg1 = Util.null2s(Util.null2String(signDetailInfo.get("signinstatus1")), "-1"); + String xbdk1 = Util.null2s(Util.null2String(signDetailInfo.get("signouttime1")), "-1"); + String qtkqjg1 = Util.null2s(Util.null2String(signDetailInfo.get("signoutstatus1")), "-1"); + list.add(sbdk1); + list.add(qdkqjg1); + list.add(xbdk1); + list.add(qtkqjg1); + String sbdk2 = Util.null2s(Util.null2String(signDetailInfo.get("signintime2")), "-1"); + String qdkqjg2 = Util.null2s(Util.null2String(signDetailInfo.get("signinstatus2")), "-1"); + String xbdk2 = Util.null2s(Util.null2String(signDetailInfo.get("signouttime2")), "-1"); + String qtkqjg2 = Util.null2s(Util.null2String(signDetailInfo.get("signoutstatus2")), "-1"); + list.add(sbdk2); + list.add(qdkqjg2); + list.add(xbdk2); + list.add(qtkqjg2); + String sbdk3 = Util.null2s(Util.null2String(signDetailInfo.get("signintime3")), "-1"); + String qdkqjg3 = Util.null2s(Util.null2String(signDetailInfo.get("signinstatus3")), "-1"); + String xbdk3 = Util.null2s(Util.null2String(signDetailInfo.get("signouttime3")), "-1"); + String qtkqjg3 = Util.null2s(Util.null2String(signDetailInfo.get("signoutstatus3")), "-1"); + list.add(sbdk3); + list.add(qdkqjg3); + list.add(xbdk3); + list.add(qtkqjg3); + + double ycqts = Util.getDoubleValue(recordSet.getString("workdays"), 0); + BigDecimal ygzsc = new BigDecimal(Util.null2s(recordSet.getString("workmins"), "0")).divide(hourMins, 2, BigDecimal.ROUND_HALF_DOWN); + double sjcqts = Util.getDoubleValue(recordSet.getString("attendancedays"), 0); + BigDecimal sjgzsc = new BigDecimal(Util.null2s(recordSet.getString("attendanceMins"), "0")).divide(hourMins, 2, BigDecimal.ROUND_HALF_DOWN); + list.add(ycqts); + list.add(ygzsc.doubleValue()); + list.add(sjcqts); + list.add(sjgzsc.doubleValue()); + + double cd = Util.getDoubleValue(recordSet.getString("beLate"), 0); + BigDecimal cdsc = new BigDecimal(Util.null2s(recordSet.getString("beLateMins"), "0")).divide(hourMins, 2, BigDecimal.ROUND_HALF_DOWN); + double zt = Util.getDoubleValue(recordSet.getString("leaveEearly"), 0); + BigDecimal ztsc = new BigDecimal(Util.null2s(recordSet.getString("leaveEarlyMins"), "0")).divide(hourMins, 2, BigDecimal.ROUND_HALF_DOWN); + double kg = Util.getDoubleValue(recordSet.getString("absenteeism"), 0); + BigDecimal kgsc = new BigDecimal(Util.null2s(recordSet.getString("absenteeismMins"), "0")).divide(hourMins, 2, BigDecimal.ROUND_HALF_DOWN); + list.add(cd); + list.add(cdsc.doubleValue()); + list.add(zt); + list.add(ztsc.doubleValue()); + list.add(kg); + list.add(kgsc.doubleValue()); + + Map leaveInfo = getLeaveInfo(syncDate, xm, allLeaveRules, flowData); + double leaveType_2 = Util.getDoubleValue(leaveInfo.get("leaveType_2"), 0); + double leaveType_5 = Util.getDoubleValue(leaveInfo.get("leaveType_5"), 0); + double leaveType_6 = Util.getDoubleValue(leaveInfo.get("leaveType_6"), 0); + double leaveType_7 = Util.getDoubleValue(leaveInfo.get("leaveType_7"), 0); + double leaveType_8 = Util.getDoubleValue(leaveInfo.get("leaveType_8"), 0); + double leaveType_9 = Util.getDoubleValue(leaveInfo.get("leaveType_9"), 0); + double leaveType_10 = Util.getDoubleValue(leaveInfo.get("leaveType_10"), 0); + double leaveType_11 = Util.getDoubleValue(leaveInfo.get("leaveType_11"), 0); + double leaveType_12 = Util.getDoubleValue(leaveInfo.get("leaveType_12"), 0); + double leaveType_13 = Util.getDoubleValue(leaveInfo.get("leaveType_13"), 0); + double leaveType_14 = Util.getDoubleValue(leaveInfo.get("leaveType_14"), 0); + double leaveType_15 = Util.getDoubleValue(leaveInfo.get("leaveType_15"), 0); + double leaveType_16 = Util.getDoubleValue(leaveInfo.get("leaveType_16"), 0); + double leaveType_17 = Util.getDoubleValue(leaveInfo.get("leaveType_17"), 0); + list.add(leaveType_2); + list.add(leaveType_5); + list.add(leaveType_6); + list.add(leaveType_7); + list.add(leaveType_8); + list.add(leaveType_9); + list.add(leaveType_10); + list.add(leaveType_11); + list.add(leaveType_12); + list.add(leaveType_13); + list.add(leaveType_14); + list.add(leaveType_15); + list.add(leaveType_16); + list.add(leaveType_17); + + double bgldxgzrjb = Util.getDoubleValue(Util.null2String(flowData.get(xm + "|" + syncDate + "|workingDayOvertime_nonleave"))); + bgldxgzrjb = bgldxgzrjb < 0 ? 0 : bgldxgzrjb; + double bgldxzmjb = Util.getDoubleValue(Util.null2String(flowData.get(xm + "|" + syncDate + "|restDayOvertime_nonleave"))); + bgldxzmjb = bgldxzmjb < 0 ? 0 : bgldxzmjb; + double bgldxjjqjb = Util.getDoubleValue(Util.null2String(flowData.get(xm + "|" + syncDate + "|holidayOvertime_nonleave"))); + bgldxjjqjb = bgldxjjqjb < 0 ? 0 : bgldxjjqjb; + double gldxgzrjb = Util.getDoubleValue(Util.null2String(flowData.get(xm + "|" + syncDate + "|workingDayOvertime_4leave"))); + gldxgzrjb = gldxgzrjb < 0 ? 0 : gldxgzrjb; + double gldxzmjb = Util.getDoubleValue(Util.null2String(flowData.get(xm + "|" + syncDate + "|restDayOvertime_4leave"))); + gldxzmjb = gldxzmjb < 0 ? 0 : gldxzmjb; + double gldxjjrjb = Util.getDoubleValue(Util.null2String(flowData.get(xm + "|" + syncDate + "|holidayOvertime_4leave"))); + gldxjjrjb = gldxjjrjb < 0 ? 0 : gldxjjrjb; + double jbzj = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(bgldxgzrjb + bgldxzmjb + bgldxjjqjb + gldxgzrjb + gldxzmjb + gldxjjrjb))); + list.add(bgldxgzrjb); + list.add(bgldxzmjb); + list.add(bgldxjjqjb); + list.add(gldxgzrjb); + list.add(gldxzmjb); + list.add(gldxjjrjb); + list.add(jbzj); + + double cc = Util.getDoubleValue(Util.null2String(flowData.get(xm + "|" + syncDate + "|businessLeave"))); + cc = cc < 0 ? 0 : cc; + double gc = Util.getDoubleValue(Util.null2String(flowData.get(xm + "|" + syncDate + "|officialBusiness"))); + gc = gc < 0 ? 0 : gc; + double lq1 = Util.getDoubleValue(recordSet.getString("forgotcheck"), 0); + double lq2 = Util.getDoubleValue(recordSet.getString("forgotBeginWorkCheck"), 0); + double lq = lq1 + lq2; + list.add(cc); + list.add(gc); + list.add(lq); + + values.add(list); + } + // 删除之前同步的数据 + newSql = "delete from " + tableName + " where rq = ?"; + recordSet.executeUpdate(newSql, syncDate); + // 同步新数据到到建模表 + newSql = "insert into " + tableName + "(formmodeid,xm,gs,bm,rq,bc,sbdk1,qdkqjg1,xbdk1,qtkqjg1,sbdk2,qdkqjg2,xbdk2,qtkqjg2,sbdk3,qdkqjg3,xbdk3,qtkqjg3,ycqts,ygzsc,sjcqts,sjgzsc,cd,cdsc,zt,ztsc,kg,kgsc,leaveType_2,leaveType_5,leaveType_6,leaveType_7,leaveType_8,leaveType_9,leaveType_10,leaveType_11,leaveType_12,leaveType_13,leaveType_14,leaveType_15,leaveType_16,leaveType_17,bgldxgzrjb,bgldxzmjb,bgldxjjqjb,gldxgzrjb,gldxzmjb,gldxjjrjb,jbzj,cc,gc,lq) " + + " values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + batchRecordSet.executeBatchSqlNew(newSql, values); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static Map getLeaveInfo(String kqdate, String id, List> allLeaveRules, Map flowData) { + Map map = new HashMap<>(); + for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) { + Map leaveRule = allLeaveRules.get(i); + String flowType = Util.null2String("leaveType_" + leaveRule.get("id")); + String leaveData = Util.null2String(flowData.get(id + "|" + kqdate + "|" + flowType)); + String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id")); + String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + kqdate + "|" + 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) { + kqLog.info("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))); + } + map.put(flowType, flowLeaveData); + } + return map; + } + + public static Map getSignDetailInfo(String resourceId, String kqDate, User user) { + Map data = new HashMap<>(); + Map signStatusInfo = null; + RecordSet rs = new RecordSet(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + try { + String sql = " select kqdate,resourceid,serialid,serialnumber,workbegindate,workbegintime, " + + " workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" + + " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," + + " leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid \n" + + " from kq_format_detail b \n" + + " where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' \n" + + " order by serialnumber \n"; + rs.execute(sql); + while (rs.next()) { + String serialid = Util.null2String(rs.getString("serialid")); + int serialnumber = rs.getInt("serialnumber") + 1; + String workbegindate = Util.null2String(rs.getString("workbegindate")).trim(); + String workbegintime = Util.null2String(rs.getString("workbegintime")).trim(); + String workenddate = Util.null2String(rs.getString("workenddate")).trim(); + String workendtime = Util.null2String(rs.getString("workendtime")).trim(); + String signintime = Util.null2String(rs.getString("signintime")).trim(); + String signouttime = Util.null2String(rs.getString("signouttime")).trim(); + String beLateMins = Util.null2String(rs.getString("beLateMins")).trim(); + String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")).trim(); + String leaveEarlyMins = Util.null2String(rs.getString("leaveEarlyMins")).trim(); + String graveLeaveEarlyMins = Util.null2String(rs.getString("graveLeaveEarlyMins")).trim(); + String absenteeismMins = Util.null2String(rs.getString("absenteeismMins")).trim(); + String forgotCheckMins = Util.null2String(rs.getString("forgotcheckMins")).trim(); + String forgotBeginWorkCheckMins = Util.null2String(rs.getString("forgotBeginWorkCheckMins")).trim(); + String signinid = Util.null2String(rs.getString("signinid")).trim(); + String signoutid = Util.null2String(rs.getString("signoutid")).trim(); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = Util.null2String(rs.getString("leaveInfo")); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + + if (serialid.length() > 0) { + if (workbegintime.length() > 0) { + signStatusInfo = new HashMap<>(); + signStatusInfo.put("workdate", workbegindate); + signStatusInfo.put("worktime", workbegintime); + signStatusInfo.put("beLateMins", beLateMins); + signStatusInfo.put("forgotBeginWorkCheckMins", forgotBeginWorkCheckMins); + signStatusInfo.put("graveBeLateMins", graveBeLateMins); + signStatusInfo.put("absenteeismMins", absenteeismMins); + signStatusInfo.put("leaveMins", leaveMins); + signStatusInfo.put("leaveInfo", leaveInfo); + signStatusInfo.put("evectionMins", evectionMins); + signStatusInfo.put("outMins", outMins); + data.put("signintime" + serialnumber, signintime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signintime); + data.put("signinstatus" + serialnumber, KQReportBiz.getSignStatus(signStatusInfo, user, "on")); + } + + if (workendtime.length() > 0) { + signStatusInfo = new HashMap<>(); + signStatusInfo.put("workdate", workenddate); + signStatusInfo.put("worktime", kqTimesArrayComInfo.turn48to24Time(workendtime)); + signStatusInfo.put("leaveEarlyMins", leaveEarlyMins); + signStatusInfo.put("graveLeaveEarlyMins", graveLeaveEarlyMins); + signStatusInfo.put("forgotCheckMins", forgotCheckMins); + signStatusInfo.put("forgotBeginWorkCheckMins", forgotBeginWorkCheckMins); + signStatusInfo.put("absenteeismMins", absenteeismMins); + signStatusInfo.put("leaveMins", leaveMins); + signStatusInfo.put("leaveInfo", leaveInfo); + signStatusInfo.put("evectionMins", evectionMins); + signStatusInfo.put("outMins", outMins); + data.put("signouttime" + serialnumber, signouttime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signouttime); + data.put("signoutstatus" + serialnumber, KQReportBiz.getSignStatus(signStatusInfo, user, "off")); + } + } else { + signStatusInfo = new HashMap(); + signStatusInfo.put("leaveMins", leaveMins); + signStatusInfo.put("leaveInfo", leaveInfo); + signStatusInfo.put("evectionMins", evectionMins); + signStatusInfo.put("outMins", outMins); + if (signinid.length() > 0) { + data.put("signintime" + serialnumber, signintime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signintime); + data.put("signinstatus" + serialnumber, KQReportBiz.getSignStatus(signStatusInfo, user, "on")); + if (signoutid.length() > 0) { + data.put("signouttime" + serialnumber, signouttime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signouttime); + data.put("signoutstatus" + serialnumber, KQReportBiz.getSignStatus(signStatusInfo, user, "off")); + } + } else { + data.put("signinstatus" + serialnumber, KQReportBiz.getSignStatus(signStatusInfo, user, "on")); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return data; + } + + + /** + * 考勤流程是否能继续提交 + * + * @param request 请求详情 + */ + public String canSubmitWorkflow(RequestInfo request) { + String requestId = request.getRequestid(); + String workflowId = request.getWorkflowid(); + kqLog.info("do canSubmitWorkflow on workflowId:" + workflowId + "|requestId:" + requestId); + if (canContinueWorkflow(workflowId, requestId)) { + return Action.SUCCESS; + } + request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222"); + request.getRequestManager().setMessagecontent("当前日期周期内存在被锁定的考勤数据,请重新选择日期周期!"); + return Action.FAILURE_AND_CONTINUE; + } + + /** + * 考勤流程能否继续提交 + * + * @param workflowId 流程id + * @param requestId 请求id + */ + public boolean canContinueWorkflow(String workflowId, String requestId) { + try { + int requestIdInt = Util.getIntValue(requestId, 0); + String formId = new WorkflowComInfo().getFormId(workflowId); + // 是否是考勤变更流程 + boolean isProcessChange = false; + // 是否是销假流程 + boolean isLeaveBack = false; + List splitBeans = new ArrayList<>(); + RecordSet recordSet = new RecordSet(); + String sql = "select * from kq_att_proc_set where field001 = ? and field002 = ? "; + recordSet.executeQuery(sql, workflowId, formId); + if (recordSet.next()) { + String proc_set_id = recordSet.getString("id"); + String useDetails = recordSet.getString("usedetail"); + int kqType = Util.getIntValue(recordSet.getString("field006")); + Map map = new HashMap<>(); + if (requestIdInt > 0) { + map.put("requestId", "and t.requestId = " + requestIdInt); + } + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + Map sqlMap = kqFlowActiontBiz.handleSql(proc_set_id, useDetails, requestIdInt, kqType, map); + if (kqType == KqSplitFlowTypeEnum.LEAVE.getFlowtype()) { + KQFlowLeaveUtil kqFlowLeaveUtil = new KQFlowLeaveUtil(); + kqFlowLeaveUtil.handleKQLeaveAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowId), requestIdInt, resourceComInfo); + } else if (kqType == KqSplitFlowTypeEnum.EVECTION.getFlowtype()) { + KQFlowEvectionUtil kqFlowEvectionUtil = new KQFlowEvectionUtil(); + kqFlowEvectionUtil.handleKQEvectionAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowId), requestIdInt, resourceComInfo); + } else if (kqType == KqSplitFlowTypeEnum.OUT.getFlowtype()) { + KQFlowOutUtil kqFlowOutUtil = new KQFlowOutUtil(); + kqFlowOutUtil.handleKQOutAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowId), requestIdInt, resourceComInfo); + } else if (kqType == KqSplitFlowTypeEnum.OVERTIME.getFlowtype()) { + KQFlowOvertimeUtil kqFlowOvertimeUtil = new KQFlowOvertimeUtil(); + kqFlowOvertimeUtil.handleKQOvertimeAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowId), requestIdInt, resourceComInfo, ""); + } else if (kqType == KqSplitFlowTypeEnum.CARD.getFlowtype()) { + String[] cardFields = KQAttFlowFieldsSetBiz.cardFields; + RecordSet newRecordSet = new RecordSet(); + if (!sqlMap.isEmpty()) { + for (Map.Entry entry : sqlMap.entrySet()) { + String value = entry.getValue(); + newRecordSet.execute(value); + while (newRecordSet.next()) { + String fDetailSignDate = cardFields[3]; + String signDate = Util.null2s(newRecordSet.getString(fDetailSignDate), ""); + if (this.isLockDate(signDate, signDate)) { + return false; + } + } + } + } + } else if (kqType == KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype()) { + isLeaveBack = true; + KQFlowLeaveBackUtil kqFlowLeaveBackUtil = new KQFlowLeaveBackUtil(); + kqFlowLeaveBackUtil.handleKQLeaveBackAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowId), requestIdInt, resourceComInfo); + } else if (kqType == KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype()) { + isProcessChange = true; + KQFlowProcessChangeUtil kqFlowProcessChangeUtil = new KQFlowProcessChangeUtil(); + kqFlowProcessChangeUtil.handleKQProcessChangeAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowId), requestIdInt, resourceComInfo); + } + } + for (SplitBean splitBean : splitBeans) { + String fromDate = ""; + String toDate = ""; + if (isProcessChange) { + ProcessChangeSplitBean processChangeSplitBean = splitBean.getProcessChangeSplitBean(); + fromDate = processChangeSplitBean.getFromdatedb(); + toDate = processChangeSplitBean.getTodatedb(); + if (this.isLockDate(fromDate, toDate)) { + return false; + } + fromDate = splitBean.getFromdatedb(); + toDate = splitBean.getTodatedb(); + } else if (isLeaveBack) { + String resourceId = splitBean.getResourceId(); + String leaveBackRequestId = splitBean.getLeavebackrequestid(); + sql = "select fromdatedb, todatedb from kq_flow_split_leave where resourceid = ? and requestid = ? group by fromdatedb, todatedb"; + recordSet.executeQuery(sql, resourceId, leaveBackRequestId); + if (recordSet.next()) { + fromDate = Util.null2String(recordSet.getString("fromdatedb")); + toDate = Util.null2String(recordSet.getString("todatedb")); + } + } else { + fromDate = splitBean.getFromdatedb(); + toDate = splitBean.getTodatedb(); + } + if (this.isLockDate(fromDate, toDate)) { + return false; + } + } + } catch (Exception e) { + return false; + } + return true; + } + + /** + * 强制归档 + * + * @param user 用户 + * @param requestParam 请求参数 + */ + public void doForceOver(User user, ReqOperateRequestEntity requestParam) { + int requestId = requestParam.getRequestId(); + Map otherParams = requestParam.getOtherParams(); + PAResponseEntity pAEntity = RequestOperateBiz.verifyBefore(user, requestId, otherParams); + if (pAEntity.getCode() != null) { + return; + } + WfFunctionManageUtil wfFunctionManageUtil = new WfFunctionManageUtil(); + RequestInfoEntity reqEntity = RequestOperateBiz.initRequestInfo(requestParam, user); + int isremark = reqEntity.getIsremark(); + int agentType = Util.getIntValue(Util.null2String(otherParams.get("agenttype"))); + int agentorByAgentId = Util.getIntValue(Util.null2String(otherParams.get("agentorbyagentid"))); + // 流程代理出去,本人提交,需先收回代理 + if (isremark == 2 && agentType == 1 && agentorByAgentId > 0) { + AgentManager agentManager = new AgentManager(user); + agentManager.agentBackRequest(agentorByAgentId, user.getUID(), reqEntity.getWorkflowId() + "", requestParam.getRequestId()); + reqEntity = RequestOperateBiz.initRequestInfo(requestParam, user); + isremark = reqEntity.getIsremark(); + } + int nodeid = Util.getIntValue(reqEntity.getCurrentNodeId()); + int takisremark = reqEntity.getTakisremark(); + HashMap map = wfFunctionManageUtil.wfFunctionManageByNodeid(reqEntity.getWorkflowId(), FreeNodeBiz.isFreeNode(nodeid) ? -9 : nodeid); + WfForceOver wfo = new WfForceOver(); + String ov = (String) map.get("ov"); + boolean hasRight = (isremark == 0 && (takisremark == 0 || takisremark == -1)) && "1".equals(ov) && wfo.isNodeOperator(requestId, user.getUID()) && !reqEntity.getCurrentNodeType().equals("3"); + boolean isMonitor = "1".equals(Util.null2String(otherParams.get("ismonitor"))); + if (!hasRight && isMonitor) { + MonitorDTO monitorInfo = new Monitor().getMonitorInfo(String.valueOf(user.getUID()), reqEntity.getCreatorId(), String.valueOf(reqEntity.getWorkflowId())); + hasRight = monitorInfo.getIsforceover() && !"3".equals(reqEntity.getCurrentNodeType()); + } + if (hasRight) { + ArrayList requestidlist = new ArrayList(); + requestidlist.add("" + requestId); + wfo.setRemark(requestParam.getRemark()); + wfo.doForceOver(requestidlist, null, null, user); + pAEntity.setCode(PAResponseCode.SUCCESS); + String isnew = new BaseBean().getPropValue("WorkflowOvertimeIsNew", "isNew"); + if ("1".equals(isnew)) { + OvertimeBiz.getInstance().cancelOvertimeTask(requestId, Util.getIntValue(reqEntity.getCurrentNodeId()));// 取消超时任务 + } + } else { + pAEntity.setCode(PAResponseCode.NO_PERMISSION); + } + } + + /** + * 同步建模表里面的打卡数据 + */ + public void importData() { + RecordSet rs = new RecordSet(); + String endDateTime = weaver.common.DateUtil.getDate(new Date(), "yyyy-MM-dd HH:mm"); + Calendar calendar = weaver.common.DateUtil.getCalendar(endDateTime); + calendar.add(Calendar.MINUTE, -45); + String startDateTime = weaver.common.DateUtil.getDate(calendar.getTime(), "yyyy-MM-dd HH:mm"); + + KQScheduleSignImport kqScheduleSignImport = new KQScheduleSignImport(); + BatchRecordSet bRs = new BatchRecordSet(); + List> lsParams = new ArrayList<>(); + List params = null; + List> lsDelParams = new ArrayList<>(); + List delParams = null; + List lsFormatData = new ArrayList<>(); + List> lsFormatParams = new ArrayList<>(); + List formatParams = null; + Map> users = kqScheduleSignImport.getUsers(7); + Map loginidMap = users.get("loginidMap"); + Map lastnameMap = users.get("lastnameMap"); + Map workcodeMap = users.get("workcodeMap"); + List keymap = new ArrayList<>(); + List lsImportSetting = new ArrayList<>(); + ImportSetting importSetting = null; + String sql = " select datasourceid, loginid, workcode, lastname, signdate, signtime, tablename, clientaddress,longitude,latitude,addr,memo from HrmScheduleSignSet "; + rs.execute(sql); + while (rs.next()) { + importSetting = new ImportSetting(); + importSetting.setDatasourceid(Util.null2String(rs.getString("datasourceid")).trim()); + importSetting.setLoginid(Util.null2String(rs.getString("loginid")).trim()); + importSetting.setWorkcode(Util.null2String(rs.getString("workcode")).trim()); + importSetting.setLastname(Util.null2String(rs.getString("lastname")).trim()); + importSetting.setSigndate(Util.null2String(rs.getString("signdate")).trim()); + importSetting.setSigntime(Util.null2String(rs.getString("signtime")).trim()); + importSetting.setTablename(Util.null2String(rs.getString("tablename")).trim()); + importSetting.setClientaddress(Util.null2String(rs.getString("clientaddress")).trim()); + importSetting.setLongitude(Util.null2String(rs.getString("longitude")).trim()); + importSetting.setLatitude(Util.null2String(rs.getString("latitude")).trim()); + importSetting.setAddr(Util.null2String(rs.getString("addr")).trim()); + importSetting.setMemo(Util.null2String(rs.getString("memo")).trim()); + lsImportSetting.add(importSetting); + } + List lsKQScheduleSignData = new ArrayList<>(); + KQScheduleSignEntity kqScheduleSignData = null; + for (int i = 0; i < lsImportSetting.size(); i++) { + try { + importSetting = lsImportSetting.get(i); + String datasourceid = importSetting.getDatasourceid(); + String loginid = importSetting.getLoginid(); + String workcode = importSetting.getWorkcode(); + String lastname = importSetting.getLastname(); + String signdate = importSetting.getSigndate(); + String signtime = importSetting.getSigntime(); + String tablename = importSetting.getTablename(); + String clientaddress = importSetting.getClientaddress(); + String longitude = importSetting.getLongitude(); + String latitude = importSetting.getLatitude(); + String addr = importSetting.getAddr(); + String memo = importSetting.getMemo(); + DateFormat df = new SimpleDateFormat("HH:mm:ss"); + if ("sqlserver".equals(rs.getDBType())) { + sql = "select * from " + tablename + " where " + " " + signdate + "+' '+" + signtime + " >= '" + startDateTime + "' and " + signdate + "+' '+" + signtime + " <= '" + endDateTime + "' "; + } else { + sql = "select * from " + tablename + " where " + " concat(" + signdate + ",' '," + signtime + ") >= '" + startDateTime + "' and concat(" + signdate + ",' '," + signtime + ") <= '" + endDateTime + "' "; + } + // 有遇到外部同步,上面的【conn = ds.getConnection();】这个阻塞住,导致下面的同步不执行,下面的用法和集成领导确认 + RecordSetDataSource rsds = new RecordSetDataSource(datasourceid); + rsds.execute(sql); + while (rsds.next()) { + String tmpLoginid = ""; + String tmpWorkcode = ""; + String tmpLastname = ""; + String tmpSigndate = ""; + String tmpSigntime = ""; + String tmpClientaddress = ""; + String tmpLongitude = ""; + String tmpLatitude = ""; + String tmpAddr = ""; + String tmpMemo = ""; + if (loginid.length() > 0) { + tmpLoginid = Util.null2String(rsds.getString(loginid)).trim(); + } + if (workcode.length() > 0) { + tmpWorkcode = Util.null2String(rsds.getString(workcode)).trim(); + } + if (lastname.length() > 0) { + tmpLastname = Util.null2String(rsds.getString(lastname)).trim(); + } + if (signdate.length() > 0) { + tmpSigndate = Util.null2String(rsds.getString(signdate)).trim(); + } + if (clientaddress.length() > 0) { + tmpClientaddress = Util.null2String(rsds.getString(clientaddress)); + } + if (longitude.length() > 0) { + tmpLongitude = Util.null2String(rsds.getString(longitude)).trim(); + } + if (latitude.length() > 0) { + tmpLatitude = Util.null2String(rsds.getString(latitude)).trim(); + } + if (addr.length() > 0) { + tmpAddr = Util.null2String(rsds.getString(addr)).trim(); + } + if (memo.length() > 0) { + tmpMemo = Util.null2String(rsds.getString(memo)).trim(); + } + if (signtime.length() > 0) { + tmpSigntime = Util.null2String(rsds.getString(signtime)).trim(); + // 判断tmpSigntime格式 08:21:11 如果为长格式需要格式化 + if (tmpSigntime.length() > 8) { + // 有遇到signtime格式为hh:mm:ss.0000的格式导致同步不成功 + if (tmpSigntime.length() < 16) { + tmpSigntime = tmpSigntime.substring(0, 8); + } + // 比如上yyyy-mm-dd hh:mm的格式走原逻辑 + else { + tmpSigntime = df.format(Timestamp.valueOf(tmpSigntime)); + } + } else if (tmpSigntime.length() < 8) { + // 不带秒的情况 自动补齐 + tmpSigntime += ":00"; + } + } else { + tmpSigntime = ""; + } + + if (tmpSigndate.length() > 10) { + // 如果时间为长格式,从signdate字段中格式化时间 + if (tmpSigndate.length() == 16) { + //不带秒的情况 自动补齐 + tmpSigntime += ":00"; + } + // 以signtime字段为有限 + if (tmpSigntime.length() == 0) { + tmpSigndate = tmpSigndate.length() > 19 ? tmpSigndate.substring(0, 19) : tmpSigndate; + tmpSigntime = df.format(Timestamp.valueOf(tmpSigndate)); + } + tmpSigndate = Tools.formatDate(tmpSigndate, "yyyy-MM-dd"); + } + // 如果时间格式不带秒补齐 + if (tmpSigntime.length() <= 5) { + tmpSigntime += ":00"; + } + kqScheduleSignData = new KQScheduleSignEntity(); + kqScheduleSignData.setLoginid(tmpLoginid); + kqScheduleSignData.setWorkcode(tmpWorkcode); + kqScheduleSignData.setLastname(tmpLastname); + kqScheduleSignData.setSigndate(tmpSigndate); + kqScheduleSignData.setSigntime(tmpSigntime); + kqScheduleSignData.setClientaddress(tmpClientaddress); + kqScheduleSignData.setLongitude(tmpLongitude); + kqScheduleSignData.setLatitude(tmpLatitude); + kqScheduleSignData.setAddr(tmpAddr); + kqScheduleSignData.setMemo(tmpMemo); + lsKQScheduleSignData.add(kqScheduleSignData); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + List noRepertSynData = new ArrayList<>(); + for (int i = 0; i < lsKQScheduleSignData.size(); i++) { + kqScheduleSignData = lsKQScheduleSignData.get(i); + String tmpLoginid = kqScheduleSignData.getLoginid(); + String tmpWorkcode = kqScheduleSignData.getWorkcode(); + String tmpLastname = kqScheduleSignData.getLastname(); + String tmpSigndate = kqScheduleSignData.getSigndate(); + String tmpSigntime = kqScheduleSignData.getSigntime(); + String tmpClientaddress = kqScheduleSignData.getClientaddress(); + String tmpLongitude = kqScheduleSignData.getLongitude(); + String tmpLatitude = kqScheduleSignData.getLatitude(); + String tmpAddr = kqScheduleSignData.getAddr(); + String tmpMemo = kqScheduleSignData.getMemo(); + int userid = 0; + if (Util.null2String(tmpLoginid).length() > 0) { + userid = weaver.common.StringUtil.parseToInt(loginidMap.get(tmpLoginid), 0); + } + if (userid == 0 && Util.null2String(tmpWorkcode).length() > 0) { + userid = weaver.common.StringUtil.parseToInt(workcodeMap.get(tmpWorkcode), 0); + } + if (userid == 0 && Util.null2String(tmpLastname).length() > 0) { + userid = weaver.common.StringUtil.parseToInt(lastnameMap.get(tmpLastname), 0); + } + if (userid <= 0) { + continue; + } + String dkParamData = userid + "#" + tmpSigndate + "#" + tmpSigntime; + if (noRepertSynData.contains(dkParamData)) { + continue; + } + noRepertSynData.add(dkParamData); + params = new ArrayList<>(); + params.add(userid); + params.add(1); + params.add(tmpSigndate); + params.add(tmpSigntime); + params.add(tmpClientaddress); + params.add(1); + params.add(1); + params.add("OutDataSourceSyn"); + params.add(tmpLongitude); + params.add(tmpLatitude); + params.add(tmpAddr); + params.add(tmpMemo); + lsParams.add(params); + String belongDate = getBelongDate(new User(userid), tmpSigndate, tmpSigntime); + String formatData = userid + "|" + tmpSigndate + "|" + belongDate; + if (!lsFormatData.contains(formatData)) { + lsFormatData.add(formatData); + } + } + Map> overtimeMap = Maps.newHashMap(); + List overtimeList = Lists.newArrayList(); + // 刷新报表数据 + for (int i = 0; i < lsFormatData.size(); i++) { + formatParams = new ArrayList<>(); + String key = lsFormatData.get(i); + String[] formatData = Util.splitString(lsFormatData.get(i), "|"); + String date_1 = weaver.common.DateUtil.addDate(formatData[1], -1); + formatParams.add(formatData[0]); + formatParams.add(date_1); + lsFormatParams.add(formatParams); + formatParams = new ArrayList<>(); + formatParams.add(formatData[0]); + formatParams.add(formatData[1]); + lsFormatParams.add(formatParams); + if (!keymap.contains(key)) { + keymap.add(key); + delParams = new ArrayList<>(); + delParams.add(formatData[0]); + // delParams.add(formatData[1]); + delParams.add(startDateTime + ":00"); + delParams.add(endDateTime + ":00"); + lsDelParams.add(delParams); + } + String resourceId = formatData[0]; + String kqdate = formatData[1]; + String belongDate = formatData[2]; + if (overtimeMap.containsKey(resourceId)) { + List tmp_overtimeList = overtimeMap.get(resourceId); + if (!tmp_overtimeList.contains(kqdate)) { + tmp_overtimeList.add(kqdate); + if (!kqdate.equals(belongDate)) { + tmp_overtimeList.add(belongDate); + } + } + } else { + if (!overtimeList.contains(kqdate)) { + overtimeList.add(kqdate); + if (!kqdate.equals(belongDate)) { + overtimeList.add(belongDate); + } + } + overtimeMap.put(resourceId, overtimeList); + } + } + // 删除本次同步数据 + // sql = " delete from hrmschedulesign where signfrom='OutDataSourceSyn' and userid =? and signdate = ? "; + if ("sqlserver".equals(rs.getDBType())) { + sql = "delete from hrmschedulesign where signfrom = 'OutDataSourceSyn' and userid = ? and signdate + ' ' + signtime >= ? and signdate + ' ' + signtime <= ?"; + } else { + sql = "delete from hrmschedulesign where signfrom = 'OutDataSourceSyn' and userid = ? and concat(signdate,' ',signtime) >= ? and concat(signdate,' ',signtime) <= ?"; + } + bRs.executeBatchSql(sql, lsDelParams); + sql = " insert into HrmScheduleSign (userid, usertype, signdate, signtime, clientaddress, isincom, isimport, signfrom, longitude, latitude, addr,memo) values(?,?,?,?,?,?,?,?,?,?,?,?)"; + bRs.executeBatchSql(sql, lsParams); + new KQFormatBiz().format(lsFormatParams); + // 处理加班生成 + List tasks = new ArrayList<>(); + for (Map.Entry> mme : overtimeMap.entrySet()) { + String resid = mme.getKey(); + List overList = mme.getValue(); + for (String date : overList) { + SplitActionUtil.pushOverTimeTasks(date, date, resid, tasks); + } + } + if (!tasks.isEmpty()) { + KQQueue.writeTasks(tasks); + } + } + + public String getBelongDate(User user, String curDate, String signDateTime) { + String belongDate = curDate; + Map todayLineMap = KQDurationCalculatorUtil.getWorkButton(user, curDate, true); + if (todayLineMap != null) { + List> preInfo = (ArrayList>) todayLineMap.get("pre_signTime"); + if (preInfo != null) { + for (Map entry : preInfo) { + String pre_endtime_across = entry.get("endtime_across"); + String pre_endtime = entry.get("endtime"); + String signEndInfo = "1".equals(pre_endtime_across) ? (curDate + " " + pre_endtime + ":00") : (weaver.common.DateUtil.addDate(curDate, -1) + " " + pre_endtime + ":00"); + String signOutDateTime = signDateTime; + if (signOutDateTime.compareTo(signEndInfo) < 0) { + belongDate = weaver.common.DateUtil.addDate(curDate, -1); + } + } + } + } + return belongDate; + } + + /** + * 线程池执行任务封装 + */ +// public static class RunnableTask implements Runnable { +// +// private final User user; +// +// private final boolean isSyncData; +// +// private final boolean isDoForceOver; +// +// private final String finalFromDate; +// +// private final String finalToDate; +// +// private Map params; +// +// private final List> formatValues; +// +// public RunnableTask(User user, String finalFromDate, String finalToDate, Map params, List> formatValues, boolean isSyncData, boolean isDoForceOver) { +// this.user = user; +// this.finalFromDate = finalFromDate; +// this.finalToDate = finalToDate; +// this.params = params; +// this.formatValues = formatValues; +// this.isSyncData = isSyncData; +// this.isDoForceOver = isDoForceOver; +// } +// +// @Override +// public void run() { +// BaseBean baseBean = new BaseBean(); +// QC2648525Util qc2648525Util = new QC2648525Util(); +// if (formatValues != null && formatValues.size() > 0) { +// long startTime = System.currentTimeMillis(); +// for (List objs : formatValues) { +// String userId = Util.null2String(objs.get(0)); +// String kqDate = Util.null2String(objs.get(1)); +// new KQFormatData().formatKqDate(userId, kqDate); +// } +// baseBean.writeLog("QC2648525 刷新考勤报表耗时:" + ((System.currentTimeMillis() - startTime) / 1000) + "秒"); +// } +// if (isDoForceOver) { +// long startTime = System.currentTimeMillis(); +// qc2648525Util.doForceOver(user); +// baseBean.writeLog("QC2648525 强制归档流程执行耗时:" + ((System.currentTimeMillis() - startTime) / 1000) + "秒"); +// } +// if (isSyncData) { +// long startTime = System.currentTimeMillis(); +// if (params == null || params.isEmpty()) { +// Map datas = new HashMap<>(); +// datas.put("typeselect", "6"); +// datas.put("fromDate", finalFromDate); +// datas.put("toDate", finalToDate); +// datas.put("attendanceSerial", ""); +// datas.put("isFromMyAttendance", "1"); +// params = new HashMap<>(); +// params.put("data", JSONObject.toJSONString(datas)); +// params.put("reportType", "month"); +// } +// qc2648525Util.syncKqData(user, finalFromDate, finalToDate, params); +// baseBean.writeLog("QC2648525 建模数据同步执行耗时:" + ((System.currentTimeMillis() - startTime) / 1000) + "秒"); +// } +// } +// } + + // --- 王宇负责部分 --- + + public static String[] colors = new String[]{"#47A9FC", "#70C06F", "#F6D65C", "#EA744D", "#4EBCCC", "#EA5C85", "#8F72F2", "#7297F2", "#CA4DE4", "#A7CC62"}; + + public static String getKQGroupId(String userId, String workDate, boolean containFixed) { + String groupId = ""; + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + List lsGroupIds = kqGroupMemberComInfo.getKQGroups(userId,workDate); + for (int i = 0; lsGroupIds != null && i < lsGroupIds.size(); i++) { + String tmpGroupId = Util.null2String((String) lsGroupIds.get(i)); + String kqtype = kqGroupComInfo.getKqtype(tmpGroupId); + String validity = kqGroupComInfo.getValidity(tmpGroupId); + String validityfromdate = kqGroupComInfo.getValidityfromdate(tmpGroupId); + String validityenddate = kqGroupComInfo.getValidityenddate(tmpGroupId); + if (validity.equals("1")) { + if (weaver.common.DateUtil.isInDateRange(workDate, validityfromdate, validityenddate)) { + groupId = tmpGroupId; + } else { + continue; + } + } else { + groupId = tmpGroupId; + } + if (groupId.length() > 0) { + if (containFixed && kqtype.equals("2")) { + KQShiftScheduleComInfo kqShiftScheduleComInfo = new KQShiftScheduleComInfo(); + if (Util.null2String(kqShiftScheduleComInfo.getSerialId(userId, workDate)).length() > 0 && Util.null2String(kqShiftScheduleComInfo.getGroupId(userId, workDate)).equals(groupId)) { + break; + } + } else { + break; + } + } + } + return groupId; + } + + /** + * 从考勤报表中获取班次 + * + * @param resourceId 用户 + * @param kqDate 日期 + * @param groupId 原来的groupId + */ + public static String getGroupId(String resourceId, String kqDate, String groupId) { + + String newGroupId = ""; + String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + if (kqDate.compareTo(currentDate) > 0) { + return groupId; + } + RecordSet recordSet = new RecordSet(); + String sql = "select groupid from kq_format_total where resourceid = ? and kqdate = ?"; + recordSet.executeQuery(sql, resourceId, kqDate); + if (recordSet.next()) { + newGroupId = Util.null2String(recordSet.getString("groupid")); + } + return StringUtil.isBlank(newGroupId) ? groupId : newGroupId; + } + + /** + * 前台我的排班颜色添加 + * + * @param user 登录用户 + * @param resourceId 展示的用户id + * @param fromDate 开始日期 + * @param toDate 结束日期 + * @param result 结果集 + */ + public static void getScheduleReportInfo(User user, String resourceId, String fromDate, String toDate, Map result) { + RecordSet recordSet = new RecordSet(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + KQWorkTime kqWorkTime = new KQWorkTime(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + String sql = ""; + Map data = null; + String currentDate = weaver.common.DateUtil.getCurrentDate(); + // 今天之前的日期在考勤报表中查询 + if (fromDate.compareTo(currentDate) <= 0) { + // 结束日期小于当前日期 当前日期=结束日期 + if (toDate.compareTo(currentDate) < 0) { + LocalDate localDate = LocalDate.parse(toDate); + currentDate = formatter.format(localDate); + } + sql = "select kqdate, groupid, serialid from kq_format_total where resourceid = ? and kqdate >= ? and kqdate <= ?"; + recordSet.executeQuery(sql, resourceId, fromDate, currentDate); + while (recordSet.next()) { + String date = Util.null2String(recordSet.getString("kqdate")); + String serialId = Util.null2String(recordSet.getString("serialid")); + String groupId = Util.null2String(recordSet.getString("groupid")); + if (StringUtil.isBlank(serialId)) { + continue; + } + String color = ""; + String kqType = kqGroupComInfo.getKqtype(groupId); + if ("1".equals(kqType)) { + color = getColorBySerialId(kqGroupComInfo, groupId, serialId); + } else if ("2".equals(kqType)) { + color = getColorBySerialId(kqGroupComInfo, groupId, serialId); + } + String serial = shiftManagementToolKit.getShiftOnOffWorkSections(serialId, user.getLanguage()); + data = new HashMap<>(); + data.put("serial", serial); + data.put("bgColor", color); + result.put(date, data); + } + } + // 今天之后的日期 固定班次保持不变,排班在排班表中查询 + currentDate = weaver.common.DateUtil.getCurrentDate(); + + if (toDate.compareTo(currentDate) >= 0) { + + // 开始日期大于当前日期 当前日期=开始日期 + LocalDate localDate; + if (fromDate.compareTo(currentDate) > 0) { + localDate = LocalDate.parse(fromDate); + } else { + localDate = LocalDate.parse(currentDate).plusDays(1); + } + currentDate = formatter.format(localDate); + String kqGroupId = getKQGroupId(resourceId, currentDate, true); + LocalDate startDate = LocalDate.parse(currentDate); + LocalDate endDate = LocalDate.parse(toDate); + KQHolidaySetComInfo kqHolidaySetComInfo = new KQHolidaySetComInfo(); + long sd = startDate.toEpochDay(); + long ed = endDate.toEpochDay(); + long diff = ed - sd; + for (long i = 0; i <= diff; i++) { + LocalDate td = startDate.plusDays(i); + String targetDate = formatter.format(td); + String changeType = kqHolidaySetComInfo.getChangeType(kqGroupId, targetDate); + if ("1".equals(changeType) || "3".equals(changeType)) { + continue; + } + WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceId, targetDate); + String serialId = workTime.getSerialId(); + if (serialId != null) { + data = new HashMap<>(); + String serial = shiftManagementToolKit.getShiftOnOffWorkSections(serialId, user.getLanguage()); + data.put("serial", serial); + data.put("bgColor", "#000"); + result.put(targetDate, data); + } + } + } + } + + public static String getColorBySerialId(KQGroupComInfo kqGroupComInfo, String groupId, String serialId) { + String color = ""; + String serialIds = kqGroupComInfo.getSerialids(groupId); + if (StringUtil.isNotBlank(serialIds)) { + String[] serialArr = serialIds.split(","); + for (int i = 0; i < serialArr.length; i++) { + if (serialArr[i].trim().equals(serialId)) { + color = colors[i]; + break; + } + } + } + return color; + } + + /** + * 星期 + * + * @param date 日期 + */ + public static int getDayOfWeek(String date) { + try { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + // 创建Calendar类实例 + Calendar instance = Calendar.getInstance(); + // 根据指定日期获取周几 + instance.setTime(format.parse(date)); + // 因为数组下标从0开始,而返回的是数组的内容,是数组{1,2,3,4,5,6,7}中用1~7来表示 Saturday->7 + int i = instance.get(Calendar.DAY_OF_WEEK); + if (i >= Calendar.MONDAY && i <= Calendar.FRIDAY) { + i = i - 2; + } else if (i == Calendar.SATURDAY) { + i = 5; + } else if (i == Calendar.SUNDAY) { + i = 6; + } + return i; + } catch (Exception e) { + return -1; + } + } + +} diff --git a/src/com/engine/kq/util/KQTransMethod.java b/src/com/engine/kq/util/KQTransMethod.java new file mode 100644 index 0000000..f7e93c9 --- /dev/null +++ b/src/com/engine/kq/util/KQTransMethod.java @@ -0,0 +1,1668 @@ +package com.engine.kq.util; + +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.biz.*; +import com.google.common.collect.Lists; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +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 weaver.workflow.workflow.WorkflowRequestComInfo; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +/** + * 列表的显示转换方法 + */ +public class KQTransMethod { + + /***************************************假期的相关方法***************************************/ + /** + * 判断假期类型能否进行编辑、删除、查看日志 + * (被流程引用过的假期类型不可删除,新建过假期规则的假期类型不可删除、未启用的假期类型不可编辑) + * + * @param ruleId 假期类型的ID + * @param param canEdit:canDelete:canLog + * @return + */ + public ArrayList getLeaveRulesOperate(String ruleId, String param) { + ArrayList resultList = new ArrayList(); + String[] allParam = param.split(":"); + String canEdit = allParam[0]; + String canDelete = allParam[1]; + String canLog = allParam[2]; + boolean leaveTypeUsed = false; + boolean isEnable = true; + boolean hasLeaveRules = false; + try { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + hasLeaveRules = true; + } + + leaveTypeUsed = KQFlowDataBiz.leaveTypeUsed(ruleId);//判断是否有发起过该请假类型的请假流程 + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + isEnable = rulesComInfo.getIsEnable(ruleId).equals("1");//判断该请假是否启用 + } catch (Exception e) { + e.printStackTrace(); + } + resultList.add(isEnable ? canEdit : "false");//是否可以编辑 + resultList.add((leaveTypeUsed || hasLeaveRules) ? "false" : canDelete);//是否可以删除 + resultList.add(canLog);//是否可以查看日志 + return resultList; + } + + /** + * 判断假期类型是否可以勾选,即是否可以删除 + * (被流程引用过的假期类型不可删除、新建过假期规则的假期类型不可删除) + * + * @param ruleId 假期类型ID + * @return + */ + public String getLeaveRulesCheckbox(String ruleId) { + boolean leaveTypeUsed = false; + boolean hasLeaveRules = false; + try { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + hasLeaveRules = true; + } + + leaveTypeUsed = KQFlowDataBiz.leaveTypeUsed(ruleId);//判断是否有发起过该请假类型的请假流程 + } catch (Exception e) { + e.printStackTrace(); + } + return String.valueOf(!leaveTypeUsed && !hasLeaveRules); + } + + /** + * 获取最小请假单位 + * 1-按天请假 + * 2-按半天请假 + * 3-按小时请假 + * 4-按整天请假 + * + * @param minimumUnit + * @param languageId + * @return + */ + public String getMinimumUnitName4Browser(String minimumUnit, String languageId) { + String minimumUnitName = ""; + int language = Util.getIntValue(languageId, 7); + switch (minimumUnit) { + case "1": + minimumUnitName = SystemEnv.getHtmlLabelName(1925, language); + break; + case "2": + minimumUnitName = SystemEnv.getHtmlLabelName(128559, language); + break; + case "3": + minimumUnitName = SystemEnv.getHtmlLabelName(391, language); + break; + case "4": + minimumUnitName = SystemEnv.getHtmlLabelName(390728, language); + break; + case "5": + minimumUnitName = SystemEnv.getHtmlLabelName(124952, language); + break; + case "6": + minimumUnitName = SystemEnv.getHtmlLabelName(529675, language); + break; + default: + minimumUnitName = ""; + break; + } + return minimumUnitName; + } + + /** + * 获取最小请假单位 + * 1-按天请假 + * 2-按半天请假 + * 3-按小时请假 + * 4-按整天请假 + * + * @param minimumUnit + * @param languageId + * @return + */ + public String getMinimumUnitName(String minimumUnit, String languageId) { + String minimumUnitName = ""; + int language = Util.getIntValue(languageId, 7); + switch (minimumUnit) { + case "1": + minimumUnitName = SystemEnv.getHtmlLabelName(388885, language); + break; + case "2": + minimumUnitName = SystemEnv.getHtmlLabelName(388886, language); + break; + case "3": + minimumUnitName = SystemEnv.getHtmlLabelName(388887, language); + break; + case "4": + minimumUnitName = SystemEnv.getHtmlLabelName(389680, language); + break; + case "5": + minimumUnitName = SystemEnv.getHtmlLabelName(514712, language); + break; + case "6": + minimumUnitName = SystemEnv.getHtmlLabelName(514786, language); + break; + default: + minimumUnitName = ""; + break; + } + return minimumUnitName; + } + + /** + * 计算请假时长方式 + * 1-按工作日计算请假时长 + * 2-按自然日计算请假时长 + * + * @param computingMode + * @param languageId + * @return + */ + public String getComputingModeName(String computingMode, String languageId) { + String computingModeName = ""; + int language = Util.getIntValue(languageId, 7); + switch (computingMode) { + case "1": + computingModeName = SystemEnv.getHtmlLabelName(388889, language); + break; + case "2": + computingModeName = SystemEnv.getHtmlLabelName(388890, language); + break; + default: + computingModeName = ""; + break; + } + return computingModeName; + } + + /** + * 获取余额规则 + * 1-手动发放 + * 2-按司龄自动发放 + * 3-按工龄自动发放 + * 4-每年自动发放固定天数 + * 5-加班时长自动计入余额 + * 6-按工龄+司龄自动发放 + * + * @param distributionMode + * @return + */ + public String getDistributionModName(String distributionMode, String languageId) { + int language = Util.getIntValue(languageId, 7); + + String distributionModeName = ""; + switch (distributionMode) { + case "1": + distributionModeName = SystemEnv.getHtmlLabelName(388947, language); + break; + case "2": + distributionModeName = SystemEnv.getHtmlLabelName(390374, language); + break; + case "3": + distributionModeName = SystemEnv.getHtmlLabelName(388949, language); + break; + case "4": + distributionModeName = SystemEnv.getHtmlLabelName(388950, language); + break; + case "5": + distributionModeName = SystemEnv.getHtmlLabelName(388951, language); + break; + case "6": + distributionModeName = SystemEnv.getHtmlLabelName(390822, language); + break; + case "7": + distributionModeName = SystemEnv.getHtmlLabelName(514025, language); + break; + case "8": + distributionModeName = SystemEnv.getHtmlLabelName(536880, language); + break; + default: + distributionModeName = ""; + break; + } + return distributionModeName; + } + + /** + * 获取应用范围的显示名称 + * + * @param scopeType + * @param languageId + * @return + */ + public String getScopeTypeName(String scopeType, String languageId) { + int language = Util.getIntValue(languageId, 7); + String scopeTypeName = ""; + if (scopeType.equals("0")) { + scopeTypeName = SystemEnv.getHtmlLabelName(140, language); + } else if (scopeType.equals("1")) { + scopeTypeName = SystemEnv.getHtmlLabelName(33553, language); + } else if (scopeType.equals("2")) { + scopeTypeName = SystemEnv.getHtmlLabelName(124, language); + }else if (scopeType.equals("3")) { + scopeTypeName = SystemEnv.getHtmlLabelName(179, language); + } + return scopeTypeName; + } + + /** + * 获取分部的名称 + * + * @param organizationType + * @param organizationId + * @return + */ + public String getOrganizationIdName(String organizationId, String organizationType) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + String showName = ""; + if (organizationType.equals("1")) { + showName = subCompanyComInfo.getSubCompanyname(organizationId); + } + return showName; + } + + /** + * 获取应用范围的显示名称 + * + * @param organizationType + * @param languageId + * @return + */ + public String getOrganizationTypeName(String organizationType, String languageId) { + int language = Util.getIntValue(languageId, 7); + String showName = ""; + if (organizationType.equals("0")) { + showName = SystemEnv.getHtmlLabelName(140, language); + } else { + showName = SystemEnv.getHtmlLabelName(141, language); + } + return showName; + } + + /** + * 获取释放规则的显示名称 + * + * @param releaseRule + * @param languageId + * @return + */ + public String getReleaseRuleName(String releaseRule, String languageId) { + String releaseRuleName = ""; + int language = Util.getIntValue(languageId, 7); + if (releaseRule.equals("0")) { + releaseRuleName = SystemEnv.getHtmlLabelName(32499, language); + } else if (releaseRule.equals("1")) { + releaseRuleName = SystemEnv.getHtmlLabelName(390280, language); + } else if (releaseRule.equals("2")) { + releaseRuleName = SystemEnv.getHtmlLabelName(390281, language); + } + return releaseRuleName; + } + + /** + * 获取有效期规则的显示名称 + * + * @param validityRule + * @param languageId + * @return + */ + public String getValidityRuleShow(String validityRule, String languageId) { + String validityRuleShow = ""; + int language = Util.getIntValue(languageId, 7); + if (validityRule.equals("0")) { + validityRuleShow = SystemEnv.getHtmlLabelName(22135, language); + } else if (validityRule.equals("1")) { + validityRuleShow = SystemEnv.getHtmlLabelName(388953, language); + } else if (validityRule.equals("2")) { + validityRuleShow = SystemEnv.getHtmlLabelName(388954, language); + } else if (validityRule.equals("3")) { + validityRuleShow = SystemEnv.getHtmlLabelName(389739, language); + } else if (validityRule.equals("4")) { + validityRuleShow = SystemEnv.getHtmlLabelName(508428, language); + } else if (validityRule.equals("5")) { + validityRuleShow = SystemEnv.getHtmlLabelName(513525, language); + } else if (validityRule.equals("6")) { + validityRuleShow = SystemEnv.getHtmlLabelName(515135, language); + } else if (validityRule.equals("7")) { + validityRuleShow = SystemEnv.getHtmlLabelName(536941, language); + } + return validityRuleShow; + } + + /** + * 获取是否启用假期余额的显示名称 + * + * @param balanceEnable 是否显示假期余额 + * @param languageId 系统语言 + * @return + */ + public String getBalanceEnableShow(String balanceEnable, String languageId) { + String balanceEnableShow = ""; + try { + int language = Util.getIntValue(languageId, 7); + if (balanceEnable.equals("1")) { + balanceEnableShow = SystemEnv.getHtmlLabelName(18095, language); + } else { + balanceEnableShow = SystemEnv.getHtmlLabelName(32386, language); + } + } catch (Exception e) { + e.printStackTrace(); + } + return balanceEnableShow; + } + + /** + * 获取假期类型的显示名称 + * + * @param typeId 假期类型的ID(对应于数据库表kq_leaveRules的主键ID) + * @param languageId 系统语言 + * @return + */ + public String getLeaveTypesName(String typeId, String languageId) { + String leaveTypesName = ""; + try { + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + leaveTypesName = Util.formatMultiLang(rulesComInfo.getLeaveName(typeId), languageId); + } catch (Exception e) { + e.printStackTrace(); + } + return leaveTypesName; + } + + /***************************************员工假期余额的相关方法***************************************/ + + /** + * 为了前端校验时取值,故将分页控件的值做一下转换显示 + * + * @param value + * @return + */ + public String getOriginalShow(String value) { + BigDecimal bigDecimal = new BigDecimal(Util.null2s(value.trim(), "0")); + return bigDecimal.setScale(2, RoundingMode.HALF_UP).toPlainString(); + } + + public String getChildrenName(String value) { + KQChildrenComInfo kqChildrenComInfo = new KQChildrenComInfo(); + String name = kqChildrenComInfo.getChildrenName(value); + return name; + } + public String getChildrenBirthday(String value,String otherPara) { + KQChildrenComInfo kqChildrenComInfo = new KQChildrenComInfo(); + String birthday = kqChildrenComInfo.getBirthday(otherPara); + return birthday; + } + + /** + * 获取当前可用的假期余额(假期余额基数*释放比例) + * + * @param balanceId 假期余额表的主键ID + * @param otherPara 指定的人员ID+指定的假期规则ID+指定的所属年份+假期基数+是计算法定年假还是计算福利年假('neither'-非混合模式、legal-法定年假、welfare-福利年假) + * @return + */ + public String getCanUseAmount(String balanceId, String otherPara) { + BigDecimal canUseAmount = new BigDecimal(0); + try { + String otherParaArr[] = otherPara.split("\\+", 5); + String resourceId = otherParaArr[0]; + String leaveRulesId = otherParaArr[1]; + String belongYear = otherParaArr[2]; + BigDecimal baseAmount = new BigDecimal(Util.null2s(otherParaArr[3].trim(), "0")); + String legalOrWelfare = Util.null2String(otherParaArr[4]); + + /*获取当前日期*/ + String date = DateUtil.getCurrentDate(); + + canUseAmount = KQBalanceOfLeaveBiz.getCanUseAmount(resourceId, leaveRulesId, belongYear, baseAmount, legalOrWelfare, date); + } catch (Exception e) { + e.printStackTrace(); + } + return canUseAmount.setScale(2, RoundingMode.HALF_UP).toPlainString(); + } + + /** + * 获取剩余的假期余额(假期余额基数*释放比例+额外余额-已用余额) + * + * @param balanceId 假期余额表的主键ID + * @param otherPara 指定的人员ID+指定的假期规则ID+指定的所属年份+假期基数+额外假期余额+已休假期余额+是计算法定年假还是计算福利年假(neither-非混合模式、legal-法定年假、welfare-福利年假) + * @return + */ + public String getRestAmount(String balanceId, String otherPara) { + String restAmount = "0.00"; + try { + String otherParaArr[] = otherPara.split("\\+", 7); + String resourceId = otherParaArr[0]; + String leaveRulesId = otherParaArr[1]; + String belongYear = otherParaArr[2]; + double baseAmount = Util.getDoubleValue(otherParaArr[3], 0.00); + double extraAmount = Util.getDoubleValue(otherParaArr[4], 0.00); + double usedAmount = Util.getDoubleValue(otherParaArr[5], 0.00); + String legalOrWelfare = Util.null2s(otherParaArr[6], ""); + + String str = resourceId + "+" + leaveRulesId + "+" + belongYear + "+" + baseAmount + "+" + legalOrWelfare; + double canUseAmount = Util.getDoubleValue(getCanUseAmount(balanceId, str), 0.00); + + restAmount = String.format("%.2f", canUseAmount + extraAmount - usedAmount); + } catch (Exception e) { + e.printStackTrace(); + } + return restAmount; + } + + /** + * 判断假期余额是否有效 + * + * @param leaveRulesId + * @param otherParams + * @return + */ + public String getBalanceStatusShow(String leaveRulesId, String otherParams) { + String statusShow = ""; + try { + String resourceId = otherParams.split("\\+", 5)[0]; + String belongYear = otherParams.split("\\+", 5)[1]; + String languageId = otherParams.split("\\+", 5)[2]; + String effectiveDate = otherParams.split("\\+", 5)[3]; + String expirationDate = otherParams.split("\\+", 5)[4]; + + /*获取今天的日期、此刻的时间*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + boolean status = KQBalanceOfLeaveBiz.getBalanceStatus(leaveRulesId, resourceId, belongYear, currentDate, effectiveDate, expirationDate); + if (status) { + statusShow = SystemEnv.getHtmlLabelName(2246, Util.getIntValue(languageId, 7)); + } else { + statusShow = SystemEnv.getHtmlLabelName(2245, Util.getIntValue(languageId, 7)); + } + } catch (Exception e) { + e.printStackTrace(); + } + return statusShow; + } + + public String getTotalAmountShow(String baseAmount, String otherParams) { + String extraAmount = otherParams; + BigDecimal _baseAmount = new BigDecimal(Util.null2s(baseAmount.trim(), "0")); + BigDecimal _extraAmount = new BigDecimal(Util.null2s(extraAmount.trim(), "0")); + BigDecimal _totalAmount = _baseAmount.add(_extraAmount); + String totalAmount = _totalAmount.setScale(2, RoundingMode.HALF_UP).toPlainString(); + return totalAmount; + } + + public String getTiaoxiuamountShow(String tiaoxiuamount) { + BigDecimal _tiaoxiuamount = new BigDecimal(Util.null2s(tiaoxiuamount, "0")); + String totalAmount = _tiaoxiuamount.setScale(2, RoundingMode.HALF_UP).toPlainString(); + return totalAmount; + } + + + public String getChangeType(String changetype, String language) { + String value = ""; + String t_changetype = Util.null2s(changetype, "0"); + if("0".equals(t_changetype) || "".equals(t_changetype)){ + value = ""; + }else if("1".equals(t_changetype)){ + value = SystemEnv.getHtmlLabelName(28386, Util.getIntValue(language,7)); + }else if("2".equals(t_changetype)){ + value = SystemEnv.getHtmlLabelName(28387, Util.getIntValue(language,7)); + }else if("3".equals(t_changetype)){ + value = SystemEnv.getHtmlLabelName(458, Util.getIntValue(language,7)); + } + return value; + } + + /** + * 获取已经失效的调休值(针对单条记录而言的,不是汇总的) + * + * @param invalidAmount + * @param otherParams + * @return + */ + public String getInvalidAmountShow(String invalidAmount, String otherParams) { + /*获取当前日期,当前时间*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); +// tiaoxiuamount + String[] otherParamArr = otherParams.split("\\+", 5); + BigDecimal baseAmount = new BigDecimal(Util.null2s(otherParamArr[0].trim(), "0"));//基数 + BigDecimal extraAmount = new BigDecimal(Util.null2s(otherParamArr[1].trim(), "0"));//额外 + BigDecimal tiaoxiuAmount = new BigDecimal(Util.null2s(otherParamArr[4].trim(), "0"));//加班生成的调休 + BigDecimal totalAmount = baseAmount.add(extraAmount).add(tiaoxiuAmount); + BigDecimal usedAmount = new BigDecimal(Util.null2s(otherParamArr[2].trim(), "0"));//已休 + String expirationDate = Util.null2String(otherParamArr[3]).trim(); + if ("".equals(expirationDate) || expirationDate.compareTo(currentDate) >= 0) { + invalidAmount = "0.00"; + } else { + invalidAmount = totalAmount.subtract(usedAmount).setScale(2, RoundingMode.HALF_UP).toPlainString(); + } + + return invalidAmount; + } + + /** + * 获取剩余的调休值(针对单条记录而言的,不是汇总的) + * + * @param restAmount + * @param otherParam + * @return + */ + public String getRestAmountShow(String restAmount, String otherParam) { + /*获取当前日期,当前时间*/ + Calendar today = Calendar.getInstance(); + String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + String[] otherParamArr = otherParam.split("\\+", 5); + BigDecimal baseAmount = new BigDecimal(Util.null2s(otherParamArr[0].trim(), "0"));//基数 + BigDecimal extraAmount = new BigDecimal(Util.null2s(otherParamArr[1].trim(), "0"));//额外 + BigDecimal usedAmount = new BigDecimal(Util.null2s(otherParamArr[2].trim(), "0"));//已休 + BigDecimal tiaoxiuamount = new BigDecimal(Util.null2s(otherParamArr[4].trim(), "0"));//加班生成调休 + BigDecimal totalAmount = baseAmount.add(extraAmount).add(tiaoxiuamount); + String expirationDate = Util.null2String(otherParamArr[3]).trim(); + if ("".equals(expirationDate) || expirationDate.compareTo(currentDate) >= 0) { + restAmount = totalAmount.subtract(usedAmount).setScale(2, RoundingMode.HALF_UP).toPlainString(); + } else { + restAmount = "0.00"; + } + + return restAmount; + } + + /** + * 获取加班类型 + * + * @param overtimeType + * @param language + * @return + */ + public String getOvertimeTypeShow(String overtimeType, String language) { + if (overtimeType.equals("3")) { + //打卡生成的调休 + return SystemEnv.getHtmlLabelName(509982, Util.getIntValue(language, 7)); + } else if (overtimeType.equals("4")) { + //加班流程生成的调休 + return SystemEnv.getHtmlLabelName(509981, Util.getIntValue(language, 7)); + } else if (overtimeType.equals("7")) { + //Excel导入生成的调休 + return SystemEnv.getHtmlLabelName(509980, Util.getIntValue(language, 7)); + } else { + //原有的调休 + return SystemEnv.getHtmlLabelName(509983, Util.getIntValue(language, 7)); + } + } + + public String getAllTotalAmount(String allTotalAmount, String otherParams) { + String[] otherParamArr = otherParams.split("\\+", 6); + BigDecimal allBaseAmountB = new BigDecimal(Util.null2s(otherParamArr[0].trim(), "0")); + BigDecimal allExtraAmountB = new BigDecimal(Util.null2s(otherParamArr[1].trim(), "0")); + BigDecimal allBaseAmountC = new BigDecimal(Util.null2s(otherParamArr[2].trim(), "0")); + BigDecimal allExtraAmountC = new BigDecimal(Util.null2s(otherParamArr[3].trim(), "0")); + BigDecimal alltiaoxiuamountB = new BigDecimal(Util.null2s(otherParamArr[4].trim(), "0")); + BigDecimal alltiaoxiuamountC = new BigDecimal(Util.null2s(otherParamArr[5].trim(), "0")); + allTotalAmount = allBaseAmountB.add(allExtraAmountB).add(allBaseAmountC).add(allExtraAmountC) + .add(alltiaoxiuamountB).add(alltiaoxiuamountC).setScale(2, RoundingMode.HALF_UP).toPlainString(); + return allTotalAmount; + } + public String getAllExtraAmount(String allExtraAmount, String otherParams) { + String[] otherParamArr = otherParams.split("\\+", 2); + BigDecimal allExtraAmountB = new BigDecimal(Util.null2s(otherParamArr[0].trim(), "0")); + BigDecimal allExtraAmountC = new BigDecimal(Util.null2s(otherParamArr[1].trim(), "0")); + allExtraAmount = allExtraAmountB.add(allExtraAmountC).setScale(2, RoundingMode.HALF_UP).toPlainString(); + return allExtraAmount; + } + public String getAllBaseAmount(String allBaseBeanAmount, String otherParams) { + String[] otherParamArr = otherParams.split("\\+", 2); + BigDecimal allBaseAmountB = new BigDecimal(Util.null2s(otherParamArr[0].trim(), "0")); + BigDecimal allBaseAmountC = new BigDecimal(Util.null2s(otherParamArr[1].trim(), "0")); + allBaseBeanAmount = allBaseAmountB.add(allBaseAmountC).setScale(2, RoundingMode.HALF_UP).toPlainString(); + return allBaseBeanAmount; + } + + public String getAllUsedAmount(String allUsedAmount, String otherParams) { + String[] otherParamArr = otherParams.split("\\+", 2); + BigDecimal allUsedAmountB = new BigDecimal(Util.null2s(otherParamArr[0].trim(), "0")); + BigDecimal allUsedAmountC = new BigDecimal(Util.null2s(otherParamArr[1].trim(), "0")); + allUsedAmount = allUsedAmountB.add(allUsedAmountC).setScale(2, RoundingMode.HALF_UP).toString(); + return allUsedAmount; + } + + public String getAllInvalidAmount(String allInvalidAmount, String otherParams) { + String[] otherParamArr = otherParams.split("\\+", 4); + BigDecimal allBaseAmountC = new BigDecimal(Util.null2s(otherParamArr[0].trim(), "0")); + BigDecimal allExtraAmountC = new BigDecimal(Util.null2s(otherParamArr[1].trim(), "0")); + BigDecimal alltiaoxiuAmountC = new BigDecimal(Util.null2s(otherParamArr[3].trim(), "0")); + BigDecimal allUsedAmountC = new BigDecimal(Util.null2s(otherParamArr[2].trim(), "0")); + allInvalidAmount = allBaseAmountC.add(allExtraAmountC).add(alltiaoxiuAmountC).subtract(allUsedAmountC).setScale(2, RoundingMode.HALF_UP).toPlainString(); + return allInvalidAmount; + } + + public String getAllRestAmount(String allRestAmount, String otherParams) { + String[] otherParamArr = otherParams.split("\\+", 4); + BigDecimal allBaseAmountB = new BigDecimal(Util.null2s(otherParamArr[0].trim(), "0")); + BigDecimal allExtraAmountB = new BigDecimal(Util.null2s(otherParamArr[1].trim(), "0")); + BigDecimal allUsedAmountB = new BigDecimal(Util.null2s(otherParamArr[2].trim(), "0")); + BigDecimal alltiaoxiuamountB = new BigDecimal(Util.null2s(otherParamArr[3].trim(), "0")); + allRestAmount = allBaseAmountB.add(allExtraAmountB).add(alltiaoxiuamountB).subtract(allUsedAmountB).setScale(2, RoundingMode.HALF_UP).toPlainString(); + return allRestAmount; + } + + /** + * 获取明细列的转换显示 + * + * @param detaiShow + * @param language + * @return + */ + public String getDetailShow(String detaiShow, String language) { + return SystemEnv.getHtmlLabelName(17463, Util.getIntValue(language, 7)); + } + + /** + * 获取有效期的显示 + * + * @param expirationDate + * @param language + * @return + */ + public String getExpirationDateShow(String expirationDate, String language) { + String expirationDateShow = ""; + if ("2222-12-31".equals(expirationDate)) { + expirationDateShow = SystemEnv.getHtmlLabelName(10000846, Util.getIntValue(Util.getIntValue(language,7))); + } else { + expirationDateShow = expirationDate; + } + return expirationDateShow; + } + /** + * 获取育儿假有效期的显示 + * + * @param expirationDate + * @param otherParam + * @return + */ + public String getExpirationDateShowP(String expirationDate, String otherParam) { + String expirationDateShow = ""; + if ("".equals(expirationDate)) { + try { + String[] otherParamArr = otherParam.split("\\+", 3); + String ruleId = Util.null2s(otherParamArr[0].trim(), "0");//假期类型id + String resourceId = Util.null2s(otherParamArr[1].trim(), "0");//人员id + String belongYear = Util.null2s(otherParamArr[2].trim(), "0");//所属年份 + //人力资源缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + //分部ID + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + //假期规则缓存类 + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + //有效期规则:0-不限制、1-按自然年失效、2-按入职日期起12个月、3-自定义次年失效日期、4-按天数失效、5-按季度失效、6-按月数失效 + int validityRule = Util.getIntValue(detailComInfo.getValidityRule(ruleId, subcompanyId, departmentId, resourceId), 0); + int yearsOld = StringUtil.parseToInt(detailComInfo.getYearsOld(ruleId, subcompanyId, departmentId, resourceId), 0); + //自定义有效天数([validityRule=4]时有效) + if (validityRule == 0) { + return SystemEnv.getHtmlLabelName(10000846, weaver.general.ThreadVarLanguage.getLang()); + } else { + ArrayList listDates = KQBalanceOfLeaveBiz.getParentalLeaveDate(resourceId); + for (int i = 0; i < listDates.size(); i++) { + String dateOfBirth = listDates.get(i); + String baseAmountReleaseDate = belongYear + dateOfBirth.substring(4); + int ageLimit = KQBalanceOfLeaveBiz.getAgeLimit(dateOfBirth, baseAmountReleaseDate); + if (ageLimit >= 0 && ageLimit <= yearsOld-1) { + expirationDate = (Util.getIntValue(belongYear) + 1) + dateOfBirth.substring(4); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + expirationDateShow = expirationDate; + + return expirationDateShow; + } + /** + * 获取育儿假发放日期的显示 + * + * @param effectiveDate + * @param otherParam + * @return + */ + public String getEffectiveDateShowP(String effectiveDate, String otherParam) { + new BaseBean().writeLog("getEffectiveDateShowP>getEffectiveDateShowP="+effectiveDate+ + ">otherParam="+otherParam); + String expirationDateShow = ""; + if ("".equals(effectiveDate)) { + try { + String[] otherParamArr = otherParam.split("\\+", 3); + String ruleId = Util.null2s(otherParamArr[0].trim(), "0");//假期类型id + String resourceId = Util.null2s(otherParamArr[1].trim(), "0");//人员id + String belongYear = Util.null2s(otherParamArr[2].trim(), "0");//所属年份 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + int yearsOld = StringUtil.parseToInt(detailComInfo.getYearsOld(ruleId, subcompanyId, departmentId, resourceId), 0); + ArrayList listDates = KQBalanceOfLeaveBiz.getParentalLeaveDate(resourceId); + for (int i = 0; i < listDates.size(); i++) { + String dateOfBirth = listDates.get(i); + String baseAmountReleaseDate = belongYear + dateOfBirth.substring(4); + int ageLimit = KQBalanceOfLeaveBiz.getAgeLimit(dateOfBirth, baseAmountReleaseDate); + if (ageLimit >= 0 && ageLimit <= yearsOld - 1) { + effectiveDate = dateOfBirth; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + expirationDateShow = effectiveDate; + + return expirationDateShow; + } + /** + * 获取员工假期余额明细操作日志中对象的显示名称 + * + * @param id + * @param params + * @return + */ + public String getTargetName4BalanceDetail(String id, String params) { + String targetName = ""; + try { + String[] paramArr = params.split("\\+"); + String resourceId = paramArr[0]; + String belongYear = paramArr[1]; + String belongMonth = paramArr[2]; + String childId = paramArr[3]; + String languageId = paramArr[4]; + + //人力资源缓存类 + ResourceComInfo resourceComInfo = new ResourceComInfo(); + if(StringUtils.isNotBlank(belongMonth)||childId.length()>0){ + String lastName = Util.formatMultiLang(resourceComInfo.getResourcename(resourceId), languageId); + String childName = new KQChildrenComInfo().getChildrenName(childId); + targetName = SystemEnv.getHtmlLabelName(547704, Util.getIntValue(languageId, 7)); + targetName = targetName.replace("${lastName}", lastName).replace("${belongYear}", belongYear).replace("${belongMonth}", childName).replace("${ID}", id); + }else { + String lastName = Util.formatMultiLang(resourceComInfo.getResourcename(resourceId), languageId); + targetName = SystemEnv.getHtmlLabelName(512690, Util.getIntValue(languageId, 7)); + targetName = targetName.replace("${lastName}", lastName).replace("${belongYear}", belongYear).replace("${belongMonth}", belongMonth).replace("${ID}", id); + } + } catch (Exception e) { + e.printStackTrace(); + } + return targetName; + } + + /** + * 员工假期余额的右键日志对象名称 + * + * @param id + * @param otherParams + * @return + */ + public String getTargetName4Balance(String id, String otherParams) { + String targetName = ""; + try { + String[] otherParaArr = otherParams.split("\\+"); + String resourceId = otherParaArr[0]; + String leaveRulesId = otherParaArr[1]; + + ResourceComInfo resourceComInfo = new ResourceComInfo(); + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + String lastName = resourceComInfo.getResourcename(resourceId); + String ruleName = rulesComInfo.getLeaveName(leaveRulesId); + targetName = lastName + "-" + ruleName; + } catch (Exception e) { + e.printStackTrace(); + } + return targetName; + } + + /***************************************加班的相关方法***************************************/ + + /** + * 获取加班规则的具体的规则内容 + * + * @param ruleId 加班规则的ID + * @return + */ + public String getRuleContent(String ruleId, String languageId) { + if (ruleId.equals("")) { + return ""; + } + int language = Util.getIntValue(languageId, 7); + /*需要显示的内容*/ + String resultStr = ""; + /*日期类型:1-工作日、2-周末、3-节假日*/ + int dayType = 0; + /*是否允许加班:0-不允许、1-允许*/ + int overtimeEnable = 0; + /*加班方式:1-需审批,以审批单为准、2-需审批,以打卡为准,但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/ + int computingMode = 0; + List dayTypeList = Lists.newArrayList(); + String sql = "select * from kq_OvertimeRulesDetail where ruleId=" + ruleId + " order by id"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + dayType = recordSet.getInt("dayType"); + overtimeEnable = recordSet.getInt("overtimeEnable"); + computingMode = recordSet.getInt("computingMode"); + + if(dayTypeList.contains((""+dayType))){ + continue; + }else{ + dayTypeList.add((""+dayType)); + } + + if (dayType == 2) {//工作日 + resultStr += SystemEnv.getHtmlLabelName(28387, language) + ":"; + if (overtimeEnable == 0) { + resultStr += SystemEnv.getHtmlLabelName(389562, language);//不允许加班 + } else if (computingMode == 1) { + resultStr += SystemEnv.getHtmlLabelName(500382, language);//需审批,以加班流程为准 + } else if (computingMode == 2) { + resultStr += SystemEnv.getHtmlLabelName(500383, language);//需审批,以打卡为准,但是不能超过加班流程时长 + } else if (computingMode == 3) { + resultStr += SystemEnv.getHtmlLabelName(390837, language);//无需审批,根据打卡时间计算加班时长 + } else if (computingMode == 4) { + resultStr += SystemEnv.getHtmlLabelName(524827, language);//流程和打卡取交集 + } + } else if (dayType == 3) {//休息日 + resultStr += "
" + SystemEnv.getHtmlLabelName(458, language) + ":"; + if (overtimeEnable == 0) { + resultStr += SystemEnv.getHtmlLabelName(389562, language);//不允许加班 + } else if (computingMode == 1) { + resultStr += SystemEnv.getHtmlLabelName(500382, language);//需审批,以加班流程为准 + } else if (computingMode == 2) { + resultStr += SystemEnv.getHtmlLabelName(500383, language);//需审批,以打卡为准,但是不能超过加班流程时长 + } else if (computingMode == 3) { + resultStr += SystemEnv.getHtmlLabelName(390837, language);//无需审批,根据打卡时间计算加班时长 + } else if (computingMode == 4) { + resultStr += SystemEnv.getHtmlLabelName(524827, language);//流程和打卡取交集 + } + } else if (dayType == 1) {//节假日 + resultStr += "
" + SystemEnv.getHtmlLabelName(28386, language) + ":"; + if (overtimeEnable == 0) { + resultStr += SystemEnv.getHtmlLabelName(389562, language);//不允许加班 + } else if (computingMode == 1) { + resultStr += SystemEnv.getHtmlLabelName(500382, language);//需审批,以加班流程为准 + } else if (computingMode == 2) { + resultStr += SystemEnv.getHtmlLabelName(500383, language);//需审批,以打卡为准,但是不能超过加班流程时长 + } else if (computingMode == 3) { + resultStr += SystemEnv.getHtmlLabelName(390837, language);//无需审批,根据打卡时间计算加班时长 + } else if (computingMode == 4) { + resultStr += SystemEnv.getHtmlLabelName(524827, language);//流程和打卡取交集 + } + } + } + System.out.println("getRuleContent resultStr:::"+resultStr); + return resultStr; + } + + /** + * 获取加班规则的应用范围列的显示名称 + * + * @param groupIds + * @param languageId + * @return + */ + public String getGroupName(String groupIds, String languageId) { + String groupName = ""; + int language = Util.getIntValue(languageId, 7); + if (groupIds.equals("")) { + groupName = SystemEnv.getHtmlLabelName(165, language); + return groupName; + } + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + int count = 0; + String[] groupIdArr = groupIds.split(","); + for (int i = 0; i < groupIdArr.length; i++) { + String groupId = groupIdArr[i]; + String isDel = kqGroupComInfo.getIsdelete(groupId); + if("1".equals(isDel)){ + continue; + } + if(groupName.length() == 0){ + groupName = kqGroupComInfo.getGroupname(groupId); + } + count++; + } + + if (count > 1) { + groupName = SystemEnv.getHtmlLabelName(516131, language).replace("{groupname}", groupName).replace("{count}", "" + count); + } + return groupName; + } + + /** + * 获取加班规则的班次的显示名称 + * + * @param oId 加班规则id + * @param languageId + * @return + */ + public String getShifNames(String oId, String languageId) { + RecordSet recordSet = new RecordSet(); + int count = 0; + String firstShiftName = ""; + String shiftName = ""; + String sql = "select * from kq_shiftmanagement where (isdelete is null or isdelete <> '1') and overtime_rule_id = "+oId; + recordSet.executeQuery(sql); + while (recordSet.next()){ + firstShiftName = recordSet.getString("serial"); + shiftName += ","+recordSet.getString("serial"); + count++; + } + int language = Util.getIntValue(languageId, 7); + if (count == 0) { + shiftName = SystemEnv.getHtmlLabelName(165, language); + return shiftName; + } + if (count > 1) { + shiftName = shiftName.substring(1); + shiftName = SystemEnv.getHtmlLabelName(546279, language).replace("{shiftname}", shiftName).replace("{count}", "" + count); + }else{ + shiftName = firstShiftName; + } + return shiftName; + } + + /** + * 获取加班计算单位的日志的对象名 + * + * @param targetId + * @param otherParams + * @return + */ + public String getTargetName4OvertimeUnit(String targetId, String otherParams) { + String targetName = ""; + String languageId = otherParams.split("\\+")[0]; + targetName = SystemEnv.getHtmlLabelName(505608, Util.getIntValue(languageId, 7)); + return targetName; + } + + + /***************************************节假日设置的相关方法***************************************/ + + /** + * 根据changeType获取显示名 + * + * @param changeType + * @return + */ + public String getChangeTypeName(String changeType, String languageId) { + int language = Util.getIntValue(languageId, 7); + String changeTypeName = ""; + if (changeType.equals("1")) { + changeTypeName = SystemEnv.getHtmlLabelName(16478, language); + } else if (changeType.equals("2")) { + changeTypeName = SystemEnv.getHtmlLabelName(16751, language); + } else if (changeType.equals("3")) { + changeTypeName = SystemEnv.getHtmlLabelName(16752, language); + } + return changeTypeName; + } + + /** + * 获取对应工作日的显示名称 + * + * @param relatedDay 对应工作日:0-星期一、1-星期二、2-星期三、3-星期四、4-星期五、5-星期六、6-星期日 + * @return + */ + public String getRelatedDayName(String relatedDay, String languageId) { + String relatedDayName = ""; + int language = Util.getIntValue(languageId, 7); + switch (relatedDay) { + case "6": + relatedDayName = SystemEnv.getHtmlLabelName(398, language); + break; + case "0": + relatedDayName = SystemEnv.getHtmlLabelName(392, language); + break; + case "1": + relatedDayName = SystemEnv.getHtmlLabelName(393, language); + break; + case "2": + relatedDayName = SystemEnv.getHtmlLabelName(394, language); + break; + case "3": + relatedDayName = SystemEnv.getHtmlLabelName(395, language); + break; + case "4": + relatedDayName = SystemEnv.getHtmlLabelName(396, language); + break; + case "5": + relatedDayName = SystemEnv.getHtmlLabelName(397, language); + break; + default: + relatedDayName = ""; + break; + } + return relatedDayName; + } + + /** + * 获取节假日设置的日志的对象名 + * + * @param targetId + * @param otherParams + * @return + */ + public String getTargetName4HolidaySet(String targetId, String otherParams) { + String targetName = ""; + try { + String groupId = otherParams.split("\\+")[0]; + String holidayDate = otherParams.split("\\+")[1]; + String languageId = otherParams.split("\\+")[2]; + + KQGroupComInfo groupComInfo = new KQGroupComInfo(); + String groupName = Util.formatMultiLang(groupComInfo.getGroupname(groupId), languageId); + targetName = groupName + " " + holidayDate; + } catch (Exception e) { + e.printStackTrace(); + } + return targetName; + } + + /***************************************原始打卡记录的相关方法***************************************/ + + /** + * 获取考勤日期显示 + * + * @param belongDate + * @param languageId + * @return + */ + public String getBelongDateShow(String belongDate, String languageId) { + String belongDateShow = belongDate + " "; + int index = DateUtil.getWeek(belongDate); + if (index == 1) { + belongDateShow += getRelatedDayName("0", languageId); + } else if (index == 2) { + belongDateShow += getRelatedDayName("1", languageId); + } else if (index == 3) { + belongDateShow += getRelatedDayName("2", languageId); + } else if (index == 4) { + belongDateShow += getRelatedDayName("3", languageId); + } else if (index == 5) { + belongDateShow += getRelatedDayName("4", languageId); + } else if (index == 6) { + belongDateShow += getRelatedDayName("5", languageId); + } else if (index == 7) { + belongDateShow += getRelatedDayName("6", languageId); + } + return belongDateShow; + } + + /** + * 获取考勤时间显示 + * + * @param belongTime + * @param belongDate + * @return + */ + public String getBelongTimeShow(String belongTime, String belongDate, String languageId) { + String belongTimeShow = belongDate + " " + new KQTimesArrayComInfo().turn48to24Time(belongTime); + int language = Util.getIntValue(languageId, 7); + if (belongTime.equals("free")) { + belongTimeShow = belongDate + " " + SystemEnv.getHtmlLabelName(500375, language); + } + return belongTimeShow; + } + + /** + * 获取打卡时间显示 + * + * @param signDate + * @param signTime + * @return + */ + public String getSignDateShow(String signDate, String signTime) { + String tmpsignDate = signDate.replaceAll("-", "/"); + return tmpsignDate + " " + signTime; + } + + public String getSignDateShowNew(String signDate, String signTime) { + String tmpsignDate = signDate.replaceAll("-", "/"); + return tmpsignDate + " " + signTime; + } + + /** + * 获取原始打卡记录的数据来源列的显示名称 + * + * @param signFrom + * @return + */ + public String getSignFromShow(String signFrom, String languageId) { + String signFromShow = ""; + int language = Util.getIntValue(languageId, 7); + if (signFrom.equalsIgnoreCase("e9pc")) { + signFromShow = SystemEnv.getHtmlLabelName(503612, language); + } else if (signFrom.equalsIgnoreCase("e9mobile")) { + signFromShow = SystemEnv.getHtmlLabelName(503613, language); + } else if (signFrom.equalsIgnoreCase("e9e")) { + signFromShow = SystemEnv.getHtmlLabelName(503614, language); + } else if (signFrom.equalsIgnoreCase("e9ewx")) { + signFromShow = SystemEnv.getHtmlLabelName(503615, language); + } else if (signFrom.startsWith("card")) { + signFromShow = SystemEnv.getHtmlLabelName(503616, language); + } else if (signFrom.equalsIgnoreCase("e9_mobile_out")) { + signFromShow = SystemEnv.getHtmlLabelName(82634, language); + } else if (signFrom.equalsIgnoreCase("importExcel")) { + signFromShow = SystemEnv.getHtmlLabelName(503617, language); + } else if (signFrom.equalsIgnoreCase("EMSyn")) { + signFromShow = SystemEnv.getHtmlLabelName(503618, language); + }else if (signFrom.equalsIgnoreCase("EMSyn_out")) { + signFromShow = SystemEnv.getHtmlLabelName(517845, language); + } else if (signFrom.equalsIgnoreCase("OutDataSourceSyn")) { + signFromShow = SystemEnv.getHtmlLabelName(503619, language); + } else if (signFrom.equalsIgnoreCase("DingTalk")) { + signFromShow = SystemEnv.getHtmlLabelName(506318, language); + } else if (signFrom.equalsIgnoreCase("DingTalk_out")) { + signFromShow = SystemEnv.getHtmlLabelName(506319, language); + } else if (signFrom.equalsIgnoreCase("Wechat_out")) { + signFromShow = SystemEnv.getHtmlLabelName(506652, language); + } else if (signFrom.equalsIgnoreCase("Wechat")) { + signFromShow = SystemEnv.getHtmlLabelName(506653, language); + } else if (signFrom.equalsIgnoreCase("auto_card")) { + signFromShow = SystemEnv.getHtmlLabelName(521191, language); + } else if (signFrom.equalsIgnoreCase("xiaoe")) { + signFromShow = SystemEnv.getHtmlLabelName(514226, language); + } else if (signFrom.equalsIgnoreCase("huawei")) { + signFromShow = SystemEnv.getHtmlLabelName(547999, language); + } else if (signFrom.equalsIgnoreCase("null")) { + signFromShow = ""; + } else { + signFromShow = signFrom; + } + return signFromShow; + } + + /***************************************考勤报表权限共享的相关方法***************************************/ + + /** + * 获取考勤报表名称的显示 + * + * @param reportName + * @param languageId + * @return + */ + public String getReportNameShow(String reportName, String languageId) { + String reportNameShow = ""; + int language = Util.getIntValue(languageId, 7); + if (reportName.equals("0")) { + reportNameShow = SystemEnv.getHtmlLabelName(332, language); + } else if (reportName.equals("1")) { + reportNameShow = SystemEnv.getHtmlLabelName(390351, language); + } else if (reportName.equals("2")) { + reportNameShow = SystemEnv.getHtmlLabelName(390352, language); + } else if (reportName.equals("3")) { + reportNameShow = SystemEnv.getHtmlLabelName(390248, language); + } else if (reportName.equals("4")) { + reportNameShow = SystemEnv.getHtmlLabelName(389441, language); + } + return reportNameShow; + } + + /** + * 获取共享级别的显示 + * + * @param shareLevel 0-分部、1-部门、2-人员、3-岗位、4-所有人 + * @param languageId + * @return + */ + public String getShareLevelShow(String shareLevel, String languageId) { + String shareLevelShow = ""; + int language = Util.getIntValue(languageId, 7); + if (shareLevel.equals("0")) { + shareLevelShow = SystemEnv.getHtmlLabelName(33553, language); + } else if (shareLevel.equals("1")) { + shareLevelShow = SystemEnv.getHtmlLabelName(27511, language); + } else if (shareLevel.equals("2")) { + shareLevelShow = SystemEnv.getHtmlLabelName(179, language); + } else if (shareLevel.equals("3")) { + shareLevelShow = SystemEnv.getHtmlLabelName(6086, language); + } else if (shareLevel.equals("4")) { + shareLevelShow = SystemEnv.getHtmlLabelName(1340, language); + } + return shareLevelShow; + } + + /** + * 获取共享对象的显示 + * + * @param id + * @param languageId + * @return + */ + public String getReportShareShow(String id, String languageId) { + String showName = ""; + try { + int language = Util.getIntValue(languageId, 7); + String sql = "select * from kq_ReportShare where id=" + id; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + String shareLevel = recordSet.getString("shareLevel"); + String subcomId = Util.null2String(recordSet.getString("subcomId")); + String deptId = Util.null2String(recordSet.getString("deptId")); + String jobtitleId = Util.null2String(recordSet.getString("jobtitleId")); + String userId = Util.null2String(recordSet.getString("userId")); + + if (shareLevel.equals("0")) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + showName = subCompanyComInfo.getSubcompanynames(subcomId); + } else if (shareLevel.equals("1")) { + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + showName = departmentComInfo.getDepartmentNames(deptId); + } else if (shareLevel.equals("2")) { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + List tempList = Util.TokenizerString(userId, ","); + for (int i = 0; i < tempList.size(); i++) { + showName += "," + resourceComInfo.getResourcename(tempList.get(i)); + } + showName = showName.startsWith(",") ? showName.substring(1) : showName; + } else if (shareLevel.equals("3")) { + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + List tempList = Util.TokenizerString(jobtitleId, ","); + for (int i = 0; i < tempList.size(); i++) { + showName += "," + jobTitlesComInfo.getJobTitlesname(tempList.get(i)); + } + showName = showName.length() > 0 ? showName.substring(1) : showName; + } else if (shareLevel.equals("4")) { + showName = SystemEnv.getHtmlLabelName(1340, language); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return showName; + } + + /** + * 获取考勤报表权限共享日志的对象名 + * + * @param targetId + * @param otherParams + * @return + */ + public String getTargetName4ReportShare(String targetId, String otherParams) { + String targetName = ""; + try { + String reportName = otherParams.split("\\+")[0]; + String resourceType = otherParams.split("\\+")[1]; + String resourceId = otherParams.split("\\+", 4)[2]; + String languageId = otherParams.split("\\+", 4)[3]; + + switch (reportName) { + case "1": + targetName += SystemEnv.getHtmlLabelName(16559, Util.getIntValue(languageId, 7)); + break; + case "2": + targetName += SystemEnv.getHtmlLabelName(82801, Util.getIntValue(languageId, 7)); + break; + case "3": + targetName += SystemEnv.getHtmlLabelName(390248, Util.getIntValue(languageId, 7)); + break; + case "4": + targetName += SystemEnv.getHtmlLabelName(389441, Util.getIntValue(languageId, 7)); + break; + } + + ResourceComInfo resourceComInfo = new ResourceComInfo(); + targetName += " " + Util.formatMultiLang(resourceComInfo.getLastnames(resourceId), languageId); + } catch (Exception e) { + e.printStackTrace(); + } + return targetName; + } + + /***************************************公出出差规则的相关方法***************************************/ + + /** + * 获取出差公出规则的日志的对象名 + * + * @param targetId + * @param otherParams + * @return + */ + public String getTargetName4TravelRules(String targetId, String otherParams) { + String targetName = ""; + String languageId = otherParams.split("\\+")[0]; + targetName = SystemEnv.getHtmlLabelName(390004, Util.getIntValue(languageId, 7)); + return targetName; + } + + /***************************************一键已用考勤的相关方法***************************************/ + + /** + * 获取目前新考勤的请假类型表的ID字段的下一个值 + * 考虑到历史数据迁移,过去的请假类型表和目前的请假类型表不是同一张,所以新考勤请假类型表kq_leaveRules的id(非自增)对应于旧的老考勤请假类型表HrmLeaveTypeColor的Id,并作为主键使用 + * + * @return + */ + public int getNextId() { + int nextId = 0; + int maxId = 0; + String maxColorIdSql = "select max(id) maxId from kq_leaveRules"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(maxColorIdSql); + if (recordSet.next()) { + maxId = Util.getIntValue(recordSet.getString("maxId"), 1); + } + nextId = maxId <= 0 ? 1 : (maxId + 1); + return nextId; + } + + /***************************************正式系统会用到的相关方法***************************************/ + + /** + * 获取人员的年假计算开始日期 + * + * @param companyStartDate + * @param resourceId + * @return + */ + public String getCompanyStartDate(String companyStartDate, String resourceId) { + return companyStartDate; + } + + /** + * 获取考勤流程校验规则的 校验规则 + * @return + */ + public String get_rules(String rule_type_uuid,String otherparam) { + List otherparams = Util.splitString2List(otherparam, "+"); + if (otherparams.size() == 4 && rule_type_uuid.length() > 0) { + String ruleid = otherparams.get(0); + String rule_table = otherparams.get(1); + String key_fieldname = otherparams.get(2); + String fieldname = ""; + RecordSet rs = new RecordSet(); + if(key_fieldname.length() > 0){ + String sql = "select * from kq_att_checkrule_fields where rule_type_uuid=? and key_fieldname=? "; + rs.executeQuery(sql, rule_type_uuid,key_fieldname); + if(rs.next()){ + fieldname = rs.getString("fieldname"); + }else{ + fieldname = key_fieldname; + } + }else{ + return ""; + } + String lanid = otherparams.get(3); + String sql = "select * from "+rule_table+" where id = ? "; + rs.executeQuery(sql,ruleid); + if(rs.next()){ + String val = rs.getString(fieldname); + if("check_rule".equalsIgnoreCase(key_fieldname)){ + if("kq_att_frequency_rule".equalsIgnoreCase(rule_table)){ + //次数校验需要单独处理 + String val_count = rs.getString(fieldname+"_count"); + String frequencyContent = getFrequencyContent(val,Util.getIntValue(lanid)); + String content = frequencyContent + SystemEnv.getHtmlLabelName(516776, Util.getIntValue(Util.getIntValue(lanid)))+val_count+SystemEnv.getHtmlLabelName(18083, Util.getIntValue(Util.getIntValue(lanid))); + return content; + }else{ + if("1".equalsIgnoreCase(val)){ + return SystemEnv.getHtmlLabelName(516104, Util.getIntValue(Util.getIntValue(lanid))); + }else{ + return SystemEnv.getHtmlLabelName(516103, Util.getIntValue(Util.getIntValue(lanid))); + } + } + }else if("check_level".equalsIgnoreCase(key_fieldname)){ + if("0".equalsIgnoreCase(val)){ + return SystemEnv.getHtmlLabelName(32137, Util.getIntValue(Util.getIntValue(lanid))); + }else if("1".equalsIgnoreCase(val)){ + return SystemEnv.getHtmlLabelName(32138, Util.getIntValue(Util.getIntValue(lanid))); + }else if("2".equalsIgnoreCase(val)){ + return SystemEnv.getHtmlLabelName(26009, Util.getIntValue(Util.getIntValue(lanid))); + }else { + return ""; + } + }else if("check_message".equalsIgnoreCase(key_fieldname)){ + return val; + }else { + return ""; + } + } + } + return ""; + } + + public String getCheckRuleName(String labelids, String lanid) { + return SystemEnv.getHtmlLabelNames(labelids,Util.getIntValue(lanid,7)); + } + + public String getFrequencyContent(String val, int lanid) { + if("0".equalsIgnoreCase(val)){ + return SystemEnv.getHtmlLabelName(539, Util.getIntValue(lanid)); + }else if("1".equalsIgnoreCase(val)){ + return SystemEnv.getHtmlLabelName(545, Util.getIntValue(lanid)); + }else if("2".equalsIgnoreCase(val)){ + return SystemEnv.getHtmlLabelName(541, Util.getIntValue(lanid)); + }else if("3".equalsIgnoreCase(val)){ + return SystemEnv.getHtmlLabelName(543, Util.getIntValue(lanid)); + }else if("4".equalsIgnoreCase(val)){ + return SystemEnv.getHtmlLabelName(546, Util.getIntValue(lanid)); + } + return ""; + } + + /** + * 获取设备信息 + * + * @param deviceinfo + * @return + */ + public String getDeviceinfo(String deviceinfo) { + String info = ""; + try{ + if(deviceinfo.length() > 0){ + JSONObject jsonObject = JSONObject.parseObject(deviceinfo); + if(jsonObject != null && !jsonObject.isEmpty()){ + String deviceId = Util.null2String(jsonObject.get("deviceId")); + if(deviceId.length() > 0){ + info = deviceId; + } + } + } + }catch (Exception e){ + e.printStackTrace(); + } + return info; + } + + /** + * 判断是否在地理范围内 + * + * @param isincom + * @param otherParam + * @return + */ + public String getIsincom(String isincom,String otherParam) { + String info = ""; + try{ + if(isincom.length() > 0){ + int lan = Util.getIntValue(otherParam); + if("1".equalsIgnoreCase(isincom)){ + info = SystemEnv.getHtmlLabelName(163, lan); + }else{ + info = SystemEnv.getHtmlLabelName(161, lan); + } + } + }catch (Exception e){ + e.printStackTrace(); + } + return info; + } + + /** + * 判断是否是虚拟定位 + * + * @param isVirtualLocation + * @param otherParam + * @return + */ + public String getVirtualLocation(String isVirtualLocation,String otherParam) { + String info = ""; + try{ + if(isVirtualLocation.length() > 0){ + int lan = Util.getIntValue(otherParam); + if("1".equalsIgnoreCase(isVirtualLocation)){ + info = SystemEnv.getHtmlLabelName(163, lan); + }else{ + info = SystemEnv.getHtmlLabelName(161, lan); + } + } + }catch (Exception e){ + e.printStackTrace(); + } + return info; + } + + public String getWorkFlowUrl4mobile(String requestid) { + WorkflowRequestComInfo workflowRequestComInfo = new WorkflowRequestComInfo(); + String flowName = workflowRequestComInfo.getRequestName(requestid); + if (StringUtil.isNotNull(flowName)) { + String url = weaver.general.GCONST.getContextPath()+"/spa/workflow/static4mobileform/index.html#/req?ismonitor=1&requestid=" + requestid; + String a_href = "" + flowName + " "; + return a_href; + } else { + return ""; + } + } + + public String getWorkFlowUrl(String requestid) { + WorkflowRequestComInfo workflowRequestComInfo = new WorkflowRequestComInfo(); + String flowName = workflowRequestComInfo.getRequestName(requestid); + if (StringUtil.isNotNull(flowName)) { + return "" + flowName + " "; + } else { + return ""; + } + } + + public String getLabelName(String id, String otherPara) { + String otherParaArr[] = otherPara.split("\\+", 5); + String labelId = otherParaArr[0]; + String LanId = otherParaArr[1]; + return SystemEnv.getHtmlLabelNames(labelId, LanId); + } + /** + * 判断是否开启办公地点统一位置显示 + * + * @param addr + * @param otherParams + * @return + */ + public String getShowAddress(String addr, String otherParams) { + String[] otherParamArr = otherParams.split("\\+", 3); + String userid = Util.null2String(otherParamArr[0].trim()); + String signdate = Util.null2String(otherParamArr[1].trim()); + String showaddress = Util.null2String(otherParamArr[2].trim()); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupid = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, signdate)); + String locationshowaddress = kqGroupComInfo.getLocationshowaddress(groupid); + if (locationshowaddress.equals("1") && showaddress.length() > 0) { + return addr; + }else{ + return addr; + } + } + + /** + * 获取人员分组应用场景显示列 + * + * @param shareLevel 0-分部、1-部门、2-人员、3-岗位、4-所有人 + * @param languageId + * @return + */ + public String getPersonGroupUserFor(String shareLevel, String languageId) { + String userforShow = ""; + int language = Util.getIntValue(languageId, 7); + if (shareLevel.equals("0")) { + userforShow = "通用"; + } else if (shareLevel.equals("1")) { + userforShow = "排班"; + } else if (shareLevel.equals("2")) { + userforShow = "打卡"; + } else if (shareLevel.equals("3")) { + userforShow = "假期额度"; + } else if (shareLevel.equals("4")) { + userforShow = "考勤方案"; + }else if (shareLevel.equals("4")) { + userforShow = "管理员权限"; + } + return userforShow; + } + + + /** + * 周期状态 + * + * @param shareLevel 0-待关账、1-已关账、2-已结账 + * @param languageId + * @return + */ + public String getCyclestate(String shareLevel, String languageId) { + String stateShow = ""; + int language = Util.getIntValue(languageId, 7); + if (shareLevel.equals("0")) { + stateShow = "待关账"; + } else if (shareLevel.equals("1")) { + stateShow = "已关账"; + } else if (shareLevel.equals("2")) { + stateShow = "已结账"; + } + return stateShow; + } + + /** + * 周期名称 + * + * @param shareLevel 0-待关账、1-已关账、2-已结账 + * @param languageId + * @return + */ + public String getCycleName(String shareLevel, String languageId) { + String stateShow = ""; + int language = Util.getIntValue(languageId, 7); + if (shareLevel.equals("0")) { + stateShow = "待关账"; + } else if (shareLevel.equals("1")) { + stateShow = "已关账"; + } else if (shareLevel.equals("2")) { + stateShow = "已结账"; + } + return stateShow; + } + +} diff --git a/src/com/engine/kq/util/PageUidFactory.java b/src/com/engine/kq/util/PageUidFactory.java new file mode 100644 index 0000000..0fc8a57 --- /dev/null +++ b/src/com/engine/kq/util/PageUidFactory.java @@ -0,0 +1,56 @@ +package com.engine.kq.util; + +import java.util.UUID; + +/** + * React化分页组参考pageuid生成类 + * + * @author lvyi + */ +public class PageUidFactory { + + /** + * 获取React分页组件所需pageuid,每个分页组件唯一,直接通过Main程序生成随机UID常量即可 + * + * @return + */ + public static String getHrmPageUid(String param){ + if("KQGroupSearchList".equals(param)) { + return "2b2ff742-645e-4b6b-b7a2-d08c0d1632d5"; + }else if("KQGroupMembersSearchList".equals(param)) { + return "3124f80d-b6a7-4194-a05e-0fae4ec6c6f5"; + }else if("KQLocationList".equals(param)){ + return "c5603887-2b6c-43be-8c1f-18c3794eddee"; + }else if("KQWifiList".equals(param)){ + return "24887e97-4b1d-4ac1-abb1-7a74678f5f53"; + }else if("KQReportDetialList".equals(param)){ + return "484dfc16-90c3-4dd8-8d21-dad2f0f443bc"; + }else if("KQReport".equals(param)){ + return "d04a46f0-03bd-43dc-b150-dc52cbd6ce71"; + }else if("KQDailyReport".equals(param)){ + return "cedbbfee-03ad-430e-bd9a-e294750a2dbe"; + }else if("KQGroupMembersSearchList".equals(param)){ + return "c26aa26c-ed9b-49f9-9553-5d60655eb4e2"; + }else if("ScheduleCodeList".equals(param)){ + return "9fb6606e-83ed-49c3-b3c7-a63f6afdbe7a"; + }else if("KQPersonGroupList".equals(param)){ + return "d0c6abf5-b722-4187-ac6c-e8735a01c329"; + }else if("KQCycleSettingList".equals(param)){ + return "01c6e218-5d4a-4826-9e4a-d123924d58ce"; + }else if("KQCycleList".equals(param)){ + return "c1dc1669-8a8d-4c4f-b80c-c9a3e2eaa0dc"; + }else if("KQCycledetailList".equals(param)){ + return "5022b6d7-b17a-4683-95f5-da9d786b3448"; + }else{ + return ""; + } + } + + public static void main(String[] args){ + for(int i=0; i<10; i++){ + UUID uuid = UUID.randomUUID(); + System.err.println(uuid); + } + } + +} diff --git a/src/com/engine/kq/util/ResponseResult.java b/src/com/engine/kq/util/ResponseResult.java new file mode 100644 index 0000000..1a052b2 --- /dev/null +++ b/src/com/engine/kq/util/ResponseResult.java @@ -0,0 +1,187 @@ +package com.engine.kq.util; + + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.common.service.HrmCommonService; +import com.engine.common.service.impl.HrmCommonServiceImpl; +import com.engine.core.exception.ECException; +import com.engine.kq.jucailin.exception.AttendanceRunTimeException; +import com.engine.kq.jucailin.exception.ExceptionUtil; +import com.engine.kq.log.KQLog; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; +import lombok.extern.slf4j.Slf4j; +import weaver.general.BaseBean; +import weaver.hrm.User; + +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 + **/ + +public class ResponseResult { + + private static final long serialVersionUID = 1L; + + private final User user; + + private final HrmCommonService hrmCommonService = new HrmCommonServiceImpl(); + + private final BaseBean baseBean = new BaseBean(); + + private final Boolean isLog = true; + + private KQLog log = new KQLog(); + + public ResponseResult(User user) { + this.user = user; + } + + private static Gson gson = new Gson(); + + + /** + * 统一返回方法 + */ + public String run(Function f, T t) { + try { + if (isLog) { + log.info("run attendance api , param "+t); + } + return Ok(f.apply(t)); + } catch (AttendanceRunTimeException e) { + log.error("attendance api run fail , param "+ t, e); + return Error(e.getMessage()); + } catch (ECException e) { + log.error("attendance 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("attendance api run fail , param "+t, e); + return Error("系统异常!"); + } + } + + /** + * 统一返回方法(有参无返回) + */ + public String run(Consumer f, T t) { + try { + if (isLog) { + log.info("run attendance api , param "+t); + } + f.accept(t); + return Ok(); + } catch (AttendanceRunTimeException e) { + log.error("attendance api run fail , param "+t, e); + return Error(e.getMessage()); + } catch (ECException e) { + log.error("attendance api run fail , param "+t, e); + return Error(ExceptionUtil.getRealMessage(e)); + } catch (Exception e) { + log.error("attendance api run fail , param "+t, e); + return Error("系统异常!", e); + } + } + + + /** + * 统一返回方法(无参有返回) + */ + public String run(Supplier f) { + try { + if (isLog) { + log.info("run attendance api"); + } + return Ok(f.get()); + } catch (AttendanceRunTimeException e) { + log.error("attendance api run fail", e); + return Error(e.getMessage()); + } catch (ECException e) { + log.error("attendance api run fail", e); + Throwable cause = e.getCause(); + return Error(cause.getMessage()); + } catch (Exception e) { + log.error("attendance api run fail", e); + return Error("系统异常!", e); + } + } + + + private static String getJsonString(Object apidatas) throws JsonProcessingException { +// ObjectMapper mapper = new ObjectMapper(); +// return mapper.writeValueAsString(apidatas); + return JSONObject.toJSONString(apidatas); + } + + /** + * 成功返回 + */ + private String Ok() throws JsonProcessingException { + Map apidatas = new HashMap<>(); + apidatas.put("api_status", true); + String success = getJsonString(apidatas); + return success; + } + + + /** + * 成功返回 + */ + private String Ok(R r) throws JsonProcessingException { + Map apidatas = new HashMap<>(); + apidatas.put("api_status", true); + apidatas.put("data", r); + String success = getJsonString(apidatas); + if (isLog) { + log.info("run attendance api success return "+success); + } + return success; + } + + + /** + * 失败返回 + */ + private static String Error(String message) { + Map apidatas = new HashMap<>(); + apidatas.put("api_status", false); + apidatas.put("api_errormsg", message); + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + + /** + * 系统异常失败返回 + */ + private static String Error(String message, Exception e) { + Map apidatas = new HashMap<>(); + apidatas.put("api_status", false); + apidatas.put("api_errormsg", message); + apidatas.put("error", e.getMessage()); + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + + +} diff --git a/src/com/engine/kq/util/TransMethod.java b/src/com/engine/kq/util/TransMethod.java new file mode 100644 index 0000000..95f3c0f --- /dev/null +++ b/src/com/engine/kq/util/TransMethod.java @@ -0,0 +1,924 @@ +package com.engine.kq.util; + +import com.api.browser.bean.SearchConditionOption; +import com.engine.kq.biz.*; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.enums.KQSettingsEnum; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.wfset.util.SplitSelectSet; +import java.text.DecimalFormat; +import java.util.*; +import weaver.systeminfo.systemright.CheckSubCompanyRight; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; +import weaver.workflow.workflow.WorkflowComInfo; +import weaver.workflow.workflow.WorkflowRequestComInfo; + +public class TransMethod extends BaseBean { + private static DecimalFormat df = new DecimalFormat("0.00"); + + public ArrayList getOperateByGroup(String id, String otherPara) { + ArrayList resultList = new ArrayList(); + String[] splitStr = Util.splitString(otherPara, "+"); + String kqType = Util.null2String(splitStr[0]); + String subcompanyid = Util.null2String(splitStr[1]); + String userid = Util.null2String(splitStr[2]); + int resourceid = Util.getIntValue(userid); + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + int operatelevel = checkSubCompanyRight.ChkComRightByUserRightCompanyId(resourceid, "HrmKQGroup:Add", Util.getIntValue(subcompanyid, -1)); + if (operatelevel > 0) { + resultList.add("true"); + resultList.add("true"); + resultList.add("true"); + resultList.add(String.valueOf(kqType.equals("2"))); + }else{ + resultList.add("false"); + resultList.add("false"); + resultList.add("false"); + resultList.add("false"); + } + if (operatelevel > 1) { + resultList.add(this.getKQGroupCheckbox(id)); + }else{ + resultList.add("false"); + } + resultList.add("true"); + return resultList; + } + + public ArrayList getOperate(String id, String kqType){ + ArrayList resultList = new ArrayList(); + + resultList.add("true"); + resultList.add("true"); + resultList.add("true"); + resultList.add(String.valueOf(kqType.equals("2"))); + resultList.add(this.getKQGroupCheckbox(id)); + resultList.add("true"); + return resultList; + } + + public ArrayList getGroupMembersOperate(String id, String groupId){ + ArrayList resultList = new ArrayList(); + String result = getKQGroupMembersCheckbox(id+"+"+groupId); + + resultList.add(result); + resultList.add("true"); + return resultList; + } + + public String getKQGroupName(String groupname, String otherPara){ + String kqGroupName = groupname; + String[] splitStr = Util.splitString(otherPara, "+"); + String groupid = Util.null2String(splitStr[0]); + String resourceid = Util.null2String(splitStr[1]); + String kqdate = Util.null2String(splitStr[2]); + String strLanguage = Util.null2String(splitStr[3]); + if(resourceid.length()>0){ + int language = Util.getIntValue(strLanguage,7); + if(kqdate.length()==0) { + kqdate = DateUtil.getCurrentDate(); + } + String currentGroupId = Util.null2String(new KQGroupMemberComInfo().getKQGroupId(resourceid,kqdate)); + if(groupid.equals(currentGroupId)) { + kqGroupName += "("+ SystemEnv.getHtmlLabelName(509551, language)+")"; + } + } + return kqGroupName; + } + + public int getGroupUserCount(String groupid){ + int count = 0; + RecordSet rs = new RecordSet(); + String sql = ""; + sql = " SELECT count(distinct id) FROM ( "+ + " SELECT a.id,a.status FROM HrmResource a, kq_groupmember b "+ + " WHERE (a.id=b.typevalue and b.type =1 and (isdelete is null or isdelete <> '1') and groupid = "+groupid+" ) "+ + " UNION ALL "+ + " SELECT a.id,a.status FROM HrmResource a, kq_groupmember b "+ + " WHERE (a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 and (isdelete is null or isdelete <> '1') and groupid = "+groupid+" ) "+ + " UNION ALL "+ + " SELECT a.id,a.status FROM HrmResource a, kq_groupmember b "+ + " WHERE (a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 and (isdelete is null or isdelete <> '1') and groupid = "+groupid+" ) "+ + " UNION ALL "+ + " SELECT a.id,a.status FROM HrmResource a, kq_groupmember b "+ + " WHERE (a.jobtitle = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=5 and (isdelete is null or isdelete <> '1') and groupid = "+groupid+" AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))))" + + " UNION ALL "+ + " select a.id,a.status from hrmresource a where seclevel>=(select min(seclevel) from kq_groupmember where type=6 and (isdelete is null or isdelete <> '1') and groupid = "+groupid+" ) and seclevel<= (select max(seclevelto) from kq_groupmember where type=6 and (isdelete is null or isdelete <> '1') and groupid = "+groupid+" )) t" + + " where t.status in(0,1,2,3) "; + rs.executeQuery(sql) ; + if(rs.next()){ + count=rs.getInt(1); + } + return count; + } + + public String getKQTypeName(String kqtype, String strLanguage){ + int language = Util.getIntValue(strLanguage,7); + String kQTypeName = ""; + if(kqtype.equals("1")){ + kQTypeName = SystemEnv.getHtmlLabelName(389127,language); + }else if(kqtype.equals("2")){ + kQTypeName = SystemEnv.getHtmlLabelName(389128,language); + }else if(kqtype.equals("3")){ + kQTypeName = SystemEnv.getHtmlLabelName(520551,language); + } + return kQTypeName; + } + + public String getKQGroupDetial(String id,String otherPara){ + String kQGroupDetial = ""; + String[] splitStr = Util.splitString(otherPara, "+"); + String kqtype = Util.null2String(splitStr[0]); + int language = Util.getIntValue(splitStr[1],7); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + + if(kqtype.equals("1")){ + String sql = ""; + RecordSet rs = new RecordSet(); + LinkedHashMap map = new LinkedHashMap<>(); + sql = "select * from kq_fixedschedulce where groupid = ? order by weekday "; + rs.executeQuery(sql,id); + while(rs.next()){ + int weekday = rs.getInt("weekday"); + String serialid = Util.null2String(rs.getString("serialid")); + if(serialid.length()==0)serialid="0"; + if(map.get(serialid)==null){ + map.put(serialid,UtilKQ.getWeekDay(weekday,language) ); + }else{ + String value = map.get(serialid); + value=value+"、"+UtilKQ.getWeekDay(weekday,language); + map.put(serialid,value); + } + } + Iterator> iter = map.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = iter.next(); + String serialid = entry.getKey(); + String weeks = entry.getValue(); + if(kQGroupDetial.length()>0)kQGroupDetial+="
"; + if(serialid.equals("0")){ + kQGroupDetial += weeks + SystemEnv.getHtmlLabelName(26593,language); + }else{ + kQGroupDetial += weeks + shiftManagementToolKit.getShiftOnOffWorkSections(serialid,language); + } + } + }else if(kqtype.equals("2")){ + List serialids = Util.splitString2List(kqGroupComInfo.getSerialids(id),",") ; + List lsSerialids = new ArrayList<>(); + for (String serialid : serialids) { + if(Util.null2String(serialid).length()==0 || lsSerialids.contains(serialid) + ||Util.null2String(shiftManagementToolKit.getShiftOnOffWorkSections(serialid,language)).length()==0)continue; + lsSerialids.add(serialid); + if(kQGroupDetial.length()>0)kQGroupDetial+="
"; + kQGroupDetial += shiftManagementToolKit.getShiftOnOffWorkSections(serialid,language); + } + }else if(kqtype.equals("3")){ + kQGroupDetial = SystemEnv.getHtmlLabelName(389120,language); + } + return kQGroupDetial; + } + + public String getSignTime(String signDate, String signTime){ + return signDate+" "+signTime; + } + + public String getFlowDurationByUnit(String duration, String otherPara){ + String[] splitStr = Util.splitString(otherPara, "+"); + String kqType = ""; + String durationrule = ""; + String lan = ""; + String newLeaveType = ""; + String requestid = ""; + String typeselect = ""; + String fromDate = ""; + String toDate = ""; + String backduraion = ""; + + if(splitStr.length == 6){ + kqType = splitStr[0]; + durationrule = splitStr[1]; + lan = splitStr[2]; + newLeaveType = splitStr[3]; + requestid = splitStr[4]; + backduraion = splitStr[5]; + }else if(splitStr.length == 5){ + kqType = splitStr[0]; + durationrule = splitStr[1]; + lan = splitStr[2]; + requestid = splitStr[3]; + backduraion = splitStr[4]; + }else if(splitStr.length == 8){ + kqType = splitStr[0]; + durationrule = splitStr[1]; + lan = splitStr[2]; + newLeaveType = splitStr[3]; + requestid = splitStr[4]; + typeselect = splitStr[5]; + fromDate = splitStr[6]; + toDate = splitStr[7]; + }else if(splitStr.length == 3){ + kqType = splitStr[0]; + durationrule = splitStr[1]; + lan = splitStr[2]; + } + if(Util.getIntValue(kqType) == 0 && newLeaveType.length() == 0){ + return duration; + } + + return getUnitByKQType(kqType,newLeaveType,durationrule,Util.getDoubleValue(duration),requestid,lan,backduraion); + + } + + /** + * 根据考勤流程类型+请假类型id得到单位 + * @param kqType + * @param newLeaveType + * @param durationrule + * @param duration + * @param requestid + * @param lan + * @param backduraion + * @return + */ + private String getUnitByKQType(String kqType, String newLeaveType, String durationrule, + double duration, String requestid, String lan, String backduraion) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); +// String unit = ""; + double kq_duration = duration; + double proportion = 0.0; + Map backDuraion = new HashMap<>(); + double backDuration = Util.getDoubleValue(Util.null2s(backduraion,"0.0"),0.0); + String minimumUnit = ""; + switch (kqType){ + case "0": + proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newLeaveType)); + minimumUnit = ""+KQLeaveRulesBiz.getMinimumUnit(newLeaveType); +// if(requestid.length() > 0){ +// backDuraion = getLeaveBackDuraion(requestid,typeselect,fromDate,toDate); +// } +// unit = getMinimumUnitName(""+minimumUnit, lan); + break; + case "1": + minimumUnit = KQTravelRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系 +// unit = getMinimumUnitName(minimumUnit,lan); + break; + case "2": + minimumUnit = KQExitRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系 +// unit = getMinimumUnitName(minimumUnit,lan); + break; + case "3": + minimumUnit = ""+KQOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + proportion = KQOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 +// unit = getMinimumUnitName(minimumUnit,lan); + break; + case "4": + break; + case "5": + break; + case "6": + break; + case "7": + break; + default: + break; + } + + + if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) { + kq_duration = duration*proportion; + backDuration = backDuration*proportion; + } + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) { + kq_duration = duration/proportion; + backDuration = backDuration/proportion; + } + } + } +// if(unit.length() > 0){ +// return kq_duration+"("+unit+")"; +// }else{ +// } + if(backDuration > 0){ + return KQDurationCalculatorUtil.getDurationRound(""+kq_duration)+"("+SystemEnv.getHtmlLabelName(24473, + Util.getIntValue(lan))+":"+KQDurationCalculatorUtil.getDurationRound(""+backDuration)+")"; + }else{ + return KQDurationCalculatorUtil.getDurationRound(""+kq_duration); + } + } + + /** + * 根据请假流程id获取被销假数据的时长 + * @param requestid + * @param typeselect + * @param fromDate + * @param toDate + * @return + */ + public Map getLeaveBackDuraion(String requestid, String typeselect, + String fromDate, String toDate) { + 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"); + } + } + Map backDuraion = new HashMap<>(); + RecordSet rs = new RecordSet(); + String getLeaveBackDuraion = "select sum(cast(duration as decimal(18,4))) as duration1,durationrule from kq_flow_split_leaveback where leavebackrequestid = ? "; + if (fromDate.length() > 0 && toDate.length() > 0){ + getLeaveBackDuraion += " and ( fromDate between '"+fromDate+"' and '"+toDate+"' or toDate between '"+fromDate+"' and '"+toDate+"' " + + " or '"+fromDate+"' between fromDate and toDate or '"+toDate+"' between fromDate and toDate) "; + } + getLeaveBackDuraion += " group by durationrule "; + rs.executeQuery(getLeaveBackDuraion, requestid); + if (rs.next()){ + String duration1 = rs.getString("duration1"); + String durationrule = rs.getString("durationrule"); + backDuraion.put("durationrule", durationrule); + backDuraion.put("duration", duration1); + } + return backDuraion; + } + + private String getMinimumUnitName(String minimumUnit,int lan){ + String minimumUnitName = ""; + switch (minimumUnit) { + case "1": + minimumUnitName = SystemEnv.getHtmlLabelName(1925, lan); + break; + case "2": + minimumUnitName = SystemEnv.getHtmlLabelName(1925, lan); + break; + case "3": + minimumUnitName = SystemEnv.getHtmlLabelName(391, lan); + break; + case "4": + minimumUnitName = SystemEnv.getHtmlLabelName(1925, lan); + break; + default: + break; + } + return minimumUnitName; + } + + public String getSerailName(String serialid,String otherPara) { + String serailName = ""; + if(Util.null2String(serialid).trim().length()==0) return serailName; + String workSections = ""; + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + String[] params = Util.splitString(otherPara, "+"); + String workbegintime = Util.null2String(params[0]).trim(); + String workendtime = Util.null2String(params[1]).trim(); + + serailName = kqShiftManagementComInfo.getSerial(serialid); + if(workbegintime.length()>0&&workendtime.length()>0){ + //只有下班时间可能跨天 + workendtime = kqTimesArrayComInfo.turn48to24Time(workendtime); + workSections += workbegintime+"-"+workendtime; + } + if(workSections.length()>0) { + serailName += "(" + workSections + ")"; + } + return serailName; + } + + /** + * 上班打卡时间 + * @param serialid + * @param otherPara + * @return + */ + public String getReportDetialSignInTime(String serialid,String otherPara) { + String signTime = ""; + String[] params = Util.splitString(otherPara, "+"); + String begintime = Util.null2String(params[0]).trim(); + String kqdate = Util.null2String(params[1]).trim(); + String resourceid = Util.null2String(params[2]).trim(); + int language = Util.getIntValue(params[3],7); + + if(begintime.length()>0){ + signTime += begintime; + } + + if(Util.null2String(serialid).length()>0){ + if(signTime.length()==0){ + signTime = SystemEnv.getHtmlLabelName(25994,language); + } + }else{ + //弹性工时打卡时间取自签到签退数据 + } + + return signTime; + } + + /** + * 下班打卡时间 + * @param serialid + * @param otherPara + * @return + */ + public String getReportDetialSignOutTime(String serialid,String otherPara) { + String signTime = ""; + String[] params = Util.splitString(otherPara, "+"); + String endtime = Util.null2String(params[0]).trim(); + String kqdate = Util.null2String(params[1]).trim(); + String resourceid = Util.null2String(params[2]).trim(); + int language = Util.getIntValue(params[3],7); + + if(endtime.length()>0){ + signTime += endtime; + } + + if(Util.null2String(serialid).length()>0){ + if(signTime.length()==0){ + signTime = SystemEnv.getHtmlLabelName(25994,language); + } + }else{ + //弹性工时打卡时间取自签到签退数据 + } + + return signTime; + } + + + public String getReportDetialSignTime(String serialid,String otherPara) { + String signTime = ""; + String[] params = Util.splitString(otherPara, "+"); + String begintime = Util.null2String(params[0]).trim(); + String endtime = Util.null2String(params[1]).trim(); + String kqdate = Util.null2String(params[2]).trim(); + String resourceid = Util.null2String(params[3]).trim(); + int language = Util.getIntValue(params[4],7); + + if(begintime.length()>0&&endtime.length()>0){ + signTime += begintime+"-"+endtime; + }else if(begintime.length()>0){ + signTime += begintime; + }else if(endtime.length()>0){ + signTime += endtime; + } + + if(Util.null2String(serialid).length()>0){ + if(signTime.length()==0){ + signTime = SystemEnv.getHtmlLabelName(25994,language); + } + }else{ + //弹性工时打卡时间取自签到签退数据 + } + + return signTime; + } + + public String getReportDetialMinToHour(String value) { + value = value.trim(); + if(value.length()>0){ + value = df.format(Util.getDoubleValue(value)/60); + } + return value; + } + + public String getLeavetype(String newleavetype) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + if(newleavetype.length() == 0){ + return ""; + } + boolean show_leave_type_unit = KQSettingsBiz.showLeaveTypeSet(KQSettingsEnum.LEAVETYPE_UNIT.getMain_key()); + String name = kqLeaveRulesComInfo.getLeaveName(newleavetype); + if(show_leave_type_unit){ + name += kqLeaveRulesComInfo.getUnitName(newleavetype, 7); + } + return name; + } + + public String getLeavetype(String newleavetype, String otherPara) { + String[] splitStr = Util.splitString(otherPara, "+"); + String languageId = (splitStr==null || splitStr.length<1) ? "7":splitStr[0]; + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + if(newleavetype.length() == 0){ + return ""; + } + boolean show_leave_type_unit = KQSettingsBiz.showLeaveTypeSet(KQSettingsEnum.LEAVETYPE_UNIT.getMain_key()); + String name = kqLeaveRulesComInfo.getLeaveName(newleavetype); + if(show_leave_type_unit){ + name += kqLeaveRulesComInfo.getUnitName(newleavetype, Util.getIntValue(languageId)); + } + return name; + } + + public String getKQGroupCheckboxByGroup(String otherPara){ + String returnVal = "true"; + + RecordSet rs = new RecordSet(); + String[] splitStr = Util.splitString(otherPara, "+"); + String id = Util.null2String(splitStr[0]); + String subcompanyid = Util.null2String(splitStr[1]); + String userid = Util.null2String(splitStr[2]); + int resourceid = Util.getIntValue(userid); + CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight(); + int operatelevel = checkSubCompanyRight.ChkComRightByUserRightCompanyId(resourceid, "HrmKQGroup:Add", Util.getIntValue(subcompanyid, -1)); + if (operatelevel <= 1) { + returnVal = "false"; + } + String sql = ""; + //有考勤组成员 + if(returnVal.equals("true")) { + sql = " SELECT count(1) FROM kq_groupmember WHERE (isdelete is null or isdelete <> '1') AND groupid=" + id; + rs.executeQuery(sql); + if (rs.next()) { + if (rs.getInt(1) > 0) { + returnVal = "false"; + } + } + } + + //有考勤排班 + if(returnVal.equals("true")){ + sql = " SELECT count(1) FROM kq_shiftschedule where (isdelete is null or isdelete <> '1') AND groupid="+id; + rs.executeQuery(sql); + if(rs.next()){ + if(rs.getInt(1)>0){ + returnVal = "false"; + } + } + } + return returnVal; + } + + public String getKQGroupCheckbox(String id){ + String returnVal = "true"; + String sql = ""; + RecordSet rs = new RecordSet(); + + //有考勤组成员 + sql = " SELECT count(1) FROM kq_groupmember WHERE (isdelete is null or isdelete <> '1') AND groupid="+id; + rs.executeQuery(sql); + if(rs.next()){ + if(rs.getInt(1)>0){ + returnVal = "false"; + } + } + + //有考勤排班 + if(returnVal.equals("true")){ + sql = " SELECT count(1) FROM kq_shiftschedule where (isdelete is null or isdelete <> '1') AND groupid="+id; + rs.executeQuery(sql); + if(rs.next()){ + if(rs.getInt(1)>0){ + returnVal = "false"; + } + } + } + return returnVal; + } + + public String getKQGroupMembersCheckbox(String params){ + String returnVal = "true"; + String[] arrParams = Util.splitString(params,"+"); + String id = arrParams[0]; + String groupId = arrParams[1]; + String sql = ""; + RecordSet rs = new RecordSet(); + sql = " SELECT count(1) FROM (\n" + + " SELECT DISTINCT t.id, t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid FROM ( \n" + + " SELECT b.id,a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT b.id,a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT b.id,a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT b.id,a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE (a.jobtitle = b.typevalue AND b.type=5 and (b.isdelete is null or b.isdelete <> '1') AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))))) t \n" + + " UNION ALL \n" + + " SELECT b.id,a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1')) t, kq_shiftschedule a\n" + + " where t.resourceid=a.resourceid AND t.groupid=a.groupid AND (a.isdelete is null or a.isdelete <> '1') AND t.id="+id + " and t.groupId="+groupId; + rs.executeQuery(sql); + if(rs.next()){ + if(rs.getInt(1)>0){ + returnVal = "false"; + } + } + return returnVal; + } + + public String getFlowTimeByUnit(String time, String otherPara){ + String compareTime = time; + String timename = time; + String[] splitStr = Util.splitString(otherPara, "+"); + String kqtype = ""; + String timetype = "";//0表示开始时间,1表示结束时间 + String lan = ""; + String newLeaveType = ""; + String durationrule = ""; + String timeselection = "1"; + String selectiontype = ""; + String changeType = ""; + KQTimeSelectionComInfo kqTimeSelectionComInfo = new KQTimeSelectionComInfo(); + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + Map half_map = new HashMap<>(); + if(splitStr.length == 5){ + //归档 + kqtype = splitStr[0]; + timetype = splitStr[1]; + lan = splitStr[2]; + newLeaveType = splitStr[3]; + durationrule = splitStr[4]; + }else if(splitStr.length == 4){ + kqtype = splitStr[0]; + timetype = splitStr[1]; + lan = splitStr[2]; + newLeaveType = splitStr[3]; + } + switch (kqtype){ + case "0": + durationrule = (durationrule.length() > 0 ? durationrule : ""+KQLeaveRulesBiz.getMinimumUnit(newLeaveType)); + timeselection = kqLeaveRulesComInfo.getTimeSelection(newLeaveType); + selectiontype = ""+KqSplitFlowTypeEnum.LEAVE.getFlowtype(); + changeType = kqLeaveRulesComInfo.getMinimumUnit(newLeaveType); + break; + case "1": + durationrule = (durationrule.length() > 0 ? durationrule : ""+KQTravelRulesBiz.getMinimumUnit()); + timeselection = KQTravelRulesBiz.getTimeselection(); + selectiontype = ""+KqSplitFlowTypeEnum.EVECTION.getFlowtype(); + changeType = durationrule; + newLeaveType = "0"; + break; + case "2": + durationrule = (durationrule.length() > 0 ? durationrule : ""+KQExitRulesBiz.getMinimumUnit()); + timeselection = KQExitRulesBiz.getTimeselection(); + selectiontype = ""+KqSplitFlowTypeEnum.OUT.getFlowtype(); + changeType = durationrule; + newLeaveType = "0"; + break; + case "3": + durationrule = (durationrule.length() > 0 ? durationrule : ""+KQOvertimeRulesBiz.getMinimumUnit()); + timeselection = KQOvertimeRulesBiz.getTimeselection(); + selectiontype = ""+KqSplitFlowTypeEnum.OVERTIME.getFlowtype(); + changeType = durationrule; + newLeaveType = "0"; + if(compareTime.length() > 5){ + compareTime = compareTime.substring(0,5); + } + break; + case "4": + break; + case "5": + break; + case "6": + break; + case "7": + break; + default: + break; + } + if("2".equalsIgnoreCase(durationrule) || "4".equalsIgnoreCase(durationrule)){ + if("2".equalsIgnoreCase(durationrule)){ + half_map = kqTimeSelectionComInfo.getTimeselections(selectiontype,newLeaveType,changeType); + if("1".equalsIgnoreCase(timeselection)){ + //下拉框显示 + String cus_am = ""; + String cus_pm = ""; + if(half_map != null && !half_map.isEmpty()){ + cus_am = Util.null2String(half_map.get("half_on")); + cus_pm = Util.null2String(half_map.get("half_off")); + } + if("0".equalsIgnoreCase(timetype)){ + if(compareTime.equalsIgnoreCase(SplitSelectSet.forenoon_start)){ + timename = SystemEnv.getHtmlLabelName(16689,Util.getIntValue(lan)); + if(cus_am.length() > 0){ + timename = cus_am; + } + }else if(compareTime.equalsIgnoreCase(SplitSelectSet.forenoon_end)){ + timename = SystemEnv.getHtmlLabelName(16690,Util.getIntValue(lan)); + if(cus_pm.length() > 0){ + timename = cus_pm; + } + } + }else if("1".equalsIgnoreCase(timetype)){ + if(compareTime.equalsIgnoreCase(SplitSelectSet.afternoon_start)){ + timename = SystemEnv.getHtmlLabelName(16689,Util.getIntValue(lan)); + if(cus_am.length() > 0){ + timename = cus_am; + } + }else if(compareTime.equalsIgnoreCase(SplitSelectSet.afternoon_end)){ + timename = SystemEnv.getHtmlLabelName(16690,Util.getIntValue(lan)); + if(cus_pm.length() > 0){ + timename = cus_pm; + } + } + } + }else{ + + } + } + if("4".equalsIgnoreCase(durationrule)){ + if("0".equalsIgnoreCase(timetype)){ + if(compareTime.equalsIgnoreCase(SplitSelectSet.forenoon_start)){ + timename = SystemEnv.getHtmlLabelName(390728,Util.getIntValue(lan)); + } + }else if("1".equalsIgnoreCase(timetype)){ + if(compareTime.equalsIgnoreCase(SplitSelectSet.afternoon_end)){ + timename = SystemEnv.getHtmlLabelName(390728,Util.getIntValue(lan)); + } + } + + } + } + return timename; + } + + /** + * 考勤报表,加班明细里根据当前加班单位显示加班时长 + * @param duration + * @return + */ + public String getDuration_minByUnit(String duration){ + + int uintType = KQOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = KQOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + + String valueField = ""; + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + valueField = KQDurationCalculatorUtil.getDurationRound(""+(Util.getDoubleValue(duration)/(60))); + }else{//按天计算 + valueField = KQDurationCalculatorUtil.getDurationRound(""+(Util.getDoubleValue(duration)/(60*hoursToDay))); + } + + return valueField; + } + + /** + * 考勤报表,加班明细里根据当前加班数据是否关联调休 + * @param paidLeaveEnable + * @param otherPram + * @return + */ + public String getPaidLeaveEnable(String paidLeaveEnable,String otherPram){ + int lan = Util.getIntValue(otherPram,7); + if("1".equalsIgnoreCase(paidLeaveEnable)){ + return SystemEnv.getHtmlLabelName(163, lan); + }else{ + return SystemEnv.getHtmlLabelName(161, lan); + } + } + + /** + * 考勤报表,加班明细里根据当前加班数据来源 + * @param computingMode + * @param otherPram + * @return + */ + public String getComputingMode(String computingMode,String otherPram){ +// String mode = ""; +// if("1".equalsIgnoreCase(computingMode)){ +// mode = "以加班流程为准"; +// }else if("2".equalsIgnoreCase(computingMode)){ +// mode = "以打卡为准,但不能超过加班流程时长"; +// }else if("3".equalsIgnoreCase(computingMode)){ +// mode = "根据打卡时间计算加班时长"; +// } + int lan = Util.getIntValue(otherPram,7); + if("1".equalsIgnoreCase(computingMode)){ + return SystemEnv.getHtmlLabelName(30045, lan); + }else{ + return SystemEnv.getHtmlLabelName(500502, lan); + } + } + + public String getSchedulecode(String params){ + String schedulecode = ""; + String sql = ""; + RecordSet rs = new RecordSet(); + try{ + boolean isOneDevice = true; + sql = " select count(1) from kq_schedule_device "; + rs.executeQuery(sql); + if(rs.next()){ + if(rs.getInt(1)>1){ + isOneDevice = false; + } + } + + if(isOneDevice){ + sql = " SELECT schedulecode FROM kq_schedule_code where resourceid="+params; + rs.executeQuery(sql); + while (rs.next()){ + if(schedulecode.length()>0)schedulecode+=","; + schedulecode += Util.null2String(rs.getString("schedulecode")); + } + }else{ + sql = " SELECT count(1) as cnt FROM kq_schedule_code where resourceid="+params; + rs.executeQuery(sql); + if(rs.next()){ + schedulecode = ""+rs.getInt("cnt"); + } + } + }catch (Exception e){ + writeLog(e); + } + return schedulecode; + } + public String getScheduleDeviceCheckbox(String id){ + String returnVal = "true"; + + String sql = ""; + RecordSet rs = new RecordSet(); + try{ + sql = " select count(1) from kq_schedule_code where deviceid = ? "; + rs.executeQuery(sql,id); + if(rs.next()){ + if(rs.getInt(1)>0){ + returnVal = "false"; + } + } + }catch (Exception e){ + writeLog(e); + } + return returnVal; + } + + public ArrayList getScheduleDeviceOperate(String id){ + ArrayList resultList = new ArrayList(); + + resultList.add("true"); + resultList.add(this.getScheduleDeviceCheckbox(id)); + resultList.add("true"); + return resultList; + } + + public String getWorkflowname(String field001){ + WorkflowComInfo workflowComInfo = new WorkflowComInfo(); + return workflowComInfo.getWorkflowname(field001); + } + + public String getFlowTypeName(String field006, String strLanguage){ + if("0".equalsIgnoreCase(field006)){ + return SystemEnv.getHtmlLabelName(83393,weaver.general.Util.getIntValue(Util.getIntValue(strLanguage))); + }else if("1".equalsIgnoreCase(field006)){ + return SystemEnv.getHtmlLabelName(83394,weaver.general.Util.getIntValue(Util.getIntValue(strLanguage))); + }else if("2".equalsIgnoreCase(field006)){ + return SystemEnv.getHtmlLabelName(83395,weaver.general.Util.getIntValue(Util.getIntValue(strLanguage))); + }else if("3".equalsIgnoreCase(field006)){ + return SystemEnv.getHtmlLabelName(83396,weaver.general.Util.getIntValue(Util.getIntValue(strLanguage))); + }else if("5".equalsIgnoreCase(field006)){ + return SystemEnv.getHtmlLabelName(390737,weaver.general.Util.getIntValue(Util.getIntValue(strLanguage))); + }else if("6".equalsIgnoreCase(field006)){ + return SystemEnv.getHtmlLabelName(389117,weaver.general.Util.getIntValue(Util.getIntValue(strLanguage))); + }else if("7".equalsIgnoreCase(field006)){ + return SystemEnv.getHtmlLabelName(390274,weaver.general.Util.getIntValue(Util.getIntValue(strLanguage))); + }else if("8".equalsIgnoreCase(field006)){ + return SystemEnv.getHtmlLabelName(513400,weaver.general.Util.getIntValue(Util.getIntValue(strLanguage))); + }else { + return ""; + } + } + + public String getRequestLink(String fromDate,String req_requestid){ + WorkflowRequestComInfo workflowRequestComInfo = new WorkflowRequestComInfo(); + if(req_requestid.length() > 0 && Util.getIntValue(req_requestid) > 0){ + return "" + fromDate + ""; + }else{ + return fromDate; + } + } + + public String getOvertimeCard(String fromdate,String otherPara){ + String[] splitStr = Util.splitString(otherPara, "+"); + if(splitStr.length == 3){ + String fromtime = splitStr[0]; + String todate = splitStr[1]; + String totime = splitStr[2]; + //多时区会把这个文字给转换改成/ + String tmpfromdate = fromdate.replaceAll("-", "/"); + String tmptodate = todate.replaceAll("-", "/"); + String datetime = tmpfromdate+" "+fromtime+"-"+tmptodate+" "+totime; + return datetime; + } + return ""; + } +} diff --git a/src/com/engine/kq/util/UtilKQ.java b/src/com/engine/kq/util/UtilKQ.java new file mode 100644 index 0000000..1b5231a --- /dev/null +++ b/src/com/engine/kq/util/UtilKQ.java @@ -0,0 +1,143 @@ +package com.engine.kq.util; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.biz.*; +import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum; +import weaver.common.DateUtil; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; + +public class UtilKQ extends BaseBean { + + private static DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + public static String getWeekDay(int day, int language){ + String weekDay=""; + if(day==0){ + weekDay= SystemEnv.getHtmlLabelName(16100, language); + }else if(day==1){ + weekDay=SystemEnv.getHtmlLabelName(16101, language); + }else if(day==2){ + weekDay=SystemEnv.getHtmlLabelName(16102, language); + }else if(day==3){ + weekDay=SystemEnv.getHtmlLabelName(16103, language); + }else if(day==4){ + weekDay=SystemEnv.getHtmlLabelName(16104, language); + }else if(day==5){ + weekDay=SystemEnv.getHtmlLabelName(16105, language); + }else if(day==6){ + weekDay=SystemEnv.getHtmlLabelName(16106, language); + } + return weekDay; + } + + public static String getWeekDayShort(int day, int language){ + String weekDay=""; + if(day==0){ + weekDay= SystemEnv.getHtmlLabelName(385821, language); + }else if(day==1){ + weekDay=SystemEnv.getHtmlLabelName(385822, language); + }else if(day==2){ + weekDay=SystemEnv.getHtmlLabelName(385823, language); + }else if(day==3){ + weekDay=SystemEnv.getHtmlLabelName(385824, language); + }else if(day==4){ + weekDay=SystemEnv.getHtmlLabelName(385825, language); + }else if(day==5){ + weekDay=SystemEnv.getHtmlLabelName(385826, language); + }else if(day==6){ + weekDay=SystemEnv.getHtmlLabelName(385820, language); + } + return weekDay; + } + + public static String getPrimaryKeyGuid1SqlStr(String dBType){ + String guid1SQlStr = "replace(newid(),'-','')"; + if("oracle".equalsIgnoreCase(dBType)){ + guid1SQlStr = "SYS_GUID()"; + }else if("mysql".equalsIgnoreCase(dBType)){ + guid1SQlStr = "replace(uuid(),'-','')"; + } + else if("postgresql".equalsIgnoreCase(dBType)){ + guid1SQlStr = "replace(uuid(),'-','')"; + } + else if("dm".equalsIgnoreCase(dBType)){ + guid1SQlStr = "replace(SYS_GUID(),'0x','')"; + } + return guid1SQlStr; + } + + public static String getTimeStampSqlStr(String dBType){ + String timeStampSqlStr = "convert(char(10),getdate(),20)+' '+convert(char(8),getdate(),108)"; + if("oracle".equalsIgnoreCase(dBType)){ + timeStampSqlStr = "to_char(sysdate,'yyyy-mm-dd hh24:mi:ss')"; + } + else if("postgresql".equalsIgnoreCase(dBType)){ + timeStampSqlStr = "to_char(now(),'yyyy-mm-dd hh24:mi:ss')"; + } + else if("mysql".equalsIgnoreCase(dBType)){ + timeStampSqlStr = "date_format(NOW(),'%Y-%m-%d %H:%i:%s')"; + } + return timeStampSqlStr; + } + + public static String getTimesAcross(String times){ + String result = times; + String[] hourMins = Util.splitString(times,":"); + if(hourMins.length==2){ + result = 24 + Util.getIntValue(hourMins[0])+":"+hourMins[1]; + } + return result; + } + + /** + * 计算签到签退状态 + * @param signType + * @param workdatesection + * @return + */ + public static String getSignStatus(String signType, String strSignDateTime ,String strWorkDateTime) { + String signStatus = ""; + try{ + strSignDateTime = DateUtil.formatDateTime(strSignDateTime); + strWorkDateTime = DateUtil.formatDateTime(strWorkDateTime); + LocalDateTime signDateTime = LocalDateTime.parse(strSignDateTime,fullFormatter); + LocalDateTime workDateTime = LocalDateTime.parse(strWorkDateTime,fullFormatter); + //签到的话 + if("1".equalsIgnoreCase(signType)){ + //打卡时间比上班时间晚,迟到了 + if(signDateTime.isAfter(workDateTime)){ + signStatus = ButtonStatusEnum.BELATE.getStatusCode(); + }else{ + signStatus = ButtonStatusEnum.NORMAL.getStatusCode(); + } + }else if("2".equalsIgnoreCase(signType)){ + //签退的话 + //打卡时间比下班班时间晚,早退了 + if(signDateTime.isBefore(workDateTime)){ + signStatus = ButtonStatusEnum.LEAVEERALY.getStatusCode(); + }else{ + signStatus = ButtonStatusEnum.NORMAL.getStatusCode(); + } + } + }catch (Exception e){ + new BaseBean().writeLog("com.engine.kq.util.UtilKQ.getSignStatus"+e); + } + return signStatus; + } + + + public static void main(String[] args){ + for(int i=0; i<10; i++){ + UUID uuid = UUID.randomUUID(); + System.err.println(uuid); + } + } +} diff --git a/src/com/engine/kq/util/face/hrmrestful/service/KqPunchButton4EWebServiceManager.java b/src/com/engine/kq/util/face/hrmrestful/service/KqPunchButton4EWebServiceManager.java new file mode 100644 index 0000000..f84c4a7 --- /dev/null +++ b/src/com/engine/kq/util/face/hrmrestful/service/KqPunchButton4EWebServiceManager.java @@ -0,0 +1,49 @@ +package com.engine.kq.util.face.hrmrestful.service; + +import com.alibaba.fastjson.JSONObject; +import com.engine.hrm.util.face.hrmrestful.style.HrmConverControllerStyle; +import com.engine.hrm.web.HrmRestFulInterfaceAction; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.*; +import weaver.hrm.cachecenter.bean.LoadComInfo; +import weaver.hrm.cachecenter.util.SqlUtil; +import weaver.hrm.common.ReflectUtil; +import weaver.hrm.common.database.dialect.DbDialectFactory; +import weaver.hrm.common.database.dialect.IDbDialectSql; +import weaver.hrm.common.database.dialect.constract.DateFormatStyle; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.definedfield.HrmCusFieldComInfo; +import weaver.hrm.definedfield.HrmFieldComInfo; +import weaver.hrm.definedfield.HrmFieldManager; +import weaver.hrm.resource.ResourceComInfo; +import weaver.hrm.webservice.HrmServiceAction; +import weaver.hrm.webservice.HrmServiceImpl; +import weaver.hrm.webservice.JobTitleBean; +import weaver.hrm.webservice.OrgXmlBean; +import weaver.hrm.webservice.exception.HrmWebServiceException; +import weaver.join.hrm.in.HrmResourceVo; +import weaver.join.hrm.in.ImportLog; +import weaver.join.hrm.in.processImpl.HrmImportProcess; + +import java.util.*; + +public class KqPunchButton4EWebServiceManager extends BaseBean { + + public void checkToken(String token, String randomVal){ + boolean isError = true; + if(token.length()>0 && randomVal.length()>0){ + String tokenName = getPropValue("QC1008221", "tokenKey"); + if(tokenName.length()>0){ + MD5 md5 = new MD5(); + if(token.equals(md5.getMD5ofStr(tokenName+randomVal))){ + isError = false; + } + } + } + if(isError){ + throw new HrmWebServiceException("-1",String.format("tokey异常,无权限访问!")) ; + } + } +} diff --git a/src/com/engine/kq/web/GetKQDatasAction.java b/src/com/engine/kq/web/GetKQDatasAction.java new file mode 100644 index 0000000..858e7b4 --- /dev/null +++ b/src/com/engine/kq/web/GetKQDatasAction.java @@ -0,0 +1,967 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.*; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.service.KQReportDetailService; +import com.engine.kq.service.impl.KQReportDetailServiceImpl; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.util.SplitActionUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +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 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.math.BigDecimal; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.SimpleDateFormat; +import java.util.*; + +@Path("/web/report") +public class GetKQDatasAction { + + private BaseBean logger = new BaseBean(); + private static KQLog kqlog = new KQLog();//用于记录日志信息 + private static DecimalFormat df = new DecimalFormat("0.00"); + private DecimalFormatSymbols symbols = new DecimalFormatSymbols(); + + + public String format(double value) { +// DecimalFormatSymbols symbols = new DecimalFormatSymbols(); + symbols.setDecimalSeparator('.'); + df.setMaximumFractionDigits(5); + df.setDecimalFormatSymbols(symbols); + return df.format(value); + } + + /** + * 获取请假相关数据 + * 可以传leavetype=假期类型id,来获取单个假期类型的时长 + * @param request + * @param response + * @return + */ + @POST + @Path("/getLeaveDatas") + @Produces(MediaType.TEXT_PLAIN) + public String getLeaveDatas(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + Map params = ParamUtil.request2Map(request); + + RecordSet rs = new RecordSet(); + try { + User user = HrmUserVarify.getUser(request, response); + String leavetype = Util.null2String(request.getParameter("leavetype")); + params.put("leavetype", leavetype); + String resourceStatus = Util.null2String(params.get("status")); + if(resourceStatus.length() == 0){ + params.put("status", "8");//没有传状态则默认查在职 + } + apidatas = getAllLeaveDatas(params,user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取出差数据 + * @param request + * @param response + * @return + */ + @POST + @Path("/getEvectionDatas") + @Produces(MediaType.TEXT_PLAIN) + public String getEvectionDatas(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + Map params = ParamUtil.request2Map(request); + + RecordSet rs = new RecordSet(); + try { + User user = HrmUserVarify.getUser(request, response); + String resourceStatus = Util.null2String(params.get("status")); + if(resourceStatus.length() == 0){ + params.put("status", "8");//没有传状态则默认查在职 + } + apidatas = getAllEvectionDatas(params,user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取公出数据 + * @param request + * @param response + * @return + */ + @POST + @Path("/getOutDatas") + @Produces(MediaType.TEXT_PLAIN) + public String getOutDatas(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + Map params = ParamUtil.request2Map(request); + + RecordSet rs = new RecordSet(); + try { + User user = HrmUserVarify.getUser(request, response); + String resourceStatus = Util.null2String(params.get("status")); + if(resourceStatus.length() == 0){ + params.put("status", "8");//没有传状态则默认查在职 + } + apidatas = getAllOutDatas(params,user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取加班数据 + * @param request + * @param response + * @return + */ + @POST + @Path("/getOvertimeDatas") + @Produces(MediaType.TEXT_PLAIN) + public String getOvertimeDatas(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + Map params = ParamUtil.request2Map(request); + + RecordSet rs = new RecordSet(); + try { + User user = HrmUserVarify.getUser(request, response); + String resourceStatus = Util.null2String(params.get("status")); + if(resourceStatus.length() == 0){ + params.put("status", "8");//没有传状态则默认查在职 + } + apidatas = getAllOvertimeDatas(params,user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤相关数据 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getKQDatas") + @Produces(MediaType.TEXT_PLAIN) + public String getKQDatas(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + Map params = ParamUtil.request2Map(request); + + RecordSet rs = new RecordSet(); + try { + User user = HrmUserVarify.getUser(request, response); + String type = Util.null2String(request.getParameter("type")); + params.put("type", type); + String resourceStatus = Util.null2String(params.get("status")); + if(resourceStatus.length() == 0){ + params.put("status", "8");//没有传状态则默认查在职 + } + apidatas = getAllKQDatas(params,user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + public Map getAllKQDatas(Map params, User user) { + Map retmap = new HashMap(); + List> datas = new ArrayList(); + Map data = null; + RecordSet rs = new RecordSet(); + + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + String type = Util.null2String(params.get("type")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect = Util.null2String(params.get("typeselect")); + if (fromDate.length() == 0 && toDate.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"); + } + } + logger.writeLog("all.params=" + JSONObject.toJSONString(params)); + + 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)) "; + } + String backFields = "select a.id,a.lastname,a.workcode,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.absenteeismMins) as absenteeismMins, " + //旷工次数和时长 + " sum(b.signdays) as signdays,sum(b.signmins) as signmins, " + + " sum(b.forgotCheck)+" + forgotBeginWorkCheck_field + " as forgotCheck "; //漏签次数 + + String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='" + fromDate + "' and b.kqdate <='" + toDate + "'"; + String sqlWhere = getSqlWhere(params, user); + String groupBy = " group by a.id,a.lastname,a.workcode,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle "; + + String sql = backFields + sqlFrom + sqlWhere + groupBy; + logger.writeLog("all.sql=" + sql); + rs.execute(sql); + while (rs.next()) { + data = new HashMap<>(); + String id = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + String workcode = Util.null2String(rs.getString("workcode")); + String subcompanyId = Util.null2String(rs.getString("subcompanyid")); + if(subcompanyId.length()==0){ + subcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id)); + } + + String departmentid = Util.null2String(rs.getString("departmentid")); + if(departmentid.length()==0){ + departmentid = Util.null2String(resourceComInfo.getDepartmentID(id)); + } + String jobtitleId = Util.null2String(rs.getString("jobtitle")); + if(jobtitleId.length()==0){ + jobtitleId = Util.null2String(resourceComInfo.getJobTitle(id)); + } + + String workdays = Util.null2String(rs.getString("workdays")); + String workMins = Util.null2String(rs.getString("workMins")); + String attendancedays = Util.null2String(rs.getString("attendancedays")); + String attendanceMins = Util.null2String(rs.getString("attendanceMins")); + String beLate = Util.null2String(rs.getString("beLate")); + String beLateMins = Util.null2String(rs.getString("beLateMins")); + String graveBeLate = Util.null2String(rs.getString("graveBeLate")); + String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")); + String leaveEearly = Util.null2String(rs.getString("leaveEearly")); + String leaveEarlyMins = Util.null2String(rs.getString("leaveEarlyMins")); + String graveLeaveEarly = Util.null2String(rs.getString("graveLeaveEarly")); + String graveLeaveEarlyMins = Util.null2String(rs.getString("graveLeaveEarlyMins")); + String absenteeism = Util.null2String(rs.getString("absenteeism")); + String signdays = Util.null2String(rs.getString("signdays")); + String signmins = Util.null2String(rs.getString("signmins")); + String absenteeismMins = Util.null2String(rs.getString("absenteeismMins")); + String forgotCheck = Util.null2String(rs.getString("forgotCheck")); + + data.put("id",id); + data.put("lastname",lastname); + data.put("workcode",workcode); + data.put("subcompany",subCompanyComInfo.getSubCompanyname(subcompanyId)); + data.put("department",departmentComInfo.getDepartmentname(departmentid)); + data.put("jobtitle",jobTitlesComInfo.getJobTitlesname(jobtitleId)); + + if (type.equals("workdays") || type.equals("workmins") || type.equals("all")) { + data.put("workdays",workdays); + data.put("workMins",workMins); + } + if (type.equals("attendancedays") || type.equals("attendanceMins") || type.equals("all") || + type.equals("signdays") || type.equals("signmins")) { + data.put("attendancedays",attendancedays); + data.put("attendanceMins",attendanceMins); + } + if (type.equals("beLate") || type.equals("beLateMins") || + type.equals("graveBeLate") || type.equals("graveBeLateMins") || type.equals("all")) { + data.put("beLate",beLate); + data.put("beLateMins",beLateMins); + data.put("graveBeLate",graveBeLate); + data.put("graveBeLateMins",graveBeLateMins); + } + if (type.equals("leaveEearly") || type.equals("leaveEarlyMins") || + type.equals("graveLeaveEarly") || type.equals("graveLeaveEarlyMins") || type.equals("all")) { + data.put("leaveEearly",leaveEearly); + data.put("leaveEarlyMins",leaveEarlyMins); + data.put("graveLeaveEarly",graveLeaveEarly); + data.put("graveLeaveEarlyMins",graveLeaveEarlyMins); + } + if (type.equals("absenteeism") || type.equals("absenteeismMins") || type.equals("all")) { + data.put("absenteeism",absenteeism); + data.put("absenteeismMins",absenteeismMins); + } + if (type.equals("forgotCheck") || type.equals("all")) { + data.put("forgotCheck",forgotCheck); + } + if (type.equals("leave") || type.startsWith("leaveType_") || type.equals("overtimeTotal") || type.equals("all") || + type.equals("businessLeave") || type.equals("officialBusiness") || + type.equals("leaveDeduction")) { +// apidatas = getService(user).getLeaveInfo(params, user); + } + datas.add(data); + } + retmap.put("datas",datas); + } catch (Exception e) { + e.printStackTrace(); + } + return retmap; + } + + /** + * 请假时长 + * 可以根据leavetype来获取单个请假类型的时长 + * @param params + * @param user + * @return + */ + public Map getAllLeaveDatas(Map params, User user){ + Map retmap = new HashMap(); + List> datas = new ArrayList(); + Map flowData = new HashMap<>(); + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + KQReportBiz kqReportBiz = new KQReportBiz(); + flowData.putAll(kqReportBiz.getFlowLeaveData(params,user)); + flowData.putAll(kqReportBiz.getFlowLeaveBackData(params,user)); + String ruleid = Util.null2String(params.get("leavetype")); + logger.writeLog("leave.params=" + JSONObject.toJSONString(params)); + + List> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + RecordSet rs = new RecordSet(); + String sql = ""; + Map data = null; + try{ + ResourceComInfo resourceComInfo = new ResourceComInfo(); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + + String backFields = "select a.id,a.lastname,a.workcode,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle from hrmresource a where 1=1 "; + String sqlWhere = getSqlWhere4Flow(params,user); + String orderBy = " order by a.id"; + sql = backFields+sqlWhere+orderBy; + logger.writeLog("leave.sql="+sql); + rs.execute(sql); + while (rs.next()) { + data = new HashMap<>(); + String id = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + String workcode = Util.null2String(rs.getString("workcode")); + String subcompanyId = Util.null2String(rs.getString("subcompanyid")); + if (subcompanyId.length() == 0) { + subcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id)); + } + + String departmentid = Util.null2String(rs.getString("departmentid")); + if (departmentid.length() == 0) { + departmentid = Util.null2String(resourceComInfo.getDepartmentID(id)); + } + String jobtitleId = Util.null2String(rs.getString("jobtitle")); + if (jobtitleId.length() == 0) { + jobtitleId = Util.null2String(resourceComInfo.getJobTitle(id)); + } + data.put("id",id); + data.put("lastname",lastname); + data.put("workcode",workcode); + data.put("subcompany",subCompanyComInfo.getSubCompanyname(subcompanyId)); + data.put("department",departmentComInfo.getDepartmentname(departmentid)); + data.put("jobtitle",jobTitlesComInfo.getJobTitlesname(jobtitleId)); + + Map leaveRule = null; + for(int i=0;allLeaveRules!=null&&i)allLeaveRules.get(i); + if(!"".equals(ruleid) && !ruleid.equals(leaveRule.get("id"))){//可能会查询某一个假期类型 + continue; + } + String leaveName = Util.null2String(leaveRule.get("name"));//假期名称 + 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){ + logger.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); + data.put(leaveName+"_"+Util.null2String(leaveRule.get("id")),flowLeaveData);//时长 + data.put("unittype",Util.null2String(leaveRule.get("unitType")));//假期单位 + data.put("proportion",Util.null2String(leaveRule.get("proportion")));//折算时长 + } + datas.add(data); + } + retmap.put("datas",datas); + }catch (Exception e){ + logger.writeLog(e); + } + return retmap; + } + + /** + * 出差 + * @param params + * @param user + * @return + */ + public Map getAllEvectionDatas(Map params, User user){ + Map retmap = new HashMap(); + List> datas = new ArrayList(); + Map flowData = new HashMap<>(); + KQReportBiz kqReportBiz = new KQReportBiz(); + flowData.putAll(kqReportBiz.getFlowEvectionOutData(params,user)); + flowData.putAll(kqReportBiz.getFlowProcessChangeData(params,user)); + logger.writeLog("evection.params=" + JSONObject.toJSONString(params)); + + RecordSet rs = new RecordSet(); + String sql = ""; + Map data = null; + try{ + ResourceComInfo resourceComInfo = new ResourceComInfo(); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + + String backFields = "select a.id,a.lastname,a.workcode,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle from hrmresource a where 1=1 "; + String sqlWhere = getSqlWhere4Flow(params,user); + String orderBy = " order by a.id"; + sql = backFields+sqlWhere+orderBy; + logger.writeLog("evection.sql="+sql); + rs.execute(sql); + while (rs.next()) { + data = new HashMap<>(); + String id = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + String workcode = Util.null2String(rs.getString("workcode")); + String subcompanyId = Util.null2String(rs.getString("subcompanyid")); + if (subcompanyId.length() == 0) { + subcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id)); + } + + String departmentid = Util.null2String(rs.getString("departmentid")); + if (departmentid.length() == 0) { + departmentid = Util.null2String(resourceComInfo.getDepartmentID(id)); + } + String jobtitleId = Util.null2String(rs.getString("jobtitle")); + if (jobtitleId.length() == 0) { + jobtitleId = Util.null2String(resourceComInfo.getJobTitle(id)); + } + data.put("id",id); + data.put("lastname",lastname); + data.put("workcode",workcode); + data.put("subcompany",subCompanyComInfo.getSubCompanyname(subcompanyId)); + data.put("department",departmentComInfo.getDepartmentname(departmentid)); + data.put("jobtitle",jobTitlesComInfo.getJobTitlesname(jobtitleId)); + + String fieldName = "businessLeave"; + String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+fieldName)),"0.0"); + String backType = fieldName+"_back"; + String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+backType)),"0.0"); + String businessLeave = ""; + try{ + //以防止出现精度问题 + if(businessLeaveData.length() == 0){ + businessLeaveData = "0.0"; + } + if(businessLeavebackData.length() == 0){ + businessLeavebackData = "0.0"; + } + BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData); + BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData); + businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString(); + if(Util.getDoubleValue(businessLeave, -1) < 0){ + businessLeave = "0.0"; + } + }catch (Exception e){ + } + String duration = KQDurationCalculatorUtil.getDurationRound(businessLeave); + data.put("duration",duration); + + datas.add(data); + } + retmap.put("datas",datas); + }catch (Exception e){ + logger.writeLog(e); + } + return retmap; + } + + /** + * 公出 + * @param params + * @param user + * @return + */ + public Map getAllOutDatas(Map params, User user){ + Map retmap = new HashMap(); + List> datas = new ArrayList(); + Map flowData = new HashMap<>(); + KQReportBiz kqReportBiz = new KQReportBiz(); + flowData.putAll(kqReportBiz.getFlowEvectionOutData(params,user)); + flowData.putAll(kqReportBiz.getFlowProcessChangeData(params,user)); + logger.writeLog("out.params=" + JSONObject.toJSONString(params)); + + RecordSet rs = new RecordSet(); + String sql = ""; + Map data = null; + try{ + ResourceComInfo resourceComInfo = new ResourceComInfo(); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + + String backFields = "select a.id,a.lastname,a.workcode,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle from hrmresource a where 1=1 "; + String sqlWhere = getSqlWhere4Flow(params,user); + String orderBy = " order by a.id"; + sql = backFields+sqlWhere+orderBy; + logger.writeLog("out.sql="+sql); + rs.execute(sql); + while (rs.next()) { + data = new HashMap<>(); + String id = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + String workcode = Util.null2String(rs.getString("workcode")); + String subcompanyId = Util.null2String(rs.getString("subcompanyid")); + if (subcompanyId.length() == 0) { + subcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id)); + } + + String departmentid = Util.null2String(rs.getString("departmentid")); + if (departmentid.length() == 0) { + departmentid = Util.null2String(resourceComInfo.getDepartmentID(id)); + } + String jobtitleId = Util.null2String(rs.getString("jobtitle")); + if (jobtitleId.length() == 0) { + jobtitleId = Util.null2String(resourceComInfo.getJobTitle(id)); + } + data.put("id",id); + data.put("lastname",lastname); + data.put("workcode",workcode); + data.put("subcompany",subCompanyComInfo.getSubCompanyname(subcompanyId)); + data.put("department",departmentComInfo.getDepartmentname(departmentid)); + data.put("jobtitle",jobTitlesComInfo.getJobTitlesname(jobtitleId)); + + String fieldName = "officialBusiness"; + String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+fieldName)),"0.0"); + String backType = fieldName+"_back"; + String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+backType)),"0.0"); + String businessLeave = ""; + try{ + //以防止出现精度问题 + if(businessLeaveData.length() == 0){ + businessLeaveData = "0.0"; + } + if(businessLeavebackData.length() == 0){ + businessLeavebackData = "0.0"; + } + BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData); + BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData); + businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString(); + if(Util.getDoubleValue(businessLeave, -1) < 0){ + businessLeave = "0.0"; + } + }catch (Exception e){ + } + String duration = KQDurationCalculatorUtil.getDurationRound(businessLeave); + data.put("duration",duration); + + datas.add(data); + } + retmap.put("datas",datas); + }catch (Exception e){ + logger.writeLog(e); + } + return retmap; + } + + /** + * 加班 + * @param params + * @param user + * @return + */ + public Map getAllOvertimeDatas(Map params, User user){ + Map retmap = new HashMap(); + List> datas = new ArrayList(); + Map flowData = new HashMap<>(); + KQReportBiz kqReportBiz = new KQReportBiz(); + flowData.putAll(kqReportBiz.getFlowOverTimeDataNew(params,user)); + logger.writeLog("overtime.params=" + JSONObject.toJSONString(params)); + + RecordSet rs = new RecordSet(); + String sql = ""; + Map data = null; + try{ + ResourceComInfo resourceComInfo = new ResourceComInfo(); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + + String backFields = "select a.id,a.lastname,a.workcode,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle from hrmresource a where 1=1 "; + String sqlWhere = getSqlWhere4Flow(params,user); + String orderBy = " order by a.id"; + sql = backFields+sqlWhere+orderBy; + logger.writeLog("overtime.sql="+sql); + rs.execute(sql); + while (rs.next()) { + data = new HashMap<>(); + String id = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + String workcode = Util.null2String(rs.getString("workcode")); + String subcompanyId = Util.null2String(rs.getString("subcompanyid")); + if (subcompanyId.length() == 0) { + subcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id)); + } + + String departmentid = Util.null2String(rs.getString("departmentid")); + if (departmentid.length() == 0) { + departmentid = Util.null2String(resourceComInfo.getDepartmentID(id)); + } + String jobtitleId = Util.null2String(rs.getString("jobtitle")); + if (jobtitleId.length() == 0) { + jobtitleId = Util.null2String(resourceComInfo.getJobTitle(id)); + } + data.put("id",id); + data.put("lastname",lastname); + data.put("workcode",workcode); + data.put("subcompany",subCompanyComInfo.getSubCompanyname(subcompanyId)); + data.put("department",departmentComInfo.getDepartmentname(departmentid)); + data.put("jobtitle",jobTitlesComInfo.getJobTitlesname(jobtitleId)); + + //关联调休-工作日加班时长 + double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_4leave"))); + workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave; + //关联调休-休息日加班时长 + double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_4leave"))); + restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave; + //关联调休-节假日加班时长 + double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_4leave"))); + holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave; + + //不关联调休-工作日加班时长 + double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleave"))); + workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave; + //不关联调休-休息日加班时长 + double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleave"))); + restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave; + //不关联调休-节假日加班时长 + double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleave"))); + holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave; + + //------------------------------------------------------------------------------------------------------- + //合计加班时长 + String duration = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+ + workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave)); + data.put("duration_total",duration); + + //------------------------------------------------------------------------------------------------------- + //合计时长-工作日(关联调休和不关联调休的工作日) + String duration_work = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+workingDayOvertime_nonleave)); + data.put("duration_work",duration_work); + //合计时长-休息日(关联调休和不关联调休的休息日) + String duration_rest = KQDurationCalculatorUtil.getDurationRound(String.valueOf(restDayOvertime_4leave+restDayOvertime_nonleave)); + data.put("duration_rest",duration_rest); + //合计时长-节假日(关联调休和不关联调休的节假日) + String duration_holiday = KQDurationCalculatorUtil.getDurationRound(String.valueOf(holidayOvertime_4leave+holidayOvertime_nonleave)); + data.put("duration_holiday",duration_holiday); + + + //------------------------------------------------------------------------------------------------------- + //关联调休-合计时长 + String duration_4leave = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave)); + data.put("duration_4leave",duration_4leave); + //关联调休-工作日时长 + String duration_4leave_work = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave)); + data.put("duration_4leave_work",duration_4leave_work); + //关联调休-休息日时长 + String duration_4leave_rest = KQDurationCalculatorUtil.getDurationRound(String.valueOf(restDayOvertime_4leave)); + data.put("duration_4leave_rest",duration_4leave_rest); + //关联调休-节假日时长 + String duration_4leave_holiday = KQDurationCalculatorUtil.getDurationRound(String.valueOf(holidayOvertime_4leave)); + data.put("duration_4leave_holiday",duration_4leave_holiday); + + //------------------------------------------------------------------------------------------------------- + //不关联调休-合计时长 + String duration_nonleave = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave)); + data.put("duration_nonleave",duration_nonleave); + String duration_nonleave_work = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_nonleave)); + data.put("duration_nonleave_work",duration_nonleave_work); + String duration_nonleave_rest = KQDurationCalculatorUtil.getDurationRound(String.valueOf(restDayOvertime_nonleave)); + data.put("duration_nonleave_rest",duration_nonleave_rest); + String duration_nonleave_holiday = KQDurationCalculatorUtil.getDurationRound(String.valueOf(holidayOvertime_nonleave)); + data.put("duration_nonleave_holiday",duration_nonleave_holiday); + + datas.add(data); + } + retmap.put("datas",datas); + }catch (Exception e){ + logger.writeLog(e); + } + return retmap; + } + + /** + * @param request + * @param response + * @return + */ + @GET + @Path("/checkDate") + @Produces(MediaType.TEXT_PLAIN) + public String checkDate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map resultMap = new HashMap(); + int code = 1; + String msg = "error"; + + List restList = new ArrayList(); + List workList = new ArrayList(); + KQWorkTime kqWorkTime = new KQWorkTime(); + + /*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/ + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + // + User user = HrmUserVarify.getUser(request, response); + String dateStart = Util.null2String(request.getParameter("dateStart")); + String dateEnd = Util.null2String(request.getParameter("dateEnd")); +// logger.writeLog("date =" + date); +// HrmScheduleDiffUtil util = new HrmScheduleDiffUtil(); +// util.setUser(new User(user.getUID())); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + + //============新优化逻辑====================== + List> splitLists = SplitActionUtil.getSplitDayList(dateStart, dateEnd); + if (!splitLists.isEmpty()) { + for (int i = 0; i < splitLists.size(); i++) { + Map splitMap = splitLists.get(i); + String splitDate = Util.null2String(splitMap.get("splitDate")); + int changeType = -1; + String groupId = kqGroupMemberComInfo.getKQGroupId("" + user.getUID(), splitDate); + /*该人员不存在于任意一个考勤组中,请为其设置考勤组*/ + if (groupId.equals("")) { + logger.writeLog("该人员不存在于任意一个考勤组中,请为其设置考勤组。resourceId=" + user.getUID() + ",date=" + splitDate); + } + + changeType = KQHolidaySetBiz.getChangeType(groupId, splitDate); + if (changeType == 1 || changeType == 3) { + restList.add(splitDate); + } else if (changeType == 2) { + workList.add(splitDate); + } + } + logger.writeLog("restList =" + restList.size() + ":restList:" + restList); + logger.writeLog("workList =" + workList.size() + ":workList:" + workList); + code = 0; + msg = "OK"; + } + //============新优化逻辑====================== + + resultMap.put("code", code); + resultMap.put("msg", msg); + resultMap.put("restList", restList);//休息日 + resultMap.put("workList", workList);//工作日 + + return JSON.toJSONString(resultMap, SerializerFeature.DisableCircularReferenceDetect); + } + + private KQReportDetailService getService(User user) { + return (KQReportDetailService) ServiceUtil.getService(KQReportDetailServiceImpl.class, user); + } + + public String getSqlWhere(Map params, User user) { + RecordSet rs = new RecordSet(); + String resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect = Util.null2String(params.get("typeselect")); + if (fromDate.length() == 0 && toDate.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 viewScope = Util.null2String(params.get("viewScope")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + + String sqlWhere = " "; +// if (fromDate.length() > 0) { +// sqlWhere += " and kqdate >= '" + fromDate + "'"; +// } +// +// if (toDate.length() > 0) { +// sqlWhere += " and kqdate <= '" + toDate + "'"; +// } + + if (subCompanyId.length() > 0) { + sqlWhere += " and a.subcompanyid1 in(" + subCompanyId + ") "; + } + + if (departmentId.length() > 0) { + sqlWhere += " and a.departmentid in(" + departmentId + ") "; + } + + if (resourceId.length() > 0) { + sqlWhere += " and a.id in ( " + resourceId + ")"; + } + + if (resourceStatus.length() > 0) { + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sqlWhere += " and a.status = " + resourceStatus + ""; + } else if (resourceStatus.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + 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<>'' "); + } + + return sqlWhere; + } + + public String getSqlWhere4Flow(Map params, User user) { + RecordSet rs = new RecordSet(); + String resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect = Util.null2String(params.get("typeselect")); + if (fromDate.length() == 0 && toDate.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 viewScope = Util.null2String(params.get("viewScope")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + + String sqlWhere = " "; +// if (fromDate.length() > 0) { +// sqlWhere += " and kqdate >= '" + fromDate + "'"; +// } +// +// if (toDate.length() > 0) { +// sqlWhere += " and kqdate <= '" + toDate + "'"; +// } + + if (subCompanyId.length() > 0) { + sqlWhere += " and a.subcompanyid1 in(" + subCompanyId + ") "; + } + + if (departmentId.length() > 0) { + sqlWhere += " and a.departmentid in(" + departmentId + ") "; + } + + if (resourceId.length() > 0) { + sqlWhere += " and a.id in ( " + resourceId + ")"; + } + + if (resourceStatus.length() > 0) { + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sqlWhere += " and a.status = " + resourceStatus + ""; + } else if (resourceStatus.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + 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<>'' "); + } + + return sqlWhere; + } + +} diff --git a/src/com/engine/kq/web/ImportLogAction.java b/src/com/engine/kq/web/ImportLogAction.java new file mode 100644 index 0000000..7aee58f --- /dev/null +++ b/src/com/engine/kq/web/ImportLogAction.java @@ -0,0 +1,126 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.ImportLogService; +import com.engine.kq.service.impl.ImportLogServiceImpl; +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.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +/** + * Excel导入记录 + * + */ +public class ImportLogAction extends BaseBean { + + private ImportLogService getService(User user) { + return (ImportLogServiceImpl) ServiceUtil.getService(ImportLogServiceImpl.class, user); + } + + /** + * 获取导入进行明细 + */ + @GET + @Path("/getImportProcessLog") + @Produces(MediaType.TEXT_PLAIN) + public String getImportProcessLog(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getImportProcessLog(ParamUtil.request2Map(request), request, user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取历史导入记录 + */ + @GET + @Path("/getImportHistory") + @Produces(MediaType.TEXT_PLAIN) + public String getImportHistory(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getImportHistory(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取导入结果明细 + */ + @GET + @Path("/getImportResult") + @Produces(MediaType.TEXT_PLAIN) + public String getImportResult(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getImportResult(ParamUtil.request2Map(request), request, user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取导入日志 + */ + @GET + @Path("/getImportColResultLog") + @Produces(MediaType.TEXT_PLAIN) + public String getImportColResultLog(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getImportColResultLog(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + * 查询高级条件 + * @param request + * @param response + * @return + */ + @GET + @Path("/getHistorySearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getHistorySearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getHistorySearchCondition(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + +} diff --git a/src/com/engine/kq/web/KQAttendanceButtonAction.java b/src/com/engine/kq/web/KQAttendanceButtonAction.java new file mode 100644 index 0000000..d32bd44 --- /dev/null +++ b/src/com/engine/kq/web/KQAttendanceButtonAction.java @@ -0,0 +1,372 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQAttendanceButtonService; +import com.engine.kq.service.impl.KQAttendanceButtonServiceImpl; +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.HashMap; +import java.util.Map; + + +/** + * 考勤按钮控制 + */ +public class KQAttendanceButtonAction { + private BaseBean logger = new BaseBean(); + + private KQAttendanceButtonService getService(User user) { + return (KQAttendanceButtonServiceImpl) ServiceUtil.getService(KQAttendanceButtonServiceImpl.class, user); + } + + /** + * 获取考勤组的基本信息的 + * @param request + * @param response + * @return + */ + @POST + @Path("/getButtonBaseInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getButtonBaseInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getButtonBaseInfo(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取签到签退按钮 + * 以及考勤流程数据 + * 以及上次签到时间 + * @param request + * @param response + * @return + */ + @POST + @Path("/getButtons") + @Produces(MediaType.TEXT_PLAIN) + public String getButtons(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getButtons(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 签到签退 + * @param request + * @param response + * @return + */ + @POST + @Path("/punchButton") + @Produces(MediaType.TEXT_PLAIN) + public String punchButton(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).punchButton(request,ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 小E签到签退 + * @param request + * @param response + * @return + */ + @POST + @Path("/punchButton4E") + @Produces(MediaType.TEXT_PLAIN) + public String punchButton4E(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).punchButton4E(request,ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + * 外勤签到签退 + * @param request + * @param response + * @return + */ + @POST + @Path("/getOutButtons") + @Produces(MediaType.TEXT_PLAIN) + public String getOutButtons(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getOutButtons(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 外勤签到签退 关联考勤的时候,打卡范围 + * @param request + * @param response + * @return + */ + @POST + @Path("/getOutButtonRange") + @Produces(MediaType.TEXT_PLAIN) + public String getOutButtonRange(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getOutButtonRange(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 外勤签到签退 + * @param request + * @param response + * @return + */ + @POST + @Path("/punchOutButton") + @Produces(MediaType.TEXT_PLAIN) + public String punchOutButton(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).punchOutButton(request,ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 外勤记录 查询条件 + * @param request + * @param response + * @return + */ + @GET + @Path("/getOutButtonCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getOutButtonCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getOutButtonCondition(request,ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 外勤记录 + * @param request + * @param response + * @return + */ + @POST + @Path("/getOutSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getOutSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getOutSearchList(request,ParamUtil.request2Map(request), user,response); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取外勤签到配置 + * @param request + * @param response + * @return + */ + @GET + @Path("/getOutSignSetting") + @Produces(MediaType.TEXT_PLAIN) + public String getOutSignSetting(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getOutSignSetting(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存外勤签到配置 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveOutSignSetting") + @Produces(MediaType.TEXT_PLAIN) + public String saveOutSignSetting(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).saveOutSignSetting(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * EM端自动打卡设置界面 + * @param request + * @param response + * @return + */ + @POST + @Path("/getAutoEMSet") + @Produces(MediaType.TEXT_PLAIN) + public String getAutoEMSet(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getAutoEMSet(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存EM端自动打卡设置界面 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveAutoEMSet") + @Produces(MediaType.TEXT_PLAIN) + public String saveAutoEMSet(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).saveAutoEMSet(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 移动端切换地图,保存最新的当前用户选择的地图 + * @param request + * @param response + * @return + */ + @POST + @Path("/resetUserMap") + @Produces(MediaType.TEXT_PLAIN) + public String resetUserMap(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).resetUserMap(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取用户最后一次选择的地图 + * @param request + * @param response + * @return + */ + @POST + @Path("/getUserLastMap") + @Produces(MediaType.TEXT_PLAIN) + public String getUserLastMap(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getUserLastMap(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 自己调整班次 + * @param request + * @param response + * @return + */ + @POST + @Path("/resetSerial") + @Produces(MediaType.TEXT_PLAIN) + public String resetSerial(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).resetSerial(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KQAttendanceEventAction.java b/src/com/engine/kq/web/KQAttendanceEventAction.java new file mode 100644 index 0000000..7a0d899 --- /dev/null +++ b/src/com/engine/kq/web/KQAttendanceEventAction.java @@ -0,0 +1,449 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQAttendanceEventService; +import com.engine.kq.service.impl.KQAttendanceEventServiceImpl; +import java.util.HashMap; +import java.util.Map; +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 weaver.general.BaseBean; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + + +/** + * 考勤流程相关的ajax请求事件 + */ +public class KQAttendanceEventAction { + private BaseBean logger = new BaseBean(); + + private KQAttendanceEventService getService(User user) { + return (KQAttendanceEventServiceImpl) ServiceUtil.getService(KQAttendanceEventServiceImpl.class, user); + } + + /** + * 获取请假的工作时长,因为请假牵扯到请假类型和时长的关系 + * @param request + * @param response + * @return + */ + @POST + @Path("/getLeaveWorkDuration") + @Produces(MediaType.TEXT_PLAIN) + public String getLeaveWorkDuration(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getLeaveWorkDuration(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取出差的工作时长 + * @param request + * @param response + * @return + */ + @POST + @Path("/getEvectionWorkDuration") + @Produces(MediaType.TEXT_PLAIN) + public String getEvectionWorkDuration(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getEvectionWorkDuration(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取公出的工作时长 + * @param request + * @param response + * @return + */ + @POST + @Path("/getOutWorkDuration") + @Produces(MediaType.TEXT_PLAIN) + public String getOutWorkDuration(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getOutWorkDuration(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取加班的工作时长 + * @param request + * @param response + * @return + */ + @POST + @Path("/getOverTimeDuration") + @Produces(MediaType.TEXT_PLAIN) + public String getOverTimeDuration(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getOverTimeDuration(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取工作时长,这个是通用的 + * @param request + * @param response + * @return + */ + @POST + @Path("/getWorkDuration") + @Produces(MediaType.TEXT_PLAIN) + public String getWorkDuration(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getWorkDuration(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取假期信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/getVacationInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getVacationInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getVacationInfo(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取补卡信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/getAttendanceCard") + @Produces(MediaType.TEXT_PLAIN) + public String getAttendanceCard(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getAttendanceCard(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 请假校验事件 + * @param request + * @param response + * @return + */ + @POST + @Path("/checkLeave") + @Produces(MediaType.TEXT_PLAIN) + public String checkLeave(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).checkLeave(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 出差校验事件 + * @param request + * @param response + * @return + */ + @POST + @Path("/checkEvection") + @Produces(MediaType.TEXT_PLAIN) + public String checkEvection(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).checkEvection(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 公出校验事件 + * @param request + * @param response + * @return + */ + @POST + @Path("/checkOut") + @Produces(MediaType.TEXT_PLAIN) + public String checkOut(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).checkOut(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + * 销假校验事件 + * @param request + * @param response + * @return + */ + @POST + @Path("/checkLeaveBack") + @Produces(MediaType.TEXT_PLAIN) + public String checkLeaveBack(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).checkLeaveBack(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + /** + * 排班校验事件 + * @param request + * @param response + * @return + */ + @POST + @Path("/checkShift") + @Produces(MediaType.TEXT_PLAIN) + public String checkShift(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).checkShift(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 销假流程用的根据流程获取相应的请假信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/getLeaveBackInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getLeaveBackInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getLeaveBackInfo(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 考勤变更流程根据流程获取相应的流程信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/getProcessChangeInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getProcessChangeInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getProcessChangeInfo(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 考勤变更流程计算时长用的 + * @param request + * @param response + * @return + */ + @POST + @Path("/getProcessChangeWorkDuration") + @Produces(MediaType.TEXT_PLAIN) + public String getProcessChangeWorkDuration(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getProcessChangeWorkDuration(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 考勤变更流程提交校验 + * @param request + * @param response + * @return + */ + @POST + @Path("/checkProcessChange") + @Produces(MediaType.TEXT_PLAIN) + public String checkProcessChange(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).checkProcessChange(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 考获取勤变更流程类型 + * @param request + * @param response + * @return + */ + @POST + @Path("/getProcessChangeType") + @Produces(MediaType.TEXT_PLAIN) + public String getProcessChangeType(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getProcessChangeType(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 补卡流程提交校验 + * @param request + * @param response + * @return + */ + @POST + @Path("/checkCard") + @Produces(MediaType.TEXT_PLAIN) + public String checkCard(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).checkCard(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 加班流程提交校验 + * @param request + * @param response + * @return + */ + @POST + @Path("/checkOvertime") + @Produces(MediaType.TEXT_PLAIN) + public String checkOvertime(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).checkOvertime(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KQAttendanceSetAction.java b/src/com/engine/kq/web/KQAttendanceSetAction.java new file mode 100644 index 0000000..67f2fd4 --- /dev/null +++ b/src/com/engine/kq/web/KQAttendanceSetAction.java @@ -0,0 +1,494 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.hrm.service.HrmStateSetService; +import com.engine.hrm.service.impl.HrmStateSetServiceImpl; +import com.engine.kq.service.KQAttendanceSetService; +import com.engine.kq.service.impl.KQAttendanceSetServiceImpl; +import java.util.HashMap; +import java.util.Map; +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.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import weaver.general.BaseBean; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +/** + * 新考勤 考勤流程设置 + */ +public class KQAttendanceSetAction extends BaseBean { + + private KQAttendanceSetService getService(User user) { + return (KQAttendanceSetService) ServiceUtil.getService(KQAttendanceSetServiceImpl.class, user); + } + + /** + * 获取状态变更右键菜单 + * @param request + * @param response + * @return + */ + @POST + @Path("/getStateRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getStateRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getStateRightMenu(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取状态变更流程的 tab页签数据 + * @param request + * @param response + * @return + */ + @POST + @Path("/getStateProcSetTabInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getStateProcSetTabInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getStateProcSetTabInfo(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取状态变更流程查询条件字段 + * @param request + * @param response + * @return + */ + @GET + @Path("/getStateProcSetListSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getStateProcSetListSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getStateProcSetListSearchCondition(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取状态变更流程查询列表 + * @param request + * @param response + * @return + */ + @POST + @Path("/getStateProcSetListSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getStateProcSetListSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getStateProcSetListSearchList(ParamUtil.request2Map(request),request, user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取状态变更流程 流程概览信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/getStateProcSetFlowForm") + @Produces(MediaType.TEXT_PLAIN) + public String getStateProcSetFlowForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getStateProcSetFlowForm(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存状态变更流程 流程概览信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveStateProcSetFlow") + @Produces(MediaType.TEXT_PLAIN) + public String saveStateProcSetFlow(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveStateProcSetFlow(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取状态变更流程 字段对应信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/getStateProcSetFlowWfFields") + @Produces(MediaType.TEXT_PLAIN) + public String getStateProcSetFlowWfFields(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getStateProcSetFlowWfFields(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存状态变更流程 字段对应信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveStateProcSetFlowWfFields") + @Produces(MediaType.TEXT_PLAIN) + public String saveStateProcSetFlowWfFields(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveStateProcSetFlowWfFields(ParamUtil.request2Map(request),request, user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取状态变更流程 动作设置 + * @param request + * @param response + * @return + */ + @POST + @Path("/getStateProcSetFlowWfSet") + @Produces(MediaType.TEXT_PLAIN) + public String getStateProcSetFlowWfSet(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getStateProcSetFlowWfSet(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存状态变更流程的 动作设置 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveStateProcSetFlowWfSet") + @Produces(MediaType.TEXT_PLAIN) + public String saveStateProcSetFlowWfSet(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveStateProcSetFlowWfSet(ParamUtil.request2Map(request),request,response, user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 删除通用变更流程 + * @param request + * @param response + * @return + */ + @POST + @Path("/delStateProcSet") + @Produces(MediaType.TEXT_PLAIN) + public String delStateProcSet(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).delStateProcSet(ParamUtil.request2Map(request),request, user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 改变通用变更流程的状态 + * @param request + * @param response + * @return + */ + @POST + @Path("/changeStateProcSetStatus") + @Produces(MediaType.TEXT_PLAIN) + public String changeStateProcSetStatus(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).changeStateProcSetStatus(ParamUtil.request2Map(request),request, user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取状态变更流程 自动创建表单 + * @param request + * @param response + * @return + */ + @POST + @Path("/getStateProcSetCreateForm") + @Produces(MediaType.TEXT_PLAIN) + public String getStateProcSetCreateForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getStateProcSetCreateForm(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存状态变更流程 自动创建表单 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveStateProcSetCreateForm") + @Produces(MediaType.TEXT_PLAIN) + public String saveStateProcSetCreateForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveStateProcSetCreateForm(ParamUtil.request2Map(request),request, user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 根据基本信息页面的选择的下拉框同步,带出不同的模板文件 + * @param request + * @param response + * @return + */ + @POST + @Path("/getProcSetTemplet") + @Produces(MediaType.TEXT_PLAIN) + public String getProcSetTemplet(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getProcSetTemplet(ParamUtil.request2Map(request),request, user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取自定义考勤流程tab页签 + * @param request + * @param response + * @return + */ + @POST + @Path("/getCustomKQFlowTab") + @Produces(MediaType.TEXT_PLAIN) + public String getCustomKQFlowTab(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getCustomKQFlowTab(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 考勤流程 新建校验规则 + * @param request + * @param response + * @return + */ + @POST + @Path("/getProcSetCheckRule") + @Produces(MediaType.TEXT_PLAIN) + public String getProcSetCheckRule(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getProcSetCheckRule(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 考勤流程 校验规则列表 + * @param request + * @param response + * @return + */ + @POST + @Path("/getStateProcSetFlowCheckRuleList") + @Produces(MediaType.TEXT_PLAIN) + public String getStateProcSetFlowCheckRuleList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getStateProcSetFlowCheckRuleList(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 考勤流程 保存校验规则 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveStateProcCheckRule") + @Produces(MediaType.TEXT_PLAIN) + public String saveStateProcCheckRule(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).saveStateProcCheckRule(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 考勤流程 删除校验规则 + * @param request + * @param response + * @return + */ + @POST + @Path("/delStateProcCheckRule") + @Produces(MediaType.TEXT_PLAIN) + public String delStateProcCheckRule(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).delStateProcCheckRule(ParamUtil.request2Map(request), user); + apidatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apidatas.put("api_status", false); + apidatas.put("api_errormsg","system error"); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KQBalanceDetailAction.java b/src/com/engine/kq/web/KQBalanceDetailAction.java new file mode 100644 index 0000000..18bb78c --- /dev/null +++ b/src/com/engine/kq/web/KQBalanceDetailAction.java @@ -0,0 +1,172 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQBalanceDetailService; +import com.engine.kq.service.impl.KQBalanceDetailServiceImpl; +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.HashMap; +import java.util.Map; + +public class KQBalanceDetailAction extends BaseBean { + + private KQBalanceDetailService getService(User user) { + return (KQBalanceDetailService) ServiceUtil.getService(KQBalanceDetailServiceImpl.class, user); + } + + /** + * 判断是否有权限 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHasRight") + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + boolean hasRight = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user); + apiDatas.put("hasRight", hasRight); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取查询列表 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchList(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取编辑的表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getBalanceForm") + @Produces(MediaType.TEXT_PLAIN) + public String getBalanceForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getBalanceForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 编辑 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/editBalance") + @Produces(MediaType.TEXT_PLAIN) + public String editBalance(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).editBalance(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 删除 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/deleteBalance") + @Produces(MediaType.TEXT_PLAIN) + public String deleteBalance(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).deleteBalance(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } +} diff --git a/src/com/engine/kq/web/KQBalanceOfLeaveAction.java b/src/com/engine/kq/web/KQBalanceOfLeaveAction.java new file mode 100644 index 0000000..a93533a --- /dev/null +++ b/src/com/engine/kq/web/KQBalanceOfLeaveAction.java @@ -0,0 +1,249 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQBalanceOfLeaveService; +import com.engine.kq.service.impl.KQBalanceOfLeaveServiceImpl; +import com.engine.kq.util.ImportProcessUtil; +import weaver.general.BaseBean; +import weaver.general.Util; +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.HashMap; +import java.util.Map; + +/** + * 假期余额 + */ +public class KQBalanceOfLeaveAction extends BaseBean { + + private KQBalanceOfLeaveService getService(User user) { + return (KQBalanceOfLeaveService) ServiceUtil.getService(KQBalanceOfLeaveServiceImpl.class, user); + } + + /** + * 判断是否有权限 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHasRight") + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + boolean hasRight = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user); + apiDatas.put("hasRight", hasRight); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取搜索条件 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchCondition(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取查询列表 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchList(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取可见的页签 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getTabs") + @Produces(MediaType.TEXT_PLAIN) + public String getTabs(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getTabs(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 批处理 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/batchProcessing") + @Produces(MediaType.TEXT_PLAIN) + public String batchProcessing(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).batchProcessing(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 保存假期余额 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/saveBalanceOfLeave") + @Produces(MediaType.TEXT_PLAIN) + public String saveBalanceOfLeave(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).saveBalanceOfLeave(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取导入的表单 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getImportForm") + @Produces(MediaType.TEXT_PLAIN) + public String getImportForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getImportForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 保存导入 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/saveImport") + @Produces(MediaType.TEXT_PLAIN) + public String saveImport(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).saveImport(ParamUtil.request2Map(request), user,request); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } +} diff --git a/src/com/engine/kq/web/KQBalanceOfLeaveRpAction.java b/src/com/engine/kq/web/KQBalanceOfLeaveRpAction.java new file mode 100644 index 0000000..6941ad5 --- /dev/null +++ b/src/com/engine/kq/web/KQBalanceOfLeaveRpAction.java @@ -0,0 +1,301 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.biz.KQSettingsBiz; +import com.engine.kq.service.KQBalanceOfLeaveRpService; +import com.engine.kq.service.impl.KQBalanceOfLeaveRpServiceImpl; +import weaver.filter.XssUtil; +import weaver.general.BaseBean; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +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.HashMap; +import java.util.Map; + +/** + * 员工假期余额报表 + */ +public class KQBalanceOfLeaveRpAction { + + private KQBalanceOfLeaveRpService getService(User user) { + return (KQBalanceOfLeaveRpService) ServiceUtil.getService(KQBalanceOfLeaveRpServiceImpl.class, user); + } + + /** + * 判断是否有权限 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHasRight") + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas.put("hasRight", user != null); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取TAB页签 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getTab") + @Produces(MediaType.TEXT_PLAIN) + public String getTab(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getTab(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取搜索条件 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchCondition(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取查询列表 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchList(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取假期的详细使用记录 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getUsageRecordDetail") + @Produces(MediaType.TEXT_PLAIN) + public String getUsageRecordDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getUsageRecordDetail(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取分页信息 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getPageInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getPageInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getPageInfo(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取假期使用记录的分页组件 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getDetailPageInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getDetailPageInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getDetailPageInfo(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取假期使用记录的查询条件 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getChangeType") + @Produces(MediaType.TEXT_PLAIN) + public String getChangeType(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getChangeType(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + @GET + @Path("/exportExcelFlag") + @Produces(MediaType.TEXT_PLAIN) + public String exportExcelFlag(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + User user = HrmUserVarify.getUser(request, response); + try { + boolean hasReportRight = new KQReportBiz().hasReportRight("4",""+user.getUID()); + boolean kq_personal_reportsearch = KQSettingsBiz.showLeaveTypeSet("kq_personal_reportsearch"); + if(!hasReportRight && kq_personal_reportsearch) { + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", SystemEnv.getHtmlLabelName(543685, user.getLanguage())); + } else { + Map params = ParamUtil.request2Map(request); + new KQReportBiz().insertKqReportExportLog(params, user); + apiDatas.put("api_status", true); + } + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + new BaseBean().writeLog("balanceofleaverp>>>exportExcelFlag::apiDatasJson:::::::"+JSONObject.toJSONString(apiDatas)); + return JSONObject.toJSONString(apiDatas); + } + + /** + * 导出Excel + * + * @param request + * @param response + * @return + */ + @POST + @Path("/exportExcel") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public String exportExcel(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).exportExcel(ParamUtil.request2Map(request), user, request, response); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + new BaseBean().writeLog("balanceofleaverp>>>ExportExcelCmd::apiDatasJson:::::::"+JSONObject.toJSONString(apiDatas)); + return JSONObject.toJSONString(apiDatas); + } +} diff --git a/src/com/engine/kq/web/KQGroupAction.java b/src/com/engine/kq/web/KQGroupAction.java new file mode 100644 index 0000000..e8e6a32 --- /dev/null +++ b/src/com/engine/kq/web/KQGroupAction.java @@ -0,0 +1,393 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQGroupService; +import com.engine.kq.service.impl.KQGroupServiceImpl; +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.HashMap; +import java.util.Map; + +/** + * 考勤组管理 + */ +public class KQGroupAction extends BaseBean { + + private KQGroupService getService(User user) { + return (KQGroupService) ServiceUtil.getService(KQGroupServiceImpl.class, user); + } + + /** + * 是否有权限 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getHasRight") + @Produces(MediaType.TEXT_PLAIN) + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas.put("hasRight", HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)); + apidatas.put("status", "1"); + } catch (Exception e) { + apidatas.put("status", "-1"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 查询条件 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getSearchCondition(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 查询结果 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getSearchList(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + * 获取新建编辑表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getForm") + @Produces(MediaType.TEXT_PLAIN) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getForm(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + * 保存 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/save") + @Produces(MediaType.TEXT_PLAIN) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).save(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + * 删除 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/del") + @Produces(MediaType.TEXT_PLAIN) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).del(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取Tab + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getTabs") + @Produces(MediaType.TEXT_PLAIN) + public String getTabs(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getTabs(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 导入考勤方式 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/importExcel") + @Produces(MediaType.TEXT_PLAIN) + public String importExcel(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).importExcel(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 导出考勤方式 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/exportExcel") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public String exportExcel(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).exportExcel(ParamUtil.request2Map(request), request, response, user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 考勤组树形 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getGroupTree") + @Produces(MediaType.TEXT_PLAIN) + public String getGroupTree(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getGroupTree(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取排班周期新建编辑表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getShiftCycleForm") + @Produces(MediaType.TEXT_PLAIN) + public String getShiftCycleForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getShiftCycleForm(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤组tabs + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getMainTabs") + @Produces(MediaType.TEXT_PLAIN) + public String getMainTabs(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getMainTabs(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤组人员搜索条件 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getGroupMemeberCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getGroupMemeberCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getGroupMemeberCondition(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取添加考勤组成员表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getAddMemberCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getAddMemberCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getAddMemberCondition(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存考勤组人员信息 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/saveAddMember") + @Produces(MediaType.TEXT_PLAIN) + public String saveAddMember(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveAddMenber(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤组人员信息 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getGroupMemberList") + @Produces(MediaType.TEXT_PLAIN) + public String getGroupMemberList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getGroupMemberList(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KQGroupLocationAction.java b/src/com/engine/kq/web/KQGroupLocationAction.java new file mode 100644 index 0000000..4f73efd --- /dev/null +++ b/src/com/engine/kq/web/KQGroupLocationAction.java @@ -0,0 +1,148 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.service.KQGroupLocationService; +import com.engine.kq.service.impl.KQGroupLocationServiceImpl; +import weaver.general.BaseBean; +import weaver.general.Util; +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.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 考勤组办公地点 + */ +public class KQGroupLocationAction extends BaseBean { + + private KQGroupLocationService getService(User user) { + return (KQGroupLocationService) ServiceUtil.getService(KQGroupLocationServiceImpl.class, user); + } + + + /** + * 查列表 + * @param request + * @param response + * @return + */ + @GET + @Path("/getGroupLocationList") + @Produces(MediaType.TEXT_PLAIN) + public String getGroupLocationList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getGroupLocationList(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取新建编辑表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getForm") + @Produces(MediaType.TEXT_PLAIN) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + *保存 + * @param request + * @param response + * @return + */ + @POST + @Path("/save") + @Produces(MediaType.TEXT_PLAIN) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).save(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + * 删除 + * @param request + * @param response + * @return + */ + @POST + @Path("/del") + @Produces(MediaType.TEXT_PLAIN) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).del(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获办公地点信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/getLocationWifiInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getLocationWifiInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + String userId = Util.null2String(request.getParameter("userId")); + String showWifiList = Util.null2String(request.getParameter("showWifiList")); + if(userId.length()==0)userId = ""+user.getUID(); + apidatas = new KQGroupBiz().getLocationWifiInfo(userId,showWifiList); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + +} diff --git a/src/com/engine/kq/web/KQGroupMemberAction.java b/src/com/engine/kq/web/KQGroupMemberAction.java new file mode 100644 index 0000000..256e3ac --- /dev/null +++ b/src/com/engine/kq/web/KQGroupMemberAction.java @@ -0,0 +1,164 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQGroupMemberService; +import com.engine.kq.service.impl.KQGroupMemberServiceImpl; +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.HashMap; +import java.util.Map; + +/** + * 考勤组成员 + */ +public class KQGroupMemberAction extends BaseBean { + + private KQGroupMemberService getService(User user) { + return (KQGroupMemberService) ServiceUtil.getService(KQGroupMemberServiceImpl.class, user); + } + + /** + * 查询条件 + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getSearchCondition(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + /** + * 查询结果 + * @param request + * @param response + * @return + */ + @POST + @Path("/getSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getSearchList(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + * 获取新建编辑表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getForm") + @Produces(MediaType.TEXT_PLAIN) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getForm(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + + /** + *保存 + * @param request + * @param response + * @return + */ + @POST + @Path("/save") + @Produces(MediaType.TEXT_PLAIN) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).save(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + *批量修改有效期 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveValidateDate") + @Produces(MediaType.TEXT_PLAIN) + public String saveValidateDate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveValidateDate(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + * 删除 + * @param request + * @param response + * @return + */ + @POST + @Path("/del") + @Produces(MediaType.TEXT_PLAIN) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).del(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + +} diff --git a/src/com/engine/kq/web/KQGroupWifiAction.java b/src/com/engine/kq/web/KQGroupWifiAction.java new file mode 100644 index 0000000..fa5a583 --- /dev/null +++ b/src/com/engine/kq/web/KQGroupWifiAction.java @@ -0,0 +1,120 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQGroupWifiService; +import com.engine.kq.service.impl.KQGroupWifiServiceImpl; +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.HashMap; +import java.util.Map; + +/** + * 考勤组WIFI + */ +public class KQGroupWifiAction extends BaseBean { + + private KQGroupWifiService getService(User user) { + return (KQGroupWifiService) ServiceUtil.getService(KQGroupWifiServiceImpl.class, user); + } + + /** + * 获取新建编辑表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getGroupWifiList") + @Produces(MediaType.TEXT_PLAIN) + public String getGroupWifiList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getGroupWifiList(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取新建编辑表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getForm") + @Produces(MediaType.TEXT_PLAIN) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getForm(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + *新建 + * @param request + * @param response + * @return + */ + @POST + @Path("/save") + @Produces(MediaType.TEXT_PLAIN) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).save(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + * 删除 + * @param request + * @param response + * @return + */ + @POST + @Path("/del") + @Produces(MediaType.TEXT_PLAIN) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).del(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KQHolidaySetAction.java b/src/com/engine/kq/web/KQHolidaySetAction.java new file mode 100644 index 0000000..e9501c1 --- /dev/null +++ b/src/com/engine/kq/web/KQHolidaySetAction.java @@ -0,0 +1,419 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQHolidaySetService; +import com.engine.kq.service.impl.KQHolidaySetServiceImpl; +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.HashMap; +import java.util.Map; + +/** + * 节假日设置 + */ +public class KQHolidaySetAction extends BaseBean { + + private KQHolidaySetService getService(User user) { + return (KQHolidaySetService) ServiceUtil.getService(KQHolidaySetServiceImpl.class, user); + } + + /** + * 判断是否有权限 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHasRight") + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + boolean hasRight = HrmUserVarify.checkUserRight("KQHolidaySetEdit:Edit", user); + apiDatas.put("hasRight", hasRight); + apiDatas.put("status", "1"); + } catch (Exception e) { + writeLog(e); + apiDatas.put("status", "-1"); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取查询条件 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传递给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchCondition(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } + + /** + * 清单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传递给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchList(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 日历 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHolidaySetCalendar") + @Produces(MediaType.TEXT_PLAIN) + public String getHolidaySetCalendar(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传递给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getHolidaySetCalendar(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 新建或者编辑的表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHolidaySetForm") + @Produces(MediaType.TEXT_PLAIN) + public String getHolidaySetForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传递给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getHolidaySetForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } + + /** + * 新增 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/addHolidaySet") + @Produces(MediaType.TEXT_PLAIN) + public String addHolidaySet(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + Map params = new HashMap(); + apiDatas = getService(user).addHolidaySet(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 编辑 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/editHolidaySet") + @Produces(MediaType.TEXT_PLAIN) + public String editHolidaySet(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + Map params = new HashMap(); + apiDatas = getService(user).editHolidaySet(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 删除 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/deleteHolidaySet") + @Produces(MediaType.TEXT_PLAIN) + public String deleteHolidaySet(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + Map params = new HashMap(); + apiDatas = getService(user).deleteHolidaySet(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取节假日的统计数据 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHolidayCount") + @Produces(MediaType.TEXT_PLAIN) + public String getHolidayCount(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传递给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getHolidayCount(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取导入的表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getImportForm") + @Produces(MediaType.TEXT_PLAIN) + public String getImportForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传递给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getImportForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 保存导入的数据 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/saveImport") + @Produces(MediaType.TEXT_PLAIN) + public String saveImport(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + Map params = new HashMap(); + apiDatas = getService(user).saveImport(ParamUtil.request2Map(request), request, user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 初始化考勤组的节假日设置 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/initHolidaySet") + @Produces(MediaType.TEXT_PLAIN) + public String initHolidaySet(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传递给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).initHolidaySet(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 新建时判断所选时间范围内是否已经设置过数据 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/hasRepeactData") + @Produces(MediaType.TEXT_PLAIN) + public String hasRepeactData(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传递给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).hasRepeactData(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取同步的表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSyncForm") + @Produces(MediaType.TEXT_PLAIN) + public String getSyncForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传递给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSyncForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 保存同步 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/syncHolidaySet") + @Produces(MediaType.TEXT_PLAIN) + public String syncHolidaySet(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传递给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).syncHolidaySet(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } +} diff --git a/src/com/engine/kq/web/KQLeaveParentalAction.java b/src/com/engine/kq/web/KQLeaveParentalAction.java new file mode 100644 index 0000000..341c2c4 --- /dev/null +++ b/src/com/engine/kq/web/KQLeaveParentalAction.java @@ -0,0 +1,56 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQLeaveParentalService; +import com.engine.kq.service.impl.KQLeaveParentalServiceImpl; +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.HashMap; +import java.util.Map; + +/** + * 假期规则 + */ +public class KQLeaveParentalAction { + + private KQLeaveParentalService getService(User user){ + return (KQLeaveParentalService) ServiceUtil.getService(KQLeaveParentalServiceImpl.class, user); + } + + + /** + * 获取新建或者编辑的表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getParentalForm") + @Produces(MediaType.TEXT_PLAIN) + public String getParentalForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getParentalForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + +} diff --git a/src/com/engine/kq/web/KQLeaveRulesAction.java b/src/com/engine/kq/web/KQLeaveRulesAction.java new file mode 100644 index 0000000..4dcc94f --- /dev/null +++ b/src/com/engine/kq/web/KQLeaveRulesAction.java @@ -0,0 +1,270 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQLeaveRulesService; +import com.engine.kq.service.impl.KQLeaveRulesServiceImpl; +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.HashMap; +import java.util.Map; + +/** + * 假期规则 + */ +public class KQLeaveRulesAction { + + private KQLeaveRulesService getService(User user){ + return (KQLeaveRulesService) ServiceUtil.getService(KQLeaveRulesServiceImpl.class, user); + } + + /** + * 判断是否有权限 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHasRight") + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + boolean hasRight = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user); + apiDatas.put("hasRight", hasRight); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取搜索条件 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchCondition(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取查询列表 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchList(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取新建或者编辑的表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getLeaveRulesForm") + @Produces(MediaType.TEXT_PLAIN) + public String getOvertimeRulesForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getLeaveRulesForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 新建 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/addLeaveRules") + @Produces(MediaType.TEXT_PLAIN) + public String addLeaveRules(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).addLeaveRules(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 编辑 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/editLeaveRules") + @Produces(MediaType.TEXT_PLAIN) + public String editLeaveRules(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).editLeaveRules(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 删除 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/deleteLeaveRules") + @Produces(MediaType.TEXT_PLAIN) + public String deleteLeaveRules(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).deleteLeaveRules(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 判断名称是否重复 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/isNameRepeat") + @Produces(MediaType.TEXT_PLAIN) + public String isNameRepeat(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).isNameRepeat(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 判断当前选择的请假类型的请假单位是天还是小时 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getUnitName") + @Produces(MediaType.TEXT_PLAIN) + public String getUnitName(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getUnitName(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } +} diff --git a/src/com/engine/kq/web/KQLeaveTypesAction.java b/src/com/engine/kq/web/KQLeaveTypesAction.java new file mode 100644 index 0000000..e3f95ce --- /dev/null +++ b/src/com/engine/kq/web/KQLeaveTypesAction.java @@ -0,0 +1,308 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQLeaveTypesService; +import com.engine.kq.service.impl.KQLeaveTypesServiceImpl; +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.HashMap; +import java.util.Map; + +/** + * @Auther: Administrator + * @Date: 2019-03-12 11:17 + * @Description: + */ +public class KQLeaveTypesAction extends BaseBean { + + private KQLeaveTypesService getService(User user){ + return (KQLeaveTypesService) ServiceUtil.getService(KQLeaveTypesServiceImpl.class, user); + } + + /** + * 判断是否有权限 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHasRight") + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + boolean hasRight = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user); + apiDatas.put("hasRight", hasRight); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + @GET + @Path("/getSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchCondition(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取查询列表 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchList(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取新建或者编辑的表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getLeaveTypesForm") + @Produces(MediaType.TEXT_PLAIN) + public String getLeaveTypesForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getLeaveTypesForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 新建 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/addLeaveTypes") + @Produces(MediaType.TEXT_PLAIN) + public String addLeaveTypes(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).addLeaveTypes(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 编辑 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/editLeaveTypes") + @Produces(MediaType.TEXT_PLAIN) + public String editLeaveTypes(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).editLeaveTypes(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 删除 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/deleteLeaveTypes") + @Produces(MediaType.TEXT_PLAIN) + public String deleteLeaveTypes(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).deleteLeaveTypes(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 判断名称是否重复 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/isNameRepeat") + @Produces(MediaType.TEXT_PLAIN) + public String isNameRepeat(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).isNameRepeat(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 是否启用 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/saveDisableLeaveTypes") + @Produces(MediaType.TEXT_PLAIN) + public String saveDisableLeaveRules(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).saveDisableLeaveTypes(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 时间选择方式表单 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getTimeSelectionForm") + @Produces(MediaType.TEXT_PLAIN) + public String getTimeSelectionForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getTimeSelectionForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存时间选择方式表单 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/saveTimeSelectionForm") + @Produces(MediaType.TEXT_PLAIN) + public String saveTimeSelectionForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveTimeSelectionForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KQMyAttendanceAction.java b/src/com/engine/kq/web/KQMyAttendanceAction.java new file mode 100644 index 0000000..42bb3f4 --- /dev/null +++ b/src/com/engine/kq/web/KQMyAttendanceAction.java @@ -0,0 +1,323 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQMyAttendanceService; +import com.engine.kq.service.impl.KQMyAttendanceServiceImpl; +import org.apache.commons.lang3.StringUtils; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; + +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.HashMap; +import java.util.Map; + +/** + * 前台--人事--我的考勤 + */ +public class KQMyAttendanceAction extends BaseBean { + + private KQMyAttendanceService getService(User user){ + return (KQMyAttendanceService) ServiceUtil.getService(KQMyAttendanceServiceImpl.class, user); + } + + private static boolean isIndirectSuperId(String id, String checkSuperId, ResourceComInfo info){ + + int loopBreakTimes = 20 ; + for(String loopId = id; + isRightResourceId(loopId) && (loopBreakTimes--)>0 ; + loopId = info.getManagerID(loopId)){ + if(isDirectSuperId(loopId,checkSuperId,info)) return true ; + } + return false ; + } + + private static boolean isDirectSuperId(String id,String checkSuperId,ResourceComInfo info){ + String superId = Util.null2String(info.getManagerID(id)) ; + return isRightResourceId(superId) && superId.equals(checkSuperId) ; + } + + private static boolean isRightResourceId(String id){ + return StringUtils.isNotBlank(id) && !"0".equals(id) ; + } + + /** + * 我的考勤权限 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/hasRight") + @Produces(MediaType.TEXT_PLAIN) + public String hasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map retmap = new HashMap(); + User user = HrmUserVarify.getUser(request, response); + retmap.put("hasRight", HrmUserVarify.checkUserRight("HrmResource:Absense", user)); + return JSONObject.toJSONString(retmap); + } + + + + /** + * 统计信息 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getHrmKQReportInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getHrmKQReportInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + + Map params = ParamUtil.request2Map(request); + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0); + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0); + String resourceId = Util.null2String(params.get("resourceId")); + //访问页面的时候前端是不会传用户id的,默认为登录人 + resourceId = "".equals(resourceId)?(user.getUID()+""):resourceId; + ResourceComInfo resourceComInfo = new ResourceComInfo(); + if (subCompanyId == 0 || departmentId == 0) { + subCompanyId = Util.getIntValue(resourceComInfo.getSubCompanyID(resourceId), 0); + departmentId = Util.getIntValue(resourceComInfo.getDepartmentID(resourceId), 0); + } + boolean isSelf = resourceId.equals("" + user.getUID()); + boolean isSuperId = isIndirectSuperId(resourceId, user.getUID() + "", resourceComInfo); + boolean hasRoleRight = HrmUserVarify.checkUserRight("HrmResource:Absense", user, departmentId); + + if (!isSelf && !isSuperId && !hasRoleRight) { + apiDatas.put("status", "-1"); + apiDatas.put("hasRight", false); + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } + + apiDatas = getService(user).getHrmKQReportInfo(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } + + /** + * 日历信息 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getHrmKQMonthReportInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getHrmKQMonthReportInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + Map params = ParamUtil.request2Map(request); + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0); + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0); + String resourceId = Util.null2String(params.get("resourceId")); + //访问页面的时候前端是不会传用户id的,默认为登录人 + resourceId = "".equals(resourceId)?(user.getUID()+""):resourceId; + ResourceComInfo resourceComInfo = new ResourceComInfo(); + if (subCompanyId == 0 || departmentId == 0) { + subCompanyId = Util.getIntValue(resourceComInfo.getSubCompanyID(resourceId), 0); + departmentId = Util.getIntValue(resourceComInfo.getDepartmentID(resourceId), 0); + } + if (!resourceId.equals("" + user.getUID()) && !isIndirectSuperId(resourceId, user.getUID() + "", resourceComInfo) && !HrmUserVarify.checkUserRight("HrmResource:Absense", user, departmentId)) { + apiDatas.put("status", "-1"); + apiDatas.put("hasRight", false); + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } + + apiDatas = getService(user).getHrmKQMonthReportInfo(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } + + /** + * 明细列表 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getHrmKQReportDetialInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getHrmKQReportDetialInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + Map params = ParamUtil.request2Map(request); + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0); + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0); + String resourceId = Util.null2String(params.get("resourceId")); + //访问页面的时候前端是不会传用户id的,默认为登录人 + resourceId = "".equals(resourceId)?(user.getUID()+""):resourceId; + ResourceComInfo resourceComInfo = new ResourceComInfo(); + if (subCompanyId == 0 || departmentId == 0) { + subCompanyId = Util.getIntValue(resourceComInfo.getSubCompanyID(resourceId), 0); + departmentId = Util.getIntValue(resourceComInfo.getDepartmentID(resourceId), 0); + } + if (!resourceId.equals("" + user.getUID()) && !isIndirectSuperId(resourceId, user.getUID() + "", resourceComInfo) && !HrmUserVarify.checkUserRight("HrmResource:Absense", user, departmentId)) { + apiDatas.put("status", "-1"); + apiDatas.put("hasRight", false); + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } + + apiDatas = getService(user).getHrmKQReportDetialInfo(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } + + /** + * 获取签到签退信息 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getHrmKQSignInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getHrmKQSignInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + Map params = ParamUtil.request2Map(request); + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0); + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0); + String resourceId = Util.null2String(params.get("resourceId")); + //访问页面的时候前端是不会传用户id的,默认为登录人 + resourceId = "".equals(resourceId)?(user.getUID()+""):resourceId; + ResourceComInfo resourceComInfo = new ResourceComInfo(); + if (subCompanyId == 0 || departmentId == 0) { + subCompanyId = Util.getIntValue(resourceComInfo.getSubCompanyID(resourceId), 0); + departmentId = Util.getIntValue(resourceComInfo.getDepartmentID(resourceId), 0); + } + if (!resourceId.equals("" + user.getUID()) && !isIndirectSuperId(resourceId, user.getUID() + "", resourceComInfo) && !HrmUserVarify.checkUserRight("HrmResource:Absense", user, departmentId)) { + apiDatas.put("status", "-1"); + apiDatas.put("hasRight", false); + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } + + apiDatas = getService(user).getHrmKQSignInfo(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } + + /** + * 移动端【我的考勤】明细的高级搜索 + * @param request + * @param response + * @return + */ + @GET + @Path("/getDetailCondition4Mobile") + @Produces(MediaType.TEXT_PLAIN) + public String getDetailCondition4Mobile(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + Map params = ParamUtil.request2Map(request); + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0); + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0); + String resourceId = Util.null2String(params.get("resourceId")); + //访问页面的时候前端是不会传用户id的,默认为登录人 + resourceId = "".equals(resourceId)?(user.getUID()+""):resourceId; + ResourceComInfo resourceComInfo = new ResourceComInfo(); + if (subCompanyId == 0 || departmentId == 0) { + subCompanyId = Util.getIntValue(resourceComInfo.getSubCompanyID(resourceId), 0); + departmentId = Util.getIntValue(resourceComInfo.getDepartmentID(resourceId), 0); + } + if (!resourceId.equals("" + user.getUID()) && !isIndirectSuperId(resourceId, user.getUID() + "", resourceComInfo) && !HrmUserVarify.checkUserRight("HrmResource:Absense", user, departmentId)) { + apiDatas.put("status", "-1"); + apiDatas.put("hasRight", false); + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } + + apiDatas = getService(user).getDetailCondition4Mobile(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } + + /** + * 移动端【我的考勤】明细 + * @param request + * @param response + * @return + */ + @GET + @Path("/getDetailList4Mobile") + @Produces(MediaType.TEXT_PLAIN) + public String getDetailList4Mobile(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + Map params = ParamUtil.request2Map(request); + int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0); + int departmentId = Util.getIntValue((String) params.get("departmentId"), 0); + String resourceId = Util.null2String(params.get("resourceId")); + //访问页面的时候前端是不会传用户id的,默认为登录人 + resourceId = "".equals(resourceId)?(user.getUID()+""):resourceId; + ResourceComInfo resourceComInfo = new ResourceComInfo(); + if (subCompanyId == 0 || departmentId == 0) { + subCompanyId = Util.getIntValue(resourceComInfo.getSubCompanyID(resourceId), 0); + departmentId = Util.getIntValue(resourceComInfo.getDepartmentID(resourceId), 0); + } + if (!resourceId.equals("" + user.getUID()) && !isIndirectSuperId(resourceId, user.getUID() + "", resourceComInfo) && !HrmUserVarify.checkUserRight("HrmResource:Absense", user, departmentId)) { + apiDatas.put("status", "-1"); + apiDatas.put("hasRight", false); + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } + + apiDatas = getService(user).getDetailList4Mobile(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas, SerializerFeature.DisableCircularReferenceDetect); + } +} diff --git a/src/com/engine/kq/web/KQOriginalPunchRpAction.java b/src/com/engine/kq/web/KQOriginalPunchRpAction.java new file mode 100644 index 0000000..1ca9f9f --- /dev/null +++ b/src/com/engine/kq/web/KQOriginalPunchRpAction.java @@ -0,0 +1,161 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.biz.KQSettingsBiz; +import com.engine.kq.service.KQOriginalPunchRpService; +import com.engine.kq.service.impl.KQOriginalPunchRpServiceImpl; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +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.HashMap; +import java.util.Map; + +/** + * 原始打卡记录报表 + */ +public class KQOriginalPunchRpAction { + + private KQOriginalPunchRpService getService(User user) { + return (KQOriginalPunchRpService) ServiceUtil.getService(KQOriginalPunchRpServiceImpl.class, user); + } + + /** + * 判断是否有权限 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHasRight") + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas.put("hasRight", user != null); + apiDatas.put("status", "1"); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("status", "-1"); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取查询条件 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchCondition(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取查询结果 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchList(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 导出Excel + * + * @param request + * @param response + * @return + */ + @POST + @Path("/exportExcel") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public String exportExcel(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + User user = HrmUserVarify.getUser(request, response); + try { + boolean hasReportRight = new KQReportBiz().hasReportRight("3",""+user.getUID()); + boolean kq_personal_reportsearch = KQSettingsBiz.showLeaveTypeSet("kq_personal_reportsearch"); + if(!hasReportRight && kq_personal_reportsearch) { + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", SystemEnv.getHtmlLabelName(543685, user.getLanguage())); + } else { + Map params = ParamUtil.request2Map(request); + new KQReportBiz().insertKqReportExportLog(params, user); +// apiDatas = getService(user).exportExcel(ParamUtil.request2Map(request), user, request, response); + apiDatas.put("api_status", true); + } + + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } +} diff --git a/src/com/engine/kq/web/KQOvertimeRulesAction.java b/src/com/engine/kq/web/KQOvertimeRulesAction.java new file mode 100644 index 0000000..3395b92 --- /dev/null +++ b/src/com/engine/kq/web/KQOvertimeRulesAction.java @@ -0,0 +1,317 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQOvertimeRulesService; +import com.engine.kq.service.impl.KQOvertimeRulesServiceImpl; +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.HashMap; +import java.util.Map; + +/** + * 加班规则 + */ +public class KQOvertimeRulesAction { + + private KQOvertimeRulesService getService(User user) { + return (KQOvertimeRulesService) ServiceUtil.getService(KQOvertimeRulesServiceImpl.class, user); + } + + /** + * 判断是否有权限 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHasRight") + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + boolean hasRight = HrmUserVarify.checkUserRight("KQOvertimeRulesEdit:Edit", user); + apiDatas.put("hasRight", hasRight); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取查询列表 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchList(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取新建或者编辑的表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getOvertimeRulesForm") + @Produces(MediaType.TEXT_PLAIN) + public String getOvertimeRulesForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getOvertimeRulesForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 新建 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/addOvertimeRules") + @Produces(MediaType.TEXT_PLAIN) + public String addOvertimeRules(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).addOvertimeRules(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 编辑 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/editOvertimeRules") + @Produces(MediaType.TEXT_PLAIN) + public String editOvertimeRules(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).editOvertimeRules(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 删除 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/deleteOvertimeRules") + @Produces(MediaType.TEXT_PLAIN) + public String deleteOvertimeRules(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).deleteOvertimeRules(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 保存是否默认 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/saveDefault") + @Produces(MediaType.TEXT_PLAIN) + public String saveDefault(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).saveDefault(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 判断某考勤组是否重复设置了加班规则 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/isRepeatSetting") + @Produces(MediaType.TEXT_PLAIN) + public String isRepeatSetting(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).isRepeatSetting(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取加班单位的表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getOvertimeUnitForm") + @Produces(MediaType.TEXT_PLAIN) + public String getOvertimeUnitForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getOvertimeUnitForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 加班单位--保存 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/saveOvertimeUnit") + @Produces(MediaType.TEXT_PLAIN) + public String saveOvertimeUnit(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).saveOvertimeUnit(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 加班增加高级搜索查询 + * @param request + * @param response + * @return + */ + @GET + @Path("/getOvertimeSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getOvertimeSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getOvertimeSearchCondition(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } +} diff --git a/src/com/engine/kq/web/KQRemindMsgAction.java b/src/com/engine/kq/web/KQRemindMsgAction.java new file mode 100644 index 0000000..0861887 --- /dev/null +++ b/src/com/engine/kq/web/KQRemindMsgAction.java @@ -0,0 +1,313 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQRemindMsgService; + +import com.engine.kq.service.impl.KQRemindMsgServiceImpl; +import org.apache.commons.lang.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.common.database.dialect.DialectUtil; +import weaver.hrm.resource.ResourceComInfo; + +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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class KQRemindMsgAction extends BaseBean{ + private KQRemindMsgService getService(User user) { + return (KQRemindMsgServiceImpl) ServiceUtil.getService(KQRemindMsgServiceImpl.class, user); + + } + + /** + * 获取查询列表 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchList(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + + /** + * 获取查询列表 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getListData") + @Produces(MediaType.TEXT_PLAIN) + public String getListData(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map jo = new HashMap<>(); + List> columnsList = new ArrayList>(); + Map columns = new HashMap(); + columns.put("dataIndex", "receiverspan"); + columns.put("showType","1"); + columns.put("hide", "false"); + columnsList.add(columns); + + columns = new HashMap(); + columns.put("dataIndex", "contentspan"); + columns.put("showType","1"); + columns.put("hide", "false"); + columnsList.add(columns); + + columns = new HashMap(); + columns.put("dataIndex", "abnormalResourceNamespan"); + columns.put("showType","1"); + columns.put("hide", "false"); + columnsList.add(columns); + + columns = new HashMap(); + columns.put("dataIndex", "sentTimespan"); + columns.put("showType","1"); + columns.put("hide", "false"); + columnsList.add(columns); + + try { + User user = HrmUserVarify.getUser(request, response); + + + RecordSet recordSet = new RecordSet(); + + boolean isOracle = recordSet.getDBType().equals("oracle") || recordSet.getDBType().equals("postgresql"); + + String abnormalResourceName = Util.null2String(request.getParameter("abnormalResourceName"));//人员id + String receiver = Util.null2String(request.getParameter("receiver"));//人员id + String content = Util.null2String(request.getParameter("content"));//人员id + String fromDate = Util.null2String(request.getParameter("fromDate"));//人员id + String toDate = Util.null2String(request.getParameter("toDate"));//人员id + String min = Util.null2String(request.getParameter("min")); + String max = Util.null2String(request.getParameter("max")); + String current = Util.null2String(request.getParameter("current")); + String mysqlEscope = "/"; + String keyword = Util.null2String(request.getParameter("keyword"));//考勤人员姓名 + String uuid = Util.null2String(request.getParameter("uuid"));//人员id + + + String sqlwhere =" where 1=1 "; + if (!"".equals(abnormalResourceName)) { + sqlwhere += " and a.resourceid = " + abnormalResourceName ; + } + + //4、提醒内容 + if (StringUtils.isNotBlank(content)) {// + sqlwhere += " and a.content like '%" + content + "%'"; + } + + if (!"".equals(uuid)) { + sqlwhere += " and a.uuid = '" + uuid +"'"; + } + + //非管理员只能查看自己收到的提醒数据 + if(!user.isAdmin()){ + if(!"".equals(receiver) && user.getUID() != Integer.parseInt(receiver)){ + sqlwhere += " and a.receiverId = 0 "; + } else { + sqlwhere += " and a.receiverid = " + user.getUID(); + } + }else { + if(!"".equals(receiver)){ + sqlwhere += " and a.receiverId = "+receiver; + } + } + if(StringUtils.isNotBlank(keyword)){ + if (DialectUtil.isMySql()) { + sqlwhere += " and a.resourceid in (select id from hrmresource where lastname like '%" + Util.StringReplace(keyword, "_", mysqlEscope + "_") +"%' )"; + } else { + sqlwhere += " and a.resourceid in (select id from hrmresource where lastname like '%" + Util.StringReplace(keyword, "_", "\\_") +"%' )"; + } + } + + + jo.put("columns",columnsList); + + String orderby = " order by sendTime desc"; + String lastsql = "select a.*,ROW_NUMBER() OVER(order by sendTime desc)rn from abnormalremindmsg_log a " + sqlwhere +orderby; + + if(recordSet.getDBType().equals("sqlserver")){ + lastsql = "SELECT TOP 100 PERCENT ROW_NUMBER() OVER (ORDER BY a.sendTime DESC) AS rn,a.* FROM abnormalremindmsg_log a " + sqlwhere + orderby; + } + + // 拼接插入参数; + List getList = new ArrayList(); + getList.add("id"); + getList.add("receiverId"); + getList.add("resourceId"); + getList.add("content"); + getList.add("sendTime"); + List> getRList = getNewlyList(lastsql, min, max,orderby ,getList); + getRList = EditGetMap(getRList); + int count = getCount(lastsql); + jo.put("status", true); + if (null != getRList && 0 < getRList.size()) { + jo.put("datas", getRList); + jo.put("count", count); + } else { + jo.put("datas", new ArrayList()); + jo.put("count", 0); + } + + } catch (Exception e) { + writeLog(e); + jo.put("status", false); + } + return JSONObject.toJSONString(jo); + } + + public List> EditGetMap(List> getRList){ + ResourceComInfo resourceComInfo = new ResourceComInfo(true); + + if (null != getRList && 0 < getRList.size()) { + for (int i = 0; i < getRList.size(); i++) { + getRList.get(i).put("resourceId", resourceComInfo.getLastname(getRList.get(i).get("resourceId"))); + getRList.get(i).put("receiverId", resourceComInfo.getLastname(getRList.get(i).get("receiverId"))); + getRList.get(i).put("content", getRList.get(i).get("content")); + getRList.get(i).put("sendTime", getRList.get(i).get("sendTime")); + getRList.get(i).put("id", getRList.get(i).get("id")); + } + } + return getRList; + } + + + /** + * 获取查询条件 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传递给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchCondition(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + + public List> getNewlyList(String sql1, String min, String max, String orderby, List getList) { + String sql = ""; + RecordSet rs = new RecordSet(); + if (DialectUtil.isMySql(rs.getDBType())) { + sql1 = formatSql(sql1); + sql1 = ("select ALLTemp.*,(@rownumber:=@rownumber+1) as rn from (select a.* from ("+sql1+") a order by sendTime desc ) ALLTemp,(select @rownumber:=0) t") ; + } + + if (DialectUtil.isMySql(rs.getDBType())) { + sql1 = formatSql(sql1); + + if (orderby.length() > 0) { + sql1 += " " + orderby; + } + + sql = "select * from (" + sql1 + ") temp where 1=1 "; + + + if (!"".equals(min)) { + sql += " and temp.rn >=" + min; + } + if (!"".equals(max)) { + sql += " and temp.rn <=" + max; + } + + + } else { + sql = "select * from (" + sql1 + ") tmp where 1=1 "; + + if (!"".equals(min)) { + sql += " and tmp.rn >=" + min; + } + if (!"".equals(max)) { + sql += " and tmp.rn <=" + max; + } + + if (orderby.length() > 0) { + sql += " " + orderby; + } + } + + if (!rs.execute(sql)) { + writeLog("getNewlyList wrongsql :" + sql); + return null; + } + List> getNewlyList = new ArrayList>(); + int j = getList.size(); + + while (rs.next()) { + Map getRMap = new HashMap(); + for (int i = 0; i < j; i++) { + getRMap.put(getList.get(i), rs.getString(getList.get(i))); + } + getNewlyList.add(getRMap); + } + return getNewlyList; + } + + private String formatSql(String sql) { + int startindex = sql.indexOf("ROW_NUMBER() OVER(order by"); + int endindex = sql.indexOf(")rn"); + if (startindex > -1 && endindex > -1) { + String startsql = sql.substring(0, startindex).trim(); + startsql = startsql.substring(0, startsql.length() - 1); + String endsql = sql.substring(endindex + 3, sql.length()); + sql = startsql + " " + endsql; + } + return sql; + } + + public int getCount(String sql1) { + RecordSet rs = new RecordSet(); + if (DialectUtil.isMySql(rs.getDBType())) { + sql1 = formatSql(sql1); + } + String sql = "select count(*) from (" + sql1 + ") tmp"; + if (!rs.execute(sql)) { + writeLog("getCount wrongsql :" + sql); + return 0; + } + return rs.next() ? rs.getInt(1) : 0; + } +} diff --git a/src/com/engine/kq/web/KQRemindOnPCAction.java b/src/com/engine/kq/web/KQRemindOnPCAction.java new file mode 100644 index 0000000..ed41d28 --- /dev/null +++ b/src/com/engine/kq/web/KQRemindOnPCAction.java @@ -0,0 +1,95 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQRemindOnPCService; +import com.engine.kq.service.impl.KQRemindOnPCServiceImpl; +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.HashMap; +import java.util.Map; + +/** + * 考勤提醒 + * 登录PC端后的弹窗提醒 + */ +public class KQRemindOnPCAction { + + private KQRemindOnPCService getService(User user) { + return (KQRemindOnPCServiceImpl) ServiceUtil.getService(KQRemindOnPCServiceImpl.class, user); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRemindInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getRemindInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getRemindInfo(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 地图设置 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveExtraMapConfig") + @Produces(MediaType.TEXT_PLAIN) + public String saveExtraMapConfig(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).saveExtraMapConfig(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 地图设置 + * @param request + * @param response + * @return + */ + @GET + @Path("/getExtraMapConfig") + @Produces(MediaType.TEXT_PLAIN) + public String getExtraMapConfig(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getExtraMapConfig(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KQReport4EAction.java b/src/com/engine/kq/web/KQReport4EAction.java new file mode 100644 index 0000000..3b1591c --- /dev/null +++ b/src/com/engine/kq/web/KQReport4EAction.java @@ -0,0 +1,106 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQReport4EService; +import com.engine.kq.service.impl.KQReport4EServiceImpl; +import java.util.HashMap; +import java.util.Map; +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 weaver.general.BaseBean; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + + +/** + * 考勤按钮控制 + */ +public class KQReport4EAction { + private BaseBean logger = new BaseBean(); + + private KQReport4EService getService(User user) { + return (KQReport4EServiceImpl) ServiceUtil.getService(KQReport4EServiceImpl.class, user); + } + + /** + * 小e 签到签退 + * @param request + * @param response + * @return + */ + @POST + @Path("/punchButton4E") + @Produces(MediaType.TEXT_PLAIN) + public String punchButton4E(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).punchButton4E(request,ParamUtil.request2Map(request), user); + +// response.addHeader("Access-Control-Allow-Origin", "*"); +// response.addHeader("Vary", "Origin"); +// // Access-Control-Allow-Credentials +// response.addHeader("Access-Control-Allow-Credentials", "true"); +// // Access-Control-Allow-Methods +// response.addHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); +// // Access-Control-Allow-Headers +// response.addHeader("Access-Control-Allow-Headers", +// "Origin, X-Requested-With, Content-Type, Accept, " + "X-CSRF-TOKEN"); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 小e 我的考勤情况 + * @param request + * @param response + * @return + */ + @POST + @Path("/getScheduleData") + @Produces(MediaType.TEXT_PLAIN) + public String getScheduleData(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getScheduleData(request,ParamUtil.request2Map(request), user); +// response.addHeader("Access-Control-Allow-Origin", "*"); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 小e 我的假期情况 + * @param request + * @param response + * @return + */ + @POST + @Path("/getBalanceInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getBalanceInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getBalanceInfo(request,ParamUtil.request2Map(request), user); +// response.addHeader("Access-Control-Allow-Origin", "*"); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KQReportAction.java b/src/com/engine/kq/web/KQReportAction.java new file mode 100644 index 0000000..7094a11 --- /dev/null +++ b/src/com/engine/kq/web/KQReportAction.java @@ -0,0 +1,1106 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.*; +import com.engine.kq.log.KQLog; +import com.engine.kq.service.KQReportDetailService; +import com.engine.kq.service.KQReportService; +import com.engine.kq.service.impl.KQReportDetailServiceImpl; +import com.engine.kq.service.impl.KQReportServiceImpl; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.util.SplitActionUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +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 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.math.BigDecimal; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 考勤报表 + */ +public class KQReportAction extends BaseBean { + + private BaseBean logger = new BaseBean(); + private static KQLog kqlog = new KQLog();//用于记录日志信息 + private static DecimalFormat df = new DecimalFormat("0.00"); + private DecimalFormatSymbols symbols = new DecimalFormatSymbols(); + + private KQReportService getService(User user) { + return (KQReportService) ServiceUtil.getService(KQReportServiceImpl.class, user); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 查询条件 + * @param request + * @param response + * @return + */ + @POST + @Path("/getSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getSearchCondition(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + /** + * 格式化考勤 + * @param request + * @param response + * @return + */ + @POST + @Path("/format") + @Produces(MediaType.TEXT_PLAIN) + public String format(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).formatReport(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + * 获取考勤报表 + * @param request + * @param response + * @return + */ + @POST + @Path("/getKQReport") + @Produces(MediaType.TEXT_PLAIN) + public String getKQReport(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + String reportType = Util.null2String(request.getParameter("reportType")); + if(reportType.equals("month")){ + apidatas = getService(user).getKQReport(ParamUtil.request2Map(request), user); + }else if(reportType.equals("daily")){ + apidatas = getService(user).getKQDailyReport(ParamUtil.request2Map(request), user); + } + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 导出考勤报表 + * @param request + * @param response + * @return + */ + @POST + @Path("/exportExcel") + @Produces(MediaType.TEXT_PLAIN) + public String exportExcel(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + String reportType = Util.null2String(request.getParameter("reportType")); + String reportTypeId = "1"; + boolean hasReportRight = false; + if("month".equals(reportType)) { + reportTypeId = "1"; //考勤汇总报表 + } else if("daily".equals(reportType)) { + reportTypeId = "2"; //每日统计报表 + } + hasReportRight = new KQReportBiz().hasReportRight(reportTypeId,""+user.getUID()); + boolean kq_personal_reportsearch = KQSettingsBiz.showLeaveTypeSet("kq_personal_reportsearch"); + if(!hasReportRight && kq_personal_reportsearch) { + apidatas.put("status", "-1"); + apidatas.put("message", SystemEnv.getHtmlLabelName(543685, user.getLanguage())); + return JSONObject.toJSONString(apidatas); + } + if(reportType.equals("month")) { + apidatas = getService(user).exportExcel(ParamUtil.request2Map(request), request, response, user); + }else if(reportType.equals("daily")){ + apidatas = getService(user).exportDailyExcel(ParamUtil.request2Map(request), request, response, user); + } + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + //单独写的api接口提示404,搞到一起 + public String format(double value) { +// DecimalFormatSymbols symbols = new DecimalFormatSymbols(); + symbols.setDecimalSeparator('.'); + df.setMaximumFractionDigits(5); + df.setDecimalFormatSymbols(symbols); + return df.format(value); + } + + /** + * 获取请假相关数据 + * 可以传leavetype=假期类型id,来获取单个假期类型的时长 + * @param request + * @param response + * @return + */ + @POST + @Path("/getLeaveDatas") + @Produces(MediaType.TEXT_PLAIN) + public String getLeaveDatas(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + Map params = ParamUtil.request2Map(request); + + RecordSet rs = new RecordSet(); + try { + User user = HrmUserVarify.getUser(request, response); + String leavetype = Util.null2String(request.getParameter("leavetype")); + params.put("leavetype", leavetype); + String resourceStatus = Util.null2String(params.get("status")); + if(resourceStatus.length() == 0){ + params.put("status", "8");//没有传状态则默认查在职 + } + apidatas = getAllLeaveDatas(params,user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取出差数据 + * @param request + * @param response + * @return + */ + @POST + @Path("/getEvectionDatas") + @Produces(MediaType.TEXT_PLAIN) + public String getEvectionDatas(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + Map params = ParamUtil.request2Map(request); + + RecordSet rs = new RecordSet(); + try { + User user = HrmUserVarify.getUser(request, response); + String resourceStatus = Util.null2String(params.get("status")); + if(resourceStatus.length() == 0){ + params.put("status", "8");//没有传状态则默认查在职 + } + apidatas = getAllEvectionDatas(params,user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取公出数据 + * @param request + * @param response + * @return + */ + @POST + @Path("/getOutDatas") + @Produces(MediaType.TEXT_PLAIN) + public String getOutDatas(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + Map params = ParamUtil.request2Map(request); + + RecordSet rs = new RecordSet(); + try { + User user = HrmUserVarify.getUser(request, response); + String resourceStatus = Util.null2String(params.get("status")); + if(resourceStatus.length() == 0){ + params.put("status", "8");//没有传状态则默认查在职 + } + apidatas = getAllOutDatas(params,user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取加班数据 + * @param request + * @param response + * @return + */ + @POST + @Path("/getOvertimeDatas") + @Produces(MediaType.TEXT_PLAIN) + public String getOvertimeDatas(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + Map params = ParamUtil.request2Map(request); + + RecordSet rs = new RecordSet(); + try { + User user = HrmUserVarify.getUser(request, response); + String resourceStatus = Util.null2String(params.get("status")); + if(resourceStatus.length() == 0){ + params.put("status", "8");//没有传状态则默认查在职 + } + apidatas = getAllOvertimeDatas(params,user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤相关数据 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getKQDatas") + @Produces(MediaType.TEXT_PLAIN) + public String getKQDatas(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + Map params = ParamUtil.request2Map(request); + + RecordSet rs = new RecordSet(); + try { + User user = HrmUserVarify.getUser(request, response); + String type = Util.null2String(request.getParameter("type")); + params.put("type", type); + String resourceStatus = Util.null2String(params.get("status")); + if(resourceStatus.length() == 0){ + params.put("status", "8");//没有传状态则默认查在职 + } + apidatas = getAllKQDatas(params,user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + public Map getAllKQDatas(Map params, User user) { + Map retmap = new HashMap(); + List> datas = new ArrayList(); + Map data = null; + RecordSet rs = new RecordSet(); + + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + String type = Util.null2String(params.get("type")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect = Util.null2String(params.get("typeselect")); + if (fromDate.length() == 0 && toDate.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"); + } + } + logger.writeLog("all.params=" + JSONObject.toJSONString(params)); + + 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)) "; + } + String backFields = "select a.id,a.lastname,a.workcode,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.absenteeismMins) as absenteeismMins, " + //旷工次数和时长 + " sum(b.signdays) as signdays,sum(b.signmins) as signmins, " + + " sum(b.forgotCheck)+" + forgotBeginWorkCheck_field + " as forgotCheck "; //漏签次数 + + String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='" + fromDate + "' and b.kqdate <='" + toDate + "'"; + String sqlWhere = getSqlWhere(params, user); + String groupBy = " group by a.id,a.lastname,a.workcode,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle "; + + String sql = backFields + sqlFrom + sqlWhere + groupBy; + logger.writeLog("all.sql=" + sql); + rs.execute(sql); + while (rs.next()) { + data = new HashMap<>(); + String id = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + String workcode = Util.null2String(rs.getString("workcode")); + String subcompanyId = Util.null2String(rs.getString("subcompanyid")); + if(subcompanyId.length()==0){ + subcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id)); + } + + String departmentid = Util.null2String(rs.getString("departmentid")); + if(departmentid.length()==0){ + departmentid = Util.null2String(resourceComInfo.getDepartmentID(id)); + } + String jobtitleId = Util.null2String(rs.getString("jobtitle")); + if(jobtitleId.length()==0){ + jobtitleId = Util.null2String(resourceComInfo.getJobTitle(id)); + } + + String workdays = Util.null2String(rs.getString("workdays")); + String workMins = Util.null2String(rs.getString("workMins")); + String attendancedays = Util.null2String(rs.getString("attendancedays")); + String attendanceMins = Util.null2String(rs.getString("attendanceMins")); + String beLate = Util.null2String(rs.getString("beLate")); + String beLateMins = Util.null2String(rs.getString("beLateMins")); + String graveBeLate = Util.null2String(rs.getString("graveBeLate")); + String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")); + String leaveEearly = Util.null2String(rs.getString("leaveEearly")); + String leaveEarlyMins = Util.null2String(rs.getString("leaveEarlyMins")); + String graveLeaveEarly = Util.null2String(rs.getString("graveLeaveEarly")); + String graveLeaveEarlyMins = Util.null2String(rs.getString("graveLeaveEarlyMins")); + String absenteeism = Util.null2String(rs.getString("absenteeism")); + String signdays = Util.null2String(rs.getString("signdays")); + String signmins = Util.null2String(rs.getString("signmins")); + String absenteeismMins = Util.null2String(rs.getString("absenteeismMins")); + String forgotCheck = Util.null2String(rs.getString("forgotCheck")); + + data.put("id",id); + data.put("lastname",lastname); + data.put("workcode",workcode); + data.put("subcompany",subCompanyComInfo.getSubCompanyname(subcompanyId)); + data.put("department",departmentComInfo.getDepartmentname(departmentid)); + data.put("jobtitle",jobTitlesComInfo.getJobTitlesname(jobtitleId)); + + if (type.equals("workdays") || type.equals("workmins") || type.equals("all")) { + data.put("workdays",workdays); + data.put("workMins",workMins); + } + if (type.equals("attendancedays") || type.equals("attendanceMins") || type.equals("all") || + type.equals("signdays") || type.equals("signmins")) { + data.put("attendancedays",attendancedays); + data.put("attendanceMins",attendanceMins); + } + if (type.equals("beLate") || type.equals("beLateMins") || + type.equals("graveBeLate") || type.equals("graveBeLateMins") || type.equals("all")) { + data.put("beLate",beLate); + data.put("beLateMins",beLateMins); + data.put("graveBeLate",graveBeLate); + data.put("graveBeLateMins",graveBeLateMins); + } + if (type.equals("leaveEearly") || type.equals("leaveEarlyMins") || + type.equals("graveLeaveEarly") || type.equals("graveLeaveEarlyMins") || type.equals("all")) { + data.put("leaveEearly",leaveEearly); + data.put("leaveEarlyMins",leaveEarlyMins); + data.put("graveLeaveEarly",graveLeaveEarly); + data.put("graveLeaveEarlyMins",graveLeaveEarlyMins); + } + if (type.equals("absenteeism") || type.equals("absenteeismMins") || type.equals("all")) { + data.put("absenteeism",absenteeism); + data.put("absenteeismMins",absenteeismMins); + } + if (type.equals("forgotCheck") || type.equals("all")) { + data.put("forgotCheck",forgotCheck); + } + if (type.equals("leave") || type.startsWith("leaveType_") || type.equals("overtimeTotal") || type.equals("all") || + type.equals("businessLeave") || type.equals("officialBusiness") || + type.equals("leaveDeduction")) { +// apidatas = getService(user).getLeaveInfo(params, user); + } + datas.add(data); + } + retmap.put("datas",datas); + } catch (Exception e) { + e.printStackTrace(); + } + return retmap; + } + + /** + * 请假时长 + * 可以根据leavetype来获取单个请假类型的时长 + * @param params + * @param user + * @return + */ + public Map getAllLeaveDatas(Map params, User user){ + Map retmap = new HashMap(); + List> datas = new ArrayList(); + Map flowData = new HashMap<>(); + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + KQReportBiz kqReportBiz = new KQReportBiz(); + flowData.putAll(kqReportBiz.getFlowLeaveData(params,user)); + flowData.putAll(kqReportBiz.getFlowLeaveBackData(params,user)); + String ruleid = Util.null2String(params.get("leavetype")); + logger.writeLog("leave.params=" + JSONObject.toJSONString(params)); + + List> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + RecordSet rs = new RecordSet(); + String sql = ""; + Map data = null; + try{ + ResourceComInfo resourceComInfo = new ResourceComInfo(); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + + String backFields = "select a.id,a.lastname,a.workcode,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle from hrmresource a where 1=1 "; + String sqlWhere = getSqlWhere4Flow(params,user); + String orderBy = " order by a.id"; + sql = backFields+sqlWhere+orderBy; + logger.writeLog("leave.sql="+sql); + rs.execute(sql); + while (rs.next()) { + data = new HashMap<>(); + String id = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + String workcode = Util.null2String(rs.getString("workcode")); + String subcompanyId = Util.null2String(rs.getString("subcompanyid")); + if (subcompanyId.length() == 0) { + subcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id)); + } + + String departmentid = Util.null2String(rs.getString("departmentid")); + if (departmentid.length() == 0) { + departmentid = Util.null2String(resourceComInfo.getDepartmentID(id)); + } + String jobtitleId = Util.null2String(rs.getString("jobtitle")); + if (jobtitleId.length() == 0) { + jobtitleId = Util.null2String(resourceComInfo.getJobTitle(id)); + } + data.put("id",id); + data.put("lastname",lastname); + data.put("workcode",workcode); + data.put("subcompany",subCompanyComInfo.getSubCompanyname(subcompanyId)); + data.put("department",departmentComInfo.getDepartmentname(departmentid)); + data.put("jobtitle",jobTitlesComInfo.getJobTitlesname(jobtitleId)); + + Map leaveRule = null; + for(int i=0;allLeaveRules!=null&&i)allLeaveRules.get(i); + if(!"".equals(ruleid) && !ruleid.equals(leaveRule.get("id"))){//可能会查询某一个假期类型 + continue; + } + String leaveName = Util.null2String(leaveRule.get("name"));//假期名称 + 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){ + logger.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); + data.put(leaveName+"_"+Util.null2String(leaveRule.get("id")),flowLeaveData);//时长 + data.put("unittype",Util.null2String(leaveRule.get("unitType")));//假期单位 + data.put("proportion",Util.null2String(leaveRule.get("proportion")));//折算时长 + } + datas.add(data); + } + retmap.put("datas",datas); + }catch (Exception e){ + logger.writeLog(e); + } + return retmap; + } + + /** + * 出差 + * @param params + * @param user + * @return + */ + public Map getAllEvectionDatas(Map params, User user){ + Map retmap = new HashMap(); + List> datas = new ArrayList(); + Map flowData = new HashMap<>(); + KQReportBiz kqReportBiz = new KQReportBiz(); + flowData.putAll(kqReportBiz.getFlowEvectionOutData(params,user)); + flowData.putAll(kqReportBiz.getFlowProcessChangeData(params,user)); + logger.writeLog("evection.params=" + JSONObject.toJSONString(params)); + + RecordSet rs = new RecordSet(); + String sql = ""; + Map data = null; + try{ + ResourceComInfo resourceComInfo = new ResourceComInfo(); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + + String backFields = "select a.id,a.lastname,a.workcode,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle from hrmresource a where 1=1 "; + String sqlWhere = getSqlWhere4Flow(params,user); + String orderBy = " order by a.id"; + sql = backFields+sqlWhere+orderBy; + logger.writeLog("evection.sql="+sql); + rs.execute(sql); + while (rs.next()) { + data = new HashMap<>(); + String id = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + String workcode = Util.null2String(rs.getString("workcode")); + String subcompanyId = Util.null2String(rs.getString("subcompanyid")); + if (subcompanyId.length() == 0) { + subcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id)); + } + + String departmentid = Util.null2String(rs.getString("departmentid")); + if (departmentid.length() == 0) { + departmentid = Util.null2String(resourceComInfo.getDepartmentID(id)); + } + String jobtitleId = Util.null2String(rs.getString("jobtitle")); + if (jobtitleId.length() == 0) { + jobtitleId = Util.null2String(resourceComInfo.getJobTitle(id)); + } + data.put("id",id); + data.put("lastname",lastname); + data.put("workcode",workcode); + data.put("subcompany",subCompanyComInfo.getSubCompanyname(subcompanyId)); + data.put("department",departmentComInfo.getDepartmentname(departmentid)); + data.put("jobtitle",jobTitlesComInfo.getJobTitlesname(jobtitleId)); + + String fieldName = "businessLeave"; + String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+fieldName)),"0.0"); + String backType = fieldName+"_back"; + String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+backType)),"0.0"); + String businessLeave = ""; + try{ + //以防止出现精度问题 + if(businessLeaveData.length() == 0){ + businessLeaveData = "0.0"; + } + if(businessLeavebackData.length() == 0){ + businessLeavebackData = "0.0"; + } + BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData); + BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData); + businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString(); + if(Util.getDoubleValue(businessLeave, -1) < 0){ + businessLeave = "0.0"; + } + }catch (Exception e){ + } + String duration = KQDurationCalculatorUtil.getDurationRound(businessLeave); + data.put("duration",duration); + + datas.add(data); + } + retmap.put("datas",datas); + }catch (Exception e){ + logger.writeLog(e); + } + return retmap; + } + + /** + * 公出 + * @param params + * @param user + * @return + */ + public Map getAllOutDatas(Map params, User user){ + Map retmap = new HashMap(); + List> datas = new ArrayList(); + Map flowData = new HashMap<>(); + KQReportBiz kqReportBiz = new KQReportBiz(); + flowData.putAll(kqReportBiz.getFlowEvectionOutData(params,user)); + flowData.putAll(kqReportBiz.getFlowProcessChangeData(params,user)); + logger.writeLog("out.params=" + JSONObject.toJSONString(params)); + + RecordSet rs = new RecordSet(); + String sql = ""; + Map data = null; + try{ + ResourceComInfo resourceComInfo = new ResourceComInfo(); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + + String backFields = "select a.id,a.lastname,a.workcode,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle from hrmresource a where 1=1 "; + String sqlWhere = getSqlWhere4Flow(params,user); + String orderBy = " order by a.id"; + sql = backFields+sqlWhere+orderBy; + logger.writeLog("out.sql="+sql); + rs.execute(sql); + while (rs.next()) { + data = new HashMap<>(); + String id = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + String workcode = Util.null2String(rs.getString("workcode")); + String subcompanyId = Util.null2String(rs.getString("subcompanyid")); + if (subcompanyId.length() == 0) { + subcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id)); + } + + String departmentid = Util.null2String(rs.getString("departmentid")); + if (departmentid.length() == 0) { + departmentid = Util.null2String(resourceComInfo.getDepartmentID(id)); + } + String jobtitleId = Util.null2String(rs.getString("jobtitle")); + if (jobtitleId.length() == 0) { + jobtitleId = Util.null2String(resourceComInfo.getJobTitle(id)); + } + data.put("id",id); + data.put("lastname",lastname); + data.put("workcode",workcode); + data.put("subcompany",subCompanyComInfo.getSubCompanyname(subcompanyId)); + data.put("department",departmentComInfo.getDepartmentname(departmentid)); + data.put("jobtitle",jobTitlesComInfo.getJobTitlesname(jobtitleId)); + + String fieldName = "officialBusiness"; + String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+fieldName)),"0.0"); + String backType = fieldName+"_back"; + String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+backType)),"0.0"); + String businessLeave = ""; + try{ + //以防止出现精度问题 + if(businessLeaveData.length() == 0){ + businessLeaveData = "0.0"; + } + if(businessLeavebackData.length() == 0){ + businessLeavebackData = "0.0"; + } + BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData); + BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData); + businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString(); + if(Util.getDoubleValue(businessLeave, -1) < 0){ + businessLeave = "0.0"; + } + }catch (Exception e){ + } + String duration = KQDurationCalculatorUtil.getDurationRound(businessLeave); + data.put("duration",duration); + + datas.add(data); + } + retmap.put("datas",datas); + }catch (Exception e){ + logger.writeLog(e); + } + return retmap; + } + + /** + * 加班 + * @param params + * @param user + * @return + */ + public Map getAllOvertimeDatas(Map params, User user){ + Map retmap = new HashMap(); + List> datas = new ArrayList(); + Map flowData = new HashMap<>(); + KQReportBiz kqReportBiz = new KQReportBiz(); + flowData.putAll(kqReportBiz.getFlowOverTimeDataNew(params,user)); + logger.writeLog("overtime.params=" + JSONObject.toJSONString(params)); + + RecordSet rs = new RecordSet(); + String sql = ""; + Map data = null; + try{ + ResourceComInfo resourceComInfo = new ResourceComInfo(); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + + String backFields = "select a.id,a.lastname,a.workcode,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle from hrmresource a where 1=1 "; + String sqlWhere = getSqlWhere4Flow(params,user); + String orderBy = " order by a.id"; + sql = backFields+sqlWhere+orderBy; + logger.writeLog("overtime.sql="+sql); + rs.execute(sql); + while (rs.next()) { + data = new HashMap<>(); + String id = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + String workcode = Util.null2String(rs.getString("workcode")); + String subcompanyId = Util.null2String(rs.getString("subcompanyid")); + if (subcompanyId.length() == 0) { + subcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id)); + } + + String departmentid = Util.null2String(rs.getString("departmentid")); + if (departmentid.length() == 0) { + departmentid = Util.null2String(resourceComInfo.getDepartmentID(id)); + } + String jobtitleId = Util.null2String(rs.getString("jobtitle")); + if (jobtitleId.length() == 0) { + jobtitleId = Util.null2String(resourceComInfo.getJobTitle(id)); + } + data.put("id",id); + data.put("lastname",lastname); + data.put("workcode",workcode); + data.put("subcompany",subCompanyComInfo.getSubCompanyname(subcompanyId)); + data.put("department",departmentComInfo.getDepartmentname(departmentid)); + data.put("jobtitle",jobTitlesComInfo.getJobTitlesname(jobtitleId)); + + //关联调休-工作日加班时长 + double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_4leave"))); + workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave; + //关联调休-休息日加班时长 + double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_4leave"))); + restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave; + //关联调休-节假日加班时长 + double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_4leave"))); + holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave; + + //不关联调休-工作日加班时长 + double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleave"))); + workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave; + //不关联调休-休息日加班时长 + double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleave"))); + restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave; + //不关联调休-节假日加班时长 + double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleave"))); + holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave; + + //------------------------------------------------------------------------------------------------------- + //合计加班时长 + String duration = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+ + workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave)); + data.put("duration_total",duration); + + //------------------------------------------------------------------------------------------------------- + //合计时长-工作日(关联调休和不关联调休的工作日) + String duration_work = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+workingDayOvertime_nonleave)); + data.put("duration_work",duration_work); + //合计时长-休息日(关联调休和不关联调休的休息日) + String duration_rest = KQDurationCalculatorUtil.getDurationRound(String.valueOf(restDayOvertime_4leave+restDayOvertime_nonleave)); + data.put("duration_rest",duration_rest); + //合计时长-节假日(关联调休和不关联调休的节假日) + String duration_holiday = KQDurationCalculatorUtil.getDurationRound(String.valueOf(holidayOvertime_4leave+holidayOvertime_nonleave)); + data.put("duration_holiday",duration_holiday); + + + //------------------------------------------------------------------------------------------------------- + //关联调休-合计时长 + String duration_4leave = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave)); + data.put("duration_4leave",duration_4leave); + //关联调休-工作日时长 + String duration_4leave_work = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave)); + data.put("duration_4leave_work",duration_4leave_work); + //关联调休-休息日时长 + String duration_4leave_rest = KQDurationCalculatorUtil.getDurationRound(String.valueOf(restDayOvertime_4leave)); + data.put("duration_4leave_rest",duration_4leave_rest); + //关联调休-节假日时长 + String duration_4leave_holiday = KQDurationCalculatorUtil.getDurationRound(String.valueOf(holidayOvertime_4leave)); + data.put("duration_4leave_holiday",duration_4leave_holiday); + + //------------------------------------------------------------------------------------------------------- + //不关联调休-合计时长 + String duration_nonleave = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave)); + data.put("duration_nonleave",duration_nonleave); + String duration_nonleave_work = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_nonleave)); + data.put("duration_nonleave_work",duration_nonleave_work); + String duration_nonleave_rest = KQDurationCalculatorUtil.getDurationRound(String.valueOf(restDayOvertime_nonleave)); + data.put("duration_nonleave_rest",duration_nonleave_rest); + String duration_nonleave_holiday = KQDurationCalculatorUtil.getDurationRound(String.valueOf(holidayOvertime_nonleave)); + data.put("duration_nonleave_holiday",duration_nonleave_holiday); + + datas.add(data); + } + retmap.put("datas",datas); + }catch (Exception e){ + logger.writeLog(e); + } + return retmap; + } + + /** + * @param request + * @param response + * @return + */ + @GET + @Path("/checkDate") + @Produces(MediaType.TEXT_PLAIN) + public String checkDate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map resultMap = new HashMap(); + int code = 1; + String msg = "error"; + + List restList = new ArrayList(); + List workList = new ArrayList(); + KQWorkTime kqWorkTime = new KQWorkTime(); + + /*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/ + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + // + User user = HrmUserVarify.getUser(request, response); + String dateStart = Util.null2String(request.getParameter("dateStart")); + String dateEnd = Util.null2String(request.getParameter("dateEnd")); +// logger.writeLog("date =" + date); +// HrmScheduleDiffUtil util = new HrmScheduleDiffUtil(); +// util.setUser(new User(user.getUID())); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + + //============新优化逻辑====================== + List> splitLists = SplitActionUtil.getSplitDayList(dateStart, dateEnd); + if (!splitLists.isEmpty()) { + for (int i = 0; i < splitLists.size(); i++) { + Map splitMap = splitLists.get(i); + String splitDate = Util.null2String(splitMap.get("splitDate")); + int changeType = -1; + String groupId = kqGroupMemberComInfo.getKQGroupId("" + user.getUID(), splitDate); + /*该人员不存在于任意一个考勤组中,请为其设置考勤组*/ + if (groupId.equals("")) { + logger.writeLog("该人员不存在于任意一个考勤组中,请为其设置考勤组。resourceId=" + user.getUID() + ",date=" + splitDate); + } + + changeType = KQHolidaySetBiz.getChangeType(groupId, splitDate); + if (changeType == 1 || changeType == 3) { + restList.add(splitDate); + } else if (changeType == 2) { + workList.add(splitDate); + } + } + logger.writeLog("restList =" + restList.size() + ":restList:" + restList); + logger.writeLog("workList =" + workList.size() + ":workList:" + workList); + code = 0; + msg = "OK"; + } + //============新优化逻辑====================== + + resultMap.put("code", code); + resultMap.put("msg", msg); + resultMap.put("restList", restList);//休息日 + resultMap.put("workList", workList);//工作日 + + return JSON.toJSONString(resultMap, SerializerFeature.DisableCircularReferenceDetect); + } + + public String getSqlWhere(Map params, User user) { + RecordSet rs = new RecordSet(); + String resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect = Util.null2String(params.get("typeselect")); + if (fromDate.length() == 0 && toDate.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 viewScope = Util.null2String(params.get("viewScope")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + + String sqlWhere = " "; +// if (fromDate.length() > 0) { +// sqlWhere += " and kqdate >= '" + fromDate + "'"; +// } +// +// if (toDate.length() > 0) { +// sqlWhere += " and kqdate <= '" + toDate + "'"; +// } + + if (subCompanyId.length() > 0) { + sqlWhere += " and a.subcompanyid1 in(" + subCompanyId + ") "; + } + + if (departmentId.length() > 0) { + sqlWhere += " and a.departmentid in(" + departmentId + ") "; + } + + if (resourceId.length() > 0) { + sqlWhere += " and a.id in ( " + resourceId + ")"; + } + + if (resourceStatus.length() > 0) { + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sqlWhere += " and a.status = " + resourceStatus + ""; + } else if (resourceStatus.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + 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<>'' "); + } + + return sqlWhere; + } + + public String getSqlWhere4Flow(Map params, User user) { + RecordSet rs = new RecordSet(); + String resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String typeselect = Util.null2String(params.get("typeselect")); + if (fromDate.length() == 0 && toDate.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 viewScope = Util.null2String(params.get("viewScope")); + String subCompanyId = Util.null2String(params.get("subCompanyId")); + String departmentId = Util.null2String(params.get("departmentId")); + String allLevel = Util.null2String(params.get("allLevel")); + String isNoAccount = Util.null2String(params.get("isNoAccount")); + //人员状态 + String resourceStatus = Util.null2String(params.get("status")); + + String sqlWhere = " "; +// if (fromDate.length() > 0) { +// sqlWhere += " and kqdate >= '" + fromDate + "'"; +// } +// +// if (toDate.length() > 0) { +// sqlWhere += " and kqdate <= '" + toDate + "'"; +// } + + if (subCompanyId.length() > 0) { + sqlWhere += " and a.subcompanyid1 in(" + subCompanyId + ") "; + } + + if (departmentId.length() > 0) { + sqlWhere += " and a.departmentid in(" + departmentId + ") "; + } + + if (resourceId.length() > 0) { + sqlWhere += " and a.id in ( " + resourceId + ")"; + } + + if (resourceStatus.length() > 0) { + if (!resourceStatus.equals("8") && !resourceStatus.equals("9")) { + sqlWhere += " and a.status = " + resourceStatus + ""; + } else if (resourceStatus.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + 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<>'' "); + } + + return sqlWhere; + } + +} diff --git a/src/com/engine/kq/web/KQReportDetailAction.java b/src/com/engine/kq/web/KQReportDetailAction.java new file mode 100644 index 0000000..fc9d4d8 --- /dev/null +++ b/src/com/engine/kq/web/KQReportDetailAction.java @@ -0,0 +1,174 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.biz.KQReportFieldComInfo; +import com.engine.kq.biz.KQSettingsBiz; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.service.KQReportDetailService; +import com.engine.kq.service.impl.KQReportDetailServiceImpl; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +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.HashMap; +import java.util.Map; + +/** + * 考勤报表 + */ +public class KQReportDetailAction extends BaseBean { + + private KQReportDetailService getService(User user) { + return (KQReportDetailService) ServiceUtil.getService(KQReportDetailServiceImpl.class, user); + } + + /** + * 获取考勤报表明细Tabs + * @param request + * @param response + * @return + */ + @POST + @Path("/getTabs") + @Produces(MediaType.TEXT_PLAIN) + public String getTabs(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getTabs(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + @POST + @Path("/exportDetailExcel") + @Produces(MediaType.TEXT_PLAIN) + public String exportDetailExcel(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + User user = HrmUserVarify.getUser(request, response); + try { + boolean hasReportRight = new KQReportBiz().hasReportRight("1",""+user.getUID()); + boolean kq_personal_reportsearch = KQSettingsBiz.showLeaveTypeSet("kq_personal_reportsearch"); + if(!hasReportRight && kq_personal_reportsearch) { + apiDatas.put("status", false); + apiDatas.put("errormsg", SystemEnv.getHtmlLabelName(543685, user.getLanguage())); + } else { + Map params = ParamUtil.request2Map(request); + params.put("isNoAccount","1") ; + new KQReportBiz().insertKqReportExportLog(params, user); +// apiDatas = getService(user).exportExcel(ParamUtil.request2Map(request), user, request, response); + apiDatas.put("status", true); + } + + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("status", false); + apiDatas.put("errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取考勤报表明细 + * @param request + * @param response + * @return + */ + @POST + @Path("/getKQReportDetail") + @Produces(MediaType.TEXT_PLAIN) + public String getKQReportDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + Map params =ParamUtil.request2Map(request) ; + params.put("isNoAccount","1") ; + RecordSet rs = new RecordSet(); + String sql = ""; + try { + User user = HrmUserVarify.getUser(request, response); + String type = Util.null2String(request.getParameter("type")); + String reportType = Util.null2String(request.getParameter("reportType")); + + if(KQReportFieldComInfo.cascadekey2fieldname.keySet().contains(type)){ + type=KQReportFieldComInfo.cascadekey2fieldname.get(type); + } + if(reportType.equals("month")) { + sql = "select formula from kq_report_field where fieldname = ? "; + rs.executeQuery(sql, type); + if(rs.next()){ + String formula = Util.null2String(rs.getString("formula")); + if(formula.indexOf("beLateMins")>-1){ + type = "beLate"; + params.put("type",type); + }else if(formula.indexOf("leaveEarlyMins")>-1){ + type = "leaveEearly"; + params.put("type",type); + } + params.put("formula",formula); + } + } + + if(type.equals("workdays")||type.equals("workmins")){ + apidatas = getService(user).getWorkDayInfo(params, user); + }else if(type.equals("attendancedays")||type.equals("attendanceMins")|| + type.equals("signdays")||type.equals("signmins")){ + apidatas = getService(user).getSignInfo(params, user); + }else if(type.equals("beLate")||type.equals("beLateMins")|| + type.equals("graveBeLate")||type.equals("graveBeLateMins")){ + apidatas = getService(user).getBeLateInfo(params, user); + }else if(type.equals("leaveEearly")||type.equals("leaveEarlyMins")|| + type.equals("graveLeaveEarly")||type.equals("graveLeaveEarlyMins")){ + apidatas = getService(user).getLeaveEearlyInfo(params, user); + }else if(type.equals("absenteeism")||type.equals("absenteeismMins")){ + apidatas = getService(user).getAbsenteeismInfo(params, user); + }else if(type.equals("forgotCheck")){ + apidatas = getService(user).getForgotCheckInfo(params, user); + }else if(type.equals("leave")||type.startsWith("leaveType_")||type.equals("overtimeTotal")|| + type.equals("businessLeave")||type.equals("officialBusiness")|| + type.equals("leaveDeduction")){ + apidatas = getService(user).getLeaveInfo(params, user); + } + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤报表明细信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/getDailyDetialInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getDailyDetialInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getDailyDetialInfo(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KQReportFieldDefineAction.java b/src/com/engine/kq/web/KQReportFieldDefineAction.java new file mode 100644 index 0000000..7883eb9 --- /dev/null +++ b/src/com/engine/kq/web/KQReportFieldDefineAction.java @@ -0,0 +1,435 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQReportFieldDefineService; +import com.engine.kq.service.impl.KQReportFieldDefineServiceImpl; +import weaver.general.BaseBean; +import weaver.general.Util; +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.HashMap; +import java.util.Map; + +/** + * 考勤报表展示列支持定制 + */ +public class KQReportFieldDefineAction extends BaseBean { + + private KQReportFieldDefineService getService(User user) { + return (KQReportFieldDefineService) ServiceUtil.getService(KQReportFieldDefineServiceImpl.class, user); + } + + /** + * 是否有权限 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/getHasRight") + @Produces(MediaType.TEXT_PLAIN) + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas.put("hasRight", HrmUserVarify.checkUserRight("KQReportFieldDefine:Add", user)); + apidatas.put("status", "1"); + } catch (Exception e) { + apidatas.put("status", "-1"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤报表定制列页签 + * @param request + * @param response + * @return + */ + @GET + @Path("/getFieldDefineTabs") + @Produces(MediaType.TEXT_PLAIN) + public String getFieldDefineTabs(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getFieldDefineTabs(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤报表定制列列表 + * @param request + * @param response + * @return + */ + @POST + @Path("/getFieldDefineList") + @Produces(MediaType.TEXT_PLAIN) + public String getFieldDefineList(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getFieldDefineList(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存考勤报表定制列列表 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveFieldDefineList") + @Produces(MediaType.TEXT_PLAIN) + public String saveFieldDefineList(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveFieldDefineList(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤报表定制表单 + * @param request + * @param response + * @return + */ + @POST + @Path("/getFieldDefineForm") + @Produces(MediaType.TEXT_PLAIN) + public String getFieldDefineForm(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getFieldDefineForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存考勤报表定制列 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveFieldDefine") + @Produces(MediaType.TEXT_PLAIN) + public String saveFieldDefine(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveFieldDefine(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 删除考勤报表定制列 + * @param request + * @param response + * @return + */ + @POST + @Path("/deleteFieldDefine") + @Produces(MediaType.TEXT_PLAIN) + public String deleteFieldDefine(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).deleteFieldDefine(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤报表定制列分组列表 + * @param request + * @param response + * @return + */ + @POST + @Path("/getGroupList") + @Produces(MediaType.TEXT_PLAIN) + public String getGroupList(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getGroupList(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤报表定制列分组表单 + * @param request + * @param response + * @return + */ + @POST + @Path("/getGroupForm") + @Produces(MediaType.TEXT_PLAIN) + public String getGroupForm(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getGroupForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存考勤报表定制列分组表单 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveGroup") + @Produces(MediaType.TEXT_PLAIN) + public String saveGroup(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveGroup(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 删除考勤报表定制列分组 + * @param request + * @param response + * @return + */ + @POST + @Path("/deleteGroup") + @Produces(MediaType.TEXT_PLAIN) + public String deleteGroup(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).deleteGroup(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 移动考勤报表定制列分组 + * @param request + * @param response + * @return + */ + @POST + @Path("/changeFieldGroup") + @Produces(MediaType.TEXT_PLAIN) + public String changeFieldGroup(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).changeFieldGroup(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤报表展示列模板页签 + * @param request + * @param response + * @return + */ + @POST + @Path("/getReportMoudleTabs") + @Produces(MediaType.TEXT_PLAIN) + public String getReportMoudleTabs(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getReportMoudleTabs(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + * 获取自定义模板表单 + * @param request + * @param response + * @return + */ + @POST + @Path("/getReportMoudleForm") + @Produces(MediaType.TEXT_PLAIN) + public String getReportMoudleForm(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getReportMoudleForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存考勤报表展示列模板页签 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveReportMoudle") + @Produces(MediaType.TEXT_PLAIN) + public String saveReportMoudle(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveReportMoudle(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 删除考勤报表展示列模板页签 + * @param request + * @param response + * @return + */ + @POST + @Path("/deleteReportMoudle") + @Produces(MediaType.TEXT_PLAIN) + public String deleteReportMoudle(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).deleteReportMoudle(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤报表排序设置 + * @param request + * @param response + * @return + */ + @POST + @Path("/getFieldOrderDefine") + @Produces(MediaType.TEXT_PLAIN) + public String getFieldOrderDefine(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getFieldOrderDefine(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存考勤报表排序设置 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveFieldOrderDefine") + @Produces(MediaType.TEXT_PLAIN) + public String saveFieldOrderDefine(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveFieldOrderDefine(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KQReportShareAction.java b/src/com/engine/kq/web/KQReportShareAction.java new file mode 100644 index 0000000..888b53a --- /dev/null +++ b/src/com/engine/kq/web/KQReportShareAction.java @@ -0,0 +1,179 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQReportShareService; +import com.engine.kq.service.impl.KQReportShareServiceImpl; +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.HashMap; +import java.util.Map; + +/** + * 考勤报表权限共享 + */ +public class KQReportShareAction extends BaseBean { + + private KQReportShareService getService(User user) { + return (KQReportShareService) ServiceUtil.getService(KQReportShareServiceImpl.class, user); + } + + /** + * 判断是否有权限 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHasRight") + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + boolean hasRight = HrmUserVarify.checkUserRight("KQ:ReportShare", user); + apiDatas.put("hasRight", hasRight); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取搜索条件 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchCondition(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取查询列表 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSearchList(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + @GET + @Path("/getReportShareForm") + @Produces(MediaType.TEXT_PLAIN) + public String getReportShareForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getReportShareForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + @POST + @Path("/saveReportShare") + @Produces(MediaType.TEXT_PLAIN) + public String saveReportShare(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).saveReportShare(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + @POST + @Path("/deleteReportShare") + @Produces(MediaType.TEXT_PLAIN) + public String deleteReportShare(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).deleteReportShare(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + +} diff --git a/src/com/engine/kq/web/KQScheduleCodeAction.java b/src/com/engine/kq/web/KQScheduleCodeAction.java new file mode 100644 index 0000000..121fb3b --- /dev/null +++ b/src/com/engine/kq/web/KQScheduleCodeAction.java @@ -0,0 +1,288 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQScheduleCodeService; +import com.engine.kq.service.impl.KQScheduleCodeServiceImpl; +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.HashMap; +import java.util.Map; + +/** + * 外部集成考勤 + * + * @author lvyi + * + */ +public class KQScheduleCodeAction { + private BaseBean logger = new BaseBean(); + + private KQScheduleCodeService getService(User user) { + return (KQScheduleCodeService) ServiceUtil.getService(KQScheduleCodeServiceImpl.class, user); + } + + /** + * 是否有权限 + * @param request + * @param response + * @return + */ + @POST + @Path("/getHasRight") + @Produces(MediaType.TEXT_PLAIN) + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas.put("hasRight", HrmUserVarify.checkUserRight("ScheduleCode:Edit", user)); + apidatas.put("status", "1"); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤编号管理查询条件 + * @param request + * @param response + * @return + */ + @GET + @Path("/getScheduleCodeCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getScheduleCodeCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getScheduleCodeCondition(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤编号管理查询列表 + * @param request + * @param response + * @return + */ + @POST + @Path("/getScheduleCodeList") + @Produces(MediaType.TEXT_PLAIN) + public String getScheduleCodeList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getScheduleCodeList(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤编号管理表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getScheduleCodeForm") + @Produces(MediaType.TEXT_PLAIN) + public String getScheduleCodeForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getScheduleCodeForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + /** + * 保存考勤编号管理 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveScheduleCode") + @Produces(MediaType.TEXT_PLAIN) + public String saveScheduleCode(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveScheduleCode(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤机管理查询条件 + * @param request + * @param response + * @return + */ + @GET + @Path("/getScheduleDeviceCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getScheduleDeviceCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getScheduleDeviceCondition(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤机管理查询列表 + * @param request + * @param response + * @return + */ + @POST + @Path("/getScheduleDeviceList") + @Produces(MediaType.TEXT_PLAIN) + public String getScheduleDeviceList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getScheduleDeviceList(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤机管理表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getScheduleDeviceForm") + @Produces(MediaType.TEXT_PLAIN) + public String getScheduleDeviceForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getScheduleDeviceForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存考勤机管理 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveScheduleDevice") + @Produces(MediaType.TEXT_PLAIN) + public String saveScheduleDevice(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveScheduleDevice(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 删除考勤机 + * @param request + * @param response + * @return + */ + @POST + @Path("/delScheduleDevice") + @Produces(MediaType.TEXT_PLAIN) + public String delScheduleDevice(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).delScheduleDevice(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考勤编号管理导入表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getImportForm") + @Produces(MediaType.TEXT_PLAIN) + public String getScheduleCodeImportForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getScheduleCodeImportForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存考勤编号管理导入 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveImport") + @Produces(MediaType.TEXT_PLAIN) + public String saveScheduleCodeImport(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveScheduleCodeImport(ParamUtil.request2Map(request), user, request); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KQScheduleSignImportAction.java b/src/com/engine/kq/web/KQScheduleSignImportAction.java new file mode 100644 index 0000000..5a9b8cf --- /dev/null +++ b/src/com/engine/kq/web/KQScheduleSignImportAction.java @@ -0,0 +1,251 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQScheduleSignImportService; +import com.engine.kq.service.impl.KQScheduleSignImportServiceImpl; +import java.util.HashMap; +import java.util.Map; +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.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import weaver.general.BaseBean; +import weaver.general.MD5; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +/** + * 外部集成考勤 + * + * @author lvyi + * + */ +public class KQScheduleSignImportAction { + private BaseBean logger = new BaseBean(); + + private KQScheduleSignImportService getService(User user) { + return (KQScheduleSignImportService) ServiceUtil.getService(KQScheduleSignImportServiceImpl.class, user); + } + + /** + * 是否有权限 + * @param request + * @param response + * @return + */ + @POST + @Path("/getHasRight") + @Produces(MediaType.TEXT_PLAIN) + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas.put("hasRight", HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)); + apidatas.put("status", "1"); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取导入表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getImportForm") + @Produces(MediaType.TEXT_PLAIN) + public String getImportForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getImportForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存导入数据 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveImport") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveImport(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取同步设置表单 + * @param request + * @param response + * @return + */ + @GET + @Path("/getImportSetForm") + @Produces(MediaType.TEXT_PLAIN) + public String getImportSetForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getImportSetForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取同步设置表单 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveImportSet") + @Produces(MediaType.TEXT_PLAIN) + public String saveImportSet(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveImportSet(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 同步外部集成考勤数据 + * @param request + * @param response + * @return + */ + @POST + @Path("/synData") + @Produces(MediaType.TEXT_PLAIN) + public String synData(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).synData(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 外部集成考勤数据上传 + * @param request + * @param response + * @return + */ + @POST + @Path("/uploadData") + @Produces(MediaType.APPLICATION_JSON) + public String uploadData(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + apidatas = getService(null).uploadData(com.api.hrm.util.ServiceUtil.requestJson2Map(request), null); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 外部系统调用这个接口同步到考勤系统里 + * @param request + * @param response + * @return + */ + @POST + @Path("/synDataOpen") + @Produces(MediaType.APPLICATION_JSON) + public synchronized String synDataOpen(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + String token = ""; + String randomName = ""; + BaseBean baseBean = new BaseBean(); + try { + String needToken = Util.null2String(baseBean.getPropValue("kq_openapi", "needToken")); + if("1".equals(needToken)){ + boolean checkToken = checkToken(token, randomName); + if(!checkToken){ + apidatas.put("status", "-1"); + apidatas.put("msg", "tokey异常,无权限访问!"); + return JSONObject.toJSONString(apidatas); + } + } + apidatas = getService(null).synDataOpen(null); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 检测下token,不能谁都可以调用 + * @param token + * @param randomVal + * @return + */ + public boolean checkToken(String token, String randomVal){ + boolean isError = true; + BaseBean baseBean = new BaseBean(); + String tokenKey = baseBean.getPropValue("kq_openapi", "tokenKey"); + if(tokenKey.length()>0){ + MD5 md5 = new MD5(); + if(token.equals(md5.getMD5ofStr(tokenKey+randomVal))){ + isError = false; + } + } + return isError; + } + + /** + * 获取token + * @param tokenName + * @param randomVal + * @return + */ + @GET + @Path("/getToken") + @Produces(MediaType.TEXT_PLAIN) + public String getToken(@QueryParam("tokenName") String tokenName,@QueryParam("randomVal") String randomVal) { + MD5 md5 = new MD5(); + String token = md5.getMD5ofStr(tokenName+randomVal); + return token; + } + +} diff --git a/src/com/engine/kq/web/KQSettingsAction.java b/src/com/engine/kq/web/KQSettingsAction.java new file mode 100644 index 0000000..3ca5743 --- /dev/null +++ b/src/com/engine/kq/web/KQSettingsAction.java @@ -0,0 +1,137 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.api.formmode.page.util.Util; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQSettingsService; +import com.engine.kq.service.impl.KQSettingsServiceImpl; +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.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +public class KQSettingsAction extends BaseBean { + + private KQSettingsService getService(User user) { + return (KQSettingsServiceImpl) ServiceUtil.getService(KQSettingsServiceImpl.class, user); + } + + /** + * 判断是否有权限 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHasRight") + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + boolean hasRight = HrmUserVarify.checkUserRight("AttendanceApplication:Settings", user); + apiDatas.put("hasRight", hasRight); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取设置表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSettingsForm") + @Produces(MediaType.TEXT_PLAIN) + public String getSettingsForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSettingsForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 保存 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/saveSettings") + @Produces(MediaType.TEXT_PLAIN) + public String saveSettings(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + boolean hasRight = HrmUserVarify.checkUserRight("AttendanceApplication:Settings", user); + if(hasRight){ + apiDatas = getService(user).saveSettings(ParamUtil.request2Map(request), user); + String status = Util.null2String(apiDatas.get("sign")); + if("-1".equals(status)) { + return JSONObject.toJSONString(apiDatas); + } + apiDatas.put("api_status", true); + }else{ + apiDatas.put("hasRight", hasRight); + apiDatas.put("api_status", true); + } + +// apiDatas = getService(user).saveSettings(ParamUtil.request2Map(request), user); +// apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } +} diff --git a/src/com/engine/kq/web/KQSetupWizardAction.java b/src/com/engine/kq/web/KQSetupWizardAction.java new file mode 100644 index 0000000..1ae687f --- /dev/null +++ b/src/com/engine/kq/web/KQSetupWizardAction.java @@ -0,0 +1,165 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQSetupWizardService; +import com.engine.kq.service.impl.KQSetupWizardServiceImpl; +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.core.Context; +import java.util.HashMap; +import java.util.Map; + +/** + * 一键开启考勤 + */ +public class KQSetupWizardAction { + + private KQSetupWizardService getService(User user) { + return (KQSetupWizardService) ServiceUtil.getService(KQSetupWizardServiceImpl.class, user); + } + + /** + * 判断是否有权限 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHasRight") + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + boolean hasRight = HrmUserVarify.checkUserRight("KQ:SetupWizard", user); + apiDatas.put("hasRight", hasRight); + apiDatas.put("status", "1"); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("status", "-1"); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSetupForm") + public String getSetupForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSetupForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取初始化考勤步骤 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getSetupSteps") + public String getSetupSteps(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getSetupSteps(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 指定初始化 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/performInitialization") + public String performInitialization(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).performInitialization(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 判断是否需要做一键初始化,检测如果存在历史一般工作时间等老考勤设置,给出提示让客户选择是否使用考勤设置升级 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/checkNeedInit") + public String checkNeedInit(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).checkNeedInit(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + e.printStackTrace(); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } +} diff --git a/src/com/engine/kq/web/KQShiftManagementAction.java b/src/com/engine/kq/web/KQShiftManagementAction.java new file mode 100644 index 0000000..be6fa6e --- /dev/null +++ b/src/com/engine/kq/web/KQShiftManagementAction.java @@ -0,0 +1,347 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQShiftManagementService; +import com.engine.kq.service.impl.KQShiftManagementServiceImpl; +import java.util.HashMap; +import java.util.Map; +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 weaver.general.BaseBean; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + + +/** + * 班次管理 + */ +public class KQShiftManagementAction { + private BaseBean logger = new BaseBean(); + + private KQShiftManagementService getService(User user) { + return (KQShiftManagementServiceImpl) ServiceUtil.getService(KQShiftManagementServiceImpl.class, user); + } + + /** + * 是否有权限 + * @param request + * @param response + * @return + */ + @POST + @Path("/getHasRight") + @Produces(MediaType.TEXT_PLAIN) + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas.put("hasRight", HrmUserVarify.checkUserRight("KQClass:Management", user)); + apidatas.put("status", "1"); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取右键菜单 + * @param request + * @param response + * @return + */ + @POST + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取Tab信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/getTabs") + @Produces(MediaType.TEXT_PLAIN) + public String getTabInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getTabs(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取班次管理查询条件条件 + * @param request + * @param response + * @return + */ + @GET + @Path("/getShiftManagementSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getShiftManagementSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getShiftManagementSearchCondition(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取班次管理查询结果列表 + * @param request + * @param response + * @return + */ + @POST + @Path("/getShiftManagementSearchList") + @Produces(MediaType.TEXT_PLAIN) + public String getShiftManagementSearchList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getShiftManagementSearchList(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取班次管理基本信息表单 + * @param request + * @param response + * @return + */ + @POST + @Path("/getShiftManagementBaseForm") + @Produces(MediaType.TEXT_PLAIN) + public String getShiftManagementBaseForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getShiftManagementBaseForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存班次管理基本信息表单 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveShiftManagementBaseForm") + @Produces(MediaType.TEXT_PLAIN) + public String saveShiftManagementBaseForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveShiftManagementBaseForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取班次管理个性化表单 + * @param request + * @param response + * @return + */ + @POST + @Path("/getShiftManagementPersonalizedForm") + @Produces(MediaType.TEXT_PLAIN) + public String getShiftManagementPersonalizedForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getShiftManagementPersonalizedForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存班次管理个性化表单 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveShiftManagementPersonalizedForm") + @Produces(MediaType.TEXT_PLAIN) + public String saveShiftManagementPersonalizedForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveShiftManagementPersonalizedForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + /** + * 删除班次管理 + * @param request + * @param response + * @return + */ + @POST + @Path("/delShiftManagementForm") + @Produces(MediaType.TEXT_PLAIN) + public String delShiftManagementForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).delShiftManagementForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取邮件提醒内容设置 + * @param request + * @param response + * @return + */ + @GET + @Path("/getEmailRemindForm") + @Produces(MediaType.TEXT_PLAIN) + public String getEmailRemindForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getEmailRemindForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存邮件提醒内容设置 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveEmailRemind") + @Produces(MediaType.TEXT_PLAIN) + public String saveEmailRemind(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveEmailRemind(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取短信提醒内容设置 + * @param request + * @param response + * @return + */ + @GET + @Path("/getMessageRemindForm") + @Produces(MediaType.TEXT_PLAIN) + public String getMessageRemindForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getMessageRemindForm(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 保存短信提醒内容设置 + * @param request + * @param response + * @return + */ + @POST + @Path("/saveMessageRemind") + @Produces(MediaType.TEXT_PLAIN) + public String saveMessageRemind(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).saveMessageRemind(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取班次管理 分权操作级别 + * @param request + * @param response + * @return + */ + @POST + @Path("/getDetachOperatelevel") + @Produces(MediaType.TEXT_PLAIN) + public String getDetachOperatelevel(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getDetachOperatelevel(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KQShiftScheduleAction.java b/src/com/engine/kq/web/KQShiftScheduleAction.java new file mode 100644 index 0000000..da8e764 --- /dev/null +++ b/src/com/engine/kq/web/KQShiftScheduleAction.java @@ -0,0 +1,306 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQShiftScheduleService; +import com.engine.kq.service.impl.KQShiftScheduleServiceImpl; +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.HashMap; +import java.util.Map; + +/** + * 排班管理 + */ +public class KQShiftScheduleAction extends BaseBean { + + private KQShiftScheduleService getService(User user) { + return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user); + } + + /** + * 查询条件 + * @param request + * @param response + * @return + */ + @POST + @Path("/getSearchCondition") + @Produces(MediaType.TEXT_PLAIN) + public String getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getSearchCondition(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + /** + * 获取Tab + * @param request + * @param response + * @return + */ + @POST + @Path("/getTabs") + @Produces(MediaType.TEXT_PLAIN) + public String getTabs(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getTabs(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 是否有权限 + * @param request + * @param response + * @return + */ + @POST + @Path("/getHasRight") + @Produces(MediaType.TEXT_PLAIN) + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + apidatas.put("hasRight", HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)); + apidatas.put("status", "1"); + } catch (Exception e) { + apidatas.put("status", "-1"); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取排班信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/getShiftSchedule") + @Produces(MediaType.TEXT_PLAIN) + public String getShiftSchedule(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getShiftSchedule(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + *保存 + * @param request + * @param response + * @return + */ + @POST + @Path("/save") + @Produces(MediaType.TEXT_PLAIN) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).save(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + + /** + * 删除 + * @param request + * @param response + * @return + */ + @POST + @Path("/delete") + @Produces(MediaType.TEXT_PLAIN) + public String delete(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).del(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取批量排班Form + * @param request + * @param response + * @return + */ + @POST + @Path("/getBatchShiftScheduleFrom") + @Produces(MediaType.TEXT_PLAIN) + public String getBatchShiftScheduleFrom(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getBatchShiftScheduleFrom(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + /** + * 获取排班设置中每个人的有效期 + * @param request + * @param response + * @return + */ + @POST + @Path("/getShiftScheduleMembersValidate") + @Produces(MediaType.TEXT_PLAIN) + public String getShiftScheduleMembersValidate(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getShiftScheduleMembersValidate(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + /** + *批量保存 + * @param request + * @param response + * @return + */ + @POST + @Path("/batchSave") + @Produces(MediaType.TEXT_PLAIN) + public String batchSave(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).batchSave(ParamUtil.request2Map(request), user); + + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 导入排班 + * @param request + * @param response + * @return + */ + @POST + @Path("/importExcel") + @Produces(MediaType.TEXT_PLAIN) + public String importExcel(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).importExcel(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 导出排班 + * @param request + * @param response + * @return + */ + @POST + @Path("/exportExcel") + @Produces(MediaType.TEXT_PLAIN) + public String exportExcel(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).exportExcel(ParamUtil.request2Map(request), request, response, user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 排班统计 + * @param request + * @param response + * @return + */ + @POST + @Path("/getShiftScheduleTotal") + @Produces(MediaType.TEXT_PLAIN) + public String getShiftScheduleTotal(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getShiftScheduleTotal(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); + } + + /** + * 获取人员排班信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/getHrmScheduleReportInfo") + @Produces(MediaType.TEXT_PLAIN) + public String getHrmScheduleReportInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getHrmScheduleReportInfo(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KQTravelRulesAction.java b/src/com/engine/kq/web/KQTravelRulesAction.java new file mode 100644 index 0000000..786b248 --- /dev/null +++ b/src/com/engine/kq/web/KQTravelRulesAction.java @@ -0,0 +1,127 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQTravelRulesService; +import com.engine.kq.service.impl.KQTravelRulesServiceImpl; +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.HashMap; +import java.util.Map; + +/** + * 出差规则 + */ +public class KQTravelRulesAction extends BaseBean { + + private KQTravelRulesService getService(User user) { + return (KQTravelRulesService) ServiceUtil.getService(KQTravelRulesServiceImpl.class, user); + } + + /** + * 判断是否有权限 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getHasRight") + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap();//传给前台的数据集合 + try { + User user = HrmUserVarify.getUser(request, response); + boolean hasRight = HrmUserVarify.checkUserRight("KQTravelRulesEdit:Edit", user); + apiDatas.put("hasRight", hasRight); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", true); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取右键菜单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 获取表单 + * + * @param request + * @param response + * @return + */ + @GET + @Path("/getTravelRulesForm") + @Produces(MediaType.TEXT_PLAIN) + public String getTravelRulesForm(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).getTravelRulesForm(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } + + /** + * 保存 + * + * @param request + * @param response + * @return + */ + @POST + @Path("/saveTravelRules") + @Produces(MediaType.TEXT_PLAIN) + public String saveTravelRules(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apiDatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apiDatas = getService(user).saveTravelRules(ParamUtil.request2Map(request), user); + apiDatas.put("api_status", true); + } catch (Exception e) { + writeLog(e); + apiDatas.put("api_status", false); + apiDatas.put("api_errormsg", e.getMessage()); + } + return JSONObject.toJSONString(apiDatas); + } +} diff --git a/src/com/engine/kq/web/KQUpgradeAction.java b/src/com/engine/kq/web/KQUpgradeAction.java new file mode 100644 index 0000000..fd2cb89 --- /dev/null +++ b/src/com/engine/kq/web/KQUpgradeAction.java @@ -0,0 +1,582 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.service.KQUpgradeService; +import com.engine.kq.service.impl.KQUpgradeServiceImpl; +import java.util.HashMap; +import java.util.Map; +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 weaver.general.BaseBean; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + + +/** + * 新考勤历史数据升级 + */ +public class KQUpgradeAction { + private BaseBean logger = new BaseBean(); + + private KQUpgradeService getService(User user) { + return (KQUpgradeServiceImpl) ServiceUtil.getService(KQUpgradeServiceImpl.class, user); + } + + /** + * 是否有权限 + * @param request + * @param response + * @return + */ + @POST + @Path("/getHasRight") + @Produces(MediaType.TEXT_PLAIN) + public String getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + if(user.getUID() == 1){ + apidatas.put("hasRight", true); + }else{ + apidatas.put("hasRight", false); + } + apidatas.put("status", "1"); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取右键菜单 + * @param request + * @param response + * @return + */ + @POST + @Path("/getRightMenu") + @Produces(MediaType.TEXT_PLAIN) + public String getRightMenu(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; +// apidatas = getService(user).getRightMenu(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取左侧Tab信息 + * @param request + * @param response + * @return + */ + @POST + @Path("/getTreeTabs") + @Produces(MediaType.TEXT_PLAIN) + public String getTreeTabs(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getTreeTabs(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 一般工作时间升级 准备 + * @param request + * @param response + * @return + */ + @POST + @Path("/getUpgrade1") + @Produces(MediaType.TEXT_PLAIN) + public String getUpgrade1(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getUpgrade1(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 排班设置,排班人员数据升级 准备 + * @param request + * @param response + * @return + */ + @POST + @Path("/getUpgrade2") + @Produces(MediaType.TEXT_PLAIN) + public String getUpgrade2(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getUpgrade2(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 请假类型升级 准备 + * @param request + * @param response + * @return + */ + @POST + @Path("/getUpgrade3") + @Produces(MediaType.TEXT_PLAIN) + public String getUpgrade3(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getUpgrade3(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 工作日期调整升级 准备 + * @param request + * @param response + * @return + */ + @POST + @Path("/getUpgrade4") + @Produces(MediaType.TEXT_PLAIN) + public String getUpgrade4(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getUpgrade4(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 年假数据升级 准备 + * @param request + * @param response + * @return + */ + @POST + @Path("/getUpgrade5") + @Produces(MediaType.TEXT_PLAIN) + public String getUpgrade5(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getUpgrade5(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 带薪假数据升级 准备 + * @param request + * @param response + * @return + */ + @POST + @Path("/getUpgrade6") + @Produces(MediaType.TEXT_PLAIN) + public String getUpgrade6(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getUpgrade6(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 调休数据升级 准备 + * @param request + * @param response + * @return + */ + @POST + @Path("/getUpgrade7") + @Produces(MediaType.TEXT_PLAIN) + public String getUpgrade7(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getUpgrade7(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 考勤流程设置升级 准备 + * @param request + * @param response + * @return + */ + @POST + @Path("/getUpgrade8") + @Produces(MediaType.TEXT_PLAIN) + public String getUpgrade8(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getUpgrade8(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 外部集成考勤设置升级 准备 + * @param request + * @param response + * @return + */ + @POST + @Path("/getUpgrade9") + @Produces(MediaType.TEXT_PLAIN) + public String getUpgrade9(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getUpgrade9(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 历史考勤流程数据升级 准备 + * @param request + * @param response + * @return + */ + @POST + @Path("/getUpgrade10") + @Produces(MediaType.TEXT_PLAIN) + public String getUpgrade10(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getUpgrade10(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 考勤报表数据升级 准备 + * @param request + * @param response + * @return + */ + @POST + @Path("/getUpgrade12") + @Produces(MediaType.TEXT_PLAIN) + public String getUpgrade12(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getUpgrade12(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 一般工作时间升级 + * @param request + * @param response + * @return + */ + @POST + @Path("/doUpgrade1") + @Produces(MediaType.TEXT_PLAIN) + public String doUpgrade1(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).doUpgrade1(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 排班设置,排班人员数据升级 + * @param request + * @param response + * @return + */ + @POST + @Path("/doUpgrade2") + @Produces(MediaType.TEXT_PLAIN) + public String doUpgrade2(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).doUpgrade2(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 请假类型升级 + * @param request + * @param response + * @return + */ + @POST + @Path("/doUpgrade3") + @Produces(MediaType.TEXT_PLAIN) + public String doUpgrade3(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).doUpgrade3(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 工作日期调整升级 + * @param request + * @param response + * @return + */ + @POST + @Path("/doUpgrade4") + @Produces(MediaType.TEXT_PLAIN) + public String doUpgrade4(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).doUpgrade4(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 年假数据升级 + * @param request + * @param response + * @return + */ + @POST + @Path("/doUpgrade5") + @Produces(MediaType.TEXT_PLAIN) + public String doUpgrade5(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).doUpgrade5(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 带薪假数据升级 + * @param request + * @param response + * @return + */ + @POST + @Path("/doUpgrade6") + @Produces(MediaType.TEXT_PLAIN) + public String doUpgrade6(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).doUpgrade6(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 调休数据升级 + * @param request + * @param response + * @return + */ + @POST + @Path("/doUpgrade7") + @Produces(MediaType.TEXT_PLAIN) + public String doUpgrade7(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).doUpgrade7(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 考勤流程设置升级 + * @param request + * @param response + * @return + */ + @POST + @Path("/doUpgrade8") + @Produces(MediaType.TEXT_PLAIN) + public String doUpgrade8(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).doUpgrade8(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 外部集成考勤设置升级 + * @param request + * @param response + * @return + */ + @POST + @Path("/doUpgrade9") + @Produces(MediaType.TEXT_PLAIN) + public String doUpgrade9(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).doUpgrade9(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 历史考勤流程数据升级 + * @param request + * @param response + * @return + */ + @POST + @Path("/doUpgrade10") + @Produces(MediaType.TEXT_PLAIN) + public String doUpgrade10(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).doUpgrade10(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 考勤报表数据升级 + * @param request + * @param response + * @return + */ + @POST + @Path("/doUpgrade12") + @Produces(MediaType.TEXT_PLAIN) + public String doUpgrade12(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).doUpgrade12(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } + + /** + * 获取考考勤报表剩余数据 + * @param request + * @param response + * @return + */ + @POST + @Path("/getUpgrade12Data") + @Produces(MediaType.TEXT_PLAIN) + public String getUpgrade12Data(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getService(user).getUpgrade12Data(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } +} diff --git a/src/com/engine/kq/web/KqPunchButton4EAction.java b/src/com/engine/kq/web/KqPunchButton4EAction.java new file mode 100644 index 0000000..744bc6c --- /dev/null +++ b/src/com/engine/kq/web/KqPunchButton4EAction.java @@ -0,0 +1,253 @@ +package com.engine.kq.web; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.kq.biz.*; +import com.engine.kq.log.KQLog; +import com.engine.kq.timer.KQTaskBean; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.util.face.hrmrestful.service.KqPunchButton4EWebServiceManager; +import com.engine.kq.wfset.util.SplitActionUtil; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.dateformat.DateTransformer; +import weaver.dateformat.TimeZoneVar; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +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.time.LocalDate; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class KqPunchButton4EAction extends BaseBean{ + + private static KqPunchButton4EWebServiceManager manager= new KqPunchButton4EWebServiceManager() ; + private KQLog kqLog = new KQLog(); + + @POST + @Path("/punchButton4E") + @Produces(MediaType.APPLICATION_JSON) + public synchronized String punchButton4E(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map retmap = new HashMap<>() ; + try { + // 需要传ip--我们有ip限制 + // 需要传mac地址,我们有mac地址匹配 + // 需要传打卡地址,系统要显示 + Map params = ParamUtil.request2Map(request); + kqLog.info("params:::"+JSON.toJSONString(params)); + + String accessToken = Util.null2String(params.get("access_token")); + String userid = Util.null2String(params.get("userid")); + User user = new User(Util.getIntValue(userid, 1)); + String type = Util.null2String(params.get("type")); + String longitude = Util.null2String(params.get("longitude")); + String latitude = Util.null2String(params.get("latitude")); + if("".equals(longitude) || "".equals(latitude)) { + retmap.put("errcode", "-1"); + retmap.put("errmsg", SystemEnv.getHtmlLabelName(536227,user.getLanguage())); + kqLog.info("punchButton4E:data:"+JSONObject.toJSONString(retmap)); + return JSONObject.toJSONString(retmap) ; + } + String checkAddress = Util.null2String(params.get("checkAddress")); // 打卡地址 + String mac = Util.null2String(params.get("wifiId")); // wifiId就是Mac地址 + String wifiName = Util.null2String(params.get("wifiName")); +// String mac = Util.null2String(params.get("mac")); + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + LocalTime localTime = LocalTime.now(); + String signTime =localTime.format(dateTimeFormatter); + String signDate = LocalDate.now().format(dateFormatter); + String belongdate = getBelongDate(user, DateUtil.getCurrentDate(), signDate+" "+signTime); + + manager.checkToken(Util.null2String(request.getParameter(getPropValue("QC1008221", "tokenName"))).trim(), Util.null2String(request.getParameter(getPropValue("QC1008221", "randomName"))).trim()); + + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map locationMap = kqGroupBiz.checkLocationScope(userid+"",longitude,latitude); + kqLog.info("locationMap:::"+JSON.toJSONString(locationMap)); + + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupMemberComInfo.setIsFormat(true); + KQLoactionComInfo kqLoactionComInfo = new KQLoactionComInfo(); + String groupId = kqGroupMemberComInfo.getKQGroupId(userid); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + String locationshowaddress = kqGroupComInfo.getLocationshowaddress(groupId); + if(locationshowaddress.equals("1")){//记录统一地址 + Map loactionInfo = (Map) locationMap.get("loactionInfo"); + if(loactionInfo != null) { + String locationid = Util.null2String(loactionInfo.get("id"));//办公地点id + if(locationid.length()>0){//如果开启统一显示,就用配置的地址 + checkAddress = kqLoactionComInfo.getLocationname(locationid); + } + } + } + + String timeZone = Util.null2String(TimeZoneVar.getTimeZone(),""); + //处理多时区 + String timeZoneConversion = Util.null2String(new weaver.general.BaseBean().getPropValue("weaver_timezone_conversion","timeZoneConversion")).trim(); + if("1".equals(timeZoneConversion)) { + DateTransformer dateTransformer=new DateTransformer(); + String[] zone_localTime = dateTransformer.getLocaleDateAndTime(signDate,signTime); + if(zone_localTime != null && zone_localTime.length == 2){ + signDate = zone_localTime[0]; + signTime = zone_localTime[1]; + } + } + + String signType = "CHECKIN".equalsIgnoreCase(type) ? "1" : "2"; + String clientAddress = Util.getIpAddr(request); + boolean isInIp = checkIsInIp(request, userid); + if(!isInIp){ + retmap.put("errcode", "-1"); + retmap.put("errmsg", SystemEnv.getHtmlLabelName(20157,user.getLanguage())); + kqLog.info("punchButton4E:data:"+JSONObject.toJSONString(retmap)); + return JSONObject.toJSONString(retmap) ; + } + String isInCom = "1"; + + //记录下是来自于小e的打卡 + String signfrom = "xiaoe"; + + boolean needLocationRange = false; + boolean needWifiRange = false; + boolean isLocationRange = false; + boolean isWifiRange = false; + + String locationNeedCheck = Util.null2String(locationMap.get("needCheck")); + boolean locationInScope = Boolean.parseBoolean(Util.null2String(locationMap.get("inScope"))); + if("1".equalsIgnoreCase(locationNeedCheck)){ + needLocationRange = true; + if(locationInScope){ + isLocationRange = true; + } + } + String wifiNeedCheck = ""; + Map wifiMap = kqGroupBiz.checkWifiScope(userid+"", wifiName, mac); + kqLog.info("wifiMap:::"+JSON.toJSONString(wifiMap)); + wifiNeedCheck = Util.null2String(wifiMap.get("needCheck")); + boolean wifiInScope = Boolean.parseBoolean(Util.null2String(wifiMap.get("inScope"))); + if("1".equalsIgnoreCase(wifiNeedCheck)){ + needWifiRange = true; + if(wifiInScope){ + isWifiRange = true; + } + } + if(needLocationRange){ + if(isLocationRange){ + }else{ + if(needWifiRange){ + if(isWifiRange){ + }else{ + //地理位置开启,而且不在范围内,且开启wifi验证,不在范围内 + retmap.put("message", SystemEnv.getHtmlLabelName(507524, user.getLanguage())); + isInCom = "0"; + } + }else { + //地理位置开启,而且不在范围内,且未开启wifi验证 + retmap.put("message", SystemEnv.getHtmlLabelName(500510, user.getLanguage())); + isInCom = "0"; + } + } + }else{ + if(needWifiRange) { + if (isWifiRange) { + } else { + //地理位置未开启,且开启wifi验证,不在范围内 + retmap.put("message", SystemEnv.getHtmlLabelName(507524, user.getLanguage())); + isInCom = "0"; + } + } + } + + RecordSet rs = new RecordSet(); + String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo) "+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + boolean isOk = rs.executeUpdate(punchSql,userid,1,signType,signDate,signTime,clientAddress,isInCom, + timeZone,belongdate,signfrom,longitude,latitude,checkAddress,null); + if(!isOk){ + retmap.put("errcode", "-1"); + retmap.put("errmsg", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + return JSONObject.toJSONString(retmap) ; + } + kqLog.info(user.getLastname()+":PunchButtonCmd:punchSql:"+punchSql+":isOk:"+isOk); + + //打卡提醒处理 + String remindSql = "insert into hrmschedulesign_remind(userId,signType,signDate,signTime,belongdate) values(?,?,?,?,?)"; + isOk = rs.executeUpdate(remindSql, userid, signType, signDate, signTime, belongdate); + kqLog.info(user.getLastname()+":PunchButtonCmd:remindSql:"+remindSql+":isOk:"+isOk); + + //同步更新考勤数据到考勤报表 + new KQFormatBiz().formatDate(""+userid,(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate)); + //点击签退的时候,可能存在加班数据生成的情况 + List tasks = new ArrayList<>(); + List after_tasks = new ArrayList<>(); + SplitActionUtil.pushOverTimeTasks(belongdate, belongdate, userid,tasks); + if(!tasks.isEmpty()){ + for(KQTaskBean kqTaskBean : tasks){ + after_tasks.add(kqTaskBean); + } + } + retmap.put("errcode","1"); + retmap.put("errmsg",SystemEnv.getHtmlLabelName(512596, Util.getIntValue(user.getLanguage()))); + } catch (Exception e){ + this.writeLog(e); + retmap.put("errcode","-1") ; + retmap.put("errmsg","系统错误:"+e.getMessage()) ; + } + + kqLog.info("punchButton4E:data:"+JSONObject.toJSONString(retmap)); + return JSONObject.toJSONString(retmap) ; + } + + private boolean checkIsInIp(HttpServletRequest request, String userId) { +// if("1".equalsIgnoreCase(ismobile)){ +// return true; +// } + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + String clientAddress = Util.getIpAddr(request); + kqLog.info("PunchButtonCmd:clientAddress:"+clientAddress); + return kqGroupBiz.getIsInScopeV4V6(userId, clientAddress,"1"); + } + + /** + * 归属日期 + * @param user + * @param curDate + * @param signDateTime + * @return + */ + private String getBelongDate(User user, String curDate, String signDateTime) { + String belongDate = curDate; + Map todayLineMap = KQDurationCalculatorUtil.getWorkButton(user, curDate,true); + if(todayLineMap != null) { + List> preInfo = (ArrayList>)todayLineMap.get("pre_signTime"); + if(preInfo != null) { + for(Map entry : preInfo) { + String pre_endtime_across = entry.get("endtime_across"); + String pre_endtime = entry.get("endtime"); + String signEndInfo = "1".equals(pre_endtime_across) ? (curDate+" "+pre_endtime+":00") : (DateUtil.addDate(curDate,-1)+" "+pre_endtime+":00"); + String signOutDateTime = signDateTime; + if(signOutDateTime.compareTo(signEndInfo) < 0) { + belongDate = DateUtil.addDate(curDate, -1); + } + } + } + } + return belongDate; + } +} diff --git a/src/com/engine/kq/wfset/action/KqCheckLockAction.java b/src/com/engine/kq/wfset/action/KqCheckLockAction.java new file mode 100644 index 0000000..44107e8 --- /dev/null +++ b/src/com/engine/kq/wfset/action/KqCheckLockAction.java @@ -0,0 +1,85 @@ +package com.engine.kq.wfset.action; + +import com.engine.kq.biz.KQAttProcSetComInfo; +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.kq.log.KQLog; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.workflow.workflow.WorkflowComInfo; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.HashMap; +import java.util.Map; + +/** + * 考勤流程数据拆分action + */ +public class KqCheckLockAction extends BaseBean implements Action { + private KQLog kqLog = new KQLog(); + + @Override + public String execute(RequestInfo request) { + this.writeLog("KqCheckLockAction", "do action on request:" + request.getRequestid()); + String requestid = request.getRequestid(); + kqLog.info("do KqCheckLockAction on requestid:" + requestid); + String workflowid = request.getWorkflowid(); + String formid = new WorkflowComInfo().getFormId(workflowid); + + int requestidInt = Util.getIntValue(requestid, 0); + + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + int cur_kqtype = Util.getIntValue(kqAttProcSetComInfo.getkqType(workflowid),-1); + + if (cur_kqtype < 0) { + kqLog.info("KqCheckLockAction:cur_kqtype="+cur_kqtype); + request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222"); + request.getRequestManager().setMessagecontent("该流程没有绑定考勤流程,校验【action】报错,请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + + try { + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + RecordSet rs = new RecordSet(); + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? and field002 = ? "; + rs.executeQuery(proc_set_sql, workflowid,formid); + if(rs.next()){ + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + + int kqtype = Util.getIntValue(rs.getString("field006")); + kqLog.info("do action on kqtype:" + kqtype+":requestidInt:"+requestidInt); + Map map = new HashMap(); + if(requestidInt > 0){ + map.put("requestId", "and t.requestId = " + requestidInt); + map.put("operatorId", ""+request.getRequestManager().getCreater()); + } + Map result = kqFlowActiontBiz.handleKQLockAction(proc_set_id, usedetails, requestidInt, kqtype, Util.getIntValue(workflowid), false,false,map); + + if(!result.isEmpty()){ + String error = Util.null2String(result.get("message")); + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(error); + return Action.FAILURE_AND_CONTINUE; + } + } + } catch (Exception e) { + kqLog.info("校验报错:KqSplitAction:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222"); + request.getRequestManager().setMessagecontent("【校验action】报错,请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + + + } + +} diff --git a/src/com/engine/kq/wfset/action/KqDeductionVacationAction.java b/src/com/engine/kq/wfset/action/KqDeductionVacationAction.java new file mode 100644 index 0000000..93322dc --- /dev/null +++ b/src/com/engine/kq/wfset/action/KqDeductionVacationAction.java @@ -0,0 +1,107 @@ +package com.engine.kq.wfset.action; + +import com.engine.kq.biz.KQAttProcSetComInfo; +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.KQFlowLeaveUtil; +import com.engine.kq.wfset.util.SplitActionUtil; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.interfaces.workflow.action.RollBackAction; +import weaver.soa.workflow.request.RequestInfo; +import weaver.workflow.workflow.WorkflowComInfo; + +/** + * 兼容E8的请假扣减action + */ +public class KqDeductionVacationAction extends BaseBean implements Action, RollBackAction { + private KQLog kqLog = new KQLog(); + + @Override + public String execute(RequestInfo request) { + //e8 的状态标识 + int DEDUCTION = 0; + int FREEZE = 1; + int RELEASE = 2; + this.writeLog("KqDeductionVacationAction", "do action on request:" + request.getRequestid()); + String requestid = request.getRequestid(); + kqLog.info("do KqDeductionVacationAction on requestid:"+requestid); + int requestidInt = Util.getIntValue(requestid, 0); + + String workflowid = request.getWorkflowid(); + String formid = new WorkflowComInfo().getFormId(workflowid); + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + int cur_kqtype = Util.getIntValue(kqAttProcSetComInfo.getkqType(workflowid),-1); + + if(cur_kqtype != KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + return Action.SUCCESS; + } + + try { + + KQFlowLeaveUtil kqFlowLeaveUtil = new KQFlowLeaveUtil(); + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + ResourceComInfo rci = new ResourceComInfo(); + + List splitBeans = new ArrayList(); + DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + RecordSet rs = new RecordSet(); + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? and field002 = ? "; + rs.executeQuery(proc_set_sql, workflowid,formid); + if(rs.next()){ + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + int kqtype = Util.getIntValue(rs.getString("field006")); + Map map = new HashMap<>(); + if(requestidInt > 0){ + map.put("requestId", "and t.requestId = " + requestidInt); + } + + Map sqlMap = kqFlowActiontBiz.handleSql(proc_set_id, usedetails, requestidInt,kqtype,map); + Map result = kqFlowLeaveUtil.handleKQLeaveAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowid), requestidInt, rci); + if(!result.isEmpty()){ + String error = Util.null2String(result.get("message")); + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(error); + return Action.FAILURE_AND_CONTINUE; + } + + } + + //先在这里执行扣减动作 + SplitActionUtil.handleLeaveAction(splitBeans,requestid); + //然后再把扣减的了数据更新下KQ_ATT_VACATION表 + String updateFreezeSql = "update KQ_ATT_VACATION set status=? where requestId=? and workflowId = ? "; + boolean isUpdate = rs.executeUpdate(updateFreezeSql,DEDUCTION,requestid,workflowid); + if(!isUpdate){ + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(82823,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""+updateFreezeSql+"("+DEDUCTION+","+requestid+","+workflowid+")"); + return Action.FAILURE_AND_CONTINUE; + } + } catch (Exception e) { + writeLog(e); + request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222"); + request.getRequestManager().setMessagecontent("请假流程【扣减action】报错,请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + + } + + @Override + public String executeRollBack(RequestInfo request) { + return null; + } +} diff --git a/src/com/engine/kq/wfset/action/KqFreezeVacationAction.java b/src/com/engine/kq/wfset/action/KqFreezeVacationAction.java new file mode 100644 index 0000000..bcf8943 --- /dev/null +++ b/src/com/engine/kq/wfset/action/KqFreezeVacationAction.java @@ -0,0 +1,169 @@ +package com.engine.kq.wfset.action; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQAttProcSetComInfo; +import com.engine.kq.biz.KQBalanceOfLeaveBiz; +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQSettingsBiz; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.KQFlowLeaveUtil; + +import java.text.SimpleDateFormat; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.workflow.workflow.WorkflowComInfo; + +/** + * 兼容E8的请假冻结action + */ +public class KqFreezeVacationAction extends BaseBean implements Action { + private KQLog kqLog = new KQLog(); + + @Override + public String execute(RequestInfo request) { + //e8 的状态标识 + int DEDUCTION = 0; + int FREEZE = 1; + int RELEASE = 2; + this.writeLog("KqFreezeVacationAction", "do action on request:" + request.getRequestid()); + String requestid = request.getRequestid(); + kqLog.info("do KqFreezeVacationAction on requestid:"+requestid); + int requestidInt = Util.getIntValue(requestid, 0); + + String workflowid = request.getWorkflowid(); + String formid = new WorkflowComInfo().getFormId(workflowid); + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + int cur_kqtype = Util.getIntValue(kqAttProcSetComInfo.getkqType(workflowid),-1); + + if(cur_kqtype != KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + return Action.SUCCESS; + } + + try { + List splitBeans = new ArrayList(); + + KQFlowLeaveUtil kqFlowLeaveUtil = new KQFlowLeaveUtil(); + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + ResourceComInfo rci = new ResourceComInfo(); + DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? and field002 = ? "; + rs.executeQuery(proc_set_sql, workflowid,formid); + if(rs.next()){ + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + int kqtype = Util.getIntValue(rs.getString("field006")); + Map map = new HashMap<>(); + if(requestidInt > 0){ + map.put("requestId", "and t.requestId = " + requestidInt); + } + + Map sqlMap = kqFlowActiontBiz.handleSql(proc_set_id, usedetails, requestidInt,kqtype,map); + Map result = kqFlowLeaveUtil.handleKQLeaveAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowid), requestidInt, rci); + if(!result.isEmpty()){ + String error = Util.null2String(result.get("message")); + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(error); + return Action.FAILURE_AND_CONTINUE; + } + + } + kqLog.info("KqFreezeVacationAction splitBeans:"+ JSON.toJSONString(splitBeans)); + String batchSql = "insert into KQ_ATT_VACATION (requestId,workflowId,dataid,detailid,resourceId,fromDate," + + "fromTime,toDate,toTime,duration,newLeaveType,durationrule,status,year)"+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + List params = new ArrayList(); + + String delSql = "delete from KQ_ATT_VACATION where requestId=?"; + List delparams = new ArrayList(); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + + for(SplitBean bean : splitBeans){ + List beanParams = new ArrayList(); + String newLeaveType = bean.getNewLeaveType(); + //这个表里只存储含有假期余额的 + boolean balanceEnable = KQLeaveRulesBiz.getBalanceEnable(newLeaveType); + kqLog.info("KqFreezeVacationAction newLeaveType:"+ newLeaveType+":balanceEnable:"+balanceEnable); + if(!balanceEnable) { + continue; + } + Calendar startCal = Calendar.getInstance(); + startCal.setTime(sdf.parse(bean.getFromDate())); + int startYear = startCal.get(Calendar.YEAR); + int lastYear=startYear-1; + String allRestAmount = KQBalanceOfLeaveBiz.getRestAmount(bean.getResourceId(), newLeaveType, bean.getFromDate(), true); + String currentRestAmount = KQBalanceOfLeaveBiz.getRestAmount(bean.getResourceId(), newLeaveType, bean.getFromDate(),false); + double beforeRestAmount = Util.getDoubleValue(allRestAmount, 0) - Util.getDoubleValue(currentRestAmount, + 0); + beanParams.add(bean.getRequestId()); + beanParams.add(bean.getWorkflowId()); + beanParams.add(bean.getDataId()); + beanParams.add(bean.getDetailId()); + beanParams.add(bean.getResourceId()); + beanParams.add(bean.getFromDate()); + beanParams.add(bean.getFromTime()); + beanParams.add(bean.getToDate()); + beanParams.add(bean.getToTime()); + beanParams.add(bean.getDuration()); + beanParams.add(bean.getNewLeaveType()); + beanParams.add(bean.getDurationrule()); + beanParams.add(FREEZE); + + if( beforeRestAmount>0){ + beanParams.add(lastYear+""); + }else{ + beanParams.add(startYear+""); + } + params.add(beanParams); + + List delParam = new ArrayList(); + delParam.add(bean.getRequestId()); + delparams.add(delParam); + } + if(!params.isEmpty()){ + boolean delOk = rs1.executeBatchSql(delSql, delparams); + if(!delOk){ + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(1232,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""+params); + kqLog.info("KqFreezeVacationAction删除数据失败:"+requestid); + return Action.FAILURE_AND_CONTINUE; + } + + boolean isOk = rs1.executeBatchSql(batchSql, params); + if(!isOk){ + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(1232,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""+params); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + kqLog.info("KqFreezeVacationAction没有冻结数据:"+requestid); + } + } catch (Exception e) { + kqLog.info("KqFreezeVacationAction:"+e); + request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222"); + request.getRequestManager().setMessagecontent("请假流程【冻结action】报错,请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + + } + +} diff --git a/src/com/engine/kq/wfset/action/KqPaidLeaveAction.java b/src/com/engine/kq/wfset/action/KqPaidLeaveAction.java new file mode 100644 index 0000000..a6ba377 --- /dev/null +++ b/src/com/engine/kq/wfset/action/KqPaidLeaveAction.java @@ -0,0 +1,100 @@ +package com.engine.kq.wfset.action; + +import com.engine.kq.biz.KQFLowEventLogBiz; +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.kq.biz.KQOvertimeLogBiz; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.KQFlowOvertimeUtil; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.google.common.collect.Maps; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.workflow.workflow.WorkflowComInfo; + +/** + * 兼容E8的加班生成调休action + */ +public class KqPaidLeaveAction extends BaseBean implements Action { + private KQLog kqLog = new KQLog(); + + @Override + public String execute(RequestInfo request) { + this.writeLog("KqPaidLeaveAction", "do action on request:" + request.getRequestid()); + String requestid = request.getRequestid(); + kqLog.info("do KqPaidLeaveAction on requestid:"+requestid); + int requestidInt = Util.getIntValue(requestid, 0); + + String workflowid = request.getWorkflowid(); + String formid = new WorkflowComInfo().getFormId(workflowid); + KQFLowEventLogBiz kqfLowEventLogBiz = new KQFLowEventLogBiz(); + String logKey = "|key|requestid|"+requestid; + + try { + List splitBeans = new ArrayList(); + + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + KQFlowOvertimeUtil kqFlowOvertimeUtil = new KQFlowOvertimeUtil(); + ResourceComInfo rci = new ResourceComInfo(); + DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + RecordSet rs = new RecordSet(); + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? and field002 = ? "; + rs.executeQuery(proc_set_sql, workflowid,formid); + + Map eventLogMap = Maps.newHashMap(); + eventLogMap.put("proc_set_sql", proc_set_sql); + eventLogMap.put("workflowid", workflowid); + eventLogMap.put("formid", formid); + + String uuid = ""; + if(rs.next()){ + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + int kqtype = Util.getIntValue(rs.getString("field006")); + Map map = new HashMap<>(); + if(requestidInt > 0){ + map.put("requestId", "and t.requestId = " + requestidInt); + } + Map sqlMap = kqFlowActiontBiz.handleSql(proc_set_id, usedetails, requestidInt,kqtype,map); + + uuid = kqfLowEventLogBiz.logEvent("request|Creatorid|"+request.getCreatorid(),eventLogMap,"KqPaidLeaveAction|触发生成调休action"+logKey); + Map result = kqFlowOvertimeUtil.handleKQOvertimeAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowid), requestidInt, rci,uuid); + if(!result.isEmpty()){ + String error = Util.null2String(result.get("message")); + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(error); + return Action.FAILURE_AND_CONTINUE; + } + } + // 生成调休 在归档的时候再单独处理下加班规则第二种情况 + SplitActionUtil.handleOverTimeAction(splitBeans, requestid,false,uuid); + } catch (Exception e) { + writeLog(e); + request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222"); + request.getRequestManager().setMessagecontent("加班流程【加班时间转为可调休时间action】报错,请联系管理员!"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info("加班流程【加班时间转为可调休时间action】报错,请联系管理员!"+errorsWriter.toString()); + Map eventLogMap = Maps.newHashMap(); + eventLogMap.put("action_error", errorsWriter.toString()); + String uuid = kqfLowEventLogBiz.logEvent("request|Creatorid|"+request.getCreatorid(),eventLogMap,"KqPaidLeaveAction|触发生成调休action"+logKey); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + + } + +} diff --git a/src/com/engine/kq/wfset/action/KqReleaseVacationAction.java b/src/com/engine/kq/wfset/action/KqReleaseVacationAction.java new file mode 100644 index 0000000..eab7693 --- /dev/null +++ b/src/com/engine/kq/wfset/action/KqReleaseVacationAction.java @@ -0,0 +1,56 @@ +package com.engine.kq.wfset.action; + +import com.engine.kq.biz.KQAttProcSetComInfo; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; + +/** + * 兼容E8的请假释放action + */ +public class KqReleaseVacationAction extends BaseBean implements Action { + private KQLog kqLog = new KQLog(); + + @Override + public String execute(RequestInfo request) { + //e8 的状态标识 + int RELEASE = 2; + this.writeLog("KqReleaseVacationAction", "do action on request:" + request.getRequestid()); + String requestid = request.getRequestid(); + kqLog.info("do KqReleaseVacationAction on requestid:"+requestid); + int requestidInt = Util.getIntValue(requestid, 0); + String workflowid = request.getWorkflowid(); + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + int cur_kqtype = Util.getIntValue(kqAttProcSetComInfo.getkqType(workflowid),-1); + + if(cur_kqtype != KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + return Action.SUCCESS; + } + + try { + + RecordSet rs = new RecordSet(); + String updateFreezeSql = "update KQ_ATT_VACATION set status=2 where requestId=? and workflowId = ? "; + boolean isUpdate = rs.executeUpdate(updateFreezeSql,requestidInt,workflowid); + if(!isUpdate){ + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(82824,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+"("+RELEASE+","+requestid+","+workflowid+")"); + return Action.FAILURE_AND_CONTINUE; + } + + } catch (Exception e) { + writeLog(e); + request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222"); + request.getRequestManager().setMessagecontent("请假流程【释放action】报错,请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + + } + +} diff --git a/src/com/engine/kq/wfset/action/KqSplitAction.java b/src/com/engine/kq/wfset/action/KqSplitAction.java new file mode 100644 index 0000000..06cc8bd --- /dev/null +++ b/src/com/engine/kq/wfset/action/KqSplitAction.java @@ -0,0 +1,80 @@ +package com.engine.kq.wfset.action; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.kq.log.KQLog; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.HashMap; +import java.util.Map; + +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.workflow.workflow.WorkflowComInfo; + +/** + * 考勤流程数据拆分action + */ +public class KqSplitAction extends BaseBean implements Action { + private KQLog kqLog = new KQLog(); + + @Override + public String execute(RequestInfo request) { + this.writeLog("KqSplitAction", "do action on request:" + request.getRequestid()); + String requestid = request.getRequestid(); + kqLog.info("do KqSplitAction on request:" + request.getRequestid()); + int requestidInt = Util.getIntValue(requestid, 0); + + String workflowid = request.getWorkflowid(); + String formid = new WorkflowComInfo().getFormId(workflowid); + long start = System.currentTimeMillis(); + try { + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + RecordSet rs = new RecordSet(); + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? and field002 = ? "; + rs.executeQuery(proc_set_sql, workflowid, formid); + if (rs.next()) { + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + + int kqtype = Util.getIntValue(rs.getString("field006")); + kqLog.info("do action on kqtype:" + kqtype + ":requestidInt:" + requestidInt); + Map map = new HashMap(); + if (requestidInt > 0) { + map.put("requestId", "and t.requestId = " + requestidInt); + map.put("operatorId", "" + request.getRequestManager().getCreater()); + } + Map result = kqFlowActiontBiz.handleKQFlowAction(proc_set_id, usedetails, requestidInt, kqtype, Util.getIntValue(workflowid), false, false, map); + + if (!result.isEmpty()) { + long end1 = System.currentTimeMillis(); + this.writeLog("do action on request:" + request.getRequestid() + ":action1执行时间:" + (end1 - start) / 1000); + String error = Util.null2String(result.get("message")); + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(error); + return Action.FAILURE_AND_CONTINUE; + } + } + } catch (Exception e) { + kqLog.info("流程数据报错:KqSplitAction:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222"); + request.getRequestManager().setMessagecontent("【考勤报表统计action】报错,请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + long end2 = System.currentTimeMillis(); + this.writeLog("do action on request:" + request.getRequestid() + ":action2执行时间:" + (end2 - start) / 1000); + + return Action.SUCCESS; + + } + +} diff --git a/src/com/engine/kq/wfset/attendance/dao/HrmAttFlowVersionDao.java b/src/com/engine/kq/wfset/attendance/dao/HrmAttFlowVersionDao.java new file mode 100644 index 0000000..2b07817 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/dao/HrmAttFlowVersionDao.java @@ -0,0 +1,78 @@ +package com.engine.kq.wfset.attendance.dao; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import weaver.common.StringUtil; +import com.engine.kq.wfset.attendance.framework.BaseConnection; +import com.engine.kq.wfset.attendance.framework.BaseDao; +import com.engine.kq.wfset.attendance.domain.HrmAttFlowVersion; +import weaver.conn.RecordSet; + +/** + * HrmAttFlowVersionDao + *

Generated from 长东设计1.0.9 http://www.mfstyle.cn

+ * + * @author wcd + * @version 1.0 2016-05-31 + */ +public class HrmAttFlowVersionDao extends BaseConnection implements BaseDao { + + public Comparable insert(HrmAttFlowVersion bean) { + return -1; + } + + public void insert(List list) { + + } + + public void update(HrmAttFlowVersion bean) { + return; + } + + public boolean allowedToCopy(HrmAttFlowVersion bean) { + RecordSet rs = new RecordSet(); + if(bean.isError()) return false; + + StringBuffer sql = new StringBuffer("select sum(case when field001 = ") + .append(bean.getField001()).append(" then 1 else 0 end) as oldWfIdCount, sum(case when field001 = ") + .append(bean.getField002()).append(" then 1 else 0 end) as newWfIdCount from"); + switch (bean.getType()) { + case ATT_PROC: + sql.append(" kq_ATT_PROC_SET"); + break; + case STATE_PROC: + sql.append(" hrm_state_proc_set"); + break; + } + rs.executeSql(sql.toString()); + int oldWfIdCount = 0, newWfIdCount = 0; + if(rs.next()) { + oldWfIdCount = StringUtil.parseToInt(rs.getString("oldWfIdCount")); + newWfIdCount = StringUtil.parseToInt(rs.getString("newWfIdCount")); + } + return oldWfIdCount > 0 && newWfIdCount == 0; + } + + public List find(Map map) { + return new ArrayList(); + } + + public HrmAttFlowVersion get(Comparable id) { + return null; + } + + public int count(Map map) { + return -1; + } + + public void delete(Comparable id) { + + } + + public void delete(Map map) { + + } + +} diff --git a/src/com/engine/kq/wfset/attendance/dao/HrmAttProcActionDao.java b/src/com/engine/kq/wfset/attendance/dao/HrmAttProcActionDao.java new file mode 100644 index 0000000..cf846d2 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/dao/HrmAttProcActionDao.java @@ -0,0 +1,359 @@ +package com.engine.kq.wfset.attendance.dao; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.wfset.attendance.domain.HrmAttProcAction; +import com.engine.kq.wfset.attendance.framework.BaseConnection; +import com.engine.kq.wfset.attendance.framework.BaseDao; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.hrm.common.database.dialect.DialectUtil; + +/** + * HrmAttProcActionDao + * @author wcd + * @version 1.0 2015-04-27 + */ +public class HrmAttProcActionDao extends BaseConnection implements BaseDao { + + public Comparable insert(HrmAttProcAction bean) { + RecordSet rs = new RecordSet(); + if(bean == null) return -1; + StringBuffer sql = new StringBuffer() + .append(" insert into kq_ATT_PROC_ACTION (mfid,field001,field002,field003,field004,field005,") + .append(" field006,field007,field008 )") + .append(" values("+bean.getMfid()+","+bean.getField001()+",'"+bean.getField002()+"','"+bean.getField003()+"',") + .append(" "+bean.getField004()+","+bean.getField005()+",'"+bean.getField006()+"',"+bean.getField007()+",") + .append(" "+bean.getField008()+" )"); + rs.executeSql(sql.toString()); + return 0; + } + + public void insert(List list) { + RecordSet rs = new RecordSet(); + if(list == null) return; + StringBuffer sql = new StringBuffer(), tempSql = new StringBuffer() + .append(" insert into kq_ATT_PROC_ACTION (mfid,field001,field002,field003,field004,field005,") + .append(" field006,field007,field008 )"); + int count = 0, index = 0; + for(HrmAttProcAction bean : list) { + index ++; + sql.append(count == 0 ? tempSql.toString() : " UNION ").append(bean.getSql()).append(isOracle() ? " from dual" : ""); + if((count++) == 100 || index >= list.size()) { + rs.executeSql(sql.toString()); + sql.setLength(count = 0); + } + } + } + + public void update(HrmAttProcAction bean) { + RecordSet rs = new RecordSet(); + if(bean == null) return; + StringBuffer sql = new StringBuffer() + .append(" update kq_ATT_PROC_ACTION set") + .append(" mfid = "+bean.getMfid()+",field001 = "+bean.getField001()+",field002 = '"+bean.getField002()+"',") + .append(" field003 = '"+bean.getField003()+"',field004 = "+bean.getField004()+",field005 = "+bean.getField005()+",") + .append(" field006 = '"+bean.getField006()+"',field007 = "+bean.getField007()+",field008 = "+bean.getField008()+"") + .append(" where id = "+bean.getId()+""); + rs.executeSql(sql.toString()); + } + + public List find(Map map) { + RecordSet rs = new RecordSet(); + List list = new ArrayList(); + StringBuffer sql = new StringBuffer() + .append(" select t.id,t.mfid,t.field001,t.field002,t.field003,t.field004,t.field005,") + .append(" t.field006,t.field007,t.field008, '' as field006Name") + .append(" from kq_ATT_PROC_ACTION t") + .append(" where 1 = 1"); + if(map != null) { + if(map.containsKey("id")){ + sql.append(" and t.id = ").append(StringUtil.vString(map.get("id"))); + } + if(map.containsKey("begin_id")){ + sql.append(" and t.id >= ").append(StringUtil.vString(map.get("begin_id"))); + } + if(map.containsKey("end_id")){ + sql.append(" and t.id < ").append(StringUtil.vString(map.get("end_id"))); + } + if(map.containsKey("sql_id")){ + sql.append(" " + StringUtil.vString(map.get("sql_id"))); + } + if((rs.getDBType()).equalsIgnoreCase("postgresql")) { + if (map.containsKey("mfid")) { + sql.append(" and t.mfid = '").append(StringUtil.vString(map.get("mfid"))).append("'"); + } + if (map.containsKey("begin_mfid")) { + sql.append(" and t.mfid >= '").append(StringUtil.vString(map.get("begin_mfid"))).append("'"); + } + if (map.containsKey("end_mfid")) { + sql.append(" and t.mfid < '").append(StringUtil.vString(map.get("end_mfid"))).append("'"); + } + } else { + if(map.containsKey("mfid")){ + sql.append(" and t.mfid = ").append(StringUtil.vString(map.get("mfid"))); + } + if(map.containsKey("begin_mfid")){ + sql.append(" and t.mfid >= ").append(StringUtil.vString(map.get("begin_mfid"))); + } + if(map.containsKey("end_mfid")){ + sql.append(" and t.mfid < ").append(StringUtil.vString(map.get("end_mfid"))); + } + } + if(map.containsKey("sql_mfid")){ + sql.append(" " + StringUtil.vString(map.get("sql_mfid"))); + } + if(map.containsKey("field001")){ + sql.append(" and t.field001 = ").append(StringUtil.vString(map.get("field001"))); + } + if(map.containsKey("begin_field001")){ + sql.append(" and t.field001 >= ").append(StringUtil.vString(map.get("begin_field001"))); + } + if(map.containsKey("end_field001")){ + sql.append(" and t.field001 < ").append(StringUtil.vString(map.get("end_field001"))); + } + if(map.containsKey("sql_field001")){ + sql.append(" " + StringUtil.vString(map.get("sql_field001"))); + } + if(map.containsKey("field004")){ + sql.append(" and t.field004 = ").append(StringUtil.vString(map.get("field004"))); + } + if(map.containsKey("begin_field004")){ + sql.append(" and t.field004 >= ").append(StringUtil.vString(map.get("begin_field004"))); + } + if(map.containsKey("end_field004")){ + sql.append(" and t.field004 < ").append(StringUtil.vString(map.get("end_field004"))); + } + if(map.containsKey("sql_field004")){ + sql.append(" " + StringUtil.vString(map.get("sql_field004"))); + } + if(map.containsKey("field005")){ + sql.append(" and t.field005 = ").append(StringUtil.vString(map.get("field005"))); + } + if(map.containsKey("begin_field005")){ + sql.append(" and t.field005 >= ").append(StringUtil.vString(map.get("begin_field005"))); + } + if(map.containsKey("end_field005")){ + sql.append(" and t.field005 < ").append(StringUtil.vString(map.get("end_field005"))); + } + if(map.containsKey("sql_field005")){ + sql.append(" " + StringUtil.vString(map.get("sql_field005"))); + } + if(map.containsKey("field007")){ + sql.append(" and t.field007 = ").append(StringUtil.vString(map.get("field007"))); + } + if(map.containsKey("begin_field007")){ + sql.append(" and t.field007 >= ").append(StringUtil.vString(map.get("begin_field007"))); + } + if(map.containsKey("end_field007")){ + sql.append(" and t.field007 < ").append(StringUtil.vString(map.get("end_field007"))); + } + if(map.containsKey("sql_field007")){ + sql.append(" " + StringUtil.vString(map.get("sql_field007"))); + } + if(map.containsKey("field008")){ + sql.append(" and t.field008 = ").append(StringUtil.vString(map.get("field008"))); + } + if(map.containsKey("begin_field008")){ + sql.append(" and t.field008 >= ").append(StringUtil.vString(map.get("begin_field008"))); + } + if(map.containsKey("end_field008")){ + sql.append(" and t.field008 < ").append(StringUtil.vString(map.get("end_field008"))); + } + if(map.containsKey("sql_field008")){ + sql.append(" " + StringUtil.vString(map.get("sql_field008"))); + } + if(map.containsKey("field002")){ + sql.append(" and t.field002 = '").append(StringUtil.vString(map.get("field002"))).append("'"); + } + if(map.containsKey("like_field002")){ + sql.append(" and t.field002 like '%").append(StringUtil.vString(map.get("like_field002"))).append("%'"); + } + if(map.containsKey("sql_field002")){ + sql.append(" " + StringUtil.vString(map.get("sql_field002"))); + } + if(map.containsKey("field003")){ + sql.append(" and t.field003 = '").append(StringUtil.vString(map.get("field003"))).append("'"); + } + if(map.containsKey("like_field003")){ + sql.append(" and t.field003 like '%").append(StringUtil.vString(map.get("like_field003"))).append("%'"); + } + if(map.containsKey("sql_field003")){ + sql.append(" " + StringUtil.vString(map.get("sql_field003"))); + } + if(map.containsKey("field006")){ + sql.append(" and t.field006 = '").append(StringUtil.vString(map.get("field006"))).append("'"); + } + if(map.containsKey("like_field006")){ + sql.append(" and t.field006 like '%").append(StringUtil.vString(map.get("like_field006"))).append("%'"); + } + if(map.containsKey("sql_field006")){ + sql.append(" " + StringUtil.vString(map.get("sql_field006"))); + } + if(map.containsKey("mfsql")){ + sql.append(" " + StringUtil.vString(map.get("mfsql"))); + } + if(map.containsKey("sqlorderby")){ + sql.append(" order by " + StringUtil.vString(map.get("sqlorderby"))); + }else{ + sql.append(" order by t.field008, t.id ").append(StringUtil.vString(map.get("sqlsortway")).length() > 0 ? StringUtil.vString(map.get("sqlsortway")) : "desc"); + } + } + writeLog("sql>>>>>>>>>>>>>>>>>>"+sql.toString()); + rs.executeQuery(sql.toString()); + boolean isMysql = false; + if(DialectUtil.isMySql(rs.getDBType())){ + isMysql = true; + } + + String wfId = map != null && map.containsKey("wfId") ? StringUtil.vString(map.get("wfId")) : ""; + boolean canExeQuery = StringUtil.isNotNull(wfId) && StringUtil.parseToInt(wfId) != -1; + List> nList = canExeQuery ? executeQuery("select a.nodeId,b.nodeName,a.nodeType from workflow_flownode a,workflow_nodebase b where (b.IsFreeNode is null or b.IsFreeNode!='1') and a.nodeId=b.id and a.workflowId="+wfId+" order by a.nodeType asc,a.nodeId asc") : null; + List> oList = canExeQuery ? executeQuery("select id,isreject,linkname,conditioncn from workflow_nodelink where workflowId = "+wfId) : null; + + List> nList_tmp = new ArrayList>(); + List> oList_tmp = new ArrayList>(); + reBuidldList(nList,oList,nList_tmp,oList_tmp); + + HrmAttProcAction bean = null; + while(rs.next()){ + bean = new HrmAttProcAction(); + bean.setId(StringUtil.parseToLong(rs.getString("id"))); + bean.setMfid(StringUtil.parseToLong(rs.getString("mfid"))); + bean.setField001(StringUtil.parseToLong(rs.getString("field001"))); + bean.setField002(StringUtil.vString(rs.getString("field002"))); + bean.setField003(StringUtil.vString(rs.getString("field003"))); + bean.setField004(StringUtil.parseToInt(rs.getString("field004"))); + bean.setField005(StringUtil.parseToInt(rs.getString("field005"))); + bean.setField006(StringUtil.vString(rs.getString("field006"), "-1")); + String field006 = bean.getField006().startsWith(",") ? bean.getField006() : "," + bean.getField006(); + field006 = field006.endsWith(",") ? field006 : field006 + ","; + StringBuffer field006Name = new StringBuffer(); + switch(bean.getField005().intValue()) { + case 0: + if(oList_tmp != null) { + String key = "linkname".toUpperCase(); + String idKey = "id".toUpperCase(); + //mysql环境下id这个不是大写 + for(Map _map : oList_tmp) { + if(field006.indexOf(","+StringUtil.vString(_map.get(idKey))+",") != -1) { + field006Name.append(field006Name.length() == 0 ? "" : ",").append(StringUtil.vString(_map.get(key))); + } + } + } + break; + case 1: + case 2: + if(nList_tmp != null) { + String key = "nodeName".toUpperCase(); + String idKey = "nodeId".toUpperCase(); + for(Map _map : nList_tmp) { + if(field006.indexOf(","+StringUtil.vString(_map.get(idKey))+",") != -1) { + field006Name.append(field006Name.length() == 0 ? "" : ",").append(StringUtil.vString(_map.get(key))); + } + } + } + break; + } + bean.setField006Name(field006Name.toString()); + bean.setField007(StringUtil.parseToInt(rs.getString("field007"))); + bean.setField008(StringUtil.parseToInt(rs.getString("field008"))); + list.add(bean); + } + return list; + } + + private void reBuidldList(List> nList, List> oList, List> nList_tmp, List> oList_tmp) { + if(nList != null && !nList.isEmpty()){ + for(Map _map : nList) { + Map nMap_tmp = new HashMap<>(); + for(Map.Entry me : _map.entrySet()){ + String map_key = me.getKey(); + Object map_val = me.getValue(); + nMap_tmp.put(map_key.toUpperCase(), map_val); + } + if(!nMap_tmp.isEmpty()){ + nList_tmp.add(nMap_tmp); + } + } + } + if(oList != null && !oList.isEmpty()){ + for(Map _map : oList) { + Map oMap_tmp = new HashMap<>(); + for(Map.Entry me : _map.entrySet()){ + String map_key = me.getKey(); + Object map_val = me.getValue(); + oMap_tmp.put(map_key.toUpperCase(), map_val); + } + if(!oMap_tmp.isEmpty()){ + oList_tmp.add(oMap_tmp); + } + } + } + } + + public HrmAttProcAction get(Comparable id) { + HrmAttProcAction bean = null; + Map map = new HashMap(); + map.put("id", id); + List list = find(map); + if(list != null && list.size() > 0){ + bean = list.get(0); + } + return bean; + } + + public void delete(Comparable id) { + RecordSet rs = new RecordSet(); + String deleteSql = "delete from kq_ATT_PROC_ACTION where id in ( "+id+" )"; + boolean flag = rs.executeUpdate(deleteSql); + writeLog("deleteSql>>>>>>>>>>>>>>>>"+deleteSql+">>>>>isOk>>>>"+flag); + } + + public void delete(Map map) { + RecordSet rs = new RecordSet(); + if(map == null || map.isEmpty()) return; + StringBuffer sql = new StringBuffer(); + if((rs.getDBType()).equalsIgnoreCase("postgresql")) { + sql.append("delete from kq_ATT_PROC_ACTION where mfid not in ('0', '5') "); + } else { + sql.append("delete from kq_ATT_PROC_ACTION where mfid not in (0, 5) "); + } + if(map.containsKey("field001")) sql.append(" and field001 = ").append(StringUtil.vString(map.get("field001"))); + boolean flag = rs.executeUpdate(sql.toString()); + writeLog("deleteSql>>>>>>>>>>>>>>>>"+sql.toString()+">>>>>>isOk>>>>"+flag); + } + + public void deleteAction(int wfid) { + RecordSet rs = new RecordSet(); +// String attAction = "'deduction','freeze','release','HrmScheduleShift','HrmPaidLeaveAction'," +// + "'KqSplitLeaveAction','KqSplitEvectionAction','KqSplitOutAction','KqSplitOvertimeAction'," +// + "'KqSplitOtherAction','KqSplitLeavebackAction','KqSplitCardAction','KqFreezeSplitLeaveAction'," +// + "'KqFreezeSplitEvectionAction','KqFreezeSplitOutAction','KqFreezeSplitOvertimeAction','KqFreezeSplitOtherAction'," +// + "'KqFreezeSplitLeavbackAction','KqFreezeVacationAction','KqDeductionVacationAction','KqReleaseVacationAction'," +// + "'KqPaidLeaveAction','KqSplitShiftAction'"; + String attAction = "'deduction','freeze','release','HrmScheduleShift','HrmPaidLeaveAction'," + + "'KqSplitAction','KqFreezeVacationAction','KqDeductionVacationAction','KqReleaseVacationAction'," + + "'KqPaidLeaveAction'"; + rs.executeSql(new StringBuffer("delete from workflowactionset where workflowid = ").append(wfid).append(" and interfaceid in ("+attAction+")").toString()); + } + + public void updateBackFlag(int field005, int flag, int wfid, int nodeid) { + updateBackFlag(field005, flag, wfid, String.valueOf(nodeid)); + } + + public void updateBackFlag(int field005, int flag, int wfid, String nodeid) { + RecordSet rs = new RecordSet(); + if(field005 <= 0 || nodeid.equals("0") || nodeid.startsWith("0,")) return; + String nodeField = "drawbackflag"; + if(field005 == 1) { + nodeField = "rejectbackflag"; + flag = flag == 1 ? 0 : 1; + } + rs.executeSql("update workflow_flownode set "+nodeField+"="+flag+" where workflowid="+wfid+" and nodeid in ("+nodeid+")"); + } + +} diff --git a/src/com/engine/kq/wfset/attendance/dao/HrmAttProcFieldsDao.java b/src/com/engine/kq/wfset/attendance/dao/HrmAttProcFieldsDao.java new file mode 100644 index 0000000..20f6a65 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/dao/HrmAttProcFieldsDao.java @@ -0,0 +1,210 @@ +package com.engine.kq.wfset.attendance.dao; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import com.engine.kq.wfset.attendance.framework.BaseDao; +import com.engine.kq.wfset.attendance.domain.HrmAttProcFields; + +/** + * HrmAttProcFieldsDao + * @author wcd + * @version 1.0 2015-04-24 + */ +public class HrmAttProcFieldsDao implements BaseDao { + + //private RecordSet rs; + + public HrmAttProcFieldsDao() { + //this.rs = new RecordSet(); + } + + public Comparable insert(HrmAttProcFields bean) { + return -1; + } + + public void update(HrmAttProcFields bean) {} + + public List find(Map map) { + RecordSet rs = new RecordSet(); + List list = new ArrayList(); + StringBuffer sql = new StringBuffer() + .append(" select distinct t.id,t.mfid,t.field001,t.field002,t.field003,t.field004,t.field005,") + .append(" t.field006,t.field007,t.field008,t.field009,t.field010,'' indexid,'' labelname,7 languageid") + .append(" from kq_ATT_PROC_FIELDS t") + .append(" where 1 = 1"); + if(map != null) { + if(map.containsKey("id")){ + sql.append(" and t.id = ").append(StringUtil.vString(map.get("id"))); + } + if(map.containsKey("begin_id")){ + sql.append(" and t.id >= ").append(StringUtil.vString(map.get("begin_id"))); + } + if(map.containsKey("end_id")){ + sql.append(" and t.id < ").append(StringUtil.vString(map.get("end_id"))); + } + if(map.containsKey("sql_id")){ + sql.append(" " + StringUtil.vString(map.get("sql_id"))); + } + if(map.containsKey("mfid")){ + sql.append(" and t.mfid = ").append(StringUtil.vString(map.get("mfid"))); + } + if(map.containsKey("begin_mfid")){ + sql.append(" and t.mfid >= ").append(StringUtil.vString(map.get("begin_mfid"))); + } + if(map.containsKey("end_mfid")){ + sql.append(" and t.mfid < ").append(StringUtil.vString(map.get("end_mfid"))); + } + if(map.containsKey("sql_mfid")){ + sql.append(" " + StringUtil.vString(map.get("sql_mfid"))); + } + if(map.containsKey("field001")){ + sql.append(" and t.field001 = ").append(StringUtil.vString(map.get("field001"))); + } + if(map.containsKey("begin_field001")){ + sql.append(" and t.field001 >= ").append(StringUtil.vString(map.get("begin_field001"))); + } + if(map.containsKey("end_field001")){ + sql.append(" and t.field001 < ").append(StringUtil.vString(map.get("end_field001"))); + } + if(map.containsKey("sql_field001")){ + sql.append(" " + StringUtil.vString(map.get("sql_field001"))); + } + if(map.containsKey("field005")){ + sql.append(" and t.field005 = ").append(StringUtil.vString(map.get("field005"))); + } + if(map.containsKey("begin_field005")){ + sql.append(" and t.field005 >= ").append(StringUtil.vString(map.get("begin_field005"))); + } + if(map.containsKey("end_field005")){ + sql.append(" and t.field005 < ").append(StringUtil.vString(map.get("end_field005"))); + } + if(map.containsKey("sql_field005")){ + sql.append(" " + StringUtil.vString(map.get("sql_field005"))); + } + if(map.containsKey("field006")){ + sql.append(" and t.field006 = ").append(StringUtil.vString(map.get("field006"))); + } + if(map.containsKey("begin_field006")){ + sql.append(" and t.field006 >= ").append(StringUtil.vString(map.get("begin_field006"))); + } + if(map.containsKey("end_field006")){ + sql.append(" and t.field006 < ").append(StringUtil.vString(map.get("end_field006"))); + } + if(map.containsKey("sql_field006")){ + sql.append(" " + StringUtil.vString(map.get("sql_field006"))); + } + if(map.containsKey("field007")){ + sql.append(" and t.field007 = ").append(StringUtil.vString(map.get("field007"))); + } + if(map.containsKey("begin_field007")){ + sql.append(" and t.field007 >= ").append(StringUtil.vString(map.get("begin_field007"))); + } + if(map.containsKey("end_field007")){ + sql.append(" and t.field007 < ").append(StringUtil.vString(map.get("end_field007"))); + } + if(map.containsKey("sql_field007")){ + sql.append(" " + StringUtil.vString(map.get("sql_field007"))); + } + if(map.containsKey("field009")){ + sql.append(" and t.field009 = ").append(StringUtil.vString(map.get("field009"))); + } + if(map.containsKey("begin_field009")){ + sql.append(" and t.field009 >= ").append(StringUtil.vString(map.get("begin_field009"))); + } + if(map.containsKey("end_field009")){ + sql.append(" and t.field009 < ").append(StringUtil.vString(map.get("end_field009"))); + } + if(map.containsKey("sql_field009")){ + sql.append(" " + StringUtil.vString(map.get("sql_field009"))); + } + if(map.containsKey("field010")){ + sql.append(" and t.field010 = ").append(StringUtil.vString(map.get("field010"))); + } + if(map.containsKey("begin_field010")){ + sql.append(" and t.field010 >= ").append(StringUtil.vString(map.get("begin_field010"))); + } + if(map.containsKey("end_field010")){ + sql.append(" and t.field010 < ").append(StringUtil.vString(map.get("end_field010"))); + } + if(map.containsKey("sql_field010")){ + sql.append(" " + StringUtil.vString(map.get("sql_field010"))); + } + if(map.containsKey("field002")){ + sql.append(" and t.field002 = '").append(StringUtil.vString(map.get("field002"))).append("'"); + } + if(map.containsKey("like_field002")){ + sql.append(" and t.field002 like '%").append(StringUtil.vString(map.get("like_field002"))).append("%'"); + } + if(map.containsKey("sql_field002")){ + sql.append(" " + StringUtil.vString(map.get("sql_field002"))); + } + if(map.containsKey("field003")){ + sql.append(" and t.field003 = '").append(StringUtil.vString(map.get("field003"))).append("'"); + } + if(map.containsKey("like_field003")){ + sql.append(" and t.field003 like '%").append(StringUtil.vString(map.get("like_field003"))).append("%'"); + } + if(map.containsKey("sql_field003")){ + sql.append(" " + StringUtil.vString(map.get("sql_field003"))); + } + if(map.containsKey("field004")){ + sql.append(" and t.field004 = '").append(StringUtil.vString(map.get("field004"))).append("'"); + } + if(map.containsKey("like_field004")){ + sql.append(" and t.field004 like '%").append(StringUtil.vString(map.get("like_field004"))).append("%'"); + } + if(map.containsKey("sql_field004")){ + sql.append(" " + StringUtil.vString(map.get("sql_field004"))); + } + if(map.containsKey("field008")){ + sql.append(" and t.field008 = '").append(StringUtil.vString(map.get("field008"))).append("'"); + } + if(map.containsKey("like_field008")){ + sql.append(" and t.field008 like '%").append(StringUtil.vString(map.get("like_field008"))).append("%'"); + } + if(map.containsKey("sql_field008")){ + sql.append(" " + StringUtil.vString(map.get("sql_field008"))); + } + if(map.containsKey("mfsql")){ + sql.append(" " + StringUtil.vString(map.get("mfsql"))); + } + if(map.containsKey("sqlorderby")){ + sql.append(" order by " + StringUtil.vString(map.get("sqlorderby"))); + }else{ + sql.append(" order by t.field009, t.id ").append(StringUtil.vString(map.get("sqlsortway")).length() > 0 ? StringUtil.vString(map.get("sqlsortway")) : "desc"); + } + } + rs.executeSql(sql.toString()); + HrmAttProcFields bean = null; + while(rs.next()){ + bean = new HrmAttProcFields(); + bean.setId(StringUtil.parseToLong(rs.getString("id"))); + bean.setMfid(StringUtil.parseToLong(rs.getString("mfid"))); + bean.setLabelName(StringUtil.vString(rs.getString("labelname"))); + bean.setLanguageid(StringUtil.parseToInt(rs.getString("languageid"))); + bean.setField001(StringUtil.parseToInt(rs.getString("field001"))); + bean.setField002(StringUtil.vString(rs.getString("field002"))); + bean.setField003(StringUtil.vString(rs.getString("field003"))); + bean.setField004(StringUtil.vString(rs.getString("field004"))); + bean.setField005(StringUtil.parseToInt(rs.getString("field005"))); + bean.setField006(StringUtil.parseToInt(rs.getString("field006"))); + bean.setField007(StringUtil.parseToInt(rs.getString("field007"))); + bean.setField008(StringUtil.vString(rs.getString("field008"))); + bean.setField009(StringUtil.parseToDouble(rs.getString("field009"))); + bean.setField010(StringUtil.parseToInt(rs.getString("field010"))); + list.add(bean); + } + return list; + } + + public HrmAttProcFields get(Comparable id) { + return null; + } + + public void delete(Comparable id) {} + +} diff --git a/src/com/engine/kq/wfset/attendance/dao/HrmAttProcRelationDao.java b/src/com/engine/kq/wfset/attendance/dao/HrmAttProcRelationDao.java new file mode 100644 index 0000000..a7e3745 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/dao/HrmAttProcRelationDao.java @@ -0,0 +1,191 @@ +package com.engine.kq.wfset.attendance.dao; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import weaver.common.StringUtil; +import com.engine.kq.wfset.attendance.framework.BaseConnection; +import com.engine.kq.wfset.attendance.framework.BaseDao; +import com.engine.kq.wfset.attendance.domain.HrmAttProcRelation; +import weaver.conn.RecordSet; + +/** + * HrmAttProcRelationDao + * @author wcd + * @version 1.0 2015-04-24 + */ +public class HrmAttProcRelationDao extends BaseConnection implements BaseDao { + + public Comparable insert(HrmAttProcRelation bean) { + RecordSet rs = new RecordSet(); + if(bean == null) return -1; + StringBuffer sql = new StringBuffer() + .append(" insert into kq_ATT_PROC_RELATION (mfid,field001,field002,field003,field004 )") + .append(" values("+bean.getMfid()+","+bean.getField001()+","+bean.getField002()+","+bean.getField003()+",") + .append(" '"+bean.getField004()+"' )"); + rs.executeSql(sql.toString()); + return 0; + } + + public void insert(List list) { + RecordSet rs = new RecordSet(); + if(list == null) return; + StringBuffer sql = new StringBuffer(), tempSql = new StringBuffer() + .append(" insert into kq_ATT_PROC_RELATION (mfid,field001,field002,field003,field004 )"); + int count = 0; + for(HrmAttProcRelation bean : list) { + sql.append(count == 0 ? tempSql.toString() : " UNION ").append(bean.getSql()).append(isOracle() ? " from dual" : ""); + if(++count > 100 || count >= list.size()) { + rs.executeSql(sql.toString()); + sql.setLength(count = 0); + } + } + } + + public void update(HrmAttProcRelation bean) { + RecordSet rs = new RecordSet(); + if(bean == null) return; + StringBuffer sql = new StringBuffer() + .append(" update kq_ATT_PROC_RELATION set") + .append(" mfid = "+bean.getMfid()+",field001 = "+bean.getField001()+",field002 = "+bean.getField002()+",") + .append(" field003 = "+bean.getField003()+",field004 = '"+bean.getField004()+"'") + .append(" where id = "+bean.getId()+""); + rs.executeSql(sql.toString()); + } + + public List find(Map map) { + RecordSet rs = new RecordSet(); + List list = new ArrayList(); + StringBuffer sql = new StringBuffer() + .append(" select t.id,t.mfid,t.field001,t.field002,t.field003,t.field004,f.field001 as field005,f.field002 as field006") + .append(" from kq_ATT_PROC_RELATION t left join kq_ATT_PROC_FIELDS f on t.field002 = f.id") + .append(" where 1 = 1"); + if(map != null) { + if(map.containsKey("id")){ + sql.append(" and t.id = ").append(StringUtil.vString(map.get("id"))); + } + if(map.containsKey("begin_id")){ + sql.append(" and t.id >= ").append(StringUtil.vString(map.get("begin_id"))); + } + if(map.containsKey("end_id")){ + sql.append(" and t.id < ").append(StringUtil.vString(map.get("end_id"))); + } + if(map.containsKey("sql_id")){ + sql.append(" " + StringUtil.vString(map.get("sql_id"))); + } + if(map.containsKey("mfid")){ + sql.append(" and t.mfid = ").append(StringUtil.vString(map.get("mfid"))); + } + if(map.containsKey("begin_mfid")){ + sql.append(" and t.mfid >= ").append(StringUtil.vString(map.get("begin_mfid"))); + } + if(map.containsKey("end_mfid")){ + sql.append(" and t.mfid < ").append(StringUtil.vString(map.get("end_mfid"))); + } + if(map.containsKey("sql_mfid")){ + sql.append(" " + StringUtil.vString(map.get("sql_mfid"))); + } + if(map.containsKey("field001")){ + sql.append(" and t.field001 = ").append(StringUtil.vString(map.get("field001"))); + } + if(map.containsKey("begin_field001")){ + sql.append(" and t.field001 >= ").append(StringUtil.vString(map.get("begin_field001"))); + } + if(map.containsKey("end_field001")){ + sql.append(" and t.field001 < ").append(StringUtil.vString(map.get("end_field001"))); + } + if(map.containsKey("sql_field001")){ + sql.append(" " + StringUtil.vString(map.get("sql_field001"))); + } + if(map.containsKey("field002")){ + sql.append(" and t.field002 = ").append(StringUtil.vString(map.get("field002"))); + } + if(map.containsKey("begin_field002")){ + sql.append(" and t.field002 >= ").append(StringUtil.vString(map.get("begin_field002"))); + } + if(map.containsKey("end_field002")){ + sql.append(" and t.field002 < ").append(StringUtil.vString(map.get("end_field002"))); + } + if(map.containsKey("sql_field002")){ + sql.append(" " + StringUtil.vString(map.get("sql_field002"))); + } + if(map.containsKey("field003")){ + sql.append(" and t.field003 = ").append(StringUtil.vString(map.get("field003"))); + } + if(map.containsKey("begin_field003")){ + sql.append(" and t.field003 >= ").append(StringUtil.vString(map.get("begin_field003"))); + } + if(map.containsKey("end_field003")){ + sql.append(" and t.field003 < ").append(StringUtil.vString(map.get("end_field003"))); + } + if(map.containsKey("sql_field003")){ + sql.append(" " + StringUtil.vString(map.get("sql_field003"))); + } + if(map.containsKey("field004")){ + sql.append(" and t.field004 = '").append(StringUtil.vString(map.get("field004"))).append("'"); + } + if(map.containsKey("like_field004")){ + sql.append(" and t.field004 like '%").append(StringUtil.vString(map.get("like_field004"))).append("%'"); + } + if(map.containsKey("sql_field004")){ + sql.append(" " + StringUtil.vString(map.get("sql_field004"))); + } + if(map.containsKey("field005")){ + sql.append(" and f.field001 = ").append(StringUtil.vString(map.get("field005"))); + } + if(map.containsKey("field006")){ + sql.append(" and f.field002 = '").append(StringUtil.vString(map.get("field006"))).append("'"); + } + if(map.containsKey("mfsql")){ + sql.append(" " + StringUtil.vString(map.get("mfsql"))); + } + if(map.containsKey("sqlorderby")){ + sql.append(" order by " + StringUtil.vString(map.get("sqlorderby"))); + }else{ + sql.append(" order by t.id ").append(StringUtil.vString(map.get("sqlsortway")).length() > 0 ? StringUtil.vString(map.get("sqlsortway")) : "desc"); + } + } + rs.executeSql(sql.toString()); + HrmAttProcRelation bean = null; + while(rs.next()){ + bean = new HrmAttProcRelation(); + bean.setId(StringUtil.parseToLong(rs.getString("id"))); + bean.setMfid(StringUtil.parseToLong(rs.getString("mfid"))); + bean.setField001(StringUtil.parseToInt(rs.getString("field001"))); + bean.setField002(StringUtil.parseToInt(rs.getString("field002"))); + bean.setField003(StringUtil.parseToInt(rs.getString("field003"))); + bean.setField004(StringUtil.vString(rs.getString("field004"))); + bean.setField005(StringUtil.parseToInt(rs.getString("field005"))); + bean.setField006(StringUtil.vString(rs.getString("field006"))); + list.add(bean); + } + return list; + } + + public HrmAttProcRelation get(Comparable id) { + HrmAttProcRelation bean = null; + Map map = new HashMap(); + map.put("id", id); + List list = find(map); + if(list != null && list.size() > 0){ + bean = list.get(0); + } + return bean; + } + + public void delete(Comparable id) { + RecordSet rs = new RecordSet(); + rs.executeSql("delete from kq_ATT_PROC_RELATION where id in ( "+id+" )"); + } + + public void delete(Map map) { + RecordSet rs = new RecordSet(); + if(map == null || map.isEmpty()) return; + StringBuffer sql = new StringBuffer("delete from kq_ATT_PROC_RELATION where 1=1 "); + if(map.containsKey("field001")) sql.append(" and field001 = ").append(StringUtil.vString(map.get("field001"))); + rs.executeSql(sql.toString()); + } + +} diff --git a/src/com/engine/kq/wfset/attendance/dao/HrmAttProcSetDao.java b/src/com/engine/kq/wfset/attendance/dao/HrmAttProcSetDao.java new file mode 100644 index 0000000..93e3c35 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/dao/HrmAttProcSetDao.java @@ -0,0 +1,498 @@ +package com.engine.kq.wfset.attendance.dao; + +import com.engine.kq.cmd.hrmAttProcSet.KqTempletEnum; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.attendance.framework.BaseConnection; +import com.engine.kq.wfset.attendance.framework.BaseDao; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.common.database.dialect.DbDialectFactory; +import weaver.hrm.common.database.dialect.DialectUtil; + +/** + * HrmAttProcSetDao + * @author wcd + * @version 1.0 2015-04-23 + */ +public class HrmAttProcSetDao extends BaseConnection implements BaseDao { + + public Comparable insert(HrmAttProcSet bean) { + RecordSet rs = new RecordSet(); + String id = "-1"; + if(bean == null) return id; + StringBuffer sql = new StringBuffer() + .append(" insert into kq_ATT_PROC_SET (field001,field002,field003,field004,field005,field006,") + .append(" field007,field008,field009,field010,field011,field012,") + .append(" field013,field014,field015,mfid,ishalfday,usedetail,templetfile,templetmobilefile,templetroute,tablename,detailtablename,flow_deduct_card )") + .append(" values("+bean.getField001()+","+bean.getField002()+","+bean.getField003()+","+bean.getField004()+",") + .append(" "+bean.getField005()+","+bean.getField006()+","+bean.getField007()+",'"+bean.getField008()+"',") + .append(" '"+bean.getField009()+"','"+bean.getField010()+"','"+bean.getField011()+"','"+bean.getField012()+"',") + .append(" '"+bean.getField013()+"',"+bean.getField014()+","+bean.getField015()+","+bean.getMfid()+","+bean.getIsHalfDay()+","+bean.getUsedetail()+", ") + .append(" '"+bean.getTempletfile()+"','"+bean.getTempletmobilefile()+"','"+bean.getTempletroute()+"','"+bean.getTablename()+"','"+bean.getDetailtablename()+"',"+bean.getFlow_deduct_card()+" )"); + rs.executeSql(sql.toString()); + rs.executeSql("select id from kq_ATT_PROC_SET where mfid = '"+bean.getMfid()+"'"); + return rs.next() ? rs.getString(1) : id; + } + + public void update(HrmAttProcSet bean) { + RecordSet rs = new RecordSet(); + if(bean == null) return; + StringBuffer sql = new StringBuffer() + .append(" update kq_ATT_PROC_SET set") + .append(" field001 = "+bean.getField001()+",field002 = "+bean.getField002()+",field003 = "+bean.getField003()+",") + .append(" field004 = "+bean.getField004()+",field005 = "+bean.getField005()+",field006 = "+bean.getField006()+",") + .append(" field007 = "+bean.getField007()+",field008 = '"+bean.getField008()+"',field009 = '"+bean.getField009()+"',") + .append(" field010 = '"+bean.getField010()+"',field011 = '"+bean.getField011()+"',field012 = '"+bean.getField012()+"',") + .append(" field013 = '"+bean.getField013()+"',field014 = "+bean.getField014()+",field015 = "+bean.getField015()+",") + .append(" mfid = "+bean.getMfid()+",ishalfday= "+bean.getIsHalfDay()+",usedetail="+bean.getUsedetail()+",") + .append(" tablename = '"+bean.getTablename()+"',detailtablename= '"+bean.getDetailtablename()+"',") + .append(" templetfile='"+bean.getTempletfile()+"',templetmobilefile='"+bean.getTempletmobilefile()+"',templetroute='"+bean.getTempletroute()+"'") + .append(" ,flow_deduct_card="+bean.getFlow_deduct_card()) + .append(" where id = "+bean.getId()+""); + rs.executeSql(sql.toString()); + } + + public List find(Map map) { + RecordSet rs = new RecordSet(); + List list = new ArrayList(); + StringBuffer sql = new StringBuffer() + .append(" select t.id,t.field001,t.field002,t.field003,t.field004,t.field005,t.field006,") + .append(" t.field007,t.field008,t.field009,t.field010,t.field011,t.field012,") + .append(" t.field013,t.field014,t.field015,t.ishalfday,t.usedetail,t.flow_deduct_card,t.templetfile,t.templetmobilefile,t.templetroute,b.from_module_ as field016,t.mfid,w.formid,b.tablename,t.detailtablename ") + .append(" from kq_ATT_PROC_SET t left join workflow_base w on t.field001 = w.id left join workflow_bill b on w.formid = b.id") + .append(" where 1 = 1"); + if(map != null) { + if(map.containsKey("id")){ + sql.append(" and t.id = ").append(StringUtil.vString(map.get("id"))); + } + if(map.containsKey("begin_id")){ + sql.append(" and t.id >= ").append(StringUtil.vString(map.get("begin_id"))); + } + if(map.containsKey("end_id")){ + sql.append(" and t.id < ").append(StringUtil.vString(map.get("end_id"))); + } + if(map.containsKey("ishalfday")){ + sql.append(" and t.ishalfday = ").append(StringUtil.vString(map.get("ishalfday"))); + } + if(map.containsKey("begin_ishalfday")){ + sql.append(" and t.ishalfday >= ").append(StringUtil.vString(map.get("begin_ishalfday"))); + } + if(map.containsKey("end_ishalfday")){ + sql.append(" and t.ishalfday < ").append(StringUtil.vString(map.get("end_ishalfday"))); + } + if(map.containsKey("sql_id")){ + sql.append(" " + StringUtil.vString(map.get("sql_id"))); + } + if(map.containsKey("field001")){ + sql.append(" and t.field001 = ").append(StringUtil.vString(map.get("field001"))); + } + if(map.containsKey("begin_field001")){ + sql.append(" and t.field001 >= ").append(StringUtil.vString(map.get("begin_field001"))); + } + if(map.containsKey("end_field001")){ + sql.append(" and t.field001 < ").append(StringUtil.vString(map.get("end_field001"))); + } + if(map.containsKey("sql_field001")){ + sql.append(" " + StringUtil.vString(map.get("sql_field001"))); + } + if(map.containsKey("field002")){ + sql.append(" and t.field002 = ").append(StringUtil.vString(map.get("field002"))); + } + if(map.containsKey("begin_field002")){ + sql.append(" and t.field002 >= ").append(StringUtil.vString(map.get("begin_field002"))); + } + if(map.containsKey("end_field002")){ + sql.append(" and t.field002 < ").append(StringUtil.vString(map.get("end_field002"))); + } + if(map.containsKey("sql_field002")){ + sql.append(" " + StringUtil.vString(map.get("sql_field002"))); + } + if(map.containsKey("field003")){ + sql.append(" and t.field003 = ").append(StringUtil.vString(map.get("field003"))); + } + if(map.containsKey("begin_field003")){ + sql.append(" and t.field003 >= ").append(StringUtil.vString(map.get("begin_field003"))); + } + if(map.containsKey("end_field003")){ + sql.append(" and t.field003 < ").append(StringUtil.vString(map.get("end_field003"))); + } + if(map.containsKey("sql_field003")){ + sql.append(" " + StringUtil.vString(map.get("sql_field003"))); + } + if(map.containsKey("field004")){ + sql.append(" and t.field004 = ").append(StringUtil.vString(map.get("field004"))); + } + if(map.containsKey("begin_field004")){ + sql.append(" and t.field004 >= ").append(StringUtil.vString(map.get("begin_field004"))); + } + if(map.containsKey("end_field004")){ + sql.append(" and t.field004 < ").append(StringUtil.vString(map.get("end_field004"))); + } + if(map.containsKey("sql_field004")){ + sql.append(" " + StringUtil.vString(map.get("sql_field004"))); + } + if(map.containsKey("field005")){ + sql.append(" and t.field005 = ").append(StringUtil.vString(map.get("field005"))); + } + if(map.containsKey("begin_field005")){ + sql.append(" and t.field005 >= ").append(StringUtil.vString(map.get("begin_field005"))); + } + if(map.containsKey("end_field005")){ + sql.append(" and t.field005 < ").append(StringUtil.vString(map.get("end_field005"))); + } + if(map.containsKey("sql_field005")){ + sql.append(" " + StringUtil.vString(map.get("sql_field005"))); + } + if(map.containsKey("field006")){ + sql.append(" and t.field006 = ").append(StringUtil.vString(map.get("field006"))); + } + if(map.containsKey("begin_field006")){ + sql.append(" and t.field006 >= ").append(StringUtil.vString(map.get("begin_field006"))); + } + if(map.containsKey("end_field006")){ + sql.append(" and t.field006 < ").append(StringUtil.vString(map.get("end_field006"))); + } + if(map.containsKey("sql_field006")){ + sql.append(" " + StringUtil.vString(map.get("sql_field006"))); + } + if(map.containsKey("field007")){ + sql.append(" and t.field007 = ").append(StringUtil.vString(map.get("field007"))); + } + if(map.containsKey("begin_field007")){ + sql.append(" and t.field007 >= ").append(StringUtil.vString(map.get("begin_field007"))); + } + if(map.containsKey("end_field007")){ + sql.append(" and t.field007 < ").append(StringUtil.vString(map.get("end_field007"))); + } + if(map.containsKey("sql_field007")){ + sql.append(" " + StringUtil.vString(map.get("sql_field007"))); + } + if(map.containsKey("field014")){ + sql.append(" and t.field014 = ").append(StringUtil.vString(map.get("field014"))); + } + if(map.containsKey("begin_field014")){ + sql.append(" and t.field014 >= ").append(StringUtil.vString(map.get("begin_field014"))); + } + if(map.containsKey("end_field014")){ + sql.append(" and t.field014 < ").append(StringUtil.vString(map.get("end_field014"))); + } + if(map.containsKey("sql_field014")){ + sql.append(" " + StringUtil.vString(map.get("sql_field014"))); + } + if(map.containsKey("field015")){ + sql.append(" and t.field015 = ").append(StringUtil.vString(map.get("field015"))); + } + if(map.containsKey("begin_field015")){ + sql.append(" and t.field015 >= ").append(StringUtil.vString(map.get("begin_field015"))); + } + if(map.containsKey("end_field015")){ + sql.append(" and t.field015 < ").append(StringUtil.vString(map.get("end_field015"))); + } + if(map.containsKey("sql_field015")){ + sql.append(" " + StringUtil.vString(map.get("sql_field015"))); + } + if(map.containsKey("mfid")){ + sql.append(" and t.mfid = ").append(StringUtil.vString(map.get("mfid"))); + } + if(map.containsKey("begin_mfid")){ + sql.append(" and t.mfid >= ").append(StringUtil.vString(map.get("begin_mfid"))); + } + if(map.containsKey("end_mfid")){ + sql.append(" and t.mfid < ").append(StringUtil.vString(map.get("end_mfid"))); + } + if(map.containsKey("sql_mfid")){ + sql.append(" " + StringUtil.vString(map.get("sql_mfid"))); + } + if(map.containsKey("field008")){ + sql.append(" and t.field008 = '").append(StringUtil.vString(map.get("field008"))).append("'"); + } + if(map.containsKey("like_field008")){ + sql.append(" and t.field008 like '%").append(StringUtil.vString(map.get("like_field008"))).append("%'"); + } + if(map.containsKey("sql_field008")){ + sql.append(" " + StringUtil.vString(map.get("sql_field008"))); + } + if(map.containsKey("field009")){ + sql.append(" and t.field009 = '").append(StringUtil.vString(map.get("field009"))).append("'"); + } + if(map.containsKey("like_field009")){ + sql.append(" and t.field009 like '%").append(StringUtil.vString(map.get("like_field009"))).append("%'"); + } + if(map.containsKey("sql_field009")){ + sql.append(" " + StringUtil.vString(map.get("sql_field009"))); + } + if(map.containsKey("field010")){ + sql.append(" and t.field010 = '").append(StringUtil.vString(map.get("field010"))).append("'"); + } + if(map.containsKey("like_field010")){ + sql.append(" and t.field010 like '%").append(StringUtil.vString(map.get("like_field010"))).append("%'"); + } + if(map.containsKey("sql_field010")){ + sql.append(" " + StringUtil.vString(map.get("sql_field010"))); + } + if(map.containsKey("field011")){ + sql.append(" and t.field011 = '").append(StringUtil.vString(map.get("field011"))).append("'"); + } + if(map.containsKey("like_field011")){ + sql.append(" and t.field011 like '%").append(StringUtil.vString(map.get("like_field011"))).append("%'"); + } + if(map.containsKey("sql_field011")){ + sql.append(" " + StringUtil.vString(map.get("sql_field011"))); + } + if(map.containsKey("field012")){ + sql.append(" and t.field012 = '").append(StringUtil.vString(map.get("field012"))).append("'"); + } + if(map.containsKey("like_field012")){ + sql.append(" and t.field012 like '%").append(StringUtil.vString(map.get("like_field012"))).append("%'"); + } + if(map.containsKey("sql_field012")){ + sql.append(" " + StringUtil.vString(map.get("sql_field012"))); + } + if(map.containsKey("field013")){ + sql.append(" and t.field013 = '").append(StringUtil.vString(map.get("field013"))).append("'"); + } + if(map.containsKey("like_field013")){ + sql.append(" and t.field013 like '%").append(StringUtil.vString(map.get("like_field013"))).append("%'"); + } + if(map.containsKey("sql_field013")){ + sql.append(" " + StringUtil.vString(map.get("sql_field013"))); + } + + if(map.containsKey("usedetail")){ + sql.append(" and t.usedetail = ").append(StringUtil.vString(map.get("usedetail"))); + } + if(map.containsKey("begin_usedetail")){ + sql.append(" and t.usedetail >= ").append(StringUtil.vString(map.get("begin_usedetail"))); + } + if(map.containsKey("end_usedetail")){ + sql.append(" and t.usedetail < ").append(StringUtil.vString(map.get("end_usedetail"))); + } + if(map.containsKey("sql_usedetail")){ + sql.append(" " + StringUtil.vString(map.get("sql_usedetail"))); + } + + if(map.containsKey("flow_deduct_card")){ + sql.append(" and t.flow_deduct_card = ").append(StringUtil.vString(map.get("flow_deduct_card"))); + } + if(map.containsKey("begin_flow_deduct_card")){ + sql.append(" and t.flow_deduct_card >= ").append(StringUtil.vString(map.get("begin_flow_deduct_card"))); + } + if(map.containsKey("end_flow_deduct_card")){ + sql.append(" and t.flow_deduct_card < ").append(StringUtil.vString(map.get("end_flow_deduct_card"))); + } + if(map.containsKey("sql_flow_deduct_card")){ + sql.append(" " + StringUtil.vString(map.get("sql_flow_deduct_card"))); + } + + if(map.containsKey("mfsql")){ + sql.append(" " + StringUtil.vString(map.get("mfsql"))); + } + if(map.containsKey("sqlorderby")){ + sql.append(" order by " + StringUtil.vString(map.get("sqlorderby"))); + }else{ + sql.append(" order by t.id ").append(StringUtil.vString(map.get("sqlsortway")).length() > 0 ? StringUtil.vString(map.get("sqlsortway")) : "desc"); + } + } + rs.executeSql(sql.toString()); + HrmAttProcSet bean = null; + while(rs.next()){ + bean = new HrmAttProcSet(); + bean.setId(StringUtil.parseToLong(rs.getString("id"))); + bean.setField001(StringUtil.parseToInt(rs.getString("field001"))); + bean.setField002(StringUtil.parseToInt(rs.getString("field002"))); + bean.setField003(StringUtil.parseToInt(rs.getString("field003"))); + bean.setField004(StringUtil.parseToInt(rs.getString("field004"))); + bean.setField005(StringUtil.parseToInt(rs.getString("field005"))); + bean.setField006(StringUtil.parseToInt(rs.getString("field006"))); + bean.setField007(StringUtil.parseToInt(rs.getString("field007"))); + bean.setField008(StringUtil.vString(rs.getString("field008"))); + bean.setField009(StringUtil.vString(rs.getString("field009"))); + bean.setField010(StringUtil.vString(rs.getString("field010"))); + bean.setField011(StringUtil.vString(rs.getString("field011"))); + bean.setField012(StringUtil.vString(rs.getString("field012"))); + bean.setField013(StringUtil.vString(rs.getString("field013"))); + bean.setField014(StringUtil.parseToInt(rs.getString("field014"))); + bean.setField015(StringUtil.parseToInt(rs.getString("field015"))); + bean.setHAF(bean.getField003() == 1 || StringUtil.vString(rs.getString("field016")).equalsIgnoreCase("hrm_mf")); + bean.setMfid(StringUtil.parseToLong(rs.getString("mfid"))); + bean.setFormid(StringUtil.parseToInt(rs.getString("formid"))); + bean.setTablename(StringUtil.vString(rs.getString("tablename"))); + bean.setDetailtablename(StringUtil.vString(rs.getString("detailtablename"))); + bean.setIsHalfDay((StringUtil.parseToInt(rs.getString("ishalfday")))); + bean.setUsedetail(StringUtil.parseToInt(rs.getString("usedetail"))); + bean.setFlow_deduct_card(StringUtil.parseToInt(rs.getString("flow_deduct_card"))); + bean.setTempletfile(StringUtil.vString(rs.getString("templetfile"))); + bean.setTempletmobilefile(StringUtil.vString(rs.getString("templetmobilefile"))); + bean.setTempletroute(StringUtil.vString(rs.getString("templetroute"))); + list.add(bean); + } + return list; + } + + public HrmAttProcSet get(Comparable id) { + HrmAttProcSet bean = null; + Map map = new HashMap(); + map.put("id", id); + List list = find(map); + if(list != null && list.size() > 0){ + bean = list.get(0); + } + return bean; + } + + @Override + public void delete(Comparable id) { + RecordSet rs = new RecordSet(); + rs.executeSql(new StringBuffer("update workflow_base set custompage = '', custompage4Emoble = '' where id in (select field001 from kq_ATT_PROC_SET where id in (").append(id).append("))").toString()); + rs.executeSql("delete from kq_ATT_PROC_SET where id in ( "+id+" )"); + } + + public List getByField006(int field006, boolean field005, String id,String usedetail) { + RecordSet rs = new RecordSet(); + List list = new ArrayList(); + String pField = ""; + if(rs.getDBType().equalsIgnoreCase("oracle")) { + pField = "(case when t.field004 is null then t.field002||'_temp' else t.field004 end) pField"; + }else if(DialectUtil.isMySql(rs.getDBType())){ + String concat = DbDialectFactory.get(rs.getDBType()).concatStr("t.field002", "'_temp'") ; + pField = "(case when (t.field004 is null or t.field004 = '') then "+concat+" else t.field004 end) pField"; + }else if(rs.getDBType().equalsIgnoreCase("postgresql")){ + pField = "(case when (t.field004 is null or t.field004 = '') then t.field002||'_temp' else t.field004 end) pField"; + } else { + pField = "(case when (t.field004 is null or t.field004 = '') then t.field002+'_temp' else t.field004 end) pField"; + } + String sqlwhere = " where 1=1 "; + if(!StringUtil.isNull(id)){ + sqlwhere += " and t.id in ("+id+")"; + } + if(!StringUtil.isNull(usedetail)){ + sqlwhere += " and t.usedetail = '"+usedetail+"'"; + } + + StringBuffer sql = new StringBuffer("select * from (select t.id, t.tablename,").append(pField).append(",t.field002 as oField,wfid,usedetail,detailtablename") + .append(" from (select ").append(StringUtil.isNull(id) ? "min(a.id) id" : "a.id").append(", a.tablename,min(c.field004) as field004,d.field002,a.field001 as wfid,a.usedetail,a.detailtablename from kq_ATT_PROC_SET a ") + .append(" left join kq_ATT_PROC_RELATION c on a.id = c.field001") + .append(" left join kq_ATT_PROC_FIELDS d on c.field002 = d.id where a.field006 = ").append(field006).append(field005 ? " and a.field005 = 1" : "") + .append(" and c.field004 is not null and d.field002 is not null group by ").append(StringUtil.isNull(id) ? "" : "a.id,").append("a.tablename,d.field002,a.field001,a.usedetail,a.detailtablename) t ) t") + .append(sqlwhere) + .append(" order by t.tablename,t.oField"); + rs.executeSql(sql.toString()); + kqLog.info("getByField006:"+sql.toString()); + + HrmAttProcSet bean = null; + while (rs.next()) { + bean = new HrmAttProcSet(); + bean.setField001(rs.getInt("wfid")); + bean.setId(StringUtil.parseToLong(rs.getString("id"))); + bean.setTablename(StringUtil.vString(rs.getString("tablename"))); + bean.setField010(StringUtil.vString(rs.getString("pField"))); + bean.setField011(StringUtil.vString(rs.getString("oField"))); + bean.setUsedetail(Util.getIntValue(rs.getString("usedetail"))); + bean.setDetailtablename(Util.null2String(rs.getString("detailtablename"))); + list.add(bean); + } + return list; + } + + public void setCustomPage(int field001) { + setCustomPage(field001, 0); + } + + public void setCustomPage(int field001, int field006) { + setCustomPage(field001, field006,"","",""); + } + + public void setCustomPage(int field001, int field006,String templetfile,String templetmobilefile,String templetroute) { + String new_custompage = ""; + String new_custompage4Emoble = ""; + String new_templetroute = ""; + switch (field006){ + case 0 : + new_custompage = KqTempletEnum.LEAVE.getTempletfile(); + new_custompage4Emoble = KqTempletEnum.LEAVE.getTempletmobilefile(); + new_templetroute = KqTempletEnum.LEAVE.getTempletroute(); + break; + case 1 : + new_custompage = KqTempletEnum.EVECTION.getTempletfile(); + new_custompage4Emoble = KqTempletEnum.EVECTION.getTempletmobilefile(); + new_templetroute = KqTempletEnum.EVECTION.getTempletroute(); + break; + case 2 : + new_custompage = KqTempletEnum.OUT.getTempletfile(); + new_custompage4Emoble = KqTempletEnum.OUT.getTempletmobilefile(); + new_templetroute = KqTempletEnum.OUT.getTempletroute(); + break; + case 3 : + new_custompage = KqTempletEnum.OVERTIME.getTempletfile(); + new_custompage4Emoble = KqTempletEnum.OVERTIME.getTempletmobilefile(); + new_templetroute = KqTempletEnum.OVERTIME.getTempletroute(); + break; + case 4 : + new_custompage = KqTempletEnum.OTHER.getTempletfile(); + new_custompage4Emoble = KqTempletEnum.OTHER.getTempletmobilefile(); + new_templetroute = KqTempletEnum.OTHER.getTempletroute(); + break; + case 5 : + new_custompage = KqTempletEnum.SHIFT.getTempletfile(); + new_custompage4Emoble = KqTempletEnum.SHIFT.getTempletmobilefile(); + new_templetroute = KqTempletEnum.SHIFT.getTempletroute(); + break; + case 6 : + new_custompage = KqTempletEnum.LEAVEBACK.getTempletfile(); + new_custompage4Emoble = KqTempletEnum.LEAVEBACK.getTempletmobilefile(); + new_templetroute = KqTempletEnum.LEAVEBACK.getTempletroute(); + break; + case 7 : + new_custompage = KqTempletEnum.Card.getTempletfile(); + new_custompage4Emoble = KqTempletEnum.Card.getTempletmobilefile(); + new_templetroute = KqTempletEnum.Card.getTempletroute(); + break; + case 8 : + new_custompage = KqTempletEnum.PROCESSCHANGE.getTempletfile(); + new_custompage4Emoble = KqTempletEnum.PROCESSCHANGE.getTempletmobilefile(); + new_templetroute = KqTempletEnum.PROCESSCHANGE.getTempletroute(); + break; + default: + break; + } + if(templetfile.length() > 0){ + new_custompage = templetfile; + } + if(templetmobilefile.length() > 0){ + new_custompage4Emoble = templetmobilefile; + } + RecordSet rs = new RecordSet(); +// new_templetroute 这个还不让修改 + rs.executeSql(new StringBuffer("update workflow_base set custompage = '"+new_templetroute+new_custompage+"', custompage4Emoble = '"+new_templetroute+(new_custompage4Emoble)+"' where id = "+field001).toString()); + } + + public int getWFStartNodeId(int wfId) { + RecordSet rs = new RecordSet(); + StringBuffer sql = new StringBuffer("select a.nodeid from workflow_flownode a left join workflow_nodebase b on a.nodeid = b.id") + .append(" where a.workflowId = ").append(wfId).append(" and (b.isFreeNode != '1' OR b.isFreeNode IS null) and b.isstart =1 "); + rs.executeSql(sql.toString()); + return rs.next() ? rs.getInt("nodeid") : -1; + + } + public boolean hasFreezeNodeId(int wfId) { + RecordSet rs = new RecordSet(); + StringBuffer sql = new StringBuffer(" select field006 from kq_ATT_PROC_ACTION where field001 in (select id from kq_ATT_PROC_SET where field001 = ").append(wfId).append(") and field002 = 'freeze' "); + rs.executeSql(sql.toString()); + return rs.next() ? true : false; + } + public int getFreezeNodeType(int wfId) { + RecordSet rs = new RecordSet(); + StringBuffer sql = new StringBuffer("select a.nodeType from workflow_flownode a left join workflow_nodebase b on a.nodeid = b.id") + .append(" where a.workflowId = ").append(wfId).append(" and (b.isFreeNode != '1' OR b.isFreeNode IS null) and a.nodeid in (") + .append(" select field006 from kq_ATT_PROC_ACTION where field001 in (select id from kq_ATT_PROC_SET where field001 = ").append(wfId).append(") and field002 = 'freeze' ) order by b.nodeName asc"); + rs.executeSql(sql.toString()); + kqLog.info("getFreezeNodeType:"+sql.toString()); + return rs.next() ? rs.getInt("nodeType") : -1; + } + +} diff --git a/src/com/engine/kq/wfset/attendance/dao/WorkflowBaseDao.java b/src/com/engine/kq/wfset/attendance/dao/WorkflowBaseDao.java new file mode 100644 index 0000000..62e797a --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/dao/WorkflowBaseDao.java @@ -0,0 +1,1742 @@ +package com.engine.kq.wfset.attendance.dao; + +import java.util.ArrayList; +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import weaver.common.StringUtil; +import com.engine.kq.wfset.attendance.framework.BaseConnection; +import com.engine.kq.wfset.attendance.framework.BaseDao; +import com.engine.kq.wfset.attendance.domain.WorkflowBase; +import weaver.conn.RecordSet; + +/** + * WorkflowBaseDao + *

Generated from 长东设计 www.mfstyle.cn

+ * + * @author wcd + * @version 1.0 2015-09-10 + */ +public class WorkflowBaseDao extends BaseConnection implements BaseDao { + + public Comparable insert(WorkflowBase bean) { + return 0; + } + + public void update(WorkflowBase bean) { + if(bean == null) return; + } + + public List find(Map map) { + RecordSet rs = new RecordSet(); + List list = new ArrayList(); + StringBuffer sql = new StringBuffer() + .append(" select t.*") + .append(" from workflow_base t") + .append(" where 1 = 1"); + if(map != null) { + if(map.containsKey("id")){ + sql.append(" and t.id = ").append(StringUtil.vString(map.get("id"))); + } + if(map.containsKey("begin_id")){ + sql.append(" and t.id >= ").append(StringUtil.vString(map.get("begin_id"))); + } + if(map.containsKey("end_id")){ + sql.append(" and t.id < ").append(StringUtil.vString(map.get("end_id"))); + } + if(map.containsKey("sql_id")){ + sql.append(" " + StringUtil.vString(map.get("sql_id"))); + } + if(map.containsKey("workflowtype")){ + sql.append(" and t.workflowtype = ").append(StringUtil.vString(map.get("workflowtype"))); + } + if(map.containsKey("begin_workflowtype")){ + sql.append(" and t.workflowtype >= ").append(StringUtil.vString(map.get("begin_workflowtype"))); + } + if(map.containsKey("end_workflowtype")){ + sql.append(" and t.workflowtype < ").append(StringUtil.vString(map.get("end_workflowtype"))); + } + if(map.containsKey("sql_workflowtype")){ + sql.append(" " + StringUtil.vString(map.get("sql_workflowtype"))); + } + if(map.containsKey("formid")){ + sql.append(" and t.formid = ").append(StringUtil.vString(map.get("formid"))); + } + if(map.containsKey("begin_formid")){ + sql.append(" and t.formid >= ").append(StringUtil.vString(map.get("begin_formid"))); + } + if(map.containsKey("end_formid")){ + sql.append(" and t.formid < ").append(StringUtil.vString(map.get("end_formid"))); + } + if(map.containsKey("sql_formid")){ + sql.append(" " + StringUtil.vString(map.get("sql_formid"))); + } + if(map.containsKey("userid")){ + sql.append(" and t.userid = ").append(StringUtil.vString(map.get("userid"))); + } + if(map.containsKey("begin_userid")){ + sql.append(" and t.userid >= ").append(StringUtil.vString(map.get("begin_userid"))); + } + if(map.containsKey("end_userid")){ + sql.append(" and t.userid < ").append(StringUtil.vString(map.get("end_userid"))); + } + if(map.containsKey("sql_userid")){ + sql.append(" " + StringUtil.vString(map.get("sql_userid"))); + } + if(map.containsKey("iscust")){ + sql.append(" and t.iscust = ").append(StringUtil.vString(map.get("iscust"))); + } + if(map.containsKey("begin_iscust")){ + sql.append(" and t.iscust >= ").append(StringUtil.vString(map.get("begin_iscust"))); + } + if(map.containsKey("end_iscust")){ + sql.append(" and t.iscust < ").append(StringUtil.vString(map.get("end_iscust"))); + } + if(map.containsKey("sql_iscust")){ + sql.append(" " + StringUtil.vString(map.get("sql_iscust"))); + } + if(map.containsKey("helpdocid")){ + sql.append(" and t.helpdocid = ").append(StringUtil.vString(map.get("helpdocid"))); + } + if(map.containsKey("begin_helpdocid")){ + sql.append(" and t.helpdocid >= ").append(StringUtil.vString(map.get("begin_helpdocid"))); + } + if(map.containsKey("end_helpdocid")){ + sql.append(" and t.helpdocid < ").append(StringUtil.vString(map.get("end_helpdocid"))); + } + if(map.containsKey("sql_helpdocid")){ + sql.append(" " + StringUtil.vString(map.get("sql_helpdocid"))); + } + if(map.containsKey("messageType")){ + sql.append(" and t.messageType = ").append(StringUtil.vString(map.get("messageType"))); + } + if(map.containsKey("begin_messageType")){ + sql.append(" and t.messageType >= ").append(StringUtil.vString(map.get("begin_messageType"))); + } + if(map.containsKey("end_messageType")){ + sql.append(" and t.messageType < ").append(StringUtil.vString(map.get("end_messageType"))); + } + if(map.containsKey("sql_messageType")){ + sql.append(" " + StringUtil.vString(map.get("sql_messageType"))); + } + if(map.containsKey("multiSubmit")){ + sql.append(" and t.multiSubmit = ").append(StringUtil.vString(map.get("multiSubmit"))); + } + if(map.containsKey("begin_multiSubmit")){ + sql.append(" and t.multiSubmit >= ").append(StringUtil.vString(map.get("begin_multiSubmit"))); + } + if(map.containsKey("end_multiSubmit")){ + sql.append(" and t.multiSubmit < ").append(StringUtil.vString(map.get("end_multiSubmit"))); + } + if(map.containsKey("sql_multiSubmit")){ + sql.append(" " + StringUtil.vString(map.get("sql_multiSubmit"))); + } + if(map.containsKey("defaultName")){ + sql.append(" and t.defaultName = ").append(StringUtil.vString(map.get("defaultName"))); + } + if(map.containsKey("begin_defaultName")){ + sql.append(" and t.defaultName >= ").append(StringUtil.vString(map.get("begin_defaultName"))); + } + if(map.containsKey("end_defaultName")){ + sql.append(" and t.defaultName < ").append(StringUtil.vString(map.get("end_defaultName"))); + } + if(map.containsKey("sql_defaultName")){ + sql.append(" " + StringUtil.vString(map.get("sql_defaultName"))); + } + if(map.containsKey("subcompanyid")){ + sql.append(" and t.subcompanyid = ").append(StringUtil.vString(map.get("subcompanyid"))); + } + if(map.containsKey("begin_subcompanyid")){ + sql.append(" and t.subcompanyid >= ").append(StringUtil.vString(map.get("begin_subcompanyid"))); + } + if(map.containsKey("end_subcompanyid")){ + sql.append(" and t.subcompanyid < ").append(StringUtil.vString(map.get("end_subcompanyid"))); + } + if(map.containsKey("sql_subcompanyid")){ + sql.append(" " + StringUtil.vString(map.get("sql_subcompanyid"))); + } + if(map.containsKey("mailMessageType")){ + sql.append(" and t.mailMessageType = ").append(StringUtil.vString(map.get("mailMessageType"))); + } + if(map.containsKey("begin_mailMessageType")){ + sql.append(" and t.mailMessageType >= ").append(StringUtil.vString(map.get("begin_mailMessageType"))); + } + if(map.containsKey("end_mailMessageType")){ + sql.append(" and t.mailMessageType < ").append(StringUtil.vString(map.get("end_mailMessageType"))); + } + if(map.containsKey("sql_mailMessageType")){ + sql.append(" " + StringUtil.vString(map.get("sql_mailMessageType"))); + } + if(map.containsKey("docRightByOperator")){ + sql.append(" and t.docRightByOperator = ").append(StringUtil.vString(map.get("docRightByOperator"))); + } + if(map.containsKey("begin_docRightByOperator")){ + sql.append(" and t.docRightByOperator >= ").append(StringUtil.vString(map.get("begin_docRightByOperator"))); + } + if(map.containsKey("end_docRightByOperator")){ + sql.append(" and t.docRightByOperator < ").append(StringUtil.vString(map.get("end_docRightByOperator"))); + } + if(map.containsKey("sql_docRightByOperator")){ + sql.append(" " + StringUtil.vString(map.get("sql_docRightByOperator"))); + } + if(map.containsKey("templateid")){ + sql.append(" and t.templateid = ").append(StringUtil.vString(map.get("templateid"))); + } + if(map.containsKey("begin_templateid")){ + sql.append(" and t.templateid >= ").append(StringUtil.vString(map.get("begin_templateid"))); + } + if(map.containsKey("end_templateid")){ + sql.append(" and t.templateid < ").append(StringUtil.vString(map.get("end_templateid"))); + } + if(map.containsKey("sql_templateid")){ + sql.append(" " + StringUtil.vString(map.get("sql_templateid"))); + } + if(map.containsKey("catelogType")){ + sql.append(" and t.catelogType = ").append(StringUtil.vString(map.get("catelogType"))); + } + if(map.containsKey("begin_catelogType")){ + sql.append(" and t.catelogType >= ").append(StringUtil.vString(map.get("begin_catelogType"))); + } + if(map.containsKey("end_catelogType")){ + sql.append(" and t.catelogType < ").append(StringUtil.vString(map.get("end_catelogType"))); + } + if(map.containsKey("sql_catelogType")){ + sql.append(" " + StringUtil.vString(map.get("sql_catelogType"))); + } + if(map.containsKey("selectedCateLog")){ + sql.append(" and t.selectedCateLog = ").append(StringUtil.vString(map.get("selectedCateLog"))); + } + if(map.containsKey("begin_selectedCateLog")){ + sql.append(" and t.selectedCateLog >= ").append(StringUtil.vString(map.get("begin_selectedCateLog"))); + } + if(map.containsKey("end_selectedCateLog")){ + sql.append(" and t.selectedCateLog < ").append(StringUtil.vString(map.get("end_selectedCateLog"))); + } + if(map.containsKey("sql_selectedCateLog")){ + sql.append(" " + StringUtil.vString(map.get("sql_selectedCateLog"))); + } + if(map.containsKey("docRightByHrmResource")){ + sql.append(" and t.docRightByHrmResource = ").append(StringUtil.vString(map.get("docRightByHrmResource"))); + } + if(map.containsKey("begin_docRightByHrmResource")){ + sql.append(" and t.docRightByHrmResource >= ").append(StringUtil.vString(map.get("begin_docRightByHrmResource"))); + } + if(map.containsKey("end_docRightByHrmResource")){ + sql.append(" and t.docRightByHrmResource < ").append(StringUtil.vString(map.get("end_docRightByHrmResource"))); + } + if(map.containsKey("sql_docRightByHrmResource")){ + sql.append(" " + StringUtil.vString(map.get("sql_docRightByHrmResource"))); + } + if(map.containsKey("titleFieldId")){ + sql.append(" and t.titleFieldId = ").append(StringUtil.vString(map.get("titleFieldId"))); + } + if(map.containsKey("begin_titleFieldId")){ + sql.append(" and t.titleFieldId >= ").append(StringUtil.vString(map.get("begin_titleFieldId"))); + } + if(map.containsKey("end_titleFieldId")){ + sql.append(" and t.titleFieldId < ").append(StringUtil.vString(map.get("end_titleFieldId"))); + } + if(map.containsKey("sql_titleFieldId")){ + sql.append(" " + StringUtil.vString(map.get("sql_titleFieldId"))); + } + if(map.containsKey("keywordFieldId")){ + sql.append(" and t.keywordFieldId = ").append(StringUtil.vString(map.get("keywordFieldId"))); + } + if(map.containsKey("begin_keywordFieldId")){ + sql.append(" and t.keywordFieldId >= ").append(StringUtil.vString(map.get("begin_keywordFieldId"))); + } + if(map.containsKey("end_keywordFieldId")){ + sql.append(" and t.keywordFieldId < ").append(StringUtil.vString(map.get("end_keywordFieldId"))); + } + if(map.containsKey("sql_keywordFieldId")){ + sql.append(" " + StringUtil.vString(map.get("sql_keywordFieldId"))); + } + if(map.containsKey("editor")){ + sql.append(" and t.editor = ").append(StringUtil.vString(map.get("editor"))); + } + if(map.containsKey("begin_editor")){ + sql.append(" and t.editor >= ").append(StringUtil.vString(map.get("begin_editor"))); + } + if(map.containsKey("end_editor")){ + sql.append(" and t.editor < ").append(StringUtil.vString(map.get("end_editor"))); + } + if(map.containsKey("sql_editor")){ + sql.append(" " + StringUtil.vString(map.get("sql_editor"))); + } + if(map.containsKey("wfdocownertype")){ + sql.append(" and t.wfdocownertype = ").append(StringUtil.vString(map.get("wfdocownertype"))); + } + if(map.containsKey("begin_wfdocownertype")){ + sql.append(" and t.wfdocownertype >= ").append(StringUtil.vString(map.get("begin_wfdocownertype"))); + } + if(map.containsKey("end_wfdocownertype")){ + sql.append(" and t.wfdocownertype < ").append(StringUtil.vString(map.get("end_wfdocownertype"))); + } + if(map.containsKey("sql_wfdocownertype")){ + sql.append(" " + StringUtil.vString(map.get("sql_wfdocownertype"))); + } + if(map.containsKey("wfdocownerfieldid")){ + sql.append(" and t.wfdocownerfieldid = ").append(StringUtil.vString(map.get("wfdocownerfieldid"))); + } + if(map.containsKey("begin_wfdocownerfieldid")){ + sql.append(" and t.wfdocownerfieldid >= ").append(StringUtil.vString(map.get("begin_wfdocownerfieldid"))); + } + if(map.containsKey("end_wfdocownerfieldid")){ + sql.append(" and t.wfdocownerfieldid < ").append(StringUtil.vString(map.get("end_wfdocownerfieldid"))); + } + if(map.containsKey("sql_wfdocownerfieldid")){ + sql.append(" " + StringUtil.vString(map.get("sql_wfdocownerfieldid"))); + } + if(map.containsKey("keepsign")){ + sql.append(" and t.keepsign = ").append(StringUtil.vString(map.get("keepsign"))); + } + if(map.containsKey("begin_keepsign")){ + sql.append(" and t.keepsign >= ").append(StringUtil.vString(map.get("begin_keepsign"))); + } + if(map.containsKey("end_keepsign")){ + sql.append(" and t.keepsign < ").append(StringUtil.vString(map.get("end_keepsign"))); + } + if(map.containsKey("sql_keepsign")){ + sql.append(" " + StringUtil.vString(map.get("sql_keepsign"))); + } + if(map.containsKey("secCategoryId")){ + sql.append(" and t.secCategoryId = ").append(StringUtil.vString(map.get("secCategoryId"))); + } + if(map.containsKey("begin_secCategoryId")){ + sql.append(" and t.secCategoryId >= ").append(StringUtil.vString(map.get("begin_secCategoryId"))); + } + if(map.containsKey("end_secCategoryId")){ + sql.append(" and t.secCategoryId < ").append(StringUtil.vString(map.get("end_secCategoryId"))); + } + if(map.containsKey("sql_secCategoryId")){ + sql.append(" " + StringUtil.vString(map.get("sql_secCategoryId"))); + } + if(map.containsKey("issignview")){ + sql.append(" and t.issignview = ").append(StringUtil.vString(map.get("issignview"))); + } + if(map.containsKey("begin_issignview")){ + sql.append(" and t.issignview >= ").append(StringUtil.vString(map.get("begin_issignview"))); + } + if(map.containsKey("end_issignview")){ + sql.append(" and t.issignview < ").append(StringUtil.vString(map.get("end_issignview"))); + } + if(map.containsKey("sql_issignview")){ + sql.append(" " + StringUtil.vString(map.get("sql_issignview"))); + } + if(map.containsKey("forbidAttDownload")){ + sql.append(" and t.forbidAttDownload = ").append(StringUtil.vString(map.get("forbidAttDownload"))); + } + if(map.containsKey("begin_forbidAttDownload")){ + sql.append(" and t.forbidAttDownload >= ").append(StringUtil.vString(map.get("begin_forbidAttDownload"))); + } + if(map.containsKey("end_forbidAttDownload")){ + sql.append(" and t.forbidAttDownload < ").append(StringUtil.vString(map.get("end_forbidAttDownload"))); + } + if(map.containsKey("sql_forbidAttDownload")){ + sql.append(" " + StringUtil.vString(map.get("sql_forbidAttDownload"))); + } + if(map.containsKey("Frequency")){ + sql.append(" and t.Frequency = ").append(StringUtil.vString(map.get("Frequency"))); + } + if(map.containsKey("begin_Frequency")){ + sql.append(" and t.Frequency >= ").append(StringUtil.vString(map.get("begin_Frequency"))); + } + if(map.containsKey("end_Frequency")){ + sql.append(" and t.Frequency < ").append(StringUtil.vString(map.get("end_Frequency"))); + } + if(map.containsKey("sql_Frequency")){ + sql.append(" " + StringUtil.vString(map.get("sql_Frequency"))); + } + if(map.containsKey("isWorkflowDoc")){ + sql.append(" and t.isWorkflowDoc = ").append(StringUtil.vString(map.get("isWorkflowDoc"))); + } + if(map.containsKey("begin_isWorkflowDoc")){ + sql.append(" and t.isWorkflowDoc >= ").append(StringUtil.vString(map.get("begin_isWorkflowDoc"))); + } + if(map.containsKey("end_isWorkflowDoc")){ + sql.append(" and t.isWorkflowDoc < ").append(StringUtil.vString(map.get("end_isWorkflowDoc"))); + } + if(map.containsKey("sql_isWorkflowDoc")){ + sql.append(" " + StringUtil.vString(map.get("sql_isWorkflowDoc"))); + } + if(map.containsKey("officalType")){ + sql.append(" and t.officalType = ").append(StringUtil.vString(map.get("officalType"))); + } + if(map.containsKey("begin_officalType")){ + sql.append(" and t.officalType >= ").append(StringUtil.vString(map.get("begin_officalType"))); + } + if(map.containsKey("end_officalType")){ + sql.append(" and t.officalType < ").append(StringUtil.vString(map.get("end_officalType"))); + } + if(map.containsKey("sql_officalType")){ + sql.append(" " + StringUtil.vString(map.get("sql_officalType"))); + } + if(map.containsKey("version")){ + sql.append(" and t.version = ").append(StringUtil.vString(map.get("version"))); + } + if(map.containsKey("begin_version")){ + sql.append(" and t.version >= ").append(StringUtil.vString(map.get("begin_version"))); + } + if(map.containsKey("end_version")){ + sql.append(" and t.version < ").append(StringUtil.vString(map.get("end_version"))); + } + if(map.containsKey("sql_version")){ + sql.append(" " + StringUtil.vString(map.get("sql_version"))); + } + if(map.containsKey("activeVersionID")){ + sql.append(" and t.activeVersionID = ").append(StringUtil.vString(map.get("activeVersionID"))); + } + if(map.containsKey("begin_activeVersionID")){ + sql.append(" and t.activeVersionID >= ").append(StringUtil.vString(map.get("begin_activeVersionID"))); + } + if(map.containsKey("end_activeVersionID")){ + sql.append(" and t.activeVersionID < ").append(StringUtil.vString(map.get("end_activeVersionID"))); + } + if(map.containsKey("sql_activeVersionID")){ + sql.append(" " + StringUtil.vString(map.get("sql_activeVersionID"))); + } + if(map.containsKey("VersionCreater")){ + sql.append(" and t.VersionCreater = ").append(StringUtil.vString(map.get("VersionCreater"))); + } + if(map.containsKey("begin_VersionCreater")){ + sql.append(" and t.VersionCreater >= ").append(StringUtil.vString(map.get("begin_VersionCreater"))); + } + if(map.containsKey("end_VersionCreater")){ + sql.append(" and t.VersionCreater < ").append(StringUtil.vString(map.get("end_VersionCreater"))); + } + if(map.containsKey("sql_VersionCreater")){ + sql.append(" " + StringUtil.vString(map.get("sql_VersionCreater"))); + } + if(map.containsKey("dsporder")){ + sql.append(" and t.dsporder = ").append(StringUtil.vString(map.get("dsporder"))); + } + if(map.containsKey("begin_dsporder")){ + sql.append(" and t.dsporder >= ").append(StringUtil.vString(map.get("begin_dsporder"))); + } + if(map.containsKey("end_dsporder")){ + sql.append(" and t.dsporder < ").append(StringUtil.vString(map.get("end_dsporder"))); + } + if(map.containsKey("sql_dsporder")){ + sql.append(" " + StringUtil.vString(map.get("sql_dsporder"))); + } + if(map.containsKey("chatsType")){ + sql.append(" and t.chatsType = ").append(StringUtil.vString(map.get("chatsType"))); + } + if(map.containsKey("begin_chatsType")){ + sql.append(" and t.chatsType >= ").append(StringUtil.vString(map.get("begin_chatsType"))); + } + if(map.containsKey("end_chatsType")){ + sql.append(" and t.chatsType < ").append(StringUtil.vString(map.get("end_chatsType"))); + } + if(map.containsKey("sql_chatsType")){ + sql.append(" " + StringUtil.vString(map.get("sql_chatsType"))); + } + if(map.containsKey("chatsAlertType")){ + sql.append(" and t.chatsAlertType = ").append(StringUtil.vString(map.get("chatsAlertType"))); + } + if(map.containsKey("begin_chatsAlertType")){ + sql.append(" and t.chatsAlertType >= ").append(StringUtil.vString(map.get("begin_chatsAlertType"))); + } + if(map.containsKey("end_chatsAlertType")){ + sql.append(" and t.chatsAlertType < ").append(StringUtil.vString(map.get("end_chatsAlertType"))); + } + if(map.containsKey("sql_chatsAlertType")){ + sql.append(" " + StringUtil.vString(map.get("sql_chatsAlertType"))); + } + if(map.containsKey("notRemindifArchived")){ + sql.append(" and t.notRemindifArchived = ").append(StringUtil.vString(map.get("notRemindifArchived"))); + } + if(map.containsKey("begin_notRemindifArchived")){ + sql.append(" and t.notRemindifArchived >= ").append(StringUtil.vString(map.get("begin_notRemindifArchived"))); + } + if(map.containsKey("end_notRemindifArchived")){ + sql.append(" and t.notRemindifArchived < ").append(StringUtil.vString(map.get("end_notRemindifArchived"))); + } + if(map.containsKey("sql_notRemindifArchived")){ + sql.append(" " + StringUtil.vString(map.get("sql_notRemindifArchived"))); + } + if(map.containsKey("isupdatetitle")){ + sql.append(" and t.isupdatetitle = ").append(StringUtil.vString(map.get("isupdatetitle"))); + } + if(map.containsKey("begin_isupdatetitle")){ + sql.append(" and t.isupdatetitle >= ").append(StringUtil.vString(map.get("begin_isupdatetitle"))); + } + if(map.containsKey("end_isupdatetitle")){ + sql.append(" and t.isupdatetitle < ").append(StringUtil.vString(map.get("end_isupdatetitle"))); + } + if(map.containsKey("sql_isupdatetitle")){ + sql.append(" " + StringUtil.vString(map.get("sql_isupdatetitle"))); + } + if(map.containsKey("workflowname")){ + sql.append(" and t.workflowname = '").append(StringUtil.vString(map.get("workflowname"))).append("'"); + } + if(map.containsKey("like_workflowname")){ + sql.append(" and t.workflowname like '%").append(StringUtil.vString(map.get("like_workflowname"))).append("%'"); + } + if(map.containsKey("sql_workflowname")){ + sql.append(" " + StringUtil.vString(map.get("sql_workflowname"))); + } + if(map.containsKey("workflowdesc")){ + sql.append(" and t.workflowdesc = '").append(StringUtil.vString(map.get("workflowdesc"))).append("'"); + } + if(map.containsKey("like_workflowdesc")){ + sql.append(" and t.workflowdesc like '%").append(StringUtil.vString(map.get("like_workflowdesc"))).append("%'"); + } + if(map.containsKey("sql_workflowdesc")){ + sql.append(" " + StringUtil.vString(map.get("sql_workflowdesc"))); + } + if(map.containsKey("securelevel")){ + sql.append(" and t.securelevel = '").append(StringUtil.vString(map.get("securelevel"))).append("'"); + } + if(map.containsKey("like_securelevel")){ + sql.append(" and t.securelevel like '%").append(StringUtil.vString(map.get("like_securelevel"))).append("%'"); + } + if(map.containsKey("sql_securelevel")){ + sql.append(" " + StringUtil.vString(map.get("sql_securelevel"))); + } + if(map.containsKey("isbill")){ + sql.append(" and t.isbill = '").append(StringUtil.vString(map.get("isbill"))).append("'"); + } + if(map.containsKey("like_isbill")){ + sql.append(" and t.isbill like '%").append(StringUtil.vString(map.get("like_isbill"))).append("%'"); + } + if(map.containsKey("sql_isbill")){ + sql.append(" " + StringUtil.vString(map.get("sql_isbill"))); + } + if(map.containsKey("isvalid")){ + sql.append(" and t.isvalid = '").append(StringUtil.vString(map.get("isvalid"))).append("'"); + } + if(map.containsKey("like_isvalid")){ + sql.append(" and t.isvalid like '%").append(StringUtil.vString(map.get("like_isvalid"))).append("%'"); + } + if(map.containsKey("sql_isvalid")){ + sql.append(" " + StringUtil.vString(map.get("sql_isvalid"))); + } + if(map.containsKey("needmark")){ + sql.append(" and t.needmark = '").append(StringUtil.vString(map.get("needmark"))).append("'"); + } + if(map.containsKey("like_needmark")){ + sql.append(" and t.needmark like '%").append(StringUtil.vString(map.get("like_needmark"))).append("%'"); + } + if(map.containsKey("sql_needmark")){ + sql.append(" " + StringUtil.vString(map.get("sql_needmark"))); + } + if(map.containsKey("docPath")){ + sql.append(" and t.docPath = '").append(StringUtil.vString(map.get("docPath"))).append("'"); + } + if(map.containsKey("like_docPath")){ + sql.append(" and t.docPath like '%").append(StringUtil.vString(map.get("like_docPath"))).append("%'"); + } + if(map.containsKey("sql_docPath")){ + sql.append(" " + StringUtil.vString(map.get("sql_docPath"))); + } + if(map.containsKey("docCategory")){ + sql.append(" and t.docCategory = '").append(StringUtil.vString(map.get("docCategory"))).append("'"); + } + if(map.containsKey("like_docCategory")){ + sql.append(" and t.docCategory like '%").append(StringUtil.vString(map.get("like_docCategory"))).append("%'"); + } + if(map.containsKey("sql_docCategory")){ + sql.append(" " + StringUtil.vString(map.get("sql_docCategory"))); + } + if(map.containsKey("istemplate")){ + sql.append(" and t.istemplate = '").append(StringUtil.vString(map.get("istemplate"))).append("'"); + } + if(map.containsKey("like_istemplate")){ + sql.append(" and t.istemplate like '%").append(StringUtil.vString(map.get("like_istemplate"))).append("%'"); + } + if(map.containsKey("sql_istemplate")){ + sql.append(" " + StringUtil.vString(map.get("sql_istemplate"))); + } + if(map.containsKey("needAffirmance")){ + sql.append(" and t.needAffirmance = '").append(StringUtil.vString(map.get("needAffirmance"))).append("'"); + } + if(map.containsKey("like_needAffirmance")){ + sql.append(" and t.needAffirmance like '%").append(StringUtil.vString(map.get("like_needAffirmance"))).append("%'"); + } + if(map.containsKey("sql_needAffirmance")){ + sql.append(" " + StringUtil.vString(map.get("sql_needAffirmance"))); + } + if(map.containsKey("isremarks")){ + sql.append(" and t.isremarks = '").append(StringUtil.vString(map.get("isremarks"))).append("'"); + } + if(map.containsKey("like_isremarks")){ + sql.append(" and t.isremarks like '%").append(StringUtil.vString(map.get("like_isremarks"))).append("%'"); + } + if(map.containsKey("sql_isremarks")){ + sql.append(" " + StringUtil.vString(map.get("sql_isremarks"))); + } + if(map.containsKey("isannexUpload")){ + sql.append(" and t.isannexUpload = '").append(StringUtil.vString(map.get("isannexUpload"))).append("'"); + } + if(map.containsKey("like_isannexUpload")){ + sql.append(" and t.isannexUpload like '%").append(StringUtil.vString(map.get("like_isannexUpload"))).append("%'"); + } + if(map.containsKey("sql_isannexUpload")){ + sql.append(" " + StringUtil.vString(map.get("sql_isannexUpload"))); + } + if(map.containsKey("annexdoccategory")){ + sql.append(" and t.annexdoccategory = '").append(StringUtil.vString(map.get("annexdoccategory"))).append("'"); + } + if(map.containsKey("like_annexdoccategory")){ + sql.append(" and t.annexdoccategory like '%").append(StringUtil.vString(map.get("like_annexdoccategory"))).append("%'"); + } + if(map.containsKey("sql_annexdoccategory")){ + sql.append(" " + StringUtil.vString(map.get("sql_annexdoccategory"))); + } + if(map.containsKey("isShowOnReportInput")){ + sql.append(" and t.isShowOnReportInput = '").append(StringUtil.vString(map.get("isShowOnReportInput"))).append("'"); + } + if(map.containsKey("like_isShowOnReportInput")){ + sql.append(" and t.isShowOnReportInput like '%").append(StringUtil.vString(map.get("like_isShowOnReportInput"))).append("%'"); + } + if(map.containsKey("sql_isShowOnReportInput")){ + sql.append(" " + StringUtil.vString(map.get("sql_isShowOnReportInput"))); + } + if(map.containsKey("isshowchart")){ + sql.append(" and t.isshowchart = '").append(StringUtil.vString(map.get("isshowchart"))).append("'"); + } + if(map.containsKey("like_isshowchart")){ + sql.append(" and t.isshowchart like '%").append(StringUtil.vString(map.get("like_isshowchart"))).append("%'"); + } + if(map.containsKey("sql_isshowchart")){ + sql.append(" " + StringUtil.vString(map.get("sql_isshowchart"))); + } + if(map.containsKey("orderbytype")){ + sql.append(" and t.orderbytype = '").append(StringUtil.vString(map.get("orderbytype"))).append("'"); + } + if(map.containsKey("like_orderbytype")){ + sql.append(" and t.orderbytype like '%").append(StringUtil.vString(map.get("like_orderbytype"))).append("%'"); + } + if(map.containsKey("sql_orderbytype")){ + sql.append(" " + StringUtil.vString(map.get("sql_orderbytype"))); + } + if(map.containsKey("isTriDiffWorkflow")){ + sql.append(" and t.isTriDiffWorkflow = '").append(StringUtil.vString(map.get("isTriDiffWorkflow"))).append("'"); + } + if(map.containsKey("like_isTriDiffWorkflow")){ + sql.append(" and t.isTriDiffWorkflow like '%").append(StringUtil.vString(map.get("like_isTriDiffWorkflow"))).append("%'"); + } + if(map.containsKey("sql_isTriDiffWorkflow")){ + sql.append(" " + StringUtil.vString(map.get("sql_isTriDiffWorkflow"))); + } + if(map.containsKey("isModifyLog")){ + sql.append(" and t.isModifyLog = '").append(StringUtil.vString(map.get("isModifyLog"))).append("'"); + } + if(map.containsKey("like_isModifyLog")){ + sql.append(" and t.isModifyLog like '%").append(StringUtil.vString(map.get("like_isModifyLog"))).append("%'"); + } + if(map.containsKey("sql_isModifyLog")){ + sql.append(" " + StringUtil.vString(map.get("sql_isModifyLog"))); + } + if(map.containsKey("ifVersion")){ + sql.append(" and t.ifVersion = '").append(StringUtil.vString(map.get("ifVersion"))).append("'"); + } + if(map.containsKey("like_ifVersion")){ + sql.append(" and t.ifVersion like '%").append(StringUtil.vString(map.get("like_ifVersion"))).append("%'"); + } + if(map.containsKey("sql_ifVersion")){ + sql.append(" " + StringUtil.vString(map.get("sql_ifVersion"))); + } + if(map.containsKey("wfdocpath")){ + sql.append(" and t.wfdocpath = '").append(StringUtil.vString(map.get("wfdocpath"))).append("'"); + } + if(map.containsKey("like_wfdocpath")){ + sql.append(" and t.wfdocpath like '%").append(StringUtil.vString(map.get("like_wfdocpath"))).append("%'"); + } + if(map.containsKey("sql_wfdocpath")){ + sql.append(" " + StringUtil.vString(map.get("sql_wfdocpath"))); + } + if(map.containsKey("wfdocowner")){ + sql.append(" and t.wfdocowner = '").append(StringUtil.vString(map.get("wfdocowner"))).append("'"); + } + if(map.containsKey("like_wfdocowner")){ + sql.append(" and t.wfdocowner like '%").append(StringUtil.vString(map.get("like_wfdocowner"))).append("%'"); + } + if(map.containsKey("sql_wfdocowner")){ + sql.append(" " + StringUtil.vString(map.get("sql_wfdocowner"))); + } + if(map.containsKey("isEdit")){ + sql.append(" and t.isEdit = '").append(StringUtil.vString(map.get("isEdit"))).append("'"); + } + if(map.containsKey("like_isEdit")){ + sql.append(" and t.isEdit like '%").append(StringUtil.vString(map.get("like_isEdit"))).append("%'"); + } + if(map.containsKey("sql_isEdit")){ + sql.append(" " + StringUtil.vString(map.get("sql_isEdit"))); + } + if(map.containsKey("editdate")){ + sql.append(" and t.editdate = '").append(StringUtil.vString(map.get("editdate"))).append("'"); + } + if(map.containsKey("like_editdate")){ + sql.append(" and t.editdate like '%").append(StringUtil.vString(map.get("like_editdate"))).append("%'"); + } + if(map.containsKey("sql_editdate")){ + sql.append(" " + StringUtil.vString(map.get("sql_editdate"))); + } + if(map.containsKey("edittime")){ + sql.append(" and t.edittime = '").append(StringUtil.vString(map.get("edittime"))).append("'"); + } + if(map.containsKey("like_edittime")){ + sql.append(" and t.edittime like '%").append(StringUtil.vString(map.get("like_edittime"))).append("%'"); + } + if(map.containsKey("sql_edittime")){ + sql.append(" " + StringUtil.vString(map.get("sql_edittime"))); + } + if(map.containsKey("ShowDelButtonByReject")){ + sql.append(" and t.ShowDelButtonByReject = '").append(StringUtil.vString(map.get("ShowDelButtonByReject"))).append("'"); + } + if(map.containsKey("like_ShowDelButtonByReject")){ + sql.append(" and t.ShowDelButtonByReject like '%").append(StringUtil.vString(map.get("like_ShowDelButtonByReject"))).append("%'"); + } + if(map.containsKey("sql_ShowDelButtonByReject")){ + sql.append(" " + StringUtil.vString(map.get("sql_ShowDelButtonByReject"))); + } + if(map.containsKey("showUploadTab")){ + sql.append(" and t.showUploadTab = '").append(StringUtil.vString(map.get("showUploadTab"))).append("'"); + } + if(map.containsKey("like_showUploadTab")){ + sql.append(" and t.showUploadTab like '%").append(StringUtil.vString(map.get("like_showUploadTab"))).append("%'"); + } + if(map.containsKey("sql_showUploadTab")){ + sql.append(" " + StringUtil.vString(map.get("sql_showUploadTab"))); + } + if(map.containsKey("isSignDoc")){ + sql.append(" and t.isSignDoc = '").append(StringUtil.vString(map.get("isSignDoc"))).append("'"); + } + if(map.containsKey("like_isSignDoc")){ + sql.append(" and t.isSignDoc like '%").append(StringUtil.vString(map.get("like_isSignDoc"))).append("%'"); + } + if(map.containsKey("sql_isSignDoc")){ + sql.append(" " + StringUtil.vString(map.get("sql_isSignDoc"))); + } + if(map.containsKey("showDocTab")){ + sql.append(" and t.showDocTab = '").append(StringUtil.vString(map.get("showDocTab"))).append("'"); + } + if(map.containsKey("like_showDocTab")){ + sql.append(" and t.showDocTab like '%").append(StringUtil.vString(map.get("like_showDocTab"))).append("%'"); + } + if(map.containsKey("sql_showDocTab")){ + sql.append(" " + StringUtil.vString(map.get("sql_showDocTab"))); + } + if(map.containsKey("isSignWorkflow")){ + sql.append(" and t.isSignWorkflow = '").append(StringUtil.vString(map.get("isSignWorkflow"))).append("'"); + } + if(map.containsKey("like_isSignWorkflow")){ + sql.append(" and t.isSignWorkflow like '%").append(StringUtil.vString(map.get("like_isSignWorkflow"))).append("%'"); + } + if(map.containsKey("sql_isSignWorkflow")){ + sql.append(" " + StringUtil.vString(map.get("sql_isSignWorkflow"))); + } + if(map.containsKey("showWorkflowTab")){ + sql.append(" and t.showWorkflowTab = '").append(StringUtil.vString(map.get("showWorkflowTab"))).append("'"); + } + if(map.containsKey("like_showWorkflowTab")){ + sql.append(" and t.showWorkflowTab like '%").append(StringUtil.vString(map.get("like_showWorkflowTab"))).append("%'"); + } + if(map.containsKey("sql_showWorkflowTab")){ + sql.append(" " + StringUtil.vString(map.get("sql_showWorkflowTab"))); + } + if(map.containsKey("candelacc")){ + sql.append(" and t.candelacc = '").append(StringUtil.vString(map.get("candelacc"))).append("'"); + } + if(map.containsKey("like_candelacc")){ + sql.append(" and t.candelacc like '%").append(StringUtil.vString(map.get("like_candelacc"))).append("%'"); + } + if(map.containsKey("sql_candelacc")){ + sql.append(" " + StringUtil.vString(map.get("sql_candelacc"))); + } + if(map.containsKey("isforwardrights")){ + sql.append(" and t.isforwardrights = '").append(StringUtil.vString(map.get("isforwardrights"))).append("'"); + } + if(map.containsKey("like_isforwardrights")){ + sql.append(" and t.isforwardrights like '%").append(StringUtil.vString(map.get("like_isforwardrights"))).append("%'"); + } + if(map.containsKey("sql_isforwardrights")){ + sql.append(" " + StringUtil.vString(map.get("sql_isforwardrights"))); + } + if(map.containsKey("isimportwf")){ + sql.append(" and t.isimportwf = '").append(StringUtil.vString(map.get("isimportwf"))).append("'"); + } + if(map.containsKey("like_isimportwf")){ + sql.append(" and t.isimportwf like '%").append(StringUtil.vString(map.get("like_isimportwf"))).append("%'"); + } + if(map.containsKey("sql_isimportwf")){ + sql.append(" " + StringUtil.vString(map.get("sql_isimportwf"))); + } + if(map.containsKey("isrejectremind")){ + sql.append(" and t.isrejectremind = '").append(StringUtil.vString(map.get("isrejectremind"))).append("'"); + } + if(map.containsKey("like_isrejectremind")){ + sql.append(" and t.isrejectremind like '%").append(StringUtil.vString(map.get("like_isrejectremind"))).append("%'"); + } + if(map.containsKey("sql_isrejectremind")){ + sql.append(" " + StringUtil.vString(map.get("sql_isrejectremind"))); + } + if(map.containsKey("ischangrejectnode")){ + sql.append(" and t.ischangrejectnode = '").append(StringUtil.vString(map.get("ischangrejectnode"))).append("'"); + } + if(map.containsKey("like_ischangrejectnode")){ + sql.append(" and t.ischangrejectnode like '%").append(StringUtil.vString(map.get("like_ischangrejectnode"))).append("%'"); + } + if(map.containsKey("sql_ischangrejectnode")){ + sql.append(" " + StringUtil.vString(map.get("sql_ischangrejectnode"))); + } + if(map.containsKey("newdocpath")){ + sql.append(" and t.newdocpath = '").append(StringUtil.vString(map.get("newdocpath"))).append("'"); + } + if(map.containsKey("like_newdocpath")){ + sql.append(" and t.newdocpath like '%").append(StringUtil.vString(map.get("like_newdocpath"))).append("%'"); + } + if(map.containsKey("sql_newdocpath")){ + sql.append(" " + StringUtil.vString(map.get("sql_newdocpath"))); + } + if(map.containsKey("custompage")){ + sql.append(" and t.custompage = '").append(StringUtil.vString(map.get("custompage"))).append("'"); + } + if(map.containsKey("like_custompage")){ + sql.append(" and t.custompage like '%").append(StringUtil.vString(map.get("like_custompage"))).append("%'"); + } + if(map.containsKey("sql_custompage")){ + sql.append(" " + StringUtil.vString(map.get("sql_custompage"))); + } + if(map.containsKey("IsSelectrejectNode")){ + sql.append(" and t.IsSelectrejectNode = '").append(StringUtil.vString(map.get("IsSelectrejectNode"))).append("'"); + } + if(map.containsKey("like_IsSelectrejectNode")){ + sql.append(" and t.IsSelectrejectNode like '%").append(StringUtil.vString(map.get("like_IsSelectrejectNode"))).append("%'"); + } + if(map.containsKey("sql_IsSelectrejectNode")){ + sql.append(" " + StringUtil.vString(map.get("sql_IsSelectrejectNode"))); + } + if(map.containsKey("isImportDetail")){ + sql.append(" and t.isImportDetail = '").append(StringUtil.vString(map.get("isImportDetail"))).append("'"); + } + if(map.containsKey("like_isImportDetail")){ + sql.append(" and t.isImportDetail like '%").append(StringUtil.vString(map.get("like_isImportDetail"))).append("%'"); + } + if(map.containsKey("sql_isImportDetail")){ + sql.append(" " + StringUtil.vString(map.get("sql_isImportDetail"))); + } + if(map.containsKey("specialApproval")){ + sql.append(" and t.specialApproval = '").append(StringUtil.vString(map.get("specialApproval"))).append("'"); + } + if(map.containsKey("like_specialApproval")){ + sql.append(" and t.specialApproval like '%").append(StringUtil.vString(map.get("like_specialApproval"))).append("%'"); + } + if(map.containsKey("sql_specialApproval")){ + sql.append(" " + StringUtil.vString(map.get("sql_specialApproval"))); + } + if(map.containsKey("Cycle")){ + sql.append(" and t.Cycle = '").append(StringUtil.vString(map.get("Cycle"))).append("'"); + } + if(map.containsKey("like_Cycle")){ + sql.append(" and t.Cycle like '%").append(StringUtil.vString(map.get("like_Cycle"))).append("%'"); + } + if(map.containsKey("sql_Cycle")){ + sql.append(" " + StringUtil.vString(map.get("sql_Cycle"))); + } + if(map.containsKey("nosynfields")){ + sql.append(" and t.nosynfields = '").append(StringUtil.vString(map.get("nosynfields"))).append("'"); + } + if(map.containsKey("like_nosynfields")){ + sql.append(" and t.nosynfields like '%").append(StringUtil.vString(map.get("like_nosynfields"))).append("%'"); + } + if(map.containsKey("sql_nosynfields")){ + sql.append(" " + StringUtil.vString(map.get("sql_nosynfields"))); + } + if(map.containsKey("isneeddelacc")){ + sql.append(" and t.isneeddelacc = '").append(StringUtil.vString(map.get("isneeddelacc"))).append("'"); + } + if(map.containsKey("like_isneeddelacc")){ + sql.append(" and t.isneeddelacc like '%").append(StringUtil.vString(map.get("like_isneeddelacc"))).append("%'"); + } + if(map.containsKey("sql_isneeddelacc")){ + sql.append(" " + StringUtil.vString(map.get("sql_isneeddelacc"))); + } + if(map.containsKey("SAPSource")){ + sql.append(" and t.SAPSource = '").append(StringUtil.vString(map.get("SAPSource"))).append("'"); + } + if(map.containsKey("like_SAPSource")){ + sql.append(" and t.SAPSource like '%").append(StringUtil.vString(map.get("like_SAPSource"))).append("%'"); + } + if(map.containsKey("sql_SAPSource")){ + sql.append(" " + StringUtil.vString(map.get("sql_SAPSource"))); + } + if(map.containsKey("isfnacontrol")){ + sql.append(" and t.isfnacontrol = '").append(StringUtil.vString(map.get("isfnacontrol"))).append("'"); + } + if(map.containsKey("like_isfnacontrol")){ + sql.append(" and t.isfnacontrol like '%").append(StringUtil.vString(map.get("like_isfnacontrol"))).append("%'"); + } + if(map.containsKey("sql_isfnacontrol")){ + sql.append(" " + StringUtil.vString(map.get("sql_isfnacontrol"))); + } + if(map.containsKey("fnanodeid")){ + sql.append(" and t.fnanodeid = '").append(StringUtil.vString(map.get("fnanodeid"))).append("'"); + } + if(map.containsKey("like_fnanodeid")){ + sql.append(" and t.fnanodeid like '%").append(StringUtil.vString(map.get("like_fnanodeid"))).append("%'"); + } + if(map.containsKey("sql_fnanodeid")){ + sql.append(" " + StringUtil.vString(map.get("sql_fnanodeid"))); + } + if(map.containsKey("fnadepartmentid")){ + sql.append(" and t.fnadepartmentid = '").append(StringUtil.vString(map.get("fnadepartmentid"))).append("'"); + } + if(map.containsKey("like_fnadepartmentid")){ + sql.append(" and t.fnadepartmentid like '%").append(StringUtil.vString(map.get("like_fnadepartmentid"))).append("%'"); + } + if(map.containsKey("sql_fnadepartmentid")){ + sql.append(" " + StringUtil.vString(map.get("sql_fnadepartmentid"))); + } + if(map.containsKey("smsAlertsType")){ + sql.append(" and t.smsAlertsType = '").append(StringUtil.vString(map.get("smsAlertsType"))).append("'"); + } + if(map.containsKey("like_smsAlertsType")){ + sql.append(" and t.smsAlertsType like '%").append(StringUtil.vString(map.get("like_smsAlertsType"))).append("%'"); + } + if(map.containsKey("sql_smsAlertsType")){ + sql.append(" " + StringUtil.vString(map.get("sql_smsAlertsType"))); + } + if(map.containsKey("isSaveCheckForm")){ + sql.append(" and t.isSaveCheckForm = '").append(StringUtil.vString(map.get("isSaveCheckForm"))).append("'"); + } + if(map.containsKey("like_isSaveCheckForm")){ + sql.append(" and t.isSaveCheckForm like '%").append(StringUtil.vString(map.get("like_isSaveCheckForm"))).append("%'"); + } + if(map.containsKey("sql_isSaveCheckForm")){ + sql.append(" " + StringUtil.vString(map.get("sql_isSaveCheckForm"))); + } + if(map.containsKey("archiveNoMsgAlert")){ + sql.append(" and t.archiveNoMsgAlert = '").append(StringUtil.vString(map.get("archiveNoMsgAlert"))).append("'"); + } + if(map.containsKey("like_archiveNoMsgAlert")){ + sql.append(" and t.archiveNoMsgAlert like '%").append(StringUtil.vString(map.get("like_archiveNoMsgAlert"))).append("%'"); + } + if(map.containsKey("sql_archiveNoMsgAlert")){ + sql.append(" " + StringUtil.vString(map.get("sql_archiveNoMsgAlert"))); + } + if(map.containsKey("archiveNoMailAlert")){ + sql.append(" and t.archiveNoMailAlert = '").append(StringUtil.vString(map.get("archiveNoMailAlert"))).append("'"); + } + if(map.containsKey("like_archiveNoMailAlert")){ + sql.append(" and t.archiveNoMailAlert like '%").append(StringUtil.vString(map.get("like_archiveNoMailAlert"))).append("%'"); + } + if(map.containsKey("sql_archiveNoMailAlert")){ + sql.append(" " + StringUtil.vString(map.get("sql_archiveNoMailAlert"))); + } + if(map.containsKey("isfnabudgetwf")){ + sql.append(" and t.isfnabudgetwf = '").append(StringUtil.vString(map.get("isfnabudgetwf"))).append("'"); + } + if(map.containsKey("like_isfnabudgetwf")){ + sql.append(" and t.isfnabudgetwf like '%").append(StringUtil.vString(map.get("like_isfnabudgetwf"))).append("%'"); + } + if(map.containsKey("sql_isfnabudgetwf")){ + sql.append(" " + StringUtil.vString(map.get("sql_isfnabudgetwf"))); + } + if(map.containsKey("forwardReceiveDef")){ + sql.append(" and t.forwardReceiveDef = '").append(StringUtil.vString(map.get("forwardReceiveDef"))).append("'"); + } + if(map.containsKey("like_forwardReceiveDef")){ + sql.append(" and t.forwardReceiveDef like '%").append(StringUtil.vString(map.get("like_forwardReceiveDef"))).append("%'"); + } + if(map.containsKey("sql_forwardReceiveDef")){ + sql.append(" " + StringUtil.vString(map.get("sql_forwardReceiveDef"))); + } + if(map.containsKey("versionDescription")){ + sql.append(" and t.versionDescription = '").append(StringUtil.vString(map.get("versionDescription"))).append("'"); + } + if(map.containsKey("like_versionDescription")){ + sql.append(" and t.versionDescription like '%").append(StringUtil.vString(map.get("like_versionDescription"))).append("%'"); + } + if(map.containsKey("sql_versionDescription")){ + sql.append(" " + StringUtil.vString(map.get("sql_versionDescription"))); + } + if(map.containsKey("fieldNotImport")){ + sql.append(" and t.fieldNotImport = '").append(StringUtil.vString(map.get("fieldNotImport"))).append("'"); + } + if(map.containsKey("like_fieldNotImport")){ + sql.append(" and t.fieldNotImport like '%").append(StringUtil.vString(map.get("like_fieldNotImport"))).append("%'"); + } + if(map.containsKey("sql_fieldNotImport")){ + sql.append(" " + StringUtil.vString(map.get("sql_fieldNotImport"))); + } + if(map.containsKey("isfree")){ + sql.append(" and t.isfree = '").append(StringUtil.vString(map.get("isfree"))).append("'"); + } + if(map.containsKey("like_isfree")){ + sql.append(" and t.isfree like '%").append(StringUtil.vString(map.get("like_isfree"))).append("%'"); + } + if(map.containsKey("sql_isfree")){ + sql.append(" " + StringUtil.vString(map.get("sql_isfree"))); + } + if(map.containsKey("ecologyPinyinSearch")){ + sql.append(" and t.ecology_pinyin_search = '").append(StringUtil.vString(map.get("ecologyPinyinSearch"))).append("'"); + } + if(map.containsKey("like_ecologyPinyinSearch")){ + sql.append(" and t.ecology_pinyin_search like '%").append(StringUtil.vString(map.get("like_ecologyPinyinSearch"))).append("%'"); + } + if(map.containsKey("sql_ecologyPinyinSearch")){ + sql.append(" " + StringUtil.vString(map.get("sql_ecologyPinyinSearch"))); + } + if(map.containsKey("custompage4Emoble")){ + sql.append(" and t.custompage4Emoble = '").append(StringUtil.vString(map.get("custompage4Emoble"))).append("'"); + } + if(map.containsKey("like_custompage4Emoble")){ + sql.append(" and t.custompage4Emoble like '%").append(StringUtil.vString(map.get("like_custompage4Emoble"))).append("%'"); + } + if(map.containsKey("sql_custompage4Emoble")){ + sql.append(" " + StringUtil.vString(map.get("sql_custompage4Emoble"))); + } + if(map.containsKey("isshared")){ + sql.append(" and t.isshared = '").append(StringUtil.vString(map.get("isshared"))).append("'"); + } + if(map.containsKey("like_isshared")){ + sql.append(" and t.isshared like '%").append(StringUtil.vString(map.get("like_isshared"))).append("%'"); + } + if(map.containsKey("sql_isshared")){ + sql.append(" " + StringUtil.vString(map.get("sql_isshared"))); + } + if(map.containsKey("isoverrb")){ + sql.append(" and t.isoverrb = '").append(StringUtil.vString(map.get("isoverrb"))).append("'"); + } + if(map.containsKey("like_isoverrb")){ + sql.append(" and t.isoverrb like '%").append(StringUtil.vString(map.get("like_isoverrb"))).append("%'"); + } + if(map.containsKey("sql_isoverrb")){ + sql.append(" " + StringUtil.vString(map.get("sql_isoverrb"))); + } + if(map.containsKey("isoveriv")){ + sql.append(" and t.isoveriv = '").append(StringUtil.vString(map.get("isoveriv"))).append("'"); + } + if(map.containsKey("like_isoveriv")){ + sql.append(" and t.isoveriv like '%").append(StringUtil.vString(map.get("like_isoveriv"))).append("%'"); + } + if(map.containsKey("sql_isoveriv")){ + sql.append(" " + StringUtil.vString(map.get("sql_isoveriv"))); + } + if(map.containsKey("mfsql")){ + sql.append(" " + StringUtil.vString(map.get("mfsql"))); + } + if(map.containsKey("sqlorderby")){ + sql.append(" order by " + StringUtil.vString(map.get("sqlorderby"))); + }else{ + sql.append(" order by t.id ").append(StringUtil.vString(map.get("sqlsortway")).length() > 0 ? StringUtil.vString(map.get("sqlsortway")) : "desc"); + } + } + rs.executeSql(sql.toString()); + WorkflowBase bean = null; + while(rs.next()){ + bean = new WorkflowBase(); + bean.setId(StringUtil.parseToInt(rs.getString("id"))); + bean.setWorkflowname(StringUtil.vString(rs.getString("workflowname"))); + bean.setWorkflowdesc(StringUtil.vString(rs.getString("workflowdesc"))); + bean.setWorkflowtype(StringUtil.parseToInt(rs.getString("workflowtype"))); + bean.setSecurelevel(StringUtil.vString(rs.getString("securelevel"))); + bean.setFormid(StringUtil.parseToInt(rs.getString("formid"))); + bean.setUserid(StringUtil.parseToInt(rs.getString("userid"))); + bean.setIsbill(StringUtil.vString(rs.getString("isbill"))); + bean.setIscust(StringUtil.parseToInt(rs.getString("iscust"))); + bean.setHelpdocid(StringUtil.parseToInt(rs.getString("helpdocid"))); + bean.setIsvalid(StringUtil.vString(rs.getString("isvalid"))); + bean.setNeedmark(StringUtil.vString(rs.getString("needmark"))); + bean.setMessagetype(StringUtil.parseToInt(rs.getString("messageType"))); + bean.setMultisubmit(StringUtil.parseToInt(rs.getString("multiSubmit"))); + bean.setDefaultname(StringUtil.parseToInt(rs.getString("defaultName"))); + bean.setDocpath(StringUtil.vString(rs.getString("docPath"))); + bean.setSubcompanyid(StringUtil.parseToInt(rs.getString("subcompanyid"))); + bean.setMailmessagetype(StringUtil.parseToInt(rs.getString("mailMessageType"))); + bean.setDocrightbyoperator(StringUtil.parseToInt(rs.getString("docRightByOperator"))); + bean.setDoccategory(StringUtil.vString(rs.getString("docCategory"))); + bean.setIstemplate(StringUtil.vString(rs.getString("istemplate"))); + bean.setTemplateid(StringUtil.parseToInt(rs.getString("templateid"))); + bean.setCatelogtype(StringUtil.parseToInt(rs.getString("catelogType"))); + bean.setSelectedcatelog(StringUtil.parseToInt(rs.getString("selectedCateLog"))); + bean.setDocrightbyhrmresource(StringUtil.parseToInt(rs.getString("docRightByHrmResource"))); + bean.setNeedaffirmance(StringUtil.vString(rs.getString("needAffirmance"))); + bean.setIsremarks(StringUtil.vString(rs.getString("isremarks"))); + bean.setIsannexupload(StringUtil.vString(rs.getString("isannexUpload"))); + bean.setAnnexdoccategory(StringUtil.vString(rs.getString("annexdoccategory"))); + bean.setIsshowonreportinput(StringUtil.vString(rs.getString("isShowOnReportInput"))); + bean.setTitlefieldid(StringUtil.parseToInt(rs.getString("titleFieldId"))); + bean.setKeywordfieldid(StringUtil.parseToInt(rs.getString("keywordFieldId"))); + bean.setIsshowchart(StringUtil.vString(rs.getString("isshowchart"))); + bean.setOrderbytype(StringUtil.vString(rs.getString("orderbytype"))); + bean.setIstridiffworkflow(StringUtil.vString(rs.getString("isTriDiffWorkflow"))); + bean.setIsmodifylog(StringUtil.vString(rs.getString("isModifyLog"))); + bean.setIfversion(StringUtil.vString(rs.getString("ifVersion"))); + bean.setWfdocpath(StringUtil.vString(rs.getString("wfdocpath"))); + bean.setWfdocowner(StringUtil.vString(rs.getString("wfdocowner"))); + bean.setIsedit(StringUtil.vString(rs.getString("isEdit"))); + bean.setEditor(StringUtil.parseToInt(rs.getString("editor"))); + bean.setEditdate(StringUtil.vString(rs.getString("editdate"))); + bean.setEdittime(StringUtil.vString(rs.getString("edittime"))); + bean.setShowdelbuttonbyreject(StringUtil.vString(rs.getString("ShowDelButtonByReject"))); + bean.setShowuploadtab(StringUtil.vString(rs.getString("showUploadTab"))); + bean.setIssigndoc(StringUtil.vString(rs.getString("isSignDoc"))); + bean.setShowdoctab(StringUtil.vString(rs.getString("showDocTab"))); + bean.setIssignworkflow(StringUtil.vString(rs.getString("isSignWorkflow"))); + bean.setShowworkflowtab(StringUtil.vString(rs.getString("showWorkflowTab"))); + bean.setCandelacc(StringUtil.vString(rs.getString("candelacc"))); + bean.setIsforwardrights(StringUtil.vString(rs.getString("isforwardrights"))); + bean.setIsimportwf(StringUtil.vString(rs.getString("isimportwf"))); + bean.setIsrejectremind(StringUtil.vString(rs.getString("isrejectremind"))); + bean.setIschangrejectnode(StringUtil.vString(rs.getString("ischangrejectnode"))); + bean.setWfdocownertype(StringUtil.parseToInt(rs.getString("wfdocownertype"))); + bean.setWfdocownerfieldid(StringUtil.parseToInt(rs.getString("wfdocownerfieldid"))); + bean.setNewdocpath(StringUtil.vString(rs.getString("newdocpath"))); + bean.setKeepsign(StringUtil.parseToInt(rs.getString("keepsign"))); + bean.setSeccategoryid(StringUtil.parseToInt(rs.getString("secCategoryId"))); + bean.setCustompage(StringUtil.vString(rs.getString("custompage"))); + bean.setIssignview(StringUtil.parseToInt(rs.getString("issignview"))); + bean.setIsselectrejectnode(StringUtil.vString(rs.getString("IsSelectrejectNode"))); + bean.setForbidattdownload(StringUtil.parseToInt(rs.getString("forbidAttDownload"))); + bean.setIsimportdetail(StringUtil.vString(rs.getString("isImportDetail"))); + bean.setSpecialapproval(StringUtil.vString(rs.getString("specialApproval"))); + bean.setFrequency(StringUtil.parseToInt(rs.getString("Frequency"))); + bean.setCycle(StringUtil.vString(rs.getString("Cycle"))); + bean.setNosynfields(StringUtil.vString(rs.getString("nosynfields"))); + bean.setIsneeddelacc(StringUtil.vString(rs.getString("isneeddelacc"))); + bean.setSapsource(StringUtil.vString(rs.getString("SAPSource"))); + bean.setIsfnacontrol(StringUtil.vString(rs.getString("isfnacontrol"))); + bean.setFnanodeid(StringUtil.vString(rs.getString("fnanodeid"))); + bean.setFnadepartmentid(StringUtil.vString(rs.getString("fnadepartmentid"))); + bean.setSmsalertstype(StringUtil.vString(rs.getString("smsAlertsType"))); + bean.setIssavecheckform(StringUtil.vString(rs.getString("isSaveCheckForm"))); + bean.setArchivenomsgalert(StringUtil.vString(rs.getString("archiveNoMsgAlert"))); + bean.setArchivenomailalert(StringUtil.vString(rs.getString("archiveNoMailAlert"))); + bean.setIsfnabudgetwf(StringUtil.vString(rs.getString("isfnabudgetwf"))); + bean.setForwardreceivedef(StringUtil.vString(rs.getString("forwardReceiveDef"))); + bean.setIsworkflowdoc(StringUtil.parseToInt(rs.getString("isWorkflowDoc"))); + bean.setOfficaltype(StringUtil.parseToInt(rs.getString("officalType"))); + bean.setVersion(StringUtil.parseToInt(rs.getString("version"))); + bean.setActiveversionid(StringUtil.parseToInt(rs.getString("activeVersionID"))); + bean.setVersiondescription(StringUtil.vString(rs.getString("versionDescription"))); + bean.setVersioncreater(StringUtil.parseToInt(rs.getString("VersionCreater"))); + bean.setDsporder(StringUtil.parseToInt(rs.getString("dsporder"))); + bean.setFieldnotimport(StringUtil.vString(rs.getString("fieldNotImport"))); + bean.setIsfree(StringUtil.vString(rs.getString("isfree"))); + bean.setEcologyPinyinSearch(StringUtil.vString(rs.getString("ecology_pinyin_search"))); + bean.setChatstype(StringUtil.parseToInt(rs.getString("chatsType"))); + bean.setChatsalerttype(StringUtil.parseToInt(rs.getString("chatsAlertType"))); + bean.setNotremindifarchived(StringUtil.parseToInt(rs.getString("notRemindifArchived"))); + bean.setCustompage4emoble(StringUtil.vString(rs.getString("custompage4Emoble"))); + bean.setIsupdatetitle(StringUtil.parseToInt(rs.getString("isupdatetitle"))); + bean.setIsshared(StringUtil.vString(rs.getString("isshared"))); + bean.setForwardingsmsalerts(""); + bean.setIsoverrb(StringUtil.vString(rs.getString("isoverrb"))); + bean.setIsoveriv(StringUtil.vString(rs.getString("isoveriv"))); + list.add(bean); + } + return list; + } + + public WorkflowBase get(Comparable id) { + Map map = new HashMap(); + map.put("id", id); + List list = find(map); + return list != null && list.size() > 0 ? list.get(0) : null; + } + + public int count(Map map) { + RecordSet rs = new RecordSet(); + StringBuffer sql = new StringBuffer("select count(id) as result from workflow_base where 1 = 1"); + if(map != null) { + if(map.containsKey("id")){ + sql.append(" and id = ").append(StringUtil.vString(map.get("id"))); + } + if(map.containsKey("sql_id")){ + sql.append(" " + StringUtil.vString(map.get("sql_id"))); + } + if(map.containsKey("workflowtype")){ + sql.append(" and workflowtype = ").append(StringUtil.vString(map.get("workflowtype"))); + } + if(map.containsKey("sql_workflowtype")){ + sql.append(" " + StringUtil.vString(map.get("sql_workflowtype"))); + } + if(map.containsKey("formid")){ + sql.append(" and formid = ").append(StringUtil.vString(map.get("formid"))); + } + if(map.containsKey("sql_formid")){ + sql.append(" " + StringUtil.vString(map.get("sql_formid"))); + } + if(map.containsKey("userid")){ + sql.append(" and userid = ").append(StringUtil.vString(map.get("userid"))); + } + if(map.containsKey("sql_userid")){ + sql.append(" " + StringUtil.vString(map.get("sql_userid"))); + } + if(map.containsKey("iscust")){ + sql.append(" and iscust = ").append(StringUtil.vString(map.get("iscust"))); + } + if(map.containsKey("sql_iscust")){ + sql.append(" " + StringUtil.vString(map.get("sql_iscust"))); + } + if(map.containsKey("helpdocid")){ + sql.append(" and helpdocid = ").append(StringUtil.vString(map.get("helpdocid"))); + } + if(map.containsKey("sql_helpdocid")){ + sql.append(" " + StringUtil.vString(map.get("sql_helpdocid"))); + } + if(map.containsKey("messageType")){ + sql.append(" and messageType = ").append(StringUtil.vString(map.get("messageType"))); + } + if(map.containsKey("sql_messageType")){ + sql.append(" " + StringUtil.vString(map.get("sql_messageType"))); + } + if(map.containsKey("multiSubmit")){ + sql.append(" and multiSubmit = ").append(StringUtil.vString(map.get("multiSubmit"))); + } + if(map.containsKey("sql_multiSubmit")){ + sql.append(" " + StringUtil.vString(map.get("sql_multiSubmit"))); + } + if(map.containsKey("defaultName")){ + sql.append(" and defaultName = ").append(StringUtil.vString(map.get("defaultName"))); + } + if(map.containsKey("sql_defaultName")){ + sql.append(" " + StringUtil.vString(map.get("sql_defaultName"))); + } + if(map.containsKey("subcompanyid")){ + sql.append(" and subcompanyid = ").append(StringUtil.vString(map.get("subcompanyid"))); + } + if(map.containsKey("sql_subcompanyid")){ + sql.append(" " + StringUtil.vString(map.get("sql_subcompanyid"))); + } + if(map.containsKey("mailMessageType")){ + sql.append(" and mailMessageType = ").append(StringUtil.vString(map.get("mailMessageType"))); + } + if(map.containsKey("sql_mailMessageType")){ + sql.append(" " + StringUtil.vString(map.get("sql_mailMessageType"))); + } + if(map.containsKey("docRightByOperator")){ + sql.append(" and docRightByOperator = ").append(StringUtil.vString(map.get("docRightByOperator"))); + } + if(map.containsKey("sql_docRightByOperator")){ + sql.append(" " + StringUtil.vString(map.get("sql_docRightByOperator"))); + } + if(map.containsKey("templateid")){ + sql.append(" and templateid = ").append(StringUtil.vString(map.get("templateid"))); + } + if(map.containsKey("sql_templateid")){ + sql.append(" " + StringUtil.vString(map.get("sql_templateid"))); + } + if(map.containsKey("catelogType")){ + sql.append(" and catelogType = ").append(StringUtil.vString(map.get("catelogType"))); + } + if(map.containsKey("sql_catelogType")){ + sql.append(" " + StringUtil.vString(map.get("sql_catelogType"))); + } + if(map.containsKey("selectedCateLog")){ + sql.append(" and selectedCateLog = ").append(StringUtil.vString(map.get("selectedCateLog"))); + } + if(map.containsKey("sql_selectedCateLog")){ + sql.append(" " + StringUtil.vString(map.get("sql_selectedCateLog"))); + } + if(map.containsKey("docRightByHrmResource")){ + sql.append(" and docRightByHrmResource = ").append(StringUtil.vString(map.get("docRightByHrmResource"))); + } + if(map.containsKey("sql_docRightByHrmResource")){ + sql.append(" " + StringUtil.vString(map.get("sql_docRightByHrmResource"))); + } + if(map.containsKey("titleFieldId")){ + sql.append(" and titleFieldId = ").append(StringUtil.vString(map.get("titleFieldId"))); + } + if(map.containsKey("sql_titleFieldId")){ + sql.append(" " + StringUtil.vString(map.get("sql_titleFieldId"))); + } + if(map.containsKey("keywordFieldId")){ + sql.append(" and keywordFieldId = ").append(StringUtil.vString(map.get("keywordFieldId"))); + } + if(map.containsKey("sql_keywordFieldId")){ + sql.append(" " + StringUtil.vString(map.get("sql_keywordFieldId"))); + } + if(map.containsKey("editor")){ + sql.append(" and editor = ").append(StringUtil.vString(map.get("editor"))); + } + if(map.containsKey("sql_editor")){ + sql.append(" " + StringUtil.vString(map.get("sql_editor"))); + } + if(map.containsKey("wfdocownertype")){ + sql.append(" and wfdocownertype = ").append(StringUtil.vString(map.get("wfdocownertype"))); + } + if(map.containsKey("sql_wfdocownertype")){ + sql.append(" " + StringUtil.vString(map.get("sql_wfdocownertype"))); + } + if(map.containsKey("wfdocownerfieldid")){ + sql.append(" and wfdocownerfieldid = ").append(StringUtil.vString(map.get("wfdocownerfieldid"))); + } + if(map.containsKey("sql_wfdocownerfieldid")){ + sql.append(" " + StringUtil.vString(map.get("sql_wfdocownerfieldid"))); + } + if(map.containsKey("keepsign")){ + sql.append(" and keepsign = ").append(StringUtil.vString(map.get("keepsign"))); + } + if(map.containsKey("sql_keepsign")){ + sql.append(" " + StringUtil.vString(map.get("sql_keepsign"))); + } + if(map.containsKey("secCategoryId")){ + sql.append(" and secCategoryId = ").append(StringUtil.vString(map.get("secCategoryId"))); + } + if(map.containsKey("sql_secCategoryId")){ + sql.append(" " + StringUtil.vString(map.get("sql_secCategoryId"))); + } + if(map.containsKey("issignview")){ + sql.append(" and issignview = ").append(StringUtil.vString(map.get("issignview"))); + } + if(map.containsKey("sql_issignview")){ + sql.append(" " + StringUtil.vString(map.get("sql_issignview"))); + } + if(map.containsKey("forbidAttDownload")){ + sql.append(" and forbidAttDownload = ").append(StringUtil.vString(map.get("forbidAttDownload"))); + } + if(map.containsKey("sql_forbidAttDownload")){ + sql.append(" " + StringUtil.vString(map.get("sql_forbidAttDownload"))); + } + if(map.containsKey("Frequency")){ + sql.append(" and Frequency = ").append(StringUtil.vString(map.get("Frequency"))); + } + if(map.containsKey("sql_Frequency")){ + sql.append(" " + StringUtil.vString(map.get("sql_Frequency"))); + } + if(map.containsKey("isWorkflowDoc")){ + sql.append(" and isWorkflowDoc = ").append(StringUtil.vString(map.get("isWorkflowDoc"))); + } + if(map.containsKey("sql_isWorkflowDoc")){ + sql.append(" " + StringUtil.vString(map.get("sql_isWorkflowDoc"))); + } + if(map.containsKey("officalType")){ + sql.append(" and officalType = ").append(StringUtil.vString(map.get("officalType"))); + } + if(map.containsKey("sql_officalType")){ + sql.append(" " + StringUtil.vString(map.get("sql_officalType"))); + } + if(map.containsKey("version")){ + sql.append(" and version = ").append(StringUtil.vString(map.get("version"))); + } + if(map.containsKey("sql_version")){ + sql.append(" " + StringUtil.vString(map.get("sql_version"))); + } + if(map.containsKey("activeVersionID")){ + sql.append(" and activeVersionID = ").append(StringUtil.vString(map.get("activeVersionID"))); + } + if(map.containsKey("sql_activeVersionID")){ + sql.append(" " + StringUtil.vString(map.get("sql_activeVersionID"))); + } + if(map.containsKey("VersionCreater")){ + sql.append(" and VersionCreater = ").append(StringUtil.vString(map.get("VersionCreater"))); + } + if(map.containsKey("sql_VersionCreater")){ + sql.append(" " + StringUtil.vString(map.get("sql_VersionCreater"))); + } + if(map.containsKey("dsporder")){ + sql.append(" and dsporder = ").append(StringUtil.vString(map.get("dsporder"))); + } + if(map.containsKey("sql_dsporder")){ + sql.append(" " + StringUtil.vString(map.get("sql_dsporder"))); + } + if(map.containsKey("chatsType")){ + sql.append(" and chatsType = ").append(StringUtil.vString(map.get("chatsType"))); + } + if(map.containsKey("sql_chatsType")){ + sql.append(" " + StringUtil.vString(map.get("sql_chatsType"))); + } + if(map.containsKey("chatsAlertType")){ + sql.append(" and chatsAlertType = ").append(StringUtil.vString(map.get("chatsAlertType"))); + } + if(map.containsKey("sql_chatsAlertType")){ + sql.append(" " + StringUtil.vString(map.get("sql_chatsAlertType"))); + } + if(map.containsKey("notRemindifArchived")){ + sql.append(" and notRemindifArchived = ").append(StringUtil.vString(map.get("notRemindifArchived"))); + } + if(map.containsKey("sql_notRemindifArchived")){ + sql.append(" " + StringUtil.vString(map.get("sql_notRemindifArchived"))); + } + if(map.containsKey("isupdatetitle")){ + sql.append(" and isupdatetitle = ").append(StringUtil.vString(map.get("isupdatetitle"))); + } + if(map.containsKey("sql_isupdatetitle")){ + sql.append(" " + StringUtil.vString(map.get("sql_isupdatetitle"))); + } + if(map.containsKey("workflowname")){ + sql.append(" and workflowname = '").append(StringUtil.vString(map.get("workflowname"))).append("'"); + } + if(map.containsKey("sql_workflowname")){ + sql.append(" " + StringUtil.vString(map.get("sql_workflowname"))); + } + if(map.containsKey("workflowdesc")){ + sql.append(" and workflowdesc = '").append(StringUtil.vString(map.get("workflowdesc"))).append("'"); + } + if(map.containsKey("sql_workflowdesc")){ + sql.append(" " + StringUtil.vString(map.get("sql_workflowdesc"))); + } + if(map.containsKey("securelevel")){ + sql.append(" and securelevel = '").append(StringUtil.vString(map.get("securelevel"))).append("'"); + } + if(map.containsKey("sql_securelevel")){ + sql.append(" " + StringUtil.vString(map.get("sql_securelevel"))); + } + if(map.containsKey("isbill")){ + sql.append(" and isbill = '").append(StringUtil.vString(map.get("isbill"))).append("'"); + } + if(map.containsKey("sql_isbill")){ + sql.append(" " + StringUtil.vString(map.get("sql_isbill"))); + } + if(map.containsKey("isvalid")){ + sql.append(" and isvalid = '").append(StringUtil.vString(map.get("isvalid"))).append("'"); + } + if(map.containsKey("sql_isvalid")){ + sql.append(" " + StringUtil.vString(map.get("sql_isvalid"))); + } + if(map.containsKey("needmark")){ + sql.append(" and needmark = '").append(StringUtil.vString(map.get("needmark"))).append("'"); + } + if(map.containsKey("sql_needmark")){ + sql.append(" " + StringUtil.vString(map.get("sql_needmark"))); + } + if(map.containsKey("docPath")){ + sql.append(" and docPath = '").append(StringUtil.vString(map.get("docPath"))).append("'"); + } + if(map.containsKey("sql_docPath")){ + sql.append(" " + StringUtil.vString(map.get("sql_docPath"))); + } + if(map.containsKey("docCategory")){ + sql.append(" and docCategory = '").append(StringUtil.vString(map.get("docCategory"))).append("'"); + } + if(map.containsKey("sql_docCategory")){ + sql.append(" " + StringUtil.vString(map.get("sql_docCategory"))); + } + if(map.containsKey("istemplate")){ + sql.append(" and istemplate = '").append(StringUtil.vString(map.get("istemplate"))).append("'"); + } + if(map.containsKey("sql_istemplate")){ + sql.append(" " + StringUtil.vString(map.get("sql_istemplate"))); + } + if(map.containsKey("needAffirmance")){ + sql.append(" and needAffirmance = '").append(StringUtil.vString(map.get("needAffirmance"))).append("'"); + } + if(map.containsKey("sql_needAffirmance")){ + sql.append(" " + StringUtil.vString(map.get("sql_needAffirmance"))); + } + if(map.containsKey("isremarks")){ + sql.append(" and isremarks = '").append(StringUtil.vString(map.get("isremarks"))).append("'"); + } + if(map.containsKey("sql_isremarks")){ + sql.append(" " + StringUtil.vString(map.get("sql_isremarks"))); + } + if(map.containsKey("isannexUpload")){ + sql.append(" and isannexUpload = '").append(StringUtil.vString(map.get("isannexUpload"))).append("'"); + } + if(map.containsKey("sql_isannexUpload")){ + sql.append(" " + StringUtil.vString(map.get("sql_isannexUpload"))); + } + if(map.containsKey("annexdoccategory")){ + sql.append(" and annexdoccategory = '").append(StringUtil.vString(map.get("annexdoccategory"))).append("'"); + } + if(map.containsKey("sql_annexdoccategory")){ + sql.append(" " + StringUtil.vString(map.get("sql_annexdoccategory"))); + } + if(map.containsKey("isShowOnReportInput")){ + sql.append(" and isShowOnReportInput = '").append(StringUtil.vString(map.get("isShowOnReportInput"))).append("'"); + } + if(map.containsKey("sql_isShowOnReportInput")){ + sql.append(" " + StringUtil.vString(map.get("sql_isShowOnReportInput"))); + } + if(map.containsKey("isshowchart")){ + sql.append(" and isshowchart = '").append(StringUtil.vString(map.get("isshowchart"))).append("'"); + } + if(map.containsKey("sql_isshowchart")){ + sql.append(" " + StringUtil.vString(map.get("sql_isshowchart"))); + } + if(map.containsKey("orderbytype")){ + sql.append(" and orderbytype = '").append(StringUtil.vString(map.get("orderbytype"))).append("'"); + } + if(map.containsKey("sql_orderbytype")){ + sql.append(" " + StringUtil.vString(map.get("sql_orderbytype"))); + } + if(map.containsKey("isTriDiffWorkflow")){ + sql.append(" and isTriDiffWorkflow = '").append(StringUtil.vString(map.get("isTriDiffWorkflow"))).append("'"); + } + if(map.containsKey("sql_isTriDiffWorkflow")){ + sql.append(" " + StringUtil.vString(map.get("sql_isTriDiffWorkflow"))); + } + if(map.containsKey("isModifyLog")){ + sql.append(" and isModifyLog = '").append(StringUtil.vString(map.get("isModifyLog"))).append("'"); + } + if(map.containsKey("sql_isModifyLog")){ + sql.append(" " + StringUtil.vString(map.get("sql_isModifyLog"))); + } + if(map.containsKey("ifVersion")){ + sql.append(" and ifVersion = '").append(StringUtil.vString(map.get("ifVersion"))).append("'"); + } + if(map.containsKey("sql_ifVersion")){ + sql.append(" " + StringUtil.vString(map.get("sql_ifVersion"))); + } + if(map.containsKey("wfdocpath")){ + sql.append(" and wfdocpath = '").append(StringUtil.vString(map.get("wfdocpath"))).append("'"); + } + if(map.containsKey("sql_wfdocpath")){ + sql.append(" " + StringUtil.vString(map.get("sql_wfdocpath"))); + } + if(map.containsKey("wfdocowner")){ + sql.append(" and wfdocowner = '").append(StringUtil.vString(map.get("wfdocowner"))).append("'"); + } + if(map.containsKey("sql_wfdocowner")){ + sql.append(" " + StringUtil.vString(map.get("sql_wfdocowner"))); + } + if(map.containsKey("isEdit")){ + sql.append(" and isEdit = '").append(StringUtil.vString(map.get("isEdit"))).append("'"); + } + if(map.containsKey("sql_isEdit")){ + sql.append(" " + StringUtil.vString(map.get("sql_isEdit"))); + } + if(map.containsKey("editdate")){ + sql.append(" and editdate = '").append(StringUtil.vString(map.get("editdate"))).append("'"); + } + if(map.containsKey("sql_editdate")){ + sql.append(" " + StringUtil.vString(map.get("sql_editdate"))); + } + if(map.containsKey("edittime")){ + sql.append(" and edittime = '").append(StringUtil.vString(map.get("edittime"))).append("'"); + } + if(map.containsKey("sql_edittime")){ + sql.append(" " + StringUtil.vString(map.get("sql_edittime"))); + } + if(map.containsKey("ShowDelButtonByReject")){ + sql.append(" and ShowDelButtonByReject = '").append(StringUtil.vString(map.get("ShowDelButtonByReject"))).append("'"); + } + if(map.containsKey("sql_ShowDelButtonByReject")){ + sql.append(" " + StringUtil.vString(map.get("sql_ShowDelButtonByReject"))); + } + if(map.containsKey("showUploadTab")){ + sql.append(" and showUploadTab = '").append(StringUtil.vString(map.get("showUploadTab"))).append("'"); + } + if(map.containsKey("sql_showUploadTab")){ + sql.append(" " + StringUtil.vString(map.get("sql_showUploadTab"))); + } + if(map.containsKey("isSignDoc")){ + sql.append(" and isSignDoc = '").append(StringUtil.vString(map.get("isSignDoc"))).append("'"); + } + if(map.containsKey("sql_isSignDoc")){ + sql.append(" " + StringUtil.vString(map.get("sql_isSignDoc"))); + } + if(map.containsKey("showDocTab")){ + sql.append(" and showDocTab = '").append(StringUtil.vString(map.get("showDocTab"))).append("'"); + } + if(map.containsKey("sql_showDocTab")){ + sql.append(" " + StringUtil.vString(map.get("sql_showDocTab"))); + } + if(map.containsKey("isSignWorkflow")){ + sql.append(" and isSignWorkflow = '").append(StringUtil.vString(map.get("isSignWorkflow"))).append("'"); + } + if(map.containsKey("sql_isSignWorkflow")){ + sql.append(" " + StringUtil.vString(map.get("sql_isSignWorkflow"))); + } + if(map.containsKey("showWorkflowTab")){ + sql.append(" and showWorkflowTab = '").append(StringUtil.vString(map.get("showWorkflowTab"))).append("'"); + } + if(map.containsKey("sql_showWorkflowTab")){ + sql.append(" " + StringUtil.vString(map.get("sql_showWorkflowTab"))); + } + if(map.containsKey("candelacc")){ + sql.append(" and candelacc = '").append(StringUtil.vString(map.get("candelacc"))).append("'"); + } + if(map.containsKey("sql_candelacc")){ + sql.append(" " + StringUtil.vString(map.get("sql_candelacc"))); + } + if(map.containsKey("isforwardrights")){ + sql.append(" and isforwardrights = '").append(StringUtil.vString(map.get("isforwardrights"))).append("'"); + } + if(map.containsKey("sql_isforwardrights")){ + sql.append(" " + StringUtil.vString(map.get("sql_isforwardrights"))); + } + if(map.containsKey("isimportwf")){ + sql.append(" and isimportwf = '").append(StringUtil.vString(map.get("isimportwf"))).append("'"); + } + if(map.containsKey("sql_isimportwf")){ + sql.append(" " + StringUtil.vString(map.get("sql_isimportwf"))); + } + if(map.containsKey("isrejectremind")){ + sql.append(" and isrejectremind = '").append(StringUtil.vString(map.get("isrejectremind"))).append("'"); + } + if(map.containsKey("sql_isrejectremind")){ + sql.append(" " + StringUtil.vString(map.get("sql_isrejectremind"))); + } + if(map.containsKey("ischangrejectnode")){ + sql.append(" and ischangrejectnode = '").append(StringUtil.vString(map.get("ischangrejectnode"))).append("'"); + } + if(map.containsKey("sql_ischangrejectnode")){ + sql.append(" " + StringUtil.vString(map.get("sql_ischangrejectnode"))); + } + if(map.containsKey("newdocpath")){ + sql.append(" and newdocpath = '").append(StringUtil.vString(map.get("newdocpath"))).append("'"); + } + if(map.containsKey("sql_newdocpath")){ + sql.append(" " + StringUtil.vString(map.get("sql_newdocpath"))); + } + if(map.containsKey("custompage")){ + sql.append(" and custompage = '").append(StringUtil.vString(map.get("custompage"))).append("'"); + } + if(map.containsKey("sql_custompage")){ + sql.append(" " + StringUtil.vString(map.get("sql_custompage"))); + } + if(map.containsKey("IsSelectrejectNode")){ + sql.append(" and IsSelectrejectNode = '").append(StringUtil.vString(map.get("IsSelectrejectNode"))).append("'"); + } + if(map.containsKey("sql_IsSelectrejectNode")){ + sql.append(" " + StringUtil.vString(map.get("sql_IsSelectrejectNode"))); + } + if(map.containsKey("isImportDetail")){ + sql.append(" and isImportDetail = '").append(StringUtil.vString(map.get("isImportDetail"))).append("'"); + } + if(map.containsKey("sql_isImportDetail")){ + sql.append(" " + StringUtil.vString(map.get("sql_isImportDetail"))); + } + if(map.containsKey("specialApproval")){ + sql.append(" and specialApproval = '").append(StringUtil.vString(map.get("specialApproval"))).append("'"); + } + if(map.containsKey("sql_specialApproval")){ + sql.append(" " + StringUtil.vString(map.get("sql_specialApproval"))); + } + if(map.containsKey("Cycle")){ + sql.append(" and Cycle = '").append(StringUtil.vString(map.get("Cycle"))).append("'"); + } + if(map.containsKey("sql_Cycle")){ + sql.append(" " + StringUtil.vString(map.get("sql_Cycle"))); + } + if(map.containsKey("nosynfields")){ + sql.append(" and nosynfields = '").append(StringUtil.vString(map.get("nosynfields"))).append("'"); + } + if(map.containsKey("sql_nosynfields")){ + sql.append(" " + StringUtil.vString(map.get("sql_nosynfields"))); + } + if(map.containsKey("isneeddelacc")){ + sql.append(" and isneeddelacc = '").append(StringUtil.vString(map.get("isneeddelacc"))).append("'"); + } + if(map.containsKey("sql_isneeddelacc")){ + sql.append(" " + StringUtil.vString(map.get("sql_isneeddelacc"))); + } + if(map.containsKey("SAPSource")){ + sql.append(" and SAPSource = '").append(StringUtil.vString(map.get("SAPSource"))).append("'"); + } + if(map.containsKey("sql_SAPSource")){ + sql.append(" " + StringUtil.vString(map.get("sql_SAPSource"))); + } + if(map.containsKey("isfnacontrol")){ + sql.append(" and isfnacontrol = '").append(StringUtil.vString(map.get("isfnacontrol"))).append("'"); + } + if(map.containsKey("sql_isfnacontrol")){ + sql.append(" " + StringUtil.vString(map.get("sql_isfnacontrol"))); + } + if(map.containsKey("fnanodeid")){ + sql.append(" and fnanodeid = '").append(StringUtil.vString(map.get("fnanodeid"))).append("'"); + } + if(map.containsKey("sql_fnanodeid")){ + sql.append(" " + StringUtil.vString(map.get("sql_fnanodeid"))); + } + if(map.containsKey("fnadepartmentid")){ + sql.append(" and fnadepartmentid = '").append(StringUtil.vString(map.get("fnadepartmentid"))).append("'"); + } + if(map.containsKey("sql_fnadepartmentid")){ + sql.append(" " + StringUtil.vString(map.get("sql_fnadepartmentid"))); + } + if(map.containsKey("smsAlertsType")){ + sql.append(" and smsAlertsType = '").append(StringUtil.vString(map.get("smsAlertsType"))).append("'"); + } + if(map.containsKey("sql_smsAlertsType")){ + sql.append(" " + StringUtil.vString(map.get("sql_smsAlertsType"))); + } + if(map.containsKey("isSaveCheckForm")){ + sql.append(" and isSaveCheckForm = '").append(StringUtil.vString(map.get("isSaveCheckForm"))).append("'"); + } + if(map.containsKey("sql_isSaveCheckForm")){ + sql.append(" " + StringUtil.vString(map.get("sql_isSaveCheckForm"))); + } + if(map.containsKey("archiveNoMsgAlert")){ + sql.append(" and archiveNoMsgAlert = '").append(StringUtil.vString(map.get("archiveNoMsgAlert"))).append("'"); + } + if(map.containsKey("sql_archiveNoMsgAlert")){ + sql.append(" " + StringUtil.vString(map.get("sql_archiveNoMsgAlert"))); + } + if(map.containsKey("archiveNoMailAlert")){ + sql.append(" and archiveNoMailAlert = '").append(StringUtil.vString(map.get("archiveNoMailAlert"))).append("'"); + } + if(map.containsKey("sql_archiveNoMailAlert")){ + sql.append(" " + StringUtil.vString(map.get("sql_archiveNoMailAlert"))); + } + if(map.containsKey("isfnabudgetwf")){ + sql.append(" and isfnabudgetwf = '").append(StringUtil.vString(map.get("isfnabudgetwf"))).append("'"); + } + if(map.containsKey("sql_isfnabudgetwf")){ + sql.append(" " + StringUtil.vString(map.get("sql_isfnabudgetwf"))); + } + if(map.containsKey("forwardReceiveDef")){ + sql.append(" and forwardReceiveDef = '").append(StringUtil.vString(map.get("forwardReceiveDef"))).append("'"); + } + if(map.containsKey("sql_forwardReceiveDef")){ + sql.append(" " + StringUtil.vString(map.get("sql_forwardReceiveDef"))); + } + if(map.containsKey("versionDescription")){ + sql.append(" and versionDescription = '").append(StringUtil.vString(map.get("versionDescription"))).append("'"); + } + if(map.containsKey("sql_versionDescription")){ + sql.append(" " + StringUtil.vString(map.get("sql_versionDescription"))); + } + if(map.containsKey("fieldNotImport")){ + sql.append(" and fieldNotImport = '").append(StringUtil.vString(map.get("fieldNotImport"))).append("'"); + } + if(map.containsKey("sql_fieldNotImport")){ + sql.append(" " + StringUtil.vString(map.get("sql_fieldNotImport"))); + } + if(map.containsKey("isfree")){ + sql.append(" and isfree = '").append(StringUtil.vString(map.get("isfree"))).append("'"); + } + if(map.containsKey("sql_isfree")){ + sql.append(" " + StringUtil.vString(map.get("sql_isfree"))); + } + if(map.containsKey("ecologyPinyinSearch")){ + sql.append(" and ecology_pinyin_search = '").append(StringUtil.vString(map.get("ecologyPinyinSearch"))).append("'"); + } + if(map.containsKey("sql_ecologyPinyinSearch")){ + sql.append(" " + StringUtil.vString(map.get("sql_ecologyPinyinSearch"))); + } + if(map.containsKey("custompage4Emoble")){ + sql.append(" and custompage4Emoble = '").append(StringUtil.vString(map.get("custompage4Emoble"))).append("'"); + } + if(map.containsKey("sql_custompage4Emoble")){ + sql.append(" " + StringUtil.vString(map.get("sql_custompage4Emoble"))); + } + if(map.containsKey("isshared")){ + sql.append(" and isshared = '").append(StringUtil.vString(map.get("isshared"))).append("'"); + } + if(map.containsKey("sql_isshared")){ + sql.append(" " + StringUtil.vString(map.get("sql_isshared"))); + } + if(map.containsKey("isoverrb")){ + sql.append(" and isoverrb = '").append(StringUtil.vString(map.get("isoverrb"))).append("'"); + } + if(map.containsKey("sql_isoverrb")){ + sql.append(" " + StringUtil.vString(map.get("sql_isoverrb"))); + } + if(map.containsKey("isoveriv")){ + sql.append(" and isoveriv = '").append(StringUtil.vString(map.get("isoveriv"))).append("'"); + } + if(map.containsKey("sql_isoveriv")){ + sql.append(" " + StringUtil.vString(map.get("sql_isoveriv"))); + } + } + rs.executeSql(sql.toString()); + return rs.next() ? rs.getInt(1) : 0; + } + + public void delete(Comparable id) { + + } + + public void delete(Map map) { + if(map == null || map.isEmpty()) return; + } + +} diff --git a/src/com/engine/kq/wfset/attendance/dao/WorkflowBillfieldDao.java b/src/com/engine/kq/wfset/attendance/dao/WorkflowBillfieldDao.java new file mode 100644 index 0000000..3933813 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/dao/WorkflowBillfieldDao.java @@ -0,0 +1,322 @@ +package com.engine.kq.wfset.attendance.dao; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import com.engine.kq.wfset.attendance.framework.BaseDao; +import com.engine.kq.wfset.attendance.domain.WorkflowBillfield; + +/** + * WorkflowBillfieldDao + * @author wcd + * @version 1.0 2015-04-24 + */ +public class WorkflowBillfieldDao implements BaseDao { + + public WorkflowBillfieldDao() { + + } + + public Comparable insert(WorkflowBillfield bean) { + return 0; + } + + public void update(WorkflowBillfield bean) {} + + /** + * map: + * 如没传入:languageid,则会每有一种语种则查询出一条表单字段记录 + * 如没传入:viewtype,则默认只查询viewtype=0的主表表单字段记录 + */ + public List find(Map map) { + List list = new ArrayList(); + StringBuffer sql = new StringBuffer() + .append(" select t.id,t.billid,t.fieldname,t.fieldlabel,t.fielddbtype,t.fieldhtmltype,t.type,") + .append(" t.viewtype,t.detailtable,t.fromUser,t.textheight,t.dsporder,t.childfieldid,") + .append(" t.imgheight,t.imgwidth,t.places,t.qfws,t.textheight_2,t.selectitem,") + .append(" t.linkfield,b.labelname,b.languageid") + .append(" from workflow_billfield t left join HtmlLabelInfo b on t.fieldlabel = b.indexid") + .append(" where 1=1 "); + if(map == null) { + map = new HashMap(); + } + if(!map.containsKey("viewtype")){ + map.put("viewtype", "0"); + } + + if(map.containsKey("id")){ + sql.append(" and t.id = ").append(StringUtil.vString(map.get("id"))); + } + if(map.containsKey("begin_id")){ + sql.append(" and t.id >= ").append(StringUtil.vString(map.get("begin_id"))); + } + if(map.containsKey("end_id")){ + sql.append(" and t.id < ").append(StringUtil.vString(map.get("end_id"))); + } + if(map.containsKey("sql_id")){ + sql.append(" " + StringUtil.vString(map.get("sql_id"))); + } + if(map.containsKey("billid")){ + sql.append(" and t.billid = ").append(StringUtil.vString(map.get("billid"))); + } + if(map.containsKey("begin_billid")){ + sql.append(" and t.billid >= ").append(StringUtil.vString(map.get("begin_billid"))); + } + if(map.containsKey("end_billid")){ + sql.append(" and t.billid < ").append(StringUtil.vString(map.get("end_billid"))); + } + if(map.containsKey("sql_billid")){ + sql.append(" " + StringUtil.vString(map.get("sql_billid"))); + } + if(map.containsKey("fieldlabel")){ + sql.append(" and t.fieldlabel = ").append(StringUtil.vString(map.get("fieldlabel"))); + } + if(map.containsKey("begin_fieldlabel")){ + sql.append(" and t.fieldlabel >= ").append(StringUtil.vString(map.get("begin_fieldlabel"))); + } + if(map.containsKey("end_fieldlabel")){ + sql.append(" and t.fieldlabel < ").append(StringUtil.vString(map.get("end_fieldlabel"))); + } + if(map.containsKey("sql_fieldlabel")){ + sql.append(" " + StringUtil.vString(map.get("sql_fieldlabel"))); + } + if(map.containsKey("languageid")){ + sql.append(" and b.languageid = ").append(StringUtil.vString(map.get("languageid"))); + } + if(map.containsKey("sql_languageid")){ + sql.append(" " + StringUtil.vString(map.get("sql_languageid"))); + } + if(map.containsKey("type")){ + sql.append(" and t.type = ").append(StringUtil.vString(map.get("type"))); + } + if(map.containsKey("begin_type")){ + sql.append(" and t.type >= ").append(StringUtil.vString(map.get("begin_type"))); + } + if(map.containsKey("end_type")){ + sql.append(" and t.type < ").append(StringUtil.vString(map.get("end_type"))); + } + if(map.containsKey("sql_type")){ + sql.append(" " + StringUtil.vString(map.get("sql_type"))); + } + if(map.containsKey("viewtype")){ + sql.append(" and t.viewtype = ").append(StringUtil.vString(map.get("viewtype"))); + } + if(map.containsKey("begin_viewtype")){ + sql.append(" and t.viewtype >= ").append(StringUtil.vString(map.get("begin_viewtype"))); + } + if(map.containsKey("end_viewtype")){ + sql.append(" and t.viewtype < ").append(StringUtil.vString(map.get("end_viewtype"))); + } + if(map.containsKey("sql_viewtype")){ + sql.append(" " + StringUtil.vString(map.get("sql_viewtype"))); + } + if(map.containsKey("textheight")){ + sql.append(" and t.textheight = ").append(StringUtil.vString(map.get("textheight"))); + } + if(map.containsKey("begin_textheight")){ + sql.append(" and t.textheight >= ").append(StringUtil.vString(map.get("begin_textheight"))); + } + if(map.containsKey("end_textheight")){ + sql.append(" and t.textheight < ").append(StringUtil.vString(map.get("end_textheight"))); + } + if(map.containsKey("sql_textheight")){ + sql.append(" " + StringUtil.vString(map.get("sql_textheight"))); + } + if(map.containsKey("dsporder")){ + sql.append(" and t.dsporder = ").append(StringUtil.vString(map.get("dsporder"))); + } + if(map.containsKey("begin_dsporder")){ + sql.append(" and t.dsporder >= ").append(StringUtil.vString(map.get("begin_dsporder"))); + } + if(map.containsKey("end_dsporder")){ + sql.append(" and t.dsporder < ").append(StringUtil.vString(map.get("end_dsporder"))); + } + if(map.containsKey("sql_dsporder")){ + sql.append(" " + StringUtil.vString(map.get("sql_dsporder"))); + } + if(map.containsKey("childfieldid")){ + sql.append(" and t.childfieldid = ").append(StringUtil.vString(map.get("childfieldid"))); + } + if(map.containsKey("begin_childfieldid")){ + sql.append(" and t.childfieldid >= ").append(StringUtil.vString(map.get("begin_childfieldid"))); + } + if(map.containsKey("end_childfieldid")){ + sql.append(" and t.childfieldid < ").append(StringUtil.vString(map.get("end_childfieldid"))); + } + if(map.containsKey("sql_childfieldid")){ + sql.append(" " + StringUtil.vString(map.get("sql_childfieldid"))); + } + if(map.containsKey("imgheight")){ + sql.append(" and t.imgheight = ").append(StringUtil.vString(map.get("imgheight"))); + } + if(map.containsKey("begin_imgheight")){ + sql.append(" and t.imgheight >= ").append(StringUtil.vString(map.get("begin_imgheight"))); + } + if(map.containsKey("end_imgheight")){ + sql.append(" and t.imgheight < ").append(StringUtil.vString(map.get("end_imgheight"))); + } + if(map.containsKey("sql_imgheight")){ + sql.append(" " + StringUtil.vString(map.get("sql_imgheight"))); + } + if(map.containsKey("imgwidth")){ + sql.append(" and t.imgwidth = ").append(StringUtil.vString(map.get("imgwidth"))); + } + if(map.containsKey("begin_imgwidth")){ + sql.append(" and t.imgwidth >= ").append(StringUtil.vString(map.get("begin_imgwidth"))); + } + if(map.containsKey("end_imgwidth")){ + sql.append(" and t.imgwidth < ").append(StringUtil.vString(map.get("end_imgwidth"))); + } + if(map.containsKey("sql_imgwidth")){ + sql.append(" " + StringUtil.vString(map.get("sql_imgwidth"))); + } + if(map.containsKey("places")){ + sql.append(" and t.places = ").append(StringUtil.vString(map.get("places"))); + } + if(map.containsKey("begin_places")){ + sql.append(" and t.places >= ").append(StringUtil.vString(map.get("begin_places"))); + } + if(map.containsKey("end_places")){ + sql.append(" and t.places < ").append(StringUtil.vString(map.get("end_places"))); + } + if(map.containsKey("sql_places")){ + sql.append(" " + StringUtil.vString(map.get("sql_places"))); + } + if(map.containsKey("selectitem")){ + sql.append(" and t.selectitem = ").append(StringUtil.vString(map.get("selectitem"))); + } + if(map.containsKey("begin_selectitem")){ + sql.append(" and t.selectitem >= ").append(StringUtil.vString(map.get("begin_selectitem"))); + } + if(map.containsKey("end_selectitem")){ + sql.append(" and t.selectitem < ").append(StringUtil.vString(map.get("end_selectitem"))); + } + if(map.containsKey("sql_selectitem")){ + sql.append(" " + StringUtil.vString(map.get("sql_selectitem"))); + } + if(map.containsKey("linkfield")){ + sql.append(" and t.linkfield = ").append(StringUtil.vString(map.get("linkfield"))); + } + if(map.containsKey("begin_linkfield")){ + sql.append(" and t.linkfield >= ").append(StringUtil.vString(map.get("begin_linkfield"))); + } + if(map.containsKey("end_linkfield")){ + sql.append(" and t.linkfield < ").append(StringUtil.vString(map.get("end_linkfield"))); + } + if(map.containsKey("sql_linkfield")){ + sql.append(" " + StringUtil.vString(map.get("sql_linkfield"))); + } + if(map.containsKey("fieldname")){ + sql.append(" and t.fieldname = '").append(StringUtil.vString(map.get("fieldname"))).append("'"); + } + if(map.containsKey("like_fieldname")){ + sql.append(" and t.fieldname like '%").append(StringUtil.vString(map.get("like_fieldname"))).append("%'"); + } + if(map.containsKey("sql_fieldname")){ + sql.append(" " + StringUtil.vString(map.get("sql_fieldname"))); + } + if(map.containsKey("fielddbtype")){ + sql.append(" and t.fielddbtype = '").append(StringUtil.vString(map.get("fielddbtype"))).append("'"); + } + if(map.containsKey("like_fielddbtype")){ + sql.append(" and t.fielddbtype like '%").append(StringUtil.vString(map.get("like_fielddbtype"))).append("%'"); + } + if(map.containsKey("sql_fielddbtype")){ + sql.append(" " + StringUtil.vString(map.get("sql_fielddbtype"))); + } + if(map.containsKey("fieldhtmltype")){ + sql.append(" and t.fieldhtmltype = '").append(StringUtil.vString(map.get("fieldhtmltype"))).append("'"); + } + if(map.containsKey("like_fieldhtmltype")){ + sql.append(" and t.fieldhtmltype like '%").append(StringUtil.vString(map.get("like_fieldhtmltype"))).append("%'"); + } + if(map.containsKey("sql_fieldhtmltype")){ + sql.append(" " + StringUtil.vString(map.get("sql_fieldhtmltype"))); + } + if(map.containsKey("detailtable")){ + sql.append(" and t.detailtable = '").append(StringUtil.vString(map.get("detailtable"))).append("'"); + } + if(map.containsKey("like_detailtable")){ + sql.append(" and t.detailtable like '%").append(StringUtil.vString(map.get("like_detailtable"))).append("%'"); + } + if(map.containsKey("sql_detailtable")){ + sql.append(" " + StringUtil.vString(map.get("sql_detailtable"))); + } + if(map.containsKey("fromUser")){ + sql.append(" and t.fromUser = '").append(StringUtil.vString(map.get("fromUser"))).append("'"); + } + if(map.containsKey("like_fromUser")){ + sql.append(" and t.fromUser like '%").append(StringUtil.vString(map.get("like_fromUser"))).append("%'"); + } + if(map.containsKey("sql_fromUser")){ + sql.append(" " + StringUtil.vString(map.get("sql_fromUser"))); + } + if(map.containsKey("qfws")){ + sql.append(" and t.qfws = '").append(StringUtil.vString(map.get("qfws"))).append("'"); + } + if(map.containsKey("like_qfws")){ + sql.append(" and t.qfws like '%").append(StringUtil.vString(map.get("like_qfws"))).append("%'"); + } + if(map.containsKey("sql_qfws")){ + sql.append(" " + StringUtil.vString(map.get("sql_qfws"))); + } + if(map.containsKey("textheight2")){ + sql.append(" and t.textheight_2 = '").append(StringUtil.vString(map.get("textheight2"))).append("'"); + } + if(map.containsKey("like_textheight2")){ + sql.append(" and t.textheight_2 like '%").append(StringUtil.vString(map.get("like_textheight2"))).append("%'"); + } + if(map.containsKey("sql_textheight2")){ + sql.append(" " + StringUtil.vString(map.get("sql_textheight2"))); + } + if(map.containsKey("mfsql")){ + sql.append(" " + StringUtil.vString(map.get("mfsql"))); + } + if(map.containsKey("sqlorderby")){ + sql.append(" order by " + StringUtil.vString(map.get("sqlorderby"))); + }else{ + sql.append(" order by t.dsporder, t.id ").append(StringUtil.vString(map.get("sqlsortway")).length() > 0 ? StringUtil.vString(map.get("sqlsortway")) : "desc"); + } + RecordSet rs = new RecordSet(); + rs.executeSql(sql.toString()); + WorkflowBillfield bean = null; + while(rs.next()){ + bean = new WorkflowBillfield(); + bean.setId(StringUtil.parseToInt(rs.getString("id"))); + bean.setBillid(StringUtil.parseToInt(rs.getString("billid"))); + bean.setFieldname(StringUtil.vString(rs.getString("fieldname"))); + bean.setFieldlabel(StringUtil.parseToInt(rs.getString("fieldlabel"))); + bean.setLabelName(StringUtil.vString(rs.getString("labelname"))); + bean.setLanguageid(StringUtil.parseToInt(rs.getString("languageid"))); + bean.setFielddbtype(StringUtil.vString(rs.getString("fielddbtype"))); + bean.setFieldhtmltype(StringUtil.vString(rs.getString("fieldhtmltype"))); + bean.setType(StringUtil.parseToInt(rs.getString("type"))); + bean.setViewtype(StringUtil.parseToInt(rs.getString("viewtype"))); + bean.setDetailtable(StringUtil.vString(rs.getString("detailtable"))); + bean.setFromuser(StringUtil.vString(rs.getString("fromUser"))); + bean.setTextheight(StringUtil.parseToInt(rs.getString("textheight"))); + bean.setDsporder(StringUtil.parseToDouble(rs.getString("dsporder"))); + bean.setChildfieldid(StringUtil.parseToInt(rs.getString("childfieldid"))); + bean.setImgheight(StringUtil.parseToInt(rs.getString("imgheight"))); + bean.setImgwidth(StringUtil.parseToInt(rs.getString("imgwidth"))); + bean.setPlaces(StringUtil.parseToInt(rs.getString("places"))); + bean.setQfws(StringUtil.vString(rs.getString("qfws"))); + bean.setTextheight2(StringUtil.vString(rs.getString("textheight_2"))); + bean.setSelectitem(StringUtil.parseToInt(rs.getString("selectitem"))); + bean.setLinkfield(StringUtil.parseToInt(rs.getString("linkfield"))); + list.add(bean); + } + return list; + } + + public WorkflowBillfield get(Comparable id) { + return null; + } + + public void delete(Comparable id) {} + +} diff --git a/src/com/engine/kq/wfset/attendance/domain/HrmAttFlowType.java b/src/com/engine/kq/wfset/attendance/domain/HrmAttFlowType.java new file mode 100644 index 0000000..d2ed8ff --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/domain/HrmAttFlowType.java @@ -0,0 +1,33 @@ +package com.engine.kq.wfset.attendance.domain; +/** + * HrmAttFlowType + *

Generated from 长东设计 www.mfstyle.cn

+ * + * @author wcd + * @version 1.0 2015-11-17 + */ +public enum HrmAttFlowType { + LEAVE(0, "leave"), + EVECTION(1, "evection"), + OUT(2, "outDays"), + OVERTIME(3, "overTimes"), + OTHER(4, "other"), + SCHEDULE(5, "schedule"); + + private int type; + + private String name; + + private HrmAttFlowType(int type, String name) { + this.type = type; + this.name = name; + } + + public int getType() { + return this.type; + } + + public String getName() { + return this.name; + } +} diff --git a/src/com/engine/kq/wfset/attendance/domain/HrmAttFlowVersion.java b/src/com/engine/kq/wfset/attendance/domain/HrmAttFlowVersion.java new file mode 100644 index 0000000..c88257d --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/domain/HrmAttFlowVersion.java @@ -0,0 +1,93 @@ +package com.engine.kq.wfset.attendance.domain; + +import weaver.common.StringUtil; +import com.engine.kq.wfset.attendance.framework.BaseEntity; +/** + * 考勤流程版本 + *

Generated from 长东设计1.0.9 http://www.mfstyle.cn

+ * + * @author wcd + * @version 1.0 2016-05-31 + */ +public class HrmAttFlowVersion extends BaseEntity { + + private static final long serialVersionUID = 1L; + /** + * 历史版本流程id + */ + private String field001; + /** + * 存为新版本流程的流程id + */ + private String field002; + private HrmAttFlowType type; + + public HrmAttFlowVersion() { + super(); + } + + public HrmAttFlowVersion(boolean arg) { + super(arg); + } + + public HrmAttFlowVersion(String workflowId, String newWfId) { + this.field001 = StringUtil.vString(workflowId); + this.field002 = StringUtil.vString(newWfId); + } + + public enum HrmAttFlowType { + ATT_PROC, + STATE_PROC + } + + protected void init() { + this.field001 = ""; + this.field002 = ""; + } + + public void setField001(String field001) { + this.field001 = field001; + } + + public String getField001() { + return field001; + } + + public void setField002(String field002) { + this.field002 = field002; + } + + public String getField002() { + return field002; + } + + public HrmAttFlowType getType() { + return type; + } + + public void setType(HrmAttFlowType type) { + this.type = type; + } + + public HrmAttFlowVersion toAttProc() { + this.type = HrmAttFlowType.ATT_PROC; + return this; + } + + public HrmAttFlowVersion toStateProc() { + this.type = HrmAttFlowType.STATE_PROC; + return this; + } + + public boolean isError() { + return StringUtil.parseToInt(field001) <= 0 || StringUtil.parseToInt(field002) <= 0; + } + + public String getSql() { + return new StringBuffer("select ") + .append("'").append(field001).append("',") + .append("'").append(field002).append("'") + .toString(); + } + +} diff --git a/src/com/engine/kq/wfset/attendance/domain/HrmAttProcAction.java b/src/com/engine/kq/wfset/attendance/domain/HrmAttProcAction.java new file mode 100644 index 0000000..92b8cfc --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/domain/HrmAttProcAction.java @@ -0,0 +1,170 @@ +package com.engine.kq.wfset.attendance.domain; + +/** + * 考勤流程动作设置 + * @author wcd + * @version 1.0 2015-04-27 + */ +public class HrmAttProcAction { + + private Long id; + /** + * 对应kq_ATT_PROC_SET的field006字段,即考勤流程类型 + */ + private Long mfid; + /** + * 对应kq_ATT_PROC_SET的id字段,-1表示默认的action + */ + private Long field001; + /** + * action名称 + */ + private String field002; + /** + * labelname + */ + private String field003; + private Integer field004; + /** + * 0出口附加规则,1节点后附加操作,2节点前附加操作 + */ + private Integer field005; + /** + * 节点id + */ + private String field006; + /** + * 节点名称 + */ + private String field006Name; + /** + * 退回时触发,1表示是 + */ + private Integer field007; + private Integer field008; + + public HrmAttProcAction() { + this(true); + } + + public HrmAttProcAction(boolean arg) { + if(arg) init(); + } + + public void init() { + this.id = 0L; + this.mfid = java.util.UUID.randomUUID().getMostSignificantBits(); + this.field001 = 0L; + this.field002 = ""; + this.field003 = ""; + this.field004 = 0; + this.field005 = 0; + this.field006 = "-1"; + this.field006Name = ""; + this.field007 = 0; + this.field008 = 0; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setMfid(Long mfid) { + this.mfid = mfid; + } + + public Long getMfid() { + return mfid; + } + + public void setField001(Long field001) { + this.field001 = field001; + } + + public Long getField001() { + return field001; + } + + public void setField002(String field002) { + this.field002 = field002; + } + + public String getField002() { + return field002; + } + + public void setField003(String field003) { + this.field003 = field003; + } + + public String getField003() { + return field003; + } + + public void setField004(Integer field004) { + this.field004 = field004; + } + + public Integer getField004() { + return field004; + } + + public void setField005(Integer field005) { + this.field005 = field005; + } + + public Integer getField005() { + return field005; + } + + public void setField006(String field006) { + this.field006 = field006; + } + + public String getField006() { + return field006; + } + + public String getField006Name() { + return field006Name; + } + + public void setField006Name(String field006Name) { + this.field006Name = field006Name; + } + + public void setField007(Integer field007) { + this.field007 = field007; + } + + public Integer getField007() { + return field007; + } + + public Integer getField008() { + return field008; + } + + public void setField008(Integer field008) { + this.field008 = field008; + } + + public String getSql() { + return new StringBuffer("select ") + .append(mfid).append(",") + .append(field001).append(",") + .append("'").append(field002).append("',") + .append("'").append(field003).append("',") + .append(field004).append(",") + .append(field005).append(",") + .append("'").append(field006).append("',") + .append(field007).append(",") + .append(field008) + .toString(); + } + +} diff --git a/src/com/engine/kq/wfset/attendance/domain/HrmAttProcFields.java b/src/com/engine/kq/wfset/attendance/domain/HrmAttProcFields.java new file mode 100644 index 0000000..0f51d91 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/domain/HrmAttProcFields.java @@ -0,0 +1,227 @@ +package com.engine.kq.wfset.attendance.domain; + + +/** + * 考勤字段对应基础信息 + * @author wcd + * @version 1.0 2015-04-24 + */ +public class HrmAttProcFields { + + private Long id; + private Long mfid; + private String labelName; + private Integer languageid; + private Integer field001; + private String field002; + private String field003; + private String field004; + private Integer field005; + private Integer field006; + private Integer field007; + private String field008; + private Double field009; + private Integer field010; + + public HrmAttProcFields() { + this(true); + } + + public HrmAttProcFields(boolean arg) { + if(arg) init(); + } + + public void init() { + this.id = 0L; + this.mfid = 0L; + this.labelName = ""; + this.languageid = 7; + this.field001 = 0; + this.field002 = ""; + this.field003 = ""; + this.field004 = ""; + this.field005 = 0; + this.field006 = 0; + this.field007 = 0; + this.field008 = ""; + this.field009 = 0.00; + this.field010 = 0; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setMfid(Long mfid) { + this.mfid = mfid; + } + + public Long getMfid() { + return mfid; + } + + public void setField001(Integer field001) { + this.field001 = field001; + } + + public Integer getField001() { + return field001; + } + + public void setField002(String field002) { + this.field002 = field002; + } + + public String getField002() { + return field002; + } + + public void setField003(String field003) { + this.field003 = field003; + } + + public String getField003() { + return field003; + } + + public void setField004(String field004) { + this.field004 = field004; + } + + public String getField004() { + return field004; + } + + public void setField005(Integer field005) { + this.field005 = field005; + } + + public Integer getField005() { + return field005; + } + + public void setField006(Integer field006) { + this.field006 = field006; + } + + public Integer getField006() { + return field006; + } + + public void setField007(Integer field007) { + this.field007 = field007; + } + + public Integer getField007() { + return field007; + } + + public void setField008(String field008) { + this.field008 = field008; + } + + public String getField008() { + return field008; + } + + public void setField009(Double field009) { + this.field009 = field009; + } + + public Double getField009() { + return field009; + } + + public void setField010(Integer field010) { + this.field010 = field010; + } + + public Integer getField010() { + return field010; + } + + public String getField005Title(){ + String title = ""; + switch (field005) { + case 1: + switch (field006) { + case 2: + title = "696"; + break; + case 3: + title = "697"; + break; + default : + title = "688"; + break; + } + break; + case 2: + title = "689"; + break; + case 3: + title = getField006Description(); + break; + case 4: + title = "691"; + break; + case 5: + if(this.field002.equals("otype")) { + title = "83955,690,81913,125804,125163,125805,81914"; + }else if(this.field002.equals("detail_signtype")){ + title = "83955,690,81913,21974,125163,21975,81914"; + }else if(this.field002.equals("changetype")){ + title = "83955,690,81913,19899,125163,16210,81914"; + }else if("overtime_type".equalsIgnoreCase(this.field002) || "detail_overtime_type".equalsIgnoreCase(this.field002)) { + title = "530091"; + }else if("repeat_type".equalsIgnoreCase(this.field002) || "detail_repeat_type".equalsIgnoreCase(this.field002)) { + title = "547084"; + break; + }else { + title = "690"; + } + break; + case 6: + title = "21691"; + break; + case 7: + title = "156"; + break; + } + return title; + } + + public String getField006Description() { + String result = ""; + String[] desc = {"","23189","97","779","23188","711","515","136","101","58", + "754","762","406","704","777","778","648","839","840","277", + "842","843","854","535","357","831","920","1932","2103","6099", + "818","804","6156","6159","1881","6160","6083","6163","6166","", + "","","","","","","","","","", + "","","","","","","","17006","",""}; + if(this.field001 == 5 && this.field002.equals("newShift") && this.field005 == 3) result = "125829"; + else if(this.field006 < desc.length && this.field006 >= 0) result = desc[this.field006]; + return result + (result.length() != 0 ? "," : "") + "695"; + } + + public String getLabelName() { + return labelName; + } + + public void setLabelName(String labelName) { + this.labelName = labelName; + } + + public Integer getLanguageid() { + return languageid; + } + + public void setLanguageid(Integer languageid) { + this.languageid = languageid; + } + +} diff --git a/src/com/engine/kq/wfset/attendance/domain/HrmAttProcRelation.java b/src/com/engine/kq/wfset/attendance/domain/HrmAttProcRelation.java new file mode 100644 index 0000000..b58d059 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/domain/HrmAttProcRelation.java @@ -0,0 +1,124 @@ +package com.engine.kq.wfset.attendance.domain; + +/** + * 字段对应配置 + * @author wcd + * @version 1.0 2015-04-24 + */ +public class HrmAttProcRelation { + + private Long id; + private Long mfid; + /** + * 对应hrm_att_proc_set的id字段 + */ + private Integer field001; + /** + * 对应hrm_att_proc_fields的id字段 + */ + private Integer field002; + /** + * 对应workflow_billfield的id字段 + */ + private Integer field003; + /** + * 对应workflow_billfield的fieldname字段 + */ + private String field004; + private Integer field005; + private String field006; + + public HrmAttProcRelation() { + this(true); + } + + public HrmAttProcRelation(boolean arg) { + if(arg) init(); + } + + public void init() { + this.id = 0L; + this.mfid = 0L; + this.field001 = 0; + this.field002 = 0; + this.field003 = 0; + this.field004 = ""; + this.field005 = 0; + this.field006 = ""; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setMfid(Long mfid) { + this.mfid = mfid; + } + + public Long getMfid() { + return mfid; + } + + public void setField001(Integer field001) { + this.field001 = field001; + } + + public Integer getField001() { + return field001; + } + + public void setField002(Integer field002) { + this.field002 = field002; + } + + public Integer getField002() { + return field002; + } + + public void setField003(Integer field003) { + this.field003 = field003; + } + + public Integer getField003() { + return field003; + } + + public void setField004(String field004) { + this.field004 = field004; + } + + public String getField004() { + return field004; + } + + public Integer getField005() { + return field005; + } + + public void setField005(Integer field005) { + this.field005 = field005; + } + + public String getField006() { + return field006; + } + + public void setField006(String field006) { + this.field006 = field006; + } + + public String getSql() { + return new StringBuffer("select ") + .append(mfid).append(",") + .append(field001).append(",") + .append(field002).append(",") + .append(field003).append(",") + .append("'").append(field004).append("'") + .toString(); + } + +} diff --git a/src/com/engine/kq/wfset/attendance/domain/HrmAttProcSet.java b/src/com/engine/kq/wfset/attendance/domain/HrmAttProcSet.java new file mode 100644 index 0000000..d80dc36 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/domain/HrmAttProcSet.java @@ -0,0 +1,371 @@ +package com.engine.kq.wfset.attendance.domain; + + + +/** + * 考勤流程设置 + * @author wcd + * @version 1.0 2015-04-22 + */ +public class HrmAttProcSet { + + private Long id; + /** + * 唯一标识,插入后查询用 + */ + private Long mfid; + /** + * 流程id + */ + private Integer field001; + /** + * 对应表单 + */ + private Integer field002; + /** + * 表单类型,1表示系统表单 + */ + private Integer field003; + /** + * 所属分部 + */ + private Integer field004; + /** + * 是否启用,1表示启用 + */ + private Integer field005; + /** + * 变更流程类型,0表示请假,1表示出差,2表示公出,3表示加班,4表示异常,5表示调班,6表示销假,7表示补卡 + */ + private Integer field006; + /** + * 操作日期 + */ + private Integer field007; + /** + * 操作日期 + */ + private String field008; + private String field009; + private String field010; + private String field011; + private String field012; + private String field013; + private Integer field014; + private Integer field015; + private Integer formid; + private String tablename; + private boolean isHAF; + private Integer isHalfDay; + /** + * 是否启用明细表,默认不启用,1表示启用 + */ + private Integer usedetail; + private String detailtablename; + /** + * 模板文件 + */ + private String templetfile; + /** + * 模板文件手机端 + */ + private String templetmobilefile; + /** + * 模板地址 + */ + private String templetroute; + /** + * 流程可抵扣打卡記錄,默认不启用,1表示启用 + */ + private Integer flow_deduct_card; + + public HrmAttProcSet() { + this(true); + } + + public HrmAttProcSet(boolean arg) { + if(arg) init(); + } + + public void init() { + this.id = 0L; + this.field001 = 0; + this.field002 = 0; + this.field003 = 0; + this.field004 = 0; + this.field005 = -1; + this.field006 = -1; + this.field007 = 0; + this.field008 = ""; + this.field009 = ""; + this.field010 = ""; + this.field011 = ""; + this.field012 = ""; + this.field013 = ""; + this.field014 = 0; + this.field015 = 0; + this.isHalfDay = 0; + this.mfid = java.util.UUID.randomUUID().getMostSignificantBits(); + this.formid = 0; + this.tablename = ""; + this.usedetail = 0; + this.flow_deduct_card = 0; + this.templetfile = ""; + this.templetmobilefile = ""; + this.templetroute = ""; + } + + public Long getMfid() { + return mfid; + } + + public void setMfid(Long mfid) { + this.mfid = mfid; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public Integer getBillId(){ + int billid = 0; + switch (this.field006){ + case 0: + billid = 180; + break; + case 1: + billid = 181; + break; + case 2: + billid = 182; + break; + case 3: + billid = 45; + break; + case 4: + billid = 0; + break; + case 5: + billid = 5; + break; + case 6: + billid = 6; + break; + case 7: + billid = 7; + break; + case 8: + billid = 8; + break; + } + return billid; + } + + public boolean isSysForm() { + return this.getField002() == 180 || this.getField002() == 181 || this.getField002() == 182; + } + + public void setField001(Integer field001) { + this.field001 = field001; + } + + public Integer getField001() { + return field001; + } + + public void setField002(Integer field002) { + this.field002 = field002; + } + + public Integer getField002() { + return field002; + } + + public void setField003(Integer field003) { + this.field003 = field003; + } + + public Integer getField003() { + return field003; + } + + public void setField004(Integer field004) { + this.field004 = field004; + } + + public Integer getField004() { + return field004; + } + + public void setField005(Integer field005) { + this.field005 = field005; + } + + public Integer getField005() { + return field005; + } + + public void setField006(Integer field006) { + this.field006 = field006; + } + + public Integer getField006() { + return field006; + } + + public void setField007(Integer field007) { + this.field007 = field007; + } + + public Integer getField007() { + return field007; + } + + public void setField008(String field008) { + this.field008 = field008; + } + + public String getField008() { + return field008; + } + + public void setField009(String field009) { + this.field009 = field009; + } + + public String getField009() { + return field009; + } + + public void setField010(String field010) { + this.field010 = field010; + } + + public String getField010() { + return field010; + } + + public void setField011(String field011) { + this.field011 = field011; + } + + public String getField011() { + return field011; + } + + public void setField012(String field012) { + this.field012 = field012; + } + + public String getField012() { + return field012; + } + + public void setField013(String field013) { + this.field013 = field013; + } + + public String getField013() { + return field013; + } + + public void setField014(Integer field014) { + this.field014 = field014; + } + + public Integer getField014() { + return field014; + } + + public void setField015(Integer field015) { + this.field015 = field015; + } + + public Integer getField015() { + return field015; + } + + public Integer getFormid() { + return formid; + } + + public void setFormid(Integer formid) { + this.formid = formid; + } + + public String getTablename() { + return tablename; + } + + public void setTablename(String tablename) { + this.tablename = tablename; + } + + public boolean isHAF() { + return isHAF; + } + + public void setHAF(boolean isHAF) { + this.isHAF = isHAF; + } + + public Integer getIsHalfDay() { + return isHalfDay; + } + + public void setIsHalfDay(Integer isHalfDay) { + this.isHalfDay = isHalfDay; + } + + public Integer getUsedetail() { + return usedetail; + } + + public void setUsedetail(Integer usedetail) { + this.usedetail = usedetail; + } + + public String getDetailtablename() { + return detailtablename; + } + + public void setDetailtablename(String detailtablename) { + this.detailtablename = detailtablename; + } + + public String getTempletfile() { + return templetfile; + } + + public void setTempletfile(String templetfile) { + this.templetfile = templetfile; + } + + public String getTempletmobilefile() { + return templetmobilefile; + } + + public void setTempletmobilefile(String templetmobilefile) { + this.templetmobilefile = templetmobilefile; + } + + public String getTempletroute() { + return templetroute; + } + + public void setTempletroute(String templetroute) { + this.templetroute = templetroute; + } + + public Integer getFlow_deduct_card() { + return flow_deduct_card; + } + + public void setFlow_deduct_card(Integer flow_deduct_card) { + this.flow_deduct_card = flow_deduct_card; + } +} diff --git a/src/com/engine/kq/wfset/attendance/domain/WorkflowBase.java b/src/com/engine/kq/wfset/attendance/domain/WorkflowBase.java new file mode 100644 index 0000000..7dbfbe4 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/domain/WorkflowBase.java @@ -0,0 +1,1101 @@ +package com.engine.kq.wfset.attendance.domain; + +/** + * 流程基本信息 + *

Generated from 长东设计 www.mfstyle.cn

+ * + * @author wcd + * @version 1.0 2015-09-10 + */ +public class WorkflowBase { + + //id + private Integer id; + //工作流名称 + private String workflowname; + //工作流描述 + private String workflowdesc; + //工作流种类 + private Integer workflowtype; + //安全级别 + private String securelevel; + //表单或单据ID + private Integer formid; + //创建人 + private Integer userid; + //单据或表单 + private String isbill; + //是否为门户工作流 + private Integer iscust; + //工作流帮助文档ID + private Integer helpdocid; + //是否有效 + private String isvalid; + //是否需要编号 + private String needmark; + //是否短信提醒 + private Integer messagetype; + //是否批量提交 + private Integer multisubmit; + //是否默认说明 + private Integer defaultname; + //附件上传目录名称 + private String docpath; + //分部id + private Integer subcompanyid; + //是否邮件提醒 + private Integer mailmessagetype; + //是否跟随文档关联人赋权 + private Integer docrightbyoperator; + //附件上传目录id + private String doccategory; + //是否为流程模板 + private String istemplate; + //流程引用模板id + private Integer templateid; + //catelogType + private Integer catelogtype; + //selectedCateLog + private Integer selectedcatelog; + //docRightByHrmResource + private Integer docrightbyhrmresource; + //是否需要提交确认 + private String needaffirmance; + //是否允许已办及办结事宜转发 + private String isremarks; + //isannexUpload + private String isannexupload; + //annexdoccategory + private String annexdoccategory; + //1:是,0或其它:否。该字段目前为鄂尔多斯数据中心专用 + private String isshowonreportinput; + //titleFieldId + private Integer titlefieldid; + //keywordFieldId + private Integer keywordfieldid; + //提交流程后是否显示流程图 + private String isshowchart; + //流程审批意见显示顺序 + private String orderbytype; + //是否触发不同流程 + private String istridiffworkflow; + //是否记录表单修改日志 + private String ismodifylog; + //是否保留正文版本 + private String ifversion; + //wfdocpath + private String wfdocpath; + //wfdocowner + private String wfdocowner; + //isEdit + private String isedit; + //editor + private Integer editor; + //editdate + private String editdate; + //edittime + private String edittime; + //退回创建节点是否可删除 1:是;0或其它:否 + private String showdelbuttonbyreject; + //是否显示上传附件tab 1:是;其它:否 + private String showuploadtab; + //是否允许签字意见关联文档 1:是;其它:否 + private String issigndoc; + //是否显示相关文档TAB 1:是;其它:否 + private String showdoctab; + //是否允许签字意见关联流程 1:是;其它:否 + private String issignworkflow; + //showWorkflowTab + private String showworkflowtab; + //是否允许删除附件 1:允许 其它:不允许 + private String candelacc; + //是否允许转发人设置被转发人权限 1:允许 其它:不允许 + private String isforwardrights; + //新建时是否可导入流程 1:允许 + private String isimportwf; + //退回是否提醒 1:是 + private String isrejectremind; + //退回人是否可设置提醒节点 1:是 + private String ischangrejectnode; + //流程存为文档的文档所有者取值类型 1,指定人 2,取流程表单字段的值 + private Integer wfdocownertype; + //流程存为文档的文档所有者,如果取值与流程表单字段的值,指定字段ID + private Integer wfdocownerfieldid; + private String newdocpath; + //keepsign + private Integer keepsign; + //secCategoryId + private Integer seccategoryid; + //自定义页面 + private String custompage; + //相关流程意见不显示(1,不显示) + private Integer issignview; + //是否允许回退到任意节点 + private String isselectrejectnode; + //forbidAttDownload + private Integer forbidattdownload; + //isImportDetail + private String isimportdetail; + //是否特批件(1、是,其他为否) + private String specialapproval; + //特批件次数 + private Integer frequency; + //特批件周期 1、周 2、月 3、季度 4、半年5、年 + private String cycle; + //不需要同步的字段列表 + private String nosynfields; + //是否需要在删除文档的同时删除相关的附件,包括签字意见中的附件 + private String isneeddelacc; + //SAPSource + private String sapsource; + //isfnacontrol + private String isfnacontrol; + //fnanodeid + private String fnanodeid; + //fnadepartmentid + private String fnadepartmentid; + //smsAlertsType + private String smsalertstype; + //isSaveCheckForm + private String issavecheckform; + //archiveNoMsgAlert + private String archivenomsgalert; + //archiveNoMailAlert + private String archivenomailalert; + //isfnabudgetwf + private String isfnabudgetwf; + //forwardReceiveDef + private String forwardreceivedef; + //isWorkflowDoc + private Integer isworkflowdoc; + //officalType + private Integer officaltype; + //version + private Integer version; + //activeVersionID + private Integer activeversionid; + //versionDescription + private String versiondescription; + //VersionCreater + private Integer versioncreater; + //dsporder + private Integer dsporder; + //fieldNotImport + private String fieldnotimport; + //isfree + private String isfree; + //ecology_pinyin_search + private String ecologyPinyinSearch; + //chatsType + private Integer chatstype; + //chatsAlertType + private Integer chatsalerttype; + //notRemindifArchived + private Integer notremindifarchived; + //自定义页面4Emoble + private String custompage4emoble; + //isupdatetitle + private Integer isupdatetitle; + //isshared + private String isshared; + //ForwardingSMSalerts + private String forwardingsmsalerts; + //isoverrb + private String isoverrb; + //isoveriv + private String isoveriv; + + public WorkflowBase() { + this(true); + } + + public WorkflowBase(boolean arg) { + if(arg) init(); + } + + public void init() { + this.id = 0; + this.workflowname = ""; + this.workflowdesc = ""; + this.workflowtype = 0; + this.securelevel = ""; + this.formid = 0; + this.userid = 0; + this.isbill = ""; + this.iscust = 0; + this.helpdocid = 0; + this.isvalid = ""; + this.needmark = ""; + this.messagetype = 0; + this.multisubmit = 0; + this.defaultname = 0; + this.docpath = ""; + this.subcompanyid = 0; + this.mailmessagetype = 0; + this.docrightbyoperator = 0; + this.doccategory = ""; + this.istemplate = ""; + this.templateid = 0; + this.catelogtype = 0; + this.selectedcatelog = 0; + this.docrightbyhrmresource = 0; + this.needaffirmance = ""; + this.isremarks = ""; + this.isannexupload = ""; + this.annexdoccategory = ""; + this.isshowonreportinput = ""; + this.titlefieldid = 0; + this.keywordfieldid = 0; + this.isshowchart = ""; + this.orderbytype = ""; + this.istridiffworkflow = ""; + this.ismodifylog = ""; + this.ifversion = ""; + this.wfdocpath = ""; + this.wfdocowner = ""; + this.isedit = ""; + this.editor = 0; + this.editdate = ""; + this.edittime = ""; + this.showdelbuttonbyreject = ""; + this.showuploadtab = ""; + this.issigndoc = ""; + this.showdoctab = ""; + this.issignworkflow = ""; + this.showworkflowtab = ""; + this.candelacc = ""; + this.isforwardrights = ""; + this.isimportwf = ""; + this.isrejectremind = ""; + this.ischangrejectnode = ""; + this.wfdocownertype = 0; + this.wfdocownerfieldid = 0; + this.newdocpath = ""; + this.keepsign = 0; + this.seccategoryid = 0; + this.custompage = ""; + this.issignview = 0; + this.isselectrejectnode = ""; + this.forbidattdownload = 0; + this.isimportdetail = ""; + this.specialapproval = ""; + this.frequency = 0; + this.cycle = ""; + this.nosynfields = ""; + this.isneeddelacc = ""; + this.sapsource = ""; + this.isfnacontrol = ""; + this.fnanodeid = ""; + this.fnadepartmentid = ""; + this.smsalertstype = ""; + this.issavecheckform = ""; + this.archivenomsgalert = ""; + this.archivenomailalert = ""; + this.isfnabudgetwf = ""; + this.forwardreceivedef = ""; + this.isworkflowdoc = 0; + this.officaltype = 0; + this.version = 0; + this.activeversionid = 0; + this.versiondescription = ""; + this.versioncreater = 0; + this.dsporder = 0; + this.fieldnotimport = ""; + this.isfree = ""; + this.ecologyPinyinSearch = ""; + this.chatstype = 0; + this.chatsalerttype = 0; + this.notremindifarchived = 0; + this.custompage4emoble = ""; + this.isupdatetitle = 0; + this.isshared = ""; + this.forwardingsmsalerts = ""; + this.isoverrb = ""; + this.isoveriv = ""; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getId() { + return id; + } + + public void setWorkflowname(String workflowname) { + this.workflowname = workflowname; + } + + public String getWorkflowname() { + return workflowname; + } + + public void setWorkflowdesc(String workflowdesc) { + this.workflowdesc = workflowdesc; + } + + public String getWorkflowdesc() { + return workflowdesc; + } + + public void setWorkflowtype(Integer workflowtype) { + this.workflowtype = workflowtype; + } + + public Integer getWorkflowtype() { + return workflowtype; + } + + public void setSecurelevel(String securelevel) { + this.securelevel = securelevel; + } + + public String getSecurelevel() { + return securelevel; + } + + public void setFormid(Integer formid) { + this.formid = formid; + } + + public Integer getFormid() { + return formid; + } + + public void setUserid(Integer userid) { + this.userid = userid; + } + + public Integer getUserid() { + return userid; + } + + public void setIsbill(String isbill) { + this.isbill = isbill; + } + + public String getIsbill() { + return isbill; + } + + public void setIscust(Integer iscust) { + this.iscust = iscust; + } + + public Integer getIscust() { + return iscust; + } + + public void setHelpdocid(Integer helpdocid) { + this.helpdocid = helpdocid; + } + + public Integer getHelpdocid() { + return helpdocid; + } + + public void setIsvalid(String isvalid) { + this.isvalid = isvalid; + } + + public String getIsvalid() { + return isvalid; + } + + public void setNeedmark(String needmark) { + this.needmark = needmark; + } + + public String getNeedmark() { + return needmark; + } + + public void setMessagetype(Integer messagetype) { + this.messagetype = messagetype; + } + + public Integer getMessagetype() { + return messagetype; + } + + public void setMultisubmit(Integer multisubmit) { + this.multisubmit = multisubmit; + } + + public Integer getMultisubmit() { + return multisubmit; + } + + public void setDefaultname(Integer defaultname) { + this.defaultname = defaultname; + } + + public Integer getDefaultname() { + return defaultname; + } + + public void setDocpath(String docpath) { + this.docpath = docpath; + } + + public String getDocpath() { + return docpath; + } + + public void setSubcompanyid(Integer subcompanyid) { + this.subcompanyid = subcompanyid; + } + + public Integer getSubcompanyid() { + return subcompanyid; + } + + public void setMailmessagetype(Integer mailmessagetype) { + this.mailmessagetype = mailmessagetype; + } + + public Integer getMailmessagetype() { + return mailmessagetype; + } + + public void setDocrightbyoperator(Integer docrightbyoperator) { + this.docrightbyoperator = docrightbyoperator; + } + + public Integer getDocrightbyoperator() { + return docrightbyoperator; + } + + public void setDoccategory(String doccategory) { + this.doccategory = doccategory; + } + + public String getDoccategory() { + return doccategory; + } + + public void setIstemplate(String istemplate) { + this.istemplate = istemplate; + } + + public String getIstemplate() { + return istemplate; + } + + public void setTemplateid(Integer templateid) { + this.templateid = templateid; + } + + public Integer getTemplateid() { + return templateid; + } + + public void setCatelogtype(Integer catelogtype) { + this.catelogtype = catelogtype; + } + + public Integer getCatelogtype() { + return catelogtype; + } + + public void setSelectedcatelog(Integer selectedcatelog) { + this.selectedcatelog = selectedcatelog; + } + + public Integer getSelectedcatelog() { + return selectedcatelog; + } + + public void setDocrightbyhrmresource(Integer docrightbyhrmresource) { + this.docrightbyhrmresource = docrightbyhrmresource; + } + + public Integer getDocrightbyhrmresource() { + return docrightbyhrmresource; + } + + public void setNeedaffirmance(String needaffirmance) { + this.needaffirmance = needaffirmance; + } + + public String getNeedaffirmance() { + return needaffirmance; + } + + public void setIsremarks(String isremarks) { + this.isremarks = isremarks; + } + + public String getIsremarks() { + return isremarks; + } + + public void setIsannexupload(String isannexupload) { + this.isannexupload = isannexupload; + } + + public String getIsannexupload() { + return isannexupload; + } + + public void setAnnexdoccategory(String annexdoccategory) { + this.annexdoccategory = annexdoccategory; + } + + public String getAnnexdoccategory() { + return annexdoccategory; + } + + public void setIsshowonreportinput(String isshowonreportinput) { + this.isshowonreportinput = isshowonreportinput; + } + + public String getIsshowonreportinput() { + return isshowonreportinput; + } + + public void setTitlefieldid(Integer titlefieldid) { + this.titlefieldid = titlefieldid; + } + + public Integer getTitlefieldid() { + return titlefieldid; + } + + public void setKeywordfieldid(Integer keywordfieldid) { + this.keywordfieldid = keywordfieldid; + } + + public Integer getKeywordfieldid() { + return keywordfieldid; + } + + public void setIsshowchart(String isshowchart) { + this.isshowchart = isshowchart; + } + + public String getIsshowchart() { + return isshowchart; + } + + public void setOrderbytype(String orderbytype) { + this.orderbytype = orderbytype; + } + + public String getOrderbytype() { + return orderbytype; + } + + public void setIstridiffworkflow(String istridiffworkflow) { + this.istridiffworkflow = istridiffworkflow; + } + + public String getIstridiffworkflow() { + return istridiffworkflow; + } + + public void setIsmodifylog(String ismodifylog) { + this.ismodifylog = ismodifylog; + } + + public String getIsmodifylog() { + return ismodifylog; + } + + public void setIfversion(String ifversion) { + this.ifversion = ifversion; + } + + public String getIfversion() { + return ifversion; + } + + public void setWfdocpath(String wfdocpath) { + this.wfdocpath = wfdocpath; + } + + public String getWfdocpath() { + return wfdocpath; + } + + public void setWfdocowner(String wfdocowner) { + this.wfdocowner = wfdocowner; + } + + public String getWfdocowner() { + return wfdocowner; + } + + public void setIsedit(String isedit) { + this.isedit = isedit; + } + + public String getIsedit() { + return isedit; + } + + public void setEditor(Integer editor) { + this.editor = editor; + } + + public Integer getEditor() { + return editor; + } + + public void setEditdate(String editdate) { + this.editdate = editdate; + } + + public String getEditdate() { + return editdate; + } + + public void setEdittime(String edittime) { + this.edittime = edittime; + } + + public String getEdittime() { + return edittime; + } + + public void setShowdelbuttonbyreject(String showdelbuttonbyreject) { + this.showdelbuttonbyreject = showdelbuttonbyreject; + } + + public String getShowdelbuttonbyreject() { + return showdelbuttonbyreject; + } + + public void setShowuploadtab(String showuploadtab) { + this.showuploadtab = showuploadtab; + } + + public String getShowuploadtab() { + return showuploadtab; + } + + public void setIssigndoc(String issigndoc) { + this.issigndoc = issigndoc; + } + + public String getIssigndoc() { + return issigndoc; + } + + public void setShowdoctab(String showdoctab) { + this.showdoctab = showdoctab; + } + + public String getShowdoctab() { + return showdoctab; + } + + public void setIssignworkflow(String issignworkflow) { + this.issignworkflow = issignworkflow; + } + + public String getIssignworkflow() { + return issignworkflow; + } + + public void setShowworkflowtab(String showworkflowtab) { + this.showworkflowtab = showworkflowtab; + } + + public String getShowworkflowtab() { + return showworkflowtab; + } + + public void setCandelacc(String candelacc) { + this.candelacc = candelacc; + } + + public String getCandelacc() { + return candelacc; + } + + public void setIsforwardrights(String isforwardrights) { + this.isforwardrights = isforwardrights; + } + + public String getIsforwardrights() { + return isforwardrights; + } + + public void setIsimportwf(String isimportwf) { + this.isimportwf = isimportwf; + } + + public String getIsimportwf() { + return isimportwf; + } + + public void setIsrejectremind(String isrejectremind) { + this.isrejectremind = isrejectremind; + } + + public String getIsrejectremind() { + return isrejectremind; + } + + public void setIschangrejectnode(String ischangrejectnode) { + this.ischangrejectnode = ischangrejectnode; + } + + public String getIschangrejectnode() { + return ischangrejectnode; + } + + public void setWfdocownertype(Integer wfdocownertype) { + this.wfdocownertype = wfdocownertype; + } + + public Integer getWfdocownertype() { + return wfdocownertype; + } + + public void setWfdocownerfieldid(Integer wfdocownerfieldid) { + this.wfdocownerfieldid = wfdocownerfieldid; + } + + public Integer getWfdocownerfieldid() { + return wfdocownerfieldid; + } + + public void setNewdocpath(String newdocpath) { + this.newdocpath = newdocpath; + } + + public String getNewdocpath() { + return newdocpath; + } + + public void setKeepsign(Integer keepsign) { + this.keepsign = keepsign; + } + + public Integer getKeepsign() { + return keepsign; + } + + public void setSeccategoryid(Integer seccategoryid) { + this.seccategoryid = seccategoryid; + } + + public Integer getSeccategoryid() { + return seccategoryid; + } + + public void setCustompage(String custompage) { + this.custompage = custompage; + } + + public String getCustompage() { + return custompage; + } + + public void setIssignview(Integer issignview) { + this.issignview = issignview; + } + + public Integer getIssignview() { + return issignview; + } + + public void setIsselectrejectnode(String isselectrejectnode) { + this.isselectrejectnode = isselectrejectnode; + } + + public String getIsselectrejectnode() { + return isselectrejectnode; + } + + public void setForbidattdownload(Integer forbidattdownload) { + this.forbidattdownload = forbidattdownload; + } + + public Integer getForbidattdownload() { + return forbidattdownload; + } + + public void setIsimportdetail(String isimportdetail) { + this.isimportdetail = isimportdetail; + } + + public String getIsimportdetail() { + return isimportdetail; + } + + public void setSpecialapproval(String specialapproval) { + this.specialapproval = specialapproval; + } + + public String getSpecialapproval() { + return specialapproval; + } + + public void setFrequency(Integer frequency) { + this.frequency = frequency; + } + + public Integer getFrequency() { + return frequency; + } + + public void setCycle(String cycle) { + this.cycle = cycle; + } + + public String getCycle() { + return cycle; + } + + public void setNosynfields(String nosynfields) { + this.nosynfields = nosynfields; + } + + public String getNosynfields() { + return nosynfields; + } + + public void setIsneeddelacc(String isneeddelacc) { + this.isneeddelacc = isneeddelacc; + } + + public String getIsneeddelacc() { + return isneeddelacc; + } + + public void setSapsource(String sapsource) { + this.sapsource = sapsource; + } + + public String getSapsource() { + return sapsource; + } + + public void setIsfnacontrol(String isfnacontrol) { + this.isfnacontrol = isfnacontrol; + } + + public String getIsfnacontrol() { + return isfnacontrol; + } + + public void setFnanodeid(String fnanodeid) { + this.fnanodeid = fnanodeid; + } + + public String getFnanodeid() { + return fnanodeid; + } + + public void setFnadepartmentid(String fnadepartmentid) { + this.fnadepartmentid = fnadepartmentid; + } + + public String getFnadepartmentid() { + return fnadepartmentid; + } + + public void setSmsalertstype(String smsalertstype) { + this.smsalertstype = smsalertstype; + } + + public String getSmsalertstype() { + return smsalertstype; + } + + public void setIssavecheckform(String issavecheckform) { + this.issavecheckform = issavecheckform; + } + + public String getIssavecheckform() { + return issavecheckform; + } + + public void setArchivenomsgalert(String archivenomsgalert) { + this.archivenomsgalert = archivenomsgalert; + } + + public String getArchivenomsgalert() { + return archivenomsgalert; + } + + public void setArchivenomailalert(String archivenomailalert) { + this.archivenomailalert = archivenomailalert; + } + + public String getArchivenomailalert() { + return archivenomailalert; + } + + public void setIsfnabudgetwf(String isfnabudgetwf) { + this.isfnabudgetwf = isfnabudgetwf; + } + + public String getIsfnabudgetwf() { + return isfnabudgetwf; + } + + public void setForwardreceivedef(String forwardreceivedef) { + this.forwardreceivedef = forwardreceivedef; + } + + public String getForwardreceivedef() { + return forwardreceivedef; + } + + public void setIsworkflowdoc(Integer isworkflowdoc) { + this.isworkflowdoc = isworkflowdoc; + } + + public Integer getIsworkflowdoc() { + return isworkflowdoc; + } + + public void setOfficaltype(Integer officaltype) { + this.officaltype = officaltype; + } + + public Integer getOfficaltype() { + return officaltype; + } + + public void setVersion(Integer version) { + this.version = version; + } + + public Integer getVersion() { + return version; + } + + public void setActiveversionid(Integer activeversionid) { + this.activeversionid = activeversionid; + } + + public Integer getActiveversionid() { + return activeversionid; + } + + public void setVersiondescription(String versiondescription) { + this.versiondescription = versiondescription; + } + + public String getVersiondescription() { + return versiondescription; + } + + public void setVersioncreater(Integer versioncreater) { + this.versioncreater = versioncreater; + } + + public Integer getVersioncreater() { + return versioncreater; + } + + public void setDsporder(Integer dsporder) { + this.dsporder = dsporder; + } + + public Integer getDsporder() { + return dsporder; + } + + public void setFieldnotimport(String fieldnotimport) { + this.fieldnotimport = fieldnotimport; + } + + public String getFieldnotimport() { + return fieldnotimport; + } + + public void setIsfree(String isfree) { + this.isfree = isfree; + } + + public String getIsfree() { + return isfree; + } + + public void setEcologyPinyinSearch(String ecologyPinyinSearch) { + this.ecologyPinyinSearch = ecologyPinyinSearch; + } + + public String getEcologyPinyinSearch() { + return ecologyPinyinSearch; + } + + public void setChatstype(Integer chatstype) { + this.chatstype = chatstype; + } + + public Integer getChatstype() { + return chatstype; + } + + public void setChatsalerttype(Integer chatsalerttype) { + this.chatsalerttype = chatsalerttype; + } + + public Integer getChatsalerttype() { + return chatsalerttype; + } + + public void setNotremindifarchived(Integer notremindifarchived) { + this.notremindifarchived = notremindifarchived; + } + + public Integer getNotremindifarchived() { + return notremindifarchived; + } + + public void setCustompage4emoble(String custompage4emoble) { + this.custompage4emoble = custompage4emoble; + } + + public String getCustompage4emoble() { + return custompage4emoble; + } + + public void setIsupdatetitle(Integer isupdatetitle) { + this.isupdatetitle = isupdatetitle; + } + + public Integer getIsupdatetitle() { + return isupdatetitle; + } + + public void setIsshared(String isshared) { + this.isshared = isshared; + } + + public String getIsshared() { + return isshared; + } + + public void setForwardingsmsalerts(String forwardingsmsalerts) { + this.forwardingsmsalerts = forwardingsmsalerts; + } + + public String getForwardingsmsalerts() { + return forwardingsmsalerts; + } + + public void setIsoverrb(String isoverrb) { + this.isoverrb = isoverrb; + } + + public String getIsoverrb() { + return isoverrb; + } + + public void setIsoveriv(String isoveriv) { + this.isoveriv = isoveriv; + } + + public String getIsoveriv() { + return isoveriv; + } + +} diff --git a/src/com/engine/kq/wfset/attendance/domain/WorkflowBillfield.java b/src/com/engine/kq/wfset/attendance/domain/WorkflowBillfield.java new file mode 100644 index 0000000..2379fd2 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/domain/WorkflowBillfield.java @@ -0,0 +1,242 @@ +package com.engine.kq.wfset.attendance.domain; + +/** + * 流程表单字段 + * @author wcd + * @version 1.0 2015-04-24 + */ +public class WorkflowBillfield { + + private Integer id; + private Integer billid; + private String fieldname; + private Integer fieldlabel; + private String labelName; + private Integer languageid; + private String fielddbtype; + private String fieldhtmltype; + private Integer type; + private Integer viewtype; + private String detailtable; + private String fromuser; + private Integer textheight; + private Double dsporder; + private Integer childfieldid; + private Integer imgheight; + private Integer imgwidth; + private Integer places; + private String qfws; + private String textheight2; + private Integer selectitem; + private Integer linkfield; + + public WorkflowBillfield() { + this(true); + } + + public WorkflowBillfield(boolean arg) { + if(arg) init(); + } + + public void init() { + this.id = 0; + this.billid = 0; + this.fieldname = ""; + this.fieldlabel = 0; + this.labelName = ""; + this.languageid = 7; + this.fielddbtype = ""; + this.fieldhtmltype = ""; + this.type = 0; + this.viewtype = 0; + this.detailtable = ""; + this.fromuser = ""; + this.textheight = 0; + this.dsporder = 0.00; + this.childfieldid = 0; + this.imgheight = 0; + this.imgwidth = 0; + this.places = 0; + this.qfws = ""; + this.textheight2 = ""; + this.selectitem = 0; + this.linkfield = 0; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getId() { + return id; + } + + public void setBillid(Integer billid) { + this.billid = billid; + } + + public Integer getBillid() { + return billid; + } + + public void setFieldname(String fieldname) { + this.fieldname = fieldname; + } + + public String getFieldname() { + return fieldname; + } + + public void setFieldlabel(Integer fieldlabel) { + this.fieldlabel = fieldlabel; + } + + public Integer getFieldlabel() { + return fieldlabel; + } + + public void setFielddbtype(String fielddbtype) { + this.fielddbtype = fielddbtype; + } + + public String getFielddbtype() { + return fielddbtype; + } + + public void setFieldhtmltype(String fieldhtmltype) { + this.fieldhtmltype = fieldhtmltype; + } + + public String getFieldhtmltype() { + return fieldhtmltype; + } + + public void setType(Integer type) { + this.type = type; + } + + public Integer getType() { + return type; + } + + public void setViewtype(Integer viewtype) { + this.viewtype = viewtype; + } + + public Integer getViewtype() { + return viewtype; + } + + public void setDetailtable(String detailtable) { + this.detailtable = detailtable; + } + + public String getDetailtable() { + return detailtable; + } + + public void setFromuser(String fromuser) { + this.fromuser = fromuser; + } + + public String getFromuser() { + return fromuser; + } + + public void setTextheight(Integer textheight) { + this.textheight = textheight; + } + + public Integer getTextheight() { + return textheight; + } + + public void setDsporder(Double dsporder) { + this.dsporder = dsporder; + } + + public Double getDsporder() { + return dsporder; + } + + public void setChildfieldid(Integer childfieldid) { + this.childfieldid = childfieldid; + } + + public Integer getChildfieldid() { + return childfieldid; + } + + public void setImgheight(Integer imgheight) { + this.imgheight = imgheight; + } + + public Integer getImgheight() { + return imgheight; + } + + public void setImgwidth(Integer imgwidth) { + this.imgwidth = imgwidth; + } + + public Integer getImgwidth() { + return imgwidth; + } + + public void setPlaces(Integer places) { + this.places = places; + } + + public Integer getPlaces() { + return places; + } + + public void setQfws(String qfws) { + this.qfws = qfws; + } + + public String getQfws() { + return qfws; + } + + public void setTextheight2(String textheight2) { + this.textheight2 = textheight2; + } + + public String getTextheight2() { + return textheight2; + } + + public void setSelectitem(Integer selectitem) { + this.selectitem = selectitem; + } + + public Integer getSelectitem() { + return selectitem; + } + + public void setLinkfield(Integer linkfield) { + this.linkfield = linkfield; + } + + public Integer getLinkfield() { + return linkfield; + } + + public String getLabelName() { + return labelName; + } + + public void setLabelName(String labelName) { + this.labelName = labelName; + } + + public Integer getLanguageid() { + return languageid; + } + + public void setLanguageid(Integer languageid) { + this.languageid = languageid; + } + +} diff --git a/src/com/engine/kq/wfset/attendance/framework/BaseCache.java b/src/com/engine/kq/wfset/attendance/framework/BaseCache.java new file mode 100644 index 0000000..bda4703 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/framework/BaseCache.java @@ -0,0 +1,67 @@ +package com.engine.kq.wfset.attendance.framework; + +import java.util.ArrayList; +import java.util.List; +import weaver.general.BaseBean; +import weaver.general.StaticObj; + +/** + * + * @author wcd + * @version 1.0 2015-10-16 + */ +public abstract class BaseCache extends BaseBean { + protected StaticObj staticobj = null; + protected int current_index = -1; + protected List list = null; + protected static Object lock = new Object(); + + protected String cacheName; + + public BaseCache(String name) { + this.cacheName = name; + this.staticobj = StaticObj.getInstance(); + + this.init(); + } + + @SuppressWarnings("unchecked") + private void init() { + try{ + synchronized (lock) { + if (staticobj.getObject(cacheName) == null) setValue(); + list = (List) (staticobj.getRecordFromObj(cacheName, "list")); + if (list == null) setValue(); + } + } catch(Exception e){ + writeLog(e); + } + } + + private void setValue() throws Exception { + if(list != null) + list.clear(); + else + list = new ArrayList(); + + list.addAll(findResults()); + + staticobj.putRecordToObj(cacheName, "list", list); + } + + protected abstract List findResults(); + + public List getResult() { + return list == null ? new ArrayList() : list; + } + + public int length() { + return list == null ? 0 : list.size(); + } + + public void remove() { + if (staticobj.getObject(cacheName) != null) + staticobj.removeObject(cacheName); + } + +} diff --git a/src/com/engine/kq/wfset/attendance/framework/BaseConnection.java b/src/com/engine/kq/wfset/attendance/framework/BaseConnection.java new file mode 100644 index 0000000..3bb1674 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/framework/BaseConnection.java @@ -0,0 +1,180 @@ +package com.engine.kq.wfset.attendance.framework; + +import java.math.BigDecimal; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.common.StringUtil; +import weaver.conn.ConnectionPool; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; + +/** + * + * @author wcd + * @version 1.0 2015-05-15 + */ +public class BaseConnection extends BaseBean { + + protected String dbType = ""; + + protected static final String SQL_WHERE = " where"; + + protected static final String SQL_AND = " and"; + + public BaseConnection() { + RecordSet rs = new RecordSet(); + this.dbType = rs.getDBType(); + } + + public boolean isOracle() { + return this.dbType.equalsIgnoreCase("oracle"); + } + + public boolean isSqlServer() { + return this.dbType.equalsIgnoreCase("sqlserver"); + } + + public List> executeQuery(String sql) { + return executeQuery(sql, ConnectionPool.getInstance().getConnection()); + } + + public List> executeQuery(String sql, Connection conn) { + PreparedStatement psmt = null; + ResultSet rs = null; + + List> result = new ArrayList>(); + if(conn == null) return result; + try { + psmt = conn.prepareStatement(sql); + rs = psmt.executeQuery(); + List columnNames = new ArrayList(); + ResultSetMetaData rsMetaData = rs.getMetaData(); + int columnCount = rsMetaData.getColumnCount(); + for (int i = 0; i < columnCount; ++i) columnNames.add(rsMetaData.getColumnName(i+1)); + Map columnMap = null; + while (rs.next()){ + columnMap = new HashMap(); + for (String name : columnNames) columnMap.put(name, rs.getObject(name)); + result.add(columnMap); + } + } catch (SQLException e) { + writeLog(e); + } finally { + close(rs, psmt, conn); + } + return result; + } + + public void executeUpdate(String sql){ + executeUpdate(sql, ConnectionPool.getInstance().getConnection(), new Object[]{}); + } + + public void executeUpdate(String sql, Connection conn, Object... obj){ + if(conn == null) return; + PreparedStatement psmt = null; + try { + psmt = initPreparedStatement(conn.prepareStatement(sql), obj); + psmt.executeUpdate(); + } catch (SQLException e) { + writeLog(e); + } finally { + close(null, psmt, conn); + } + } + + private PreparedStatement initPreparedStatement(PreparedStatement ps, Object... obj) { + if(obj == null) return ps; + try { + int i = 1; + for (Object param : obj) { + if (param instanceof Integer) { + ps.setInt(i, StringUtil.parseToInt("" + param)); + } else if (param instanceof Long) { + ps.setLong(i, StringUtil.parseToLong("" + param)); + } else if ((param instanceof Float)) { + ps.setFloat(i, StringUtil.parseToFloat("" + param)); + } else if ((param instanceof Double)) { + ps.setDouble(i, StringUtil.parseToDouble("" + param)); + } else if (param instanceof BigDecimal) { + ps.setBigDecimal(i, (param instanceof BigDecimal) ? (BigDecimal) param : new BigDecimal(StringUtil.parseToDouble("" + param))); + } else if ((param instanceof java.sql.Date)) { + ps.setDate(i, (java.sql.Date) param); + } else if (((param instanceof String)) || ((param instanceof Character))) { + ps.setString(i, "" + param); + } else if (param == null) { + ps.setNull(i, 0); + } else if ((param instanceof Clob)) { + ps.setClob(i, (Clob) param); + } else if ((param instanceof Blob)) { + ps.setBlob(i, (Blob) param); + } else { + ps.setObject(i, param); + } + i++; + } + } catch (Exception e) { + } + return ps; + } + + public boolean executeSql(String sql) { + RecordSet rs = new RecordSet(); + return rs.executeQuery(sql, new Object[]{}); + } + + private void close(ResultSet rs, PreparedStatement pstmt, Connection conn){ + if(conn != null) try {conn.close();} catch (SQLException e) {} + if(pstmt != null) try {pstmt.close();} catch (SQLException e) {} + if(rs != null) try {rs.close();} catch (SQLException e) {} + } + + protected String getJoinStr(String str) { + return str.equals(SQL_WHERE) ? SQL_AND : str; + } + + /** + * Oracle环境下 in 条件超过1000个即报错,所以选用in时,统一调用此方法 + * @param ids + * @param fieldname 字段名 + * @return + */ + protected static String getSQLIn(String ids, String fieldname) { + if (StringUtil.isNull(ids)) return ""; + + String[] id = StringUtil.split(ids, ","); + int len = id.length; + if (len < 1000) return "and " + fieldname + " in (" + ids + ")"; + + int count = 1000; + int size = len % count; + if (size == 0) { + size = len / count; + } else { + size = (len / count) + 1; + } + + StringBuilder builder = new StringBuilder(); + List ls = Arrays.asList(id); + for (int i = 0; i < size; i++) { + int fromIndex = i * count; + int toIndex = Math.min(fromIndex + count, len); + List tmpls = ls.subList(fromIndex, toIndex); + if (i != 0) + builder.append(" or "); + builder.append(fieldname + " in (").append( + tmpls.toString().replace("[", "").replace("]", "")).append( + ")"); + } + return "and (" + builder.toString() + ")"; + } +} diff --git a/src/com/engine/kq/wfset/attendance/framework/BaseController.java b/src/com/engine/kq/wfset/attendance/framework/BaseController.java new file mode 100644 index 0000000..f91e642 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/framework/BaseController.java @@ -0,0 +1,407 @@ +package com.engine.kq.wfset.attendance.framework; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.text.DateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.IOUtils; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFDataFormat; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.json.JSONObject; +import weaver.common.DateUtil; +import weaver.common.FileUtil; +import weaver.common.StringUtil; +import weaver.file.MyMultiPartHelper; +import weaver.general.BaseBean; +import weaver.hrm.common.SplitPageTagFormat; + +/** + * + * @author wcd + * @version 1.0 2014-11-18 + */ +public class BaseController extends BaseBean { + private BaseManager manager; + + private String separator; + + private String rootPath; + + private String appresPath; + + private Hashtable multiData; + + private static final int B = 8 * 1024; + + private static final String SUFFIX = ".xls"; + + private static final String ENCODING = "UTF-8"; + + protected SplitPageTagFormat format; + + public BaseController() { + this.separator = File.separator; + this.multiData = new Hashtable(); + this.rootPath = weaver.general.GCONST.getRootPath(); + this.appresPath = this.rootPath + "appres" + separator; + this.format = new SplitPageTagFormat(); + } + + public BaseManager getManager() { + return manager; + } + + public void setManager(BaseManager manager) { + this.manager = manager; + } + + public String getRootPath() { + return rootPath; + } + + public String getAppresPath() { + return appresPath; + } + + public JSONObject handle(HttpServletRequest request, HttpServletResponse response) throws Exception { + String filePath = StringUtil.getURLDecode(request.getParameter("thumbnailFilePath")); + if(StringUtil.isNotNull(filePath)) { + if(!filePath.startsWith("http")) { + filePath = (filePath.startsWith("/") ? "" : "/") + filePath.replaceAll("\\\\","/"); + } + response.sendRedirect(filePath); + } + return new JSONObject(); + } + + protected void upload(HttpServletRequest request, HttpServletResponse response, String filePath) throws IOException { + this.multiData = getMultiData(request); + File file = uploadFile(filePath); + if(file != null && file.isFile()) { + this.readFile(file); + this.delFile(file); + } + this.closeWindow(response); + } + + private Hashtable getMultiData(HttpServletRequest request) { + Hashtable result = null; + int contentLength = request.getContentLength(); + String contentType = StringUtil.vString(request.getContentType()); + if(contentType.toLowerCase().startsWith("multipart/form-data")) { + MyMultiPartHelper multiHelper = new MyMultiPartHelper(); + String boundary = "--" + multiHelper.getBoundary(contentType); + try {result = multiHelper.parseMultiPart(request.getInputStream(), boundary, contentLength);} catch (Exception e) {} + } + return result; + } + + private File uploadFile(String filePath) { + Hashtable attachment = multiData == null ? null : (Hashtable)multiData.get("filePath"); + File tempFile = null; + if(attachment != null) { + if(StringUtil.isNotNull((String)attachment.get("filename"))) { + filePath = this.appresPath + filePath + separator + "upload" + separator; + FileUtil.mkDir(filePath) ; + tempFile = new File(filePath + java.util.UUID.randomUUID().getMostSignificantBits() + SUFFIX); + + FileOutputStream out = null; + ByteArrayInputStream in = null; + Object content = attachment.get("content") ; + try { + in = (content instanceof String) ? new ByteArrayInputStream(((String)content).getBytes("ISO-8859-1")) : (ByteArrayInputStream)content; + } catch (Exception e) { + in = (content instanceof String) ? new ByteArrayInputStream(((String)content).getBytes()) : (ByteArrayInputStream)content; + } + try { + out = new FileOutputStream(tempFile); + byte temp[] = new byte[B]; + int count = 0; + while ((count = in.read(temp)) > 0) out.write(temp, 0, count); + } catch(Exception e) { + writeLog(e); + } finally { + IOUtils.closeQuietly(in); + IOUtils.closeQuietly(out); + } + } + } + return tempFile; + } + + private void readFile(File file) { + InputStream in = null; + try { + in = new FileInputStream(file); + HSSFWorkbook wb = new HSSFWorkbook(new POIFSFileSystem(in)); + HSSFSheet sheet = wb.getSheetAt(0); + HSSFRow row = null; + for (int i = 0; i < sheet.getLastRowNum(); i++) { + row = sheet.getRow(i+1); + saveBean(row); + } + } catch (Exception e) { + writeLog(e); + } finally { + IOUtils.closeQuietly((FileInputStream)in); + } + } + + private void delFile (final File file) { + new Thread(new Runnable() { + public void run() { + try { + Thread.sleep(100); + file.delete(); + } catch (InterruptedException e) { + } + } + }).start(); + } + + protected String getCellValue(HSSFCell cell) { + String cellValue = ""; + switch (cell.getCellType()) { + case NUMERIC: + if (HSSFDateUtil.isCellDateFormatted(cell)) { + Date date = cell.getDateCellValue(); + if (cell.getCellStyle().getDataFormat() == HSSFDataFormat.getBuiltinFormat("h:mm:ss")) { + cellValue = DateUtil.getDate(date, "HH:mm:ss"); + } else { + cellValue = DateUtil.getDate(date); + } + } else { + cellValue = StringUtil.vString(cell.getNumericCellValue()); + } + break; + case STRING: + cellValue = StringUtil.vString(cell.getStringCellValue()); + break; + case FORMULA: + cellValue = StringUtil.vString(DateFormat.getDateInstance().format((cell.getDateCellValue()))); + break; + } + return cellValue; + } + + protected void download(HttpServletRequest request, HttpServletResponse response, String filePath, String fileName, String downName) { + if(request == null || response == null || StringUtil.isNull(filePath) || StringUtil.isNull(fileName)) return; + filePath = this.appresPath + filePath + separator + "download" + separator; + fileName = fileName.endsWith(SUFFIX) ? fileName : (fileName + SUFFIX); + downName = downName.endsWith(SUFFIX) ? downName : (downName + SUFFIX); + + File file = new File(filePath + fileName); + if(!file.isFile()) return; + + InputStream in = null; + ServletOutputStream out = null; + try { + in = new FileInputStream(file); + out = response.getOutputStream(); + initOut(request, response, downName); + response.setContentLength((int)file.length()); + + int count = 0; + byte[] temp = new byte[B]; + while ((count = in.read(temp)) >= 0) out.write(temp, 0, count); + out.flush(); + } catch(Exception e) { + writeLog(e); + } finally { + IOUtils.closeQuietly((FileInputStream)in); + IOUtils.closeQuietly(out); + } + } + + private HSSFCellStyle createStyle(HSSFWorkbook wb, int type) { + HSSFCellStyle style = wb.createCellStyle(); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setAlignment(HorizontalAlignment.CENTER); + style.setWrapText(true); + style.setBorderTop(BorderStyle.THIN); + style.setBorderRight(BorderStyle.THIN); + style.setBorderBottom(BorderStyle.THIN); + style.setBorderLeft(BorderStyle.THIN); + + HSSFFont font = null; + switch(type) { + case 0: + font = wb.createFont(); + font.setBold(true); + font.setFontHeightInPoints((short) 15); + style.setAlignment(HorizontalAlignment.CENTER); + style.setFont(font); + break; + case 1: + font = wb.createFont(); + font.setBold(true); + style.setFillPattern( FillPatternType.SOLID_FOREGROUND); + style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index); + style.setFillBackgroundColor(IndexedColors.WHITE.index); + style.setAlignment(HorizontalAlignment.CENTER); + style.setFont(font); + break; + case 2: + style.setAlignment(HorizontalAlignment.CENTER); + break; + } + return style; + } + + private HSSFRow createEmptyRow(HSSFSheet sheet, int rowIndex, int cLength) { + HSSFRow row = sheet.createRow(rowIndex); + HSSFCell ce = null; + for(int i=0; i list) { + this.export(request, response, fileName, header, new short[]{}, list); + } + + protected void export(HttpServletRequest request, HttpServletResponse response, String fileName, String[] header, short[] cWidth, List list) { + if(request == null || response == null || StringUtil.isNull(fileName) || header == null || header.length == 0) return; + + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFCellStyle tStyle = createStyle(wb, 0); + HSSFCellStyle hStyle = createStyle(wb, 1); + HSSFCellStyle cStyle = createStyle(wb, 2); + + HSSFSheet sheet = wb.createSheet(); + wb.setSheetName(0, fileName); + HSSFCell ce = null; + int len = header.length; + if(cWidth == null || cWidth.length != len) { + cWidth = new short[len]; + for(int i=0; i list, int len, HSSFCellStyle style) { + if(list == null || list.size() == 0) return; + HSSFRow row = null; + HSSFCell ce = null; + T bean = null; + for(int i=0; i getParamMap(HttpServletRequest request) { + Map map = new HashMap(); + String[] querys = StringUtil.vString(request.getQueryString()).split("\\&"); + String[] params = null; + for(String query : querys) { + params = query.split("\\="); + if(params.length != 2) continue; + map.put("like_"+StringUtil.getURLDecode(params[0]), StringUtil.getURLDecode(params[1])); + } + return map; + } + + protected void closeWindow(HttpServletResponse response) throws IOException { + executeJavascript(response, new StringBuffer() + .append("var parentWin = parent.parent.getParentWindow(parent);") + .append("parentWin._table.reLoad();") + .append("parentWin.closeDialog();") + .toString()); + } + + protected void executeJavascript(HttpServletResponse response, String content) throws IOException { + PrintWriter out = response.getWriter(); + out.println(""); + out.close(); + } +} diff --git a/src/com/engine/kq/wfset/attendance/framework/BaseDao.java b/src/com/engine/kq/wfset/attendance/framework/BaseDao.java new file mode 100644 index 0000000..f92c8a6 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/framework/BaseDao.java @@ -0,0 +1,23 @@ +package com.engine.kq.wfset.attendance.framework; + +import com.engine.kq.log.KQLog; +import java.util.List; +import java.util.Map; + +/** + * + * @author wcd + * @version 1.0 2014-06-19 + */ +public interface BaseDao { + public KQLog kqLog = new KQLog(); + public abstract Comparable insert(T bean); + + public abstract void update(T bean); + + public abstract void delete(Comparable id); + + public abstract T get(Comparable id); + + public abstract List find(Map map); +} diff --git a/src/com/engine/kq/wfset/attendance/framework/BaseEntity.java b/src/com/engine/kq/wfset/attendance/framework/BaseEntity.java new file mode 100644 index 0000000..d78ea48 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/framework/BaseEntity.java @@ -0,0 +1,86 @@ +package com.engine.kq.wfset.attendance.framework; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import org.apache.commons.lang.ArrayUtils; +import weaver.common.StringUtil; + +/** + * @author wangcd + * @version 9.0 2016-05-17 + */ +public abstract class BaseEntity implements Serializable { + private Map param; + + protected int rowNum; + + private boolean isDown; + + protected String errorMessage; + + public BaseEntity() { + this(true); + } + + public BaseEntity(boolean arg) { + this.param = new HashMap(); + if(arg) init(); + } + + protected abstract void init(); + + public Object get(String key) { + return param.get(StringUtil.vString(key)); + } + + public void put(String key, Object value) { + if(StringUtil.isNotNull(key)) { + this.param.put(StringUtil.vString(key), value); + } + } + + public void putAll(Map map) { + this.param.putAll(map); + } + + public Object getId() { + return null; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public boolean isDown() { + return isDown; + } + + public void setDown(boolean isDown) { + this.isDown = isDown; + } + + public int getRowNum() { + return rowNum; + } + + public void setRowNum(int rowNum) { + this.rowNum = rowNum; + } + + public String getSql() { + return ""; + } + + public Object[] toInsertObj() { + return new Object[]{}; + } + + public Object[] toUpdateObj() { + return ArrayUtils.addAll(toInsertObj(), new Object[]{getId()}); + } +} diff --git a/src/com/engine/kq/wfset/attendance/framework/BaseManager.java b/src/com/engine/kq/wfset/attendance/framework/BaseManager.java new file mode 100644 index 0000000..fc94e1d --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/framework/BaseManager.java @@ -0,0 +1,492 @@ +package com.engine.kq.wfset.attendance.framework; + +import com.engine.kq.log.KQLog; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.general.BaseBean; +import weaver.hrm.User; +import weaver.hrm.company.CompanyComInfo; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.hrm.roles.RolesComInfo; +import weaver.systeminfo.SystemEnv; +import weaver.workflow.workflow.WorkflowComInfo; + + +/** + * + * @author wcd + * @version 1.0 2014-06-19 + */ +public abstract class BaseManager extends BaseBean { + public KQLog kqLog = new KQLog(); + + private BaseDao dao; + + protected HttpServletRequest request; + + protected HttpServletResponse response; + + protected User user; + + protected User processUser; + + protected boolean isDebug; + + protected boolean isWriteLog; + + protected final String FIELD = "field"; + + public BaseManager() {} + + public BaseManager(HttpServletRequest request, HttpServletResponse response) { + this.set(request, response); + this.isDebug = false; + this.isWriteLog = true; + } + + public void setDao(BaseDao dao) { + this.dao = dao; + } + + public BaseDao getDao() { + return this.dao; + } + + public HttpServletRequest getRequest() { + return request; + } + + public HttpServletResponse getResponse() { + return response; + } + + public void set(HttpServletRequest request, HttpServletResponse response) { + this.request = request; + this.response = response; + this.user = request != null ? ((User)request.getSession(true).getAttribute("weaver_user@bean")) : user; + this.processUser = this.user; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public User getProcessUser() { + return processUser; + } + + public void setProcessUser(User processUser) { + this.processUser = processUser; + } + + public Comparable insert(T bean) { + return dao.insert(bean); + } + + public void update(T bean) { + dao.update(bean); + } + + public void delete(Comparable id) { + dao.delete(id); + } + + public T get(Comparable id) { + String sid = StringUtil.vString(id); + return sid.startsWith("[map]") ? get(getMapParam(sid.substring("[map]".length()))) : dao.get(id); + } + + public T get(Map map) { + List l = find(map); + return (l == null || l.size() == 0) ? null : (T)l.get(0); + } + + public List find() { + return find(new HashMap()); + } + + public List find(Map map) { + return dao.find(map); + } + + public List find(String params) { + if(params == null || !params.startsWith("[map]")) return find(); + else return find(getMapParam(params.substring("[map]".length()))); + } + + public Map getMapParam(String params){ + params = StringUtil.vString(params); + if(params.startsWith("[map]")) { + params = params.substring("[map]".length()); + } + return StringUtil.getMapParam(params, ";", "\\:"); + } + + public String getLabelName(Comparable indexid) { + return user == null ? String.valueOf(indexid) : SystemEnv.getHtmlLabelNames(String.valueOf(indexid), user.getLanguage()); + } + + public String getLabelName(Comparable indexid, Comparable languageId) { + return SystemEnv.getHtmlLabelNames(String.valueOf(indexid), StringUtil.parseToInt(String.valueOf(languageId))); + } + + public String getParam(String param) { + param = StringUtil.vString(param); + return param.length() == 0 || request == null ? "" : StringUtil.vString(request.getParameter(param)); + } + + public String getDecodeParam(String param) { + return StringUtil.getURLDecode(getParam(param)); + } + + public int getUID() { + return user == null ? 0 : user.getUID(); + } + + public int getLanguageId() { + return user == null ? 7 : user.getLanguage(); + } + + public String getCountryId() { + return StringUtil.vString(user == null ? "" : user.getCountryid(), "1"); + } + + public String getResourceName(String id) { + return getMultiResourceName(id); + } + + public String getMultiResourceName(String id) { + return getMultiResourceNameHtml(id, ", ", false); + } + + public String getMultiResourceNameHtml(String id) { + return getMultiResourceNameHtml(id, "  ", true); + } + + private String getMultiResourceNameHtml(String id, String splitFlag, boolean isShowHtml) { + StringBuffer name = new StringBuffer(); + try{ + String[] ids = StringUtil.replace(id, ";", ",").split(","); + ResourceComInfo comInfo = new ResourceComInfo(); + for(String _id : ids) { + name.append(name.length() == 0 ? "" : splitFlag); + if(isShowHtml) { + name.append(""+comInfo.getResourcename(_id)+""); + } else { + name.append(comInfo.getResourcename(_id)); + } + } + }catch(Exception e){} + return name.toString(); + } + + public String getDepartmentName(String id) { + return getMultiDepartmentName(id); + } + + public String getMultiDepartmentName(String id) { + return getMultiDepartmentNameHtml(id, ", "); + } + + public String getMultiDepartmentNameHtml(String id) { + return getMultiDepartmentNameHtml(id, "  "); + } + + private String getMultiDepartmentNameHtml(String id, String splitFlag) { + StringBuffer name = new StringBuffer(); + try{ + String[] ids = StringUtil.replace(id, ";", ",").split(","); + DepartmentComInfo comInfo = new DepartmentComInfo(); + for(String _id : ids) { + name.append(name.length() == 0 ? "" : splitFlag).append(comInfo.getDepartmentname(_id)); + } + }catch(Exception e){} + return name.toString(); + } + + public String getRolesName(String id) { + return getMultiRolesName(id); + } + + public String getMultiRolesName(String id) { + return getMultiRolesNameHtml(id, ", "); + } + + public String getMultiRolesNameHtml(String id) { + return getMultiRolesNameHtml(id, "  "); + } + + private String getMultiRolesNameHtml(String id, String splitFlag) { + StringBuffer name = new StringBuffer(); + try{ + String[] ids = StringUtil.replace(id, ";", ",").split(","); + RolesComInfo comInfo = new RolesComInfo(); + for(String _id : ids) { + name.append(name.length() == 0 ? "" : splitFlag).append(comInfo.getRolesRemark(_id)); + } + }catch(Exception e){} + return name.toString(); + } + + public String getWorkflowName(String id) { + return getMultiWorkflowName(id); + } + + public String getMultiWorkflowName(String id) { + return getMultiWorkflowNameHtml(id, ", "); + } + + public String getMultiWorkflowNameHtml(String id) { + return getMultiWorkflowNameHtml(id, "  "); + } + + private String getMultiWorkflowNameHtml(String id, String splitFlag) { + StringBuffer name = new StringBuffer(); + try{ + String[] ids = StringUtil.replace(id, ";", ",").split(","); + WorkflowComInfo comInfo = new WorkflowComInfo(); + for(String _id : ids) { + name.append(name.length() == 0 ? "" : splitFlag).append(comInfo.getWorkflowname(_id)); + } + }catch(Exception e){} + return name.toString(); + } + + public String getSubcompanyName(String id) { + return getMultiSubcompanyName(id); + } + + public String getMultiSubcompanyName(String id) { + return getMultiSubcompanyNameHtml(id, ", "); + } + + public String getMultiSubcompanyNameHtml(String id) { + return getMultiSubcompanyNameHtml(id, "  "); + } + + private String getMultiSubcompanyNameHtml(String id, String splitFlag) { + StringBuffer name = new StringBuffer(); + try{ + String[] ids = StringUtil.replace(id, ";", ",").split(","); + SubCompanyComInfo comInfo = new SubCompanyComInfo(); + for(String _id : ids) { + name.append(name.length() == 0 ? "" : splitFlag).append(comInfo.getSubCompanyname(_id)); + } + }catch(Exception e){} + return name.toString(); + } + + public String getCompanyName() { + return getMultiCompanyName("1"); + } + + public String getMultiCompanyName(String id) { + return getMultiCompanyNameHtml(id, ", "); + } + + public String getMultiCompanyNameHtml(String id) { + return getMultiCompanyNameHtml(id, "  "); + } + + private String getMultiCompanyNameHtml(String id, String splitFlag) { + StringBuffer name = new StringBuffer(); + try{ + String[] ids = StringUtil.replace(id, ";", ",").split(","); + CompanyComInfo comInfo = new CompanyComInfo(); + for(String _id : ids) { + name.append(name.length() == 0 ? "" : splitFlag).append(comInfo.getCompanyname(_id)); + } + }catch(Exception e){} + return name.toString(); + } + + public String getShowName(int subcompanyid, int departmentid) { + return getShowName(subcompanyid, departmentid, null, true); + } + + public String getShowName(int subcompanyid, int departmentid, String title) { + return getShowName(subcompanyid, departmentid, title, isDetachable()); + } + + private String getShowName(int subcompanyid, int departmentid, String title, boolean isDetachable) { + String name = StringUtil.vString(title); + if(isDetachable) { + if(departmentid > 0) { + name = getDepartmentName(String.valueOf(departmentid)); + } else if(subcompanyid > 0) { + name = getSubcompanyName(String.valueOf(subcompanyid)); + } else { + name = getCompanyName(); + } + } + return name; + } + + public String getColorSpan(String color) { + return getColorSpan(color, "24", "16"); + } + + public String getColorSpan(String color, String width, String height) { + return ""; + } + + public Map getQueryMap(String params) { + return StringUtil.getMapParam(params, "&", "\\="); + } + + public String getAppendStr() { + return getAppendStr(this.getLanguageId()); + } + + public String getAppendStr(Comparable languageId) { + return StringUtil.vString(languageId).equals("8") ? "," : ","; + } + + public String bracket(String str) { + return bracket(str, String.valueOf(getLanguageId())); + } + + public String bracket(String str, String languageId) { + return getLabelName(81913, languageId) + str + getLabelName(81914, languageId); + } + + public boolean exist(String str, String[] array) { + return exist(str, Arrays.asList(array)); + } + + public boolean exist(String str, List list) { + return list == null || StringUtil.isNull(str) ? false : list.contains(str); + } + + public List getDateList(String fromDate, String toDate) { + List list = new ArrayList(); + if(StringUtil.isNull(fromDate, toDate) || fromDate.compareTo(toDate) > 0) return list; + + boolean hasReachToDate = false; + for(String currentDate = fromDate; !hasReachToDate;){ + if(currentDate.length() != "2018-01-01".length()) break; + if(currentDate.equals(toDate)) hasReachToDate = true; + list.add(currentDate); + if(StringUtil.isNull(currentDate = DateUtil.addDate(currentDate, 1))) break; + } + return list; + } + + public String getMobileBrowserShowContent(String method, String isedit, String showvalue, String fieldformname, String fieldname, String fieldvalue, String dataChangeString, String disIsmand, String ismandfieldval) { + return getMobileBrowserShowContent(method, isedit, showvalue, fieldformname, fieldname, fieldvalue, dataChangeString, disIsmand, ismandfieldval, 0); + } + + public String getMobileBrowserShowContent(String method, String isedit, String showvalue, String fieldformname, String fieldname, String fieldvalue, String dataChangeString, String disIsmand, String ismandfieldval, int isMuti) { + StringBuffer content = new StringBuffer(); + showvalue = StringUtil.vString(showvalue); + fieldformname = StringUtil.vString(fieldformname); + if("1".equals(StringUtil.vString(isedit))) { + content.append(""); + content.append(""); + content.append("
"+ + ""+ + "
"+ + "
"+showvalue+"" + "!" + ""); + content.append("
"); + } else { + content.append(showvalue); + } + return content.toString(); + } + + protected Map initMap(Map map) { + if(map == null) map = new HashMap(); + return map; + } + + protected long totalTime(String fromDate, String fromTime, String toDate, String toTime) { + long time = 0; + if(StringUtil.isNotNull(fromDate, fromTime, toDate, toTime)) { + if(fromTime.length() > 5) fromTime = fromTime.substring(0, 5); + if(toTime.length() > 5) toTime = toTime.substring(0, 5); + time += DateUtil.timeInterval(fromDate + " " + fromTime + ":00", toDate + " " + toTime + ":00"); + } + return time; + } + + protected void println(String str) { + if(isDebug) { + if(isWriteLog) { + writeLog(str); + } else { + System.out.println(str); + } + } + } + + public String getRemoteAddr() { + String ip = ""; + if(request != null) { + ip = request.getHeader("x-forwarded-for"); + if(StringUtil.isNull(ip) || "unknown".equalsIgnoreCase(ip)) ip = request.getHeader("Proxy-Client-IP"); + if(StringUtil.isNull(ip) || "unknown".equalsIgnoreCase(ip)) ip = request.getHeader("WL-Proxy-Client-IP"); + if(StringUtil.isNull(ip) || "unknown".equalsIgnoreCase(ip)) ip = request.getRemoteAddr(); + if (ip.indexOf(",") >= 0) ip = ip.substring(0 , ip.indexOf(",")); + } + return ip; + } + + public boolean isDetachable() { + return StringUtil.vString(new ManageDetachComInfo().getDetachable()).equals("1"); + } + + public String getDetachSubCompanyIds(String auth) { + return getDetachSubCompanyIds(user, auth); + } + + public String getDetachSubCompanyIds(User user, String auth) { + String result = ""; + try { + if(user != null && user.getUID() != 1 && isDetachable()) { + StringBuffer allIds = new StringBuffer(); + ArrayList sList = new SubCompanyComInfo().getRightSubCompany(user.getUID(), auth); + for(int i=0;iGenerated from 长东设计1.0.9 http://www.mfstyle.cn

+ * + * @author wcd + * @version 1.0 2016-05-31 + */ +public class HrmAttFlowVersionManager extends BaseManager { + + private HrmAttFlowVersionDao dao = null; + + public HrmAttFlowVersionManager() { + this(null, null); + } + + public HrmAttFlowVersionManager(HttpServletRequest request, HttpServletResponse response) { + super(request, response); + this.setDao(dao = new HrmAttFlowVersionDao()); + } + + public Long save(HrmAttFlowVersion bean) { + return save(bean, false); + } + + public Long save(HrmAttFlowVersion bean, boolean isNew) { + return -1L; + } + + public void save(List list) { + dao.insert(list); + } + + public int count(String params) { + return dao.count(this.getMapParam(params)); + } + + public void delete(Map map) { + dao.delete(map); + } + + /** + * 流程存为新版时,复制考勤流程设置、人事状态变更设置 + * @param oldWfId + * @param newWfID + */ + public void copySet(final String oldWfId, final String newWfId) { + new Thread(new Runnable() { + public void run() { + try { + HrmAttFlowVersion bean = new HrmAttFlowVersion(oldWfId, newWfId); + if(!bean.isError()) { + copyAttProcSet(bean.toAttProc()); + copyStateProcSet(bean.toStateProc()); + } + } catch (Exception e) { + writeLog(e); + } + } + }).start(); + } + + /** + * 复制考勤流程设置 + * @param bean + */ + private void copyAttProcSet(HrmAttFlowVersion bean) { + HrmAttProcSet setBean = null, newSetbean = new HrmAttProcSet(); + com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager setManager = new HrmAttProcSetManager(); + if(!dao.allowedToCopy(bean) || (setBean = setManager.get("[map]field001:"+bean.getField001())) == null) return; + + try {BeanUtils.copyProperties(newSetbean, setBean);} catch (Exception e) {} + newSetbean.setId(0L); + newSetbean.setField001(StringUtil.parseToInt(bean.getField002())); + newSetbean.setMfid(StringUtil.getUUID()); + Long newSetId = setManager.save(newSetbean); + newSetbean.setId(newSetId); + + HrmAttProcRelationManager rManager = new HrmAttProcRelationManager(); + List relationList = rManager.find("[map]field001:"+setBean.getId()); + for(HrmAttProcRelation rBean : relationList) rBean.setField001(newSetId.intValue()); + rManager.save(relationList); + + com.engine.kq.wfset.attendance.manager.HrmAttProcActionManager aManager = new HrmAttProcActionManager(); + List actionList = aManager.find("[map]field001:"+setBean.getId()); + for(HrmAttProcAction aBean : actionList) { + aBean.setField001(newSetId); + int old_nodeid = Util.getIntValue(aBean.getField006()); + String new_nodeid = ""+getNodeidByWfidAndOldnodeid(Util.getIntValue(bean.getField002()), old_nodeid); + aBean.setMfid(StringUtil.getUUID()); + aBean.setField006(new_nodeid); + } + aManager.save(actionList); + writeLog(":::::setBean::::"+ JSON.toJSON(setBean)); + writeLog(":::::newSetbean::::"+ JSON.toJSON(newSetbean)); + saveCopyCheckRule(setBean,newSetbean,bean.getField002()); + } + + public void saveCheckRule(HrmAttProcSet setBean, + HrmAttProcSet newSetbean) { + + saveCopyCheckRule(setBean, newSetbean, null); + } + + /** + * 考勤流程设置里的校验规则也需要存为新版本 + * @param setBean + * @param newSetbean + */ + public void saveCopyCheckRule(HrmAttProcSet setBean, + HrmAttProcSet newSetbean, String newWorkflowId) { + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + RecordSet rs3 = new RecordSet(); + long old_att_id = setBean.getId(); + long new_att_id = newSetbean.getId(); + int field006 = newSetbean.getField006(); + String sql = "select * from kq_att_checkrule_set where attid = ? "; + rs.executeQuery(sql, old_att_id); + while (rs.next()){ + Map params = Maps.newHashMap(); + String rule_type_uuid = rs.getString("rule_type_uuid"); + String ruleid = rs.getString("ruleid"); + params.put("attid", new_att_id); + params.put("kqtype", field006); + params.put("rule_type_uuid", rule_type_uuid); + String sql1 = "select * from kq_att_checkrule_type where uuid = ? and att_type=? "; + rs1.executeQuery(sql1,rule_type_uuid,field006); + while (rs1.next()){ + String rule_table = rs1.getString("rule_table"); + String sql2 = "select * from "+rule_table+" where id=? "; + rs2.executeQuery(sql2, ruleid); + while (rs2.next()){ + String fieldSql = "select * from kq_att_checkrule_fields where rule_type_uuid = ? order by fieldorder "; + rs3.executeQuery(fieldSql,rule_type_uuid); + while (rs3.next()){ + String fieldname = rs3.getString("fieldname"); + String field_value = rs2.getString(fieldname); + if("duplicate_wfids".equals(fieldname)) { + if(!"".equals(field_value)) { + field_value += ","+newWorkflowId; + } + } + params.put(fieldname, field_value); + } + } + } + writeLog(":::::params::::"+ JSON.toJSON(params)); + SaveStateProcCheckRuleCmd saveStateProcCheckRuleCmd = new SaveStateProcCheckRuleCmd(params, new User(1)); + saveStateProcCheckRuleCmd.execute(null); + } + + } + + /** + * 流程存为新版后,根据旧版本的节点id,获取当前路径中该节点对应的节点id + * @param newWfId + * @param nodeid_old + * @return + */ + public int getNodeidByWfidAndOldnodeid(int newWfId,int nodeid_old){ + int newNodeid = -1; + RecordSet rs = new RecordSet(); + List childrenNodeList = getChildrenNodeListByNodeID(nodeid_old+""); + int childrenNodeList_len = childrenNodeList.size(); + if(childrenNodeList_len == 0){ + return newNodeid; + } + + String sql = "select max(nodeid) maxnodeid from workflow_flownode where nodeid in ( "; + for(int i=0;i0){ + sql += ","; + } + sql += "?"; + } + sql += " ) and workflowid = ?"; + childrenNodeList.add(String.valueOf(newWfId)); + + rs.executeQuery(sql, childrenNodeList); + if(rs.next()){ + newNodeid = rs.getInt("maxnodeid"); + } + return newNodeid; + } + /** + * 根据节点id,获取与之相关的所有子节点 + * @param parentnodeid + * @return + */ + public static List getChildrenNodeListByNodeID(String parentnodeid) { + + List nodes = new ArrayList(); + + if (parentnodeid == null || "".equals(parentnodeid.trim())) { + return nodes; + } + + RecordSet rs = new RecordSet(); + String sql = "select nodeid, parentnodeid from workflow_versionNodeRelation where parentnodeid=" + parentnodeid; + rs.execute(sql); + while (rs.next()) { + String nodeid = rs.getString("nodeid"); + nodes.add(nodeid); + nodes.addAll(getChildrenNodeListByNodeID(nodeid)); + } + return nodes; + } + + /** + * 复制人事状态变更设置 + * @param bean + */ + private void copyStateProcSet(HrmAttFlowVersion bean) { + HrmStateProcSet setBean = null, newSetbean = new HrmStateProcSet(); + HrmStateProcSetManager setManager = new HrmStateProcSetManager(); + if(!dao.allowedToCopy(bean) || (setBean = setManager.get("[map]field001:"+bean.getField001())) == null) return; + + try {BeanUtils.copyProperties(newSetbean, setBean);} catch (Exception e) {} + newSetbean.setId(0L); + newSetbean.setMfid(StringUtil.getUUID()); + newSetbean.setField001(StringUtil.parseToInt(bean.getField002())); + Long newSetId = setManager.save(newSetbean); + + HrmStateProcRelationManager rManager = new HrmStateProcRelationManager(); + List relationList = rManager.find("[map]field001:"+setBean.getId()); + for(HrmStateProcRelation rBean : relationList) rBean.setField001(newSetId.intValue()); + rManager.save(relationList); + + HrmStateProcActionManager aManager = new HrmStateProcActionManager(); + List actionList = aManager.find("[map]field001:"+setBean.getId()); + for(HrmStateProcAction aBean : actionList) { + aBean.setField001(newSetId); + aBean.setMfid(StringUtil.getUUID()); + } + aManager.save(actionList); + } + +} diff --git a/src/com/engine/kq/wfset/attendance/manager/HrmAttProcActionManager.java b/src/com/engine/kq/wfset/attendance/manager/HrmAttProcActionManager.java new file mode 100644 index 0000000..83612a7 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/manager/HrmAttProcActionManager.java @@ -0,0 +1,126 @@ +package com.engine.kq.wfset.attendance.manager; + +import com.engine.kq.wfset.attendance.dao.HrmAttProcActionDao; +import com.engine.kq.wfset.attendance.domain.HrmAttProcAction; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.attendance.framework.BaseManager; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.workflow.action.WorkflowActionManager; + +/** + * HrmAttProcActionManager + * @author wcd + * @version 1.0 2015-04-27 + */ +public class HrmAttProcActionManager extends BaseManager { + + private HrmAttProcActionDao dao = null; + + public HrmAttProcActionManager() { + dao = new HrmAttProcActionDao(); + this.setDao(dao); + } + + public Long save(HrmAttProcAction bean) { + String id = String.valueOf(bean.getId()); + if(id.equals("0") || id.equals("-1")) id = String.valueOf(this.insert(bean)); + else this.update(bean); + return Long.valueOf(id); + } + + public void delete(Map map){ + dao.delete(map); + } + + public void save(HttpServletRequest request, HttpServletResponse response) { + set(request, response); + String field001 = getDecodeParam("field001"); + com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager setManager = new HrmAttProcSetManager(); + int workflowid = 0; + HrmAttProcSet setBean = setManager.get(StringUtil.parseToInt(field001, 0)); + if(setBean != null) { + workflowid = setBean.getField001(); + setBean.setField009(DateUtil.getCurrentDate()); + setManager.update(setBean); + } + delete(getMapParam("field001:"+field001)); + + WorkflowActionManager workflowActionManager = new WorkflowActionManager(); + HrmAttProcAction bean = null; + String[] allDatas = getDecodeParam("field002").split("___"); + String[] data = null; + dao.deleteAction(workflowid); + + for(String _data : allDatas){ + data = _data.split(";"); + if(data == null || data.length == 0) continue; + + bean = new HrmAttProcAction(); + bean.setField001(StringUtil.parseToLong(field001)); + bean.setField002(data[0].split("\\:")[0].split("_")[0]); + String[] _pAv = null; + for(String _rData : data){ + _pAv = _rData.split("\\:"); + if(_pAv[0].endsWith("field003")) bean.setField003(StringUtil.vString(_pAv[1])); + else if(_pAv[0].endsWith("field005")) bean.setField005(StringUtil.parseToInt(_pAv[1])); + else if(_pAv[0].endsWith("field006")) bean.setField006(_pAv.length>=2?StringUtil.vString(_pAv[1], "-1") : "-1"); + else if(_pAv[0].endsWith("field007")) bean.setField007(Boolean.valueOf(_pAv[1]) ? 1 : 0); + else if(_pAv[0].endsWith("field008")) bean.setField008(StringUtil.parseToInt(_pAv[1])); + } + insert(bean); + + if(bean.getField006().equals("-1")) continue; + int size = bean.getField006().split(",").length; + String defaultValue = ""; + for(int i=0; i list) { + dao.insert(list); + } + +} diff --git a/src/com/engine/kq/wfset/attendance/manager/HrmAttProcActionManagerE9.java b/src/com/engine/kq/wfset/attendance/manager/HrmAttProcActionManagerE9.java new file mode 100644 index 0000000..1332ac1 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/manager/HrmAttProcActionManagerE9.java @@ -0,0 +1,216 @@ +package com.engine.kq.wfset.attendance.manager; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.cmd.hrmAttProcSet.KqSplitActionEnum; +import com.engine.kq.wfset.attendance.dao.HrmAttProcActionDao; +import com.engine.kq.wfset.attendance.domain.HrmAttProcAction; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.attendance.framework.BaseManager; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.workflow.action.WorkflowActionManager; + +/** + * HrmAttProcActionManager + * @author wcd + * @version 1.0 2015-04-27 + */ +public class HrmAttProcActionManagerE9 extends BaseManager { + + private HrmAttProcActionDao dao = null; + + public HrmAttProcActionManagerE9() { + dao = new HrmAttProcActionDao(); + this.setDao(dao); + } + + public Long save(HrmAttProcAction bean) { + String id = String.valueOf(bean.getId()); + if(id.equals("0") || id.equals("-1")) id = String.valueOf(this.insert(bean)); + else this.update(bean); + return Long.valueOf(id); + } + + public void delete(Map map){ + dao.delete(map); + } + + public String save(HttpServletRequest request, HttpServletResponse response, String field001, String field002) { + String result = ""; + set(request, response); + HrmAttProcSetManager setManager = new HrmAttProcSetManager(); + int workflowid = 0; + HrmAttProcSet setBean = setManager.get(StringUtil.parseToInt(field001, 0)); + int flowtype = setBean.getField006();//考勤流程类型 + String splitAction = KqSplitActionEnum.ATT.getSplitAction(); + + WorkflowActionManager workflowActionManager = new WorkflowActionManager(); + HrmAttProcAction bean = null; + JSONArray jSONArray = JSON.parseArray(field002); + + for(int k = 0 ; k < jSONArray.size() ; k ++){ + + JSONObject jObject = (JSONObject) jSONArray.get(k); + String actionId = StringUtil.vString(jObject.get("rowKey")); + String nodeid = StringUtil.vString(jObject.get("field006")); + //0出口附加规则,1节点后附加操作,2节点前附加操作 + String nodeidType = StringUtil.vString(jObject.get("field005")); + //两个校验,一个是保存的时候校验是否设置了拆分的action,第二个是校验拆分的action是否配置在归档节点前 + if(splitAction.equalsIgnoreCase(actionId)){ + if(nodeid.length() == 0){ + result = "1"; + break; + } + if(!checkAction(nodeid,nodeidType)){ + result = "1"; + break; + } + } + //两个校验,一个是保存的时候校验是否设置了拆分的action,第二个是校验冻结拆分的action是否配置在创建节点后 + //TODO 未考虑做这个创建节点后拆分流程的功能,暂时屏蔽 +// if(splitFreezeAction.equalsIgnoreCase(actionId)){ +// if(!checkFreezeAction(nodeid,nodeidType)){ +// result = "2"; +// break; +// } +// } + } + if(result.length() > 0){ + return result; + } + if(setBean != null) { + workflowid = setBean.getField001(); + setBean.setField009(DateUtil.getCurrentDate()); + setManager.update(setBean); + } + delete(getMapParam("field001:"+field001)); + + //只有排班流程没有这块节点前action的控制 + if(flowtype != 5 && result.length() > 0) { + return result; + } + dao.deleteAction(workflowid); + + for(int k = 0 ; k < jSONArray.size() ; k ++){ + JSONObject jObject = (JSONObject) jSONArray.get(k); + String actionId = StringUtil.vString(jObject.get("rowKey")); + + bean = new HrmAttProcAction(); + bean.setField001(StringUtil.parseToLong(field001)); + bean.setField002(actionId); + bean.setField003(StringUtil.vString(jObject.get("field003"))); + bean.setField005(StringUtil.parseToInt(StringUtil.vString(jObject.get("field005")))); + bean.setField006(StringUtil.vString(jObject.get("field006"))); +// bean.setField007(StringUtil.parseToInt(StringUtil.vString(jObject.get("field007"),"0"))); + bean.setField008(StringUtil.parseToInt(StringUtil.vString(jObject.get("field008")))); + insert(bean); + + if(bean.getField006().equals("-1")) continue; + int size = bean.getField006().split(",").length; + String defaultValue = ""; + for(int i=0; i list) { + dao.insert(list); + } + + /** + * 判断拆分action是否配置在流程的归档节点且节点前 + * @param nodeid + * @param nodeidType + * @return + */ + public boolean checkAction(String nodeid,String nodeidType){ + RecordSet rs = new RecordSet(); + String checkSql = "select nodeType from workflow_flownode where nodeid in ("+nodeid+") "; + rs.executeQuery(checkSql); + + boolean isNeededAction = true; + while (rs.next()){ + //节点类型 0:创建 1:审批 2:实现 3:归档 + String nodetype = rs.getString("nodeType"); + boolean isCreateNode = "3".equalsIgnoreCase(nodetype) ? true : false; + boolean isRightNodeType = "2".equalsIgnoreCase(nodeidType) ? true : false; + if(!isCreateNode && isRightNodeType){ + isNeededAction = false; + break; + } + } + return isNeededAction; + } + + /** + * 判断冻结拆分action是否配置在流程的创建节点且节点后 + * @param nodeid + * @param nodeidType + * @return + */ + public boolean checkFreezeAction(String nodeid,String nodeidType){ + RecordSet rs = new RecordSet(); + String checkSql = "select nodeType from workflow_flownode where nodeid = ? "; + rs.executeQuery(checkSql, nodeid); + //节点类型 0:创建 1:审批 2:实现 3:归档 + String nodetype = ""; + if(rs.next()){ + nodetype = rs.getString("nodeType"); + } + boolean isCreateNode = "0".equalsIgnoreCase(nodetype) ? true : false; + + boolean isRightNodeType = "1".equalsIgnoreCase(nodeidType) ? true : false; + return isCreateNode && isRightNodeType; + } + +} diff --git a/src/com/engine/kq/wfset/attendance/manager/HrmAttProcFieldsManager.java b/src/com/engine/kq/wfset/attendance/manager/HrmAttProcFieldsManager.java new file mode 100644 index 0000000..0d119a4 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/manager/HrmAttProcFieldsManager.java @@ -0,0 +1,28 @@ +package com.engine.kq.wfset.attendance.manager; + +import com.engine.kq.wfset.attendance.framework.BaseManager; +import com.engine.kq.wfset.attendance.dao.HrmAttProcFieldsDao; +import com.engine.kq.wfset.attendance.domain.HrmAttProcFields; + +/** + * HrmAttProcFieldsManager + * @author wcd + * @version 1.0 2015-04-24 + */ +public class HrmAttProcFieldsManager extends BaseManager { + + private HrmAttProcFieldsDao dao = null; + + public HrmAttProcFieldsManager() { + dao = new HrmAttProcFieldsDao(); + this.setDao(dao); + } + + public Long save(HrmAttProcFields bean) { + String id = String.valueOf(bean.getId()); + if(id.equals("0") || id.equals("-1")) id = String.valueOf(this.insert(bean)); + else this.update(bean); + return Long.valueOf(id); + } + +} diff --git a/src/com/engine/kq/wfset/attendance/manager/HrmAttProcRelationManager.java b/src/com/engine/kq/wfset/attendance/manager/HrmAttProcRelationManager.java new file mode 100644 index 0000000..4a86863 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/manager/HrmAttProcRelationManager.java @@ -0,0 +1,259 @@ +package com.engine.kq.wfset.attendance.manager; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.util.KQAttFlowCheckUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import weaver.common.StringUtil; +import com.engine.kq.wfset.attendance.framework.BaseManager; +import com.engine.kq.wfset.attendance.dao.HrmAttProcRelationDao; +import com.engine.kq.wfset.attendance.domain.HrmAttProcFields; +import com.engine.kq.wfset.attendance.domain.HrmAttProcRelation; +import com.engine.kq.wfset.attendance.domain.WorkflowBillfield; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +/** + * HrmAttProcRelationManager + * @author wcd + * @version 1.0 2015-04-24 + */ +public class HrmAttProcRelationManager extends BaseManager { + + private HrmAttProcRelationDao dao = null; + + public HrmAttProcRelationManager() { + dao = new HrmAttProcRelationDao(); + this.setDao(dao); + } + + public Long save(HrmAttProcRelation bean) { + String id = String.valueOf(bean.getId()); + if(id.equals("0") || id.equals("-1")) id = String.valueOf(this.insert(bean)); + else this.update(bean); + return Long.valueOf(id); + } + + public void delete(Map map){ + dao.delete(map); + } + + public void save(HttpServletRequest request, HrmAttProcSet hrmAttProcSet,Map retmap, + User user) { + String field001 = StringUtil.vString(request.getParameter("field001")); + kqLog.info("field001::::::"+ field001); + RecordSet rs = new RecordSet(); + Enumeration enu = request.getParameterNames(); + String field002 = ""; + String[] value = null; + //多明细处理 + Map detailMap = new HashMap<>(); + Map mainMap = new HashMap<>(); + kqLog.info("hrmAttProcSet::::::"+ JSON.toJSONString(hrmAttProcSet)); + getDetailInfoBy(hrmAttProcSet.getField002(),detailMap,detailMap); + kqLog.info("detailMap::::::"+ detailMap); + List detailnames = new ArrayList<>(); + + int usedetail = hrmAttProcSet.getUsedetail(); + + boolean isUseDetail = usedetail==1; + boolean isMainDetail = false; + if(hrmAttProcSet.getField006() == 7 || hrmAttProcSet.getField006() == 6 || hrmAttProcSet.getField006() == 8){ + isMainDetail = true; + } + if(isMainDetail){ + isUseDetail = true; + } + List hrmAttProcRelations = Lists.newArrayList(); + kqLog.info("isMainDetail::::::"+ isMainDetail+"::isUseDetail::"+isUseDetail); + while(enu.hasMoreElements()) { + field002 = StringUtil.vString(enu.nextElement()); + kqLog.info("field002::::::"+ field002); + if(field002.equalsIgnoreCase("field001") + || field002.equalsIgnoreCase("cmd") + || !field002.startsWith("select")) continue; + value = StringUtil.getURLDecode(request.getParameter(field002)).split("___"); + kqLog.info("value::::::"+ JSON.toJSONString(value)); + if(value.length != 2) continue; + String fieldid = value[1]; + String fieldname = value[0]; + String detailname = Util.null2String(detailMap.get(fieldid)); + kqLog.info("detailname::::::"+ detailname); + HrmAttProcRelation bean = new HrmAttProcRelation(); + bean.setField001(StringUtil.parseToInt(field001)); + bean.setField002(StringUtil.parseToInt(field002.substring("select".length()))); + bean.setField003(StringUtil.parseToInt(fieldid)); + bean.setField004(StringUtil.vString(fieldname)); + if(!isMainDetail){ + if(isUseDetail && (detailname == null || detailname.length() == 0)){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(500734,user.getLanguage())); + return ; + } + } + if(isUseDetail && detailname != null && detailname.length() > 0){ + if(detailnames.isEmpty()){ + detailnames.add(detailname); + }else{ + //表明多明细下字段对应了两种 + if(!detailnames.contains(detailname)){ + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(500735,user.getLanguage())); + return ; + } + } + } + int att_fieldid = bean.getField002(); +// 0表示请假,1表示出差,2表示公出,3表示加班,4表示异常,5表示调班,6表示销假,7表示补卡 + int kqtype = hrmAttProcSet.getField006(); + int workflowid = hrmAttProcSet.getField001(); +// String sql = "select * from kq_att_proc_fields where id = ? "; +// rs.executeQuery(sql, att_fieldid); +// if(rs.next()){ +// String fields_field002 = rs.getString("field002"); +// Map map = Maps.newConcurrentMap(); +// if(0 == kqtype){ +// if("duration".equalsIgnoreCase(fields_field002) || "detail_duration".equalsIgnoreCase(fields_field002)){ +// KQAttFlowCheckUtil.duration_edit_check_new(fieldid, map,workflowid); +// } +// }else if(1 == kqtype){ +// if("duration".equalsIgnoreCase(fields_field002) || "detail_duration".equalsIgnoreCase(fields_field002)){ +// KQAttFlowCheckUtil.duration_edit_check_new(fieldid, map, workflowid); +// } +// }else if(2 == kqtype){ +// if("duration".equalsIgnoreCase(fields_field002) || "detail_duration".equalsIgnoreCase(fields_field002)){ +// KQAttFlowCheckUtil.duration_edit_check_new(fieldid, map, workflowid); +// } +// }else if(3 == kqtype){ +// if("duration".equalsIgnoreCase(fields_field002) || "detail_duration".equalsIgnoreCase(fields_field002)){ +// KQAttFlowCheckUtil.duration_edit_check_new(fieldid, map, workflowid); +// } +// }else if(6 == kqtype){ +// if("detail_duration".equalsIgnoreCase(fields_field002)){ +// KQAttFlowCheckUtil.duration_edit_check_new(fieldid, map, workflowid); +// } +// }else if(8 == kqtype){ +// if("detail_duration".equalsIgnoreCase(fields_field002)){ +// KQAttFlowCheckUtil.duration_edit_check_new(fieldid, map, workflowid); +// } +// } +// if(!map.isEmpty()){ +// retmap.put("status", "-1"); +// retmap.put("message", Util.null2String(map.get("msgAttError"))); +// return ; +// } +// } + hrmAttProcRelations.add(bean); + } + kqLog.info("detailnames::::::"+ JSON.toJSONString(detailnames)); + if(!detailnames.isEmpty()) { + hrmAttProcSet.setDetailtablename(detailnames.get(0)); + } else { + hrmAttProcSet.setDetailtablename(""); + } + kqLog.info("hrmAttProcSet::::::"+ JSON.toJSONString(hrmAttProcSet)); + if(hrmAttProcSet.getField006() == 7) { + boolean isDetailResource = false; // 如果补卡流程绑定了明细人员,就需要刷新历史补卡流程数据 + int prosetId = Util.getIntValue(Util.null2String(request.getParameter("field001")), 0); + HrmAttProcSetManager attProcSetManager = new HrmAttProcSetManager(); + HrmAttProcSet bean = attProcSetManager.get(prosetId); + String tableName = bean.getTablename(); + String detailTableName = bean.getDetailtablename(); + int billId = bean.getField002(); + int workflowId = bean.getField001(); + Map result = attProcSetManager.getFieldList(7,workflowId, billId); + kqLog.info("result::::::"+ JSON.toJSONString(result)); + String[] fieldList = (String[])result.get("fields"); + String mainResourceField = Util.null2String(fieldList[0]); + String detailResourceField = Util.null2String(fieldList[9]); + if(!"".equals(detailResourceField)) { + isDetailResource = true; + } + kqLog.info("isDetailResource::::::"+ JSON.toJSONString(isDetailResource)); + if(isDetailResource) { + String mainResource = ""; + String detailResource = ""; + for(HrmAttProcRelation attBean : hrmAttProcRelations) { + if(("field"+attBean.getField003()).equals(mainResourceField)) { + mainResource = attBean.getField004(); + } + if(("field"+attBean.getField003()).equals(detailResourceField)) { + detailResource = attBean.getField004(); + } + } + kqLog.info("prosetId::::::"+ prosetId+"::billId::"+billId+"::workflowId::"+workflowId+"::tableName::"+tableName + +"::detailTableName::"+detailTableName+"::mainResource::"+mainResource+"::detailResource::"+detailResource); + if(!"".equals(mainResource) && !"".equals(detailResource)) { + flushCardInsert(prosetId, billId, workflowId, tableName, detailTableName, mainResource, detailResource); + } + } + } + delete(getMapParam("field001:"+field001)); + + if(!hrmAttProcRelations.isEmpty()){ + for(HrmAttProcRelation hrmAttProcRelation : hrmAttProcRelations){ + insert(hrmAttProcRelation); + } + } + } + + /** + * + */ + public void flushCardInsert(int prosetId, int billId, int workflowId, String tableName, String detailTableName, String mainResourceField, String detailResourceField) { + String searchSql = "select * from flush_oldcard_flow where prosetid=?"; + String sql = "insert into flush_oldcard_flow(prosetid, workflowid, billid, maintablename, detailtablename, mainresourcefield, detailresourcefield, isexecute) values(?,?,?,?,?,?,?,?)"; + RecordSet rs = new RecordSet(); + rs.executeQuery(searchSql, prosetId); + if(rs.next()) { + return; + } + rs.executeUpdate(sql, prosetId, workflowId,billId,tableName,detailTableName,mainResourceField,detailResourceField,0); + } + + public void getDetailInfoBy(Integer formid,Map detailMap,Map mainMap){ + RecordSet rs = new RecordSet(); + String detailSql = "select * from workflow_billfield where billid = ? "; + rs.executeQuery(detailSql, formid); + while (rs.next()){ + String fieldid = rs.getString("id"); + String detailtable = rs.getString("detailtable"); + detailMap.put(fieldid, detailtable); + } + } + + + public void save(List list) { + dao.insert(list); + } + + public void initRelation(Long id, List list, List fieldList) { + if(list == null || fieldList == null || id == null) return; + + HrmAttProcRelation bean = null; + for(HrmAttProcFields fBean : list){ + bean = new HrmAttProcRelation(); + bean.setField001(id.intValue()); + bean.setField002(fBean.getId().intValue()); + for(WorkflowBillfield wfBean : fieldList){ + if(!fBean.getField002().equalsIgnoreCase(wfBean.getFieldname())) continue; + bean.setField003(wfBean.getId()); + bean.setField004(wfBean.getFieldname()); + break; + } + insert(bean); + } + } + +} diff --git a/src/com/engine/kq/wfset/attendance/manager/HrmAttProcSetManager.java b/src/com/engine/kq/wfset/attendance/manager/HrmAttProcSetManager.java new file mode 100644 index 0000000..b1664fe --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/manager/HrmAttProcSetManager.java @@ -0,0 +1,1253 @@ +package com.engine.kq.wfset.attendance.manager; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQAttProcSetComInfo; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.wfset.attendance.dao.HrmAttProcSetDao; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.attendance.domain.WorkflowBillfield; +import com.engine.kq.wfset.attendance.framework.BaseManager; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import weaver.common.StringUtil; +import weaver.conn.RecordSet; + +/** + * HrmAttProcSetManager + * + * @author wcd + * @version 1.0 2015-04-22 + */ +public class HrmAttProcSetManager extends BaseManager { + + private HrmAttProcSetDao dao = null; + + public HrmAttProcSetManager() { + dao = new HrmAttProcSetDao(); + this.setDao(dao); + } + + public Long save(HrmAttProcSet bean) { + String id = String.valueOf(bean.getId()); + if (id.equals("0") || id.equals("-1")) id = String.valueOf(this.insert(bean)); + else this.update(bean); + return Long.valueOf(id); + } + + public List getFieldList(int field006, boolean field005, String id, String usedetail) { + return dao.getByField006(field006, field005, id, usedetail); + } + + /** + * @param field006 变更流程类型,0表示请假,1表示出差,2表示公出,3表示加班,4表示异常,5表示调班,6表示销假 + * @param paramMap 参数拼接sqlwhere + * @param ef true表示归档流程 + * @param field005 表示考勤流程是否启用 + * @param id 查询kq_ATT_PROC_SET的sql条件 + * @param usedetails 是否使用明细 + * @return + */ + public Map getSQLByField006Map(int field006, Map paramMap, boolean ef, boolean field005, String id, String usedetails) { + Map sqlMap = new HashMap<>(); + List list = getFieldList(field006, field005, id, usedetails); + //和E8不一样,这里的tableMap里只能记录一种考勤流程设置,所以size都只能是1 + Map tableMap = new HashMap(); + String concort = "###"; + + //补卡/销假流程既有主表也有明细表 + if (field006 == KqSplitFlowTypeEnum.CARD.getFlowtype() + || field006 == KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype() + || field006 == KqSplitFlowTypeEnum.PROCESSCHANGE.getFlowtype()) { + getTableMap7(list, tableMap); + } else { + getTableMap(list, tableMap); + } + + StringBuffer sql = new StringBuffer(); + Iterator it = tableMap.entrySet().iterator(); + Iterator paramIt = null; + String whereSql = ef ? "b.currentNodeType = '3'" : "1 = 1"; + while (it.hasNext()) { + sql = new StringBuffer(); + Map.Entry entry = (Map.Entry) it.next(); + String key = StringUtil.vString(entry.getKey()); + String[] keys = key.split(concort); + //是否是补卡流程 + String isSpecial = ""; + if (keys.length == 5) { + //是否是补卡流程 + isSpecial = keys[4]; + } + // 补卡流程特殊处理 + if (field006 == KqSplitFlowTypeEnum.CARD.getFlowtype()) { + for (HrmAttProcSet bean : list) { + if ("detail_resourceid".equals(bean.getField011())) { + isSpecial = "-1"; + break; + } + } + } + String wfId = keys[3]; + String usedetail = keys[2]; + String tableDetailName = keys[1]; + String tableName = keys[0]; + boolean isDetail = "1".equalsIgnoreCase(usedetail); + boolean hasSpecial = "1".equalsIgnoreCase(isSpecial); + + //value是所有的字段 主表明细表要显示的字段 + String value = StringUtil.vString(entry.getValue()); + if (value.endsWith(",")) { + value = value.substring(0, value.length() - 1); + } + kqLog.info("getSQLByField006Map:value:" + value); + if (value.length() == 0) { + continue; + } + +// sql模型: +// (select backfield from 主表 t left join 明细表(如果有的话) t1 on t.id = t1.mainid) t +// left join Workflow_Requestbase b on t.requestid = b.requestid left join HrmResource c +// on t.detail_resourceId = c.id(这个是和人员表关联,因为resourceId这个字段补卡和其他类型不一样需要特殊处理) +// left join HrmDepartment d on c.departmentId = d.id + + sql.append("select t.*,b.requestname,b.status,c.lastname,c.departmentId c_departmentId,d.departmentname,c.subcompanyid1,c.workcode from (select t.requestid,"). + append(isDetail ? " t1.id as detailId," : "t.id as dataId,").append(value). + append(" from ").append(tableName).append(" t "). + append(isDetail ? " left join " + tableDetailName + " t1 on t.id = t1.mainid" : "").append(") t"). + append(" left join Workflow_Requestbase b on t.requestid = b.requestid left join HrmResource c on "). + append(hasSpecial ? " t.resourceId = c.id" : (isDetail ? " t.detail_resourceId = c.id " : " t.resourceId = c.id ")). + append(" left join HrmDepartment d on c.departmentId = d.id where "). + append(whereSql).append(" and workflowid=" + wfId); + + if (paramMap != null && !paramMap.isEmpty()) { + paramIt = paramMap.entrySet().iterator(); + while (paramIt.hasNext()) { + entry = (Map.Entry) paramIt.next(); + if ("operatorId".equals(entry.getKey())) { + continue; + } + sql.append(" ").append(StringUtil.vString(entry.getValue())); + } + } + sqlMap.put(key, sql.toString()); + } + + kqLog.info("getSQLByField006Map:" + sqlMap); + return sqlMap; + } + + /** + * 因为getSQLByField006Map我限定了外层循环kq_att_set表,所以这个tableMap的size只能唯一 + * 针对补卡流程,主表明细表都有的情况 + * + * @param list + * @param tableMap + */ + private void getTableMap7(List list, Map tableMap) { + String tempSql = ""; + String concort = "###"; + int wfId = 0; + int usedetail = 1; + //表示是主表带明细表流程 + int isSpecial = 1; + String tablename = ""; + String detailtablename = ""; + + for (HrmAttProcSet bean : list) { + wfId = bean.getField001() > 0 ? bean.getField001() : wfId; + tablename = bean.getTablename().length() > 0 ? bean.getTablename() : tablename; + detailtablename = bean.getDetailtablename().length() > 0 ? bean.getDetailtablename() : detailtablename; + + if (StringUtil.isNotNull(bean.getField011())) { + String alias = "t"; + + if (bean.getField011().startsWith("detail_")) { + //t1表示明细别名 + alias = "t1"; + } else { + alias = "t"; + } + String column = (StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp") ? "''" + : " " + alias + "." + bean.getField010()) + " as " + bean.getField011() + ","; + + if (!tempSql.contains(column)) { + tempSql += column; + } + } + } + String key = tablename + concort + detailtablename + concort + usedetail + concort + wfId + concort + isSpecial; + tableMap.put(key, tempSql); + + } + + /** + * 因为getSQLByField006Map我限定了外层循环kq_att_set表,所以这个tableMap的size只能唯一 + * 针对考勤字段只有主表或者明细表的情况 + * + * @param list + * @param tableMap + */ + private void getTableMap(List list, Map tableMap) { + String tempSql = ""; + String concort = "###"; + int wfId = 0; + int usedetail = 0; + String tablename = ""; + String detailtablename = ""; + for (HrmAttProcSet bean : list) { + kqLog.info("getTableMap:bean:" + JSON.toJSON(bean)); + usedetail = bean.getUsedetail() > -1 ? bean.getUsedetail() : usedetail; + boolean isUseDetail = usedetail == 1; + + wfId = bean.getField001() > 0 ? bean.getField001() : wfId; + tablename = bean.getTablename().length() > 0 ? bean.getTablename() : tablename; + detailtablename = bean.getDetailtablename().length() > 0 ? bean.getDetailtablename() : detailtablename; + if (StringUtil.isNotNull(bean.getField011())) { + if ("vacationInfo".equalsIgnoreCase(bean.getField011()) || "detail_vacationInfo".equalsIgnoreCase(bean.getField011())) { + continue; + } + String alias = "t"; + + //如果是明细表,那么所有以detail_开头的都记录,其他的都不记录 + if (isUseDetail) { + if (!bean.getField011().startsWith("detail_")) { + continue; + } + } else { + //主表的话,只要是detail_开头的都不记录 + if (bean.getField011().startsWith("detail_")) { + continue; + } + } + if (isUseDetail) { + //t1表示明细别名 + alias = "t1"; + } + String column = (StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp") ? "''" + : " " + alias + "." + bean.getField010()) + " as " + bean.getField011() + ","; + + if (!tempSql.contains(column)) { + tempSql += column; + } + } + } + String key = tablename + concort + detailtablename + concort + usedetail + concort + wfId; + kqLog.info("getTableMap:key:" + key); + tableMap.put(key, tempSql); + } + + public void welcomeToSet(int field001) { + welcomeToSet(field001, 0); + } + + public void welcomeToSet(int field001, int field006) { + dao.setCustomPage(field001, field006); + } + + public void welcomeToSet(int field001, int field006, String templetfile, String templetmobilefile, String templetroute) { + dao.setCustomPage(field001, field006, templetfile, templetmobilefile, templetroute); + } + + public boolean isFreezeNode(int wfId, int nodeType) { + return dao.getFreezeNodeType(wfId) == nodeType; + } + + //只在创建节点做冻结判断 + public boolean isFreezeNodeId(int wfId, int nodeid) { + boolean hasFreezeNodeId = dao.hasFreezeNodeId(wfId); + boolean isStartNodeId = dao.getWFStartNodeId(wfId) == nodeid; + return isStartNodeId && hasFreezeNodeId; + } + + public String[] getFieldList(int field001, int field002) { + Map result = getFieldList(0, field001, field002); + return (String[]) result.get("fields"); + } + + private Map getResultMap(int type, int field001, int field002) { + Map map = new HashMap(); + WorkflowBillfieldManager manager = new WorkflowBillfieldManager(); + List fList = manager.find("[map]billid:" + field002); + List fListDetail = manager.find("[map]billid:" + field002 + ";viewtype:1"); + + List list = getFieldList(type, true, "select id from kq_ATT_PROC_SET where field001 = " + field001 + " and field002 = " + field002); + map.put("fList", fList); + map.put("fListDetail", fListDetail); + map.put("list", list); + return map; + } + + public List getFieldList(int field006, boolean field005, String id) { + return dao.getByField006(field006, field005, id, ""); + } + + /** + * @param type 变更流程类型,0表示请假,1表示出差,2表示公出,3表示加班,4表示异常,5表示调班,6表示销假,7表示补卡,8表示考勤变更流程 + * @param field001 流程id + * @param field002 表单id + * @return + */ + public Map getFieldList(int type, int field001, int field002) { + Map map = getResultMap(type, field001, field002); + List fList = (List) map.get("fList"); + List fListDetail = (List) map.get("fListDetail"); + List list = (List) map.get("list"); + Map result = new HashMap<>(); + if (fList == null || list == null) { + return result; + } + +// 变更流程类型,0表示请假,1表示出差,2表示公出,3表示加班,4表示异常,5表示调班,6表示销假,7表示补卡,8表示考勤变更流程 + switch (type) { + case 0: + result = getFieldList0(fList, fListDetail, list); + break; + case 1: + result = getFieldList1(fList, fListDetail, list); + break; + case 2: + result = getFieldList2(fList, fListDetail, list); + break; + case 3: + result = getFieldList3(fList, fListDetail, list); + break; + case 4: + result = getFieldList4(fList, fListDetail, list); + break; + case 5: + result = getFieldList5(fList, fListDetail, list); + break; + case 6: + result = getFieldList6(fList, fListDetail, list); + break; + case 7: + result = getFieldList7(fList, fListDetail, list); + break; + case 8: + result = getFieldList8(fList, fListDetail, list); + break; + } + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + String attid = kqAttProcSetComInfo.getAttid(field001 + ""); + if (result != null) { + result.put("attid", attid); + } + return result; + } + + private static final String FIELD = "field"; + + private Map getFieldList0(List fList, List fListDetail, List list) { + Map fieldMap = new HashMap<>(); + String resourceId = ""; + String departmentId = ""; + String newLeaveType = ""; + String fromDate = ""; + String fromTime = ""; + String toDate = ""; + String toTime = ""; + String duration = ""; + String vacationInfo = ""; + String edit_duration = ""; + String repeatType = ""; + String repeatLate = ""; + String repeatEarly = ""; + String usedetailstr = ""; + String detailtablename = ""; + String tablename = ""; + Long attid = 0L; + int formid = 0; + List forfList = fList; + for (HrmAttProcSet bean : list) { + int usedetail = bean.getUsedetail(); + formid = bean.getField002(); + if (usedetail == 1) { + forfList = fListDetail; + usedetailstr = "" + usedetail; + detailtablename = bean.getDetailtablename(); + } else { + tablename = bean.getTablename(); + } + String detailPre = ""; + if (usedetail == 1) { + detailPre = "detail_"; + } + for (WorkflowBillfield fieldBean : forfList) { + if (usedetail == 1) { + String fieldbean_detailtable = fieldBean.getDetailtable(); + if (fieldbean_detailtable.length() > 0 && detailtablename.length() > 0) { + if (!fieldbean_detailtable.equalsIgnoreCase(detailtablename)) { + continue; + } + } + } + if (!fieldBean.getFieldname().equalsIgnoreCase(bean.getField010()) || + StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp")) { + continue; + } + if (bean.getField011().equalsIgnoreCase(detailPre + "resourceId")) { + resourceId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "departmentId")) { + departmentId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "newLeaveType")) { + newLeaveType = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "fromDate")) { + fromDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "fromTime")) { + fromTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "toDate")) { + toDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "toTime")) { + toTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "duration")) { + duration = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "vacationInfo")) { + vacationInfo = FIELD + fieldBean.getId(); + break; + } else if(bean.getField011().equalsIgnoreCase(detailPre+"edit_duration")) { + edit_duration = FIELD + fieldBean.getId(); + break; + } else if(bean.getField011().equalsIgnoreCase(detailPre+"repeat_type")) { + repeatType = FIELD + fieldBean.getId(); + break; + } else if(bean.getField011().equalsIgnoreCase(detailPre+"repeat_late")) { + repeatLate = FIELD + fieldBean.getId(); + break; + } else if(bean.getField011().equalsIgnoreCase(detailPre+"repeat_early")) { + repeatEarly = FIELD + fieldBean.getId(); + break; + } + } + attid = bean.getId(); + } + String[] result = new String[13]; + result[0] = resourceId; + result[1] = departmentId; + result[2] = newLeaveType; + result[3] = fromDate; + result[4] = fromTime; + result[5] = toDate; + result[6] = toTime; + result[7] = duration; + result[8] = vacationInfo; + result[9] = edit_duration; + result[10] = repeatType; + result[11] = repeatLate; + result[12] = repeatEarly; + fieldMap.put("fields", result); + fieldMap.put("usedetail", usedetailstr); + fieldMap.put("detailtablename", detailtablename); + if (detailtablename.length() > 0) { + int detailIndex = getDetail_index(formid + "", detailtablename); + fieldMap.put("detailIndex", detailIndex); + } + fieldMap.put("tablename", tablename); + fieldMap.put("attid", attid); + + return fieldMap; + } + + private Map getFieldList1(List fList, List fListDetail, List list) { + Map fieldMap = new HashMap<>(); + + String resourceId = ""; + String departmentId = ""; + String fromDate = ""; + String fromTime = ""; + String toDate = ""; + String toTime = ""; + String duration = ""; + String edit_duration = ""; + String companion = ""; + String usedetailstr = ""; + String detailtablename = ""; + String tablename = ""; + Long attid = 0L; + int formid = 0; + List forfList = fList; + for (HrmAttProcSet bean : list) { + int usedetail = bean.getUsedetail(); + formid = bean.getField002(); + if (usedetail == 1) { + forfList = fListDetail; + usedetailstr = "" + usedetail; + detailtablename = bean.getDetailtablename(); + } else { + tablename = bean.getTablename(); + } + String detailPre = ""; + if (usedetail == 1) { + detailPre = "detail_"; + } + for (WorkflowBillfield fieldBean : forfList) { + if (usedetail == 1) { + String fieldbean_detailtable = fieldBean.getDetailtable(); + if (fieldbean_detailtable.length() > 0 && detailtablename.length() > 0) { + if (!fieldbean_detailtable.equalsIgnoreCase(detailtablename)) { + continue; + } + } + } + if (!fieldBean.getFieldname().equalsIgnoreCase(bean.getField010()) || + StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp")) { + continue; + } + if (bean.getField011().equalsIgnoreCase(detailPre + "resourceId")) { + resourceId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "departmentId")) { + departmentId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "fromDate")) { + fromDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "fromTime")) { + fromTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "toDate")) { + toDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "toTime")) { + toTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "duration")) { + duration = FIELD + fieldBean.getId(); + break; + } else if(bean.getField011().equalsIgnoreCase(detailPre+"edit_duration")) { + edit_duration = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "companion")) { + companion = FIELD + fieldBean.getId(); + break; + } + } + attid = bean.getId(); + } + String[] result = new String[9]; + result[0] = resourceId; + result[1] = departmentId; + result[2] = fromDate; + result[3] = fromTime; + result[4] = toDate; + result[5] = toTime; + result[6] = duration; + result[7] = edit_duration; + result[8] = companion; + fieldMap.put("fields", result); + fieldMap.put("usedetail", usedetailstr); + fieldMap.put("detailtablename", detailtablename); + fieldMap.put("tablename", tablename); + fieldMap.put("attid", attid); + if (detailtablename.length() > 0) { + int detailIndex = getDetail_index(formid + "", detailtablename); + fieldMap.put("detailIndex", detailIndex); + } + return fieldMap; + } + + private Map getFieldList3(List fList, List fListDetail, List list) { + Map fieldMap = new HashMap<>(); + + String resourceId = ""; + String departmentId = ""; + String fromDate = ""; + String fromTime = ""; + String toDate = ""; + String toTime = ""; + String duration = ""; + String edit_duration = ""; + String overtime_type = ""; + String usedetailstr = ""; + String detailtablename = ""; + String tablename = ""; + Long attid = 0L; + int formid = 0; + List forfList = fList; + for (HrmAttProcSet bean : list) { + int usedetail = bean.getUsedetail(); + formid = bean.getField002(); + if (usedetail == 1) { + forfList = fListDetail; + usedetailstr = "" + usedetail; + detailtablename = bean.getDetailtablename(); + } else { + tablename = bean.getTablename(); + } + String detailPre = ""; + if (usedetail == 1) { + detailPre = "detail_"; + } + for (WorkflowBillfield fieldBean : forfList) { + if (usedetail == 1) { + String fieldbean_detailtable = fieldBean.getDetailtable(); + if (fieldbean_detailtable.length() > 0 && detailtablename.length() > 0) { + if (!fieldbean_detailtable.equalsIgnoreCase(detailtablename)) { + continue; + } + } + } + if (!fieldBean.getFieldname().equalsIgnoreCase(bean.getField010()) || + StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp")) { + continue; + } + if (bean.getField011().equalsIgnoreCase(detailPre + "resourceId")) { + resourceId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "departmentId")) { + departmentId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "fromDate")) { + fromDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "fromTime")) { + fromTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "toDate")) { + toDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "toTime")) { + toTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "duration")) { + duration = FIELD + fieldBean.getId(); + break; + } else if(bean.getField011().equalsIgnoreCase(detailPre+"edit_duration")) { + edit_duration = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "overtime_type")) { + overtime_type = FIELD + fieldBean.getId(); + break; + } + } + attid = bean.getId(); + } + String[] result = new String[9]; + result[0] = resourceId; + result[1] = departmentId; + result[2] = fromDate; + result[3] = fromTime; + result[4] = toDate; + result[5] = toTime; + result[6] = duration; + result[7] = edit_duration; + result[8] = overtime_type; + fieldMap.put("fields", result); + fieldMap.put("usedetail", usedetailstr); + fieldMap.put("detailtablename", detailtablename); + if (detailtablename.length() > 0) { + int detailIndex = getDetail_index(formid + "", detailtablename); + fieldMap.put("detailIndex", detailIndex); + } + fieldMap.put("tablename", tablename); + fieldMap.put("attid", attid); + return fieldMap; + } + + private Map getFieldList2(List fList, List fListDetail, List list) { + Map fieldMap = new HashMap<>(); + + String resourceId = ""; + String departmentId = ""; + String fromDate = ""; + String fromTime = ""; + String toDate = ""; + String toTime = ""; + String duration = ""; + String edit_duration = ""; + String usedetailstr = ""; + String detailtablename = ""; + String tablename = ""; + Long attid = 0L; + int formid = 0; + List forfList = fList; + for (HrmAttProcSet bean : list) { + int usedetail = bean.getUsedetail(); + formid = bean.getField002(); + if (usedetail == 1) { + forfList = fListDetail; + usedetailstr = "" + usedetail; + detailtablename = bean.getDetailtablename(); + } else { + tablename = bean.getTablename(); + } + String detailPre = ""; + if (usedetail == 1) { + detailPre = "detail_"; + } + for (WorkflowBillfield fieldBean : forfList) { + if (usedetail == 1) { + String fieldbean_detailtable = fieldBean.getDetailtable(); + if (fieldbean_detailtable.length() > 0 && detailtablename.length() > 0) { + if (!fieldbean_detailtable.equalsIgnoreCase(detailtablename)) { + continue; + } + } + } + if (!fieldBean.getFieldname().equalsIgnoreCase(bean.getField010()) || + StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp")) { + continue; + } + if (bean.getField011().equalsIgnoreCase(detailPre + "resourceId")) { + resourceId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "departmentId")) { + departmentId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "fromDate")) { + fromDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "fromTime")) { + fromTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "toDate")) { + toDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "toTime")) { + toTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "duration")) { + duration = FIELD + fieldBean.getId(); + break; + } else if(bean.getField011().equalsIgnoreCase(detailPre+"edit_duration")) { + edit_duration = FIELD + fieldBean.getId(); + break; + } + } + attid = bean.getId(); + } + String[] result = new String[8]; + result[0] = resourceId; + result[1] = departmentId; + result[2] = fromDate; + result[3] = fromTime; + result[4] = toDate; + result[5] = toTime; + result[6] = duration; + result[7] = edit_duration; + fieldMap.put("fields", result); + fieldMap.put("usedetail", usedetailstr); + fieldMap.put("detailtablename", detailtablename); + if (detailtablename.length() > 0) { + int detailIndex = getDetail_index(formid + "", detailtablename); + fieldMap.put("detailIndex", detailIndex); + } + fieldMap.put("tablename", tablename); + fieldMap.put("attid", attid); + return fieldMap; + } + + private Map getFieldList4(List fList, List fListDetail, List list) { + Map fieldMap = new HashMap<>(); + + String resourceId = ""; + String departmentId = ""; + String fromDate = ""; + String fromTime = ""; + String toDate = ""; + String toTime = ""; + String duration = ""; + String usedetailstr = ""; + String detailtablename = ""; + Long attid = 0L; + List forfList = fList; + for (HrmAttProcSet bean : list) { + int usedetail = bean.getUsedetail(); + if (usedetail == 1) { + forfList = fListDetail; + usedetailstr = "" + usedetail; + detailtablename = bean.getDetailtablename(); + } + String detailPre = ""; + if (usedetail == 1) { + detailPre = "detail_"; + } + for (WorkflowBillfield fieldBean : forfList) { + if (usedetail == 1) { + String fieldbean_detailtable = fieldBean.getDetailtable(); + if (fieldbean_detailtable.length() > 0 && detailtablename.length() > 0) { + if (!fieldbean_detailtable.equalsIgnoreCase(detailtablename)) { + continue; + } + } + } + if (!fieldBean.getFieldname().equalsIgnoreCase(bean.getField010()) || + StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp")) { + continue; + } + if (bean.getField011().equalsIgnoreCase(detailPre + "resourceId")) { + resourceId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "departmentId")) { + departmentId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "fromDate")) { + fromDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "fromTime")) { + fromTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "toDate")) { + toDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "toTime")) { + toTime = FIELD + fieldBean.getId(); + break; + } + } + attid = bean.getId(); + } + String[] result = new String[6]; + result[0] = resourceId; + result[1] = departmentId; + result[2] = fromDate; + result[3] = fromTime; + result[4] = toDate; + result[5] = toTime; + fieldMap.put("fields", result); + fieldMap.put("usedetail", usedetailstr); + fieldMap.put("detailtablename", detailtablename); + fieldMap.put("attid", attid); + return fieldMap; + } + + private Map getFieldList5(List fList, List fListDetail, List list) { + Map fieldMap = new HashMap<>(); + + String resourceId = ""; + String fromDate = ""; + String toDate = ""; + String shift = ""; + String group = ""; + String usedetailstr = ""; + String detailtablename = ""; + Long attid = 0L; + int formid = 0; + for (HrmAttProcSet bean : list) { + //TODO 现在排班流程只做明细 + formid = bean.getField002(); + String detailPre = "detail_"; + int usedetail = 1; + usedetailstr = "1"; + detailtablename = bean.getDetailtablename(); + + for (WorkflowBillfield fieldBean : fListDetail) { + if (usedetail == 1) { + String fieldbean_detailtable = fieldBean.getDetailtable(); + if (fieldbean_detailtable.length() > 0 && detailtablename.length() > 0) { + if (!fieldbean_detailtable.equalsIgnoreCase(detailtablename)) { + continue; + } + } + } + if (!fieldBean.getFieldname().equalsIgnoreCase(bean.getField010()) || + StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp")) { + continue; + } + if (bean.getField011().equalsIgnoreCase(detailPre + "resourceId")) { + resourceId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "fromDate")) { + fromDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "toDate")) { + toDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "shift")) { + shift = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase(detailPre + "group")) { + group = FIELD + fieldBean.getId(); + break; + } + } + attid = bean.getId(); + } + String[] result = new String[5]; + result[0] = resourceId; + result[1] = fromDate; + result[2] = toDate; + result[3] = shift; + result[4] = group; + fieldMap.put("fields", result); + fieldMap.put("usedetail", usedetailstr); + fieldMap.put("detailtablename", detailtablename); + fieldMap.put("attid", attid); + if (detailtablename.length() > 0) { + int detailIndex = getDetail_index(formid + "", detailtablename); + fieldMap.put("detailIndex", detailIndex); + } + return fieldMap; + } + + private Map getFieldList6(List fList, List fListDetail, List list) { + Map fieldMap = new HashMap<>(); + + String resourceId = ""; + String leaverequestid = ""; + String detail_leavefromDate = ""; + String detail_leavefromTime = ""; + String detail_leavetoDate = ""; + String detail_leavetoTime = ""; + String detail_leaveduration = ""; + + String detail_newLeaveType = ""; + + String detail_fromDate = ""; + String detail_fromTime = ""; + String detail_toDate = ""; + String detail_toTime = ""; + String detail_duration = ""; + String detail_edit_duration = ""; + String usedetailstr = ""; + String detailtablename = ""; + Long attid = 0L; + int formid = 0; + + for (HrmAttProcSet bean : list) { + formid = bean.getField002(); + if (bean.getDetailtablename().length() > 0) { + detailtablename = bean.getDetailtablename(); + } + for (WorkflowBillfield fieldBean : fList) { + if (!fieldBean.getFieldname().equalsIgnoreCase(bean.getField010()) || + StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp")) { + continue; + } + if (bean.getField011().equalsIgnoreCase("resourceId")) { + resourceId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("leaverequestid")) { + leaverequestid = FIELD + fieldBean.getId(); + break; + } + } + for (WorkflowBillfield fieldBean : fListDetail) { + String fieldbean_detailtable = fieldBean.getDetailtable(); + if (fieldbean_detailtable.length() > 0 && detailtablename.length() > 0) { + if (!fieldbean_detailtable.equalsIgnoreCase(detailtablename)) { + continue; + } + } + if (!fieldBean.getFieldname().equalsIgnoreCase(bean.getField010()) || + StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp")) { + continue; + } + if (bean.getField011().equalsIgnoreCase("detail_leavefromDate")) { + detail_leavefromDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_leavefromTime")) { + detail_leavefromTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_leavetoDate")) { + detail_leavetoDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_leavetoTime")) { + detail_leavetoTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_newLeaveType")) { + detail_newLeaveType = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_leaveduration")) { + detail_leaveduration = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_fromDate")) { + detail_fromDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_fromTime")) { + detail_fromTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_toDate")) { + detail_toDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_toTime")) { + detail_toTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_duration")) { + detail_duration = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_edit_duration")) { + detail_edit_duration = FIELD + fieldBean.getId(); + break; + } + } + attid = bean.getId(); + } + + String[] result = new String[14]; + result[0] = resourceId; + result[1] = leaverequestid; + result[2] = detail_leavefromDate; + result[3] = detail_leavefromTime; + result[4] = detail_leavetoDate; + result[5] = detail_leavetoTime; + result[6] = detail_newLeaveType; + result[7] = detail_leaveduration; + result[8] = detail_fromDate; + result[9] = detail_fromTime; + result[10] = detail_toDate; + result[11] = detail_toTime; + result[12] = detail_duration; + result[13] = detail_edit_duration; + + fieldMap.put("fields", result); + fieldMap.put("usedetail", usedetailstr); + fieldMap.put("detailtablename", detailtablename); + if (detailtablename.length() > 0) { + int detailIndex = getDetail_index(formid + "", detailtablename); + fieldMap.put("detailIndex", detailIndex); + } + fieldMap.put("attid", attid); + return fieldMap; + } + + private Map getFieldList7(List fList, List fListDetail, List list) { + Map fieldMap = new HashMap<>(); + + String resourceId = ""; + String resourceIds = ""; + String fromDate = ""; + String toDate = ""; + String detail_scheduletime = ""; + String detail_atteStatus = ""; + String detail_signtype = ""; + String detail_signdate = ""; + String detail_signtime = ""; + String detail_resourceid = ""; + String detailtablename = ""; + Long attid = 0L; + int formid = 0; + + for (HrmAttProcSet bean : list) { + formid = bean.getField002(); + if (bean.getDetailtablename().length() > 0) { + detailtablename = bean.getDetailtablename(); + } + for (WorkflowBillfield fieldBean : fList) { + if (!fieldBean.getFieldname().equalsIgnoreCase(bean.getField010()) || + StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp")) { + continue; + } + if (bean.getField011().equalsIgnoreCase("resourceId")) { + resourceId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("fromDate")) { + fromDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("toDate")) { + toDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("resourceIds")) { + resourceIds = FIELD + fieldBean.getId(); + break; + } + } + for (WorkflowBillfield fieldBean : fListDetail) { + String fieldbean_detailtable = fieldBean.getDetailtable(); + if (fieldbean_detailtable.length() > 0 && detailtablename.length() > 0) { + if (!fieldbean_detailtable.equalsIgnoreCase(detailtablename)) { + continue; + } + } + if (!fieldBean.getFieldname().equalsIgnoreCase(bean.getField010()) || + StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp")) { + continue; + } + if (bean.getField011().equalsIgnoreCase("detail_scheduletime")) { + detail_scheduletime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_atteStatus")) { + detail_atteStatus = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_signtype")) { + detail_signtype = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_signdate")) { + detail_signdate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_signtime")) { + detail_signtime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_resourceid")) { + detail_resourceid = FIELD + fieldBean.getId(); + break; + } + } + attid = bean.getId(); + } + + String[] result = new String[10]; + result[0] = resourceId; + result[1] = fromDate; + result[2] = toDate; + result[3] = detail_scheduletime; + result[4] = detail_atteStatus; + result[5] = detail_signtype; + result[6] = detail_signdate; + result[7] = detail_signtime; + result[8] = resourceIds; + result[9] = detail_resourceid; + fieldMap.put("fields", result); + fieldMap.put("detailtablename", detailtablename); + if (detailtablename.length() > 0) { + int detailIndex = getDetail_index(formid + "", detailtablename); + fieldMap.put("detailIndex", detailIndex); + } + fieldMap.put("attid", attid); + return fieldMap; + } + + private Map getFieldList8(List fList, List fListDetail, List list) { + Map fieldMap = new HashMap<>(); + + String resourceId = ""; + String changerequestid = ""; + String changetype = ""; + String detail_attendancefromDate = ""; + String detail_attendancefromTime = ""; + String detail_attendancetoDate = ""; + String detail_attendancetoTime = ""; + String detail_attendanceduration = ""; + + String detail_fromDate = ""; + String detail_fromTime = ""; + String detail_toDate = ""; + String detail_toTime = ""; + String detail_duration = ""; + String detail_edit_duration = ""; + String usedetailstr = ""; + String detailtablename = ""; + Long attid = 0L; + int formid = 0; + + for (HrmAttProcSet bean : list) { + formid = bean.getField002(); + if (bean.getDetailtablename().length() > 0) { + detailtablename = bean.getDetailtablename(); + } + for (WorkflowBillfield fieldBean : fList) { + if (!fieldBean.getFieldname().equalsIgnoreCase(bean.getField010()) || + StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp")) { + continue; + } + if (bean.getField011().equalsIgnoreCase("resourceId")) { + resourceId = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("changerequestid")) { + changerequestid = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("changetype")) { + changetype = FIELD + fieldBean.getId(); + break; + } + } + for (WorkflowBillfield fieldBean : fListDetail) { + String fieldbean_detailtable = fieldBean.getDetailtable(); + if (fieldbean_detailtable.length() > 0 && detailtablename.length() > 0) { + if (!fieldbean_detailtable.equalsIgnoreCase(detailtablename)) { + continue; + } + } + if (!fieldBean.getFieldname().equalsIgnoreCase(bean.getField010()) || + StringUtil.isNull(bean.getField010()) || bean.getField010().endsWith("_temp")) { + continue; + } + if (bean.getField011().equalsIgnoreCase("detail_attendancefromDate")) { + detail_attendancefromDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_attendancefromTime")) { + detail_attendancefromTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_attendancetoDate")) { + detail_attendancetoDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_attendancetoTime")) { + detail_attendancetoTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_attendanceduration")) { + detail_attendanceduration = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_fromDate")) { + detail_fromDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_fromTime")) { + detail_fromTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_toDate")) { + detail_toDate = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_toTime")) { + detail_toTime = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_duration")) { + detail_duration = FIELD + fieldBean.getId(); + break; + } else if (bean.getField011().equalsIgnoreCase("detail_edit_duration")) { + detail_edit_duration = FIELD + fieldBean.getId(); + break; + } + } + attid = bean.getId(); + } + + String[] result = new String[14]; + result[0] = resourceId; + result[1] = changerequestid; + result[2] = changetype; + result[3] = detail_attendancefromDate; + result[4] = detail_attendancefromTime; + result[5] = detail_attendancetoDate; + result[6] = detail_attendancetoTime; + result[7] = detail_attendanceduration; + result[8] = detail_fromDate; + result[9] = detail_fromTime; + result[10] = detail_toDate; + result[11] = detail_toTime; + result[12] = detail_duration; + result[13] = detail_edit_duration; + + fieldMap.put("fields", result); + fieldMap.put("usedetail", usedetailstr); + fieldMap.put("detailtablename", detailtablename); + if (detailtablename.length() > 0) { + int detailIndex = getDetail_index(formid + "", detailtablename); + fieldMap.put("detailIndex", detailIndex); + } + fieldMap.put("attid", attid); + return fieldMap; + } + + /** + * 获取明细下标 WfForm.getDetailAllRowIndexStr("detail_*")这个*就是这个下标 + * + * @param formid + * @param tablename + * @return + */ + public int getDetail_index(String formid, String tablename) { + int index = 1; + RecordSet rs = new RecordSet(); + String sql = "select * from workflow_billdetailtable where billid = ? order by orderid"; + rs.executeQuery(sql, formid); + while (rs.next()) { + String detailname = rs.getString("tablename"); + if (tablename.equalsIgnoreCase(detailname)) { + return index; + } + index++; + } + return index; + } +} diff --git a/src/com/engine/kq/wfset/attendance/manager/WorkflowBaseManager.java b/src/com/engine/kq/wfset/attendance/manager/WorkflowBaseManager.java new file mode 100644 index 0000000..0695ae6 --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/manager/WorkflowBaseManager.java @@ -0,0 +1,40 @@ +package com.engine.kq.wfset.attendance.manager; + +import java.util.Map; + +import com.engine.kq.wfset.attendance.framework.BaseManager; +import com.engine.kq.wfset.attendance.dao.WorkflowBaseDao; +import com.engine.kq.wfset.attendance.domain.WorkflowBase; + +/** + * WorkflowBaseManager + *

Generated from 长东设计 www.mfstyle.cn

+ * + * @author wcd + * @version 1.0 2015-09-10 + */ +public class WorkflowBaseManager extends BaseManager { + + private WorkflowBaseDao dao = null; + + public WorkflowBaseManager() { + dao = new WorkflowBaseDao(); + this.setDao(dao); + } + + public Long save(WorkflowBase bean) { + String id = String.valueOf(bean.getId()); + if(id.equals("0") || id.equals("-1")) id = String.valueOf(this.insert(bean)); + else this.update(bean); + return Long.valueOf(id); + } + + public int count(String params) { + return dao.count(this.getMapParam(params)); + } + + public void delete(Map map) { + dao.delete(map); + } + +} diff --git a/src/com/engine/kq/wfset/attendance/manager/WorkflowBillfieldManager.java b/src/com/engine/kq/wfset/attendance/manager/WorkflowBillfieldManager.java new file mode 100644 index 0000000..7a0657e --- /dev/null +++ b/src/com/engine/kq/wfset/attendance/manager/WorkflowBillfieldManager.java @@ -0,0 +1,28 @@ +package com.engine.kq.wfset.attendance.manager; + +import com.engine.kq.wfset.attendance.framework.BaseManager; +import com.engine.kq.wfset.attendance.dao.WorkflowBillfieldDao; +import com.engine.kq.wfset.attendance.domain.WorkflowBillfield; + +/** + * WorkflowBillfieldManager + * @author wcd + * @version 1.0 2015-04-24 + */ +public class WorkflowBillfieldManager extends BaseManager { + + private WorkflowBillfieldDao dao = null; + + public WorkflowBillfieldManager() { + dao = new WorkflowBillfieldDao(); + this.setDao(dao); + } + + public Long save(WorkflowBillfield bean) { + String id = String.valueOf(bean.getId()); + if(id.equals("0") || id.equals("-1")) id = String.valueOf(this.insert(bean)); + else this.update(bean); + return Long.valueOf(id); + } + +} diff --git a/src/com/engine/kq/wfset/auto/AutoInitWFSet.java b/src/com/engine/kq/wfset/auto/AutoInitWFSet.java new file mode 100644 index 0000000..330ac0f --- /dev/null +++ b/src/com/engine/kq/wfset/auto/AutoInitWFSet.java @@ -0,0 +1,3383 @@ +package com.engine.kq.wfset.auto; + +import com.engine.kq.cmd.hrmAttProcSet.KqTempletEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.attendance.domain.HrmAttProcAction; +import com.engine.kq.wfset.attendance.domain.HrmAttProcRelation; +import com.engine.kq.wfset.attendance.domain.HrmAttProcSet; +import com.engine.kq.wfset.attendance.manager.HrmAttProcActionManagerE9; +import com.engine.kq.wfset.attendance.manager.HrmAttProcRelationManager; +import com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.apache.commons.lang.StringEscapeUtils; +import weaver.common.StringUtil; +import weaver.conn.ConnectionPool; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; +import weaver.monitor.cache.CacheFactory; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.label.LabelComInfo; +import weaver.workflow.action.WorkflowActionManager; +import weaver.workflow.form.FormManager; +import weaver.workflow.workflow.BillComInfo; +import weaver.workflow.workflow.WorkflowBillComInfo; + +public class AutoInitWFSet { + + private User user; + private boolean log; + private boolean isdetail; + private KQLog kqLog = new KQLog(); + + public AutoInitWFSet() { + this.log = true; + this.isdetail = false; + } + + public void InitWFSet(String symbol){ + RecordSet rs = new RecordSet(); + String wfSql = "select * from kq_wf_init where 1=1 and (cancelled is null or cancelled <> '1') "; + rs.executeQuery(wfSql); + + if(user == null){ + user = new User(1); + } +// Map wfType = new HashMap<>(); +// Map formNameLabels = new HashMap<>(); + + while(rs.next()){ +// 变更流程类型,0表示请假,1表示出差,2表示公出,3表示加班,4表示异常,5表示排班,6表示销假,7表示补卡 + String wftype = rs.getString("wftype"); + String usedetail = rs.getString("usedetail"); + if("1".equalsIgnoreCase(usedetail)){ + setIsdetail(true); + } + String wfname = SystemEnv.getHtmlLabelNames(rs.getString("wfnamelabel"), user.getLanguage()); + wfname = symbol+wfname; + + wfname = wfname.replaceAll("<","<").replaceAll(">",">"); + wfname = Util.toHtmlForSplitPage(wfname); + int formid = 0; + try { + //先创建表单 + formid = InitForm(wftype,wfname); + if(formid == 0){ + break; + } + //再创建流程 + Map wfMap = InitWorkflow(formid,wftype,wfname); + //再把考勤流程设置基本信息和字段信息保存 + InitSet(formid,wftype,wfname,wfMap,usedetail); + }catch (Exception e){ + rs.writeLog("wftype:"+wftype+":创建失败"); + e.printStackTrace(); + rs.writeLog(e.getMessage()); + } + } + } + + /** + * 一建初始化,初始化考勤流程 + * @param wftype 0表示请假,1表示出差,2表示公出,3表示加班,4表示异常,5表示排班,6表示销假,7表示补卡 + * @param wfname + * @throws Exception + */ + public boolean initWfForKQ(int wftype,String wfname,String usedetail) { + boolean isInit = true; + try{ + wfname = wfname.replaceAll("<","<").replaceAll(">",">"); + wfname = Util.toHtmlForSplitPage(wfname); + int formid = 0; + //先创建表单 + formid = InitForm(wftype+"",wfname); + if(formid == 0){ + return false; + } + //再创建流程 + Map wfMap = InitWorkflow(formid,wftype+"",wfname); + //再把考勤流程设置基本信息和字段信息保存 + InitSet(formid,wftype+"",wfname,wfMap,usedetail); + }catch (Exception e){ + isInit = false; + new BaseBean().writeLog("wftype:"+wftype+":创建失败"); + e.printStackTrace(); + } + + return isInit; + } + + public int InitForm(String wfType,String wfname) throws Exception{ + + int formid = 0; + //同名校验 通过 + if(!homonymyCheck(wfname)){ + RecordSet rs = new RecordSet(); + RecordSetTrans rst = new RecordSetTrans(); + FormManager formManager = new FormManager(); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + LabelComInfo labelComInfo = new LabelComInfo(); + BillComInfo billComInfo = new BillComInfo(); + + int subcompanyid = -1; + int subCompanyId3 = -1; + + String formtable_main = ""; + String formtable_main_mx = ""; + + formid = formManager.getNewFormId(); + formtable_main = "formtable_main_"+Math.abs(formid); + formtable_main_mx = formtable_main+"_dt1"; + + rst.setChecksql(false); + rst.setAutoCommit(false); + try{ + //1、先获取到表单的namelabelid + int namelabelid = -1; + if((rs.getDBType()).equalsIgnoreCase("sqlserver")){ + rst.executeSql("select indexid from HtmlLabelInfo "+ + " where labelname='"+StringEscapeUtils.escapeSql(wfname)+"' collate Chinese_PRC_CS_AI "+ + " and languageid="+Util.getIntValue(""+user.getLanguage(),7)); + }else { + rst.executeSql("select indexid from HtmlLabelInfo "+ + " where labelname='"+StringEscapeUtils.escapeSql(wfname)+"' "+ + " and languageid="+Util.getIntValue(""+user.getLanguage(),7)); + } + if(rst.next()){ + namelabelid = rst.getInt("indexid");//如果表单名称在标签库中存在,取得标签id + }else{ + namelabelid = formManager.getNewIndexId(rst);//生成新的标签id + if(namelabelid!=-1){//更新标签库 + rst.executeSql("delete from HtmlLabelIndex where id="+namelabelid); + rst.executeSql("delete from HtmlLabelInfo where indexid="+namelabelid); + rst.executeSql(" insert into HtmlLabelIndex(id,indexdesc) values("+namelabelid+",'"+StringEscapeUtils.escapeSql(wfname)+"')"); + rst.executeSql(" insert into HtmlLabelInfo(INDEXID,labelname, LANGUAGEID) values("+namelabelid+",'"+StringEscapeUtils.escapeSql(wfname)+"',7)"); + rst.executeSql(" insert into HtmlLabelInfo(INDEXID,labelname, LANGUAGEID) values("+namelabelid+",'"+StringEscapeUtils.escapeSql(wfname)+"',8)"); + rst.executeSql(" insert into HtmlLabelInfo(INDEXID,labelname, LANGUAGEID) values("+namelabelid+",'"+StringEscapeUtils.escapeSql(wfname)+"',9)"); + + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'HtmlLabelIndex',"+namelabelid+",'id')"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'HtmlLabelInfo',"+namelabelid+",'indexid')"); + } + } + + //2、获取分权分部。如果页面没有,则首先从分权设置的默认机构取得,如果默认机构没有设置则取所有分部中id最小的那个分部。 + subcompanyid = Util.getIntValue(manageDetachComInfo.getWfdftsubcomid(), -1); + subCompanyId3 = Util.getIntValue(manageDetachComInfo.getWfdftsubcomid(), -1); + if(subcompanyid==-1){ + rst.executeSql("select min(id) as id from HrmSubCompany"); + if(rst.next()){ + subcompanyid = rst.getInt("id"); + } + } + if(subCompanyId3==-1){ + rst.executeSql("select min(id) as id from HrmSubCompany"); + if(rst.next()){ + subCompanyId3 = rst.getInt("id"); + } + } + rst.executeSql("insert into workflow_bill(id,namelabel,tablename,detailkeyfield,formdes,subcompanyid,subCompanyId3) "+ + " values("+formid+","+namelabelid+",'"+StringEscapeUtils.escapeSql(formtable_main)+"','mainid','',"+subcompanyid+","+subCompanyId3+")"); + if(rs.getDBType().equalsIgnoreCase("oracle")){//创建表单主表,明细表的创建在新建字段的时候如果有明细字段则创建明细表 + rs.executeSql("create table " + formtable_main + "(id integer primary key not null, requestId integer)"); + if(isdetail) { + //如果是明细表,oracle情况下还需要创建下序列和触发器 + String appendSql = ""; + rs.executeSql("create sequence "+formtable_main+"_Id start with 1 increment by 1 maxvalue 9223372036854775807 nocycle nocache "); + rs.setChecksql(false); + rs.executeSql("create or replace trigger "+formtable_main+"_ID_TR before insert on "+formtable_main+" for each row begin select "+formtable_main+"_Id.nextval into :new.id from dual; end;"); + } + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + rs.executeSql("create table " + formtable_main + "(id int AUTO_INCREMENT primary key , requestId int)"); + } + else if((rs.getDBType()).equalsIgnoreCase("postgresql")){ + rs.executeSql("create table " + formtable_main + "(id serial primary key , requestId int)"); + } + else{ + rs.executeSql("create table " + formtable_main + "(id int IDENTITY(1,1) primary key , requestId int)"); + } + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_bill',"+formid+",'id')"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'formtable_main','"+formtable_main+"','id')"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'formtable_main','"+formtable_main_mx+"','id')"); + + //创建主表的sql + List tableCreateSql_array = new ArrayList(); +// 创建明细表的sql + List detailtable_array = new ArrayList(); + //创建表索引的sql + List tableCreateIndexSql_array = new ArrayList(); + //创建表字段的sql + List tableFieldInitSql_array = new ArrayList(); + +// 变更流程类型,0表示请假,1表示出差,2表示公出,3表示加班,4表示异常,5表示排班,6表示销假 +// 考勤流程数据库字段对应 180表示请假,181表示出差,182表示公出,45表示加班,0表示异常,5表示排班,6表示销假 + //0表示请假 + if("0".equals(wfType)){ + initWfType0(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array); + } + //1表示出差 + if("1".equals(wfType)){ + initWfType1(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array); + } + //2表示公出 + if("2".equals(wfType)){ + initWfType2(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array); + } + //3表示加班 + if("3".equals(wfType)){ + initWfType3(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array); + } + //4表示异常 + if("4".equals(wfType)){ + initWfType4(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array); + } + //5表示排班 + if("5".equals(wfType)){ + initWfType5(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array); + } + //6表示销假 + if("6".equals(wfType)){ + initWfType6(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array); + } + //7表示补卡 + if("7".equals(wfType)){ + initWfType7(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array); + } + //8表示考勤变更流程 + if("8".equals(wfType)){ + initWfType8(formid,formtable_main,formtable_main_mx,tableCreateSql_array,detailtable_array,tableCreateIndexSql_array,tableFieldInitSql_array); + } + + //添加主表字段、建明细表 + for(int tempi=0;tempi tableCreateSql_array,List detailtable_array,List tableCreateIndexSql_array,List tableFieldInitSql_array) { + + RecordSet rs = new RecordSet(); + if(isdetail){ + detailtable_array.add(formtable_main_mx); + } + if(rs.getDBType().equalsIgnoreCase("oracle")){ + if(isdetail) { + tableCreateSql_array.add("create table " + formtable_main_mx + + " (id integer primary key not null, mainid integer, " + + "detail_resourceId int, detail_departmentId int, detail_newLeaveType int, detail_fromDate char(10)," + + + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_vacationInfo varchar2(500))"); + tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache "); + + tableCreateIndexSql_array.add("create or replace trigger " + formtable_main_mx + "_ID_TR " + + " before insert on " + formtable_main_mx + " for each row " + + " begin " + + " select " + formtable_main_mx + "_ID.nextval into :new.id from dual; " + + " end;"); + tableCreateIndexSql_array.add( + "create index idx_" + formtable_main_mx + " on " + formtable_main_mx + + " (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_vacationInfo',390297,'varchar(500)','2',1,1,'"+formtable_main_mx+"','1',4,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add newLeaveType int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + tableCreateSql_array.add("alter table "+formtable_main+" add vacationInfo varchar(500)"); + + tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache "); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " + + " before insert on "+formtable_main+" for each row " + + " begin " + + " select "+formtable_main+"_ID.nextval into :new.id from dual; " + + " end;"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'newLeaveType',1881,'int','3',34,0,'','1',0,3.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'vacationInfo',390297,'varchar(500)','2',1,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + } + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(0,'sequence','"+formtable_main+"_ID','id')"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(0,'sequence','"+formtable_main_mx+"_ID','id')"); + + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_newLeaveType int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_vacationInfo varchar(500))"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_vacationInfo',390297,'varchar(500)','2',1,1,'"+formtable_main_mx+"','1',4,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + else{ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add newLeaveType int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + tableCreateSql_array.add("alter table "+formtable_main+" add vacationInfo varchar(500)"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'newLeaveType',1881,'int','3',34,0,'','1',0,3.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'vacationInfo',390297,'varchar(500)','2',1,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + } + + } + else if((rs.getDBType()).equalsIgnoreCase("postgresql")){ + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_newLeaveType int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_vacationInfo varchar(500))"); + //tableCreateIndexSql_array.add("create unique index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_vacationInfo',390297,'varchar(500)','2',1,1,'"+formtable_main_mx+"','1',4,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + else{ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add newLeaveType int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + tableCreateSql_array.add("alter table "+formtable_main+" add vacationInfo varchar(500)"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'newLeaveType',1881,'int','3',34,0,'','1',0,3.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'vacationInfo',390297,'varchar(500)','2',1,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + } + + } + + else{ + if(isdetail) { + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_newLeaveType int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_vacationInfo varchar(500))"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_vacationInfo',390297,'varchar(500)','2',1,1,'"+formtable_main_mx+"','1',4,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add newLeaveType int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + tableCreateSql_array.add("alter table "+formtable_main+" add vacationInfo varchar(500)"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'newLeaveType',1881,'int','3',34,0,'','1',0,3.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'vacationInfo',390297,'varchar(500)','2',1,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + } + } + + } + + /** + * 出差流程的表结构创建 + * @param formid + * @param formtable_main + * @param formtable_main_mx + * @param tableCreateSql_array + * @param detailtable_array + * @param tableCreateIndexSql_array + * @param tableFieldInitSql_array + */ + private void initWfType1(int formid,String formtable_main, String formtable_main_mx,List tableCreateSql_array,List detailtable_array,List tableCreateIndexSql_array,List tableFieldInitSql_array) { + + RecordSet rs = new RecordSet(); + + if(isdetail) { + detailtable_array.add(formtable_main_mx); + } + if(rs.getDBType().equalsIgnoreCase("oracle")){ + + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_companion clob)"); + + tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache "); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " + + " before insert on "+formtable_main_mx+" for each row " + + " begin " + + " select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " + + " end;"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_companion','27209','clob','3',17,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + tableCreateSql_array.add("alter table "+formtable_main+" add companion clob"); + if("jc".equalsIgnoreCase(rs.getOrgindbtype()) || "st".equalsIgnoreCase(rs.getOrgindbtype()) || "gs".equalsIgnoreCase(rs.getOrgindbtype())){ + tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9223372036854775807 NOCYCLE "); + }else{ + tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9999999999999999999999999999 NOCYCLE "); + } + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " + + " before insert on "+formtable_main+" for each row " + + " begin " + + " select "+formtable_main+"_ID.nextval into :new.id from dual; " + + " end;"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',4,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'companion',27209,'clob','3',17,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + } + + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(1,'sequence','"+formtable_main+"_ID','id')"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(1,'sequence','"+formtable_main_mx+"_ID','id')"); + + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_companion text)"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_companion','27209','text','3',17,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + tableCreateSql_array.add("alter table "+formtable_main+" add companion text"); + + tableCreateIndexSql_array.add("create unique index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'companion',27209,'text','3',17,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + } + + } + else if((rs.getDBType()).equalsIgnoreCase("postgresql")){ + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_companion text)"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_companion','27209','text','3',17,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + tableCreateSql_array.add("alter table "+formtable_main+" add companion text"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'companion',27209,'text','3',17,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + } + + } + else{ + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2), detail_companion text)"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_companion','27209','text','3',17,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + tableCreateSql_array.add("alter table "+formtable_main+" add companion text"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'companion',27209,'text','3',17,0,'','1',4,9.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + } + + } + + } + + /** + * 公出流程表结构 + * @param formid + * @param formtable_main + * @param formtable_main_mx + * @param tableCreateSql_array + * @param detailtable_array + * @param tableCreateIndexSql_array + * @param tableFieldInitSql_array + */ + private void initWfType2(int formid,String formtable_main, String formtable_main_mx,List tableCreateSql_array,List detailtable_array,List tableCreateIndexSql_array,List tableFieldInitSql_array) { + + RecordSet rs = new RecordSet(); + + if(isdetail) { + detailtable_array.add(formtable_main_mx); + } + if(rs.getDBType().equalsIgnoreCase("oracle")){ + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2))"); + + tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache "); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " + + " before insert on "+formtable_main_mx+" for each row " + + " begin " + + " select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " + + " end;"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + + if("jc".equalsIgnoreCase(rs.getOrgindbtype()) || "st".equalsIgnoreCase(rs.getOrgindbtype()) || "gs".equalsIgnoreCase(rs.getOrgindbtype())){ + tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9223372036854775807 NOCYCLE "); + }else{ + tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9999999999999999999999999999 NOCYCLE "); + } + + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(2,'sequence','"+formtable_main+"_ID','id')"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(2,'sequence','"+formtable_main_mx+"_ID','id')"); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " + + " before insert on "+formtable_main+" for each row " + + " begin " + + " select "+formtable_main+"_ID.nextval into :new.id from dual; " + + " end;"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',4,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + } + + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2))"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + } + } + else if((rs.getDBType()).equalsIgnoreCase("postgresql")){ + + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2))"); + //tableCreateIndexSql_array.add("create unique index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + + tableCreateIndexSql_array.add("create unique index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + } + } + else{ + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_duration decimal(15,2))"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration','21551','decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,8.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + } + } + + } + + /** + * 加班流程表结构 + * @param formid + * @param formtable_main + * @param formtable_main_mx + * @param tableCreateSql_array + * @param detailtable_array + * @param tableCreateIndexSql_array + * @param tableFieldInitSql_array + */ + private void initWfType3(int formid,String formtable_main, String formtable_main_mx,List tableCreateSql_array,List detailtable_array,List tableCreateIndexSql_array,List tableFieldInitSql_array) { + + RecordSet rs = new RecordSet(); + + if(isdetail) { + detailtable_array.add(formtable_main_mx); + } + if(rs.getDBType().equalsIgnoreCase("oracle")){ + if(isdetail) { + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_overtime_type int, detail_duration decimal(15,2))"); + tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache "); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " + + " before insert on "+formtable_main_mx+" for each row " + + " begin " + + " select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " + + " end;"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_overtime_type',525492,'int','5',1,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add overtime_type char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + + if("jc".equalsIgnoreCase(rs.getOrgindbtype()) || "st".equalsIgnoreCase(rs.getOrgindbtype()) || "gs".equalsIgnoreCase(rs.getOrgindbtype())){ + tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9223372036854775807 NOCYCLE "); + }else{ + tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9999999999999999999999999999 NOCYCLE "); + } + + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(3,'sequence','"+formtable_main+"_ID','id')"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(3,'sequence','"+formtable_main_mx+"_ID','id')"); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " + + " before insert on "+formtable_main+" for each row " + + " begin " + + " select "+formtable_main+"_ID.nextval into :new.id from dual; " + + " end;"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'overtime_type',525492,'int','5',1,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + + } + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_overtime_type int, detail_duration decimal(15,2))"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_overtime_type',525492,'int','5',1,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add overtime_type char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'overtime_type',525492,'int','5',1,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + } + + } + else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_overtime_type int, detail_duration decimal(15,2))"); + tableCreateIndexSql_array.add("create unique index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_overtime_type',525492,'int','5',1,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add overtime_type char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + + tableCreateIndexSql_array.add("create unique index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'overtime_type',525492,'int','5',1,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + } + + } + + else{ + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8), detail_overtime_type int, detail_duration decimal(15,2))"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_overtime_type',525492,'int','5',1,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration',21551,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add overtime_type char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add duration decimal(15,2)"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'overtime_type',525492,'int','5',1,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'duration',21551,'decimal(15,2)','1',3,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + } + } + + } + + /** + * 异常流程 + * @param formid + * @param formtable_main + * @param formtable_main_mx + * @param tableCreateSql_array + * @param detailtable_array + * @param tableCreateIndexSql_array + * @param tableFieldInitSql_array + */ + private void initWfType4(int formid,String formtable_main, String formtable_main_mx,List tableCreateSql_array,List detailtable_array,List tableCreateIndexSql_array,List tableFieldInitSql_array) { + + RecordSet rs = new RecordSet(); + + if(isdetail) { + detailtable_array.add(formtable_main_mx); + } + + if(rs.getDBType().equalsIgnoreCase("oracle")){ + if(isdetail) { + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8))"); + tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache "); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " + + " before insert on "+formtable_main_mx+" for each row " + + " begin " + + " select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " + + " end;"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + + if("jc".equalsIgnoreCase(rs.getOrgindbtype()) || "st".equalsIgnoreCase(rs.getOrgindbtype()) || "gs".equalsIgnoreCase(rs.getOrgindbtype())){ + tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9223372036854775807 NOCYCLE "); + }else{ + tableCreateIndexSql_array.add("create sequence "+formtable_main+"_ID increment by 1 start with 1 MINVALUE 1 maxvalue 9999999999999999999999999999 NOCYCLE "); + } + + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(4,'sequence','"+formtable_main+"_ID','id')"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(4,'sequence','"+formtable_main_mx+"_ID','id')"); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " + + " before insert on "+formtable_main+" for each row " + + " begin " + + " select "+formtable_main+"_ID.nextval into :new.id from dual; " + + " end;"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + } + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8))"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + } + + } + else if((rs.getDBType()).equalsIgnoreCase("postgresql")){ + if(isdetail) { + tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8))"); + // tableCreateIndexSql_array.add("create unique index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + + tableCreateIndexSql_array.add("create unique index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + } + + } + + else{ + if(isdetail) { + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+ + "detail_resourceId int, detail_departmentId int, detail_fromDate char(10),"+ + "detail_fromTime char(8), detail_toDate char(10), detail_toTime char(8))"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',413,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_departmentId',124,'int','3',4,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',742,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',743,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + }else{ + + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add departmentId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromTime char(8)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toTime char(8)"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',413,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'departmentId',124,'int','3',4,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromTime',742,'char(8)','3',19,0,'','1',0,5.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,6.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toTime',743,'char(8)','3',19,0,'','1',0,7.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + } + } + + } + + /** + * 排班流程 + * 现在只有明细 + * @param formid + * @param formtable_main + * @param formtable_main_mx + * @param tableCreateSql_array + * @param detailtable_array + * @param tableCreateIndexSql_array + * @param tableFieldInitSql_array + */ + private void initWfType5(int formid,String formtable_main, String formtable_main_mx,List tableCreateSql_array,List detailtable_array,List tableCreateIndexSql_array,List tableFieldInitSql_array) { + + RecordSet rs = new RecordSet(); + + detailtable_array.add(formtable_main_mx); + if(rs.getDBType().equalsIgnoreCase("oracle")){ + tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+ + "detail_resourceId int, detail_fromDate char(10), detail_toDate char(10),"+ + "detail_shift int, detail_group int)"); + tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache "); + + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(5,'sequence','"+formtable_main+"_ID','id')"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(5,'sequence','"+formtable_main_mx+"_ID','id')"); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " + + " before insert on "+formtable_main_mx+" for each row " + + " begin " + + " select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " + + " end;"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',125839,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_shift',390738,'int','3',388,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_group',390221,'int','3',389,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+ + "detail_resourceId int, detail_fromDate char(10),"+ + "detail_toDate char(10), detail_shift int, detail_group int)"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',125839,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_shift',390738,'int','3',388,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_group',390221,'int','3',389,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + else if((rs.getDBType()).equalsIgnoreCase("postgresql")){ + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+ + "detail_resourceId int, detail_fromDate char(10),"+ + "detail_toDate char(10), detail_shift int, detail_group int)"); + // tableCreateIndexSql_array.add("create unique index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',125839,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_shift',390738,'int','3',388,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_group',390221,'int','3',389,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + else{ + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+ + "detail_resourceId int, detail_fromDate char(10),"+ + "detail_toDate char(10), detail_shift int, detail_group int)"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_resourceId)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceId',125839,'int','3',1,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',740,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',741,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_shift',390738,'int','3',388,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_group',390221,'int','3',389,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + + } + + /** + * 销假流程 + * @param formid + * @param formtable_main + * @param formtable_main_mx + * @param tableCreateSql_array + * @param detailtable_array + * @param tableCreateIndexSql_array + * @param tableFieldInitSql_array + */ + private void initWfType6(int formid,String formtable_main, String formtable_main_mx,List tableCreateSql_array,List detailtable_array,List tableCreateIndexSql_array,List tableFieldInitSql_array) { + + RecordSet rs = new RecordSet(); + + detailtable_array.add(formtable_main_mx); + + if(rs.getDBType().equalsIgnoreCase("oracle")){ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add leaverequestid int"); + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+ + "detail_leavefromDate char(10), detail_leavefromTime char(8),detail_leavetoDate char(10),"+ + "detail_leavetoTime char(8), detail_newLeaveType int, detail_leaveduration decimal(15,2), " + + "detail_fromDate char(10), detail_fromTime char(8),detail_toDate char(10),detail_toTime char(8), " + + "detail_duration decimal(15,2))"); + tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache "); + + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(6,'sequence','"+formtable_main+"_ID','id')"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(6,'sequence','"+formtable_main_mx+"_ID','id')"); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " + + " before insert on "+formtable_main+" for each row " + + " begin " + + " select "+formtable_main+"_ID.nextval into :new.id from dual; " + + " end;"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " + + " before insert on "+formtable_main_mx+" for each row " + + " begin " + + " select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " + + " end;"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',389034,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'leaverequestid',83393,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavefromDate',30547,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavefromTime',30548,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavetoDate',30549,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavetoTime',30550,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leaveduration',500672,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',389035,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',389036,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',389037,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',389038,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration',389039,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,11.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add leaverequestid int"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+ + "detail_leavefromDate char(10), detail_leavefromTime char(8),detail_leavetoDate char(10),"+ + "detail_leavetoTime char(8), detail_newLeaveType int, detail_leaveduration decimal(15,2), " + + "detail_fromDate char(10), detail_fromTime char(8),detail_toDate char(10),detail_toTime char(8), " + + "detail_duration decimal(15,2))"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',389034,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'leaverequestid',83393,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavefromDate',30547,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavefromTime',30548,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavetoDate',30549,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavetoTime',30550,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leaveduration',500672,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',389035,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',389036,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',389037,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',389038,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration',389039,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,11.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + else if((rs.getDBType()).equalsIgnoreCase("postgresql")){ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add leaverequestid int"); + +// tableCreateIndexSql_array.add("create unique index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+ + "detail_leavefromDate char(10), detail_leavefromTime char(8),detail_leavetoDate char(10),"+ + "detail_leavetoTime char(8), detail_newLeaveType int, detail_leaveduration decimal(15,2), " + + "detail_fromDate char(10), detail_fromTime char(8),detail_toDate char(10),detail_toTime char(8), " + + "detail_duration decimal(15,2))"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',389034,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'leaverequestid',83393,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavefromDate',30547,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavefromTime',30548,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavetoDate',30549,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavetoTime',30550,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leaveduration',500672,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',389035,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',389036,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',389037,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',389038,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration',389039,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,11.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + else{ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add leaverequestid int"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+ + "detail_leavefromDate char(10), detail_leavefromTime char(8),detail_leavetoDate char(10),"+ + "detail_leavetoTime char(8), detail_newLeaveType int, detail_leaveduration decimal(15,2), " + + "detail_fromDate char(10), detail_fromTime char(8),detail_toDate char(10),detail_toTime char(8), " + + "detail_duration decimal(15,2))"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',389034,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'leaverequestid',83393,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavefromDate',30547,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavefromTime',30548,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavetoDate',30549,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leavetoTime',30550,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_newLeaveType',1881,'int','3',34,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_leaveduration',500672,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromDate',389035,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_fromTime',389036,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toDate',389037,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_toTime',389038,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_duration',389039,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,11.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + + } + + /** + * 补卡流程 + * @param formid + * @param formtable_main + * @param formtable_main_mx + * @param tableCreateSql_array + * @param detailtable_array + * @param tableCreateIndexSql_array + * @param tableFieldInitSql_array + */ + private void initWfType7(int formid,String formtable_main, String formtable_main_mx,List tableCreateSql_array,List detailtable_array,List tableCreateIndexSql_array,List tableFieldInitSql_array) { + + RecordSet rs = new RecordSet(); + + detailtable_array.add(formtable_main_mx); + if(rs.getDBType().equalsIgnoreCase("oracle")){ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add resourceIds clob"); + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+ + "detail_signdate char(10),detail_scheduletime varchar2(100),detail_atteStatus varchar2(100),detail_signtype int,"+ + "detail_signtime char(8))"); + tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache "); + + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(7,'sequence','"+formtable_main+"_ID','id')"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(7,'sequence','"+formtable_main_mx+"_ID','id')"); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " + + " before insert on "+formtable_main+" for each row " + + " begin " + + " select "+formtable_main+"_ID.nextval into :new.id from dual; " + + " end;"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " + + " before insert on "+formtable_main_mx+" for each row " + + " begin " + + " select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " + + " end;"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_signdate)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',1867,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceIds',382459,'clob','3',17,0,'','1',0,1.50,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_signdate',382262,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_scheduletime',125821,'varchar2(100)','1',1,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_atteStatus',25005,'varchar2(100)','1',1,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_signtype',382261,'int','5',1,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_signtime',382263,'char(8)','3',19,1,'"+formtable_main_mx+"','1',4,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceid',1867,'int','3',1,1,'"+formtable_main_mx+"','1',4,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add resourceIds text"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+ + "detail_signdate char(10), detail_scheduletime varchar(100),detail_atteStatus varchar(100),detail_signtype int,"+ + "detail_signtime char(8))"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_signdate)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',1867,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceIds',382459,'text','3',17,0,'','1',0,1.50,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_signdate',382262,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_scheduletime',125821,'varchar(100)','1',1,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_atteStatus',25005,'varchar(100)','1',1,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_signtype',382261,'int','5',1,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_signtime',382263,'char(8)','3',19,1,'"+formtable_main_mx+"','1',4,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceid',1867,'int','3',1,1,'"+formtable_main_mx+"','1',4,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + else if((rs.getDBType()).equalsIgnoreCase("postgresql")){ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add resourceIds text"); + +// tableCreateIndexSql_array.add("create unique index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+ + "detail_signdate char(10), detail_scheduletime char(100),detail_atteStatus char(100),detail_signtype int,"+ + "detail_signtime char(8))"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_signdate)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',1867,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceIds',382459,'text','3',17,0,'','1',0,1.50,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_signdate',382262,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_scheduletime',125821,'char(100)','1',1,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_atteStatus',25005,'char(100)','1',1,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_signtype',382261,'int','5',1,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_signtime',382263,'char(8)','3',19,1,'"+formtable_main_mx+"','1',4,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceid',1867,'int','3',1,1,'"+formtable_main_mx+"','1',4,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + else{ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add fromDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add toDate char(10)"); + tableCreateSql_array.add("alter table "+formtable_main+" add resourceIds text"); + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+ + "detail_signdate char(10), detail_scheduletime varchar(100),detail_atteStatus varchar(100),detail_signtype int,"+ + "detail_signtime char(8))"); + + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + tableCreateIndexSql_array.add("create index idx_"+formtable_main_mx+" on "+formtable_main_mx+" (detail_signdate)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',1867,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'fromDate',740,'char(10)','3',2,0,'','1',0,2.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'toDate',741,'char(10)','3',2,0,'','1',0,4.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceIds',382459,'text','3',17,0,'','1',0,1.50,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_signdate',382262,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_scheduletime',125821,'varchar(100)','1',1,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_atteStatus',25005,'varchar(100)','1',1,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_signtype',382261,'int','5',1,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_signtime',382263,'char(8)','3',19,1,'"+formtable_main_mx+"','1',4,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_resourceid',1867,'int','3',1,1,'"+formtable_main_mx+"','1',4,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + + } + + + /** + * 考勤变更流程 + * @param formid + * @param formtable_main + * @param formtable_main_mx + * @param tableCreateSql_array + * @param detailtable_array + * @param tableCreateIndexSql_array + * @param tableFieldInitSql_array + */ + private void initWfType8(int formid,String formtable_main, String formtable_main_mx,List tableCreateSql_array,List detailtable_array,List tableCreateIndexSql_array,List tableFieldInitSql_array) { + + RecordSet rs = new RecordSet(); + + detailtable_array.add(formtable_main_mx); + + if(rs.getDBType().equalsIgnoreCase("oracle")){ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add changerequestid int"); + tableCreateSql_array.add("alter table "+formtable_main+" add changetype int"); + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id integer primary key not null, mainid integer, "+ + "detail_attendancefromDate char(10), detail_attendancefromTime char(8),detail_attendancetoDate char(10),"+ + "detail_attendancetoTime char(8), detail_attendanceduration decimal(15,2), " + + "detail_changefromDate char(10), detail_changefromTime char(8),detail_changetoDate char(10),detail_changetoTime char(8), " + + "detail_changeduration decimal(15,2))"); + tableCreateIndexSql_array.add("create sequence "+formtable_main_mx+"_ID minvalue 1 maxvalue 9223372036854775807 start with 1 increment by 1 nocache "); + + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(7,'sequence','"+formtable_main+"_ID','id')"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values(7,'sequence','"+formtable_main_mx+"_ID','id')"); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main+"_ID_TR " + + " before insert on "+formtable_main+" for each row " + + " begin " + + " select "+formtable_main+"_ID.nextval into :new.id from dual; " + + " end;"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableCreateIndexSql_array.add("create or replace trigger "+formtable_main_mx+"_ID_TR " + + " before insert on "+formtable_main_mx+" for each row " + + " begin " + + " select "+formtable_main_mx+"_ID.nextval into :new.id from dual; " + + " end;"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',513403,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'changerequestid',503981,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'changetype',513404,'int','5',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancefromDate',513405,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancefromTime',513406,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancetoDate',513407,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancetoTime',513408,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendanceduration',513409,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changefromDate',513410,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changefromTime',513411,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changetoDate',513412,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changetoTime',513413,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changeduration',513414,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add changerequestid int"); + tableCreateSql_array.add("alter table "+formtable_main+" add changetype int"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int AUTO_INCREMENT primary key not null, mainid integer, "+ + "detail_attendancefromDate char(10), detail_attendancefromTime char(8),detail_attendancetoDate char(10),"+ + "detail_attendancetoTime char(8), detail_attendanceduration decimal(15,2), " + + "detail_changefromDate char(10), detail_changefromTime char(8),detail_changetoDate char(10),detail_changetoTime char(8), " + + "detail_changeduration decimal(15,2))"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',513403,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'changerequestid',503981,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'changetype',513404,'int','5',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancefromDate',513405,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancefromTime',513406,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancetoDate',513407,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancetoTime',513408,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendanceduration',513409,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changefromDate',513410,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changefromTime',513411,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changetoDate',513412,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changetoTime',513413,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changeduration',513414,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + else if((rs.getDBType()).equalsIgnoreCase("postgresql")){ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add changerequestid int"); + tableCreateSql_array.add("alter table "+formtable_main+" add changetype int"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id serial primary key not null, mainid integer, "+ + "detail_attendancefromDate char(10), detail_attendancefromTime char(8),detail_attendancetoDate char(10),"+ + "detail_attendancetoTime char(8), detail_attendanceduration decimal(15,2), " + + "detail_changefromDate char(10), detail_changefromTime char(8),detail_changetoDate char(10),detail_changetoTime char(8), " + + "detail_changeduration decimal(15,2))"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',513403,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'changerequestid',503981,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'changetype',513404,'int','5',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancefromDate',513405,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancefromTime',513406,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancetoDate',513407,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancetoTime',513408,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendanceduration',513409,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changefromDate',513410,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changefromTime',513411,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changetoDate',513412,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changetoTime',513413,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changeduration',513414,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + else{ + tableCreateSql_array.add("alter table "+formtable_main+" add resourceId int"); + tableCreateSql_array.add("alter table "+formtable_main+" add changerequestid int"); + tableCreateSql_array.add("alter table "+formtable_main+" add changetype int"); + + tableCreateIndexSql_array.add("create index idx_"+formtable_main+" on "+formtable_main+" (resourceId)"); + + tableCreateSql_array.add("create table "+formtable_main_mx+" (id int IDENTITY(1,1) primary key not null, mainid integer, "+ + "detail_attendancefromDate char(10), detail_attendancefromTime char(8),detail_attendancetoDate char(10),"+ + "detail_attendancetoTime char(8), detail_attendanceduration decimal(15,2), " + + "detail_changefromDate char(10), detail_changefromTime char(8),detail_changetoDate char(10),detail_changetoTime char(8), " + + "detail_changeduration decimal(15,2))"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'resourceId',513403,'int','3',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'changerequestid',503981,'int','3',16,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'changetype',513404,'int','5',1,0,'','1',0,1.00,0,100,100,0,'0','',0,0,'0',0,0,0,null)"); + + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancefromDate',513405,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,1.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancefromTime',513406,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,2.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancetoDate',513407,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,3.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendancetoTime',513408,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,4.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_attendanceduration',513409,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,5.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changefromDate',513410,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,6.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changefromTime',513411,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,7.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changetoDate',513412,'char(10)','3',2,1,'"+formtable_main_mx+"','1',0,8.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changetoTime',513413,'char(8)','3',19,1,'"+formtable_main_mx+"','1',0,9.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + tableFieldInitSql_array.add("insert into workflow_billfield (billid,fieldname,fieldlabel,fielddbtype,fieldhtmltype,type,viewtype,detailtable,fromUser,textheight,dsporder,childfieldid,imgheight,imgwidth,places,qfws,textheight_2,selectitem,linkfield,selectItemType,pubchoiceId,pubchilchoiceId,statelev,locatetype)"+ + "values("+formid+",'detail_changeduration',513414,'decimal(15,2)','1',3,1,'"+formtable_main_mx+"','1',0,10.00,0,50,50,0,'0','',0,0,'0',0,0,0,null)"); + + } + + } + + public Map InitWorkflow(int formid,String wfType,String wfname) throws Exception{ + Map wfMap = new HashMap<>(); + int wfid = 0; + String[] _workflow_nodeId_array = new String[]{ + "0",//创建 + "0",//审批 + "0"//归档 + }; + RecordSet rs = new RecordSet(); + RecordSetTrans rst = new RecordSetTrans(); + try { + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + + int subcompanyid = -1; + int wfTypeid = 1;//系统默认工作流 + String sql = ""; + + //获取分权分部。如果页面没有,则首先从分权设置的默认机构取得,如果默认机构没有设置则取所有分部中id最小的那个分部。 + subcompanyid = Util.getIntValue(manageDetachComInfo.getWfdftsubcomid(), -1); + + HashMap wfBillfield_hm = new HashMap(); + rs.executeSql("select id, fieldname from workflow_billfield where billid = "+formid); + while(rs.next()){ + wfBillfield_hm.put(Util.null2String(rs.getString("fieldname")).trim(), rs.getString("id")); + } + String _guid1 = UUID.randomUUID().toString(); + + //新建流程 + String inserSql_workflow_base = + "insert into workflow_base\n" + + " (workflowname, workflowdesc,\n" + + " workflowtype, securelevel, formid,\n" + + " userid, isbill, iscust,\n" + + " helpdocid, isvalid, needmark,\n" + + " messagetype, multisubmit, defaultname,\n" + + " docpath, subcompanyid, mailmessagetype,\n" + + " docrightbyoperator, doccategory, istemplate,\n" + + " templateid, catelogtype, selectedcatelog,\n" + + " docrightbyhrmresource, needaffirmance, isremarks,\n" + + " isannexupload, annexdoccategory, isshowonreportinput,\n" + + " titlefieldid, keywordfieldid, isshowchart,\n" + + " orderbytype, istridiffworkflow, ismodifylog,\n" + + " ifversion, wfdocpath, wfdocowner,\n" + + " isedit, editor, editdate,\n" + + " edittime, showdelbuttonbyreject, wfdocownertype,\n" + + " wfdocownerfieldid, issignview, showuploadtab,\n" + + " issigndoc, showdoctab, issignworkflow,\n" + + " showworkflowtab, candelacc, isforwardrights,\n" + + " isimportwf, isrejectremind, ischangrejectnode,\n" + + " newdocpath, keepsign, seccategoryid,\n" + + " custompage, isselectrejectnode, forbidattdownload,\n" + + " isimportdetail, specialapproval, frequency,\n" + + " cycle, nosynfields, isneeddelacc,\n" + + " sapsource, isfnacontrol, fnanodeid,\n" + + " fnadepartmentid, smsalertstype, issavecheckform,\n" + + " archivenomsgalert, archivenomailalert, isfnabudgetwf,\n" + + " forwardreceivedef, fieldnotimport, isworkflowdoc,\n" + + " version, activeversionid, versiondescription,\n" + + " versioncreater, dsporder, isfree,\n" + + " chatstype, chatsalerttype,\n" + + " notremindifarchived, officaltype, custompage4emoble,\n" + + " isupdatetitle, isshared, isoverrb,\n" + + " isoveriv \n" + + " )values( \n" + + " '"+StringEscapeUtils.escapeSql(_guid1)+"', '',\n" + + " "+wfTypeid+", '', "+formid+",\n" + + " NULL, '1', 0,\n" + + " 0, '1', '',\n" + + " 0, 0, 1,\n" + + " '', "+subcompanyid+", 0,\n" + + " 0, ',,', '0',\n" + + " 0, 0, 0,\n" + + " 0, '', '',\n" + + " '', ',,', '',\n" + + " NULL, NULL, '',\n" + + " '1', NULL, '',\n" + + " NULL, '', '',\n" + + " NULL, NULL, NULL,\n" + + " NULL, '1', 0,\n" + + " 0, 0, '',\n" + + " '', '', '',\n" + + " '', '', '0',\n" + + " '', '', '',\n" + + " '', NULL, NULL,\n" + + " '', '', 0,\n" + + " '', '', 0,\n" + + " '', '', '0',\n" + + " '', NULL, NULL,\n" + + " NULL, '0', '',\n" + + " '', '', NULL,\n" + + " '', '', 0,\n" + + " NULL, NULL, NULL,\n" + + " NULL, 0, '0',\n" + + " 0, 0,\n" + + " 0, NULL, NULL,\n" + + " 1, '0', '0',\n" + + " '0' \n" + + " )"; + + String[] _workflow_nodeName_array = new String[]{ + "创建", + "审批", + "归档" + }; + String[] inserSql_workflow_nodebase_array = new String[]{ + "INSERT INTO workflow_nodebase (nodename,isstart,isreject,isreopen,isend,drawxpos,drawypos,totalgroups,nodeattribute,passnum,IsFreeNode,floworder,Signtype,operators_1,requestid,startnodeid,operators)\n" + + " VALUES ('"+StringEscapeUtils.escapeSql(_guid1)+"','1','0','0','0',-1,-1,0,'0',0,'',NULL,NULL,NULL,NULL,NULL,NULL)", + "INSERT INTO workflow_nodebase (nodename,isstart,isreject,isreopen,isend,drawxpos,drawypos,totalgroups,nodeattribute,passnum,IsFreeNode,floworder,Signtype,operators_1,requestid,startnodeid,operators)\n" + + " VALUES ('"+StringEscapeUtils.escapeSql(_guid1)+"','0','1','1','0',-1,-1,0,'0',0,'',NULL,NULL,NULL,NULL,NULL,NULL)", + "INSERT INTO workflow_nodebase (nodename,isstart,isreject,isreopen,isend,drawxpos,drawypos,totalgroups,nodeattribute,passnum,IsFreeNode,floworder,Signtype,operators_1,requestid,startnodeid,operators)\n" + + " VALUES ('"+StringEscapeUtils.escapeSql(_guid1)+"','0','0','0','1',-1,-1,0,'0',0,'',NULL,NULL,NULL,NULL,NULL,NULL)" + }; + + String[] inserSql_workflow_flownode_array = new String[]{ + "INSERT INTO workflow_flownode (workflowid, nodeid, nodetype, viewnodeids, "+ + " viewtypeall, viewdescall, showtype, IsPendingForward, IsSubmitedOpinion, "+ + " isfeedback, nodeorder, isRemarkLocation)\n" + + " VALUES (666666workflowid999999, 666666nodeid666666, '0', '-1', "+ + " '1', '1', '0', '1', '1', "+ + " '1', 1, 0)", + + "INSERT INTO workflow_flownode (workflowid, nodeid, nodetype, viewnodeids, "+ + " viewtypeall, viewdescall, showtype, IsPendingForward, IsSubmitedOpinion, "+ + " isfeedback, nodeorder, isRemarkLocation)\n" + + " VALUES (666666workflowid999999, 666666nodeid666666, '1', '-1', "+ + " '1', '1', '0', '1', '1', "+ + " '1', 2, 0)", + + "INSERT INTO workflow_flownode (workflowid, nodeid, nodetype, viewnodeids, "+ + " viewtypeall, viewdescall, showtype, IsPendingForward, IsSubmitedOpinion, "+ + " isfeedback, nodeorder, isRemarkLocation)\n" + + " VALUES (666666workflowid999999, 666666nodeid666666, '3', '-1', "+ + " '1', '1', '0', '1', '1', "+ + " '1', 3, 0)" + }; + + HashMap workflow_nodeform_fieldEditType_hm = new HashMap(); + initFieldEditType(workflow_nodeform_fieldEditType_hm,wfType); + + rst.setAutoCommit(false); + + rst.executeSql(inserSql_workflow_base); + //rst.writeLog("inserSql_workflow_base:"+inserSql_workflow_base); + rst.executeSql("select max(id) maxId from workflow_base where workflowname = '"+StringEscapeUtils.escapeSql(_guid1)+"'"); + if(rst.next()){ + wfid = rst.getInt("maxId"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_base',"+wfid+",'id')"); + rst.executeSql("update workflow_base set workflowname = '"+StringEscapeUtils.escapeSql(wfname)+"' where id = "+wfid); + //rst.writeLog("update workflow_base set workflowname = '"+StringEscapeUtils.escapeSql(wfname)+"' where id = "+wfid); + + rst.executeSql("insert into workflow_versioninfo (wfid, wfversionid) values ("+wfid+", "+wfid+")"); + //rst.writeLog("insert into workflow_versioninfo (wfid, wfversionid) values ("+wfid+", "+wfid+")"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_versioninfo',"+wfid+",'wfid')"); + + for(int i=0;i<_workflow_nodeName_array.length;i++){ + String inserSql_workflow_nodeName = _workflow_nodeName_array[i]; + String inserSql_workflow_nodebase = inserSql_workflow_nodebase_array[i]; + String inserSql_workflow_flownode = inserSql_workflow_flownode_array[i]; + + rst.executeSql(inserSql_workflow_nodebase); + //rst.writeLog("inserSql_workflow_nodebase:"+inserSql_workflow_nodebase); + + rst.executeSql("select max(id) maxId from workflow_nodebase where nodename = '"+StringEscapeUtils.escapeSql(_guid1)+"'"); + if(rst.next()){ + int _nodeId = rst.getInt("maxId"); + _workflow_nodeId_array[i] = _nodeId+""; + + rst.executeSql("update workflow_nodebase set nodename = '"+StringEscapeUtils.escapeSql(inserSql_workflow_nodeName)+"' where id = "+_nodeId); + //rst.writeLog("update workflow_nodebase set nodename = '"+StringEscapeUtils.escapeSql(inserSql_workflow_nodeName)+"' where id = "+_nodeId); + + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_nodebase',"+_nodeId+",'id')"); + + inserSql_workflow_flownode = inserSql_workflow_flownode + .replaceAll("666666workflowid999999", wfid+"") + .replaceAll("666666nodeid666666", _nodeId+""); + + rst.executeSql(inserSql_workflow_flownode); + //rst.writeLog("inserSql_workflow_flownode:"+inserSql_workflow_flownode); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_flownode',"+wfid+",'workflowid')"); + } + } + + + String inserSql_workflow_nodelink = "INSERT INTO workflow_nodelink (workflowid, nodeid, linkname, destnodeid, directionfrom, directionto, "+ + " nodepasstime, startDirection, endDirection, linkorder )\n" + + " VALUES ("+wfid+", "+Util.getIntValue(_workflow_nodeId_array[0])+", '"+ SystemEnv.getHtmlLabelName(383043,weaver.general.ThreadVarLanguage.getLang())+"', "+Util.getIntValue(_workflow_nodeId_array[1])+", -1, -1, "+ + " '-1', -1, -1, 1 )"; + rst.executeSql(inserSql_workflow_nodelink); + //rst.writeLog("inserSql_workflow_nodelink:"+inserSql_workflow_nodelink); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_nodelink',"+wfid+",'workflowid')"); + + inserSql_workflow_nodelink = "INSERT INTO workflow_nodelink (workflowid, nodeid, linkname, destnodeid, directionfrom, directionto, "+ + " nodepasstime, startDirection, endDirection, linkorder )\n" + + " VALUES ("+wfid+", "+Util.getIntValue(_workflow_nodeId_array[1])+", '"+ SystemEnv.getHtmlLabelName(142,weaver.general.ThreadVarLanguage.getLang())+"', "+Util.getIntValue(_workflow_nodeId_array[2])+", -1, -1, "+ + " '-1', -1, -1, 2 )"; + rst.executeSql(inserSql_workflow_nodelink); + //rst.writeLog("inserSql_workflow_nodelink:"+inserSql_workflow_nodelink); + + List _insert_sql_workflow_nodeform_list = new ArrayList(); + for(int i=0;i<_workflow_nodeId_array.length;i++){ + int inserSql_workflow_nodeId = Util.getIntValue(_workflow_nodeId_array[i]); + if(inserSql_workflow_nodeId > 0){ + String sql_workflow_billfield = "select id, fieldname, dsporder from workflow_billfield where billid = "+formid+" order by dsporder"; + rst.executeSql(sql_workflow_billfield); + while(rst.next()){ + int _fieldId = rst.getInt("id"); + String _fieldname = Util.null2String(rst.getString("fieldname")).trim(); + double _dsporder = Util.getDoubleValue(rst.getString("dsporder"), 0); + + int isview = Util.getIntValue(workflow_nodeform_fieldEditType_hm.get(_fieldname+"_isview"), 1); + int isedit = Util.getIntValue(workflow_nodeform_fieldEditType_hm.get(_fieldname+"_isedit"), 1); + int ismandatory = Util.getIntValue(workflow_nodeform_fieldEditType_hm.get(_fieldname+"_ismandatory"), 0); + _insert_sql_workflow_nodeform_list.add("insert into workflow_nodeform (nodeid, fieldid, isview, isedit, ismandatory, orderid) "+ + " values ("+inserSql_workflow_nodeId+", "+_fieldId+", '"+isview+"', '"+isedit+"', '"+ismandatory+"', "+_dsporder+")"); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflow_nodeform',"+inserSql_workflow_nodeId+",'nodeid')"); + } + } + } + + for(int i=0;i<_insert_sql_workflow_nodeform_list.size();i++){ + rst.executeSql(_insert_sql_workflow_nodeform_list.get(i)); + //rst.writeLog("_insert_sql_workflow_nodeform_list:"+_insert_sql_workflow_nodeform_list.get(i)); + } + } + + rst.commit(); + //更新缓存 + String tables[] = {"workflow_nodebase"}; + CacheFactory.getInstance().removeCache(tables); + + }catch (Exception e){ + try{ + rst.rollback(); + rst.setChecksql(true); + }catch(Exception ex1){} + new BaseBean().writeLog(e); + throw new Exception("流程创建失败"); + } + + wfMap.put("wfid", wfid); + wfMap.put("_workflow_nodeId_array", _workflow_nodeId_array); + return wfMap; + } + + /** + * 初始化字段属性,可编辑还是必填 + * @param workflow_nodeform_fieldEditType_hm + * @param wfType + */ + private void initFieldEditType(HashMap workflow_nodeform_fieldEditType_hm,String wfType) { + +// 变更流程类型,0表示请假,1表示出差,2表示公出,3表示加班,4表示异常,5表示排班,6表示销假 + //0表示请假 + if("0".equals(wfType)){ + initFieldEditType0(workflow_nodeform_fieldEditType_hm); + } + //1表示出差 + if("1".equals(wfType)){ + initFieldEditType1(workflow_nodeform_fieldEditType_hm); + } + //2表示公出 + if("2".equals(wfType)){ + initFieldEditType2(workflow_nodeform_fieldEditType_hm); + } + //3表示加班 + if("3".equals(wfType)){ + initFieldEditType3(workflow_nodeform_fieldEditType_hm); + } + //4表示异常 + if("4".equals(wfType)){ + initFieldEditType4(workflow_nodeform_fieldEditType_hm); + } + //5表示排班 + if("5".equals(wfType)){ + initFieldEditType5(workflow_nodeform_fieldEditType_hm); + } + //6表示销假 + if("6".equals(wfType)){ + initFieldEditType6(workflow_nodeform_fieldEditType_hm); + } + } + + /** + * 初始化请假的流程字段属性 + * @param workflow_nodeform_fieldEditType_hm + */ + private void initFieldEditType0(HashMap workflow_nodeform_fieldEditType_hm) { + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("departmentId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("newLeaveType"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("fromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("fromTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("toDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("toTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("duration"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("vacationInfo"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_newLeaveType"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_duration"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_vacationInfo"+"_isedit", "1"); + + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("departmentId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("newLeaveType"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("fromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("fromTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("toDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("toTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("duration"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("vacationInfo"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_newLeaveType"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_duration"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_vacationInfo"+"_ismandatory", "1"); + } + + /** + * 初始化出差的流程字段属性 + * @param workflow_nodeform_fieldEditType_hm + */ + private void initFieldEditType1(HashMap workflow_nodeform_fieldEditType_hm) { + + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("departmentId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("fromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("fromTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("toDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("toTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_isedit", "1"); + + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("departmentId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("fromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("fromTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("toDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("toTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_ismandatory", "1"); + + } + + /** + * 初始化公出的流程字段属性 + * @param workflow_nodeform_fieldEditType_hm + */ + private void initFieldEditType2(HashMap workflow_nodeform_fieldEditType_hm) { + + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("departmentId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("fromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("fromTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("toDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("toTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_isedit", "1"); + + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("departmentId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("fromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("fromTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("toDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("toTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_ismandatory", "1"); + } + + /** + * 初始化加班的流程字段属性 + * @param workflow_nodeform_fieldEditType_hm + */ + private void initFieldEditType3(HashMap workflow_nodeform_fieldEditType_hm) { + + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("departmentId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("fromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("fromTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("toDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("toTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("duration"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_duration"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_isedit", "1"); + + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("departmentId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("fromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("fromTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("toDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("toTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("duration"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_duration"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_ismandatory", "1"); + } + + /** + * 初始化异常的流程字段属性 + * @param workflow_nodeform_fieldEditType_hm + */ + private void initFieldEditType4(HashMap workflow_nodeform_fieldEditType_hm) { + + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("departmentId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("fromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("fromTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("toDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("toTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_isedit", "1"); + + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("departmentId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("fromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("fromTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("toDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("toTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_departmentId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_ismandatory", "1"); + } + + /** + * 初始化排班的流程字段属性 + * @param workflow_nodeform_fieldEditType_hm + */ + private void initFieldEditType5(HashMap workflow_nodeform_fieldEditType_hm) { + + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("scheduleResourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("fromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("toDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("newShift"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_scheduleResourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_newShift"+"_isedit", "1"); + + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("scheduleResourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("fromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("toDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("newShift"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_resourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_scheduleResourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_newShift"+"_ismandatory", "1"); + + } + + /** + * 初始化销假的流程字段属性 + * @param workflow_nodeform_fieldEditType_hm + */ + private void initFieldEditType6(HashMap workflow_nodeform_fieldEditType_hm) { + + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("leaverequestid"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_leavefromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_leavefromTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_leavetoDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_leavetoTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_newLeaveType"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_leaveduration"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_isedit", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_duration"+"_isedit", "1"); + + workflow_nodeform_fieldEditType_hm.put("resourceId"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("leaverequestid"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_leavefromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_leavefromTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_leavetoDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_leavetoTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_newLeaveType"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_leaveduration"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_fromTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toDate"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_toTime"+"_ismandatory", "1"); + workflow_nodeform_fieldEditType_hm.put("detail_duration"+"_ismandatory", "1"); + + } + + public void InitSet(int formid,String wfType,String wfname,Map wfMap,String usedetail) throws Exception{ + + long id = 0L; + //初始化考勤流程基本信息 + id = initBaseSet(formid,wfType,wfname,wfMap,usedetail); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'kq_att_proc_set',"+id+",'id')"); + + //初始化考勤流程字段对应 + initWfFields(id,formid,wfType,wfname,wfMap,usedetail); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'kq_att_proc_relation',"+id+",'field001')"); + //初始化考勤流程动作设置 + initAction(id,formid,wfType,wfname,wfMap); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'kq_att_proc_action',"+id+",'field001')"); + } + + /** + * 初始化考勤流程基本信息 + * @param formid + * @param wfType + * @param wfname + */ + public long initBaseSet(int formid,String wfType,String wfname,Map wfMap,String usedetail) throws Exception{ + + long id = 0l; + int wfid = (int)wfMap.get("wfid"); + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + HrmAttProcSetManager attProcSetManager = new HrmAttProcSetManager(); + + int subcompanyid = -1; + //获取分权分部。如果页面没有,则首先从分权设置的默认机构取得,如果默认机构没有设置则取所有分部中id最小的那个分部。 + subcompanyid = Util.getIntValue(manageDetachComInfo.getWfdftsubcomid(), -1); + + HrmAttProcSet bean = new HrmAttProcSet(true); + bean.setField001(wfid); + bean.setField002(formid); + bean.setField003(0); + bean.setField004(subcompanyid); + bean.setField005(1); + bean.setField006(Util.getIntValue(wfType)); + bean.setField007(0); + bean.setField008(TimeUtil.getCurrentDateString()); + bean.setField009(TimeUtil.getCurrentDateString()); + bean.setUsedetail(Util.getIntValue(usedetail,0)); + String custompage = ""; + String custompage4Emoble = ""; + String templetroute = ""; + switch (bean.getField006()){ + case 0 : + custompage = KqTempletEnum.LEAVE.getTempletfile(); + custompage4Emoble = KqTempletEnum.LEAVE.getTempletmobilefile(); + templetroute = KqTempletEnum.LEAVE.getTempletroute(); + break; + case 1 : + custompage = KqTempletEnum.EVECTION.getTempletfile(); + custompage4Emoble = KqTempletEnum.EVECTION.getTempletmobilefile(); + templetroute = KqTempletEnum.EVECTION.getTempletroute(); + break; + case 2 : + custompage = KqTempletEnum.OUT.getTempletfile(); + custompage4Emoble = KqTempletEnum.OUT.getTempletmobilefile(); + templetroute = KqTempletEnum.OUT.getTempletroute(); + break; + case 3 : + custompage = KqTempletEnum.OVERTIME.getTempletfile(); + custompage4Emoble = KqTempletEnum.OVERTIME.getTempletmobilefile(); + templetroute = KqTempletEnum.OVERTIME.getTempletroute(); + break; + case 4 : + custompage = KqTempletEnum.OTHER.getTempletfile(); + custompage4Emoble = KqTempletEnum.OTHER.getTempletmobilefile(); + templetroute = KqTempletEnum.OTHER.getTempletroute(); + break; + case 5 : + custompage = KqTempletEnum.SHIFT.getTempletfile(); + custompage4Emoble = KqTempletEnum.SHIFT.getTempletmobilefile(); + templetroute = KqTempletEnum.SHIFT.getTempletroute(); + break; + case 6 : + custompage = KqTempletEnum.LEAVEBACK.getTempletfile(); + custompage4Emoble = KqTempletEnum.LEAVEBACK.getTempletmobilefile(); + templetroute = KqTempletEnum.LEAVEBACK.getTempletroute(); + break; + case 7 : + custompage = KqTempletEnum.Card.getTempletfile(); + custompage4Emoble = KqTempletEnum.Card.getTempletmobilefile(); + templetroute = KqTempletEnum.Card.getTempletroute(); + break; + case 8 : + custompage = KqTempletEnum.PROCESSCHANGE.getTempletfile(); + custompage4Emoble = KqTempletEnum.PROCESSCHANGE.getTempletmobilefile(); + templetroute = KqTempletEnum.PROCESSCHANGE.getTempletroute(); + break; + default: + break; + } + bean.setTempletfile(custompage); + bean.setTempletmobilefile(custompage4Emoble); + bean.setTempletroute(templetroute); + String tablename = "formtable_main_"+Math.abs(formid); + bean.setTablename(tablename); + if("1".equalsIgnoreCase(usedetail)){ + String detailname = tablename+"_dt1"; + bean.setDetailtablename(detailname); + } + id = attProcSetManager.save(bean); + attProcSetManager.welcomeToSet(wfid, Util.getIntValue(wfType)); + + return id; + } + + /** + * 初始化考勤流程字段对应 + * @param id + * @param formid + * @param wfType + * @param wfname + */ + public void initWfFields(long id,int formid,String wfType,String wfname,Map wfMap,String usedetail) throws Exception{ + + if (id > 0) { + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + HrmAttProcRelationManager attProcRelationManager = new HrmAttProcRelationManager(); + +// 考勤流程数据库字段对应 180表示请假,181表示出差,182表示公出,45表示加班,0表示异常,5表示排班,6表示销假 + String fieldType = ""; + switch (wfType){ + case "0" : + fieldType = "180"; + break; + case "1" : + fieldType = "181"; + break; + case "2" : + fieldType = "182"; + break; + case "3" : + fieldType = "45"; + break; + case "4" : + fieldType = "0"; + break; + case "5" : + fieldType = "5"; + break; + case "6" : + fieldType = "6"; + break; + case "7" : + fieldType = "7"; + break; + case "8" : + fieldType = "8"; + break; + default: + break; + } + + String wfFiledsSql = "select * from kq_att_proc_fields where field001="+fieldType; + String wfBillFieldSql = "select * from workflow_billfield where billid="+formid+" and viewtype= 0"; + String wfBillFieldDetailSql = "select * from workflow_billfield where billid="+formid+" and viewtype= 1"; + + Map wfBillFieldMap = new HashMap<>(); + Map wfBillFieldDetailMap = new HashMap<>(); + + rs.execute(wfBillFieldSql); + while(rs.next()){ + wfBillFieldMap.put(rs.getString("fieldname"), rs.getString("id")); + } + + rs1.execute(wfBillFieldDetailSql); + while(rs1.next()){ + wfBillFieldDetailMap.put(rs1.getString("fieldname"), rs1.getString("id")); + } + + rs2.execute(wfFiledsSql); + while(rs2.next()){ + String fid = rs2.getString("id"); + String fieldname = rs2.getString("field002"); + if(null != fieldname && fieldname.indexOf("edit_duration")>-1){ + continue; + } + HrmAttProcRelation bean = new HrmAttProcRelation(); + bean.setField001((int)id); + bean.setField002(Util.getIntValue(fid)); + if(fieldType.equalsIgnoreCase("5") || fieldType.equalsIgnoreCase("6") || fieldType.equalsIgnoreCase("7") || fieldType.equalsIgnoreCase("8")){ + if(fieldname.startsWith("detail_")){ + int field003 = Util.getIntValue(Util.null2String(wfBillFieldDetailMap.get(fieldname)), 0); + if(field003 == 0){ + continue; + } + bean.setField003(field003);//因为是自己去创建的,已经规定数据库里workflow_billfield的字段名和hrm_att_proc_fields里的字段名是一致的 + }else{ + int field003 = Util.getIntValue(Util.null2String(wfBillFieldMap.get(fieldname)), 0); + if(field003 == 0){ + continue; + } + bean.setField003(field003);//因为是自己去创建的,已经规定数据库里workflow_billfield的字段名和hrm_att_proc_fields里的字段名是一致的 + } + }else{ + if("1".equalsIgnoreCase(usedetail)){ + if(fieldname.startsWith("detail_")){ + int field003 = Util.getIntValue(Util.null2String(wfBillFieldDetailMap.get(fieldname)), 0); + if(field003 == 0){ + continue; + } + bean.setField003(field003);//因为是自己去创建的,已经规定数据库里workflow_billfield的字段名和hrm_att_proc_fields里的字段名是一致的 + }else{ + continue; + } + }else{ + if(!fieldname.startsWith("detail_")){ + int field003 = Util.getIntValue(Util.null2String(wfBillFieldMap.get(fieldname)), 0); + if(field003 == 0){ + continue; + } + bean.setField003(field003);//因为是自己去创建的,已经规定数据库里workflow_billfield的字段名和hrm_att_proc_fields里的字段名是一致的 + }else{ + continue; + } + } + } + + bean.setField004(fieldname); + attProcRelationManager.insert(bean); + } + }else { + return ; + } + + } + + /** + * 初始化考勤流程动作设置 + * @param id + * @param formid + * @param wfType + * @param wfname + */ + public void initAction(long id,int formid,String wfType,String wfname,Map wfMap) throws Exception{ + + // action名称,labelname,不知道默认0,节点类型,退回时不触发,顺序 + String[][] actions = null; + //请假 需要 配置action + if("0".equals(wfType)){ + actions = new String[][]{{"KqReleaseVacationAction","82824"},{"KqFreezeVacationAction","1232"},{"KqDeductionVacationAction","82823"},{"KqSplitAction","81543"}}; + doInitAction(wfType,actions,id,wfMap); + }else if("3".equals(wfType)){ + actions = new String[][]{{"KqPaidLeaveAction","126739"},{"KqSplitAction","81543"}}; + doInitAction(wfType,actions,id,wfMap); + }else{ + actions = new String[][]{{"KqSplitAction","81543"}}; + doInitAction(wfType,actions,id,wfMap); + } + } + + /** + * 考勤流程action保存 + * @param wfType + * @param actions + * @param id + * @param wfMap + */ + private void doInitAction(String wfType,String[][] actions,long id,Map wfMap){ + + if(actions == null) { + return; + } + + HrmAttProcActionManagerE9 hrmAttProcActionManagerE9 = new HrmAttProcActionManagerE9(); + WorkflowActionManager workflowActionManager = new WorkflowActionManager(); + // [0] 创建 [1] 审批 [2] 归档 + String[] _workflow_nodeId_array = (String[])wfMap.get("_workflow_nodeId_array"); + int wfid = (int)wfMap.get("wfid"); + + for(int i = 0; i < actions.length ; i ++){ + int preoperator = 0; + String[] actionA = actions[i]; + HrmAttProcAction bean = new HrmAttProcAction(); + String actioname = actionA[0]; + bean.setField001(id); + bean.setField002(actioname); + bean.setField003(actionA[1]); + bean.setField004(0); + String nodeId = ""; +// setField005 0出口附加规则,1节点后附加操作,2节点前附加操作 + if(actioname.equalsIgnoreCase("KqSplitAction") || + actioname.equalsIgnoreCase("KqDeductionVacationAction") || + actioname.equalsIgnoreCase("KqPaidLeaveAction")){ + //归档节点前 + nodeId = _workflow_nodeId_array[2]; + bean.setField005(2); + bean.setField006(nodeId); + } + if(actioname.equalsIgnoreCase("KqFreezeVacationAction")){ + //创建节点后 + nodeId = _workflow_nodeId_array[0]; + bean.setField005(1); + bean.setField006(nodeId); + } + if(actioname.equalsIgnoreCase("KqReleaseVacationAction")){ + //创建节点前 + nodeId = _workflow_nodeId_array[0]; + bean.setField005(2); + bean.setField006(nodeId); + } + bean.setField007(0); + bean.setField008(1); + hrmAttProcActionManagerE9.insert(bean); + + if(bean.getField005() == 2){ + preoperator = 1; + } + + String field003Name = SystemEnv.getHtmlLabelNames(bean.getField003(),7); + workflowActionManager.setActionid(0); + workflowActionManager.setActionname(field003Name); + workflowActionManager.setWorkflowid(wfid); + workflowActionManager.setNodeid(StringUtil.parseToInt(nodeId)); + workflowActionManager.setNodelinkid(0); + workflowActionManager.setIspreoperator(preoperator); + workflowActionManager.setActionorder(1); + workflowActionManager.setInterfaceid(bean.getField002()); + workflowActionManager.setInterfacetype(3); + workflowActionManager.setIsused(1); + workflowActionManager.doSaveWsAction(); + logAutoInit("insert into kq_autoinit_log(wftype,inittype,initids,initcolumn) values("+wfType+",'workflowactionset',"+wfid+",'workflowid')"); + } + } + + + /** + * 表单名称同名验证 + */ + public boolean homonymyCheck(String wfname){ + RecordSet rs = new RecordSet(); + + boolean issamename = false; + rs.executeSql("select namelabel from workflow_bill"); + while(rs.next()){//新表单名和单据名 + int namelabel = Util + .getIntValue(Util.null2String(rs.getString("namelabel")),0); + if(namelabel!=0){ + if(wfname.equals(SystemEnv.getHtmlLabelName(namelabel,user.getLanguage()))){ + issamename = true; + break; + } + } + } + if(!issamename){ + rs.executeSql("select 1 from workflow_formbase where formname = '"+ StringEscapeUtils + .escapeSql(wfname)+"'"); + if(rs.next()){//旧表单名 + issamename = true; + } + } + return issamename; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public void cleanAutoInit(String wfType){ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String clearSql = "select inittype,initids,initcolumn from kq_autoinit_log where wftype=? group by inittype,initids,initcolumn"; + rs.executeQuery(clearSql,wfType); + + while (rs.next()){ + String inittype = rs.getString("inittype"); + String initids = rs.getString("initids"); + String initcolumn = rs.getString("initcolumn"); + + //如果是表结构。需要drop + if("formtable_main".equalsIgnoreCase(inittype)){ + String dropTableSql = "drop table "+initids; + rs1.executeSql(dropTableSql); + }else if("sequence".equalsIgnoreCase(inittype)){ + String dropSequenceSql = "drop sequence "+initids; + rs1.executeSql(dropSequenceSql); + }else { + String deleteTableSql = "delete from "+inittype+" where "+initcolumn+" in ("+initids+")"; + rs1.executeSql(deleteTableSql); + } + } + + cleanSelf(wfType); + } + + /** + * 清除日志表 + */ + private void cleanSelf(String wfType) { + RecordSet rs = new RecordSet(); + String cleanSql = "delete from kq_autoinit_log where wftype=? "; + rs.executeUpdate(cleanSql,wfType); + } + /** + * 把初始化的表单和流程数据清除 + */ + public void cleanAutoInit(){ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String clearSql = "select inittype,initids,initcolumn from kq_autoinit_log group by inittype,initids,initcolumn"; + rs.executeSql(clearSql); + + while (rs.next()){ + String inittype = rs.getString("inittype"); + String initids = rs.getString("initids"); + String initcolumn = rs.getString("initcolumn"); + + //如果是表结构。需要drop + if("formtable_main".equalsIgnoreCase(inittype)){ + String dropTableSql = "drop table "+initids; + rs1.executeSql(dropTableSql); + }else if("sequence".equalsIgnoreCase(inittype)){ + String dropSequenceSql = "drop sequence "+initids; + rs1.executeSql(dropSequenceSql); + }else { + String deleteTableSql = "delete from "+inittype+" where "+initcolumn+" in ("+initids+")"; + rs1.executeSql(deleteTableSql); + } + } + + cleanSelf(); + } + /** + * 清除日志表 + */ + private void cleanSelf() { + RecordSet rs = new RecordSet(); + String cleanSql = "delete from kq_autoinit_log"; + rs.execute(cleanSql); + } + + /** + * 记录考勤流程相关的数据以便以后删除 + * @param logInfo + */ + private void logAutoInit(String logInfo){ + if(this.log){ + RecordSet rs = new RecordSet(); + rs.executeSql(logInfo); + } + } + + public boolean isLog() { + return log; + } + + public void setLog(boolean log) { + this.log = log; + } + + public boolean isIsdetail() { + return isdetail; + } + + public void setIsdetail(boolean isdetail) { + this.isdetail = isdetail; + } +} diff --git a/src/com/engine/kq/wfset/bean/LeavebackSplitBean.java b/src/com/engine/kq/wfset/bean/LeavebackSplitBean.java new file mode 100644 index 0000000..6988926 --- /dev/null +++ b/src/com/engine/kq/wfset/bean/LeavebackSplitBean.java @@ -0,0 +1,146 @@ +package com.engine.kq.wfset.bean; + +/** + * 销假 + */ +public class LeavebackSplitBean { + + private String requestId; + + private String workflowId; + + private String usedetail; + + /**主表id + * + */ + private String dataId; + + /** + * 明细表id + */ + private String detailId; + + private String resourceId; + + private String fromDate; + + private String fromTime; + + private String toDate; + + private String toTime; + + private String duration; + + /** + * 表单上数据库里存的天数字段 + */ + private String durationDB; + + private String requestname; + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + public String getUsedetail() { + return usedetail; + } + + public void setUsedetail(String usedetail) { + this.usedetail = usedetail; + } + + public String getDataId() { + return dataId; + } + + public void setDataId(String dataId) { + this.dataId = dataId; + } + + public String getDetailId() { + return detailId; + } + + public void setDetailId(String detailId) { + this.detailId = detailId; + } + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public String getFromDate() { + return fromDate; + } + + public void setFromDate(String fromDate) { + this.fromDate = fromDate; + } + + public String getFromTime() { + return fromTime; + } + + public void setFromTime(String fromTime) { + this.fromTime = fromTime; + } + + public String getToDate() { + return toDate; + } + + public void setToDate(String toDate) { + this.toDate = toDate; + } + + public String getToTime() { + return toTime; + } + + public void setToTime(String toTime) { + this.toTime = toTime; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getDurationDB() { + return durationDB; + } + + public void setDurationDB(String durationDB) { + this.durationDB = durationDB; + } + + public String getRequestname() { + return requestname; + } + + public void setRequestname(String requestname) { + this.requestname = requestname; + } +} diff --git a/src/com/engine/kq/wfset/bean/OvertimeBalanceTimeBean.java b/src/com/engine/kq/wfset/bean/OvertimeBalanceTimeBean.java new file mode 100644 index 0000000..8d9fe86 --- /dev/null +++ b/src/com/engine/kq/wfset/bean/OvertimeBalanceTimeBean.java @@ -0,0 +1,97 @@ +package com.engine.kq.wfset.bean; + +import java.io.Serializable; + +/** + * 按加班的时间段设置转调休时长 + */ +public class OvertimeBalanceTimeBean implements Serializable { + + + private static final long serialVersionUID = -1L; + /** + * list里对应的下标 + */ + int list_index; + /** + * 对应表kq_overdutyrulesdetail的id + */ + String rulesdetailid; + /** + * 加班时间再timepoint之后的 + */ + String timepoint; + /** + * 加班时间再timepoint之后对应的分钟数 + */ + int timepoint_mins; + /** + * timepoint对应的区间开始时间 + */ + String timepoint_start; + /** + * timepoint对应的区间结束时间 + */ + String timepoint_end; + + /** + * 是否需要转调休 + */ + boolean needTX; + + public int getList_index() { + return list_index; + } + + public void setList_index(int list_index) { + this.list_index = list_index; + } + + public String getRulesdetailid() { + return rulesdetailid; + } + + public void setRulesdetailid(String rulesdetailid) { + this.rulesdetailid = rulesdetailid; + } + + public String getTimepoint() { + return timepoint; + } + + public void setTimepoint(String timepoint) { + this.timepoint = timepoint; + } + + public int getTimepoint_mins() { + return timepoint_mins; + } + + public void setTimepoint_mins(int timepoint_mins) { + this.timepoint_mins = timepoint_mins; + } + + public String getTimepoint_start() { + return timepoint_start; + } + + public void setTimepoint_start(String timepoint_start) { + this.timepoint_start = timepoint_start; + } + + public String getTimepoint_end() { + return timepoint_end; + } + + public void setTimepoint_end(String timepoint_end) { + this.timepoint_end = timepoint_end; + } + + public boolean isNeedTX() { + return needTX; + } + + public void setNeedTX(boolean needTX) { + this.needTX = needTX; + } +} diff --git a/src/com/engine/kq/wfset/bean/ProcessChangeSplitBean.java b/src/com/engine/kq/wfset/bean/ProcessChangeSplitBean.java new file mode 100644 index 0000000..b028fa6 --- /dev/null +++ b/src/com/engine/kq/wfset/bean/ProcessChangeSplitBean.java @@ -0,0 +1,96 @@ +package com.engine.kq.wfset.bean; + +/** + * 考勤变更流程特有bean + */ +public class ProcessChangeSplitBean { + + /** + * 表单上数据库里存的开始日期字段 + */ + private String fromdatedb; + + /** + * 表单上数据库里存的开始时间字段 + */ + private String fromtimedb; + + /** + * 表单上数据库里存的结束日期字段 + */ + private String todatedb; + + /** + * 表单上数据库里存的结束时间字段 + */ + private String totimedb; + + /** + * 表单上数据库里存的时长字段 + */ + private String durationDB; + + /** + * 考勤变更类型,撤销还是变更 + * 0是变更,1是撤销 + */ + private String processType; + + + public ProcessChangeSplitBean() { + this.fromdatedb = ""; + this.fromtimedb = ""; + this.todatedb = ""; + this.totimedb = ""; + this.durationDB = ""; + this.processType = ""; + } + + public String getFromdatedb() { + return fromdatedb; + } + + public void setFromdatedb(String fromdatedb) { + this.fromdatedb = fromdatedb; + } + + public String getFromtimedb() { + return fromtimedb; + } + + public void setFromtimedb(String fromtimedb) { + this.fromtimedb = fromtimedb; + } + + public String getTodatedb() { + return todatedb; + } + + public void setTodatedb(String todatedb) { + this.todatedb = todatedb; + } + + public String getTotimedb() { + return totimedb; + } + + public void setTotimedb(String totimedb) { + this.totimedb = totimedb; + } + + public String getDurationDB() { + return durationDB; + } + + public void setDurationDB(String durationDB) { + this.durationDB = durationDB; + } + + public String getProcessType() { + return processType; + } + + public void setProcessType(String processType) { + this.processType = processType; + } +} diff --git a/src/com/engine/kq/wfset/bean/SplitBean.java b/src/com/engine/kq/wfset/bean/SplitBean.java new file mode 100644 index 0000000..2daae7d --- /dev/null +++ b/src/com/engine/kq/wfset/bean/SplitBean.java @@ -0,0 +1,713 @@ +package com.engine.kq.wfset.bean; + +import com.engine.kq.enums.DurationTypeEnum; +import com.google.common.collect.Lists; +import java.util.List; + +/** + * 请假,出差,公出,加班,异常bean + */ +public class SplitBean { + + private String requestId; + + /** + * 2个用处 + * 1、销假流程和考勤变更流程生成请假数据的时候记录下原流程的requestid + * 2、请假流程和考勤变更流程被销假流程抵消掉后记录下是对应销假流程的requestid + */ + private String leavebackrequestid; + + private String workflowId; + + private String usedetail; + + /**主表id + * + */ + private String dataId; + + /** + * 明细表id + */ + private String detailId; + + private String resourceId; + + private String fromDate; + + private String fromTime; + + private String toDate; + + private String toTime; + + private String newLeaveType; + + private String duration; + + /** + * 表单上的可编辑时长 + */ + private String edit_duration; + + /** + * 对加班而言 节假日加班时长 + */ + private String pub_duration; + /** + * 对加班而言 工作日加班时长 + */ + private String work_duration; + /** + * 对加班而言 休息日加班时长 + */ + private String rest_duration; + + /** + * 实际的表单名称 + */ + private String tablenamedb; + + /** + * 表单上数据库里存的开始日期字段 + */ + private String fromdatedb; + + /** + * 表单上数据库里存的开始时间字段 + */ + private String fromtimedb; + + /** + * 表单上数据库里存的结束日期字段 + */ + private String todatedb; + + /** + * 表单上数据库里存的结束时间字段 + */ + private String totimedb; + + /** + * 表单上数据库里存的时长字段 + */ + private String durationDB; + + /** + * 时长计算规则 + * 1-按天、2-按半天、3-按小时、4-按整天 + */ + private String durationrule; + /** + * 时长计算方式 + * 1-按照工作日计算请假时长 + * 2-按照自然日计算请假时长 + */ + private String computingMode; + + private String vacationInfo; + + /** + * 作为请假冻结表里,1表示冻结,2表示释放,3表示作废的标识位 + * + * 作为考勤拆分表里的有效标识默认为0,如果请假流程被销假消掉了。那么就变为1了 + * 作为考勤变更流程里的有效表示,默认为0,如果是被考勤变更或者撤销了,那么变为1 + */ + private String status; + + /** + * 出差里用到的同行人 + */ + private String companion; + + /** + * 拆分后的流程的所属日期,因为跨天情况下半天规则或者整天规则再时间赋值的时候可能会一天的流程拆分成两天 + */ + private String belongDate; + + /** + * 得到实际时长分钟数 + */ + private double D_Mins; + /** + * 当前日期的班次 + */ + private String serialid; + + /** + * 加班用的 当前日期是何种类型 + * 1-公众假日、2-工作日、3-休息日 + * 考勤变更流程用的 + * 1表示出差,2表示公出 + */ + private int changeType; + + /** + * 加班用的前一天是何种类型 + * 1-公众假日、2-工作日、3-休息日 + */ + private int preChangeType; + + /** + * 人员对应的分部id + */ + private String subcompanyid; + + /** + * 人员对应的部门id + */ + private String departmentid; + + /** + * 人员对应的岗位id + */ + private String jobtitle; + + private DurationTypeEnum durationTypeEnum; + + /** + * 工作时长 + */ + private int workmins; + + /** + * 按照自然日计算的时候一天对应的时长 + */ + private double oneDayHour; + + /** + * 人员对应的考勤组id + */ + private String groupid; + + /** + * 半天,整天单位的时候,判断是值显示还是下拉框显示 + * 1下拉框,2是值,默认是1 + */ + private String timeselection; + + private ProcessChangeSplitBean processChangeSplitBean; + + /** + * 是否是同行人 1表示是 + */ + private String iscompanion; + /** + * 请假类型按照自然日计算的时候,是否排除休息日或者节假日 + * 0-不排除 + * 1-排除节假日 + * 2-排除休息日 + * 1,2-排除节假日和休息日 + */ + private String filterholidays; + + /** + * 加班补偿方式,是下拉框,0是生成调休,非0是不生成调休 + */ + private String overtime_type; + + /** + * 折算方式 1是四舍五入 2是向上取整 3是向下取整 + */ + private String conversion; + + /** + * 应出勤折算天数 + */ + private String convertAttendDay = ""; + + /** + * 流程重复时段 1是重复 0是不重复,默认不重复 + */ + private String repeatTime; + + /** + * 重复请假方式 下拉单选框(0-晚到,1-早走,2-晚到+早走) 注:0,1,2为下拉选项的value值 + */ + private String repeatType; + + /** + * 每天晚到时长(分钟) + */ + private String repeatLate; + + /** + * 每天早走时长(分钟) + */ + private String repeatEarly; + + private List overtimeBalanceTimeBeans; + + public SplitBean() { + this.requestId = ""; + this.leavebackrequestid = ""; + this.workflowId = ""; + this.usedetail = ""; + this.dataId = ""; + this.detailId = ""; + this.resourceId = ""; + this.fromDate = ""; + this.fromTime = ""; + this.toDate = ""; + this.toTime = ""; + this.newLeaveType = ""; + this.duration = ""; + this.edit_duration = ""; + this.tablenamedb = ""; + this.fromdatedb = ""; + this.fromtimedb = ""; + this.todatedb = ""; + this.totimedb = ""; + this.durationDB = ""; + this.durationrule = ""; + this.computingMode = ""; + this.vacationInfo = ""; + this.status = ""; + this.companion = ""; + this.belongDate = ""; + D_Mins = 0; + this.serialid = ""; + this.changeType = 0; + this.preChangeType = 0; + this.subcompanyid = ""; + this.departmentid = ""; + this.jobtitle = ""; + this.workmins = 0; + this.oneDayHour = 0.0; + this.groupid = ""; + this.pub_duration = ""; + this.work_duration = ""; + this.rest_duration = ""; + this.timeselection = "1"; + processChangeSplitBean = new ProcessChangeSplitBean(); + this.iscompanion = ""; + this.filterholidays = ""; + this.overtimeBalanceTimeBeans = Lists.newArrayList(); + this.overtime_type = ""; + this.conversion = ""; + this.convertAttendDay = "1.0"; + this.repeatTime = "0"; + this.repeatType = ""; + this.repeatLate = ""; + this.repeatEarly = ""; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + public String getUsedetail() { + return usedetail; + } + + public void setUsedetail(String usedetail) { + this.usedetail = usedetail; + } + + public String getDataId() { + return dataId; + } + + public void setDataId(String dataId) { + this.dataId = dataId; + } + + public String getDetailId() { + return detailId; + } + + public void setDetailId(String detailId) { + this.detailId = detailId; + } + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public String getFromDate() { + return fromDate; + } + + public void setFromDate(String fromDate) { + this.fromDate = fromDate; + } + + public String getFromTime() { + return fromTime; + } + + public void setFromTime(String fromTime) { + this.fromTime = fromTime; + } + + public String getToDate() { + return toDate; + } + + public void setToDate(String toDate) { + this.toDate = toDate; + } + + public String getToTime() { + return toTime; + } + + public void setToTime(String toTime) { + this.toTime = toTime; + } + + public String getNewLeaveType() { + return newLeaveType; + } + + public void setNewLeaveType(String newLeaveType) { + this.newLeaveType = newLeaveType; + } + + public String getVacationInfo() { + return vacationInfo; + } + + public void setVacationInfo(String vacationInfo) { + this.vacationInfo = vacationInfo; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getEdit_duration() { + return edit_duration; + } + + public void setEdit_duration(String edit_duration) { + this.edit_duration = edit_duration; + } + + public String getDurationDB() { + return durationDB; + } + + public void setDurationDB(String durationDB) { + this.durationDB = durationDB; + } + + public String getDurationrule() { + return durationrule; + } + + public void setDurationrule(String durationrule) { + this.durationrule = durationrule; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCompanion() { + return companion; + } + + public void setCompanion(String companion) { + this.companion = companion; + } + + public String getBelongDate() { + return belongDate; + } + + public void setBelongDate(String belongDate) { + this.belongDate = belongDate; + } + + public String getComputingMode() { + return computingMode; + } + + public void setComputingMode(String computingMode) { + this.computingMode = computingMode; + } + + public DurationTypeEnum getDurationTypeEnum() { + return durationTypeEnum; + } + + public void setDurationTypeEnum(DurationTypeEnum durationTypeEnum) { + this.durationTypeEnum = durationTypeEnum; + } + + public double getD_Mins() { + return D_Mins; + } + + public void setD_Mins(double d_Mins) { + D_Mins = d_Mins; + } + + public String getSerialid() { + return serialid; + } + + public void setSerialid(String serialid) { + this.serialid = serialid; + } + + public int getChangeType() { + return changeType; + } + + public void setChangeType(int changeType) { + this.changeType = changeType; + } + + public String getSubcompanyid() { + return subcompanyid; + } + + public void setSubcompanyid(String subcompanyid) { + this.subcompanyid = subcompanyid; + } + + public String getDepartmentid() { + return departmentid; + } + + public void setDepartmentid(String departmentid) { + this.departmentid = departmentid; + } + + public String getJobtitle() { + return jobtitle; + } + + public void setJobtitle(String jobtitle) { + this.jobtitle = jobtitle; + } + + public int getWorkmins() { + return workmins; + } + + public void setWorkmins(int workmins) { + this.workmins = workmins; + } + + public String getTablenamedb() { + return tablenamedb; + } + + public void setTablenamedb(String tablenamedb) { + this.tablenamedb = tablenamedb; + } + + public String getFromdatedb() { + return fromdatedb; + } + + public void setFromdatedb(String fromdatedb) { + this.fromdatedb = fromdatedb; + } + + public String getFromtimedb() { + return fromtimedb; + } + + public void setFromtimedb(String fromtimedb) { + this.fromtimedb = fromtimedb; + } + + public String getTodatedb() { + return todatedb; + } + + public void setTodatedb(String todatedb) { + this.todatedb = todatedb; + } + + public String getTotimedb() { + return totimedb; + } + + public void setTotimedb(String totimedb) { + this.totimedb = totimedb; + } + + public String getLeavebackrequestid() { + return leavebackrequestid; + } + + public void setLeavebackrequestid(String leavebackrequestid) { + this.leavebackrequestid = leavebackrequestid; + } + + public double getOneDayHour() { + return oneDayHour; + } + + public void setOneDayHour(double oneDayHour) { + this.oneDayHour = oneDayHour; + } + + public int getPreChangeType() { + return preChangeType; + } + + public void setPreChangeType(int preChangeType) { + this.preChangeType = preChangeType; + } + + public String getGroupid() { + return groupid; + } + + public void setGroupid(String groupid) { + this.groupid = groupid; + } + + public String getPub_duration() { + return pub_duration; + } + + public void setPub_duration(String pub_duration) { + this.pub_duration = pub_duration; + } + + public String getWork_duration() { + return work_duration; + } + + public void setWork_duration(String work_duration) { + this.work_duration = work_duration; + } + + public String getRest_duration() { + return rest_duration; + } + + public void setRest_duration(String rest_duration) { + this.rest_duration = rest_duration; + } + + public String getTimeselection() { + return timeselection; + } + + public void setTimeselection(String timeselection) { + this.timeselection = timeselection; + } + + public ProcessChangeSplitBean getProcessChangeSplitBean() { + return processChangeSplitBean; + } + + public void setProcessChangeSplitBean( + ProcessChangeSplitBean processChangeSplitBean) { + this.processChangeSplitBean = processChangeSplitBean; + } + + public String getIscompanion() { + return iscompanion; + } + + public void setIscompanion(String iscompanion) { + this.iscompanion = iscompanion; + } + + public String getFilterholidays() { + return filterholidays; + } + + public void setFilterholidays(String filterholidays) { + this.filterholidays = filterholidays; + } + + public List getOvertimeBalanceTimeBeans() { + return overtimeBalanceTimeBeans; + } + + public void setOvertimeBalanceTimeBeans( + List overtimeBalanceTimeBeans) { + this.overtimeBalanceTimeBeans = overtimeBalanceTimeBeans; + } + + public String getOvertime_type() { + return overtime_type; + } + + public void setOvertime_type(String overtime_type) { + this.overtime_type = overtime_type; + } + + public String getConversion() { + return conversion; + } + + public void setConversion(String conversion) { + this.conversion = conversion; + } + + public String getConvertAttendDay() { + return convertAttendDay; + } + + public void setConvertAttendDay(String convertAttendDay) { + this.convertAttendDay = convertAttendDay; + } + + public String getRepeatTime() { + return repeatTime; + } + + public void setRepeatTime(String repeatTime) { + this.repeatTime = repeatTime; + } + + public String getRepeatType() { + return repeatType; + } + + public void setRepeatType(String repeatType) { + this.repeatType = repeatType; + } + + public String getRepeatLate() { + return repeatLate; + } + + public void setRepeatLate(String repeatLate) { + this.repeatLate = repeatLate; + } + + public String getRepeatEarly() { + return repeatEarly; + } + + public void setRepeatEarly(String repeatEarly) { + this.repeatEarly = repeatEarly; + } +} diff --git a/src/com/engine/kq/wfset/job/HrmTimesArrayJob.java b/src/com/engine/kq/wfset/job/HrmTimesArrayJob.java new file mode 100644 index 0000000..9d5618f --- /dev/null +++ b/src/com/engine/kq/wfset/job/HrmTimesArrayJob.java @@ -0,0 +1,110 @@ +package com.engine.kq.wfset.job; + +import com.engine.kq.biz.KQShiftManagementComInfo; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.wfset.util.KQ122Util; +import com.engine.kq.wfset.util.KQAttFlowCheckUtil; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import weaver.conn.RecordSet; + +/** + * E9 考勤 时间(小时:分钟)和数组下标对应表 + */ +public class HrmTimesArrayJob { + + /** + * 脚本更新后运行 + */ + public static void goJob() { + boolean hasData = checkHasData(); + if(!hasData){ + tableDataSync(); + } + //在启动的时候初始化一下 + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + KQAttFlowCheckUtil kqAttFlowCheckUtil = new KQAttFlowCheckUtil(); + kqAttFlowCheckUtil.initLeaveUnit(); + //122考勤非标是否开启 开启过就永远开启了 + new KQ122Util().is122Open(); + } + + /** + * 检查是否已经有表数据了 + * @return + */ + private static boolean checkHasData() { + String checkSql = "select count(1) from kq_timesarray"; + RecordSet rs = new RecordSet(); + int count = 0; + rs.execute(checkSql); + if(rs.next()){ + count = rs.getInt(1); + } + boolean hasdata = (count == 2881); + if(!hasdata){ + rs.execute("delete from kq_timesarray"); + } + + return hasdata; + } + /** + * 初始化表数据 + */ + private static void tableDataSync() { + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + LocalTime localTime = LocalTime.parse("00:00",dateTimeFormatter); + int size = 1440; + String insertSql = "insert into kq_timesarray(times,arrayindex) values(?,?) "; + List insertParamsList= new ArrayList(); + + int index = 0; + for(int i = 0 ; i < 2;i++){ + if(i == 0){ + for(int j = 0 ; j < size ;j ++){ + LocalTime localTime0 = localTime.plusMinutes(j); + String time = localTime0.format(dateTimeFormatter); + List paramList = new ArrayList(); + paramList.add(time); + paramList.add(index); + index++; + insertParamsList.add(paramList); + } + } + if(i == 1){ + for(int j = 0 ; j < size ;j ++){ + LocalTime localTime0 = localTime.plusMinutes(j); + String strLocalTime = localTime0.format(dateTimeFormatter); + String[] strLocalTimes = strLocalTime.split(":"); + String localTimeHead = ""+(Integer.valueOf(strLocalTimes[0])+24); + String localTimeBody = strLocalTimes[1]; + String time = localTimeHead+":"+localTimeBody; + + List paramList = new ArrayList(); + paramList.add(time); + paramList.add(index); + index++; + insertParamsList.add(paramList); + } + } + } + + boolean isRight = rs.executeBatchSql(insertSql, insertParamsList); + if(isRight){ + //把48:00初始化进去 + String sql_48 = "insert into kq_timesarray(times,arrayindex) values(?,?) "; + rs1.executeUpdate(sql_48, "48:00","2880"); + System.out.println("初始化kq_timesarray成功"); + }else{ + System.out.println("初始化kq_timesarray失败"); + } + + } + +} diff --git a/src/com/engine/kq/wfset/test/DateTimeTest.java b/src/com/engine/kq/wfset/test/DateTimeTest.java new file mode 100644 index 0000000..9de9c63 --- /dev/null +++ b/src/com/engine/kq/wfset/test/DateTimeTest.java @@ -0,0 +1,18 @@ +package com.engine.kq.wfset.test; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; + +public class DateTimeTest { + + public static void main(String[] args) { + + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_LOCAL_TIME; + String time = "10:15:30"; + LocalTime time1 = LocalTime.parse(time, dateTimeFormatter); + System.out.println(time1); + + } +} diff --git a/src/com/engine/kq/wfset/util/KQ122Util.java b/src/com/engine/kq/wfset/util/KQ122Util.java new file mode 100644 index 0000000..5635bff --- /dev/null +++ b/src/com/engine/kq/wfset/util/KQ122Util.java @@ -0,0 +1,49 @@ +package com.engine.kq.wfset.util; + +import com.engine.kq.log.KQLog; +import com.engine.portal.biz.nonstandardfunction.SysModuleInfoBiz; +import weaver.conn.RecordSet; + +/** + * 考勤非标包工具类 + */ +public class KQ122Util { + private KQLog kqLog = new KQLog(); + private static String is122Open = ""; + + /** + * 判断非标122是否开启 + * @return true 表示开启 + */ + public boolean is122Open(){ + if(!"".equals(is122Open)) { + return "1".equalsIgnoreCase(is122Open); + } + RecordSet rs = new RecordSet(); + //checkNonstandardStatus这个方法查询很慢 + boolean hasOpened_122 = false; + String getsql= "select * from kq_settings where main_key='kq122' "; + rs.executeQuery(getsql); + if(rs.next()){ + String main_val = rs.getString("main_val"); + is122Open = main_val; + if("1".equalsIgnoreCase(main_val)){ + hasOpened_122 = true; + } + } + //122考勤只要是开启过就默认是新考勤了 + if(hasOpened_122){ + return true; + } + //后端考勤按钮启用表示开启了122非标 + boolean isOpen122 = SysModuleInfoBiz.checkNonstandardStatus("122"); + if(isOpen122){ + String up_122Sql = "update kq_settings set main_val='1' where main_key='kq122' "; + rs.executeUpdate(up_122Sql); + } + + // kqLog.info("SysModuleInfoBiz.checkMenuStatus:isOpen122::"+isOpen122); + return isOpen122; + } + +} diff --git a/src/com/engine/kq/wfset/util/KQAttFlowCheckUtil.java b/src/com/engine/kq/wfset/util/KQAttFlowCheckUtil.java new file mode 100644 index 0000000..43aa128 --- /dev/null +++ b/src/com/engine/kq/wfset/util/KQAttFlowCheckUtil.java @@ -0,0 +1,681 @@ +package com.engine.kq.wfset.util; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.cmd.hrmAttProcSet.KqSplitActionEnum; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import weaver.conn.RecordSet; +import weaver.general.StaticObj; +import weaver.general.Util; + +/** + * 考勤流程设置校验类 + */ +public class KQAttFlowCheckUtil { + + public StaticObj staticobj = StaticObj.getInstance(); + + /** + * 考勤流程设置里的校验 + * + * @param param + * @param kqSplitFlowTypeEnum + * @return + */ + public static Map checkAttFlow(Map param, + KqSplitFlowTypeEnum kqSplitFlowTypeEnum) { + String isAttOk = "1"; + String msgAttError = ""; + Map result = new HashMap<>(); + try { + boolean is_flow_check = is_flow_check(); + if (!is_flow_check) { + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + return result; + } + boolean isKQFlow = isKQFlow(param); + if (!isKQFlow) { + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + return result; + } + commonCheck(param, result, kqSplitFlowTypeEnum); + + if ("0".equalsIgnoreCase(Util.null2s(result.get("isAttOk"), ""))) { + return result; + } + if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.LEAVE) { + leaveCheck(param, result); + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.EVECTION) { + evectionCheck(param, result); + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.OUT) { + outCheck(param, result); + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.OVERTIME) { + overtimeCheck(param, result); + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.SHIFT) { + shiftCheck(param, result); + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.OTHER) { + otherCheck(param, result); + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.CARD) { + cardCheck(param, result); + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.LEAVEBACK) { + leavebackCheck(param, result); + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.PROCESSCHANGE) { + processchangeCheck(param, result); + } else { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005362, weaver.general.ThreadVarLanguage.getLang()) + ""; + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + } + } catch (Exception e) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005362, weaver.general.ThreadVarLanguage.getLang()) + ""; + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + } + return result; + } + + public static boolean isKQFlow(Map param) { + String isAttOk = "1"; + String msgAttError = ""; + boolean isKQFlow = true; + RecordSet rs = new RecordSet(); + String attid = Util.null2String(param.get("attid")); + if (attid.length() > 0 && Util.getIntValue(attid, -1) > 0) { + String sql = " select *from kq_att_proc_set where field005 = 1 and id = ? "; + rs.executeQuery(sql, attid); + if (rs.next()) { + } else { + isKQFlow = false; + } + } else { + isKQFlow = false; + } + return isKQFlow; + } + + private static void commonCheck(Map param, Map result, + KqSplitFlowTypeEnum kqSplitFlowTypeEnum) throws Exception { + String isAttOk = "1"; + String msgAttError = ""; + RecordSet rs = new RecordSet(); + + String[] fieldList = (String[]) param.get("fields"); + String usedetail = Util.null2String(param.get("usedetail")); + String detailtablename = Util.null2String(param.get("detailtablename")); + String tablename = Util.null2String(param.get("tablename")); + String attid = Util.null2String(param.get("attid")); + + if (attid.length() == 0) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005362, weaver.general.ThreadVarLanguage.getLang()) + ""; + } else { + List actions = new ArrayList<>(); + String actionSql = "select * from kq_att_proc_action where field001= ? "; + rs.executeQuery(actionSql, attid); + while (rs.next()) { + String actionname = Util.null2String(rs.getString("field002")); + String nodeid = Util.null2String(rs.getString("field006")); + actions.add(actionname); + } + if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.LEAVE) { + if (!actions.contains(KqSplitActionEnum.LEAVE.getSplitAction())) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005363, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.EVECTION) { + if (!actions.contains(KqSplitActionEnum.EVECTION.getSplitAction())) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005363, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.OUT) { + if (!actions.contains(KqSplitActionEnum.OUT.getSplitAction())) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005363, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.OVERTIME) { + if (!actions.contains(KqSplitActionEnum.OVERTIME.getSplitAction())) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005363, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.SHIFT) { + if (!actions.contains(KqSplitActionEnum.SHIFT.getSplitAction())) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005363, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.OTHER) { + if (!actions.contains(KqSplitActionEnum.OTHER.getSplitAction())) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005363, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.CARD) { + if (!actions.contains(KqSplitActionEnum.Card.getSplitAction())) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005363, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + } else if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.LEAVEBACK) { + if (!actions.contains(KqSplitActionEnum.LEAVEBACK.getSplitAction())) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005363, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + } + } + if (fieldList == null || fieldList.length == 0 || (Util.null2s(fieldList[0], "").length() == 0 && Util.null2s(fieldList[8], "").length() == 0)) { + new KQLog().info("考勤流程fieldList有问题:" + JSON.toJSONString(fieldList)); + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005364, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("1".equalsIgnoreCase(usedetail) && detailtablename.length() == 0) { + new KQLog().info("考勤流程有问题:detailtablename为空"); + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005364, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if (kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.LEAVE || kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.EVECTION + || kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.OUT || kqSplitFlowTypeEnum == KqSplitFlowTypeEnum.OVERTIME) { + if (!"1".equalsIgnoreCase(usedetail) && tablename.length() == 0) { + new KQLog().info("考勤流程有问题:tablename为空"); + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005364, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + } + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + } + + public static void leavebackCheck(Map param, Map result) throws Exception { + String isAttOk = "1"; + String msgAttError = ""; + String[] fieldList = (String[]) param.get("fields"); + + if ("".equalsIgnoreCase(fieldList[0]) || !fieldList[0].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005365, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[1]) || !fieldList[1].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005366, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[2]) || !fieldList[2].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005367, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[3]) || !fieldList[3].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005368, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[4]) || !fieldList[4].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005369, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[5]) || !fieldList[5].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005370, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[6]) || !fieldList[6].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005371, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[7]) || !fieldList[7].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005372, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[8]) || !fieldList[8].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005373, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[9]) || !fieldList[9].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005374, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[10]) || !fieldList[10].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005375, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[11]) || !fieldList[11].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005376, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if (("".equalsIgnoreCase(fieldList[12]) || !fieldList[12].startsWith("field")) + && ("".equalsIgnoreCase(fieldList[13]) || !fieldList[13].startsWith("field"))) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(546982,weaver.general.ThreadVarLanguage.getLang())+""; + } else { + if (!result.isEmpty()) { + return; + } + } + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + + } + + public static void processchangeCheck(Map param, Map result) throws Exception { + String isAttOk = "1"; + String msgAttError = ""; + String[] fieldList = (String[]) param.get("fields"); + + if ("".equalsIgnoreCase(fieldList[0]) || !fieldList[0].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005378, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[1]) || !fieldList[1].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005379, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[2]) || !fieldList[2].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005380, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[3]) || !fieldList[3].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005381, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[4]) || !fieldList[4].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005382, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[5]) || !fieldList[5].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005383, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[6]) || !fieldList[6].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005384, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[7]) || !fieldList[7].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005385, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[8]) || !fieldList[8].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005386, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[9]) || !fieldList[9].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005387, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[10]) || !fieldList[10].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005388, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if ("".equalsIgnoreCase(fieldList[11]) || !fieldList[11].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005389, weaver.general.ThreadVarLanguage.getLang()) + ""; + } + if (("".equalsIgnoreCase(fieldList[12]) || !fieldList[12].startsWith("field")) + && ("".equalsIgnoreCase(fieldList[13]) || !fieldList[13].startsWith("field"))) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(546982, weaver.general.ThreadVarLanguage.getLang()) + ""; + } else { + if (!result.isEmpty()) { + return; + } + } + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + + } + + public static void cardCheck(Map param, Map result) throws Exception { + String isAttOk = "1"; + String msgAttError = ""; + String[] fieldList = (String[]) param.get("fields"); + +// if(("".equalsIgnoreCase(fieldList[0]) || !fieldList[0].startsWith("field")){ +// isAttOk = "0"; +// msgAttError = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005391,weaver.general.ThreadVarLanguage.getLang())+""; +// } + if ("".equalsIgnoreCase(fieldList[1]) || !fieldList[1].startsWith("field")) { + new KQLog().info("考勤流程字段【考勤开始日期】未对应"); + } + if ("".equalsIgnoreCase(fieldList[2]) || !fieldList[2].startsWith("field")) { + new KQLog().info("考勤流程字段【考勤结束日期】未对应"); + } + if ("".equalsIgnoreCase(fieldList[3]) || !fieldList[3].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005392, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[4]) || !fieldList[4].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005393, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[5]) || !fieldList[5].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005394, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[6]) || !fieldList[6].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005395, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[7]) || !fieldList[7].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005396, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + + } + + /** + * 没有异常流程了。不作处理 + * + * @param param + * @param result + */ + public static void otherCheck(Map param, Map result) throws Exception { + + } + + public static void shiftCheck(Map param, Map result) throws Exception { + String isAttOk = "1"; + String msgAttError = ""; + String[] fieldList = (String[]) param.get("fields"); + + if ("".equalsIgnoreCase(fieldList[0]) || !fieldList[0].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005397, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[1]) || !fieldList[2].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005398, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[2]) || !fieldList[3].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005399, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[3]) || !fieldList[3].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005400, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + + } + + public static void overtimeCheck(Map param, Map result) throws Exception { + String isAttOk = "1"; + String msgAttError = ""; + String[] fieldList = (String[]) param.get("fields"); + + if ("".equalsIgnoreCase(fieldList[0]) || !fieldList[0].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005401, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[2]) || !fieldList[2].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005402, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[3]) || !fieldList[3].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005403, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[4]) || !fieldList[4].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005404, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[5]) || !fieldList[5].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005405, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if (("".equalsIgnoreCase(fieldList[6]) || !fieldList[6].startsWith("field")) && ("".equalsIgnoreCase(fieldList[7]) || !fieldList[7].startsWith("field"))) { + isAttOk = "0"; + msgAttError = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(546982,weaver.general.ThreadVarLanguage.getLang())+""; + + } else { + if (!result.isEmpty()) { + return; + } + } + + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + } + + public static void outCheck(Map param, Map result) throws Exception { + String isAttOk = "1"; + String msgAttError = ""; + String[] fieldList = (String[]) param.get("fields"); + + if ("".equalsIgnoreCase(fieldList[0]) || !fieldList[0].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005401, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[2]) || !fieldList[2].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005402, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[3]) || !fieldList[3].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005403, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[4]) || !fieldList[4].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005404, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[5]) || !fieldList[5].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005405, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[6]) || !fieldList[6].startsWith("field")) { + } else { + if (!result.isEmpty()) { + return; + } + } + + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + + } + + public static void evectionCheck(Map param, Map result) throws Exception { + String isAttOk = "1"; + String msgAttError = ""; + String[] fieldList = (String[]) param.get("fields"); + + if ("".equalsIgnoreCase(fieldList[0]) || !fieldList[0].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005401, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[2]) || !fieldList[2].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005402, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[3]) || !fieldList[3].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005403, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[4]) || !fieldList[4].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005404, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[5]) || !fieldList[5].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005405, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[6]) || !fieldList[6].startsWith("field")) { + } else { + if (!result.isEmpty()) { + return; + } + } + + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + } + + public static void leaveCheck(Map param, Map result) throws Exception { + String isAttOk = "1"; + String msgAttError = ""; + String[] fieldList = (String[]) param.get("fields"); + String attid = Util.null2String(param.get("attid")); + + if ("".equalsIgnoreCase(fieldList[0]) || !fieldList[0].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005401, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[2]) || !fieldList[2].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005371, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[3]) || !fieldList[3].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005402, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[4]) || !fieldList[4].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005403, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[5]) || !fieldList[5].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005404, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if ("".equalsIgnoreCase(fieldList[6]) || !fieldList[6].startsWith("field")) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005405, weaver.general.ThreadVarLanguage.getLang()) + ""; + + } + if (("".equalsIgnoreCase(fieldList[7]) || !fieldList[7].startsWith("field")) && ("".equalsIgnoreCase(fieldList[9]) || !fieldList[9].startsWith("field"))) { + isAttOk = "0"; + msgAttError = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(546982,weaver.general.ThreadVarLanguage.getLang())+""; + } else { + if (!result.isEmpty()) { + return; + } + } + if ("".equalsIgnoreCase(fieldList[8]) || !fieldList[8].startsWith("field")) { + new KQLog().info("考勤流程字段【假期余额】未对应"); + } + + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + } + + public static void duration_edit_check(String fieldid, Map result) { + if (true) { + //最终确认,不在发起流程的时候提示,在考勤流程字段对应里增加说明 + return; + } + } + + public static void duration_edit_check_new(String fieldid, Map result, + int workflowid) { + String isAttOk = "1"; + String msgAttError = ""; + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String edit_sql = "select * from workflow_nodeform where 1 = 1 and fieldid = ? and nodeid in(" + + " SELECT nodeid from workflow_flownode where workflowid=? ) "; + rs.executeQuery(edit_sql, fieldid, workflowid); + while (rs.next()) { + String isedit = Util.null2s(rs.getString("isedit"), ""); + String ismandatory = Util.null2s(rs.getString("ismandatory"), ""); + String isonlyshow = Util.null2s(rs.getString("isonlyshow"), ""); + if ("1".equalsIgnoreCase(isedit) || "1".equalsIgnoreCase(ismandatory) || "1".equalsIgnoreCase(isonlyshow)) { + //如果字段是可编辑的或者是必填的,或者是禁止手工编辑的,都满足条件 + } else { + String nodeid = Util.null2s(rs.getString("nodeid"), ""); + boolean isEnd = false; + if (nodeid.length() > 0) { + String is_end_sql = "select 1 from workflow_nodebase where id= ? and isend =1 "; + rs1.executeQuery(is_end_sql, nodeid); + if (rs1.next()) { + //如果是归档节点,可以不考虑 + isEnd = true; + } + } + if (!isEnd) { + isAttOk = "0"; + msgAttError = "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005332, weaver.general.ThreadVarLanguage.getLang()) + ""; + result.put("isAttOk", isAttOk); + result.put("msgAttError", msgAttError); + break; + } + } + } + } + + public void initLeaveUnit() { + String half_leave_ruleid = ""; + String whole_leave_ruleid = ""; + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + while (kqLeaveRulesComInfo.next()) { + String ruleid = kqLeaveRulesComInfo.getId(); + String changeType = kqLeaveRulesComInfo.getMinimumUnit(); + boolean isHalf = "2".equals(changeType); + boolean isWhole = "4".equals(changeType); + if (isHalf) { + half_leave_ruleid += "," + ruleid; + } + if (isWhole) { + whole_leave_ruleid += "," + ruleid; + } + } + if (half_leave_ruleid.length() > 0 && !half_leave_ruleid.endsWith(",")) { + half_leave_ruleid += ","; + staticobj.putObject("half_leave_ruleid", half_leave_ruleid); + } + if (whole_leave_ruleid.length() > 0 && !whole_leave_ruleid.endsWith(",")) { + whole_leave_ruleid += ","; + staticobj.putObject("whole_leave_ruleid", whole_leave_ruleid); + } + } + + /** + * 是否开启流程设置校验 + * + * @return + */ + public static boolean is_flow_check() { + boolean is_flow_check = true; + RecordSet rs = new RecordSet(); + String settingSql = "select * from KQ_SETTINGS where main_key='flow_check'"; + rs.executeQuery(settingSql); + if (rs.next()) { + String main_val = rs.getString("main_val"); + if (!"1".equalsIgnoreCase(main_val)) { + is_flow_check = false; + } + } + return is_flow_check; + } +} diff --git a/src/com/engine/kq/wfset/util/KQFlowCardUtil.java b/src/com/engine/kq/wfset/util/KQFlowCardUtil.java new file mode 100644 index 0000000..98c2407 --- /dev/null +++ b/src/com/engine/kq/wfset/util/KQFlowCardUtil.java @@ -0,0 +1,373 @@ +package com.engine.kq.wfset.util; + +import com.engine.kq.biz.*; +import com.engine.kq.entity.KQOvertimeRulesDetailEntity; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQLockAttendaUtil; +import com.engine.kq.wfset.bean.SplitBean; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.lang.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class KQFlowCardUtil { + private KQLog kqLog = new KQLog(); + + + /** + * 补卡流程数据 生成签到签退数据并更新考勤报表 + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQCardAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + + String[] cardFields = KQAttFlowFieldsSetBiz.cardFields; + + KQFormatData kqFormatData = new KQFormatData(); + Map result = new HashMap<>(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + + String resourceId = ""; + String resourceIds = ""; + String detail_scheduletime = ""; + String detail_signtype = ""; + String detail_signdate = ""; + String detail_signtime = ""; + String detail_resourceid = ""; + + String userId = ""; + String userType = "1";//默认给1 + String signType = ""; + String signDate = ""; + String signTime = ""; + String isInCom = "1"; +// String belongdate = ""; + +// String serialid = ""; +// String worksection = ""; +// String belongtime = ""; + String signfrom = ""; + + String signStatus = ""; +// String workdatesection = ""; + + if(!sqlMap.isEmpty()){ + for(Map.Entry me : sqlMap.entrySet()){ + String concort = "###" ; + String key = me.getKey(); + String value = me.getValue(); + + String wfId = key.split(concort)[3] ; + int usedetail = Util.getIntValue(key.split(concort)[2], 0); + String tableDetailName= key.split(concort)[1] ; + String tableName= key.split(concort)[0] ; + String idVal = ""; + String id = "dataId"; + if(usedetail == 1){ + id = "detailId"; + } + kqLog.info("findcardsql="+value); + rs1.execute(value); + List belongDateList = Lists.newArrayList(); + List overtimeList = Lists.newArrayList(); + Map> formatMap = Maps.newHashMap(); + Map> overtimeMap = Maps.newHashMap(); + while (rs1.next()) { + idVal = Util.null2s(rs1.getString(id), ""); + String signSource = "card:|wfid|"+wfId+"|requestid|"+requestId+"|detailId|"+idVal; + + String f_resourceId = cardFields[0]; + String f_detail_signdate = cardFields[3]; + String f_detail_scheduletime = cardFields[4]; + String f_detail_signtype = cardFields[6]; + String f_detail_signtime = cardFields[7]; + String f_resourceIds = cardFields[8]; + String f_detail_resourceid = cardFields[9]; + resourceId = Util.null2s(rs1.getString(f_resourceId), ""); + detail_scheduletime = Util.null2s(rs1.getString(f_detail_scheduletime), ""); + detail_signtype = Util.null2s(rs1.getString(f_detail_signtype), ""); + detail_signdate = Util.null2s(rs1.getString(f_detail_signdate), ""); + detail_signtime = Util.null2s(rs1.getString(f_detail_signtime), ""); + detail_resourceid = Util.null2s(rs1.getString(f_detail_resourceid), ""); + userId = "".equals(detail_resourceid) ? resourceId : detail_resourceid; + resourceId = userId; + + signType = "0".equalsIgnoreCase(detail_signtype)?"1":"2"; + signDate = detail_signdate; + signTime = detail_signtime+":00"; + signfrom = signSource; + + StringBuffer sql = new StringBuffer("insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,isInCom,signfrom) values(") + .append(userId).append(",'").append(userType).append("','") + .append(signType).append("','").append(signDate).append("','") + .append(signTime).append("','").append(isInCom).append("','") + .append(signfrom).append("'").append(" )"); + boolean isOk = rs2.execute(sql.toString()); + + if(!isOk){ + result.put("status", "-1"); + result.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(390273,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""); + return result; + } + kqLog.info("handleKQCardAction:userId:"+userId+":signDate:"+signDate+":signTime:"+signTime); + String cardKey = resourceId+"_"+signDate+"_"+signTime; + if(!overtimeList.contains(cardKey)){ + overtimeList.add(cardKey); + } + } + for (int i = 0; i < overtimeList.size(); i++) { + String cardKey = overtimeList.get(i); + List cardKeys = Util.splitString2List(cardKey, "_"); + if(cardKeys.size() == 3){ + String resourceid = cardKeys.get(0); + String date = cardKeys.get(1); + String time = cardKeys.get(2); + String belongDate = getBelongDate(resourceId, date, time); + String belongKey = resourceid+"_"+belongDate; + if(!belongDateList.contains(belongKey)){ + belongDateList.add(belongKey); + } + } + } + KQOverTimeRuleCalBiz kqOvertimeCalBiz = new KQOverTimeRuleCalBiz(); + if(!belongDateList.isEmpty()){ + for (String keys :belongDateList) { + List belongdateKey = Util.splitString2List(keys, "_"); + if(belongdateKey.size() == 2){ + String resourceid = belongdateKey.get(0); + String belongDate = belongdateKey.get(1); + kqLog.info("handleKQCardAction:resourceid:"+resourceid+":belongDate:"+belongDate); + new KQFormatData().formatKqDateByLock(resourceid,belongDate,17); + String tomorrow = DateUtil.addDate(belongDate,1); + new KQFormatData().formatKqDateByLock(resourceid,tomorrow,17); + String preDay = DateUtil.addDate(belongDate, -1); + new KQFormatData().formatKqDateByLock(resourceid, preDay,17); + kqOvertimeCalBiz.buildOvertime(resourceid, preDay, preDay, "补卡流程生成加班#card,preDay,requestId:" + requestId); + kqOvertimeCalBiz.buildOvertime(resourceid, belongDate, belongDate, "补卡流程生成加班#card,belongDate,requestId:"+requestId); + + } + + } + } + + } + } + + return result; + } + +/** + * 补卡流程提交校验是否锁定 + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQCardLockAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + String[] cardFields = KQAttFlowFieldsSetBiz.cardFields; + + Map result = new HashMap<>(); + RecordSet rs1 = new RecordSet(); + + String resourceId = ""; + String resourceIds = ""; + String detail_signdate = ""; + String detail_resourceid = ""; + String userId = ""; + String signDate = ""; + + ResourceComInfo resourceComInfo = new ResourceComInfo(); + if(!sqlMap.isEmpty()){ + for(Map.Entry me : sqlMap.entrySet()){ + String concort = "###" ; + String key = me.getKey(); + String value = me.getValue(); + + String wfId = key.split(concort)[3] ; + int usedetail = Util.getIntValue(key.split(concort)[2], 0); + String tableDetailName= key.split(concort)[1] ; + String tableName= key.split(concort)[0] ; + String idVal = ""; + String id = "dataId"; + if(usedetail == 1){ + id = "detailId"; + } + + kqLog.info("findcardsql="+value); + rs1.execute(value); + while (rs1.next()) { + idVal = Util.null2s(rs1.getString(id), ""); + String signSource = "card:|wfid|"+wfId+"|requestid|"+requestId+"|detailId|"+idVal; + + String f_resourceId = cardFields[0]; + String f_detail_signdate = cardFields[3]; + String f_detail_scheduletime = cardFields[4]; + String f_detail_signtype = cardFields[6]; + String f_detail_signtime = cardFields[7]; + String f_resourceIds = cardFields[8]; + String f_detail_resourceid = cardFields[9]; + resourceId = Util.null2s(rs1.getString(f_resourceId), ""); + detail_signdate = Util.null2s(rs1.getString(f_detail_signdate), ""); + detail_resourceid = Util.null2s(rs1.getString(f_detail_resourceid), ""); + userId = "".equals(detail_resourceid) ? resourceId : detail_resourceid; + signDate = detail_signdate; + + if(StringUtils.isNotBlank(userId)&&StringUtils.isNotBlank(signDate)){ + if (new KQLockAttendaUtil().checkLockStatus(userId, signDate)) { + kqLog.info(""+resourceComInfo.getLastname(userId)+"在"+signDate+"的考勤数据已被锁定,不能提交考勤流程!"); + result.put("status", "-1"); + result.put("message", resourceComInfo.getLastname(userId)+ SystemEnv.getHtmlLabelName(18805,weaver.general.ThreadVarLanguage.getLang())+signDate+SystemEnv.getHtmlLabelName(547673,weaver.general.ThreadVarLanguage.getLang())); + } + }else{ + result.put("status", "-1"); + result.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(390273,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""); + return result; + } + } + } + } + return result; + } + + /** + * 判断打卡归属日期 + * @param userid + * @param date + * @param time + * @throws Exception + */ + public String getBelongDate(String userid, String date, String time) throws Exception{ + KQOverTimeRuleCalBiz kqOverTimeRuleCalBiz = new KQOverTimeRuleCalBiz(); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + String preDay = DateUtil.addDate(date, -1);//昨天 + String nextDay = DateUtil.addDate(date, 1);//明天 + Map changeTypeMap = Maps.newHashMap(); + Map overRulesDetailMap = Maps.newHashMap(); + Map> restTimeMap = Maps.newHashMap(); + Map computingModeMap = Maps.newHashMap(); + //先获取一些前提数据,加班規則和假期規則 + kqOverTimeRuleCalBiz.getOverTimeDataMap(userid, preDay, nextDay, dateFormatter,changeTypeMap,overRulesDetailMap,restTimeMap,computingModeMap); + + String change_key = date+"_"+userid; + String preChange_key = preDay+"_"+userid; + String nextChange_key = nextDay+"_"+userid; + int changeType = Util.getIntValue(""+changeTypeMap.get(change_key),-1); + int preChangeType = Util.getIntValue(""+changeTypeMap.get(preChange_key),-1); + int nextChangeType = Util.getIntValue(""+changeTypeMap.get(nextChange_key),-1); + String changeType_key = date+"_"+changeType; + String preChangeType_key = preDay+"_"+preChangeType; + String nextChangeType_key = nextDay+"_"+nextChangeType; + KQOvertimeRulesDetailEntity curKqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key); + KQOvertimeRulesDetailEntity preKqOvertimeRulesDetailEntity = overRulesDetailMap.get(preChangeType_key); + KQOvertimeRulesDetailEntity nextKqOvertimeRulesDetailEntity = overRulesDetailMap.get(preChangeType_key); + + boolean isInRange = checkInWortTimeRange(userid, date,date, time,curKqOvertimeRulesDetailEntity); + if(isInRange){ + return date; + } + isInRange = checkInWortTimeRange(userid, preDay,date, time, preKqOvertimeRulesDetailEntity); + if(isInRange){ + return preDay; + } + isInRange = checkInWortTimeRange(userid, nextDay,date, time, nextKqOvertimeRulesDetailEntity); + if(isInRange){ + return nextDay; + } + return date; + + } + + public boolean checkInWortTimeRange(String userid, String checkDate, String date, String time, + KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity) throws Exception{ + boolean isInRange = false; + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String preDay = DateUtil.addDate(checkDate, -1);//昨天 + String nextDay = DateUtil.addDate(checkDate, 1);//明天 + + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTime = kqWorkTime.getWorkTime(userid, checkDate); + List lsSignTime = new ArrayList<>(); + List lsWorkTime = new ArrayList<>(); + lsSignTime = workTime.getSignTime();//允许打卡时间 + if(lsSignTime != null && !lsSignTime.isEmpty()) { + TimeScopeEntity firstSignTimeScope = lsSignTime.get(0); + TimeScopeEntity lastSignTimeScope = lsSignTime.get(lsSignTime.size()-1); + String beginSignScope = ""; + String endSignScope = ""; + + String signBeginTime = firstSignTimeScope.getBeginTime(); + String signEndTime = lastSignTimeScope.getEndTime(); + beginSignScope = checkDate+" "+signBeginTime; + endSignScope = checkDate+" "+signEndTime; + //上班允许打卡是否跨到前一天 + boolean beginTimePreAcross = firstSignTimeScope.isBeginTimePreAcross(); + if(beginTimePreAcross){ + beginSignScope = preDay+" "+signBeginTime; + } + boolean signEndTimeAcross = lastSignTimeScope.getEndTimeAcross(); + if(signEndTimeAcross){ + endSignScope = nextDay+" "+signEndTime; + } + if(beginSignScope.length() > 0){ + beginSignScope = beginSignScope+":00"; + } + if(endSignScope.length() > 0){ + endSignScope = endSignScope+":59"; + } + if(kqOvertimeRulesDetailEntity != null){ + int has_cut_point = kqOvertimeRulesDetailEntity.getHas_cut_point(); + if(has_cut_point == 1){ + //如果设置了打卡归属 + String cut_point = kqOvertimeRulesDetailEntity.getCut_point(); + String cut_point_datettime = nextDay+" "+cut_point+":59"; + if(endSignScope.compareTo(cut_point_datettime) < 0){ + endSignScope = cut_point_datettime; + } + } + } + String datetime = date+" "+time; + if(beginSignScope.length() > 0 && endSignScope.length() > 0){ + LocalDateTime local_beginSignScope = LocalDateTime.parse(beginSignScope,fullFormatter); + LocalDateTime local_endSignScope = LocalDateTime.parse(endSignScope,fullFormatter); + LocalDateTime datetime_endSignScope = LocalDateTime.parse(datetime,fullFormatter); + if((datetime_endSignScope.isAfter(local_beginSignScope) || datetime_endSignScope.equals(local_beginSignScope)) + && (datetime_endSignScope.isBefore(local_endSignScope) || datetime_endSignScope.equals(local_endSignScope))){ + isInRange = true; + } + } + } + return isInRange; + } + + +} diff --git a/src/com/engine/kq/wfset/util/KQFlowEvectionUtil.java b/src/com/engine/kq/wfset/util/KQFlowEvectionUtil.java new file mode 100644 index 0000000..1620881 --- /dev/null +++ b/src/com/engine/kq/wfset/util/KQFlowEvectionUtil.java @@ -0,0 +1,112 @@ +package com.engine.kq.wfset.util; + +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.kq.biz.KQTravelRulesBiz; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; + +public class KQFlowEvectionUtil { + private KQLog kqLog = new KQLog(); + + + /** + * 拆分出差数据 生成splitBeans + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQEvectionAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + return kqFlowActiontBiz.handleAction(sqlMap,splitBeans, datetimeFormatter, workflowId,requestId, rci,DurationTypeEnum.EVECTION); + } + /** + * 出差流程单独需要赋值的数据 + * @param prefix + * @param rs1 + * @param splitBean + */ + public static void bean4Evection(String prefix,RecordSet rs1, SplitBean splitBean) { + String minimumUnit = Util.null2s(Util.null2String(KQTravelRulesBiz.getMinimumUnit()),"-1"); + String computingMode = Util.null2s(Util.null2String(KQTravelRulesBiz.getComputingMode()),"-1"); + String companion = Util.null2s(rs1.getString(prefix+"companion"), ""); + String edit_duration = Util.null2s(rs1.getString(prefix+"edit_duration"), ""); + //设置同行人 这里拆分的时候并没有把同行人也拆分 + splitBean.setCompanion(companion); + splitBean.setDurationrule(minimumUnit); + splitBean.setComputingMode(computingMode); + splitBean.setEdit_duration(edit_duration); + } + + /** + * 出差流程特有的陪同人 + * @param companion + * @param bean + * @param params + * @param rci + * @param formateList + */ + public void splitEvectionCompanion(String companion, SplitBean bean, + List params, ResourceComInfo rci, List formateList) { + String[] companions = companion.split(","); + if(companions != null && companions.length > 0 ) { + for (int i = 0; i < companions.length; i++) { + String compan_resid = companions[i]; + if(compan_resid.length() > 0 && Util.getIntValue(compan_resid) > 0){ + if(bean.getResourceId().equalsIgnoreCase(compan_resid)){ + //陪同人是自己的不要存到中间表里 + continue; + } + List beanParams = new ArrayList(); + beanParams.add(bean.getRequestId()); + beanParams.add(bean.getWorkflowId()); + beanParams.add(bean.getDataId()); + beanParams.add(bean.getDetailId()); + beanParams.add(compan_resid); + beanParams.add(bean.getFromDate()); + beanParams.add(bean.getFromTime()); + beanParams.add(bean.getToDate()); + beanParams.add(bean.getToTime()); + beanParams.add(bean.getNewLeaveType()); + beanParams.add(Util.null2s(bean.getDuration(),"0")); + beanParams.add(bean.getUsedetail()); + beanParams.add(bean.getDurationrule()); + beanParams.add(bean.getTablenamedb()); + beanParams.add(bean.getFromdatedb()); + beanParams.add(bean.getFromtimedb()); + beanParams.add(bean.getTodatedb()); + beanParams.add(bean.getTotimedb()); + beanParams.add(bean.getDurationDB()); + beanParams.add(bean.getStatus()); + beanParams.add(bean.getBelongDate()); + beanParams.add(bean.getD_Mins()); + beanParams.add(bean.getSerialid()); + beanParams.add(bean.getChangeType()); + beanParams.add(rci.getSubCompanyID(compan_resid)); + beanParams.add(rci.getDepartmentID(compan_resid)); + beanParams.add(rci.getDepartmentID(compan_resid)); + beanParams.add(bean.getCompanion()); + beanParams.add("1"); + String format_1 = compan_resid+"_"+bean.getBelongDate(); + formateList.add(format_1); + params.add(beanParams); + } + } + } + } +} diff --git a/src/com/engine/kq/wfset/util/KQFlowLeaveBackUtil.java b/src/com/engine/kq/wfset/util/KQFlowLeaveBackUtil.java new file mode 100644 index 0000000..fddd91d --- /dev/null +++ b/src/com/engine/kq/wfset/util/KQFlowLeaveBackUtil.java @@ -0,0 +1,449 @@ +package com.engine.kq.wfset.util; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.bean.KQRepeatBean; +import com.engine.kq.biz.*; +import com.engine.kq.cmd.attendanceEvent.GetLeaveBackInfoCmd; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.ProcessChangeSplitBean; +import com.engine.kq.wfset.bean.SplitBean; +import com.google.common.collect.Maps; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +public class KQFlowLeaveBackUtil { + private static KQLog kqLog = new KQLog(); + + /** + * 拆分销假流程数据 生成数据到splitBeans和backsplitBeans + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQLeaveBackAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + Map result = kqFlowActiontBiz.handleAction(sqlMap,splitBeans, datetimeFormatter, workflowId,requestId, rci,DurationTypeEnum.LEAVEBACK); + KQRepeatLengthContext.removeRepeatBean(); + return result; + } + /** + * 销假流程和请假流程相似 单独需要赋值的数据 + * @param prefix + * @param rs1 + * @param splitBean + */ + public static void bean4LeaveBack(String prefix, RecordSet rs1, SplitBean splitBean) { + String leaverequestid = Util.null2s(rs1.getString("leaverequestid"), ""); + String newLeaveType = Util.null2s(rs1.getString(prefix+"newLeaveType"), ""); + String minimumUnit = Util.null2s(Util.null2String(KQLeaveRulesBiz.getMinimumUnit(newLeaveType)),"-1"); + String computingMode = Util.null2s(Util.null2String(KQLeaveRulesBiz.getComputingMode(newLeaveType)),"-1"); + String edit_duration = Util.null2s(rs1.getString(prefix+"edit_duration"), ""); + String resourceId = Util.null2s(rs1.getString("resourceId"), ""); + + splitBean.setLeavebackrequestid(leaverequestid); + splitBean.setNewLeaveType(newLeaveType); + splitBean.setDurationrule(minimumUnit); + splitBean.setComputingMode(computingMode); + splitBean.setEdit_duration(edit_duration); + if("2".equalsIgnoreCase(computingMode)){ + //只有自然日 请假才有这个排除节假日、休息日的功能 + splitBean.setFilterholidays(KQLeaveRulesBiz.getFilterHolidays(newLeaveType)); + } + if(newLeaveType.length() > 0){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String conversion = kqLeaveRulesComInfo.getConversion(newLeaveType); + splitBean.setConversion(conversion); + String repeatTime = kqLeaveRulesComInfo.getRepeatTime(newLeaveType); + splitBean.setRepeatTime(repeatTime); + } + + Map params = Maps.newHashMap(); + params.put("resourceId",resourceId); + params.put("requestid",leaverequestid); + GetLeaveBackInfoCmd getLeaveBackInfoCmd = new GetLeaveBackInfoCmd(params,new User(Util.getIntValue(resourceId))); + Map backmap = getLeaveBackInfoCmd.execute(null); + if(MapUtils.isNotEmpty(backmap)){ + if(backmap.containsKey("backList")){ + List backList = (List) backmap.get("backList"); + if(CollectionUtils.isNotEmpty(backList)){ + Map backListMap = (Map) backList.get(0); + if(backListMap.containsKey("repeatType")){ + String repeatType = Util.null2String(backListMap.get("repeatType")); + String repeatLate = Util.null2String(backListMap.get("repeat_late")); + String repeatEarly = Util.null2String(backListMap.get("repeat_early")); + if(repeatType.length() > 0){ + splitBean.setRepeatTime("0"); + if("0".equals(repeatType) || "1".equals(repeatType) || "2".equals(repeatType)){ + splitBean.setRepeatType(repeatType); + splitBean.setRepeatLate(repeatLate); + splitBean.setRepeatEarly(repeatEarly); + if(splitBean.getFromtimedb().length() == 0){ + splitBean.setFromtimedb("00:00"); + } + if(splitBean.getTotimedb().length() == 0){ + splitBean.setTotimedb("23:59"); + } + KQRepeatBean kqRepeatBean = new KQRepeatBean(); + kqRepeatBean.setRepeatType(repeatType); + if(StringUtils.isNotEmpty(repeatLate)){ + kqRepeatBean.setRepeatLate(new Double(Double.valueOf(repeatLate)).longValue()); + } + if(StringUtils.isNotEmpty(repeatEarly)){ + kqRepeatBean.setRepeatEarly(new Double(Double.valueOf(repeatEarly)).longValue()); + } + KQRepeatLengthContext.setRepeatBean(kqRepeatBean); + } + } + } + } + } + } + } + + + + /** + * 销假流程特有的校验事件 + */ + public static boolean leaveBackCheck(RecordSet rs1, DateTimeFormatter datetimeFormatter, String prefix, + Map result, Map repeatTypeMap) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + + String fromDate = Util.null2s(rs1.getString(prefix+"fromDate"), ""); + String toDate = Util.null2s(rs1.getString(prefix+"toDate"), ""); + String fromTime = Util.null2s(rs1.getString(prefix+"fromTime"), ""); + String toTime = Util.null2s(rs1.getString(prefix+"toTime"), ""); + + String leavefromDate = Util.null2s(rs1.getString(prefix+"leavefromDate"), ""); + String leavetoDate = Util.null2s(rs1.getString(prefix+"leavetoDate"), ""); + String leavefromTime = Util.null2s(rs1.getString(prefix+"leavefromTime"), ""); + String leavetoTime = Util.null2s(rs1.getString(prefix+"leavetoTime"), ""); + String leaveduration = Util.null2s(rs1.getString(prefix+"leaveduration"), ""); + String resourceId = Util.null2s(rs1.getString("resourceId"), ""); + String leaverequestid = Util.null2s(rs1.getString("leaverequestid"), ""); + String newLeaveType1 = Util.null2s(rs1.getString(prefix+"newLeaveType"), ""); + + String repeatType = ""; + Map params = Maps.newHashMap(); + params.put("resourceId",resourceId); + params.put("requestid",leaverequestid); + GetLeaveBackInfoCmd getLeaveBackInfoCmd = new GetLeaveBackInfoCmd(params,new User(Util.getIntValue(resourceId))); + Map backmap = getLeaveBackInfoCmd.execute(null); + if(MapUtils.isNotEmpty(backmap)){ + if(backmap.containsKey("backList")){ + List backList = (List) backmap.get("backList"); + if(CollectionUtils.isNotEmpty(backList)){ + Map backListMap = (Map) backList.get(0); + if(backListMap.containsKey("repeatType")){ + repeatType = Util.null2String(backListMap.get("repeatType")); + if(repeatType.length() > 0){ + repeatTypeMap.put("repeatType",repeatType); + } + } + } + } + } + KQFlowUtil kqFlowUtil = new KQFlowUtil(); + Map repeatMap = kqFlowUtil.resetTimeWhenRepeat(newLeaveType1,repeatType); + if(MapUtils.isNotEmpty(repeatMap) && repeatMap.containsKey("fromTime") && repeatMap.containsKey("toTime")){ + leavefromTime = Util.null2s(repeatMap.get("fromTime"),leavefromTime); + leavetoTime = Util.null2s(repeatMap.get("toTime"),leavetoTime); + fromTime = Util.null2s(repeatMap.get("fromTime"),fromTime); + toTime = Util.null2s(repeatMap.get("toTime"),toTime); + repeatTypeMap.put("fromTime",fromTime); + repeatTypeMap.put("toTime",toTime); + } + LocalDateTime localFromDateTime = LocalDateTime.parse(fromDate+" "+fromTime,datetimeFormatter); + LocalDateTime localToDateTime = LocalDateTime.parse(toDate+" "+toTime,datetimeFormatter); + + LocalDateTime localleaveFromDateTime = LocalDateTime.parse(leavefromDate+" "+leavefromTime,datetimeFormatter); + LocalDateTime localleaveToDateTime = LocalDateTime.parse(leavetoDate+" "+leavetoTime,datetimeFormatter); + + String newLeaveType = Util.null2s(rs1.getString(prefix+"newLeaveType"), ""); + if(newLeaveType.length() > 0){ + String repeatTime = kqLeaveRulesComInfo.getRepeatTime(newLeaveType); + if("1".equals(repeatTime)){ + if(!fromTime.equals(leavefromTime) || !toTime.equals(leavetoTime)){ + //销假信息有误 + result.put("status", "-1"); + result.put("message", ""+ SystemEnv.getHtmlLabelName(505782,weaver.general.ThreadVarLanguage.getLang())+""); + return false; + } + } + } + + //销假区间要在请假区间内 + if((localFromDateTime.isAfter(localleaveFromDateTime) || localFromDateTime.isEqual(localleaveFromDateTime)) && + (localFromDateTime.isBefore(localleaveToDateTime) || localFromDateTime.isEqual(localleaveToDateTime)) && + (localToDateTime.isAfter(localleaveFromDateTime) || localToDateTime.isEqual(localleaveFromDateTime)) && + (localToDateTime.isBefore(localleaveToDateTime) || localToDateTime.isEqual(localleaveToDateTime))){ + //这是满足条件的 + }else{ + //不在请假区间的 + result.put("status", "-1"); + result.put("message", ""+ SystemEnv.getHtmlLabelName(10005407,weaver.general.ThreadVarLanguage.getLang())+""); + return false; + } + return true; + } + /** + * + * @param splitBeans + * @param result + * @param isUpgrade 是否是升级,升级的话不需要处理假期余额数据 + * @param requestId + * @throws Exception + */ + public void handleSplitFLowActionData4LeaveBack( + List splitBeans, Map result, boolean isUpgrade, int requestId) throws Exception{ + + boolean isBackOk = buildLeaveBackData(splitBeans,requestId); + if(isBackOk){ + if(!isUpgrade){ + //根据销假数据回填带薪数据 + reBuildBalance(splitBeans); + } + + }else{ + result.put("status", "-1"); + result.put("message", ""+ SystemEnv.getHtmlLabelName(10005408,weaver.general.ThreadVarLanguage.getLang())+":"+ SystemEnv.getHtmlLabelName(10005409,weaver.general.ThreadVarLanguage.getLang())+""); + return ; + } + } + + /** + * 销假数据拆分记录 + * @param backsplitBeans + * @param requestId + * @return + */ + public boolean buildLeaveBackData(List backsplitBeans, int requestId){ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + List formateList = new ArrayList<>(); + String backbatchSql = "insert into "+ KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" (subcompanyid,departmentid,jobtitle,requestid,workflowid,usedetail,dataid,detailid,resourceid,fromdate,fromtime,todate,totime,newleavetype,durationdb,duration,durationrule,status,belongDate,D_Mins,serialid,tablenamedb,fromdatedb,fromtimedb,todatedb,totimedb,leavebackrequestid)"+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + List params = new ArrayList(); + List updateSql = new ArrayList<>(); + + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + for(SplitBean bean : backsplitBeans){ + List beanParams = new ArrayList(); + if(bean.getD_Mins() > 0 && bean.getWorkmins() > 0 && bean.getD_Mins() == bean.getWorkmins()){ + String endDate = bean.getToDate(); + String toTime = bean.getToTime(); + if(toTime.length() > 0 && kqTimesArrayComInfo.getArrayindexByTimes(toTime) >= 1440){ + endDate = DateUtil.addDate(endDate, 1); + toTime = kqTimesArrayComInfo.turn48to24Time(toTime); + } + StringBuffer timeWhere = new StringBuffer(); + if(endDate.length() > 0){ + String tmpDate = endDate+" "+toTime; + if(rs.getDBType().equals("oracle")){ + timeWhere.append(" AND signDate||' '||signTime<='").append(tmpDate).append("' "); + } else if(rs.getDBType().equals("postgresql")){ + timeWhere.append(" AND signDate||' '||signTime<='").append(tmpDate).append("' "); + } else if(rs.getDBType().equals("mysql")){ + timeWhere.append(" AND concat(signDate,' ',signTime)<='").append(tmpDate).append("' "); + }else{ + timeWhere.append(" AND signDate+' '+signTime<='").append(tmpDate).append("' "); + } + } + //如果销假时长就是一条的工作时长 + String whole_day_sql = "select * from "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId() + + (timeWhere.length() > 0 ? timeWhere : "") + +" and belongdate='"+bean.getBelongDate()+"' order by fromdate,fromtime"; + + rs1.executeQuery(whole_day_sql); + int i = 0 ; + while (rs1.next()){ + if(i == 0){ + bean.setFromDate(rs1.getString("fromdate")); + bean.setFromTime(rs1.getString("fromtime")); + } + bean.setToDate(rs1.getString("todate")); + bean.setToTime(rs1.getString("totime")); + i++; + } + } + beanParams.add(bean.getSubcompanyid()); + beanParams.add(bean.getDepartmentid()); + beanParams.add(bean.getJobtitle()); + beanParams.add(bean.getRequestId()); + beanParams.add(bean.getWorkflowId()); + beanParams.add(bean.getUsedetail()); + beanParams.add(bean.getDataId()); + beanParams.add(bean.getDetailId()); + beanParams.add(bean.getResourceId()); + beanParams.add(bean.getFromDate()); + beanParams.add(bean.getFromTime()); + beanParams.add(bean.getToDate()); + beanParams.add(bean.getToTime()); + beanParams.add(bean.getNewLeaveType()); + beanParams.add(bean.getDurationDB()); + beanParams.add(Util.null2s(bean.getDuration(),"0")); + beanParams.add(bean.getDurationrule()); + beanParams.add(bean.getStatus()); + beanParams.add(bean.getBelongDate()); + beanParams.add(bean.getD_Mins()); + beanParams.add(bean.getSerialid()); + beanParams.add(bean.getTablenamedb()); + beanParams.add(bean.getFromdatedb()); + beanParams.add(bean.getFromtimedb()); + beanParams.add(bean.getTodatedb()); + beanParams.add(bean.getTotimedb()); + beanParams.add(bean.getLeavebackrequestid()); + String format = bean.getResourceId()+"_"+bean.getBelongDate(); + formateList.add(format); + + params.add(beanParams); + + String newLeaveType = bean.getNewLeaveType(); + String repeatTime = "0"; + if(newLeaveType.length() > 0){ + repeatTime = kqLeaveRulesComInfo.getRepeatTime(newLeaveType); + if(Util.null2String(bean.getRepeatType()).length() > 0){ + repeatTime = "0"; + } + } + String updateLeaveSql = ""; + if(rs1.getDBType().equalsIgnoreCase("oracle")||rs1.getDBType().equalsIgnoreCase("gs")) { + updateLeaveSql = "update "+ KqSplitFlowTypeEnum.LEAVE.getTablename()+" set leavebackrequestid=nvl(leavebackrequestid,'')||','||"+bean.getRequestId()+" where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId()+" and belongdate='"+bean.getBelongDate()+"'"; + if("1".equals(repeatTime)){ + String fromtime = bean.getFromTime(); + String totime = bean.getToTime(); + updateLeaveSql+= " and FROMTIME <='"+fromtime+"' and TOTIME >='"+totime+"' "; + } + }else if((rs1.getDBType()).equalsIgnoreCase("postgresql")){ + updateLeaveSql = "update "+ KqSplitFlowTypeEnum.LEAVE.getTablename()+" set leavebackrequestid=coalesce(leavebackrequestid,'')||','||"+bean.getRequestId()+" where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId()+" and belongdate='"+bean.getBelongDate()+"'"; + if("1".equals(repeatTime)){ + String fromtime = bean.getFromTime(); + String totime = bean.getToTime(); + updateLeaveSql+= " and FROMTIME <='"+fromtime+"' and TOTIME >='"+totime+"' "; + } + }else if((rs1.getDBType()).equalsIgnoreCase("mysql")){ + updateLeaveSql = "update "+ KqSplitFlowTypeEnum.LEAVE.getTablename()+" set leavebackrequestid=concat(ifnull(leavebackrequestid,''),',',"+bean.getRequestId()+") where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId()+" and belongdate='"+bean.getBelongDate()+"'"; + if("1".equals(repeatTime)){ + String fromtime = bean.getFromTime(); + String totime = bean.getToTime(); + updateLeaveSql+= " and FROMTIME <='"+fromtime+"' and TOTIME >='"+totime+"' "; + } + }else { + updateLeaveSql = "update "+ KqSplitFlowTypeEnum.LEAVE.getTablename()+" set leavebackrequestid=isnull(leavebackrequestid,'')+',"+bean.getRequestId()+"'"+" where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId()+" and belongdate='"+bean.getBelongDate()+"'"; + if("1".equals(repeatTime)){ + String fromtime = bean.getFromTime(); + String totime = bean.getToTime(); + updateLeaveSql+= " and FROMTIME <='"+fromtime+"' and TOTIME >='"+totime+"' "; + } + } + updateSql.add(updateLeaveSql); + } + if(!params.isEmpty()){ + //先根据requestid删除中间表里的数据,再做啥插入操作 + String delSql = "delete from "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" where requestid = "+requestId; + rs2.executeUpdate(delSql); + boolean isOk = rs1.executeBatchSql(backbatchSql, params); + if(isOk){ + for(String up_sql : updateSql){ + kqLog.info("销假记录sql buildLeaveBackData up_sql:"+up_sql); + boolean isUpOk = rs.executeUpdate(up_sql); + kqLog.info("销假记录执行情况 buildLeaveBackData isUpOk:"+isUpOk); + } + KQFormatData kqFormatData = new KQFormatData(); + kqLog.info("handleSplitFLowActionData4LeaveBack:formateList:"+formateList); + for(String format: formateList){ + String[] formats = format.split("_"); + kqLog.info("handleSplitFLowActionData4LeaveBack:formats:"+ JSON.toJSONString(formats)); + new KQFormatData().formatKqDateByLock(formats[0],formats[1],17); + } + return true; + }else{ + return false; + } + }else{ + return false; + } + } + + /** + * 根据销假数据回填带薪数据 + * @param backsplitBeans 销假数据 + * @return + */ + public static void reBuildBalance(List backsplitBeans) throws Exception{ + for(SplitBean splitBean : backsplitBeans){ + String requestid = splitBean.getRequestId(); + String back_requestid = splitBean.getLeavebackrequestid(); + String resourceId = splitBean.getResourceId(); + String newLeaveType = splitBean.getNewLeaveType(); + String duration = splitBean.getDuration(); + String durationrule = splitBean.getDurationrule(); + String fromdatedb = splitBean.getFromDate(); + kqLog.info("销假返还:resourceId:"+resourceId+":duration:"+duration+":newLeaveType:"+newLeaveType+":durationrule:"+durationrule+":requestid:"+requestid+":fromdatedb:"+fromdatedb+":back_requestid:"+back_requestid); + if(null != duration && Util.getDoubleValue(duration)<=0){ + continue; + } + KQBalanceOfLeaveBiz.reduceUsedAmount(resourceId, fromdatedb, newLeaveType, duration, "",requestid,back_requestid); + } + } + + /** + * 根据销假数据回填带薪数据 + * @param backsplitBeans 销假数据 + * @return + */ + public static void reBuildChangeBalance(List backsplitBeans) throws Exception{ + List repeatList = new ArrayList<>(); + for(SplitBean splitBean : backsplitBeans){ + String back_requestid = splitBean.getLeavebackrequestid(); + String requestid = splitBean.getRequestId(); + String newLeaveType = splitBean.getNewLeaveType(); + String durationrule = splitBean.getDurationrule(); + String fromdate = splitBean.getFromDate(); + ProcessChangeSplitBean processChangeSplitBean = splitBean.getProcessChangeSplitBean(); + String resourceId = splitBean.getResourceId(); + String fromdatedb = processChangeSplitBean.getFromdatedb(); + String fromtimedb = processChangeSplitBean.getFromtimedb(); + String todatedb = processChangeSplitBean.getTodatedb(); + String totimedb = processChangeSplitBean.getTotimedb(); + String process_durationdb = processChangeSplitBean.getDurationDB(); + String param = requestid+"#"+back_requestid+"#"+resourceId+"#"+fromdatedb+"#"+fromtimedb+"#"+todatedb+"#"+totimedb+"#"+process_durationdb; + if(repeatList.contains(param)) { + continue; + } + repeatList.add(param); + kqLog.info("销假返还:resourceId:"+resourceId+":process_durationdb:"+process_durationdb+":newLeaveType:"+newLeaveType+":durationrule:"+durationrule+":requestid:"+requestid+":fromdate:"+fromdate+":back_requestid:"+back_requestid); + KQBalanceOfLeaveBiz.reduceUsedAmount(resourceId, fromdate, newLeaveType, process_durationdb, "",requestid,back_requestid); + } + } +} diff --git a/src/com/engine/kq/wfset/util/KQFlowLeaveUtil.java b/src/com/engine/kq/wfset/util/KQFlowLeaveUtil.java new file mode 100644 index 0000000..03ee4db --- /dev/null +++ b/src/com/engine/kq/wfset/util/KQFlowLeaveUtil.java @@ -0,0 +1,96 @@ +package com.engine.kq.wfset.util; + +import com.engine.kq.bean.KQRepeatBean; +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQRepeatLengthContext; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; + +public class KQFlowLeaveUtil { + private KQLog kqLog = new KQLog(); + + + /** + * 拆分请假数据 生成splitBeans + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQLeaveAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + Map result = kqFlowActiontBiz.handleAction(sqlMap,splitBeans, datetimeFormatter, workflowId,requestId, rci,DurationTypeEnum.LEAVE); + KQRepeatLengthContext.removeRepeatBean(); + return result; + } + + + /** + * 请假流程单独需要赋值的数据 + * @param prefix + * @param rs1 + * @param splitBean + */ + public static void bean4Leave(String prefix,RecordSet rs1, SplitBean splitBean) { + String newLeaveType = Util.null2s(rs1.getString(prefix+"newLeaveType"), ""); + String minimumUnit = Util.null2s(Util.null2String(KQLeaveRulesBiz.getMinimumUnit(newLeaveType)),"-1"); + String computingMode = Util.null2s(Util.null2String(KQLeaveRulesBiz.getComputingMode(newLeaveType)),"-1"); + String edit_duration = Util.null2s(rs1.getString(prefix+"edit_duration"), ""); + String repeatType = Util.null2s(rs1.getString(prefix+"repeat_type"), ""); + String repeatLate = Util.null2s(rs1.getString(prefix+"repeat_late"), ""); + String repeatEarly = Util.null2s(rs1.getString(prefix+"repeat_early"), ""); + + splitBean.setNewLeaveType(newLeaveType); + splitBean.setDurationrule(minimumUnit); + splitBean.setComputingMode(computingMode); + splitBean.setEdit_duration(edit_duration); + if("2".equalsIgnoreCase(computingMode)){ + //只有自然日 请假才有这个排除节假日、休息日的功能 + splitBean.setFilterholidays(KQLeaveRulesBiz.getFilterHolidays(newLeaveType)); + } + if(newLeaveType.length() > 0){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String conversion = kqLeaveRulesComInfo.getConversion(newLeaveType); + splitBean.setConversion(conversion); + String repeatTime = kqLeaveRulesComInfo.getRepeatTime(newLeaveType); + splitBean.setRepeatTime(repeatTime); + } + if("0".equals(repeatType) || "1".equals(repeatType) || "2".equals(repeatType)){ + splitBean.setRepeatType(repeatType); + splitBean.setRepeatLate(repeatLate); + splitBean.setRepeatEarly(repeatEarly); + if(splitBean.getFromtimedb().length() == 0){ + splitBean.setFromtimedb("00:00"); + } + if(splitBean.getTotimedb().length() == 0){ + splitBean.setTotimedb("23:59"); + } + KQRepeatBean kqRepeatBean = new KQRepeatBean(); + kqRepeatBean.setRepeatType(repeatType); + if(StringUtils.isNotEmpty(repeatLate)){ + kqRepeatBean.setRepeatLate(new Double(Double.valueOf(repeatLate)).longValue()); + } + if(StringUtils.isNotEmpty(repeatEarly)){ + kqRepeatBean.setRepeatEarly(new Double(Double.valueOf(repeatEarly)).longValue()); + } + KQRepeatLengthContext.setRepeatBean(kqRepeatBean); + } + } +} diff --git a/src/com/engine/kq/wfset/util/KQFlowOtherUtil.java b/src/com/engine/kq/wfset/util/KQFlowOtherUtil.java new file mode 100644 index 0000000..7f22bd6 --- /dev/null +++ b/src/com/engine/kq/wfset/util/KQFlowOtherUtil.java @@ -0,0 +1,33 @@ +package com.engine.kq.wfset.util; + +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.wfset.bean.SplitBean; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Map; +import weaver.hrm.resource.ResourceComInfo; + +public class KQFlowOtherUtil { + + + + /** + * 拆分异常流程数据 生成数据到splitBeans + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQOtherAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + return kqFlowActiontBiz.handleAction(sqlMap,splitBeans, datetimeFormatter, workflowId,requestId, rci,DurationTypeEnum.OTHER); + } +} diff --git a/src/com/engine/kq/wfset/util/KQFlowOutUtil.java b/src/com/engine/kq/wfset/util/KQFlowOutUtil.java new file mode 100644 index 0000000..4d7a14e --- /dev/null +++ b/src/com/engine/kq/wfset/util/KQFlowOutUtil.java @@ -0,0 +1,56 @@ +package com.engine.kq.wfset.util; + +import com.engine.kq.biz.KQExitRulesBiz; +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.wfset.bean.SplitBean; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; + +public class KQFlowOutUtil { + + + /** + * 拆分公出数据 生成splitBeans + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQOutAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + return kqFlowActiontBiz.handleAction(sqlMap,splitBeans, datetimeFormatter, workflowId,requestId, rci,DurationTypeEnum.OUT); + } + + /** + * 公出流程单独需要赋值的数据 + * @param splitBean + */ + public static void bean4Out(SplitBean splitBean) { + bean4Out("",null,splitBean); + } + public static void bean4Out(String prefix,RecordSet rs1,SplitBean splitBean) { + String minimumUnit = Util.null2s(Util.null2String(KQExitRulesBiz.getMinimumUnit()),"-1"); + String computingMode = Util.null2s(Util.null2String(KQExitRulesBiz.getComputingMode()),"-1"); + if(null != rs1){ + String edit_duration = Util.null2s(rs1.getString(prefix+"edit_duration"), ""); + splitBean.setEdit_duration(edit_duration); + } + + splitBean.setDurationrule(minimumUnit); + splitBean.setComputingMode(computingMode); + + } +} diff --git a/src/com/engine/kq/wfset/util/KQFlowOvertimeUtil.java b/src/com/engine/kq/wfset/util/KQFlowOvertimeUtil.java new file mode 100644 index 0000000..1da2203 --- /dev/null +++ b/src/com/engine/kq/wfset/util/KQFlowOvertimeUtil.java @@ -0,0 +1,169 @@ +package com.engine.kq.wfset.util; + +import com.engine.kq.biz.KQFLowEventLogBiz; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQWorkTime; +import com.engine.kq.biz.chain.duration.NonDayUnitSplitChain; +import com.engine.kq.biz.chain.duration.NonHalfUnitSplitChain; +import com.engine.kq.biz.chain.duration.NonHourUnitSplitChain; +import com.engine.kq.biz.chain.duration.NonWholeUnitSplitChain; +import com.engine.kq.biz.chain.duration.NonWorkDurationChain; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import com.google.common.collect.Maps; + +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; + +public class KQFlowOvertimeUtil { + private KQLog kqLog = new KQLog(); + + /** + * 拆分加班数据 生成splitBeans + * + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @param uuid + * @return + * @throws Exception + */ + public Map handleKQOvertimeAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci, String main_uuid) throws Exception { + KQFlowUtil kqFlowUtil = new KQFlowUtil(); + KQFLowEventLogBiz kqfLowEventLogBiz = new KQFLowEventLogBiz(); + + KQWorkTime kqWorkTime = new KQWorkTime(); + RecordSet rs1 = new RecordSet(); + Map result = new HashMap<>(); + + if (!sqlMap.isEmpty()) { + for (Map.Entry me : sqlMap.entrySet()) { + String key = me.getKey(); + String value = me.getValue(); + String concort = "###"; + int usedetail = Util.getIntValue(key.split(concort)[2], 0); + String prefix = ""; + if (usedetail == 1) { + prefix = "detail_"; + } + + rs1.execute(value); + while (rs1.next()) { + + String resourceId = Util.null2s(rs1.getString(prefix + "resourceId"), ""); + String fromDate = Util.null2s(rs1.getString(prefix + "fromDate"), ""); + WorkTimeEntity kqWorkTimeEntity = kqWorkTime.getWorkTime(resourceId, fromDate); + + String actionKey = resourceId + "_" + fromDate; + Map workTimeEntityLogMap = Maps.newHashMap(); + workTimeEntityLogMap.put("resourceid", resourceId); + workTimeEntityLogMap.put("splitDate", fromDate); + workTimeEntityLogMap.put("workTimeEntity", kqWorkTimeEntity); + String uuid = kqfLowEventLogBiz.logDetailWorkTimeEntity(resourceId, workTimeEntityLogMap, main_uuid, "handleKQOvertimeAction|加班生成调休|key|" + actionKey); + + if (kqWorkTimeEntity != null) { + String kqType = Util.null2String(kqWorkTimeEntity.getKQType()); + if ("3".equalsIgnoreCase(kqType)) { + kqLog.info("自由班制不计算加班:resourceId:" + resourceId); + continue; + } + } + SplitBean splitBean = new SplitBean(); + boolean isFillRight = kqFlowUtil.fillSplitBean(splitBean, rs1, "" + requestId, rci, "" + workflowId, DurationTypeEnum.OVERTIME, key, result, datetimeFormatter, ""); + if (!isFillRight) { + return result; + } + + String edit_duration = splitBean.getEdit_duration().trim(); + int computingMode = KQOvertimeRulesBiz.getComputingMode(splitBean.getResourceId(), splitBean.getFromdatedb()); + if(edit_duration.length()>0 && computingMode==1){//暂时只支持纯加班的规则 + splitBean.setComputingMode("1"); + splitBean.setChangeType(KQOvertimeRulesBiz.getChangeType(splitBean.getResourceId(), splitBean.getFromdatedb())); + splitBean.setBelongDate(splitBean.getFromdatedb()); + splitBean.setDuration(edit_duration); + splitBean.setDurationDB(edit_duration); + double hoursToDay = KQOvertimeRulesBiz.getHoursToDay(); + int workmins = (int)(hoursToDay * 60); + splitBean.setWorkmins(workmins); + if("3".equals(splitBean.getDurationrule()) || "5".equals(splitBean.getDurationrule()) || "6".equals(splitBean.getDurationrule())){ + double D_Mins = Util.getDoubleValue(edit_duration,0.0)*60; + splitBean.setD_Mins(D_Mins); + }else{ + double D_Mins = Util.getDoubleValue(edit_duration,0.0)*workmins; + splitBean.setD_Mins(D_Mins); + } + splitBeans.add(splitBean); + }else { + + Map eventMap = Maps.newHashMap(); + eventMap.put("sql", value); + eventMap.put("sql拼装后的bean|splitBean", splitBean); + kqfLowEventLogBiz.logDetailEvent(resourceId, eventMap, uuid, "handleKQOvertimeAction|加班生成调休|key|" + actionKey); + List tmp_splitBeans = new ArrayList<>(); + doNonWorkSplitChain(splitBean, tmp_splitBeans); + splitBeans.addAll(tmp_splitBeans); + } + } + + } + } + return result; + } + + /** + * 计算非工作时长拆分 + * + * @param splitBean + * @param splitBeans + * @throws Exception + */ + public void doNonWorkSplitChain(SplitBean splitBean, List splitBeans) throws Exception { + + NonWorkDurationChain hourUnitSplitChain = new NonHourUnitSplitChain(splitBeans); + NonWorkDurationChain dayUnitSplitChain = new NonDayUnitSplitChain(splitBeans); + NonWorkDurationChain halfUnitSplitChain = new NonHalfUnitSplitChain(splitBeans); + NonWorkDurationChain wholeUnitSplitChain = new NonWholeUnitSplitChain(splitBeans); + + //设置执行链 + hourUnitSplitChain.setDurationChain(dayUnitSplitChain); + dayUnitSplitChain.setDurationChain(halfUnitSplitChain); + halfUnitSplitChain.setDurationChain(wholeUnitSplitChain); + //把初始数据设置进去 + hourUnitSplitChain.handleDuration(splitBean); + + } + + + /** + * 加班流程单独需要赋值的数据 + * + * @param prefix + * @param rs1 + * @param splitBean + */ + public static void bean4Overtime(String prefix, RecordSet rs1, SplitBean splitBean) { + String overtime_type = Util.null2s(rs1.getString(prefix + "overtime_type"), "-1"); + String minimumUnit = Util.null2s(Util.null2String(KQOvertimeRulesBiz.getMinimumUnit()), "-1"); + String edit_duration = Util.null2s(rs1.getString(prefix + "edit_duration"), ""); + String computingMode = "1"; + splitBean.setDurationrule(minimumUnit); + splitBean.setComputingMode(computingMode); + splitBean.setOvertime_type(overtime_type); + splitBean.setEdit_duration(edit_duration); + } + +} diff --git a/src/com/engine/kq/wfset/util/KQFlowProcessChangeUtil.java b/src/com/engine/kq/wfset/util/KQFlowProcessChangeUtil.java new file mode 100644 index 0000000..58c4b76 --- /dev/null +++ b/src/com/engine/kq/wfset/util/KQFlowProcessChangeUtil.java @@ -0,0 +1,681 @@ +package com.engine.kq.wfset.util; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.*; +import com.engine.kq.cmd.attendanceEvent.AttendanceUtil; +import com.engine.kq.cmd.attendanceEvent.GetProcessChangeTypeCmd; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.ProcessChangeSplitBean; +import com.engine.kq.wfset.bean.SplitBean; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; + +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +public class KQFlowProcessChangeUtil { + private User user; + + public KQFlowProcessChangeUtil() { + + } + + public KQFlowProcessChangeUtil(User user) { + this.user = user; + } + + private KQLog kqLog = new KQLog(); + public static boolean processChangeCheck(RecordSet rs1, String requestId_rs, Map result) { + String resourceId = Util.null2s(rs1.getString("resourceId"), ""); + String changerequestid = Util.null2s(rs1.getString("changerequestid"), ""); + String detail_attendancefromDate = Util.null2s(rs1.getString("detail_attendancefromDate"), ""); + String detail_attendancefromTime = Util.null2s(rs1.getString("detail_attendancefromTime"), ""); + String detail_attendancetoDate = Util.null2s(rs1.getString("detail_attendancetoDate"), ""); + String detail_attendancetoTime = Util.null2s(rs1.getString("detail_attendancetoTime"), ""); + boolean canProcessChange = canProcessChange(resourceId,changerequestid, detail_attendancefromDate, + detail_attendancefromTime, detail_attendancetoDate, detail_attendancetoTime); + if(!canProcessChange){ + result.put("status", "-1"); + result.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005328,weaver.general.ThreadVarLanguage.getLang())+","+weaver.systeminfo.SystemEnv.getHtmlLabelName(383337,weaver.general.ThreadVarLanguage.getLang())+""); + return false; + } + return true; + } + + /** + * 流程到申请节点默认释放 + */ + public void doLeaveFlowRelease(int workflowid, int requestid) { + kqLog.info("doLeaveFlowRelease workflowid:"+ workflowid+":::requestid::"+requestid); + RecordSet rs = new RecordSet(); + String updateFreezeSql = "update KQ_ATT_VACATION set status=2 where requestId=? and workflowId = ? "; + rs.executeUpdate(updateFreezeSql,requestid,workflowid); + } + + /** + * 请假变更的冻结 + * @param splitBeans + * @param retmap + */ + public void doLeaveFlowFreeze( List splitBeans, Map retmap) { + RecordSet rs = new RecordSet(); + int FREEZE = 1; + kqLog.info("doLeaveFlowFreeze splitBeans:"+ JSON.toJSONString(splitBeans)); + String batchSql = "insert into KQ_ATT_VACATION (requestId,workflowId,dataid,detailid,resourceId,fromDate,fromTime,toDate,toTime,duration,newLeaveType,durationrule,status)"+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?) "; + List params = new ArrayList(); + + String delSql = "delete from KQ_ATT_VACATION where requestId=?"; + List delparams = new ArrayList(); + + for(SplitBean bean : splitBeans){ + List beanParams = new ArrayList(); + String newLeaveType = bean.getNewLeaveType(); + //这个表里只存储含有假期余额的 + boolean balanceEnable = KQLeaveRulesBiz.getBalanceEnable(newLeaveType); + kqLog.info("KqFreezeVacationAction newLeaveType:"+ newLeaveType+":balanceEnable:"+balanceEnable); + if(!balanceEnable) { + continue; + } + beanParams.add(bean.getRequestId()); + beanParams.add(bean.getWorkflowId()); + beanParams.add(bean.getDataId()); + beanParams.add(bean.getDetailId()); + beanParams.add(bean.getResourceId()); + beanParams.add(bean.getFromDate()); + beanParams.add(bean.getFromTime()); + beanParams.add(bean.getToDate()); + beanParams.add(bean.getToTime()); + beanParams.add(bean.getDuration()); + beanParams.add(bean.getNewLeaveType()); + beanParams.add(bean.getDurationrule()); + beanParams.add(FREEZE); + params.add(beanParams); + + List delParam = new ArrayList(); + delParam.add(bean.getRequestId()); + delparams.add(delParam); + } + if(!params.isEmpty()){ + boolean delOk = rs.executeBatchSql(delSql, delparams); + if(!delOk){ + retmap.put("status", "-1"); + retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(1232,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""+params); + return; + } + + boolean isOk = rs.executeBatchSql(batchSql, params); + if(!isOk){ + retmap.put("status", "-1"); + retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(1232,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""+params); + } + } + } + + /** + * 判断请假时长是不是大于剩余时长,大于就无法支持提交 + * @param resourceId + * @param changerequestid + * @param retmap + * @param date + * @param leaveDays + * @param workflowid + * @param nodeid + */ + public void canLeaveFlowProcessChange(String resourceId, String changerequestid, Map retmap, + String date, String leaveDays, int workflowid, int nodeid, String leaveFlowLeaveDays, String attid) { + Map params = new HashMap<>(); + RecordSet rs = new RecordSet(); + params.put("resourceId", resourceId); + params.put("requestid", changerequestid); + params.put("isAll", "1"); + String balanceOfLeave = ""; + //正式系统需要的 + String isFormal = Util.null2String(new BaseBean().getPropValue("kq_flow_formal", "isFormal"),"0"); + GetProcessChangeTypeCmd processChangeTypeCmd = new GetProcessChangeTypeCmd(params, new User(1)); + Map retmaps = processChangeTypeCmd.execute(null); + if (!retmaps.isEmpty()) { + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + boolean allow_negative_flag = "1".equals(Util.null2String(kqSettingsComInfo.getMain_val("allow_negative"),"0")); + String newLeaveType = Util.null2String(retmaps.get("newleaveType")); + String durationrule = Util.null2String(retmaps.get("durationrule")); + if (!"".equals(newLeaveType)) { +// // 变更请假流程的话,需要绑定冻结和释放 +// List actions = new ArrayList<>(); +// String actionSql = "select * from kq_att_proc_action where field001= ? "; +// rs.executeQuery(actionSql, attid); +// while(rs.next()){ +// String actionname = Util.null2String(rs.getString("field002")); +// actions.add(actionname); +// } +// if(!actions.contains("KqFreezeVacationAction") || !actions.contains("KqReleaseVacationAction")) { +// retmap.put("status", "-1"); +// retmap.put("message", SystemEnv.getHtmlLabelName(547115, user.getLanguage())); +// new KQLog().info("CheckProcessLeaveCmd:::::考勤变更流程要变更请假,必须绑定冻结和释放action:" + retmap); +// return; +// } + + //带薪假存在不同释放规则,这里需要单独根据请假类型+日期 处理不同有效期和释放规则的请假 + Map balanceMap = new HashMap<>(); + //记录每一个类型的 带薪假余额的汇总list + Map> allbalanceMap = new HashMap<>(); + //相同请假类型的 请假时长总和记录下 + Map durationMap = new HashMap<>(); + boolean balanceEnable = KQLeaveRulesBiz.getBalanceEnable(newLeaveType); + if (balanceEnable) { + if ("1".equalsIgnoreCase(isFormal)) { + balanceOfLeave = KQBalanceOfLeaveBiz.getRestAmount(resourceId, newLeaveType, DateUtil.getCurrentDate()); + } else { + balanceOfLeave = KQBalanceOfLeaveBiz.getRestAmount(resourceId, newLeaveType, date); + } + balanceOfLeave = ""+(Util.getDoubleValue(balanceOfLeave, 0.0)+Util.getDoubleValue(leaveFlowLeaveDays, 0.0)); + if (balanceMap.containsKey(newLeaveType)) { + //如果请假类型相同,记录下最大的那个假期余额 + String curBalance = balanceMap.get(newLeaveType); + if (Util.getDoubleValue(balanceOfLeave, 0.0) > Util.getDoubleValue(curBalance, 0.0)) { + balanceMap.put(newLeaveType, balanceOfLeave); + } + String curleaveDays = durationMap.get(newLeaveType); + durationMap.put(newLeaveType, Util.null2String( + Util.getDoubleValue(curleaveDays, 0.0) + Util.getDoubleValue(leaveDays, 0.0))); + + List allbalanceList = allbalanceMap.get(newLeaveType); + allbalanceList.add(balanceOfLeave); + } else { + balanceMap.put(newLeaveType, balanceOfLeave); + durationMap.put(newLeaveType, leaveDays); + + List allbalanceList = new ArrayList<>(); + allbalanceList.add(balanceOfLeave); + allbalanceMap.put(newLeaveType, allbalanceList); + } + double balanceOfLeaveDays = Util.getDoubleValue(balanceOfLeave); + if (true) { + double d_duration = AttendanceUtil.getFreezeDuration(newLeaveType, resourceId,date,date); + if (d_duration > 0) { + //以防止出现精度问题 + BigDecimal p1 = new BigDecimal(Double.toString(balanceOfLeaveDays)); + BigDecimal p2 = new BigDecimal(Double.toString(d_duration)); + //考虑下冻结的数据 + String tmp_balanceOfLeaveDays = p1.subtract(p2).toString(); + balanceOfLeaveDays = Util.getDoubleValue(tmp_balanceOfLeaveDays); + } + } + double leaveDays_Double = Util.getDoubleValue(leaveDays); + if (!allow_negative_flag && balanceOfLeaveDays <= 0) { + //可请 带薪假时长为0 不能提交 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(390298, user.getLanguage())); + new KQLog().info("CheckProcessLeaveCmd:::::带薪假时长为0 不能提交:" + retmap); + return; + } + if (!allow_negative_flag && leaveDays_Double > balanceOfLeaveDays) { + //请假天数大于带薪假时长 不能提交 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(390299, user.getLanguage())); + new KQLog().info("CheckProcessLeaveCmd:::::请假天数大于带薪假时长 不能提交:" + retmap); + return; + } + } + if (!balanceMap.isEmpty()) { + for (Map.Entry me : balanceMap.entrySet()) { + String key = me.getKey(); + double max_balance = Util.getDoubleValue(me.getValue(), 0.0); + double totalLeavedays = Util.getDoubleValue(durationMap.get(key), 0.0); + if (!allow_negative_flag && totalLeavedays > max_balance) { + //请假天数大于带薪假时长 不能提交 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(390299, user.getLanguage())); + new KQLog().info("CheckProcessLeaveCmd:::::请假天数大于带薪假时长 不能提交:" + retmap); + return; + } + if (true) { + double d_duration = AttendanceUtil.getFreezeDuration(key, resourceId,date,date); + if (d_duration > 0) { + List allbalanceList = allbalanceMap.get(key); + for (String tmp : allbalanceList) { + //以防止出现精度问题 + BigDecimal p1 = new BigDecimal(tmp); + BigDecimal p2 = new BigDecimal(Double.toString(d_duration)); + //考虑下冻结的数据 + String tmp_balanceOfLeaveDays = p1.subtract(p2).toString(); + double tmp_max_balance = Util.getDoubleValue(tmp_balanceOfLeaveDays); + if (!allow_negative_flag && totalLeavedays > tmp_max_balance) { + //请假天数大于带薪假时长 不能提交 + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(390299, user.getLanguage())); + new KQLog().info("CheckProcessLeaveCmd:::::请假天数大于带薪假时长 不能提交:" + retmap); + return; + } + } + } + } + } + } + retmap.put("newLeaveType", newLeaveType); + retmap.put("durationrule", durationrule); + } + } + } + + public static boolean canProcessChange(String resourceId, String changerequestid, + String attendancefromDate, String attendancefromTime, String attendancetoDate, + String attendancetoTime) { + + Map params = new HashMap<>(); + params.put("resourceId", resourceId); + params.put("requestid", changerequestid); + params.put("isAll", "1"); + GetProcessChangeTypeCmd processChangeTypeCmd = new GetProcessChangeTypeCmd(params, new User(1)); + Map retmaps = processChangeTypeCmd.execute(null); + if(!retmaps.isEmpty()) { + if (retmaps.containsKey("process_type") && retmaps.containsKey("process_tablename")) { + int process_type = Util.getIntValue(Util.null2String(retmaps.get("process_type"))); + String sql = ""; + if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == process_type){ + sql = "select * from "+KqSplitFlowTypeEnum.EVECTION.getTablename()+" where status='1' and requestid=? and resourceid=? " + + " and fromdatedb=? and fromtimedb=? and todatedb=? and totimedb=? "; + }else if(KqSplitFlowTypeEnum.OUT.getFlowtype() == process_type){ + sql = "select * from "+KqSplitFlowTypeEnum.OUT.getTablename()+" where status='1' and requestid=? and resourceid=? " + + " and fromdatedb=? and fromtimedb=? and todatedb=? and totimedb=? "; + }else if(KqSplitFlowTypeEnum.LEAVE.getFlowtype() == process_type){ + sql = "select * from "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" where status='1' and requestid=? and resourceid=? " + + " and fromdatedb=? and fromtimedb=? and todatedb=? and totimedb=? "; + } + RecordSet rs = new RecordSet(); + if(sql.length() > 0){ + rs.executeQuery(sql, changerequestid,resourceId,attendancefromDate,attendancefromTime,attendancetoDate,attendancetoTime); + if(rs.next()){ + return false; + } + } + if(KqSplitFlowTypeEnum.LEAVE.getFlowtype() == process_type){ + // 变更不能变更已经销假过的请假流程 + sql = "select leavebackrequestid from "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" where status='0' and requestid=? and resourceid=?"; + rs.executeQuery(sql, changerequestid,resourceId); + if(rs.next()){ + String leavebackrequestid = Util.null2String(rs.getString("leavebackrequestid")); + if(!"".equals(leavebackrequestid)) { + return false; + } + } + } + } + } + return true; + } + /** + * 拆分销假流程数据 生成数据到splitBeans和backsplitBeans + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public Map handleKQProcessChangeAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + return kqFlowActiontBiz.handleAction(sqlMap,splitBeans, datetimeFormatter, workflowId,requestId, rci,DurationTypeEnum.PROCESSCHANGE); + } + + public static void bean4ProcessChange(String prefix, RecordSet rs1, SplitBean splitBean) { + String resourceId = Util.null2s(rs1.getString("resourceId"), ""); + String changerequestid = Util.null2s(rs1.getString("changerequestid"), ""); + String changetype = Util.null2s(rs1.getString("changetype"), ""); + + String detail_attendancefromDate = Util.null2s(rs1.getString("detail_attendancefromDate"), ""); + String detail_attendancefromTime = Util.null2s(rs1.getString("detail_attendancefromTime"), ""); + String detail_attendancetoDate = Util.null2s(rs1.getString("detail_attendancetoDate"), ""); + String detail_attendancetoTime = Util.null2s(rs1.getString("detail_attendancetoTime"), ""); + String detail_attendanceduration = Util.null2s(rs1.getString("detail_attendanceduration"), ""); + ProcessChangeSplitBean processChangeSplitBean = new ProcessChangeSplitBean(); + processChangeSplitBean.setFromdatedb(detail_attendancefromDate); + processChangeSplitBean.setFromtimedb(detail_attendancefromTime); + processChangeSplitBean.setTodatedb(detail_attendancetoDate); + processChangeSplitBean.setTotimedb(detail_attendancetoTime); + processChangeSplitBean.setDurationDB(detail_attendanceduration); + processChangeSplitBean.setProcessType(changetype); + splitBean.setProcessChangeSplitBean(processChangeSplitBean); + + splitBean.setLeavebackrequestid(changerequestid); + Map params = new HashMap<>(); + params.put("resourceId", resourceId); + params.put("requestid", changerequestid); + params.put("isAll", "1"); + GetProcessChangeTypeCmd processChangeTypeCmd = new GetProcessChangeTypeCmd(params, new User(1)); + Map retmaps = processChangeTypeCmd.execute(null); + if(!retmaps.isEmpty()) { + String edit_duration = Util.null2s(rs1.getString(prefix+"edit_duration"), ""); + splitBean.setNewLeaveType(Util.null2String(retmaps.get("newleaveType"))); + splitBean.setDurationrule(Util.null2String(retmaps.get("durationrule"))); + if (retmaps.containsKey("process_type") && retmaps.containsKey("process_tablename")) { + int process_type = Util.getIntValue(Util.null2String(retmaps.get("process_type"))); + if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == process_type){ + String minimumUnit = Util.null2s(Util.null2String(KQTravelRulesBiz.getMinimumUnit()),"-1"); + String computingMode = Util.null2s(Util.null2String(KQTravelRulesBiz.getComputingMode()),"-1"); + splitBean.setDurationrule(minimumUnit); + splitBean.setComputingMode(computingMode); + splitBean.setDurationTypeEnum(DurationTypeEnum.EVECTION); + splitBean.setEdit_duration(edit_duration); + }else if(KqSplitFlowTypeEnum.OUT.getFlowtype() == process_type){ + String minimumUnit = Util.null2s(Util.null2String(KQExitRulesBiz.getMinimumUnit()),"-1"); + String computingMode = Util.null2s(Util.null2String(KQExitRulesBiz.getComputingMode()),"-1"); + splitBean.setDurationrule(minimumUnit); + splitBean.setComputingMode(computingMode); + splitBean.setDurationTypeEnum(DurationTypeEnum.OUT); + splitBean.setEdit_duration(edit_duration); + }else if(KqSplitFlowTypeEnum.LEAVE.getFlowtype() == process_type){ + String newLeaveType = Util.null2String(retmaps.get("newleaveType")); + String minimumUnit = Util.null2s(Util.null2String(KQLeaveRulesBiz.getMinimumUnit(newLeaveType)),"-1"); + String computingMode = Util.null2s(Util.null2String(KQLeaveRulesBiz.getComputingMode(newLeaveType)),"-1"); + + splitBean.setNewLeaveType(newLeaveType); + splitBean.setDurationrule(minimumUnit); + splitBean.setComputingMode(computingMode); + if("2".equalsIgnoreCase(computingMode)){ + //只有自然日 请假才有这个排除节假日、休息日的功能 + splitBean.setFilterholidays(KQLeaveRulesBiz.getFilterHolidays(newLeaveType)); + } + if(newLeaveType.length() > 0){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String conversion = kqLeaveRulesComInfo.getConversion(newLeaveType); + splitBean.setConversion(conversion); + String repeatTime = kqLeaveRulesComInfo.getRepeatTime(newLeaveType); + splitBean.setRepeatTime(repeatTime); + splitBean.setEdit_duration(edit_duration); + } + } + } + } + } + + /** + * 考勤变更流程拆分表处理 + * @param splitBeans + * @param result + * @param isUpgrade + * @param requestId + * @throws Exception + */ + public void handleSplitFLowActionData4ProcessChange( + List splitBeans, Map result, boolean isUpgrade, int requestId) throws Exception{ + + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + RecordSet rs2 = new RecordSet(); + + //是否是撤销 + boolean isDrawBack = false; + List formateList = new ArrayList<>(); + List params = new ArrayList(); + List before_updateSql = new ArrayList<>(); + List updateSql = new ArrayList<>(); + String change_tablename = ""; + //变更前的流程区间也需要格式化考勤报表的 + List process_dates = new ArrayList<>(); + boolean isLeave = false; + + String changedrequestid = ""; + for(SplitBean bean : splitBeans){ + //被变更流程 + changedrequestid = bean.getLeavebackrequestid(); + ProcessChangeSplitBean processChangeSplitBean = bean.getProcessChangeSplitBean(); + String process_fromdatedb = processChangeSplitBean.getFromdatedb(); + String process_fromtimedb = processChangeSplitBean.getFromtimedb(); + String process_todatedb = processChangeSplitBean.getTodatedb(); + String process_totimedb = processChangeSplitBean.getTotimedb(); + String process_durationdb = processChangeSplitBean.getDurationDB(); + String processType = processChangeSplitBean.getProcessType(); + String process_key = bean.getResourceId()+"_"+process_fromdatedb+"_"+process_todatedb; + if(!process_dates.contains(process_key)){ + process_dates.add(process_key); + } + if("1".equalsIgnoreCase(processType)){ + isDrawBack = true; + } + if(bean.getDurationTypeEnum() == DurationTypeEnum.EVECTION){ + change_tablename = KqSplitFlowTypeEnum.EVECTION.getTablename(); + }else if(bean.getDurationTypeEnum() == DurationTypeEnum.OUT){ + change_tablename = KqSplitFlowTypeEnum.OUT.getTablename(); + }else if(bean.getDurationTypeEnum() == DurationTypeEnum.PROCESSCHANGE){ + if(!"".equals(bean.getNewLeaveType())) { + change_tablename = KqSplitFlowTypeEnum.LEAVE.getTablename(); + isLeave = true; + } + } + if(!isDrawBack){ + getProcessChangeParams(bean,params,formateList,updateSql,change_tablename); + } + + String updateLeaveSql = ""; + String before_updateLeaveSql = ""; + if(rs1.getDBType().equalsIgnoreCase("oracle")) { + before_updateLeaveSql = "update "+ change_tablename+" set leavebackrequestid='',status='0' where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId()+" and fromdatedb='"+process_fromdatedb+"' " + +" and fromtimedb='"+process_fromtimedb+"'"+" and todatedb='"+process_todatedb+"'"+" and totimedb='"+process_totimedb+"'"; + updateLeaveSql = "update "+ change_tablename+" set leavebackrequestid=nvl(leavebackrequestid,'')||','||"+bean.getRequestId()+",status='1' where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId()+" and fromdatedb='"+process_fromdatedb+"' " + +" and fromtimedb='"+process_fromtimedb+"'"+" and todatedb='"+process_todatedb+"'"+" and totimedb='"+process_totimedb+"'"; + } + else if(rs1.getDBType().equalsIgnoreCase("postgresql")) { + before_updateLeaveSql = "update "+ change_tablename+" set leavebackrequestid='',status='0' where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId()+" and fromdatedb='"+process_fromdatedb+"' " + +" and fromtimedb='"+process_fromtimedb+"'"+" and todatedb='"+process_todatedb+"'"+" and totimedb='"+process_totimedb+"'"; + updateLeaveSql = "update "+ change_tablename+" set leavebackrequestid=isnull(leavebackrequestid,'')||','||"+bean.getRequestId()+",status='1' where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId()+" and fromdatedb='"+process_fromdatedb+"' " + +" and fromtimedb='"+process_fromtimedb+"'"+" and todatedb='"+process_todatedb+"'"+" and totimedb='"+process_totimedb+"'"; + } + else if((rs1.getDBType()).equalsIgnoreCase("mysql")){ + before_updateLeaveSql = "update "+ change_tablename+" set leavebackrequestid='',status='0' where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId()+" and fromdatedb='"+process_fromdatedb+"' " + +" and fromtimedb='"+process_fromtimedb+"'"+" and todatedb='"+process_todatedb+"'"+" and totimedb='"+process_totimedb+"'"; + updateLeaveSql = "update "+ change_tablename+" set leavebackrequestid=concat(ifnull(leavebackrequestid,''),',',"+bean.getRequestId()+"),status='1' where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId()+" and fromdatedb='"+process_fromdatedb+"' " + +" and fromtimedb='"+process_fromtimedb+"'"+" and todatedb='"+process_todatedb+"'"+" and totimedb='"+process_totimedb+"'"; + }else { + before_updateLeaveSql = "update "+ change_tablename+" set leavebackrequestid='',status='0' where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId()+" and fromdatedb='"+process_fromdatedb+"' " + +" and fromtimedb='"+process_fromtimedb+"'"+" and todatedb='"+process_todatedb+"'"+" and totimedb='"+process_totimedb+"'"; + updateLeaveSql = "update "+ change_tablename+" set leavebackrequestid=isnull(leavebackrequestid,'')+',"+bean.getRequestId()+"'"+",status='1' where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId()+" and fromdatedb='"+process_fromdatedb+"' " + +" and fromtimedb='"+process_fromtimedb+"'"+" and todatedb='"+process_todatedb+"'"+" and totimedb='"+process_totimedb+"'"; + } + if(isLeave) { + before_updateLeaveSql = "update "+ change_tablename+" set status='1', leavebackrequestid='"+bean.getRequestId()+"' where " + + " requestid="+bean.getLeavebackrequestid()+" and resourceid="+bean.getResourceId()+" and fromdatedb='"+process_fromdatedb+"' " + +" and fromtimedb='"+process_fromtimedb+"'"+" and todatedb='"+process_todatedb+"'"+" and totimedb='"+process_totimedb+"'"; + updateLeaveSql = ""; + } + if(!updateSql.contains(updateLeaveSql) && !"".equals(updateLeaveSql)){ + updateSql.add(updateLeaveSql); + } + if(!before_updateSql.contains(before_updateLeaveSql)){ + before_updateSql.add(before_updateLeaveSql); + } + } + if(change_tablename.length() > 0){ + boolean isOk = true; + if(!isDrawBack && !params.isEmpty()){ + //先根据requestid删除中间表里的数据,再做啥插入操作 + if(isLeave) { + String delSql = "update "+change_tablename+" set status='1' where requestid = "+requestId; + rs2.executeUpdate(delSql); + } else { + String delSql = "delete from "+change_tablename+" where requestid = "+requestId; + rs2.executeUpdate(delSql); + } + String backbatchSql = "insert into "+change_tablename+" (subcompanyid,departmentid,jobtitle,requestid,workflowid,usedetail,dataid,detailid,resourceid,fromdate,fromtime,todate,totime,newleavetype,durationdb,duration,durationrule,status,belongDate,D_Mins,serialid,tablenamedb,fromdatedb,fromtimedb,todatedb,totimedb,leavebackrequestid,changeType)"+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + isOk = rs1.executeBatchSql(backbatchSql, params); + } + if(isOk){ + boolean isUpOk = false; + for(String before_up_sql : before_updateSql){ + kqLog.info("考勤变更流程 重复归档流程记录sql handleSplitFLowActionData4ProcessChange before_up_sql:"+before_up_sql); + isUpOk = rs.executeUpdate(before_up_sql); + kqLog.info("考勤变更流程 重复归档流程记录执行情况 handleSplitFLowActionData4ProcessChange isUpOk:"+isUpOk); + } + if(isUpOk){ + for(String up_sql : updateSql){ + kqLog.info("考勤变更流程 记录sql handleSplitFLowActionData4ProcessChange up_sql:"+up_sql); + isUpOk = rs.executeUpdate(up_sql); + kqLog.info("考勤变更流程 记录执行情况 handleSplitFLowActionData4ProcessChange isUpOk:"+isUpOk); + } + } + if(changedrequestid.length() > 0){ + handle_flow_deduct_card(changedrequestid,change_tablename); + } + if(isLeave) { + //根据销假数据回填带薪数据 + KQFlowLeaveBackUtil.reBuildChangeBalance(splitBeans); + if(!isDrawBack) { // 如果不是撤销,那么就要扣减余额 + SplitActionUtil.handleLeaveAction(splitBeans, ""+requestId); + } + } + kqLog.info("handleSplitFLowActionData4ProcessChange:formateList:"+formateList); + for(String format: formateList){ + String[] formats = format.split("_"); + kqLog.info("handleSplitFLowActionData4ProcessChange:formats:"+ JSON.toJSONString(formats)); + new KQFormatData().formatKqDateByLock(formats[0],formats[1],17); + } + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + for(String dates : process_dates){ + String[] datesArr = dates.split("_"); + if(datesArr.length == 3){ + String resourceid = datesArr[0]; + String fromDate = datesArr[1]; + String toDate = datesArr[2]; + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate localToDate = LocalDate.parse(toDate); + LocalDate preFromDate = localFromDate.minusDays(1); + LocalDate nextToDate = localToDate.plusDays(1); + long betweenDays = nextToDate.toEpochDay() - preFromDate.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + LocalDate curLocalDate = preFromDate.plusDays(i); + String date = curLocalDate.format(dateFormatter); + kqLog.info("handleSplitFLowActionData4ProcessChange:formats changed:resourceid:"+ resourceid+":date:"+date); + new KQFormatData().formatKqDateByLock(resourceid,date,17); + } + } + } + }else{ + result.put("status", "-1"); + result.put("message", (""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005410,weaver.general.ThreadVarLanguage.getLang())+"requestId:"+requestId)); + kqLog.info("handleSplitFLowActionData4ProcessChange考勤变更流程保存失败:requestId:"+requestId); + return ; + } + }else{ + result.put("status", "-1"); + result.put("message", (""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005410,weaver.general.ThreadVarLanguage.getLang())+"requestId:"+requestId)); + kqLog.info("handleSplitFLowActionData4ProcessChange考勤变更流程保存失败:requestId:"+requestId); + return ; + } + } + + /** + * 出差变更完了之后被变更的流程如果之前开启了流程抵扣打卡也需要被变更掉 + * @param changedrequestid + * @param change_tablename + */ + public void handle_flow_deduct_card(String changedrequestid, String change_tablename) { + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String workflowid = ""; + String sql = "select * from workflow_requestbase where requestid=? "; + rs.executeQuery(sql,changedrequestid); + if(rs.next()){ + workflowid = rs.getString("workflowid"); + } + if(workflowid.length() > 0){ + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + String flow_deduct_card = Util.null2String(kqAttProcSetComInfo.getFlow_deduct_card(workflowid)); + String kqType = Util.null2String(kqAttProcSetComInfo.getkqType(workflowid)); + kqLog.info("KQFlowProcessChangeUtil handle_flow_deduct_card:flow_deduct_card:"+ flow_deduct_card+":workflowid:"+workflowid+":changedrequestid:"+changedrequestid); + sql = "select * from "+ change_tablename+" where 1=1 and (status is null or status<>1) and requestid=? "; + rs.executeQuery(sql,changedrequestid); + if("1".equalsIgnoreCase(flow_deduct_card)){ + String del_card_sql = "delete from kq_flow_deduct_card where requestid=? "; + boolean isDone = rs1.executeUpdate(del_card_sql,changedrequestid); + if(isDone){ + List splitBeans = new ArrayList<>(); + while (rs.next()){ + SplitBean splitBean = new SplitBean(); + splitBean.setResourceId(rs.getString("resourceid")); + splitBean.setBelongDate(rs.getString("belongdate")); + splitBean.setFromDate(rs.getString("fromdate")); + splitBean.setFromTime(rs.getString("fromtime")); + splitBean.setToDate(rs.getString("todate")); + splitBean.setToTime(rs.getString("totime")); + splitBeans.add(splitBean); + } + if(!splitBeans.isEmpty()){ + new KQFlowActiontBiz().do_flow_deduct_card(splitBeans, kqType, Util.getIntValue(changedrequestid)); + } + } + } + + } + } + + private void getProcessChangeParams(SplitBean bean, List params, + List formateList, List updateSql, String change_tablename) { + List beanParams = new ArrayList(); + beanParams.add(bean.getSubcompanyid()); + beanParams.add(bean.getDepartmentid()); + beanParams.add(bean.getJobtitle()); + beanParams.add(bean.getRequestId()); + beanParams.add(bean.getWorkflowId()); + beanParams.add(bean.getUsedetail()); + beanParams.add(bean.getDataId()); + beanParams.add(bean.getDetailId()); + beanParams.add(bean.getResourceId()); + beanParams.add(bean.getFromDate()); + beanParams.add(bean.getFromTime()); + beanParams.add(bean.getToDate()); + beanParams.add(bean.getToTime()); + beanParams.add(bean.getNewLeaveType()); + beanParams.add(bean.getDurationDB()); + beanParams.add(Util.null2s(bean.getDuration(),"0")); + beanParams.add(bean.getDurationrule()); + beanParams.add(bean.getStatus()); + beanParams.add(bean.getBelongDate()); + beanParams.add(bean.getD_Mins()); + beanParams.add(bean.getSerialid()); + beanParams.add(bean.getTablenamedb()); + beanParams.add(bean.getFromdatedb()); + beanParams.add(bean.getFromtimedb()); + beanParams.add(bean.getTodatedb()); + beanParams.add(bean.getTotimedb()); + if(!"".equals(bean.getNewLeaveType())) { + beanParams.add(bean.getLeavebackrequestid()); + } else { + beanParams.add(""); + } + if(bean.getDurationTypeEnum() == DurationTypeEnum.EVECTION){ + beanParams.add("1"); + }else if(bean.getDurationTypeEnum() == DurationTypeEnum.OUT){ + beanParams.add("2"); + }else{ + beanParams.add(""); + } + String format = bean.getResourceId()+"_"+bean.getBelongDate(); + formateList.add(format); + + params.add(beanParams); + } +} diff --git a/src/com/engine/kq/wfset/util/KQFlowShiftUtil.java b/src/com/engine/kq/wfset/util/KQFlowShiftUtil.java new file mode 100644 index 0000000..af645da --- /dev/null +++ b/src/com/engine/kq/wfset/util/KQFlowShiftUtil.java @@ -0,0 +1,232 @@ +package com.engine.kq.wfset.util; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQAttFlowFieldsSetBiz; +import com.engine.kq.biz.KQFormatData; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.biz.KQShiftscheduleBiz; +import com.engine.kq.entity.KQGroupEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQLockAttendaUtil; +import com.engine.kq.wfset.bean.SplitBean; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Map; + +public class KQFlowShiftUtil { + private KQLog kqLog = new KQLog(); + private String operatorId; + + public Map handleKQShiftAction2(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci, Map result, Map map) throws Exception{ + String operId = Util.null2String(map.get("operatorId")); + if(!"".equals(operId)) { + setOperatorId(operId); + } + handleKQShiftAction(sqlMap, splitBeans, datetimeFormatter, workflowId, requestId, rci, result); + return result; + } + + public void handleKQShiftAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci) throws Exception{ + handleKQShiftAction(sqlMap, splitBeans, datetimeFormatter, workflowId, requestId, rci, null); + } + + public Map handleKQShiftLockAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci, Map result, Map map) throws Exception{ + String operId = Util.null2String(map.get("operatorId")); + if(!"".equals(operId)) { + setOperatorId(operId); + } + KQShiftscheduleBiz kqShiftscheduleBiz = new KQShiftscheduleBiz(); + if(result != null) { + String createrId = getOperatorId(); + kqShiftscheduleBiz.setCreatorId(createrId); + } + ResourceComInfo resourceComInfo = new ResourceComInfo(); + RecordSet rs1 = new RecordSet(); + String detail_resourceId = ""; + String detail_fromDate = ""; + String detail_toDate = ""; + String detail_shift = ""; + String detail_group = ""; + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + String[] shiftFields = KQAttFlowFieldsSetBiz.shiftDetailFields; + kqLog.info("handleKQShiftAction: : sqlMap:"+sqlMap); + + if(!sqlMap.isEmpty()){ + + for(Map.Entry me : sqlMap.entrySet()){ + String concort = "###" ; + String key = me.getKey(); + String value = me.getValue(); + + String wfId = key.split(concort)[3] ; + int usedetail = Util.getIntValue(key.split(concort)[2], 0); + String tableDetailName= key.split(concort)[1] ; + String tableName= key.split(concort)[0] ; + String idVal = ""; + String id = "dataId"; + if(usedetail == 1){ + id = "detailId"; + } + rs1.execute(value); + while (rs1.next()) { + idVal = Util.null2s(rs1.getString(id), ""); + + String f_detail_resourceId = shiftFields[0]; + String f_detail_fromDate = shiftFields[1]; + String f_detail_toDate = shiftFields[2]; + String f_detail_shift = shiftFields[3]; + String f_detail_group = shiftFields[4]; + + detail_resourceId = Util.null2s(rs1.getString(f_detail_resourceId), ""); + detail_fromDate = Util.null2s(rs1.getString(f_detail_fromDate), ""); + detail_toDate = Util.null2s(rs1.getString(f_detail_toDate), ""); + detail_shift = Util.null2s(rs1.getString(f_detail_shift), ""); + detail_group = Util.null2s(rs1.getString(f_detail_group), ""); + if("".equals(detail_group)) { + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQGroupEntity kQGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(detail_resourceId,detail_fromDate,true); + if(kQGroupEntity == null){ + kqLog.info("handleKQShiftAction: kQGroupEntity is null : detail_resourceId:"+detail_resourceId+":detail_fromDate:"+detail_fromDate); + continue; + } + kqLog.info("handleKQShiftAction: kQGroupEntity : kQGroupEntity:"+ JSON.toJSON(kQGroupEntity)+":detail_resourceId:"+detail_resourceId + +":detail_fromDate:"+detail_fromDate+":detail_toDate:"+detail_toDate+":detail_shift:"+detail_shift); + + } + //排班流程 生成之后还需要格式化下对应人员下的考勤数据 + LocalDate fromLocal = LocalDate.parse(detail_fromDate); + LocalDate toLocal = LocalDate.parse(detail_toDate); + if(!toLocal.isBefore(fromLocal)){ + long betweenDays = toLocal.toEpochDay() - fromLocal.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + LocalDate curLocalDate = fromLocal.plusDays(i); + String shiftDate = curLocalDate.format(dateFormatter); + if (new KQLockAttendaUtil().checkLockStatus(detail_resourceId, shiftDate)) { + kqLog.info(""+resourceComInfo.getLastname(detail_resourceId)+"在"+shiftDate+"的考勤数据已被锁定,不能提交考勤流程!"); + result.put("status", "-1"); + result.put("message", resourceComInfo.getLastname(detail_resourceId)+ SystemEnv.getHtmlLabelName(18805,weaver.general.ThreadVarLanguage.getLang())+shiftDate+SystemEnv.getHtmlLabelName(547673,weaver.general.ThreadVarLanguage.getLang())); + } + + } + } + } + } + } + return result; + } + /** + * 拆分排班数据 + * @param sqlMap + * @param splitBeans + * @param datetimeFormatter + * @param workflowId + * @param requestId + * @param rci + * @return + * @throws Exception + */ + public void handleKQShiftAction(Map sqlMap, + List splitBeans, DateTimeFormatter datetimeFormatter, int workflowId, + int requestId, ResourceComInfo rci, Map result) throws Exception{ + + KQShiftscheduleBiz kqShiftscheduleBiz = new KQShiftscheduleBiz(); + if(result != null) { + String createrId = getOperatorId(); + kqShiftscheduleBiz.setCreatorId(createrId); + } + + RecordSet rs1 = new RecordSet(); + String detail_resourceId = ""; + String detail_fromDate = ""; + String detail_toDate = ""; + String detail_shift = ""; + String detail_group = ""; + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + String[] shiftFields = KQAttFlowFieldsSetBiz.shiftDetailFields; + kqLog.info("handleKQShiftAction: : sqlMap:"+sqlMap); + + if(!sqlMap.isEmpty()){ + KQFormatData kqFormatData = new KQFormatData(); + for(Map.Entry me : sqlMap.entrySet()){ + String concort = "###" ; + String key = me.getKey(); + String value = me.getValue(); + + String wfId = key.split(concort)[3] ; + int usedetail = Util.getIntValue(key.split(concort)[2], 0); + String tableDetailName= key.split(concort)[1] ; + String tableName= key.split(concort)[0] ; + String idVal = ""; + String id = "dataId"; + if(usedetail == 1){ + id = "detailId"; + } + rs1.execute(value); + while (rs1.next()) { + idVal = Util.null2s(rs1.getString(id), ""); + + String f_detail_resourceId = shiftFields[0]; + String f_detail_fromDate = shiftFields[1]; + String f_detail_toDate = shiftFields[2]; + String f_detail_shift = shiftFields[3]; + String f_detail_group = shiftFields[4]; + + detail_resourceId = Util.null2s(rs1.getString(f_detail_resourceId), ""); + detail_fromDate = Util.null2s(rs1.getString(f_detail_fromDate), ""); + detail_toDate = Util.null2s(rs1.getString(f_detail_toDate), ""); + detail_shift = Util.null2s(rs1.getString(f_detail_shift), ""); + detail_group = Util.null2s(rs1.getString(f_detail_group), ""); + if("".equals(detail_group)) { + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + KQGroupEntity kQGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(detail_resourceId,detail_fromDate,true); + if(kQGroupEntity == null){ + kqLog.info("handleKQShiftAction: kQGroupEntity is null : detail_resourceId:"+detail_resourceId+":detail_fromDate:"+detail_fromDate); + continue; + } + kqLog.info("handleKQShiftAction: kQGroupEntity : kQGroupEntity:"+ JSON.toJSON(kQGroupEntity)+":detail_resourceId:"+detail_resourceId + +":detail_fromDate:"+detail_fromDate+":detail_toDate:"+detail_toDate+":detail_shift:"+detail_shift); + detail_group = kQGroupEntity.getId(); + } + kqLog.info("handleKQShiftAction: : detail_resourceId:"+detail_resourceId+":detail_fromDate:"+detail_fromDate+":detail_toDate:"+detail_toDate+":detail_shift:"+detail_shift+":detail_group:"+detail_group); + + kqShiftscheduleBiz.saveShiftschedule(detail_resourceId, detail_fromDate, detail_toDate, detail_shift,detail_group,result); + + //排班流程 生成之后还需要格式化下对应人员下的考勤数据 + LocalDate fromLocal = LocalDate.parse(detail_fromDate); + LocalDate toLocal = LocalDate.parse(detail_toDate); + if(!toLocal.isBefore(fromLocal)){ + long betweenDays = toLocal.toEpochDay() - fromLocal.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + LocalDate curLocalDate = fromLocal.plusDays(i); + String shiftDate = curLocalDate.format(dateFormatter); + kqLog.info("handleKQShiftAction: formatDate : detail_resourceId:"+detail_resourceId+":shiftDate:"+shiftDate); + new KQFormatData().formatKqDateByLock(detail_resourceId, shiftDate,17); + } + } + } + } + } + } + + public String getOperatorId() { + return operatorId; + } + + public void setOperatorId(String operatorId) { + this.operatorId = operatorId; + } +} diff --git a/src/com/engine/kq/wfset/util/KQFlowUtil.java b/src/com/engine/kq/wfset/util/KQFlowUtil.java new file mode 100644 index 0000000..dca49ab --- /dev/null +++ b/src/com/engine/kq/wfset/util/KQFlowUtil.java @@ -0,0 +1,523 @@ +package com.engine.kq.wfset.util; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQExitRulesBiz; +import com.engine.kq.biz.KQFormatData; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQTravelRulesBiz; +import com.engine.kq.cmd.attendanceEvent.GetLeaveBackInfoCmd; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.apache.commons.collections.MapUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.workflow.workflow.WorkflowRequestComInfo; + +public class KQFlowUtil { + private KQLog kqLog = new KQLog(); + + /** + * 把通用的bean部分在这里进行填充 + * @param splitBean + * @param rs1 + * @param requestId + * @param rci + * @param workflowId + * @param durationTypeEnum + * @param key + * @param result + * @param datetimeFormatter + * @param uuid + */ + public boolean fillSplitBean(SplitBean splitBean, RecordSet rs1, String requestId, + ResourceComInfo rci, String workflowId, DurationTypeEnum durationTypeEnum, String key, + Map result, DateTimeFormatter datetimeFormatter, String uuid){ + + boolean isFillRight = true; + String concort = "###" ; + int usedetail = Util.getIntValue(key.split(concort)[2], 0); + String tableDetailName= key.split(concort)[1] ; + String tableName= key.split(concort)[0] ; + String prefix = ""; + String id = "dataId"; + if(usedetail == 1){ + prefix = "detail_"; + id = "detailId"; + } + + boolean isLeaveBack = false; + if(durationTypeEnum == DurationTypeEnum.LEAVEBACK){ + isLeaveBack = true; + } + boolean isProcessChange = false; + boolean isProcessDrawBack = false; + if(durationTypeEnum == DurationTypeEnum.PROCESSCHANGE){ + isProcessChange = true; + String changetype = Util.null2s(rs1.getString("changetype"), ""); + if("1".equalsIgnoreCase(changetype)){ + //如果是撤销的话,没有开始日期时间和结束日期时间 + isProcessDrawBack = true; + } + } + + String resourceId = ""; + //查询到的requestid + String requestId_rs = ""; + + String idVal = Util.null2s(rs1.getString(id), "0"); + String fromDate = Util.null2s(rs1.getString(prefix+"fromDate"), ""); + String toDate = Util.null2s(rs1.getString(prefix+"toDate"), ""); + String fromTime = Util.null2s(rs1.getString(prefix+"fromTime"), ""); + String toTime = Util.null2s(rs1.getString(prefix+"toTime"), ""); + String durationDB = Util.null2s(rs1.getString(prefix+"duration"), ""); + if(isLeaveBack || isProcessChange){ + resourceId = Util.null2s(rs1.getString("resourceId"), ""); + }else{ + resourceId = Util.null2s(rs1.getString(prefix+"resourceId"), ""); + } + if(Util.getIntValue(requestId,0) <= 0){ + requestId_rs = Util.null2s(rs1.getString("requestId"), "0"); + } + String repeatType = Util.null2s(rs1.getString(prefix+"repeat_type"), ""); + String newLeaveType1 = Util.null2s(rs1.getString(prefix+"newLeaveType"), ""); + + if(durationTypeEnum == DurationTypeEnum.LEAVE){ + Map repeatMap = resetTimeWhenRepeat(newLeaveType1,repeatType); + if(MapUtils.isNotEmpty(repeatMap) && repeatMap.containsKey("fromTime") && repeatMap.containsKey("toTime")){ + fromTime = Util.null2s(repeatMap.get("fromTime"),fromTime); + toTime = Util.null2s(repeatMap.get("toTime"),toTime); + } + } + + Map repeatTypeMap = Maps.newHashMap(); + if(isLeaveBack){ + isFillRight = KQFlowLeaveBackUtil.leaveBackCheck(rs1,datetimeFormatter,prefix,result,repeatTypeMap); + if(!isFillRight){ + return isFillRight; + } + } + if(MapUtils.isNotEmpty(repeatTypeMap)){ + fromTime = Util.null2String(repeatTypeMap.get("fromTime")); + toTime = Util.null2String(repeatTypeMap.get("toTime")); + } + + boolean isVal = checkActionValidate(result, fromDate, toDate, fromTime, toTime, datetimeFormatter); + if(isProcessDrawBack){ + result.clear(); + result.put("isProcessDrawBack", "1"); + isVal = true; + } + if(!isVal){ + isFillRight = false; + return isFillRight; + } + if(isProcessChange){ + isFillRight = KQFlowProcessChangeUtil.processChangeCheck(rs1 ,requestId_rs,result); + if(!isFillRight){ + return isFillRight; + } + } + + if(usedetail == 1){ + splitBean.setDataId("0"); + splitBean.setDetailId(idVal); + splitBean.setTablenamedb(tableDetailName); + }else{ + splitBean.setDataId(idVal); + splitBean.setDetailId("0"); + splitBean.setTablenamedb(tableName); + } + splitBean.setFromdatedb(fromDate); + splitBean.setFromtimedb(fromTime); + splitBean.setTodatedb(toDate); + splitBean.setTotimedb(toTime); + + if(requestId_rs.length() > 0){ + WorkflowRequestComInfo workflowRequestComInfo = new WorkflowRequestComInfo(); + splitBean.setRequestId(requestId_rs); + splitBean.setWorkflowId(workflowRequestComInfo.getWorkflowId(requestId_rs)); + }else{ + splitBean.setRequestId(requestId); + splitBean.setWorkflowId(workflowId); + } + splitBean.setUsedetail(""+usedetail); + splitBean.setResourceId(resourceId); + splitBean.setSubcompanyid(Util.null2s(rci.getSubCompanyID(resourceId),"0")); + splitBean.setDepartmentid(Util.null2s(rci.getDepartmentID(resourceId),"0")); + splitBean.setJobtitle(Util.null2s(rci.getJobTitle(resourceId),"0")); + splitBean.setFromDate(fromDate); + splitBean.setFromTime(fromTime); + splitBean.setToDate(toDate); + splitBean.setToTime(toTime); + splitBean.setDurationDB(durationDB); + //默认记录的状态都为0 + splitBean.setStatus("0"); + splitBean.setDurationTypeEnum(durationTypeEnum); + + switch (durationTypeEnum){ + case LEAVE: + KQFlowLeaveUtil.bean4Leave(prefix,rs1,splitBean); + break; + case EVECTION: + KQFlowEvectionUtil.bean4Evection(prefix,rs1,splitBean); + break; + case OUT: +// KQFlowOutUtil.bean4Out(splitBean); + KQFlowOutUtil.bean4Out(prefix,rs1,splitBean); + break; + case OVERTIME: + KQFlowOvertimeUtil.bean4Overtime(prefix,rs1,splitBean); + break; + case LEAVEBACK: + KQFlowLeaveBackUtil.bean4LeaveBack(prefix,rs1,splitBean); + break; + case OTHER: + bean4Other(prefix,rs1,splitBean); + break; + case PROCESSCHANGE: + KQFlowProcessChangeUtil.bean4ProcessChange(prefix,rs1,splitBean); + break; + default: + break; + } + String computingMode = splitBean.getComputingMode(); + String newLeaveType = splitBean.getNewLeaveType(); + if("2".equalsIgnoreCase(computingMode)){ + if(durationTypeEnum == DurationTypeEnum.PROCESSCHANGE){ + double oneDayHour = getOneDayHour(splitBean.getDurationTypeEnum(),newLeaveType); + splitBean.setOneDayHour(oneDayHour); + }else{ + double oneDayHour = getOneDayHour(durationTypeEnum,newLeaveType); + splitBean.setOneDayHour(oneDayHour); + } + } + return isFillRight; + + } + + /** + * 根据重复计算方式获取开始时间和结束时间 + * @param newLeaveType1 + * @param repeatType + * @return + */ + public Map resetTimeWhenRepeat(String newLeaveType1, String repeatType) { + Map repeatMap = Maps.newHashMap(); + String fromTime = ""; + String toTime = ""; + boolean is_half_select = false; + int minimumUnit = KQLeaveRulesBiz.getMinimumUnit(newLeaveType1); + int timeselection = KQLeaveRulesBiz.getTimeselection(newLeaveType1); + if(timeselection == 1){ + //下拉框 + if(minimumUnit == 2){ + is_half_select = true; + } + } + if("0".equals(repeatType) || "1".equals(repeatType) || "2".equals(repeatType)){ + fromTime = "00:00"; + toTime = "23:59"; + if(is_half_select){ + fromTime = SplitSelectSet.forenoon_start; + toTime = SplitSelectSet.afternoon_end; + } + } + if(fromTime.length() > 0 && toTime.length() > 0){ + repeatMap.put("fromTime",fromTime); + repeatMap.put("toTime",toTime); + } + return repeatMap; + } + + private void bean4Other(String prefix, RecordSet rs1, SplitBean splitBean) { + String minimumUnit = "1"; + String computingMode = "1"; + splitBean.setDurationrule(minimumUnit); + splitBean.setComputingMode(computingMode); + } + + + /** + * 获取按照自然日计算的时候,按天/半天计算的时候一天对应的小时数 + * @param durationTypeEnum + * @param newLeaveType + * @return + */ + public static double getOneDayHour(DurationTypeEnum durationTypeEnum,String newLeaveType){ + double oneDayHour = 0.0; + //TODO KQLeaveRulesBiz.getHoursToDay如果单位是小时的时候取不到日折算时长 + switch (durationTypeEnum){ + case LEAVE: + oneDayHour = Util.getDoubleValue(KQLeaveRulesBiz.getHoursToDay(newLeaveType), 0.0); + break; + case EVECTION: + oneDayHour = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay(), 0.0); + break; + case OUT: + oneDayHour = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay(), 0.0); + break; + case OVERTIME: + oneDayHour = KQOvertimeRulesBiz.getHoursToDay(); + break; + case LEAVEBACK: + oneDayHour = Util.getDoubleValue(KQLeaveRulesBiz.getHoursToDay(newLeaveType), 0.0); + break; + default: + } + return oneDayHour; + } + + public boolean checkActionValidate(Map result,String fromDate,String toDate,String fromTime,String toTime, DateTimeFormatter datetimeFormatter){ + + boolean isVal = true; + + if(Util.null2String(fromDate,"").length() == 0 || + Util.null2String(toDate,"").length() == 0 || + Util.null2String(fromTime,"").length() == 0 || + Util.null2String(toTime,"").length() == 0){ + result.put("status", "-1"); + result.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005411,weaver.general.ThreadVarLanguage.getLang())+""); + isVal = false; + return isVal; + } + if((fromDate+" "+fromTime).length() != 16 || (toDate+" "+toTime).length() != 16){ + result.put("status", "-1"); + result.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005412,weaver.general.ThreadVarLanguage.getLang())+""+(fromDate+" "+fromTime)+":"+(toDate+" "+toTime)); + isVal = false; + return isVal; + } + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate localToDate = LocalDate.parse(toDate); + LocalDateTime localFromDateTime = LocalDateTime.parse(fromDate+" "+fromTime,datetimeFormatter); + LocalDateTime localToDateTime = LocalDateTime.parse(toDate+" "+toTime,datetimeFormatter); + + if(localFromDateTime.isAfter(localToDateTime)){ + result.put("status", "-1"); + result.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(511480,weaver.general.ThreadVarLanguage.getLang())+""); + isVal = false; + return isVal; + } + + if (localFromDate.isAfter(localToDate)) { + result.put("status", "-1"); + result.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005413,weaver.general.ThreadVarLanguage.getLang())+""); + isVal = false; + return isVal; + } + return isVal; + } + + + /** + * 插入数据到中间表 + * @param splitBeans + * @param flowTypeEnum + * @param rci + * @param result + * @param isForce + * @param requestId + * @param workflowId + * @param isUpgrade 是否是升级,升级的话不需要处理假期余额数据 + * @throws Exception + */ + public void handleSplitFLowActionData( + List splitBeans, KqSplitFlowTypeEnum flowTypeEnum, + ResourceComInfo rci, Map result, boolean isForce, int requestId, + int workflowId,boolean isUpgrade) throws Exception{ + + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + Map custome_map = Maps.newHashMap(); + List custome_field = Lists.newArrayList(); + if(flowTypeEnum == KqSplitFlowTypeEnum.OVERTIME){ + custome_field.add("overtime_type"); + } + if(flowTypeEnum == KqSplitFlowTypeEnum.LEAVE || flowTypeEnum == KqSplitFlowTypeEnum.LEAVEBACK){ + custome_field.add("repeat_type"); + custome_field.add("repeat_late"); + custome_field.add("repeat_early"); + } + + String batchSql = "insert into "+flowTypeEnum.getTablename()+" (" + + "requestid,workflowid,dataid,detailid,resourceid,fromdate,fromtime," + + "todate,totime,newleavetype,duration,usedetail,durationrule,tablenamedb,fromdatedb," + + "fromtimedb,todatedb,totimedb,durationdb,status,belongDate,D_Mins,serialid," + + "changeType,subcompanyid,departmentid,jobtitle,companion,iscompanion"+getCustomField(custome_field,"field",null, + custome_map)+")"+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?"+getCustomField(custome_field,"param",null, + custome_map)+") "; + List params = new ArrayList(); + + List formateList = new ArrayList<>(); + for(SplitBean bean : splitBeans){ + List beanParams = new ArrayList(); + beanParams.add(bean.getRequestId()); + beanParams.add(bean.getWorkflowId()); + beanParams.add(bean.getDataId()); + beanParams.add(bean.getDetailId()); + beanParams.add(bean.getResourceId()); + beanParams.add(bean.getFromDate()); + beanParams.add(bean.getFromTime()); + beanParams.add(bean.getToDate()); + beanParams.add(bean.getToTime()); + beanParams.add(bean.getNewLeaveType()); + beanParams.add(Util.null2s(bean.getDuration(),"0")); + beanParams.add(bean.getUsedetail()); + beanParams.add(bean.getDurationrule()); + beanParams.add(bean.getTablenamedb()); + beanParams.add(bean.getFromdatedb()); + beanParams.add(bean.getFromtimedb()); + beanParams.add(bean.getTodatedb()); + beanParams.add(bean.getTotimedb()); + beanParams.add(bean.getDurationDB()); + beanParams.add(bean.getStatus()); + beanParams.add(bean.getBelongDate()); + beanParams.add(bean.getD_Mins()); + beanParams.add(bean.getSerialid()); + beanParams.add(bean.getChangeType()); + beanParams.add(bean.getSubcompanyid()); + beanParams.add(bean.getDepartmentid()); + beanParams.add(bean.getJobtitle()); + beanParams.add(bean.getCompanion()); + beanParams.add(bean.getIscompanion()); + if(!custome_field.isEmpty()){ + if(flowTypeEnum == KqSplitFlowTypeEnum.OVERTIME){ + custome_map.put("overtime_type", bean.getOvertime_type()); + } + if(flowTypeEnum == KqSplitFlowTypeEnum.LEAVE || flowTypeEnum == KqSplitFlowTypeEnum.LEAVEBACK){ + custome_map.put("repeat_type", bean.getRepeatType()); + custome_map.put("repeat_late", Util.null2s(bean.getRepeatLate(),"0")); + custome_map.put("repeat_early", Util.null2s(bean.getRepeatEarly(),"0")); + } + getCustomField(custome_field, "value",beanParams,custome_map); + } + + String format = bean.getResourceId()+"_"+bean.getBelongDate(); + formateList.add(format); + + params.add(beanParams); + + if(flowTypeEnum == KqSplitFlowTypeEnum.EVECTION && false){ + //qc898997 已经改成根据每个人的班次来计算了,这里就屏蔽了 + KQFlowEvectionUtil kqFlowEvectionUtil = new KQFlowEvectionUtil(); + String companion = Util.null2s(bean.getCompanion(), ""); + if(companion.length() > 0){ + kqFlowEvectionUtil.splitEvectionCompanion(companion,bean,params,rci,formateList); + } + } + } + if(!params.isEmpty()){ + //先根据requestid删除中间表里的数据,再做啥插入操作 + String delSql = "delete from "+flowTypeEnum.getTablename()+" where requestid = "+requestId; + rs.executeUpdate(delSql); + + for(int i = 0 ; i < params.size() ; i++){ + List beanParams = params.get(i); + boolean isOk = rs1.executeUpdate(batchSql, beanParams); + if(!isOk){ + delSql = "delete from "+flowTypeEnum.getTablename()+" where requestid = "+requestId; + rs.executeUpdate(delSql); + result.put("status", "-1"); + result.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005408,weaver.general.ThreadVarLanguage.getLang())+":"+flowTypeEnum.getTablename()+""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005414,weaver.general.ThreadVarLanguage.getLang())+""); + kqLog.info("handleSplitFLowActionData:batchSql:"+batchSql); + kqLog.info("handleSplitFLowActionData:"+flowTypeEnum.getTablename()+"拆分保存失败:"+params); + kqLog.info("handleSplitFLowActionData:"+flowTypeEnum.getTablename()+":rs.getExceptionMsg():"+rs.getExceptionMsg()); + return ; + } + } + kqLog.info("handleSplitFLowActionData:formateList:"+formateList+":flowTypeEnum:"+flowTypeEnum); + for(String format: formateList){ + kqLog.info("handleSplitFLowActionData:format:"+ JSON.toJSONString(format)+":flowTypeEnum:"+flowTypeEnum); + String[] formats = format.split("_"); + if(!isUpgrade){ + //考勤设置升级的话 流程数据就不需要格式化考勤了 + new KQFormatData().formatKqDateByLock(formats[0],formats[1],17); + } + } + if(!isUpgrade){ + if(isForce){ + if(flowTypeEnum == KqSplitFlowTypeEnum.LEAVE){ + //先在这里执行扣减动作 + SplitActionUtil.handleLeaveAction(splitBeans,""+requestId); + //然后再把扣减的了数据更新下KQ_ATT_VACATION表 + String updateFreezeSql = "update KQ_ATT_VACATION set status=0 where requestId=? and workflowId = ? "; + boolean isUpdate = rs.executeUpdate(updateFreezeSql,requestId,""+workflowId); + if(!isUpdate){ + result.put("status", "-1"); + result.put("message", (""+weaver.systeminfo.SystemEnv.getHtmlLabelName(82823,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""+updateFreezeSql+"(0,"+requestId+","+workflowId+")")); + kqLog.info("扣减action保存失败:"+updateFreezeSql+"(0,"+requestId+","+workflowId+")"); + return ; + } + }else if(flowTypeEnum == KqSplitFlowTypeEnum.OVERTIME){ + // 强制归档,加班数据第一第二种规则都需要处理 + SplitActionUtil.handleOverTimeAction(splitBeans, ""+requestId,true, ""); + } + }else{ + if(flowTypeEnum == KqSplitFlowTypeEnum.OVERTIME){ + //正常归档的时候 单独针对加班规则的第一 第二种模式 生成加班数据 + SplitActionUtil.handleOverTimeActionMode2(splitBeans, ""+requestId); + } + } + }else{ + if(flowTypeEnum == KqSplitFlowTypeEnum.OVERTIME){ + if(!splitBeans.isEmpty()){ + for (SplitBean splitBean : splitBeans) { + String sql = "delete from kq_flow_overtime where requestid=? "; + rs.executeUpdate(sql, splitBean.getRequestId()); + } + } + SplitActionUtil.handleOverTimeActionMode2(splitBeans, ""+requestId); + } + } + }else{ + rs1.writeLog(flowTypeEnum.getTablename()+"生成的params是空:"); + return ; + } + } + + /** + * 考勤流程中间表针对某个流程扩展字段 + * @param custome_field + * @param key + * @param beanParams + * @param custome_map + * @return + */ + public String getCustomField(List custome_field, String key, List beanParams, + Map custome_map) { + String fieldValue = ""; + if(!custome_field.isEmpty()){ + for(int i = 0 ; i < custome_field.size() ; i++){ + String tmp_value = Util.null2String(custome_field.get(i)); + if(tmp_value.length() > 0){ + if("field".equalsIgnoreCase(key)){ + fieldValue += ","+tmp_value; + }else if("param".equalsIgnoreCase(key)){ + fieldValue += ",?"; + }else if("value".equalsIgnoreCase(key)){ + String value = custome_map.get(tmp_value); + if (tmp_value.equals("repeat_late") || tmp_value.equals("repeat_early")) { + beanParams.add(Float.parseFloat(value)); + } else { + beanParams.add(value); + } + } + } + } + } + return fieldValue; + } + +} diff --git a/src/com/engine/kq/wfset/util/KQSignUtil.java b/src/com/engine/kq/wfset/util/KQSignUtil.java new file mode 100644 index 0000000..1e8fc28 --- /dev/null +++ b/src/com/engine/kq/wfset/util/KQSignUtil.java @@ -0,0 +1,359 @@ +package com.engine.kq.wfset.util; + +import com.engine.kq.bean.KQHrmScheduleSign; +import com.engine.kq.biz.KQScheduleSignBiz; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import weaver.common.DateUtil; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.report.manager.HrmReportManager.SignType; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class KQSignUtil extends BaseBean { + public static KQLog kqLog = new KQLog(); + + private static DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + private static DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + private static DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + + /** + * 根据考勤范围生成要查询的考勤表 + * @param onSignSectionTime + * @param offSignSectionTime + * @return + */ + public static String buildSignSql(String onSignSectionTime, String offSignSectionTime) { + RecordSet rs = new RecordSet(); + StringBuffer sql = new StringBuffer(); + String signindate = onSignSectionTime.substring(0,10); + String signoutdate = offSignSectionTime.substring(0,10); + + if(rs.getDBType().equals("oracle")){ + sql.append(" signdate >='").append(signindate).append("' "); + sql.append(" and signdate <='").append(signoutdate).append("' "); + sql.append(" and signDate||' '||signTime>='").append(onSignSectionTime).append("' "); + sql.append(" AND signDate||' '||signTime<='").append(offSignSectionTime).append("' "); + } + else if(rs.getDBType().equals("postgresql")){ + sql.append(" signdate >='").append(signindate).append("' "); + sql.append(" and signdate <='").append(signoutdate).append("' "); + sql.append(" and signDate||' '||signTime>='").append(onSignSectionTime).append("' "); + sql.append(" AND signDate||' '||signTime<='").append(offSignSectionTime).append("' "); + } + else if(rs.getDBType().equals("mysql")){ + sql.append(" signdate >='").append(signindate).append("' "); + sql.append(" and signdate <='").append(signoutdate).append("' "); + sql.append(" and concat(signDate,' ',signTime)>='").append(onSignSectionTime).append("' "); + sql.append(" AND concat(signDate,' ',signTime)<='").append(offSignSectionTime).append("' "); + }else{ + sql.append(" signdate >='").append(signindate).append("' "); + sql.append(" and signdate <='").append(signoutdate).append("' "); + sql.append(" and signDate+' '+signTime>='").append(onSignSectionTime).append("' "); + sql.append(" AND signDate+' '+signTime<='").append(offSignSectionTime).append("' "); + } + return sql.toString(); + } + + /** + * + * @param resourceid 人员id + * @param curDate 查询日期 + * @param showCard 是否显示补卡数据 true表示显示,默认显示 + * @return + */ + public static List getSignInfo4MyAttendance(String resourceid,String curDate,boolean showCard){ + List signInfos = new ArrayList<>(); + Map todayLineMap = KQDurationCalculatorUtil.getWorkButton(resourceid, curDate,false); + if(todayLineMap.get("signTime") != null){ + List> todaySignTime = (List>)todayLineMap.get("signTime"); + if(todaySignTime != null && !todaySignTime.isEmpty()){ + getTodaySignInfo(todaySignTime,signInfos,resourceid,curDate,showCard); + }else{ + getNonWorkDaySignInfo(signInfos,resourceid,curDate,showCard); + } + }else{ + getNonWorkDaySignInfo(signInfos,resourceid,curDate,showCard); + } + return signInfos; + } + + /** + * 获取非工作时段的打卡记录 + * @param signInfos + * @param resourceid + * @param curDate + * @param showCard + */ + public static void getNonWorkDaySignInfo(List signInfos,String resourceid, String curDate, boolean showCard) { + String signDateTimeSql = ""; + String signInDateTime = curDate + " 00:00:00"; + String signOutDateTime = curDate + " 23:59:59"; + String buildSql = buildSignSql(signInDateTime, signOutDateTime); + kqLog.info("resourceid:"+resourceid+":curDate:"+curDate+":signInDateTime:"+signInDateTime+":signOutDateTime:"+signOutDateTime); + if(buildSql.length() > 0){ + signDateTimeSql += buildSql; + } + if(!showCard){ + RecordSet rs = new RecordSet(); + if(rs.getDBType().equalsIgnoreCase("oracle")) { + signDateTimeSql += " and nvl(signfrom,'') not like 'card%' "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + signDateTimeSql += " and ifnull(signfrom,'') not like 'card%' "; + }else { + signDateTimeSql += " and isnull(signfrom,'') not like 'card%' "; + } + } + KQScheduleSignBiz kqScheduleSignBiz = new KQScheduleSignBiz.KQScheduleSignParamBuilder().resourceidParam(resourceid). + signDateTimeSqlParam(signDateTimeSql).build(); + fillSignInfos(kqScheduleSignBiz, signInfos); + } + + /** + * 获取工作时段的打卡记录 + * @param todaySignTime + * @param signInfos + * @param resourceid + * @param curDate + * @param showCard + */ + public static void getTodaySignInfo(List> todaySignTime,List signInfos, String resourceid,String curDate,boolean showCard) { + + String signDateTimeSql = ""; + if(!showCard){ + RecordSet rs = new RecordSet(); + if(rs.getDBType().equalsIgnoreCase("oracle")) { + signDateTimeSql += " and nvl(signfrom,'') not like 'card%' "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + signDateTimeSql += " and ifnull(signfrom,'') not like 'card%' "; + }else { + signDateTimeSql += " and isnull(signfrom,'') not like 'card%' "; + } + } + + String yesterday = LocalDate.parse(curDate).minusDays(1).format(dateFormatter); + String nextday = LocalDate.parse(curDate).plusDays(1).format(dateFormatter); + for(int i = 0 ; i < todaySignTime.size() ; i++) { + Map todaySignMap = todaySignTime.get(i); + String bengintime = Util.null2s(todaySignMap.get("bengintime"),""); + String bengintime_across = Util.null2s(todaySignMap.get("bengintime_across"),""); + String bengintime_end = Util.null2s(todaySignMap.get("bengintime_end"),""); + String bengintime_end_across = Util.null2s(todaySignMap.get("bengintime_end_across"),""); + + String endtime = Util.null2s(todaySignMap.get("endtime"),""); + String endtime_across = Util.null2s(todaySignMap.get("endtime_across"),""); + String endtime_start = Util.null2s(todaySignMap.get("endtime_start"),""); + String endtime_start_across = Util.null2s(todaySignMap.get("endtime_start_across"),""); + + String signInDateTime = curDate + " " +bengintime+":00"; + if("1".equalsIgnoreCase(bengintime_across)) { + signInDateTime = yesterday + " " +bengintime+":00"; + } + String signInEndDateTime = ""; + if(bengintime_end.length() > 0){ + signInEndDateTime = curDate + " " +bengintime_end+":00"; + if("1".equalsIgnoreCase(bengintime_end_across)) { + signInEndDateTime = nextday + " " +bengintime_end+":00"; + } + } + String signOutDateTime = curDate + " " +endtime+":59"; + if("1".equalsIgnoreCase(endtime_across)) { + signOutDateTime = nextday + " " +endtime+":59"; + } + String signOutBeginDateTime = ""; + if(endtime_start.length() > 0){ + signOutBeginDateTime = curDate + " " +endtime_start+":59"; + if("1".equalsIgnoreCase(endtime_start_across)) { + signOutBeginDateTime = nextday + " " +endtime_start+":59"; + } + } + + String sign_signSectionTime = ""; + String sign_signSectionEndTime = ""; + String sign_signSectionBeginTime = ""; + String sign_offSignSectionTime = ""; + if(signInEndDateTime.length() == 0 && signOutBeginDateTime.length() == 0){ + //如果没设置上班后,下班前打卡 + sign_signSectionTime = signInDateTime; + sign_offSignSectionTime = signOutDateTime; + }else{ + if(signInEndDateTime.length() > 0){ + if(signOutBeginDateTime.length() > 0){ + //如果上班后,下班前打卡范围都做了控制 + sign_signSectionTime = signInDateTime; + sign_signSectionEndTime = signInEndDateTime; + sign_signSectionBeginTime = signOutBeginDateTime; + sign_offSignSectionTime = signOutDateTime; + + }else{ + LocalDateTime onLocalDateEndTime = LocalDateTime.parse(signInEndDateTime,fullFormatter); + //如果只是上班后打卡范围做了控制 + LocalDateTime tmp = LocalDateTime.parse(onLocalDateEndTime.plusMinutes(1).format(datetimeFormatter)+":00",fullFormatter); + String tmp_datetime = tmp.format(fullFormatter); + sign_signSectionTime = signInDateTime; + sign_signSectionEndTime = signInEndDateTime; + sign_signSectionBeginTime = tmp_datetime; + sign_offSignSectionTime = signOutDateTime; + + } + }else if(signOutBeginDateTime.length() > 0){ + //如果只是下班前打卡范围做了控制 + LocalDateTime offLocalDateBeginTime = LocalDateTime.parse(signOutBeginDateTime,fullFormatter); + LocalDateTime tmp = LocalDateTime.parse(offLocalDateBeginTime.minusMinutes(1).format(datetimeFormatter)+":59",fullFormatter); + String tmp_datetime = tmp.format(fullFormatter); + sign_signSectionTime = signInDateTime; + sign_signSectionEndTime = tmp_datetime; + sign_signSectionBeginTime = signOutBeginDateTime; + sign_offSignSectionTime = signOutDateTime; + } + } + + KQScheduleSignBiz kqScheduleSignBiz = new KQScheduleSignBiz.KQScheduleSignParamBuilder().resourceidParam(resourceid) + .signSectionTimeParam(sign_signSectionTime).signSectionEndTimeParam(sign_signSectionEndTime) + .signSectionBeginTimeParam(sign_signSectionBeginTime).offSignSectionTimeParam(sign_offSignSectionTime). + signDateTimeSqlParam(signDateTimeSql).build(); + fillSignInfos(kqScheduleSignBiz, signInfos); + } + } + + public static void fillSignInfos(KQScheduleSignBiz kqScheduleSignBiz,List signInfos){ + + Map signMap = kqScheduleSignBiz.getScheduleSignInfoWithCardRange(); + if(signMap != null && !signMap.isEmpty()) { + Map signInfo = new HashMap<>(); + KQHrmScheduleSign signInTimeBean = signMap.get("signin"); + KQHrmScheduleSign signOutTimeBean = signMap.get("signout"); + if(signInTimeBean != null){ + String signdate = Util.null2String(signInTimeBean.getSigndate()); + String signtime= Util.null2String(signInTimeBean.getSigntime()); + String clientaddress = Util.null2String(signInTimeBean.getClientaddress()); + String addr = Util.null2String(signInTimeBean.getAddr()); + signInfo.put("on_signdate", signdate); + signInfo.put("on_signtime", signtime); + signInfo.put("on_clientaddress", clientaddress); + signInfo.put("on_position", addr); + } + if(signOutTimeBean != null){ + String signdate = Util.null2String(signOutTimeBean.getSigndate()); + String signtime= Util.null2String(signOutTimeBean.getSigntime()); + String clientaddress = Util.null2String(signOutTimeBean.getClientaddress()); + String addr = Util.null2String(signOutTimeBean.getAddr()); + signInfo.put("off_signdate", signdate); + signInfo.put("off_signtime", signtime); + signInfo.put("off_clientaddress", clientaddress); + signInfo.put("off_position", addr); + } + if(!signInfo.isEmpty()){ + signInfos.add(signInfo); + } + } + } + + /** + * 兼容E8的 HrmScheduleDiffDetSignInManager 和 HrmScheduleDiffDetSignOutManager + * @param signtype + * @param resourceId + * @param fromdate + * @param todate + * @param user + */ + public static List> getKQSignData(SignType signtype,String resourceId,String fromdate,String todate){ + List> scheduleList = new ArrayList>(); + try{ + ResourceComInfo resourceComInfo = new ResourceComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String sql = "select * from kq_format_detail where resourceid = ? and kqdate >= ? and kqdate <= ? "; + rs.executeQuery(sql, resourceId,fromdate,todate); + while (rs.next()){ + String signindate = rs.getString("signindate"); + String signintime = rs.getString("signintime"); + String signoutdate = rs.getString("signoutdate"); + String signouttime = rs.getString("signouttime"); + String signinid = rs.getString("signinid"); + String signoutid = rs.getString("signoutid"); + Map map = new HashMap(); + map.put("subCompanyId", resourceComInfo.getSubCompanyID(resourceId)); + map.put("departmentId", resourceComInfo.getDepartmentID(resourceId)); + map.put("departmentName", departmentComInfo.getDepartmentName(resourceComInfo.getDepartmentID(resourceId))); + map.put("resourceId", resourceId); + map.put("resourceName", resourceComInfo.getLastname(resourceId)); + map.put("statusName", getStatusName(resourceComInfo.getStatus(resourceId),resourceId)); + map.put("status", resourceComInfo.getStatus(resourceId)); + map.put("workcode", resourceComInfo.getWorkcode(resourceId)); + map.put("currentDate", DateUtil.getCurrentDate()); + String get_sign_info_sql = "select * from hrmschedulesign where id = ? "; + if(signtype == SignType.SIGN_IN){ + map.put("signId", signinid); + map.put("signDate", signindate); + map.put("signTime", signintime); + }else if(signtype == SignType.SIGN_OUT){ + map.put("signId", signoutid); + map.put("signDate", signoutdate); + map.put("signTime", signouttime); + } + map.put("mfer", signtype.getName()); + rs1.executeQuery(get_sign_info_sql, signinid); + if(rs1.next()){ + map.put("clientAddress", Util.null2String(rs1.getString("clientaddress"))); + map.put("_addr", Util.null2String(rs1.getString("addr"))); + map.put("longitude", Util.null2String(rs1.getString("longitude"))); + map.put("latitude", Util.null2String(rs1.getString("latitude"))); + } + scheduleList.add(map); + } + + }catch (Exception e){ + e.printStackTrace(); + } + return scheduleList; + } + + /** + * 获取人员状态 + * @param status + * @param resourceId + * @return + */ + private static String getStatusName(String status, String resourceId) { + String statusName = ""; + int lanId = new User(Util.getIntValue(resourceId)).getLanguage(); + if (StringUtil.isNotNull(status)) { + if (status.equals("0")) { + statusName = SystemEnv.getHtmlLabelName(15710, lanId); + } else if (status.equals("1")) { + statusName = SystemEnv.getHtmlLabelName(15711, lanId); + } else if (status.equals("2")) { + statusName = SystemEnv.getHtmlLabelName(480, lanId); + } else if (status.equals("3")) { + statusName = SystemEnv.getHtmlLabelName(15844, lanId); + } else if (status.equals("4")) { + statusName = SystemEnv.getHtmlLabelName(6094, lanId); + } else if (status.equals("5")) { + statusName = SystemEnv.getHtmlLabelName(6091, lanId); + } else if (status.equals("6")) { + statusName = SystemEnv.getHtmlLabelName(6092, lanId); + } else if (status.equals("7")) { + statusName = SystemEnv.getHtmlLabelName(2245, lanId); + } else if (status.equals("10")) { + statusName = SystemEnv.getHtmlLabelName(1831, lanId); + } + } + return statusName; + } + +} diff --git a/src/com/engine/kq/wfset/util/SplitActionUtil.java b/src/com/engine/kq/wfset/util/SplitActionUtil.java new file mode 100644 index 0000000..ba0a881 --- /dev/null +++ b/src/com/engine/kq/wfset/util/SplitActionUtil.java @@ -0,0 +1,3487 @@ +package com.engine.kq.wfset.util; + +import cn.hutool.core.bean.BeanUtil; +import com.alibaba.fastjson.JSON; +import com.engine.kq.bean.KQHrmScheduleSign; +import com.engine.kq.bean.KQRepeatBean; +import com.engine.kq.biz.*; +import com.engine.kq.biz.chain.duration.WorkHalfUnitSplitChain; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.entity.KQOvertimeRulesDetailEntity; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.jucailin.util.KQDateUtil; +import com.engine.kq.log.KQLog; +import com.engine.kq.timer.KQQueue; +import com.engine.kq.timer.KQTaskBean; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.wfset.bean.SplitBean; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.sql.Date; +import java.sql.Timestamp; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; + +public class SplitActionUtil extends BaseBean { + public static KQLog kqLog = new KQLog(); + + private static BaseBean baseBean = new BaseBean(); + + /** + * 现在先用正常的去执行吧 + * + * @param splitBeans + * @param requestid + */ + public static void handleLeaveAction(List splitBeans, String requestid) { + for (int i = 0; i < splitBeans.size(); i++) { + SplitBean splitBean = splitBeans.get(i); + String resourceId = splitBean.getResourceId(); + String duration = splitBean.getDuration(); + String newLeaveType = splitBean.getNewLeaveType(); + String durationrule = splitBean.getDurationrule(); + String fromdate = splitBean.getFromDate(); + String fromdatedb = splitBean.getFromdatedb(); + kqLog.info("请假扣减:resourceId:" + resourceId + ":fromdate:" + fromdate + ":duration:" + duration + ":newLeaveType:" + newLeaveType + ":durationrule:" + durationrule + ":requestid:" + requestid + ":fromdatedb:" + fromdatedb); + if(Util.getDoubleValue(duration) <= 0){ + continue; + } + KQBalanceOfLeaveBiz.addUsedAmount(resourceId, fromdate, newLeaveType, duration, "", requestid, fromdatedb); + } + } + + /** + * 单独针对加班规则的第二种模式 生成加班数据 + * + * @param splitBeans + * @param requestid + */ + public static void handleOverTimeActionMode2(List splitBeans, String requestid) { + clearSameRequestTX(requestid); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + List overKeys = new ArrayList<>(); + for (int i = 0; i < splitBeans.size(); i++) { + SplitBean splitBean = splitBeans.get(i); + int computingMode = Util.getIntValue(splitBean.getComputingMode()); + if (computingMode == 2 || computingMode == 4) { + //判断流程对应的日期下有没有打卡数据,如果有的话,需要生成相应的调休数据 + String belongDate = splitBean.getBelongDate(); + String resourceId = splitBean.getResourceId(); + String fromtime = splitBean.getFromTime(); + int fromtimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime); + String key = resourceId + "_" + belongDate + "_" + belongDate; + if (fromtimeIndex > 1439) { + //跨天了 + key = resourceId + "_" + belongDate + "_" + DateUtil.addDate(belongDate, 1); + } + if (!overKeys.contains(key)) { + overKeys.add(key); + } + } + if (computingMode == 1) { + doComputingMode1_splitBean(splitBean); + } + } + KQOverTimeRuleCalBiz kqOvertimeCalBiz = new KQOverTimeRuleCalBiz(); + kqLog.info("加班生成调休:handleOverTimeActionMode2 overKeys:" + JSON.toJSONString(overKeys)); + if (overKeys != null && !overKeys.isEmpty()) { + for (String key : overKeys) { + String[] keys = key.split("_", -1); + if (keys.length == 3) { + String resourceId = keys[0]; + String fromDate = keys[1]; + String belongToDate = keys[2]; + if(checkHasKTCard(resourceId, fromDate)){ + fromDate = DateUtil.addDate(fromDate,-1); + } + kqOvertimeCalBiz.buildOvertime(resourceId, fromDate, belongToDate, "加班流程生成加班#flow,requestId:" + requestid); + } + } + } + } + + /** + * 判斷下昨日的打卡有沒有落在今日的數據,如果有,則加班需要往前多算一天 + * @param resourceId + * @param belongDate + * @return + */ + public static boolean checkHasKTCard(String resourceId, String belongDate){ + RecordSet recordSet = new RecordSet(); + //如果打卡存在跨天的情况 + String sql = "select count(*) as cnt from KQ_FORMAT_DETAIL where RESOURCEID="+resourceId+" and KQDATE='"+DateUtil.addDate(belongDate, -1)+"' and (SIGNOUTDATE='"+belongDate+"' or signindate='"+belongDate+"')"; + recordSet.executeQuery(sql); + if(recordSet.next()){ + String cnt = recordSet.getString("cnt"); + if(Util.getIntValue(cnt, 0) > 0){ + return true; + } + } + return false; + } + + public static void turnOvertimeBeansWithRule(List splitBeans) { + + Map> resourceMap = new HashMap<>(); + //公众假日加班时长 + double D_Pub_Duration = 0.0; + double D_Pub_Mins = 0.0; + //工作日加班时长 + double D_Work_Duration = 0.0; + double D_Work_Mins = 0.0; + //休息日加班时长 + double D_Rest_Duration = 0.0; + double D_Rest_Mins = 0.0; + + //公众假日加班 + List holiday = new ArrayList<>(); + //工作日加班 + List work = new ArrayList<>(); + //休息日加班 + List rest = new ArrayList<>(); + + String pub_date = ""; + String work_date = ""; + String rest_date = ""; + + //每一天的流程时长都在这里了,搞吧 + for (SplitBean sb : splitBeans) { +// * 1-公众假日、2-工作日、3-休息日 + String tmpResid = sb.getResourceId(); + if (resourceMap.containsKey(tmpResid)) { + resourceMap.get(tmpResid).add(sb); + } else { + List splitBeans_tmp = new ArrayList<>(); + splitBeans_tmp.add(sb); + resourceMap.put(tmpResid, splitBeans_tmp); + } + } + if (!resourceMap.isEmpty()) { + for (Map.Entry> me : resourceMap.entrySet()) { + String resourceid = me.getKey(); + List tmp_splitbeans = me.getValue(); + for (SplitBean sb : tmp_splitbeans) { +// * 1-公众假日、2-工作日、3-休息日 + int changeType = sb.getChangeType(); + double durations = Util.getDoubleValue(sb.getDuration(), 0.0); + double durationMins = sb.getD_Mins(); + if (1 == changeType) { + D_Pub_Duration += durations; + D_Pub_Mins += durationMins; + pub_date = sb.getBelongDate(); + holiday.add(sb); + } + if (2 == changeType) { + D_Work_Duration += durations; + D_Work_Mins += durationMins; + work_date = sb.getBelongDate(); + work.add(sb); + } + if (3 == changeType) { + D_Rest_Duration += durations; + D_Rest_Mins += durationMins; + rest_date = sb.getBelongDate(); + rest.add(sb); + } + } + + if (D_Pub_Duration > 0) { + int minimumUnit = KQOvertimeRulesBiz.getMinimumLen(resourceid, pub_date); + if (D_Pub_Mins < minimumUnit) { + for (SplitBean tmp : holiday) { + tmp.setDuration("0.0"); + tmp.setD_Mins(0.0); + } + } + } + if (D_Work_Duration > 0) { + int minimumUnit = KQOvertimeRulesBiz.getMinimumLen(resourceid, work_date); + if (D_Work_Mins < minimumUnit) { + for (SplitBean tmp : work) { + tmp.setDuration("0.0"); + tmp.setD_Mins(0.0); + } + } + } + if (D_Rest_Duration > 0) { + int minimumUnit = KQOvertimeRulesBiz.getMinimumLen(resourceid, rest_date); + if (D_Rest_Mins < minimumUnit) { + for (SplitBean tmp : rest) { + tmp.setDuration("0.0"); + tmp.setD_Mins(0.0); + } + } + } + } + } + + } + + /** + * 生成加班数据 + * + * @param splitBeans + * @param requestid + * @param canMode2 是否是归档节点 归档节点才可以把加班数据写到加班中间表,不是归档节点的话意味着只生成调休不生成加班,只有强制归档canMode2才是true + * @param from_uuid 来自action的uuid + */ + public static void handleOverTimeAction(List splitBeans, String requestid, + boolean canMode2, String from_uuid) throws Exception { +// 保证同一个requestid能重复生成调休和加班 + if (canMode2) { + clearSameRequestTX(requestid); + } + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + RecordSet rs = new RecordSet(); + List overKeys = new ArrayList<>(); + for (int i = 0; i < splitBeans.size(); i++) { + SplitBean splitBean = splitBeans.get(i); + String resourceId = splitBean.getResourceId(); + String belongDate = splitBean.getBelongDate(); + String toDate = splitBean.getToDate(); + String duration = splitBean.getDuration(); + String durationrule = splitBean.getDurationrule(); + + int computingMode = Util.getIntValue(splitBean.getComputingMode()); + int changeType = splitBean.getChangeType(); + String paidSql = "insert into KQ_PAID_VACATION (requestId,workflowId,dataid,detailid,resourceId,fromDate,fromTime,toDate,toTime,duration,durationrule,computingMode,changeType)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?) "; + boolean isLog = rs.executeUpdate(paidSql, splitBean.getRequestId(), splitBean.getWorkflowId(), + splitBean.getDataId(), splitBean.getDetailId(), splitBean.getResourceId(), + splitBean.getFromDate(), splitBean.getFromTime(), splitBean.getToDate(), + splitBean.getToTime(), splitBean.getDuration(), splitBean.getDurationrule(), computingMode, changeType); + if (isLog) { + kqLog.info("加班生成调休:resourceId:" + resourceId + ":computingMode:" + computingMode + ":belongDate:" + belongDate + ":duration:" + duration + ":durationrule:" + durationrule + ":requestid:" + requestid); + + if (computingMode == 1) { + doComputingMode1_4TX(splitBean); + if (canMode2) { + doComputingMode1_splitBean(splitBean); + } + } + if (canMode2 && (computingMode == 2 || computingMode == 4)) { + //判断流程对应的日期下有没有打卡数据,如果有的话,需要生成相应的调休数据 + String fromtime = splitBean.getFromTime(); + int fromtimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime); + String key = resourceId + "_" + belongDate + "_" + belongDate; + if (fromtimeIndex > 1439) { + //跨天了 + key = resourceId + "_" + belongDate + "_" + DateUtil.addDate(belongDate, 1); + } + if (!overKeys.contains(key)) { + overKeys.add(key); + } + } + } + } + KQOverTimeRuleCalBiz kqOvertimeCalBiz = new KQOverTimeRuleCalBiz(); + kqLog.info("加班生成调休:handleOverTimeAction overKeys:" + JSON.toJSONString(overKeys)); + if (overKeys != null && !overKeys.isEmpty()) { + for (String key : overKeys) { + String[] keys = key.split("_", -1); + if (keys.length == 3) { + String resourceId = keys[0]; + String fromDate = keys[1]; + String belongToDate = keys[2]; + if(checkHasKTCard(resourceId, fromDate)){ + fromDate = DateUtil.addDate(fromDate,-1); + } + kqOvertimeCalBiz.buildOvertime(resourceId, fromDate, belongToDate, "加班流程生成加班#flow,requestId:" + requestid + "#from_uuid|" + from_uuid); + } + } + } + } + + /** + * 保证同一个requestid能重复生成调休和加班 + * + * @param requestid + */ + public static void clearSameRequestTX(String requestid) { + String all_tiaoxiuids = ""; + List all_tiaoxiuidList = Lists.newArrayList(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_flow_overtime where requestid = ? "; + rs.executeQuery(sql, requestid); + while (rs.next()) { + String tiaoxiuid = Util.null2String(rs.getString("tiaoxiuid"), ""); + if (tiaoxiuid.length() > 0 && Util.getIntValue(tiaoxiuid) > 0) { + all_tiaoxiuids += "," + tiaoxiuid; + all_tiaoxiuidList.add(tiaoxiuid); + } + } + if (all_tiaoxiuids.length() > 0) { + all_tiaoxiuids = all_tiaoxiuids.substring(1); + String tiaoxiuidis0 = ""; + String delSql0 = "select * from kq_balanceofleave where " + Util.getSubINClause(all_tiaoxiuids, "id", "in") + " and " + + " baseamount =0 and extraamount=0 and usedamount=0 and baseamount2=0 and extraamount2=0 and usedamount2=0 "; + + if (rs.getDBType().equalsIgnoreCase("oracle")) { + delSql0 = "select * from kq_balanceofleave where " + Util.getSubINClause(all_tiaoxiuids, "id", "in") + " and " + + " nvl(baseamount,0) =0 and nvl(extraamount,0)=0 and nvl(usedamount,0)=0 and nvl(baseamount2,0)=0 " + + " and nvl(extraamount2,0)=0 and nvl(usedamount2,0)=0 "; + } else if ((rs.getDBType()).equalsIgnoreCase("mysql")) { + delSql0 = "select * from kq_balanceofleave where " + Util.getSubINClause(all_tiaoxiuids, "id", "in") + " and " + + " ifnull(baseamount,0) =0 and ifnull(extraamount,0)=0 and ifnull(usedamount,0)=0 and ifnull(baseamount2,0)=0 " + + " and ifnull(extraamount2,0)=0 and ifnull(usedamount2,0)=0 "; + } else { + delSql0 = "select * from kq_balanceofleave where " + Util.getSubINClause(all_tiaoxiuids, "id", "in") + " and " + + " isnull(baseamount,0) =0 and isnull(extraamount,0)=0 and isnull(usedamount,0)=0 and isnull(baseamount2,0)=0 " + + " and isnull(extraamount2,0)=0 and isnull(usedamount2,0)=0 "; + } + rs.executeQuery(delSql0); + kqLog.info("all_tiaoxiuidList:" + all_tiaoxiuidList); + kqLog.info("clearSameRequestTX:" + delSql0); + while (rs.next()) { + String tiaoxiuid = Util.null2String(rs.getString("id"), ""); + if (tiaoxiuid.length() > 0 && Util.getIntValue(tiaoxiuid) > 0) { + tiaoxiuidis0 += "," + tiaoxiuid; + all_tiaoxiuidList.remove(tiaoxiuid); + } + } + kqLog.info("all_tiaoxiuidList:" + all_tiaoxiuidList); + kqLog.info("tiaoxiuidis0:" + tiaoxiuidis0); + if (tiaoxiuidis0.length() > 0) { + tiaoxiuidis0 = tiaoxiuidis0.substring(1); + String delSql = "delete from kq_balanceofleave where " + Util.getSubINClause(tiaoxiuidis0, "id", "in"); + boolean isok = rs.executeUpdate(delSql); + kqLog.info("delSql:" + delSql + ":isok:" + isok); + } + if (!all_tiaoxiuidList.isEmpty()) { + String clear_tiaoxiuids = all_tiaoxiuidList.stream().collect(Collectors.joining(",")); + String clearSql = "update kq_balanceofleave set tiaoxiuamount=0.0,update_time=? where " + Util.getSubINClause(clear_tiaoxiuids, "id", "in"); + if (rs.getDBType().equals("postgresql")) { + clearSql = "update kq_balanceofleave set tiaoxiuamount=0.0,update_time=?::timestamp where " + Util.getSubINClause(clear_tiaoxiuids, "id", "in"); + } + boolean isclearOk = rs.executeUpdate(clearSql,KQDateUtil.getUpdateTimeStamp()); + kqLog.info("clearSql:" + clearSql + ":isclearOk:" + isclearOk); + } + + String delUsageSql = "delete from kq_usagehistory where " + Util.getSubINClause(tiaoxiuidis0, "balanceofleaveid", "in"); + boolean isdelUsageOk = rs.executeUpdate(delUsageSql); + kqLog.info("delUsageSql:" + delUsageSql + ":isdelUsageOk:" + isdelUsageOk); + } + String delSql = "delete from kq_flow_overtime where requestid = ? "; + boolean isDelOk = rs.executeUpdate(delSql, requestid); + kqLog.info("delSql:" + delSql + ":requestid:" + requestid + ":isDelOk:" + isDelOk); + } + + /** + * 加班方式是第一种,如果是先生成调休,后面才生成加班,需要先把调休给按照加班规则给生成出来 + * + * @param splitBean + */ + public static void doComputingMode1_4TX(SplitBean splitBean) { + RecordSet rs = new RecordSet(); + int changeType = splitBean.getChangeType(); + String resourceId = splitBean.getResourceId(); + String belongDate = splitBean.getBelongDate(); + String duration = splitBean.getDuration(); + String fromdateDB = splitBean.getFromdatedb(); + String requestId = splitBean.getRequestId(); + String fromdate = splitBean.getFromDate(); + String fromtime = splitBean.getFromTime(); + String todate = splitBean.getToDate(); + String totime = splitBean.getToTime(); + String overtime_type = splitBean.getOvertime_type(); + double D_Mins = splitBean.getD_Mins(); + int workMins = splitBean.getWorkmins(); + String workingHours = Util.null2String(workMins / 60.0); + Map changeTypeMap = Maps.newHashMap(); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + KQOverTimeRuleCalBiz kqOverTimeRuleCalBiz = new KQOverTimeRuleCalBiz(); + Map overRulesDetailMap = Maps.newHashMap(); + Map> restTimeMap = Maps.newHashMap(); + Map computingModeMap = Maps.newHashMap(); + //先获取一些前提数据,加班規則和假期規則 + kqOverTimeRuleCalBiz.getOverTimeDataMap(resourceId, belongDate, belongDate, dateFormatter, changeTypeMap, overRulesDetailMap, restTimeMap, computingModeMap); + + String changeType_key = belongDate + "_" + changeType; + if (!overRulesDetailMap.containsKey(changeType_key)) { + return; + } +// 根据加班单位重新生成下加班分钟数 + D_Mins = kqOverTimeRuleCalBiz.getD_MinsByUnit(D_Mins); + + KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key); + int paidLeaveEnable = kqOverTimeRuleCalBiz.getPaidLeaveEnable(kqOvertimeRulesDetailEntity, overtime_type); + Map otherParam = Maps.newHashMap(); + otherParam.put("overtime_type", overtime_type); + + String tiaoxiuId = KQBalanceOfLeaveBiz.addExtraAmountByDis5(resourceId, belongDate, D_Mins + "", "0", workingHours, requestId, "1", fromdateDB, otherParam); + if (Util.getIntValue(tiaoxiuId) > 0) { + //为啥要用kq_overtime_tiaoxiu这个表呢,因为kqpaidleaveaction可能和splitaction不是在同一个归档前节点 + String split_key = splitBean.getRequestId() + "_" + splitBean.getDataId() + "_" + splitBean.getDetailId() + "_" + + splitBean.getFromDate() + "_" + splitBean.getFromTime() + "_" + splitBean.getToDate() + "_" + + splitBean.getToTime() + "_" + splitBean.getD_Mins(); + String tiaoxiuId_sql = "insert into kq_overtime_tiaoxiu(split_key,tiaoxiu_id) values(?,?) "; + rs.executeUpdate(tiaoxiuId_sql, split_key, tiaoxiuId); + kqLog.info("doComputingMode1 加班生成调休成功!!!"); + } else { + kqLog.info("doComputingMode1 加班生成调休失败!!!"); + } + } + + /** + * 加班方式是第一种,然后再流程归档的时候把加班数据写到加班中间表里 + * + * @param splitBean + */ + public static void doComputingMode1_splitBean(SplitBean splitBean) { + try { + kqLog.info("doComputingMode1_splitBean:splitBean: " + (splitBean != null ? JSON.toJSONString(splitBean) : "null")); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + int changeType = splitBean.getChangeType(); + String requestId = splitBean.getRequestId(); + String resourceId = splitBean.getResourceId(); + String belongDate = splitBean.getBelongDate(); + String duration = splitBean.getDuration(); + String durationrule = splitBean.getDurationrule(); + String fromdateDB = splitBean.getFromdatedb(); + String fromtimedb = splitBean.getFromtimedb(); + String todatedb = splitBean.getTodatedb(); + String totimedb = splitBean.getTotimedb(); + String fromdate = splitBean.getFromDate(); + String fromtime = splitBean.getFromTime(); + String todate = splitBean.getToDate(); + String totime = splitBean.getToTime(); + double D_Mins = splitBean.getD_Mins(); + Map changeTypeMap = Maps.newHashMap(); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + KQOverTimeRuleCalBiz kqOverTimeRuleCalBiz = new KQOverTimeRuleCalBiz(); + Map overRulesDetailMap = Maps.newHashMap(); + Map> restTimeMap = Maps.newHashMap(); + Map computingModeMap = Maps.newHashMap(); + //先获取一些前提数据,加班規則和假期規則 + kqOverTimeRuleCalBiz.getOverTimeDataMap(resourceId, belongDate, belongDate, dateFormatter, changeTypeMap, overRulesDetailMap, restTimeMap, computingModeMap); + String overtime_type = splitBean.getOvertime_type(); + String changeType_key = belongDate + "_" + changeType; + if (!overRulesDetailMap.containsKey(changeType_key)) { + return; + } + KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key); + int paidLeaveEnable = kqOverTimeRuleCalBiz.getPaidLeaveEnable(kqOvertimeRulesDetailEntity, overtime_type); + int unit = KQOvertimeRulesBiz.getMinimumUnit(); + + String tiaoxiu_id = ""; + String overtime_tiaoxiu_id = ""; + + String split_key = splitBean.getRequestId() + "_" + splitBean.getDataId() + "_" + splitBean.getDetailId() + "_" + + splitBean.getFromDate() + "_" + splitBean.getFromTime() + "_" + splitBean.getToDate() + "_" + + splitBean.getToTime() + "_" + splitBean.getD_Mins(); + String check_tiaoxiu_sql = "select * from kq_overtime_tiaoxiu where split_key=? "; + rs1.executeQuery(check_tiaoxiu_sql, split_key); + if (rs1.next()) { + overtime_tiaoxiu_id = rs1.getString("id"); + tiaoxiu_id = rs1.getString("tiaoxiu_id"); + } + + fromtime = fromtime + ":00"; + totime = totime + ":00"; + Long cur = System.currentTimeMillis(); + Timestamp date = new Timestamp(cur); + String flow_overtime_sql = "insert into kq_flow_overtime(requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate,workMins,durationrule,changetype,paidLeaveEnable,computingMode,fromdatedb,fromtimedb,todatedb,totimedb,tiaoxiuid,create_time,update_time,creator)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + if (rs.getDBType().equals("postgresql")) { + flow_overtime_sql = "insert into kq_flow_overtime(requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate,workMins,durationrule,changetype,paidLeaveEnable,computingMode,fromdatedb,fromtimedb,todatedb,totimedb,tiaoxiuid,create_time,update_time,creator)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?::timestamp,?::timestamp,?) "; + } + boolean isUp = rs.executeUpdate(flow_overtime_sql, requestId, resourceId, fromdate, fromtime, todate, totime, D_Mins, "", belongDate, "", + unit, changeType, paidLeaveEnable, "1", fromdateDB, fromtimedb, todatedb, totimedb, tiaoxiu_id,date,date,Util.getIntValue(resourceId)); + if (!isUp) { + kqLog.info("doComputingMode1 加班数据flow_overtime_sql记录失败!!!"); + } else { + kqLog.info("doComputingMode1:flow_overtime_sql: " + flow_overtime_sql); + kqLog.info("doComputingMode1:requestId:" + requestId + ":resourceId:" + resourceId + ":fromdate:" + fromdate + ":fromtime:" + fromtime + + ":todate:" + todate + ":totime:" + totime + ":D_Mins:" + D_Mins + ":belongDate:" + belongDate + ":unit:" + unit + ":changeType:" + changeType + + ":paidLeaveEnable:" + paidLeaveEnable + ":fromdateDB:" + fromdateDB + ":fromtimedb:" + fromtimedb + ":todatedb:" + todatedb + ":totimedb:" + totimedb); + } + if (overtime_tiaoxiu_id.length() > 0 && Util.getIntValue(overtime_tiaoxiu_id) > 0) { + String delSql = "delete from kq_overtime_tiaoxiu where id = ? "; + rs1.executeUpdate(delSql, overtime_tiaoxiu_id); + } + } catch (Exception e) { + kqLog.info("加班生成数据报错:doComputingMode1_splitBean:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + + } + + public static List> getSplitHalfDayListRepeat(String fromDate, String toDate, String fromTime, String toTime) { + List> splitLists = new ArrayList<>(); + Map splitMap = new HashMap<>(); + + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate localToDate = LocalDate.parse(toDate); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + long betweenDays = localToDate.toEpochDay() - localFromDate.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + splitMap = new HashMap<>(); + LocalDate curLocalDate = localFromDate.plusDays(i); + splitMap.put("splitDate", curLocalDate.format(dateFormatter)); + int foreOrAfter = SplitSelectSet.foreOrAfter(fromTime, toTime); + splitMap.put("foreOrAfter", "" + foreOrAfter); + splitLists.add(splitMap); + } + return splitLists; + } + + /** + * 签到签退 生成加班数据 + * + * @param taskBeans + */ + public void handleOverTime(List taskBeans) throws Exception { + try { + if (true) { + KQOverTimeRuleCalBiz kqOverTimeRuleCalBiz = new KQOverTimeRuleCalBiz(); + for (int i = 0; i < taskBeans.size(); i++) { + KQTaskBean taskBean = taskBeans.get(i); + String tasktype = taskBean.getTasktype(); + String eventtype = ""; + if ("punchcard".equalsIgnoreCase(tasktype)) { + eventtype = "考勤打卡生成加班."; + } + kqOverTimeRuleCalBiz.buildOvertime(taskBean.getResourceId(), taskBean.getOvertime_fromdate(), taskBean.getOvertime_todate(), + eventtype); + } + } else { + handleOverTime_old(taskBeans); + } + } catch (Exception e) { + kqLog.info("加班生成数据报错:handleOverTime:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + } + } + + /** + * 这个加班方法后面废弃 + * 新的加班都在这里kqOverTimeRuleCalBiz.buildOvertime + * @param taskBeans + * @throws Exception + */ + @Deprecated + public void handleOverTime_old(List taskBeans) throws Exception { + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + int workMins = (int) (KQFlowUtil.getOneDayHour(DurationTypeEnum.OVERTIME, "") * 60); + kqLog.info("handleOverTime:start:" + (taskBeans != null ? JSON.toJSONString(taskBeans) : "is empty")); + //防止bean里重复的 + List repeat_taskBeans = new ArrayList<>(); + for (int i = 0; i < taskBeans.size(); i++) { + KQTaskBean taskBean = taskBeans.get(i); + if (repeat_taskBeans.contains(taskBean)) { + continue; + } else { + repeat_taskBeans.add(taskBean); + } + taskBean.setWorkmins(workMins); + String resourceId = taskBean.getResourceId(); + String taskDate = taskBean.getTaskDate(); + int overtimeEnable = KQOvertimeRulesBiz.getOvertimeEnable(resourceId, taskDate); + + //如果人再当前指定日期下未开启加班,直接跳过 + if (overtimeEnable != 1) { + kqLog.info("签到签退 生成加班数据 handleOverTimeBySign:resourceId:" + resourceId + ":taskDate:" + taskDate + "不允许加班"); + continue; + } + + int computingMode = KQOvertimeRulesBiz.getComputingMode(resourceId, taskDate); + kqLog.info("加班生成调休方式:resourceId:" + resourceId + ":taskDate:" + taskDate + ":computingMode:" + computingMode); + if (computingMode == 1) { +// 需审批,以审批单为准 + doComputingMode1(taskBean, fullFormatter); + } + if (computingMode == 2) { +// 需审批,以打卡为准,但是不能超过审批时长 + doComputingMode2(taskBean, fullFormatter); + } + if (computingMode == 3) { +// 无需审批,根据打卡时间计算加班时长 + doComputingMode3(taskBean, fullFormatter); + } + } + } + + /** + * 流程为主的就在流程归档的时候处理下,不在队列里进行处理了 + * + * @param taskBean + * @param fullFormatter + * @throws Exception + */ + @Deprecated + private void doComputingMode1(KQTaskBean taskBean, + DateTimeFormatter fullFormatter) throws Exception { + SplitBean splitBean = taskBean.getSplitBean(); + kqLog.info("doComputingMode1:splitBean: start"); + if (splitBean != null) { + RecordSet rs = new RecordSet(); + int changeType = splitBean.getChangeType(); + String requestId = splitBean.getRequestId(); + String resourceId = splitBean.getResourceId(); + String belongDate = splitBean.getBelongDate(); + String duration = splitBean.getDuration(); + String durationrule = splitBean.getDurationrule(); + String fromdateDB = splitBean.getFromdatedb(); + String fromtimedb = splitBean.getFromtimedb(); + String todatedb = splitBean.getTodatedb(); + String totimedb = splitBean.getTotimedb(); + String fromdate = splitBean.getFromDate(); + String fromtime = splitBean.getFromTime(); + String todate = splitBean.getToDate(); + String totime = splitBean.getToTime(); + double D_Mins = splitBean.getD_Mins(); + + int unit = KQOvertimeRulesBiz.getMinimumUnit(); + int paidLeaveEnable = KQOvertimeRulesBiz.getPaidLeaveEnable(resourceId, belongDate); + paidLeaveEnable = paidLeaveEnable == 1 ? 1 : 0; + + fromtime = fromtime + ":00"; + totime = totime + ":00"; + Long cur = System.currentTimeMillis(); + Date date = new Date(cur); + String flow_overtime_sql = "insert into kq_flow_overtime(requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate,workMins,durationrule,changetype,paidLeaveEnable,computingMode,fromdatedb,fromtimedb,todatedb,totimedb,create_time,update_time,creator)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + if (rs.getDBType().equals("postgresql")) { + flow_overtime_sql = "insert into kq_flow_overtime(requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate,workMins,durationrule,changetype,paidLeaveEnable,computingMode,fromdatedb,fromtimedb,todatedb,totimedb,create_time,update_time,creator)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?::timestamp,?::timestamp,?) "; + } + boolean isUp = rs.executeUpdate(flow_overtime_sql, requestId, resourceId, fromdate, fromtime, todate, totime, D_Mins, "", belongDate, "", + unit, changeType, paidLeaveEnable, "1", fromdateDB, fromtimedb, todatedb, totimedb,date,date,Util.getIntValue(resourceId)); + if (!isUp) { + kqLog.info("doComputingMode1 加班数据flow_overtime_sql记录失败!!!"); + } else { + kqLog.info("doComputingMode1:flow_overtime_sql: " + flow_overtime_sql); + kqLog.info("doComputingMode1:requestId:" + requestId + ":resourceId:" + resourceId + ":fromdate:" + fromdate + ":fromtime:" + fromtime + + ":todate:" + todate + ":totime:" + totime + ":D_Mins:" + D_Mins + ":belongDate:" + belongDate + ":unit:" + unit + ":changeType:" + changeType + + ":paidLeaveEnable:" + paidLeaveEnable + ":fromdateDB:" + fromdateDB + ":fromtimedb:" + fromtimedb + ":todatedb:" + todatedb + ":totimedb:" + totimedb); + } + } + } + + /** + * 无需审批,以打卡为准,但是不能超过审批时长 + * + * @param taskBean + * @param fullFormatter + */ + private void doComputingMode2(KQTaskBean taskBean, + DateTimeFormatter fullFormatter) throws Exception { + String resourceId = taskBean.getResourceId(); + String taskDate = taskBean.getTaskDate(); + KQFlowDataBiz kqFlowDataBiz = new KQFlowDataBiz.FlowDataParamBuilder().belongDateParam(taskDate).resourceidParam(resourceId).build(); + Map flowMaps = new HashMap<>(); + List splitBeans = kqFlowDataBiz.getOverTimeData(flowMaps); + if (!splitBeans.isEmpty()) { + Map flowMap = new HashMap<>(); + Map requestMap = new HashMap<>(); + for (int i = 0; i < splitBeans.size(); i++) { + SplitBean splitBean = splitBeans.get(i); + String changeTpe = "" + splitBean.getChangeType(); + String requestid = splitBean.getRequestId(); + String flowMins = Util.null2String(splitBean.getD_Mins()); + if (flowMap.get(changeTpe) != null) { + double tmpMins = Util.getDoubleValue(Util.null2String(flowMap.get(changeTpe)), 0.0); + flowMap.put(changeTpe, "" + (tmpMins + Util.getDoubleValue(flowMins))); + } else { + flowMap.put(changeTpe, flowMins); + } + if (requestMap.get(changeTpe) != null) { + String tmpRequestid = Util.null2String(requestMap.get(changeTpe)); + if (("," + tmpRequestid + ",").indexOf(requestid) < 0) { + requestMap.put(changeTpe, tmpRequestid + "," + requestid); + } + } else { + requestMap.put(changeTpe, requestid); + } + } + int changeType = KQOvertimeRulesBiz.getChangeType(resourceId, taskDate); + if (requestMap.get("" + changeType) != null) { + taskBean.setRequestId(requestMap.get("" + changeType)); + } + kqLog.info("签到签退 生成加班数据为 doComputingMode2:加班流程数据为 flowMap:" + flowMap); +// 1-节假日、2-工作日、3-休息日 + if (changeType == 1) { + doMode2ChangeType1(taskBean, fullFormatter, flowMap.get("1")); + } + if (changeType == 2) { + doMode2ChangeType2(taskBean, fullFormatter, flowMap.get("2")); + } + if (changeType == 3) { + doMode2ChangeType3(taskBean, fullFormatter, flowMap.get("3")); + } + } else { + kqLog.info("签到签退 生成加班数据为 doComputingMode2:加班流程数据为空:resourceId:" + resourceId + ":taskDate:" + taskDate); + } + } + + + /** + * 需审批,以打卡为准 + * 休息日 + * + * @param taskBean + * @param fullFormatter + * @param flowMins + */ + private void doMode2ChangeType3(KQTaskBean taskBean, DateTimeFormatter fullFormatter, + String flowMins) throws Exception { + String taskDate = taskBean.getTaskDate(); + String resourceId = taskBean.getResourceId(); + String taskSignTime = taskBean.getTaskSignTime(); + String signInTime4Out = taskBean.getSignInTime4Out(); + String requestid = taskBean.getRequestId(); + String signDate = taskBean.getSignDate(); + String signEndDate = taskBean.getSignEndDate(); + String timesource = Util.null2String(taskBean.getTimesource()); + boolean isBefore = false; + if ("before".equalsIgnoreCase(timesource)) { + isBefore = true; + } + if (taskSignTime.length() > 0 && signInTime4Out.length() > 0) { + + long mins = calNonWorkDuration(signInTime4Out, taskSignTime, taskDate, resourceId); + if (isBefore && signEndDate.compareTo(signDate) < 0) { + //打卡日期和归属日期不是同一天的话 + String fromDateTime = signEndDate + " " + signInTime4Out; + String toDateTime = signDate + " " + taskSignTime; +// 还需要交换一下开始日期和结束日期 + String tmpDate = signDate; + signDate = signEndDate; + signEndDate = tmpDate; + mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + } + if (mins > 0) { + int unit = KQOvertimeRulesBiz.getMinimumUnit(); + int paidLeaveEnable = KQOvertimeRulesBiz.getPaidLeaveEnable(resourceId, taskDate); + int minimumUnit = KQOvertimeRulesBiz.getMinimumLen(resourceId, taskDate); + paidLeaveEnable = paidLeaveEnable == 1 ? 1 : 0; + if (mins >= minimumUnit && Util.getDoubleValue(flowMins) >= minimumUnit) { + RecordSet rs = new RecordSet(); + String fromtime = ""; + String totime = ""; + double D_flowMins = Util.getDoubleValue(flowMins); + String tmp_taskSignTime = signEndDate + " " + taskSignTime; + Map mutiMap = checkMultiSign(resourceId, taskDate, tmp_taskSignTime, fullFormatter, timesource); + String hasSign = Util.null2String(mutiMap.get("hasSign")); + Map> sourceMap = (Map>) mutiMap.get("sourceMap"); + String before_checkLastSignTime = ""; + String before_checkLastSignDate = ""; + double before_hasMins = 0.0; + + String after_checkLastSignTime = ""; + String after_checkLastSignDate = ""; + double after_hasMins = 0.0; + if (sourceMap.containsKey("before")) { + Map tmpMap = sourceMap.get("before"); + before_checkLastSignDate = Util.null2String(tmpMap.get("checkLastSignDate")); + before_checkLastSignTime = Util.null2String(tmpMap.get("checkLastSignTime")); + before_hasMins = Util.getDoubleValue(Util.null2String(tmpMap.get("hasMins")), 0.0); + } + if (sourceMap.containsKey("after")) { + Map tmpMap = sourceMap.get("after"); + after_checkLastSignDate = Util.null2String(tmpMap.get("checkLastSignDate")); + after_checkLastSignTime = Util.null2String(tmpMap.get("checkLastSignTime")); + after_hasMins = Util.getDoubleValue(Util.null2String(tmpMap.get("hasMins")), 0.0); + } + long hasMins = Long.parseLong(Util.null2String(mutiMap.get("hasMins"))); + + if ("1".equalsIgnoreCase(hasSign)) { + String checkLastSignTime = ""; + if (isBefore) { + checkLastSignTime = before_checkLastSignTime; + } else { + checkLastSignTime = after_checkLastSignTime; + } + if (checkLastSignTime.compareTo(signInTime4Out) > 0) { + fromtime = checkLastSignTime; + } else { + fromtime = signInTime4Out; + } + totime = taskSignTime; + if (hasMins >= D_flowMins) { + //如果已经生成过的加班数据已经大于等于流程时长了,那么此次的加班时长就是0 + mins = 0; + } else { + if (isBefore) { + //如果是上班前 当前的打卡时长+下班后已经生成过的加班时长,和流程总时长的比较 + double before_after_mins = mins + after_hasMins; + if (before_after_mins > D_flowMins) { + mins = (long) (D_flowMins - after_hasMins - before_hasMins); + } else { + mins = (long) (mins - before_hasMins); + } + } else { + //如果是下班后 当前的打卡时长+上班前已经生成过的加班时长,和流程总时长的比较 + double before_after_mins = mins + before_hasMins; + if (before_after_mins > D_flowMins) { + mins = (long) (D_flowMins - before_hasMins - after_hasMins); + } else { + mins = (long) (mins - after_hasMins); + } + } + } + } else { + fromtime = signInTime4Out; + totime = taskSignTime; + if (D_flowMins > 0 && mins > D_flowMins) { + //之前没有生成过加班 打卡加班时长不能超过流程时长 + mins = (long) D_flowMins; + } + } + mins = mins < 0 ? 0 : mins; + if (mins <= 0) { + return; + } + + String tiaoxiuId = KQBalanceOfLeaveBiz.addExtraAmountByDis5(resourceId, taskDate, mins + "", "0", "", requestid, "", taskDate, null); + if (Util.getIntValue(tiaoxiuId) > 0) { + kqLog.info("生成加班数据成功 doMode2ChangeType3:resourceId:" + resourceId + ":taskDate:" + taskDate + ":mins:" + mins); + } else { + kqLog.info("生成加班数据失败 doMode2ChangeType3:resourceId:" + resourceId + ":taskDate:" + taskDate + ":mins:" + mins); + } + String uuid = UUID.randomUUID().toString(); + String flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate,workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + boolean isUp = rs.executeUpdate(flow_overtime_sql, requestid, resourceId, signDate, fromtime, signEndDate, totime, mins, "", taskDate, "", unit, "3", paidLeaveEnable, "2", tiaoxiuId, uuid); + if (!isUp) { + kqLog.info("doMode2ChangeType3 加班数据记录失败!!!"); + } + + logMultiSign(resourceId, taskDate, taskSignTime, "", 0, signInTime4Out, mins, signEndDate, timesource, + uuid, tiaoxiuId); + } else { + kqLog.info("签到签退 生成加班数据为 doMode2ChangeType2:实际加班时长mins:" + mins + ":最小加班时长minimumUnit:" + minimumUnit + ":流程时长:Util.getDoubleValue(flowMins):" + Util.getDoubleValue(flowMins)); + } + + } else { + kqLog.info("签到签退 生成加班数据为 doMode2ChangeType3:taskSignTime:" + taskSignTime + ":signInTime4Out:" + signInTime4Out); + } + } else { + kqLog.info("签到签退 生成加班数据异常 doMode2ChangeType3:taskSignTime:" + taskSignTime + ":signInTime4Out:" + signInTime4Out); + } + + } + + /** + * 需审批,以打卡为准 + * 工作日 + * + * @param taskBean + * @param fullFormatter + * @param flowMins + */ + private void doMode2ChangeType2(KQTaskBean taskBean, DateTimeFormatter fullFormatter, + String flowMins) throws Exception { + String taskDate = taskBean.getTaskDate(); + String resourceId = taskBean.getResourceId(); + String taskSignTime = taskBean.getTaskSignTime(); + String lastWorkTime = taskBean.getLastWorkTime(); + String signDate = taskBean.getSignDate(); + String signEndDate = taskBean.getSignEndDate(); + String requestid = taskBean.getRequestId(); + String timesource = Util.null2String(taskBean.getTimesource()); + boolean isBefore = false; + if ("before".equalsIgnoreCase(timesource)) { + isBefore = true; + } + int workMins = taskBean.getWorkmins(); + if (taskSignTime.length() > 0 && lastWorkTime.length() > 0) { + if (lastWorkTime.length() == 5) { + lastWorkTime = lastWorkTime + ":00"; + } + String fromDateTime = signDate + " " + lastWorkTime; + String toDateTime = signEndDate + " " + taskSignTime; + int startTime = KQOvertimeRulesBiz.getStartTime(resourceId, taskDate); + startTime = startTime < 0 ? 0 : startTime; + if (isBefore) { + //上班前就不不需要考虑下班后多久算加班这个逻辑了 + startTime = 0; + } + long mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter).plusMinutes(startTime), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + if (mins > 0) { + String workingHours = Util.null2String(workMins / 60.0); + int minimumUnit = KQOvertimeRulesBiz.getMinimumLen(resourceId, taskDate); + int unit = KQOvertimeRulesBiz.getMinimumUnit(); + int paidLeaveEnable = KQOvertimeRulesBiz.getPaidLeaveEnable(resourceId, taskDate); + paidLeaveEnable = paidLeaveEnable == 1 ? 1 : 0; + if (mins >= minimumUnit && Util.getDoubleValue(flowMins) >= minimumUnit) { + RecordSet rs = new RecordSet(); + boolean isLateoutlatein = checkIsLateoutlatein(resourceId, taskDate); + if (!isLateoutlatein) { + String fromDate = ""; + String fromtime = ""; + String toDate = ""; + String totime = ""; + double D_flowMins = Util.getDoubleValue(flowMins); + String tmp_taskSignTime = signEndDate + " " + taskSignTime; + Map mutiMap = checkMultiSign(resourceId, taskDate, tmp_taskSignTime, fullFormatter, timesource); + String hasSign = Util.null2String(mutiMap.get("hasSign")); + Map> sourceMap = (Map>) mutiMap.get("sourceMap"); + String before_checkLastSignTime = ""; + String before_checkLastSignDate = ""; + String before_checkLastSignTimesource = ""; + double before_hasMins = 0.0; + + String after_checkLastSignTime = ""; + String after_checkLastSignDate = ""; + String after_checkLastSignTimesource = ""; + double after_hasMins = 0.0; + if (sourceMap.containsKey("before")) { + Map tmpMap = sourceMap.get("before"); + before_checkLastSignDate = Util.null2String(tmpMap.get("checkLastSignDate")); + before_checkLastSignTime = Util.null2String(tmpMap.get("checkLastSignTime")); + before_checkLastSignTimesource = Util.null2String(tmpMap.get("checkLastSignTimesource")); + before_hasMins = Util.getDoubleValue(Util.null2String(tmpMap.get("hasMins")), 0.0); + } + if (sourceMap.containsKey("after")) { + Map tmpMap = sourceMap.get("after"); + after_checkLastSignDate = Util.null2String(tmpMap.get("checkLastSignDate")); + after_checkLastSignTime = Util.null2String(tmpMap.get("checkLastSignTime")); + after_checkLastSignTimesource = Util.null2String(tmpMap.get("checkLastSignTimesource")); + after_hasMins = Util.getDoubleValue(Util.null2String(tmpMap.get("hasMins")), 0.0); + } + + long hasMins = Long.parseLong(Util.null2String(mutiMap.get("hasMins"))); + if ("1".equalsIgnoreCase(hasSign)) { + String checkLastSignTime = ""; + String checkLastSignDate = ""; + String checkLastSignTimesource = ""; + if (isBefore) { + checkLastSignTime = before_checkLastSignTime; + checkLastSignDate = before_checkLastSignDate; + checkLastSignTimesource = before_checkLastSignTimesource; + } else { + checkLastSignTime = after_checkLastSignTime; + checkLastSignDate = after_checkLastSignDate; + checkLastSignTimesource = after_checkLastSignTimesource; + } + if (isBefore) { + fromDate = signDate; + fromtime = lastWorkTime; + if ("before".equalsIgnoreCase(checkLastSignTimesource)) { + toDate = checkLastSignDate; + totime = checkLastSignTime; + } else { + String[] toDateTimes = toDateTime.split(" "); + if (toDateTimes.length == 2) { + toDate = toDateTimes[0]; + totime = toDateTimes[1]; + } + } + } else { + if (checkLastSignDate.length() > 0 && checkLastSignTime.length() > 0) { + fromDate = checkLastSignDate; + fromtime = checkLastSignTime; + } else { + fromDate = signDate; + fromtime = lastWorkTime; + } + toDate = signEndDate; + totime = taskSignTime; + } + + if (hasMins >= D_flowMins) { + //如果已经生成过的加班数据已经大于等于流程时长了,那么此次的加班时长就是0 + mins = 0; + } else { + if (isBefore) { + //如果是上班前 当前的打卡时长+下班后已经生成过的加班时长,和流程总时长的比较 + double before_after_mins = mins + after_hasMins; + if (before_after_mins > D_flowMins) { + mins = (long) (D_flowMins - after_hasMins - before_hasMins); + } else { + mins = (long) (mins - before_hasMins); + } + } else { + //如果是下班后 当前的打卡时长+上班前已经生成过的加班时长,和流程总时长的比较 + double before_after_mins = mins + before_hasMins; + if (before_after_mins > D_flowMins) { + mins = (long) (D_flowMins - before_hasMins - after_hasMins); + } else { + mins = (long) (mins - after_hasMins); + } + } + } + } else { + String[] fromDateTimes = fromDateTime.split(" "); + String[] toDateTimes = toDateTime.split(" "); + if (fromDateTimes.length == 2) { + fromDate = fromDateTimes[0]; + fromtime = fromDateTimes[1]; + } + if (toDateTimes.length == 2) { + toDate = toDateTimes[0]; + totime = toDateTimes[1]; + } + if (D_flowMins > 0 && mins > D_flowMins) { + //之前没有生成过加班 打卡加班时长不能超过流程时长 + mins = (long) D_flowMins; + } + } + mins = mins < 0 ? 0 : mins; + if (mins <= 0) { + return; + } + + String tiaoxiuId = KQBalanceOfLeaveBiz.addExtraAmountByDis5(resourceId, taskDate, mins + "", "0", workingHours, requestid, "", taskDate, null); + if (Util.getIntValue(tiaoxiuId) > 0) { + kqLog.info("生成加班数据为成功 doMode2ChangeType2:resourceId:" + resourceId + ":taskDate:" + taskDate + ":mins:" + mins + ":workingHours:" + workingHours); + } else { + kqLog.info("生成加班数据为失败 doMode2ChangeType2:resourceId:" + resourceId + ":taskDate:" + taskDate + ":mins:" + mins + ":workingHours:" + workingHours); + } + String uuid = UUID.randomUUID().toString(); + String flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate,workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + boolean isUp = rs.executeUpdate(flow_overtime_sql, requestid, resourceId, signDate, fromtime, signEndDate, totime, mins, "", taskDate, "", unit, "2", paidLeaveEnable, "2", tiaoxiuId, uuid); + if (!isUp) { + kqLog.info("doMode2ChangeType2 加班数据记录失败!!!"); + } + + logMultiSign(resourceId, taskDate, taskSignTime, lastWorkTime, 0, "", mins, signEndDate, timesource, + uuid, tiaoxiuId); + } + } else { + kqLog.info("签到签退 生成加班数据为 doMode2ChangeType2:实际加班时长mins:" + mins + ":最小加班时长minimumUnit:" + minimumUnit + ":流程时长:Util.getDoubleValue(flowMins):" + Util.getDoubleValue(flowMins)); + } + } else { + kqLog.info("签到签退 生成加班数据为 doMode2ChangeType2:fromDateTime:" + fromDateTime + ":toDateTime:" + toDateTime + ":mins:" + mins); + } + } else { + kqLog.info("签到签退 生成加班数据异常 doMode2ChangeType2:taskSignTime:" + taskSignTime + ":lastWorkTime:" + lastWorkTime); + } + + } + + /** + * 需审批,以打卡为准 + * 节假日 + * + * @param taskBean + * @param fullFormatter + * @param flowMins + */ + private void doMode2ChangeType1(KQTaskBean taskBean, DateTimeFormatter fullFormatter, + String flowMins) throws Exception { + String taskDate = taskBean.getTaskDate(); + String resourceId = taskBean.getResourceId(); + String taskSignTime = taskBean.getTaskSignTime(); + String signInTime4Out = taskBean.getSignInTime4Out(); + String requestid = taskBean.getRequestId(); + String signDate = taskBean.getSignDate(); + String signEndDate = taskBean.getSignEndDate(); + String timesource = Util.null2String(taskBean.getTimesource()); + boolean isBefore = false; + if ("before".equalsIgnoreCase(timesource)) { + isBefore = true; + } + if (taskSignTime.length() > 0 && signInTime4Out.length() > 0) { + + long mins = calNonWorkDuration(signInTime4Out, taskSignTime, taskDate, resourceId); + if (isBefore && signEndDate.compareTo(signDate) < 0) { + //打卡日期和归属日期不是同一天的话 + String fromDateTime = signEndDate + " " + signInTime4Out; + String toDateTime = signDate + " " + taskSignTime; +// 还需要交换一下开始日期和结束日期 + String tmpDate = signDate; + signDate = signEndDate; + signEndDate = tmpDate; + mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + } + if (mins > 0) { + int minimumUnit = KQOvertimeRulesBiz.getMinimumLen(resourceId, taskDate); + int unit = KQOvertimeRulesBiz.getMinimumUnit(); + int paidLeaveEnable = KQOvertimeRulesBiz.getPaidLeaveEnable(resourceId, taskDate); + paidLeaveEnable = paidLeaveEnable == 1 ? 1 : 0; + if (mins >= minimumUnit && Util.getDoubleValue(flowMins) >= minimumUnit) { + RecordSet rs = new RecordSet(); + String fromtime = ""; + String totime = ""; + double D_flowMins = Util.getDoubleValue(flowMins); + String tmp_taskSignTime = signEndDate + " " + taskSignTime; + Map mutiMap = checkMultiSign(resourceId, taskDate, tmp_taskSignTime, fullFormatter, timesource); + String hasSign = Util.null2String(mutiMap.get("hasSign")); + Map> sourceMap = (Map>) mutiMap.get("sourceMap"); + String before_checkLastSignTime = ""; + String before_checkLastSignDate = ""; + double before_hasMins = 0.0; + + String after_checkLastSignTime = ""; + String after_checkLastSignDate = ""; + double after_hasMins = 0.0; + if (sourceMap.containsKey("before")) { + Map tmpMap = sourceMap.get("before"); + before_checkLastSignDate = Util.null2String(tmpMap.get("checkLastSignDate")); + before_checkLastSignTime = Util.null2String(tmpMap.get("checkLastSignTime")); + before_hasMins = Util.getDoubleValue(Util.null2String(tmpMap.get("hasMins")), 0.0); + } + if (sourceMap.containsKey("after")) { + Map tmpMap = sourceMap.get("after"); + after_checkLastSignDate = Util.null2String(tmpMap.get("checkLastSignDate")); + after_checkLastSignTime = Util.null2String(tmpMap.get("checkLastSignTime")); + after_hasMins = Util.getDoubleValue(Util.null2String(tmpMap.get("hasMins")), 0.0); + } + long hasMins = Long.parseLong(Util.null2String(mutiMap.get("hasMins"))); + if ("1".equalsIgnoreCase(hasSign)) { + String checkLastSignTime = ""; + if (isBefore) { + checkLastSignTime = before_checkLastSignTime; + } else { + checkLastSignTime = after_checkLastSignTime; + } + if (checkLastSignTime.compareTo(signInTime4Out) > 0) { + fromtime = checkLastSignTime; + } else { + fromtime = signInTime4Out; + } + totime = taskSignTime; + if (hasMins >= D_flowMins) { + //如果已经生成过的加班数据已经大于等于流程时长了,那么此次的加班时长就是0 + mins = 0; + } else { + if (mins > D_flowMins) { + //如果打卡时长大于流程时长 + mins = (long) (D_flowMins - hasMins); + } else { + if (isBefore) { + //如果是上班前 当前的打卡时长+下班后已经生成过的加班时长,和流程总时长的比较 + double before_after_mins = mins + after_hasMins; + if (before_after_mins > D_flowMins) { + mins = (long) (D_flowMins - after_hasMins - before_hasMins); + } else { + mins = (long) (mins - before_hasMins); + } + } else { + //如果是下班后 当前的打卡时长+上班前已经生成过的加班时长,和流程总时长的比较 + double before_after_mins = mins + before_hasMins; + if (before_after_mins > D_flowMins) { + mins = (long) (D_flowMins - before_hasMins - after_hasMins); + } else { + mins = (long) (mins - after_hasMins); + } + } + } + } + } else { + fromtime = signInTime4Out; + totime = taskSignTime; + if (D_flowMins > 0 && mins > D_flowMins) { + //之前没有生成过加班 打卡加班时长不能超过流程时长 + mins = (long) D_flowMins; + } + } + mins = mins < 0 ? 0 : mins; + if (mins <= 0) { + return; + } + + String tiaoxiuId = KQBalanceOfLeaveBiz.addExtraAmountByDis5(resourceId, taskDate, mins + "", "0", "", requestid, "", taskDate, null); + if (Util.getIntValue(tiaoxiuId) > 0) { + kqLog.info("生成加班数据成功 doMode2ChangeType1:resourceId:" + resourceId + ":taskDate:" + taskDate + ":mins:" + mins); + } else { + kqLog.info("生成加班数据失败 doMode2ChangeType1:resourceId:" + resourceId + ":taskDate:" + taskDate + ":mins:" + mins); + } + + String uuid = UUID.randomUUID().toString(); + String flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate,workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + boolean isUp = rs.executeUpdate(flow_overtime_sql, requestid, resourceId, signDate, fromtime, signEndDate, totime, mins, "", taskDate, "", unit, "1", paidLeaveEnable, "2", tiaoxiuId, uuid); + if (!isUp) { + kqLog.info("doMode2ChangeType1 加班数据记录失败!!!"); + } + logMultiSign(resourceId, taskDate, taskSignTime, "", 0, signInTime4Out, mins, signEndDate, timesource, + uuid, tiaoxiuId); + } else { + kqLog.info("签到签退 生成加班数据为 doMode2ChangeType1:实际加班时长mins:" + mins + ":最小加班时长minimumUnit:" + minimumUnit + ":流程时长:Util.getDoubleValue(flowMins):" + Util.getDoubleValue(flowMins)); + } + + } else { + kqLog.info("签到签退 生成加班数据为 doMode2ChangeType1:taskSignTime:" + taskSignTime + ":signInTime4Out:" + signInTime4Out); + } + } else { + kqLog.info("签到签退 生成加班数据异常 doMode2ChangeType1:taskSignTime:" + taskSignTime + ":signInTime4Out:" + signInTime4Out); + } + + } + + /** + * 打卡计算非工作时长 + * + * @param fromTime + * @param toTime + * @param date + * @param resourceid + * @return + */ + private int calNonWorkDuration(String fromTime, String toTime, String date, String resourceid) { + fromTime = (fromTime.length() > 6 ? fromTime.substring(0, 5) : fromTime); + toTime = (toTime.length() > 6 ? toTime.substring(0, 5) : toTime); + + List restTimeList = KQOvertimeRulesBiz.getRestTimeList(resourceid, date); + KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo(); + int[] initArrays = arrayComInfo.getInitArr(); + int startIndex = 0; + int endIndex = 0; + startIndex = arrayComInfo.getArrayindexByTimes(fromTime); + endIndex = arrayComInfo.getArrayindexByTimes(toTime); + if (startIndex > endIndex) { + return 0; + } + + //先把要计算的时长填充上0 + Arrays.fill(initArrays, startIndex, endIndex, 0); + + //再把休息时间填充上去 + if (!restTimeList.isEmpty()) { + for (int i = 0; i < restTimeList.size(); i++) { + String[] restTimes = restTimeList.get(i); + if (restTimes.length == 2) { + int restStart = arrayComInfo.getArrayindexByTimes(restTimes[0]); + int restEnd = arrayComInfo.getArrayindexByTimes(restTimes[1]); + Arrays.fill(initArrays, restStart, restEnd, 1); + } + } + } + //最后排除掉休息时间还剩多少加班时长就是最终的结果 + int curMins = arrayComInfo.getCnt(initArrays, startIndex, endIndex + 1, 0); + + return curMins; + } + + /** + * 无需审批,根据打卡时间计算加班时长 + * + * @param taskBean + * @param fullFormatter + */ + private void doComputingMode3(KQTaskBean taskBean, + DateTimeFormatter fullFormatter) throws Exception { + String resourceId = taskBean.getResourceId(); + String taskDate = taskBean.getTaskDate(); + int changeType = KQOvertimeRulesBiz.getChangeType(resourceId, taskDate); +// 1-节假日、2-工作日、3-休息日 + if (changeType == 1) { + doMode3ChangeType1(taskBean, fullFormatter); + } + if (changeType == 2) { + doMode3ChangeType2(taskBean, fullFormatter); + } + if (changeType == 3) { + doMode3ChangeType3(taskBean, fullFormatter); + } + } + + /** + * 无需审批,根据打开时间计算加班时长 + * 休息日处理 + * + * @param taskBean + * @param fullFormatter + */ + private void doMode3ChangeType3(KQTaskBean taskBean, + DateTimeFormatter fullFormatter) throws Exception { + String taskDate = taskBean.getTaskDate(); + String resourceId = taskBean.getResourceId(); + String taskSignTime = taskBean.getTaskSignTime(); + String signInTime4Out = taskBean.getSignInTime4Out(); + String signDate = taskBean.getSignDate(); + String signEndDate = taskBean.getSignEndDate(); + String timesource = Util.null2String(taskBean.getTimesource()); + String up_tiaoxiuid = taskBean.getTiaoxiuId(); + boolean isBefore = false; + if ("before".equalsIgnoreCase(timesource)) { + isBefore = true; + } + if (taskSignTime.length() > 0 && signInTime4Out.length() > 0) { + + long mins = calNonWorkDuration(signInTime4Out, taskSignTime, taskDate, resourceId); + if (isBefore && signEndDate.compareTo(signDate) < 0) { + //打卡日期和归属日期不是同一天的话 + String fromDateTime = signEndDate + " " + signInTime4Out; + String toDateTime = signDate + " " + taskSignTime; +// 还需要交换一下开始日期和结束日期 + String tmpDate = signDate; + signDate = signEndDate; + signEndDate = tmpDate; + mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + } + if (mins > 0) { + RecordSet rs = new RecordSet(); + int minimumUnit = KQOvertimeRulesBiz.getMinimumLen(resourceId, taskDate); + int unit = KQOvertimeRulesBiz.getMinimumUnit(); + int paidLeaveEnable = KQOvertimeRulesBiz.getPaidLeaveEnable(resourceId, taskDate); + paidLeaveEnable = paidLeaveEnable == 1 ? 1 : 0; + if (mins >= minimumUnit) { + if (taskSignTime.length() == 5) { + taskSignTime += ":00"; + } + String tmp_taskSignTime = signEndDate + " " + taskSignTime; + Map mutiMap = checkMultiSign(resourceId, taskDate, tmp_taskSignTime, fullFormatter, timesource); + String hasSign = Util.null2String(mutiMap.get("hasSign")); + Map> sourceMap = (Map>) mutiMap.get("sourceMap"); + String before_checkLastSignTime = ""; + String before_checkLastSignDate = ""; + double before_hasMins = 0.0; + + String after_checkLastSignTime = ""; + String after_checkLastSignDate = ""; + double after_hasMins = 0.0; + if (sourceMap.containsKey("before")) { + Map tmpMap = sourceMap.get("before"); + before_checkLastSignDate = Util.null2String(tmpMap.get("checkLastSignDate")); + before_checkLastSignTime = Util.null2String(tmpMap.get("checkLastSignTime")); + before_hasMins = Util.getDoubleValue(Util.null2String(tmpMap.get("hasMins")), 0.0); + } + if (sourceMap.containsKey("after")) { + Map tmpMap = sourceMap.get("after"); + after_checkLastSignDate = Util.null2String(tmpMap.get("checkLastSignDate")); + after_checkLastSignTime = Util.null2String(tmpMap.get("checkLastSignTime")); + after_hasMins = Util.getDoubleValue(Util.null2String(tmpMap.get("hasMins")), 0.0); + } + long hasMins = Long.parseLong(Util.null2String(mutiMap.get("hasMins"))); + + String fromtime = ""; + String totime = ""; + if ("1".equalsIgnoreCase(hasSign)) { + String checkLastSignTime = ""; + if (isBefore) { + checkLastSignTime = before_checkLastSignTime; + } else { + checkLastSignTime = after_checkLastSignTime; + } + if (checkLastSignTime.compareTo(signInTime4Out) > 0) { + fromtime = checkLastSignTime; + } else { + fromtime = signInTime4Out; + } + totime = taskSignTime; + if (isBefore) { + mins = (long) (mins - before_hasMins); + } else { + mins = (long) (mins - after_hasMins); + } + } else { + fromtime = signInTime4Out; + totime = taskSignTime; + } + mins = mins < 0 ? 0 : mins; + + String tiaoxiuId = ""; + if (up_tiaoxiuid.length() > 0 && Util.getIntValue(up_tiaoxiuid) > 0) { + boolean is_tiaoxiuId = KQBalanceOfLeaveBiz.updateExtraAmountByDis5(up_tiaoxiuid, Util.getDoubleValue(mins + ""), ""); + tiaoxiuId = up_tiaoxiuid; + } else { + tiaoxiuId = KQBalanceOfLeaveBiz.addExtraAmountByDis5(resourceId, taskDate, mins + "", "0", "", "", "", taskDate, null); + } + if (Util.getIntValue(tiaoxiuId) > 0) { + kqLog.info("生成加班数据成功 doMode3ChangeType3:resourceId:" + resourceId + ":taskDate:" + taskDate + ":mins:" + mins); + } else { + kqLog.info("生成加班数据失败 doMode3ChangeType3:resourceId:" + resourceId + ":taskDate:" + taskDate + ":mins:" + mins); + } + + String uuid = UUID.randomUUID().toString(); + String flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate,workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + boolean isUp = rs.executeUpdate(flow_overtime_sql, "", resourceId, signDate, fromtime, signEndDate, totime, mins, "", taskDate, "", unit, "3", paidLeaveEnable, "3", tiaoxiuId, uuid); + if (!isUp) { + kqLog.info("doMode2ChangeType1 加班数据记录失败!!!"); + } + logMultiSign(resourceId, taskDate, taskSignTime, "", 0, signInTime4Out, mins, signEndDate, timesource, + uuid, tiaoxiuId); + + } else { + kqLog.info("签到签退 生成加班数据为 doMode3ChangeType3:实际加班时长mins:" + mins + ":最小加班时长minimumUnit:" + minimumUnit); + } + + } else { + kqLog.info("签到签退 生成加班数据为 doMode3ChangeType3:taskSignTime:" + taskSignTime + ":signInTime4Out:" + signInTime4Out); + } + } else { + kqLog.info("签到签退 生成加班数据异常 doMode3ChangeType3:taskSignTime:" + taskSignTime + ":signInTime4Out:" + signInTime4Out); + } + + } + + + /** + * 无需审批,根据打开时间计算加班时长 + * 工作日处理 + * + * @param taskBean + * @param fullFormatter + */ + private void doMode3ChangeType2(KQTaskBean taskBean, + DateTimeFormatter fullFormatter) throws Exception { + String taskDate = taskBean.getTaskDate(); + String resourceId = taskBean.getResourceId(); + String taskSignTime = taskBean.getTaskSignTime(); + String lastWorkTime = taskBean.getLastWorkTime(); + String signDate = taskBean.getSignDate(); + String signEndDate = taskBean.getSignEndDate(); + String timesource = taskBean.getTimesource(); + String up_tiaoxiuid = taskBean.getTiaoxiuId(); + boolean isBefore = false; + if ("before".equalsIgnoreCase(timesource)) { + isBefore = true; + } + int workMins = taskBean.getWorkmins(); + if (taskSignTime.length() > 0 && lastWorkTime.length() > 0) { + if (lastWorkTime.length() == 5) { + lastWorkTime = lastWorkTime + ":00"; + } + String fromDateTime = signDate + " " + lastWorkTime; + String toDateTime = signEndDate + " " + taskSignTime; + int startTime = KQOvertimeRulesBiz.getStartTime(resourceId, taskDate); + startTime = startTime < 0 ? 0 : startTime; + if (isBefore) { + //上班前就不不需要考虑下班后多久算加班这个逻辑了 + startTime = 0; + } + long mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter).plusMinutes(startTime), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + if (mins > 0) { + String workingHours = Util.null2String(workMins / 60.0); + int minimumUnit = KQOvertimeRulesBiz.getMinimumLen(resourceId, taskDate); + int unit = KQOvertimeRulesBiz.getMinimumUnit(); + int paidLeaveEnable = KQOvertimeRulesBiz.getPaidLeaveEnable(resourceId, taskDate); + paidLeaveEnable = paidLeaveEnable == 1 ? 1 : 0; + if (mins >= minimumUnit) { + if (taskSignTime.length() == 5) { + taskSignTime += ":00"; + } + RecordSet rs = new RecordSet(); + String tmp_taskSignTime = signEndDate + " " + taskSignTime; + Map mutiMap = checkMultiSign(resourceId, taskDate, tmp_taskSignTime, fullFormatter, timesource); + String hasSign = Util.null2String(mutiMap.get("hasSign")); + Map> sourceMap = (Map>) mutiMap.get("sourceMap"); + String before_checkLastSignTime = ""; + String before_checkLastSignDate = ""; + String before_checkLastSignTimesource = ""; + double before_hasMins = 0.0; + + String after_checkLastSignTime = ""; + String after_checkLastSignDate = ""; + String after_checkLastSignTimesource = ""; + double after_hasMins = 0.0; + if (sourceMap.containsKey("before")) { + Map tmpMap = sourceMap.get("before"); + before_checkLastSignDate = Util.null2String(tmpMap.get("checkLastSignDate")); + before_checkLastSignTime = Util.null2String(tmpMap.get("checkLastSignTime")); + before_checkLastSignTimesource = Util.null2String(tmpMap.get("checkLastSignTimesource")); + before_hasMins = Util.getDoubleValue(Util.null2String(tmpMap.get("hasMins")), 0.0); + } + if (sourceMap.containsKey("after")) { + Map tmpMap = sourceMap.get("after"); + after_checkLastSignDate = Util.null2String(tmpMap.get("checkLastSignDate")); + after_checkLastSignTime = Util.null2String(tmpMap.get("checkLastSignTime")); + after_checkLastSignTimesource = Util.null2String(tmpMap.get("checkLastSignTimesource")); + after_hasMins = Util.getDoubleValue(Util.null2String(tmpMap.get("hasMins")), 0.0); + } + long hasMins = Long.parseLong(Util.null2String(mutiMap.get("hasMins"))); + boolean isLateoutlatein = checkIsLateoutlatein(resourceId, taskDate); + if (!isLateoutlatein) { + String fromDate = ""; + String fromtime = ""; + String toDate = ""; + String totime = ""; + if ("1".equalsIgnoreCase(hasSign)) { + String checkLastSignTime = ""; + String checkLastSignDate = ""; + String checkLastSignTimesource = ""; + if (isBefore) { + checkLastSignTime = before_checkLastSignTime; + checkLastSignDate = before_checkLastSignDate; + checkLastSignTimesource = before_checkLastSignTimesource; + } else { + checkLastSignTime = after_checkLastSignTime; + checkLastSignDate = after_checkLastSignDate; + checkLastSignTimesource = after_checkLastSignTimesource; + } + if (isBefore) { + fromDate = signDate; + fromtime = lastWorkTime; + if ("before".equalsIgnoreCase(checkLastSignTimesource)) { + toDate = checkLastSignDate; + totime = checkLastSignTime; + } else { + String[] toDateTimes = toDateTime.split(" "); + if (toDateTimes.length == 2) { + toDate = toDateTimes[0]; + totime = toDateTimes[1]; + } + } + mins = (long) (mins - before_hasMins); + } else { + if (checkLastSignDate.length() > 0 && checkLastSignTime.length() > 0) { + fromDate = checkLastSignDate; + fromtime = checkLastSignTime; + } else { + fromDate = signDate; + fromtime = lastWorkTime; + } + toDate = signEndDate; + totime = taskSignTime; + mins = (long) (mins - after_hasMins); + } + } else { + String[] fromDateTimes = fromDateTime.split(" "); + String[] toDateTimes = toDateTime.split(" "); + if (fromDateTimes.length == 2) { + fromDate = fromDateTimes[0]; + fromtime = fromDateTimes[1]; + } + if (toDateTimes.length == 2) { + toDate = toDateTimes[0]; + totime = toDateTimes[1]; + } + } + mins = mins < 0 ? 0 : mins; + + String tiaoxiuId = ""; + if (up_tiaoxiuid.length() > 0 && Util.getIntValue(up_tiaoxiuid) > 0) { + boolean is_tiaoxiuId = KQBalanceOfLeaveBiz.updateExtraAmountByDis5(up_tiaoxiuid, Util.getDoubleValue(mins + ""), ""); + tiaoxiuId = up_tiaoxiuid; + } else { + tiaoxiuId = KQBalanceOfLeaveBiz.addExtraAmountByDis5(resourceId, taskDate, mins + "", "0", "", "", "", taskDate, null); + } + if (Util.getIntValue(tiaoxiuId) > 0) { + kqLog.info("生成加班数据成功 doMode3ChangeType2:resourceId:" + resourceId + ":taskDate:" + taskDate + ":mins:" + mins + ":workingHours:" + workingHours); + } else { + kqLog.info("生成加班数据失败 doMode3ChangeType2:resourceId:" + resourceId + ":taskDate:" + taskDate + ":mins:" + mins + ":workingHours:" + workingHours); + } + + String uuid = UUID.randomUUID().toString(); + String flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate,workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + boolean isUp = rs.executeUpdate(flow_overtime_sql, "", resourceId, fromDate, fromtime, toDate, totime, mins, "", taskDate, "", unit, "2", paidLeaveEnable, "3", tiaoxiuId, uuid); + if (!isUp) { + kqLog.info("doMode2ChangeType1 加班数据记录失败!!!"); + } + logMultiSign(resourceId, taskDate, taskSignTime, lastWorkTime, workMins, "", mins, signEndDate, timesource, + uuid, tiaoxiuId); + } + } else { + kqLog.info("签到签退 生成加班数据为 doMode3ChangeType2:实际加班时长mins:" + mins + ":最小加班时长minimumUnit:" + minimumUnit); + } + } else { + kqLog.info("签到签退 生成加班数据为 doMode3ChangeType2:fromDateTime:" + fromDateTime + ":toDateTime:" + toDateTime + ":mins:" + mins); + } + } else { + kqLog.info("签到签退 生成加班数据异常 doMode3ChangeType2:taskSignTime:" + taskSignTime + ":lastWorkTime:" + lastWorkTime); + } + + } + + /** + * 校验多次签退问题 + * + * @param taskSignTime 最新的签退日期时间 + * @param fullFormatter + */ + public Map checkMultiSign(String resourceId, String taskDate, String taskSignTime, DateTimeFormatter fullFormatter, String timesource) { + RecordSet rs = new RecordSet(); + Map mutiMap = new HashMap<>(); + long mins = 0L; + boolean hasSigned = false; + //倒数第二新的签退时间 + String signDate = ""; + String checkLastSignTime = ""; + String checkLastSignTimesource = ""; + Map> sourceMap = new HashMap<>(); + Map minsMap = new HashMap<>(); + Map datetimeMap = new HashMap<>(); + //已经生成了的加班时长 + long hasMins = 0L; + String checkSql = "select * from kq_overtime_signtask where resourceid=? and belongdate=? order by signdate ,signtime "; + rs.executeQuery(checkSql, resourceId, taskDate); + while (rs.next()) { + signDate = rs.getString("signdate"); + checkLastSignTime = rs.getString("signtime"); + checkLastSignTimesource = rs.getString("timesource"); + double tmp_mins = Util.getDoubleValue(rs.getString("mins"), 0.0); + hasMins += tmp_mins; + if (sourceMap.containsKey(checkLastSignTimesource)) { + Map tmp_minsMap = sourceMap.get(checkLastSignTimesource); + String tmp_hasMins = tmp_minsMap.get("hasMins"); + if (checkLastSignTimesource.equalsIgnoreCase("after")) { + tmp_minsMap.put("checkLastSignDate", signDate); + tmp_minsMap.put("checkLastSignTime", checkLastSignTime); + tmp_minsMap.put("checkLastSignTimesource", checkLastSignTimesource); + } else { + //before 上班前的时候,第一条就是最早的打卡时间所以后面不需要更新了 + } + double sourceMins = Util.getDoubleValue(tmp_hasMins, 0.0); + tmp_minsMap.put("hasMins", (tmp_mins + sourceMins) + ""); + } else { + minsMap = new HashMap<>(); + minsMap.put("hasMins", tmp_mins + ""); + minsMap.put("checkLastSignDate", signDate + ""); + minsMap.put("checkLastSignTime", checkLastSignTime + ""); + minsMap.put("checkLastSignTimesource", checkLastSignTimesource + ""); + sourceMap.put(checkLastSignTimesource, minsMap); + } + hasSigned = true; + } + mutiMap.put("hasSign", hasSigned ? "1" : "0"); + mutiMap.put("hasMins", "" + (hasMins <= 0 ? 0 : hasMins)); + mutiMap.put("sourceMap", sourceMap); + return mutiMap; + } + + /** + * 记录下多次签退生成加班数据问题 + * + * @param resourceId + * @param taskDate + * @param taskSignTime + * @param lastWorkTime + * @param workMins + * @param signInTime4Out + * @param mins + * @param signDate + * @param timesource + * @param uuid + * @param tiaoxiuId + */ + private void logMultiSign(String resourceId, String taskDate, String taskSignTime, + String lastWorkTime, int workMins, String signInTime4Out, long mins, String signDate, + String timesource, String uuid, String tiaoxiuId) throws Exception { + RecordSet rs = new RecordSet(); + String logSql = "insert into kq_overtime_signtask(resourceid,belongdate,signtime,lastworktime,workmins,signInTime4Out,mins,signDate,timesource,uuid,tiaoxiuId) values(?,?,?,?,?,?,?,?,?,?,?) "; + boolean isLog = false; + if ("before".equalsIgnoreCase(timesource)) { + isLog = rs.executeUpdate(logSql, resourceId, taskDate, lastWorkTime, taskSignTime, workMins, signInTime4Out, mins, signDate, timesource, uuid, tiaoxiuId); + } else { + isLog = rs.executeUpdate(logSql, resourceId, taskDate, taskSignTime, lastWorkTime, workMins, signInTime4Out, mins, signDate, timesource, uuid, tiaoxiuId); + } + + kqLog.info("记录下多次签退生成加班数据问题 logMultiSign:logSql:" + logSql + ":resourceId:" + resourceId + ":isLog:" + isLog + + ":taskDate:" + taskDate + ":taskSignTime:" + taskSignTime + ":lastWorkTime:" + lastWorkTime + ":workMins:" + workMins + ":signInTime4Out:" + + signInTime4Out + ":mins:" + mins + ":signDate:" + signDate + ":timesource:" + timesource); + + } + + /** + * 无需审批,根据打开时间计算加班时长 + * 节假日处理 + * + * @param taskBean + * @param fullFormatter + */ + private void doMode3ChangeType1(KQTaskBean taskBean, + DateTimeFormatter fullFormatter) throws Exception { + String taskDate = taskBean.getTaskDate(); + String resourceId = taskBean.getResourceId(); + String taskSignTime = taskBean.getTaskSignTime(); + String signInTime4Out = taskBean.getSignInTime4Out(); + String signDate = taskBean.getSignDate(); + String signEndDate = taskBean.getSignEndDate(); + String timesource = Util.null2String(taskBean.getTimesource()); + String up_tiaoxiuid = taskBean.getTiaoxiuId(); + boolean isBefore = false; + if ("before".equalsIgnoreCase(timesource)) { + isBefore = true; + } + if (taskSignTime.length() > 0 && signInTime4Out.length() > 0) { + + long mins = calNonWorkDuration(signInTime4Out, taskSignTime, taskDate, resourceId); + if (isBefore && signEndDate.compareTo(signDate) < 0) { + //打卡日期和归属日期不是同一天的话 + String fromDateTime = signEndDate + " " + signInTime4Out; + String toDateTime = signDate + " " + taskSignTime; +// 还需要交换一下开始日期和结束日期 + String tmpDate = signDate; + signDate = signEndDate; + signEndDate = tmpDate; + mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes(); + } + if (mins > 0) { + int minimumUnit = KQOvertimeRulesBiz.getMinimumLen(resourceId, taskDate); + int unit = KQOvertimeRulesBiz.getMinimumUnit(); + int paidLeaveEnable = KQOvertimeRulesBiz.getPaidLeaveEnable(resourceId, taskDate); + paidLeaveEnable = paidLeaveEnable == 1 ? 1 : 0; + if (mins >= minimumUnit) { + if (taskSignTime.length() == 5) { + taskSignTime += ":00"; + } + RecordSet rs = new RecordSet(); + String tmp_taskSignTime = signEndDate + " " + taskSignTime; + Map mutiMap = checkMultiSign(resourceId, taskDate, tmp_taskSignTime, fullFormatter, timesource); + String hasSign = Util.null2String(mutiMap.get("hasSign")); + Map> sourceMap = (Map>) mutiMap.get("sourceMap"); + String before_checkLastSignTime = ""; + String before_checkLastSignDate = ""; + double before_hasMins = 0.0; + + String after_checkLastSignTime = ""; + String after_checkLastSignDate = ""; + double after_hasMins = 0.0; + if (sourceMap.containsKey("before")) { + Map tmpMap = sourceMap.get("before"); + before_checkLastSignDate = Util.null2String(tmpMap.get("checkLastSignDate")); + before_checkLastSignTime = Util.null2String(tmpMap.get("checkLastSignTime")); + before_hasMins = Util.getDoubleValue(Util.null2String(tmpMap.get("hasMins")), 0.0); + } + if (sourceMap.containsKey("after")) { + Map tmpMap = sourceMap.get("after"); + after_checkLastSignDate = Util.null2String(tmpMap.get("checkLastSignDate")); + after_checkLastSignTime = Util.null2String(tmpMap.get("checkLastSignTime")); + after_hasMins = Util.getDoubleValue(Util.null2String(tmpMap.get("hasMins")), 0.0); + } + long hasMins = Long.parseLong(Util.null2String(mutiMap.get("hasMins"))); + + String fromtime = ""; + String totime = ""; + if ("1".equalsIgnoreCase(hasSign)) { + String checkLastSignTime = ""; + if (isBefore) { + checkLastSignTime = before_checkLastSignTime; + } else { + checkLastSignTime = after_checkLastSignTime; + } + if (checkLastSignTime.compareTo(signInTime4Out) > 0) { + fromtime = checkLastSignTime; + } else { + fromtime = signInTime4Out; + } + totime = taskSignTime; + if (isBefore) { + mins = (long) (mins - before_hasMins); + } else { + mins = (long) (mins - after_hasMins); + } + } else { + fromtime = signInTime4Out; + totime = taskSignTime; + } + mins = mins < 0 ? 0 : mins; + + String tiaoxiuId = ""; + if (up_tiaoxiuid.length() > 0 && Util.getIntValue(up_tiaoxiuid) > 0) { + boolean is_tiaoxiuId = KQBalanceOfLeaveBiz.updateExtraAmountByDis5(up_tiaoxiuid, Util.getDoubleValue(mins + ""), ""); + tiaoxiuId = up_tiaoxiuid; + } else { + tiaoxiuId = KQBalanceOfLeaveBiz.addExtraAmountByDis5(resourceId, taskDate, mins + "", "0", "", "", "", taskDate, null); + } + + if (Util.getIntValue(tiaoxiuId) > 0) { + kqLog.info("生成加班数据成功 doMode3ChangeType1:resourceId:" + resourceId + ":taskDate:" + taskDate + ":mins:" + mins); + } else { + kqLog.info("生成加班数据失败 doMode3ChangeType1:resourceId:" + resourceId + ":taskDate:" + taskDate + ":mins:" + mins); + } + String uuid = UUID.randomUUID().toString(); + String flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate,workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid)" + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + boolean isUp = rs.executeUpdate(flow_overtime_sql, "", resourceId, signDate, fromtime, signEndDate, totime, mins, "", taskDate, "", unit, "1", paidLeaveEnable, "3", tiaoxiuId, uuid); + if (!isUp) { + kqLog.info("doMode2ChangeType1 加班数据记录失败!!!"); + } + + logMultiSign(resourceId, taskDate, taskSignTime, "", 0, signInTime4Out, mins, signEndDate, timesource, uuid, tiaoxiuId); + } else { + kqLog.info("签到签退 生成加班数据为 doMode3ChangeType1:实际加班时长mins:" + mins + ":最小加班时长minimumUnit:" + minimumUnit); + } + + } else { + kqLog.info("签到签退 生成加班数据为 doMode3ChangeType1:taskSignTime:" + taskSignTime + ":signInTime4Out:" + signInTime4Out); + } + } else { + kqLog.info("签到签退 生成加班数据异常 doMode3ChangeType1:taskSignTime:" + taskSignTime + ":signInTime4Out:" + signInTime4Out); + } + + } + + /** + * 根据每一天的班次来拆分 + * + * @param splitBean + * @param splitBeans + * @return + */ + public void doSerialSplitList(SplitBean splitBean, List splitBeans) throws Exception { + String resourceid = splitBean.getResourceId(); + String fromDate = splitBean.getFromdatedb(); + String toDate = splitBean.getTodatedb(); + //哺乳假用到 + KQRepeatBean kqRepeatBean = KQRepeatLengthContext.getRepeatBean(); + if(kqRepeatBean != null){ + //流程上有重复时段,就不需要请假类型的重复时间了 + splitBean.setRepeatTime("0"); + } + + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate localToDate = LocalDate.parse(toDate); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate preFromDate = localFromDate.minusDays(1); + + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + DurationTypeEnum durationTypeEnum = splitBean.getDurationTypeEnum(); + + boolean shouldLog = true; + if (durationTypeEnum == DurationTypeEnum.COMMON_CAL) { + shouldLog = false; + } + if (shouldLog) { + kqLog.info("resourceid::" + resourceid + "::doSerialSplitList:" + (splitBean != null ? JSON.toJSONString(splitBean) : null)); + } + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + long betweenDays = localToDate.toEpochDay() - preFromDate.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + if(kqRepeatBean != null){ + if(i == 0){ + continue; + } + } + LocalDate curLocalDate = preFromDate.plusDays(i); + String splitDate = curLocalDate.format(dateFormatter); + ShiftInfoBean shiftInfoBean = null; + if (shouldLog) { + shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate, false); + } else { + shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate, false, false); + } + if (shouldLog) { + kqLog.info("resourceid::" + resourceid + "::splitDate:" + splitDate + ":shiftInfoBean:" + (shiftInfoBean != null ? JSON.toJSONString(shiftInfoBean) : null)); + } + int restShift = 0; + if (shiftInfoBean != null) { + restShift = shiftInfoBean.getRestShift(); + } + + int[] initArrays = kqTimesArrayComInfo.getInitArr(); + boolean isSplit = true; + if (shiftInfoBean != null && 1 != restShift) { + splitBean.setSerialid(Util.null2String(shiftInfoBean.getSerialid())); + if (!shiftInfoBean.isIsfree()) { + isSplit = commonShiftSplit(shiftInfoBean, splitBean, i, kqTimesArrayComInfo, initArrays, localFromDate, localToDate, betweenDays, shouldLog, is_flow_humanized); + if (!isSplit) { + continue; + } + } else { + isSplit = freeShiftSplit(shiftInfoBean, splitBean, i, kqTimesArrayComInfo, initArrays, localFromDate, localToDate, betweenDays); + if (!isSplit) { + continue; + } + } + //根据单位转换时长 + turnDuration(splitBean, false); + } else { + //非工作时长 + String computingMode = splitBean.getComputingMode(); + if ("2".equalsIgnoreCase(computingMode)) { + String filterholidays = splitBean.getFilterholidays(); + boolean is_filterholidays = check_filterholidays(filterholidays, resourceid, splitDate, i); + if (is_filterholidays) { + continue; + } + ShiftInfoBean preShiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, curLocalDate.minusDays(1).format(dateFormatter), false); + isSplit = nonWorkDaySplit(preShiftInfoBean, splitBean, i, kqTimesArrayComInfo, initArrays, localFromDate, localToDate, betweenDays); + if (!isSplit) { + continue; + } + //根据单位转换时长 + turnDuration(splitBean, true); + } else { + if (shouldLog) { + kqLog.info("resourceid::" + resourceid + "::doSerialSplitList splitDate:" + splitDate + ":resourceid:" + resourceid + "是非工作日"); + } + continue; + } + } + + SplitBean newsplitBean = new SplitBean(); + //然后把bean重新赋值下,根据拆分后的时间 + //BeanUtils.copyProperties(splitBean, newsplitBean); + BeanUtil.copyProperties(splitBean,newsplitBean); +// SplitBean newsplitBean = copySplitBean(splitBean); + newsplitBean.setFromDate(splitDate); + newsplitBean.setToDate(splitDate); + newsplitBean.setBelongDate(splitDate); + splitBeans.add(newsplitBean); + } + } + + public SplitBean copySplitBean(SplitBean splitBean) { + SplitBean newsplitBean = new SplitBean(); + if (null == splitBean) { + return newsplitBean; + } + newsplitBean.setRequestId(splitBean.getRequestId()); + newsplitBean.setLeavebackrequestid(splitBean.getLeavebackrequestid()); + newsplitBean.setWorkflowId(splitBean.getWorkflowId()); + newsplitBean.setUsedetail(splitBean.getUsedetail()); + newsplitBean.setDataId(splitBean.getDataId()); +// this.detailId = ""; + newsplitBean.setDetailId(splitBean.getDetailId()); +// this.resourceId = ""; + newsplitBean.setResourceId(splitBean.getResourceId()); +// this.fromDate = ""; + newsplitBean.setFromDate(splitBean.getFromDate()); +// this.fromTime = ""; + newsplitBean.setFromTime(splitBean.getFromTime()); +// this.toDate = ""; + newsplitBean.setToDate(splitBean.getToDate()); +// this.toTime = ""; + newsplitBean.setToTime(splitBean.getToTime()); +// this.newLeaveType = ""; + newsplitBean.setNewLeaveType(splitBean.getNewLeaveType()); +// this.duration = ""; + newsplitBean.setDuration(splitBean.getDuration()); +// this.pub_duration = ""; + newsplitBean.setPub_duration(splitBean.getPub_duration()); +// this.work_duration = ""; + newsplitBean.setWork_duration(splitBean.getWork_duration()); +// this.rest_duration = ""; + newsplitBean.setRest_duration(splitBean.getRest_duration()); +// this.tablenamedb = ""; + newsplitBean.setTablenamedb(splitBean.getTablenamedb()); +// this.fromdatedb = ""; + newsplitBean.setFromdatedb(splitBean.getFromdatedb()); +// this.fromtimedb = ""; + newsplitBean.setFromtimedb(splitBean.getFromtimedb()); +// this.todatedb = ""; + newsplitBean.setTodatedb(splitBean.getTodatedb()); +// this.totimedb = ""; + newsplitBean.setTotimedb(splitBean.getTotimedb()); +// this.durationDB = ""; + newsplitBean.setDurationDB(splitBean.getDurationDB()); +// this.durationrule = ""; + newsplitBean.setDurationrule(splitBean.getDurationrule()); +// this.computingMode = ""; + newsplitBean.setComputingMode(splitBean.getComputingMode()); +// this.vacationInfo = ""; + newsplitBean.setVacationInfo(splitBean.getVacationInfo()); +// this.status = ""; + newsplitBean.setStatus(splitBean.getStatus()); +// this.companion = ""; + newsplitBean.setCompanion(splitBean.getCompanion()); +// this.belongDate = ""; + newsplitBean.setBelongDate(splitBean.getBelongDate()); +// D_Mins = 0; + newsplitBean.setD_Mins(splitBean.getD_Mins()); +// this.serialid = ""; + newsplitBean.setSerialid(splitBean.getSerialid()); +// this.changeType = 0; + newsplitBean.setChangeType(splitBean.getChangeType()); +// this.preChangeType = 0; + newsplitBean.setPreChangeType(splitBean.getPreChangeType()); +// this.subcompanyid = ""; + newsplitBean.setSubcompanyid(splitBean.getSubcompanyid()); +// this.departmentid = ""; + newsplitBean.setDepartmentid(splitBean.getDepartmentid()); +// this.jobtitle = ""; + newsplitBean.setJobtitle(splitBean.getJobtitle()); +// this.durationTypeEnum + newsplitBean.setDurationTypeEnum(splitBean.getDurationTypeEnum()); +// this.workmins = 0; + newsplitBean.setWorkmins(splitBean.getWorkmins()); +// this.oneDayHour = 0.0; + newsplitBean.setOneDayHour(splitBean.getOneDayHour()); +// this.groupid = ""; + newsplitBean.setGroupid(splitBean.getGroupid()); +// this.timeselection = "1"; + newsplitBean.setTimeselection(splitBean.getTimeselection()); +// processChangeSplitBean = new ProcessChangeSplitBean(); + newsplitBean.setProcessChangeSplitBean(splitBean.getProcessChangeSplitBean()); +// this.iscompanion = ""; + newsplitBean.setIscompanion(splitBean.getIscompanion()); +// this.filterholidays = ""; + newsplitBean.setFilterholidays(splitBean.getFilterholidays()); +// this.overtime_type = ""; + newsplitBean.setOvertime_type(splitBean.getOvertime_type()); +// this.duration_type = ""; +// newsplitBean.setDuration_type(splitBean.getDuration_type()); +// this.conversion = ""; + newsplitBean.setConversion(splitBean.getConversion()); +// this.overtimeBalanceTimeBeans = Lists.newArrayList(); + newsplitBean.setOvertimeBalanceTimeBeans(splitBean.getOvertimeBalanceTimeBeans()); + newsplitBean.setRepeatTime(splitBean.getRepeatTime()); + + return newsplitBean; + } + + /** + * 监测按照自然日计算,根据排除休息日和节假日的设置,判断当前自然日是否需要排除计算 + * + * @param filterholidays + * @param resourceid + * @param splitDate + * @param i + */ + public boolean check_filterholidays(String filterholidays, String resourceid, String splitDate, + int i) { + boolean is_filterholidays = false; + if (i == 0) { + return is_filterholidays; + } + if (Util.null2String(filterholidays).length() > 0) { + List filterholidayList = Arrays.asList(filterholidays.split(",")); + if (filterholidayList != null && !filterholidayList.isEmpty()) { + //日期类型:1-节假日、2-工作日、3-休息日(节假日设置的优先级高于考勤组中的设置) + int changeType = KQOvertimeRulesBiz.getChangeType(resourceid, splitDate); + if (filterholidayList.contains("1")) { + //排除节假日 + if (filterholidayList.contains("2")) { + //排除休息日 + if (changeType == 3 || changeType == 1) { + is_filterholidays = true; + } + } else { + if (changeType == 1) { + is_filterholidays = true; + } + } + } else if (filterholidayList.contains("2")) { + //排除休息日 + if (changeType == 3) { + is_filterholidays = true; + } + } else { + //不排除休息日,也不排除节假日 + } + } + } + return is_filterholidays; + } + + /** + * 自由工时的流程数据拆分 + * + * @param shiftInfoBean + * @param splitBean + * @param i + * @param kqTimesArrayComInfo + * @param initArrays + * @param localFromDate + * @param localToDate + * @param betweenDays + * @return + */ + public boolean freeShiftSplit(ShiftInfoBean shiftInfoBean, SplitBean splitBean, int i, KQTimesArrayComInfo kqTimesArrayComInfo, int[] initArrays, LocalDate localFromDate, LocalDate localToDate, + long betweenDays) { + + String fromTime = splitBean.getFromtimedb(); + String toTime = splitBean.getTotimedb(); + int fromtimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromTime); + int totimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(toTime); + int flowbegintimeIndex = -1; + int flowendtimeIndex = -1; + + String fromtimedbOri = splitBean.getFromtimedb(); + String totimedbOri = splitBean.getTotimedb(); + String repeatTime = "0"; + DurationTypeEnum durationTypeEnum = splitBean.getDurationTypeEnum(); + if(DurationTypeEnum.LEAVE == durationTypeEnum || DurationTypeEnum.LEAVEBACK == durationTypeEnum){ + repeatTime = splitBean.getRepeatTime(); + } + + boolean isSplit = true; + String freeSignStart = shiftInfoBean.getFreeSignStart(); + String freeSignEnd = shiftInfoBean.getFreeSignEnd(); + if (freeSignStart.length() == 0) { + shiftInfoBean.setD_Mins(0.0); + isSplit = false; + return isSplit; + } + int freeSignStartIndex = kqTimesArrayComInfo.getArrayindexByTimes(freeSignStart); + int freeSignEndIndex = kqTimesArrayComInfo.getArrayindexByTimes(freeSignEnd); + int freeWorkMins = Util.getIntValue(shiftInfoBean.getFreeWorkMins()); + if (i == 0) { + isSplit = false; + return isSplit; + } else { + if (localFromDate.isEqual(localToDate)) { + if (fromtimeIndex > freeSignStartIndex) { + flowbegintimeIndex = fromtimeIndex; + flowendtimeIndex = totimeIndex; + } else { + flowbegintimeIndex = freeSignStartIndex; + flowendtimeIndex = totimeIndex; + } + } else { + if (i == 1) { + if (fromtimeIndex > freeSignStartIndex) { + flowbegintimeIndex = fromtimeIndex; + flowendtimeIndex = 1440; + } else { + flowbegintimeIndex = freeSignStartIndex; + flowendtimeIndex = 1440; + } + } else if (i == betweenDays) { + if (totimeIndex > freeSignStartIndex) { + flowbegintimeIndex = freeSignStartIndex; + flowendtimeIndex = totimeIndex; + } else { + isSplit = false; + return isSplit; + } + } else { + flowbegintimeIndex = freeSignStartIndex; + flowendtimeIndex = freeSignEndIndex; + } + } + } + kqLog.info("resourceid::" + splitBean.getResourceId() + "::自由班制 isSplit之前 i::" + i + "::flowbegintimeIndex:" + flowbegintimeIndex + ":flowendtimeIndex:" + flowendtimeIndex); + + if (isSplit) { + String splitFromTime = kqTimesArrayComInfo.getTimesByArrayindex(flowbegintimeIndex); + String splitToTime = kqTimesArrayComInfo.getTimesByArrayindex(flowendtimeIndex); + if("1".equals(repeatTime)) { + int flowbegintimeIndexO = kqTimesArrayComInfo.getArrayindexByTimes(fromtimedbOri); + int flowendtimeIndexO = kqTimesArrayComInfo.getArrayindexByTimes(totimedbOri); + if(flowbegintimeIndexO > flowbegintimeIndex){ + flowbegintimeIndex = flowbegintimeIndexO; + splitFromTime = kqTimesArrayComInfo.getTimesByArrayindex(flowbegintimeIndex); + } + if(flowendtimeIndexO < flowendtimeIndex){ + flowendtimeIndex = flowendtimeIndexO; + splitToTime = kqTimesArrayComInfo.getTimesByArrayindex(flowendtimeIndex); + } + } + int flowMins = flowendtimeIndex - flowbegintimeIndex; + flowMins = flowMins > freeWorkMins ? freeWorkMins : flowMins; + flowMins = flowMins > 0 ? flowMins : 0; + if (flowMins < 0) { + kqLog.info("resourceid::" + splitBean.getResourceId() + "::自由班制 不记录中间表 i::" + i + "::flowbegintimeIndex:" + flowbegintimeIndex + ":flowendtimeIndex:" + flowendtimeIndex + ":flowMins:" + flowMins); + return false; + } + splitBean.setD_Mins(flowMins); + splitBean.setWorkmins(freeWorkMins); + splitBean.setOneDayHour((freeWorkMins / 60.0)); + splitBean.setFromTime(splitFromTime); + splitBean.setToTime(splitToTime); + } + return isSplit; + } + + /** + * 非工作时长(自然日计算的) + * + * @param preShiftInfoBean + * @param splitBean + * @param i + * @param kqTimesArrayComInfo + * @param initArrays + * @param localFromDate + * @param localToDate + * @param betweenDays + * @return + */ + public boolean nonWorkDaySplit(ShiftInfoBean preShiftInfoBean, SplitBean splitBean, int i, + KQTimesArrayComInfo kqTimesArrayComInfo, int[] initArrays, LocalDate localFromDate, + LocalDate localToDate, long betweenDays) { + + boolean isSplit = true; + if (preShiftInfoBean != null) { + String isAcross = preShiftInfoBean.getIsAcross(); + if ("1".equalsIgnoreCase(isAcross)) { + List workAcrossIndex = preShiftInfoBean.getWorkAcrossIndex(); + if (workAcrossIndex != null && !workAcrossIndex.isEmpty()) { + int[] workIndexs = workAcrossIndex.get(workAcrossIndex.size() - 1); + return nonWorkDayCommonSplit(splitBean, i, kqTimesArrayComInfo, localFromDate, localToDate, betweenDays, workIndexs[1]); + } + } else { + return nonWorkDayCommonSplit(splitBean, i, kqTimesArrayComInfo, localFromDate, localToDate, betweenDays, -1); + } + } else { + return nonWorkDayCommonSplit(splitBean, i, kqTimesArrayComInfo, localFromDate, localToDate, betweenDays, -1); + } + + return isSplit; + } + + /** + * 非工作时长(自然日计算的) + * + * @param splitBean + * @param i + * @param kqTimesArrayComInfo + * @param localFromDate + * @param localToDate + * @param betweenDays + * @param preLastWorkIndex 如果前一天跨天,前一天最晚的下班时间 + * @return + */ + public boolean nonWorkDayCommonSplit(SplitBean splitBean, int i, + KQTimesArrayComInfo kqTimesArrayComInfo, LocalDate localFromDate, + LocalDate localToDate, long betweenDays, int preLastWorkIndex) { + boolean isSplit = true; + + String fromtimedbOri = splitBean.getFromtimedb(); + String totimedbOri = splitBean.getTotimedb(); + String repeatTime = "0"; + DurationTypeEnum durationTypeEnum = splitBean.getDurationTypeEnum(); + if(DurationTypeEnum.LEAVE == durationTypeEnum || DurationTypeEnum.LEAVEBACK == durationTypeEnum){ + repeatTime = splitBean.getRepeatTime(); + } + String fromTime = splitBean.getFromtimedb(); + String toTime = splitBean.getTotimedb(); + int fromtimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromTime); + int totimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(toTime); + int flowbegintimeIndex = -1; + int flowendtimeIndex = -1; + + if (i == 0) { + isSplit = false; + return isSplit; + } else { + if (localFromDate.isEqual(localToDate)) { + flowbegintimeIndex = fromtimeIndex; + flowendtimeIndex = totimeIndex; + } else { + if (i == 1) { + flowbegintimeIndex = fromtimeIndex; + flowendtimeIndex = 1440; + } else if (i == betweenDays) { + flowbegintimeIndex = 0; + flowendtimeIndex = totimeIndex; + } else { + flowbegintimeIndex = 0; + flowendtimeIndex = 1440; + } + } + } + if (isSplit) { + String splitFromTime = kqTimesArrayComInfo.getTimesByArrayindex(flowbegintimeIndex); + if (preLastWorkIndex > 0) { + if (preLastWorkIndex > flowbegintimeIndex) { + flowbegintimeIndex = preLastWorkIndex; + } + } + if("1".equals(repeatTime)){ + int flowbegintimeIndexO = kqTimesArrayComInfo.getArrayindexByTimes(fromtimedbOri); + int flowendtimeIndexO = kqTimesArrayComInfo.getArrayindexByTimes(totimedbOri); + if(flowbegintimeIndexO > flowbegintimeIndex){ + flowbegintimeIndex = flowbegintimeIndexO; + } + if(flowendtimeIndexO < flowendtimeIndex){ + flowendtimeIndex = flowendtimeIndexO; + } + } + if ("2".equalsIgnoreCase(splitBean.getDurationrule())) { + if ("2".equalsIgnoreCase(splitBean.getTimeselection())) { + return WorkHalfUnitSplitChain.getSplitDurationBean4NonTime(kqTimesArrayComInfo, splitBean, flowbegintimeIndex, flowendtimeIndex); + } + } else { + splitFromTime = kqTimesArrayComInfo.getTimesByArrayindex(flowbegintimeIndex); + String splitToTime = kqTimesArrayComInfo.getTimesByArrayindex(flowendtimeIndex); + int flowMins = flowendtimeIndex - flowbegintimeIndex; + flowMins = flowMins > 0 ? flowMins : 0; + splitBean.setD_Mins(flowMins); + splitBean.setFromTime(splitFromTime); + splitBean.setToTime(splitToTime); + } + } + return isSplit; + } + + /** + * 固定班制和排班制的数据拆分 + * + * @param shiftInfoBean + * @param splitBean + * @param i + * @param kqTimesArrayComInfo + * @param initArrays + * @param localFromDate + * @param localToDate + * @param betweenDays + * @param shouldLog + * @return + */ + + public boolean commonShiftSplit(ShiftInfoBean shiftInfoBean, SplitBean splitBean, int i, + KQTimesArrayComInfo kqTimesArrayComInfo, int[] initArrays, LocalDate localFromDate, + LocalDate localToDate, long betweenDays, boolean shouldLog) { + return commonShiftSplit(shiftInfoBean, splitBean, i, kqTimesArrayComInfo, initArrays, localFromDate, localToDate, betweenDays, shouldLog, false); + } + + public boolean commonShiftSplit(ShiftInfoBean shiftInfoBean, SplitBean splitBean, int i, + KQTimesArrayComInfo kqTimesArrayComInfo, int[] initArrays, LocalDate localFromDate, + LocalDate localToDate, long betweenDays, boolean shouldLog, boolean is_flow_humanized) { + + boolean isSplit = true; + + String fromTime = splitBean.getFromtimedb(); + String toTime = splitBean.getTotimedb(); + String fromtimedbOri = splitBean.getFromtimedb(); + String totimedbOri = splitBean.getTotimedb(); + String repeatTime = "0"; + DurationTypeEnum durationTypeEnum = splitBean.getDurationTypeEnum(); + if(DurationTypeEnum.LEAVE == durationTypeEnum || DurationTypeEnum.LEAVEBACK == durationTypeEnum){ + repeatTime = splitBean.getRepeatTime(); + } + + int fromtimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromTime); + int totimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(toTime); + int flowbegintimeIndex = -1; + int flowendtimeIndex = -1; + + String isAcross = shiftInfoBean.getIsAcross(); + List real_allLongWorkTime = Lists.newArrayList(); + List allLongWorkTime = shiftInfoBean.getAllLongWorkTime(); + CollectionUtils.addAll(real_allLongWorkTime, new Object[allLongWorkTime.size()]); + Collections.copy(real_allLongWorkTime, allLongWorkTime); + + List real_workLongTimeIndex = Lists.newArrayList(); + List workLongTimeIndex = shiftInfoBean.getWorkLongTimeIndex(); + + //list带数组,这里要深拷贝 + for (int[] tmp : workLongTimeIndex) { + int[] real_tmp = new int[tmp.length]; + System.arraycopy(tmp, 0, real_tmp, 0, tmp.length); + real_workLongTimeIndex.add(real_tmp); + } + List restLongTimeIndex = shiftInfoBean.getRestLongTimeIndex(); + if (real_allLongWorkTime == null || real_allLongWorkTime.isEmpty()) { + isSplit = false; + return isSplit; + } + + if (real_workLongTimeIndex.size() == 1) { + KQShiftRuleInfoBiz kqShiftRuleInfoBiz = new KQShiftRuleInfoBiz(); + kqShiftRuleInfoBiz.rest_workLongTimeIndex(shiftInfoBean, splitBean, real_workLongTimeIndex, kqTimesArrayComInfo, real_allLongWorkTime, is_flow_humanized); + } + + //如果不跨天 + if (!isAcross.equalsIgnoreCase("1")) { + //如果是请假开始日期的前一天 + if (i == 0) { + isSplit = false; + return isSplit; + } else { + int firstTime = kqTimesArrayComInfo.getArrayindexByTimes(real_allLongWorkTime.get(0)); + int lastTime = kqTimesArrayComInfo.getArrayindexByTimes(real_allLongWorkTime.get(real_allLongWorkTime.size() - 1)); + + if (localFromDate.isEqual(localToDate)) { + flowbegintimeIndex = fromtimeIndex; + flowendtimeIndex = totimeIndex; + } else { + if (i == 1) { + flowbegintimeIndex = fromtimeIndex; + flowendtimeIndex = lastTime; + } else if (i == betweenDays) { + flowbegintimeIndex = firstTime; + flowendtimeIndex = totimeIndex; + } else { + flowbegintimeIndex = firstTime; + flowendtimeIndex = lastTime; + } + } + //工作时段里填充上1 + for (int j = 0; real_workLongTimeIndex != null && j < real_workLongTimeIndex.size(); j++) { + int[] longtimeIndexs = real_workLongTimeIndex.get(j); + Arrays.fill(initArrays, longtimeIndexs[0], longtimeIndexs[1], 1); + } + for (int j = 0; restLongTimeIndex != null && j < restLongTimeIndex.size(); j++) { + int[] resttimeIndexs = restLongTimeIndex.get(j); + Arrays.fill(initArrays, resttimeIndexs[0], resttimeIndexs[1], -1); + } + } + + + } else { + int firstTime = kqTimesArrayComInfo.getArrayindexByTimes(real_allLongWorkTime.get(0)); + //lasttime一定是跨天的 + int lastTime = kqTimesArrayComInfo.getArrayindexByTimes(real_allLongWorkTime.get(real_allLongWorkTime.size() - 1)); + if (i == 0) { + int fromtimeIndex48 = kqTimesArrayComInfo.turn24to48TimeIndex(fromtimeIndex); + int totimeIndex48 = kqTimesArrayComInfo.turn24to48TimeIndex(totimeIndex); + if (fromtimeIndex48 < lastTime) { + flowbegintimeIndex = fromtimeIndex48; + if (localFromDate.isEqual(localToDate)) { + if (totimeIndex48 < lastTime) { + flowendtimeIndex = totimeIndex48; + } else { + flowendtimeIndex = lastTime; + } + } else { + if (betweenDays == 2) { + //流程上开始日期和结束日期就相差一天 + if ((totimeIndex48 + 1440) < lastTime) { + flowendtimeIndex = totimeIndex48; + } else { + flowendtimeIndex = lastTime; + } + } else { + //流程上开始日期和结束日期相差超过1天 + flowendtimeIndex = lastTime; + } + + } + } else { + isSplit = false; + return isSplit; + } + } else { + if (localFromDate.isEqual(localToDate)) { + flowbegintimeIndex = fromtimeIndex; + flowendtimeIndex = totimeIndex; + } else { + if (i == 1) { + flowbegintimeIndex = fromtimeIndex; + if ((i + 1) == (betweenDays)) { + int totimeIndex48 = kqTimesArrayComInfo.turn24to48TimeIndex(totimeIndex); + if (totimeIndex48 < lastTime) { + flowendtimeIndex = totimeIndex48; + } else { + flowendtimeIndex = lastTime; + } + } else { + flowendtimeIndex = lastTime; + } + } else if (i == (betweenDays - 1)) { + flowbegintimeIndex = firstTime; + int totimeIndex48 = kqTimesArrayComInfo.turn24to48TimeIndex(totimeIndex); + if (totimeIndex48 < lastTime) { + flowendtimeIndex = totimeIndex48; + } else { + flowendtimeIndex = lastTime; + } + } else if (i == betweenDays) { + flowbegintimeIndex = firstTime; + flowendtimeIndex = totimeIndex; + if (firstTime > totimeIndex) { + isSplit = false; + return isSplit; + } + } else { + flowbegintimeIndex = firstTime; + flowendtimeIndex = lastTime; + if (firstTime > lastTime) { + isSplit = false; + return isSplit; + } + } + } + } + //工作时段里填充上1 + for (int j = 0; j < real_workLongTimeIndex.size(); j++) { + int[] longtimeIndexs = real_workLongTimeIndex.get(j); + Arrays.fill(initArrays, longtimeIndexs[0], longtimeIndexs[1], 1); + + } + for (int j = 0; j < restLongTimeIndex.size(); j++) { + int[] resttimeIndexs = restLongTimeIndex.get(j); + Arrays.fill(initArrays, resttimeIndexs[0], resttimeIndexs[1], -1); + } + } + if (isSplit) { + + if ("2".equalsIgnoreCase(splitBean.getDurationrule())) { + if ("2".equalsIgnoreCase(splitBean.getTimeselection())) { + return WorkHalfUnitSplitChain.getSplitDurationBean4Time(initArrays, shiftInfoBean, kqTimesArrayComInfo, splitBean, flowbegintimeIndex, flowendtimeIndex); + } + } else { + String splitFromTime = kqTimesArrayComInfo.getTimesByArrayindex(flowbegintimeIndex); + String splitToTime = kqTimesArrayComInfo.getTimesByArrayindex(flowendtimeIndex); + int flowMins = kqTimesArrayComInfo.getCnt(initArrays, flowbegintimeIndex, flowendtimeIndex, 1); + if("1".equals(repeatTime)){ + flowMins = 0; + int flowbegintimeIndexO = kqTimesArrayComInfo.getArrayindexByTimes(fromtimedbOri); + int flowendtimeIndexO = kqTimesArrayComInfo.getArrayindexByTimes(totimedbOri); + if(flowbegintimeIndexO < flowbegintimeIndex){ + flowbegintimeIndexO = flowbegintimeIndex; + } + if(flowendtimeIndexO > flowendtimeIndex){ + flowendtimeIndexO = flowendtimeIndex; + } + int flowMinsO = kqTimesArrayComInfo.getCnt(initArrays, flowbegintimeIndexO, flowendtimeIndexO, 1); + if(flowMinsO > 0){ + splitFromTime = fromtimedbOri; + splitToTime = totimedbOri; + flowMins += flowMinsO; + } + //还有跨天的情况 + int flowbegintimeIndexN = kqTimesArrayComInfo.getArrayindexByTimes(kqTimesArrayComInfo.turn24to48Time(fromtimedbOri)); + int flowendtimeIndexN = kqTimesArrayComInfo.getArrayindexByTimes(kqTimesArrayComInfo.turn24to48Time(totimedbOri)); + if(flowbegintimeIndexN < flowbegintimeIndex){ + flowbegintimeIndexN = flowbegintimeIndex; + } + if(flowendtimeIndexN > flowendtimeIndex){ + flowendtimeIndexN = flowendtimeIndex; + } + int flowMinsN = kqTimesArrayComInfo.getCnt(initArrays, flowbegintimeIndexN, flowendtimeIndexN, 1); + if(flowMinsN > 0){ + splitFromTime = kqTimesArrayComInfo.turn24to48Time(fromtimedbOri); + splitToTime = kqTimesArrayComInfo.turn24to48Time(totimedbOri); + flowMins += flowMinsN; + } + } + if (shouldLog) { + kqLog.info("resourceid:" + splitBean.getResourceId() + ":::i::" + i + "::flowbegintimeIndex:" + flowbegintimeIndex + ":flowendtimeIndex:" + flowendtimeIndex + ":flowMins:" + flowMins); + } + flowMins = flowMins > 0 ? flowMins : 0; + if (flowMins < 0) { + if (shouldLog) { + kqLog.info("resourceid:" + splitBean.getResourceId() + ":::不记录中间表 i::" + i + "::flowbegintimeIndex:" + flowbegintimeIndex + ":flowendtimeIndex:" + flowendtimeIndex + ":flowMins:" + flowMins); + } + return false; + } + splitBean.setD_Mins(flowMins); + splitBean.setWorkmins(shiftInfoBean.getWorkmins()); + splitBean.setFromTime(splitFromTime); + splitBean.setToTime(splitToTime); + String repeatType = splitBean.getRepeatType(); + if(StringUtils.isNotEmpty(repeatType)){ + if(CollectionUtils.isNotEmpty(real_workLongTimeIndex)){ + int startIdx = real_workLongTimeIndex.get(0)[0]; + int endIdx = real_workLongTimeIndex.get(real_workLongTimeIndex.size()-1)[1]; + splitBean.setFromtimedb(kqTimesArrayComInfo.getTimesByArrayindex(startIdx)); + splitBean.setTotimedb(kqTimesArrayComInfo.getTimesByArrayindex(endIdx)); + splitBean.setFromTime("00:00"); + splitBean.setToTime("00:00"); + } + } + splitBean.setConvertAttendDay(shiftInfoBean.getConvertAttendDay()); + } + + } + return isSplit; + } + + /** + * 根据单位来转换时长 + * + * @param splitBean + * @param isComputingMode2 是否按照自然日计算 + */ + private void turnDuration(SplitBean splitBean, boolean isComputingMode2) { + //哺乳假用到 + KQRepeatBean kqRepeatBean = KQRepeatLengthContext.getRepeatBean(); + if(kqRepeatBean != null){ + Long repeatMins = getRepeatMins(kqRepeatBean); + if(repeatMins != null && repeatMins > 0){ + splitBean.setD_Mins(repeatMins); + } + } + String durationrule = splitBean.getDurationrule(); + + //计算规则 1-按天请假 2-按半天请假 3-按小时请假 4-按整天请假 5半小时 6整小时 + //按照天和小时的可以在这里计算,半天的和整天的单独处理 + if ("1".equalsIgnoreCase(durationrule)) { + durationrule1(splitBean, isComputingMode2); + } else if ("3".equalsIgnoreCase(durationrule)) { + durationrule3(splitBean, isComputingMode2); + } else if ("5".equalsIgnoreCase(durationrule)) { + String conversion = splitBean.getConversion(); + if (conversion.length() > 0 && Util.getIntValue(conversion) > 0) { + double conversionMins = 0.0; + int halfHourInt = 30; + KQOverTimeRuleCalBiz kqOverTimeRuleCalBiz = new KQOverTimeRuleCalBiz(); + conversionMins = kqOverTimeRuleCalBiz.getConversionMins(halfHourInt, splitBean.getD_Mins(), Util.getIntValue(conversion)); + splitBean.setD_Mins(conversionMins); + } + durationrule3(splitBean, isComputingMode2); + } else if ("6".equalsIgnoreCase(durationrule)) { + String conversion = splitBean.getConversion(); + if (conversion.length() > 0 && Util.getIntValue(conversion) > 0) { + double conversionMins = 0.0; + int wholeHourInt = 60; + KQOverTimeRuleCalBiz kqOverTimeRuleCalBiz = new KQOverTimeRuleCalBiz(); + conversionMins = kqOverTimeRuleCalBiz.getConversionMins(wholeHourInt, splitBean.getD_Mins(), Util.getIntValue(conversion)); + splitBean.setD_Mins(conversionMins); + } + durationrule3(splitBean, isComputingMode2); + } + + } + + private Long getRepeatMins(KQRepeatBean kqRepeatBean) { + Long repeatMins = 0L; + try{ + String repeatType = kqRepeatBean.getRepeatType(); + if(StringUtils.isNotEmpty(repeatType)){ + Long repeatLate = kqRepeatBean.getRepeatLate(); + Long repeatEarly = kqRepeatBean.getRepeatEarly(); + if("0".equals(repeatType)){ + if(repeatLate != null){ + repeatMins += new Double(Double.valueOf(repeatLate)).longValue(); + } + } + if("1".equals(repeatType)){ + if(repeatEarly != null){ + repeatMins += new Double(Double.valueOf(repeatEarly)).longValue(); + } + } + if("2".equals(repeatType)){ + if(repeatLate != null){ + repeatMins += new Double(Double.valueOf(repeatLate)).longValue(); + } + if(repeatEarly != null){ + repeatMins += new Double(Double.valueOf(repeatEarly)).longValue(); + } + } + } + }catch (Exception e){ + } + return repeatMins; + } + + /** + * 按天请假 + * + * @param splitBean + * @param isComputingMode2 是否按照自然日计算 + * @return + */ + private void durationrule1(SplitBean splitBean, boolean isComputingMode2) { + String computingMode = splitBean.getComputingMode(); + double d_Mins = splitBean.getD_Mins(); + double curDays = 0.0; + if (isComputingMode2) { + double oneDayHour = splitBean.getOneDayHour(); + if (oneDayHour > 0) { + double oneDayMins = oneDayHour * 60.0; + splitBean.setWorkmins(((int) oneDayMins)); + if (d_Mins > oneDayMins) { + d_Mins = oneDayMins; + splitBean.setD_Mins(d_Mins); + } + curDays = (d_Mins) / (oneDayMins); + curDays = curDays > 0 ? curDays : 0.0; + } + } else { + int workmins = splitBean.getWorkmins(); + String convertAttendDay = Util.null2s(splitBean.getConvertAttendDay(),"1.0"); + double convertAttendDayD = Util.getDoubleValue(convertAttendDay); + if (workmins > 0) { + curDays = (d_Mins / (workmins * 1.0))*convertAttendDayD; + curDays = curDays > 0 ? curDays : 0.0; + } + } + + splitBean.setDuration(KQDurationCalculatorUtil.getDurationRound5("" + (curDays))); + } + + /** + * 按小时请假 + * + * @param splitBean + * @param isComputingMode2 + * @return + */ + private double durationrule3(SplitBean splitBean, boolean isComputingMode2) { + double D_Mins = splitBean.getD_Mins(); + double hours = 0.0; + if (isComputingMode2) { + double oneDayHour = splitBean.getOneDayHour(); + if (oneDayHour > 0) { + double oneDayMins = oneDayHour * 60.0; + splitBean.setWorkmins(((int) oneDayMins)); + if (D_Mins > oneDayMins) { + D_Mins = oneDayMins; + splitBean.setD_Mins(D_Mins); + } + } + } + hours = D_Mins / 60.0; + hours = hours > 0 ? hours : 0.0; + splitBean.setDuration(KQDurationCalculatorUtil.getDurationRound("" + (hours))); + return hours; + } + + + /** + * 根据传入的日期和时间拆分成每一天一条的集合 + * + * @param fromDate + * @param toDate + * @param fromTime + * @param toTime + * @return + */ + public static List> getSplitList(String fromDate, String toDate, String fromTime, String toTime) { + List> splitLists = new ArrayList<>(); + Map splitMap = new HashMap<>(); + + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate localToDate = LocalDate.parse(toDate); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + //进入到这里表示是多天 + if (localFromDate.isBefore(localToDate)) { + long betweenDays = localToDate.toEpochDay() - localFromDate.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + splitMap = new HashMap<>(); + LocalDate curLocalDate = localFromDate.plusDays(i); + + splitMap.put("splitDate", curLocalDate.format(dateFormatter)); + if (i == 0) { + splitMap.put("fromTime", fromTime); + splitMap.put("toTime", "23:59"); + } else if (i == betweenDays) { + splitMap.put("fromTime", "00:00"); + splitMap.put("toTime", toTime); + } else { + splitMap.put("fromTime", "00:00"); + splitMap.put("toTime", "23:59"); + } + splitLists.add(splitMap); + } + } else if (localFromDate.isEqual(localToDate)) { + //同一天 + splitMap.put("splitDate", localFromDate.format(dateFormatter)); + splitMap.put("fromTime", fromTime); + splitMap.put("toTime", toTime); + splitLists.add(splitMap); + } + return splitLists; + } + + /** + * 根据传入的日期和时间拆分成每一天一条的集合 + * + * @param fromDate + * @param toDate + * @param fromTime + * @param toTime + * @return + */ + public static List> getSplitListRepeat(String fromDate, String toDate, String fromTime, String toTime) { + List> splitLists = new ArrayList<>(); + Map splitMap = new HashMap<>(); + + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate localToDate = LocalDate.parse(toDate); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + long betweenDays = localToDate.toEpochDay() - localFromDate.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + splitMap = new HashMap<>(); + LocalDate curLocalDate = localFromDate.plusDays(i); + splitMap.put("splitDate", curLocalDate.format(dateFormatter)); + splitMap.put("fromTime", fromTime); + splitMap.put("toTime", toTime); + splitLists.add(splitMap); + } + return splitLists; + } + + /** + * 根据传入的日期和时间拆分成半天规则的集合 + * + * @param fromDate + * @param toDate + * @param fromTime + * @param toTime + * @return + */ + public static List> getSplitHalfDayList(String fromDate, String toDate, String fromTime, String toTime) { + List> splitLists = new ArrayList<>(); + Map splitMap = new HashMap<>(); + + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate localToDate = LocalDate.parse(toDate); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + //进入到这里表示是多天 + if (localFromDate.isBefore(localToDate)) { + long betweenDays = localToDate.toEpochDay() - localFromDate.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + splitMap = new HashMap<>(); + LocalDate curLocalDate = localFromDate.plusDays(i); + splitMap.put("splitDate", curLocalDate.format(dateFormatter)); + if (i == 0) { + int foreOrAfter = SplitSelectSet.foreOrAfter(fromTime, SplitSelectSet.afternoon_end); + splitMap.put("foreOrAfter", "" + foreOrAfter); + } else if (i == betweenDays) { + int foreOrAfter = SplitSelectSet.foreOrAfter(SplitSelectSet.forenoon_start, toTime); + splitMap.put("foreOrAfter", "" + foreOrAfter); + } else { + splitMap.put("foreOrAfter", "" + SplitSelectSet.fore_after_index); + } + splitLists.add(splitMap); + } + } else if (localFromDate.isEqual(localToDate)) { + //同一天 + splitMap.put("splitDate", localFromDate.format(dateFormatter)); + int foreOrAfter = SplitSelectSet.foreOrAfter(fromTime, toTime); + splitMap.put("foreOrAfter", "" + foreOrAfter); + splitLists.add(splitMap); + } + return splitLists; + } + + /** + * 根据传入的日期分成集合 + * + * @param fromDate + * @param toDate + * @return + */ + public static List> getSplitDayList(String fromDate, String toDate) { + List> splitLists = new ArrayList<>(); + Map splitMap = new HashMap<>(); + + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate localToDate = LocalDate.parse(toDate); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + long betweenDays = localToDate.toEpochDay() - localFromDate.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + splitMap = new HashMap<>(); + LocalDate curLocalDate = localFromDate.plusDays(i); + splitMap.put("splitDate", curLocalDate.format(dateFormatter)); + splitLists.add(splitMap); + } + return splitLists; + } + + /** + * 对于工作日加班判断是否是开启了晚走晚到的规则,开启了的话,不试做加班 + * + * @return + */ + public boolean checkIsLateoutlatein(String resourceId, String taskDate) { + boolean isLateoutlatein = false; + KQWorkTime kqWorkTime = new KQWorkTime(); + Map serialInfo = kqWorkTime.getSerialInfo(resourceId, taskDate, false); + if (serialInfo != null && serialInfo.size() > 0) { + boolean isRest = kqWorkTime.isNonWork(serialInfo); + if(isRest){ + return isLateoutlatein; + } + String serialid = Util.null2String(serialInfo.get(taskDate)); + if (serialid.length() > 0) { + KQShiftPersonalizedRuleCominfo ruleCominfo = new KQShiftPersonalizedRuleCominfo(); + KQShiftPersonalizedRuleDetailComInfo ruleDetailComInfo = new KQShiftPersonalizedRuleDetailComInfo(); + String personalizedruleid = ruleCominfo.getID(serialid); + Map ruleDetailMap = ruleDetailComInfo.getPersonalizedRuleDetail(personalizedruleid); + if (ruleDetailMap != null && !ruleDetailMap.isEmpty()) { + List workSectionList = (List) ruleDetailMap.get("lateoutlatein"); + if (workSectionList != null && !workSectionList.isEmpty()) { +// workSectionList里存的enable都是一致的,取一个就行 + Map sectionMap = (Map) workSectionList.get(0); + if (sectionMap != null && !sectionMap.isEmpty()) { + String enable = Util.null2String(sectionMap.get("enable")); + if ("1".equalsIgnoreCase(enable)) { + isLateoutlatein = true; + kqLog.info("resourceid:" + resourceId + ":taskDate:" + taskDate + ":::开启了晚走晚到规则,不计算加班 checkIsLateoutlatein:resourceId:" + resourceId + ":taskDate:" + taskDate + ":serialid:" + serialid); + return isLateoutlatein; + } + } + } + } + } + } + + return isLateoutlatein; + } + + /** + * 推送 补打卡,外勤,考勤同步数据,触发加班规则生成加班数据处理 + * + * @param fromDate + * @param toDate + * @param resourceids 支持多个人的 + */ + public static void pushOverTimeTasksAll(String fromDate, String toDate, String resourceids) { + + kqLog.info("pushOverTimeTasksAll 参数为:resourceids:" + resourceids + ":fromDate:" + fromDate + ":toDate:" + toDate); + if (resourceids.length() == 0 || fromDate.length() == 0 || toDate.length() == 0) { + return; + } + List tasks = new ArrayList<>(); + String[] resourceid_arr = resourceids.split(","); + for (int i = 0; i < resourceid_arr.length; i++) { + pushOverTimeTasks(fromDate, toDate, resourceid_arr[i], tasks); + } + if (!tasks.isEmpty()) { + KQQueue.writeTasks(tasks); + } + + } + + /** + * 推送 补打卡,外勤,考勤同步数据,触发加班规则生成加班数据处理 + * + * @param fromDate + * @param toDate + * @param resourceid + * @param tasks + */ + public static void pushOverTimeTasks(String fromDate, String toDate, String resourceid, List tasks) { + + try { + if (true) { + KQTaskBean kqTaskBean = new KQTaskBean(); + kqTaskBean.setResourceId(resourceid); + kqTaskBean.setOvertime_fromdate(fromDate); + kqTaskBean.setOvertime_todate(toDate); + tasks.add(kqTaskBean); + } else { + pushOverTimeTasks_old(fromDate, toDate, resourceid, tasks); + } + } catch (Exception e) { + baseBean.writeLog(e); + } + } + + public static void pushOverTimeTasks_old(String fromDate, String toDate, String resourceid, List tasks) { + +// kqLog.info("批量加班推送 pushOverTimeTasks:fromDate:"+fromDate+"::toDate:"+toDate+"::resourceid:"+resourceid); + + LocalDate localFromDate = LocalDate.parse(fromDate); + LocalDate localToDate = LocalDate.parse(toDate); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + long betweenDays = localToDate.toEpochDay() - localFromDate.toEpochDay(); + for (int i = 0; i <= betweenDays; i++) { + LocalDate curLocalDate = localFromDate.plusDays(i); + LocalDate preCurLocalDate = curLocalDate.minusDays(1); + LocalDate nextCurLocalDate = curLocalDate.plusDays(1); + String splitDate = curLocalDate.format(dateFormatter); + String pre_splitDate = preCurLocalDate.format(dateFormatter); + String next_splitDate = nextCurLocalDate.format(dateFormatter); + Map pre_todayLineMap = KQDurationCalculatorUtil.getWorkButton(resourceid, pre_splitDate, false); + Map todayLineMap = KQDurationCalculatorUtil.getWorkButton(resourceid, splitDate, false); + //因为现在是上班前都归属前一天,所以这里存一下上班前的开始时间 + Map workTimeStartMap = new HashMap<>(); + //如果昨天是工作日,昨天的上班时间作为今天的允许加班开始时间(因为下班后加班都属于前一天的) + String pre_workTime = ""; + if (pre_todayLineMap.get("signTime") != null) { + pre_workTime = getEndWorktime(pre_todayLineMap, splitDate, workTimeStartMap, resourceid, pre_splitDate); + } else { + workTimeStartMap.put("pre_isrest", "1"); + } + //如果今天是非工作日,明天是工作日,明天的上班时间作为今天的允许加班结束时间 + String next_workTime = ""; + Map next_todayLineMap = KQDurationCalculatorUtil.getWorkButton(resourceid, next_splitDate, false); + + if (next_todayLineMap.get("signTime") != null) { + next_workTime = getStartWorktime(next_todayLineMap, splitDate, workTimeStartMap); + } else { + workTimeStartMap.put("next_isrest", "1"); + } + boolean isTodayWorkDay = todayLineMap.get("signTime") != null; + + kqLog.info("pushOverTimeTasks splitDate:" + splitDate + ":isTodayWorkDay:" + isTodayWorkDay + ":pre_workTime:" + pre_workTime + ":next_workTime:" + next_workTime); + //如果当前日期是工作日 + if (isTodayWorkDay) { + List> todaySignTime = (List>) todayLineMap.get("signTime"); + if (todaySignTime != null && !todaySignTime.isEmpty()) { + overTime4Work(splitDate, pre_splitDate, resourceid, tasks, todayLineMap, todaySignTime, workTimeStartMap); + } else { + overTime4NonWork(splitDate, pre_workTime, resourceid, tasks, next_workTime, workTimeStartMap, pre_splitDate); + } + } else { + overTime4NonWork(splitDate, pre_workTime, resourceid, tasks, next_workTime, workTimeStartMap, pre_splitDate); + } + } +// kqLog.info("批量加班推送 数据为:"+(JSON.toJSONString(tasks))); + + } + + /** + * 获取最晚允许下班时间 + * + * @param pre_todayLineMap + * @param splitDate + * @param workTimeStartMap + * @param resourceid + * @param pre_splitDate + * @return + */ + private static String getEndWorktime(Map pre_todayLineMap, String splitDate, + Map workTimeStartMap, String resourceid, String pre_splitDate) { + String pre_workTime = ""; + List> pre_todaySignTime = (List>) pre_todayLineMap.get("signTime"); + if (pre_todaySignTime != null && !pre_todaySignTime.isEmpty()) { + Map pre_todaySignMap = pre_todaySignTime.get(pre_todaySignTime.size() - 1); + String endtime = pre_todaySignMap.get("endtime"); + String endtime_across = pre_todaySignMap.get("endtime_across"); + if ("1".equalsIgnoreCase(endtime_across)) { + pre_workTime = splitDate + " " + endtime + ":59"; + } + Map first_SignMap = pre_todaySignTime.get(0); + String workbengintime = first_SignMap.get("workbengintime"); + workTimeStartMap.put("pre_workbengintime", workbengintime); + if (pre_todaySignTime.size() == 1) { + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + if (is_flow_humanized) { + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, pre_splitDate, false); + Map shifRuleMap = Maps.newHashMap(); + KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, resourceid, shifRuleMap); + if (!shifRuleMap.isEmpty()) { + if (shifRuleMap.containsKey("shift_beginworktime")) { + String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime")); + if (shift_beginworktime.length() > 0) { + workTimeStartMap.put("pre_workbengintime", shift_beginworktime); + } + } + if (shifRuleMap.containsKey("shift_endworktime")) { + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if (shift_endworktime.length() > 0) { + pre_workTime = shift_endworktime; + } + } + } + } + } + } else { + workTimeStartMap.put("pre_isrest", "1"); + } + return pre_workTime; + } + + /** + * 获取最早允许上班时间 + * + * @param next_todayLineMap + * @param splitDate + * @return + */ + private static String getStartWorktime(Map next_todayLineMap, String splitDate, + Map workTimeStartMap) { + String next_workTime = ""; + List> next_todaySignTime = (List>) next_todayLineMap.get("signTime"); + if (next_todaySignTime != null && !next_todaySignTime.isEmpty()) { + Map next_todaySignMap = next_todaySignTime.get(0); + String bengintime = next_todaySignMap.get("bengintime"); + String workbengintime = next_todaySignMap.get("workbengintime"); + String bengintime_pre_across = next_todaySignMap.get("bengintime_pre_across"); + if ("1".equalsIgnoreCase(bengintime_pre_across)) { + next_workTime = splitDate + " " + bengintime + ":00"; + } + workTimeStartMap.put("next_workbengintime", workbengintime); + } else { + workTimeStartMap.put("next_isrest", "1"); + } + return next_workTime; + } + + public static void overTime4Work(String splitDate, String pre_splitDate, String resourceid, + List tasks, Map todayLineMap, + List> todaySignTime, + Map workTimeStartMap) { + + //现在标准是默认取最后一个班次作为加班 + Map todaySignMap = Maps.newHashMap(); + if (todaySignTime.size() == 1) { + todaySignMap = todaySignTime.get(0); + overTime4WorkSign(todaySignMap, splitDate, pre_splitDate, resourceid, tasks, todayLineMap, workTimeStartMap, ""); + } else if (todaySignTime.size() > 1) { + for (int i = 0; i < 2; i++) { + if (i == 0) { + todaySignMap = todaySignTime.get(0); + overTime4WorkSign(todaySignMap, splitDate, pre_splitDate, resourceid, tasks, todayLineMap, workTimeStartMap, "before"); + } else if (i == 1) { + todaySignMap = todaySignTime.get(todaySignTime.size() - 1); + overTime4WorkSign(todaySignMap, splitDate, pre_splitDate, resourceid, tasks, todayLineMap, workTimeStartMap, "after"); + } + } + } + } + + public static void overTime4WorkSign( + Map todaySignMap, String splitDate, String pre_splitDate, + String resourceid, List tasks, + Map todayLineMap, + Map workTimeStartMap, String signsource) { + RecordSet rs = new RecordSet(); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + + List allWorkTime = (List) todayLineMap.get("allWorkTime"); + String firstWorkTime = ""; + String lastWorkTime = ""; + if (allWorkTime != null && !allWorkTime.isEmpty()) { + firstWorkTime = allWorkTime.get(0); + lastWorkTime = allWorkTime.get(allWorkTime.size() - 1); + } + String yesterday = LocalDate.parse(splitDate).minusDays(1).format(dateFormatter); + String nextday = LocalDate.parse(splitDate).plusDays(1).format(dateFormatter); + + String workbengintime = Util.null2s(todaySignMap.get("workbengintime"), ""); + String bengintime = Util.null2s(todaySignMap.get("bengintime"), ""); + //上班开始时间是否跨天到后一天 + String bengintime_across = Util.null2s(todaySignMap.get("bengintime_across"), ""); + //上班打卡开始时间是否跨天到前一天 + String bengintime_pre_across = Util.null2s(todaySignMap.get("bengintime_pre_across"), ""); + String bengintime_end = Util.null2s(todaySignMap.get("bengintime_end"), ""); + String bengintime_end_across = Util.null2s(todaySignMap.get("bengintime_end_across"), ""); + + String endtime = Util.null2s(todaySignMap.get("endtime"), ""); + String endtime_across = Util.null2s(todaySignMap.get("endtime_across"), ""); + String endtime_start = Util.null2s(todaySignMap.get("endtime_start"), ""); + String endtime_start_across = Util.null2s(todaySignMap.get("endtime_start_across"), ""); + + String workendtime_across = Util.null2s(todaySignMap.get("workendtime_across"), ""); + boolean isEndTimeAcross = false; + if ("1".equalsIgnoreCase(workendtime_across)) { + isEndTimeAcross = true; + } + + String signInDateTime = splitDate + " " + bengintime + ":00"; + if ("1".equalsIgnoreCase(bengintime_pre_across)) { + signInDateTime = yesterday + " " + bengintime + ":00"; + } + if ("1".equalsIgnoreCase(bengintime_across)) { + signInDateTime = nextday + " " + bengintime + ":00"; + } + String signInEndDateTime = ""; + if (bengintime_end.length() > 0) { + signInEndDateTime = splitDate + " " + bengintime_end + ":00"; + if ("1".equalsIgnoreCase(bengintime_end_across)) { + signInEndDateTime = nextday + " " + bengintime_end + ":00"; + } + } +// if(pre_workTime.length() > 0){ +// signInDateTime = splitDate + " " +pre_workTime+":00"; +// } + String signOutDateTime = splitDate + " " + endtime + ":59"; + if ("1".equalsIgnoreCase(endtime_across)) { + signOutDateTime = nextday + " " + endtime + ":59"; + } + String signOutBeginDateTime = ""; + if (endtime_start.length() > 0) { + signOutBeginDateTime = splitDate + " " + endtime_start + ":59"; + if ("1".equalsIgnoreCase(endtime_start_across)) { + signOutBeginDateTime = nextday + " " + endtime_start + ":59"; + } + } + String sign_signSectionTime = ""; + String sign_signSectionEndTime = ""; + String sign_signSectionBeginTime = ""; + String sign_offSignSectionTime = ""; + if (signInEndDateTime.length() == 0 && signOutBeginDateTime.length() == 0) { + //如果没设置上班后,下班前打卡 + sign_signSectionTime = signInDateTime; + sign_offSignSectionTime = signOutDateTime; + } else { + if (signInEndDateTime.length() > 0) { + if (signOutBeginDateTime.length() > 0) { + //如果上班后,下班前打卡范围都做了控制 + sign_signSectionTime = signInDateTime; + sign_signSectionEndTime = signInEndDateTime; + sign_signSectionBeginTime = signOutBeginDateTime; + sign_offSignSectionTime = signOutDateTime; + + } else { + LocalDateTime onLocalDateEndTime = LocalDateTime.parse(signInEndDateTime, fullFormatter); + //如果只是上班后打卡范围做了控制 + LocalDateTime tmp = LocalDateTime.parse(onLocalDateEndTime.plusMinutes(1).format(datetimeFormatter) + ":00", fullFormatter); + String tmp_datetime = tmp.format(fullFormatter); + sign_signSectionTime = signInDateTime; + sign_signSectionEndTime = signInEndDateTime; + sign_signSectionBeginTime = tmp_datetime; + sign_offSignSectionTime = signOutDateTime; + + } + } else if (signOutBeginDateTime.length() > 0) { + //如果只是下班前打卡范围做了控制 + LocalDateTime offLocalDateBeginTime = LocalDateTime.parse(signOutBeginDateTime, fullFormatter); + LocalDateTime tmp = LocalDateTime.parse(offLocalDateBeginTime.minusMinutes(1).format(datetimeFormatter) + ":59", fullFormatter); + String tmp_datetime = tmp.format(fullFormatter); + sign_signSectionTime = signInDateTime; + sign_signSectionEndTime = tmp_datetime; + sign_signSectionBeginTime = signOutBeginDateTime; + sign_offSignSectionTime = signOutDateTime; + } + } + + KQScheduleSignBiz kqScheduleSignBiz = new KQScheduleSignBiz.KQScheduleSignParamBuilder().resourceidParam(resourceid) + .signSectionTimeParam(sign_signSectionTime).signSectionEndTimeParam(sign_signSectionEndTime) + .signSectionBeginTimeParam(sign_signSectionBeginTime).offSignSectionTimeParam(sign_offSignSectionTime).build(); + Map signMap = kqScheduleSignBiz.getScheduleSignInfoWithCardRange(); + if (signMap != null && !signMap.isEmpty()) { + KQHrmScheduleSign signInTimeBean = signMap.get("signin"); + KQHrmScheduleSign signOutTimeBean = signMap.get("signout"); + if (allWorkTime.size() == 2) { + boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized(); + if (is_flow_humanized) { + //一天一次打卡的情况下需要考虑个性化设置 + if (todayLineMap.containsKey("shiftRuleMap")) { + Map shiftRuleMap = (Map) todayLineMap.get("shiftRuleMap"); + if (shiftRuleMap != null && !shiftRuleMap.isEmpty() && shiftRuleMap.containsKey("ruleDetail")) {//处理人性化设置其他规则 + Map ruleDetail = (Map) shiftRuleMap.get("ruleDetail"); + if (ruleDetail != null && !ruleDetail.isEmpty()) { + Map shifRuleMap = KQShiftRuleInfoBiz.do4ShiftRule(ruleDetail, signInTimeBean, signOutTimeBean, allWorkTime, splitDate, nextday, resourceid); + if (!shifRuleMap.isEmpty()) { + if (shifRuleMap.containsKey("shift_beginworktime")) { + String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime")); + firstWorkTime = shift_beginworktime; + } + if (shifRuleMap.containsKey("shift_endworktime")) { + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if (shift_endworktime.length() > 0) { + lastWorkTime = shift_endworktime; + int lastWorkTime_index = kqTimesArrayComInfo.getArrayindexByTimes(lastWorkTime); + if (lastWorkTime_index >= 1440) { + isEndTimeAcross = true; + lastWorkTime = kqTimesArrayComInfo.turn48to24Time(lastWorkTime); + } else { + isEndTimeAcross = false; + } + + } + } + } + } + } + } + } + } + if (signsource.length() > 0) { + if ("before".equalsIgnoreCase(signsource)) { + signOutTimeBean = null; + } + if ("after".equalsIgnoreCase(signsource)) { + signInTimeBean = null; + } + } + if (signInTimeBean != null) { + String signdate = Util.null2String(signInTimeBean.getSigndate()); + String signtime = Util.null2String(signInTimeBean.getSigntime()); + String pre_bengintime = Util.null2String(workTimeStartMap.get("pre_workbengintime")); + if (pre_bengintime.length() > 0) { + //当前是工作日,前一天是工作日的情况 + pre_bengintime = pre_bengintime + ":00"; + String tmp_pre_bengintime = splitDate + " " + pre_bengintime; + String tmp_workbengintime = splitDate + " " + workbengintime + ":00"; + if (tmp_pre_bengintime.compareTo(tmp_workbengintime) > 0) { + pre_bengintime = workbengintime + ":00"; + } + if (firstWorkTime.length() > 0) { + String tmp_firstWorkTime = splitDate + " " + firstWorkTime + ":00"; + if (tmp_pre_bengintime.compareTo(tmp_firstWorkTime) > 0) { + tmp_pre_bengintime = tmp_firstWorkTime; + pre_bengintime = firstWorkTime + ":00"; + } + } + String tmp_signtime = signdate + " " + signtime; + if (tmp_pre_bengintime.compareTo(tmp_signtime) > 0) { + if (signtime.length() > 0) { + KQTaskBean kqTaskBean = new KQTaskBean(); + kqTaskBean.setResourceId(resourceid); + kqTaskBean.setTaskDate(pre_splitDate); + kqTaskBean.setLastWorkTime(signtime); + kqTaskBean.setTaskSignTime(pre_bengintime); + kqTaskBean.setSignDate(signdate); + kqTaskBean.setSignEndDate(splitDate); + kqTaskBean.setTimesource("before"); + if (!tasks.contains(kqTaskBean)) { + tasks.add(kqTaskBean); + } + } else { + kqLog.info("overTime4Work::signtime is null:" + signtime); + } + } + } else { + //当前是工作日,前一天是非工作日的情况 + String pre_isrest = Util.null2String(workTimeStartMap.get("pre_isrest")); + if ("1".equalsIgnoreCase(pre_isrest)) { + if (firstWorkTime.length() > 0) { + String tmp_firstWorkTime = splitDate + " " + firstWorkTime + ":00"; + String tmp_signtime = signdate + " " + signtime; + if (tmp_firstWorkTime.compareTo(tmp_signtime) > 0) { + KQTaskBean kqTaskBean = new KQTaskBean(); + kqTaskBean.setResourceId(resourceid); + kqTaskBean.setTaskDate(pre_splitDate); + kqTaskBean.setSignDate(splitDate); + kqTaskBean.setSignEndDate(signdate); + kqTaskBean.setSignInTime4Out(signtime); + kqTaskBean.setTaskSignTime(firstWorkTime + ":00"); + kqTaskBean.setTimesource("before"); + if (!tasks.contains(kqTaskBean)) { + tasks.add(kqTaskBean); + } + } + } + } + } + } + if (signOutTimeBean != null) { + String signdate = Util.null2String(signOutTimeBean.getSigndate()); + String signtime = Util.null2String(signOutTimeBean.getSigntime()); + + if (lastWorkTime.length() > 0 && signtime.length() > 0) { + if (signtime.length() == 5) { + signtime += ":00"; + } + if (lastWorkTime.length() == 5) { + lastWorkTime += ":00"; + } + String tmpsigndatetime = signdate + " " + signtime; + String tmpworkdatetime = splitDate + " " + lastWorkTime; + if (isEndTimeAcross) { + tmpworkdatetime = nextday + " " + lastWorkTime; + } + if (tmpsigndatetime.compareTo(tmpworkdatetime) > 0) { + KQTaskBean kqTaskBean = new KQTaskBean(); + kqTaskBean.setResourceId(resourceid); + kqTaskBean.setTaskDate(splitDate); + kqTaskBean.setLastWorkTime(lastWorkTime); + kqTaskBean.setTaskSignTime(signtime); + if (isEndTimeAcross) { + kqTaskBean.setSignDate(nextday); + } else { + kqTaskBean.setSignDate(splitDate); + } + kqTaskBean.setSignEndDate(signdate); + kqTaskBean.setTimesource("after"); + if (!tasks.contains(kqTaskBean)) { + tasks.add(kqTaskBean); + } + } + } else { + kqLog.info("overTime4Work:lastWorkTime is null :" + lastWorkTime + ":signtime is null:" + signtime); + } + } + } + } + + /** + * 针对非工作日推送加班数据 + * + * @param splitDate + * @param pre_workTime 前一天是工作日,前一天工作日最后下班时间跨天了会影响到今天开始打卡时间 + * @param resourceid + * @param tasks + * @param next_workTime 后一天是工作日,后一天的最早上班时间跨天了,会影响到今天的结束打卡时间 + * @param workTimeStartMap + * @param pre_splitDate + */ + public static void overTime4NonWork(String splitDate, String pre_workTime, String resourceid, + List tasks, String next_workTime, + Map workTimeStartMap, String pre_splitDate) { + + String signInTime4Out = ""; + String signTime = ""; + String bengintime = "00:00"; + String endtime = "23:59"; + String signInDateTime = splitDate + " " + bengintime + ":00"; + if (pre_workTime.length() > 0) { + signInDateTime = pre_workTime; + } + String signOutDateTime = splitDate + " " + endtime + ":59"; + if (next_workTime.length() > 0) { + signOutDateTime = next_workTime; + } + String signDateTimeSql = ""; + String buildSql = KQSignUtil.buildSignSql(signInDateTime, signOutDateTime); + if (buildSql.length() > 0) { + signDateTimeSql += buildSql; + } + KQScheduleSignBiz kqScheduleSignBiz = new KQScheduleSignBiz.KQScheduleSignParamBuilder().resourceidParam(resourceid). + signDateTimeSqlParam(signDateTimeSql).signDateParam(splitDate).build(); + Map signMap = kqScheduleSignBiz.getScheduleSignInfo(); + if (signMap != null && !signMap.isEmpty()) { + KQHrmScheduleSign signInTimeBean = signMap.get("signin"); + KQHrmScheduleSign signOutTimeBean = signMap.get("signout"); + if (signInTimeBean != null) { + signInTime4Out = Util.null2String(signInTimeBean.getSigntime()); + } + if (signOutTimeBean != null) { + signTime = Util.null2String(signOutTimeBean.getSigntime()); + } + } + + String pre_bengintime = Util.null2String(workTimeStartMap.get("pre_workbengintime")); + if (pre_bengintime.length() > 0) { + pre_bengintime = pre_bengintime + ":00"; + if (pre_bengintime.compareTo(signInTime4Out) > 0) { + //非工作日加班的话,签退数据都需要去搞一遍调休 + if (pre_bengintime.length() > 0 && signInTime4Out.length() > 0) { + KQTaskBean kqTaskBean = new KQTaskBean(); + kqTaskBean.setResourceId(resourceid); + kqTaskBean.setTaskDate(pre_splitDate); + kqTaskBean.setLastWorkTime(signInTime4Out); + kqTaskBean.setTaskSignTime(pre_bengintime); + kqTaskBean.setSignDate(splitDate); + kqTaskBean.setSignEndDate(splitDate); + kqTaskBean.setTimesource("before"); + if (!tasks.contains(kqTaskBean)) { + tasks.add(kqTaskBean); + } + } else { + kqLog.info("overTime4NonWork:pre_bengintime is null :" + pre_bengintime + ":signInTime4Out is null:" + signInTime4Out); + } + if (pre_bengintime.length() > 0 && signTime.length() > 0) { + //TODO pre_bengintime signTime 需要比较一下大小 + if (signTime.compareTo(pre_bengintime) > -1) { + KQTaskBean kqTaskBean = new KQTaskBean(); + kqTaskBean.setResourceId(resourceid); + kqTaskBean.setTaskDate(splitDate); + kqTaskBean.setSignDate(splitDate); + kqTaskBean.setSignEndDate(splitDate); + //对于非工作时段,签到就是他的最后一次下班时间 + kqTaskBean.setSignInTime4Out(pre_bengintime); + kqTaskBean.setTaskSignTime(signTime); + kqTaskBean.setTimesource("after"); + if (!tasks.contains(kqTaskBean)) { + tasks.add(kqTaskBean); + } + } + } else { + kqLog.info("overTime4NonWork:pre_bengintime is null :" + pre_bengintime + ":signTime is null:" + signTime); + } + + } else { + //非工作日加班的话,签退数据都需要去搞一遍调休 + if (signInTime4Out.length() > 0 && signTime.length() > 0) { + KQTaskBean kqTaskBean = new KQTaskBean(); + kqTaskBean.setResourceId(resourceid); + kqTaskBean.setTaskDate(splitDate); + kqTaskBean.setSignDate(splitDate); + kqTaskBean.setSignEndDate(splitDate); + //对于非工作时段,签到就是他的最后一次下班时间 + kqTaskBean.setSignInTime4Out(signInTime4Out); + kqTaskBean.setTimesource("after"); + kqTaskBean.setTaskSignTime(signTime); + if (!tasks.contains(kqTaskBean)) { + tasks.add(kqTaskBean); + } + } else { + kqLog.info("overTime4NonWork:signInTime4Out is null :" + signInTime4Out + ":signTime is null:" + signTime); + } + } + } else { + //非工作日加班的话,签退数据都需要去搞一遍调休 + if (signInTime4Out.length() > 0 && signTime.length() > 0) { + KQTaskBean kqTaskBean = new KQTaskBean(); + kqTaskBean.setResourceId(resourceid); + kqTaskBean.setTaskDate(splitDate); + kqTaskBean.setSignDate(splitDate); + kqTaskBean.setSignEndDate(splitDate); + //对于非工作时段,签到就是他的最后一次下班时间 + kqTaskBean.setSignInTime4Out(signInTime4Out); + kqTaskBean.setTaskSignTime(signTime); + kqTaskBean.setTimesource("after"); + if (!tasks.contains(kqTaskBean)) { + tasks.add(kqTaskBean); + } + } else { + kqLog.info("overTime4NonWork:signInTime4Out is null :" + signInTime4Out + ":signTime is null:" + signTime); + } + } + + } + +} diff --git a/src/com/engine/kq/wfset/util/SplitSelectSet.java b/src/com/engine/kq/wfset/util/SplitSelectSet.java new file mode 100644 index 0000000..70ae5aa --- /dev/null +++ b/src/com/engine/kq/wfset/util/SplitSelectSet.java @@ -0,0 +1,95 @@ +package com.engine.kq.wfset.util; + +/** + * 要改这里的需要注意,KQAttFlowSetComInfo 这个流程上半天的联动也得跟着一起改 + */ +public class SplitSelectSet { + + /** + * 半天规则下拉框对应的上午开始时间 + */ + public static String forenoon_start = "08:00"; + + /** + * 半天规则下拉框对应的上午结束时间 + */ + public static String forenoon_end = "13:00"; + + /** + * 半天规则下拉框对应的下午午开始时间 + */ + public static String afternoon_start = "13:00"; + + /** + * 半天规则下拉框对应的下午结束时间 + */ + public static String afternoon_end = "18:00"; + + /** + * 半天规则下 上午-上午 + */ + public static int fore_fore_index = 0; + + /** + * 半天规则下 上午-下午 + */ + public static int fore_after_index = 1; + + /** + * 半天规则下 下午-上午 + */ + public static int after_fore_index = 2; + + /** + * 半天规则下 下午-下午 + */ + public static int after_after_index = 3; + + + /** + * 全天规则 下拉框对应的开始时间 + */ + public static String daylong_start = "08:00"; + + /** + * 全天规则 下拉框对应的结束时间 + */ + public static String daylong_end = "18:00"; + + /** + * 根据传入的时间判断是是上午还是下午 + * 总共四种情况 + * 上午-上午 0.5 + * 上午-下午 1 + * 下午-上午 0 + * 下午-下午 0.5 + * @param fromTime + * @param toTime + * @return + * 0表示上午-上午 + * 1表示上午-上午 + * 2表示上午-上午 + * 3表示上午-上午 + */ + public static int foreOrAfter(String fromTime,String toTime){ + int foreOrAfter = -1; + if(forenoon_start.equalsIgnoreCase(fromTime)){ + if(afternoon_start.equalsIgnoreCase(toTime)){ + //上午-上午 + foreOrAfter= fore_fore_index; + }else if(afternoon_end.equalsIgnoreCase(toTime)){ + //上午-下午 + foreOrAfter= fore_after_index; + } + }else if(forenoon_end.equalsIgnoreCase(fromTime)){ + if(afternoon_start.equalsIgnoreCase(toTime)){ + //下午-上午 + foreOrAfter= after_fore_index; + }else if(afternoon_end.equalsIgnoreCase(toTime)){ + //下午-下午 + foreOrAfter= after_after_index; + } + } + return foreOrAfter; + } +}