Просмотр исходного кода

加班单删除变更改造开发

zqy 4 месяцев назад
Родитель
Сommit
c37400c68b

+ 0 - 435
js/addon/attendmanage/web/js/shr/ats/atsOverTimeBillBatchEditEx.js

@@ -1,435 +0,0 @@
-
-shr.defineClass("shr.ats.AtsOverTimeBillBatchEditEx", shr.ats.AtsOverTimeBillBatchEdit, {
-	initalizeDOM: function () {
-		shr.ats.AtsOverTimeBillBatchEditEx.superClass.initalizeDOM.call(this);
-		// 编辑表格合计
-		var _self = this;
-		var that = this;
-		var entries_cont = waf("#entries");
-		entries_cont.jqGrid("option", {
-			onChange: function (rowid, cellname, value, iRow, iCol) {
-				console.log(rowid, cellname, value, iRow, iCol, 123123);
-			},
-			beforeSaveCell: function (
-				rowid,
-				cellname,
-				value,
-				iRow,
-				iCol
-			) { },
-			afterSaveCell: function (rowid, cellname, value, iRow, iCol) {
-			
-				if (value["adminOrgUnit.id"]) {
-					$("#entries").jqGrid(
-						"setCell",
-						rowid,
-						"adminOrgUnit.id",
-						value["adminOrgUnit.id"]
-					);
-				}
-
-				that.removePreShowError(rowid);
-				if (cellname == "otDate") {
-					var val = value;
-					if (val.length <= 10) {
-						val = val + " 00:00:00";
-					}
-					val &&
-						$("#entries").jqGrid(
-							"setCell",
-							rowid,
-							"startTime",
-							val
-						);
-					val &&
-						$("#entries").jqGrid(
-							"setCell",
-							rowid,
-							"endTime",
-							val
-						);
-					that.changeOverTimeType(rowid);
-					that.calRestTimeLen(rowid);
-					that.getOTContrlParams(rowid);
-				}
-
-				if (cellname == "otType") {
-					that.changeOTCompens(rowid);
-				}
-				// 添加 开始时间  结束时间   休息时长(分钟) 响应时间
-				if (
-					cellname == "startTime" ||
-					cellname == "endTime" ||
-					cellname == "restTime"
-				) {
-
-					if (cellname != "restTime") {
-						that.calRestTimeLen(rowid);
-					}
-					that.calculateOTtimes(rowid);
-				}
-				if (cellname == "person") {
-					that.calRestTimeLen(rowid);
-					that.getOTContrlParams(rowid);
-				}
-				if (cellname == "applyOTTime") {
-					_self.calculateTotal();
-
-					// 加班小时数  发生改变就给予提示
-					that.changOtTimeTipInfo(rowid);
-				}
-				if (
-					cellname == "restStartTime" ||
-					cellname == "restStartTime2" ||
-					cellname == "restEndTime" ||
-					cellname == "restEndTime2"
-				) {
-					//计算休息时间,加班时间
-					var startTime = $("#entries").jqGrid(
-						"getCell",
-						rowid,
-						"startTime"
-					);
-					var endTime = $("#entries").jqGrid(
-						"getCell",
-						rowid,
-						"endTime"
-					);
-					var restStartTime = $("#entries").jqGrid(
-						"getCell",
-						rowid,
-						"restStartTime"
-					);
-					var restEndTime = $("#entries").jqGrid(
-						"getCell",
-						rowid,
-						"restEndTime"
-					);
-					var restStartTime2 = $("#entries").jqGrid(
-						"getCell",
-						rowid,
-						"restStartTime2"
-					);
-					var restEndTime2 = $("#entries").jqGrid(
-						"getCell",
-						rowid,
-						"restEndTime2"
-					);
-					if (startTime == "" || endTime == "") {
-						return;
-					}
-
-					var totalRestTime = 0;
-					var totalRestTimeLong = 0;
-					var restStartTimeOfDate;
-					var restEndTimeOfDate;
-					if (shr.getBowserInfo().browser === 'IE' || shr.getBowserInfo().browser === 'Safari') {
-						restStartTime = restStartTime.replace(/-/g, '/');
-						restEndTime = restEndTime.replace(/-/g, '/');
-						restStartTime2 = restStartTime2.replace(/-/g, '/');
-						restEndTime2 = restEndTime2.replace(/-/g, '/');
-					}
-					if (restStartTime != "" && restEndTime != "") {
-						restStartTimeOfDate = new Date(restStartTime);
-						restEndTimeOfDate = new Date(restEndTime);
-						var times =
-							restEndTimeOfDate.getTime() -
-							restStartTimeOfDate.getTime();
-						if (times < 0) {
-							times = 0;
-						}
-						totalRestTimeLong += times;
-						times = times / 1000 / 60;
-						totalRestTime += times;
-					}
-					if (restStartTime2 != "" && restEndTime2 != "") {
-						var restStartTime2OfDate = new Date(restStartTime2);
-						var restEndTime2OfDate = new Date(restEndTime2);
-						if (
-							(restStartTime != "" &&
-								restEndTime2OfDate.getTime() >
-								restStartTimeOfDate.getTime() &&
-								restStartTimeOfDate.getTime() >=
-								restStartTime2OfDate.getTime()) ||
-							(restEndTime != "" &&
-								restEndTimeOfDate.getTime() <=
-								restEndTime2OfDate.getTime() &&
-								restStartTime2OfDate.getTime() <
-								restEndTimeOfDate.getTime()) ||
-							(restStartTime != "" &&
-								restEndTime != "" &&
-								restEndTimeOfDate.getTime() >=
-								restEndTime2OfDate.getTime() &&
-								restStartTime2OfDate.getTime() >=
-								restStartTimeOfDate.getTime())
-						) {
-							//时间有交叉
-							$("#entries").jqGrid(
-								"setCell",
-								rowid,
-								"restEndTime2",
-								restStartTime2
-							);
-						} else {
-							var times =
-								restEndTime2OfDate.getTime() -
-								restStartTime2OfDate.getTime();
-							if (times < 0) {
-								times = 0;
-							}
-							totalRestTimeLong += times;
-							times = times / 1000 / 60;
-							totalRestTime += times;
-						}
-					}
-					var t1 = totalRestTime.toFixed(
-						atsMlUtile.getSysDecimalPlace()
-					);
-					$("#entries").jqGrid("setCell", rowid, "restTime", t1);
-					var startTime = NewDate(startTime + ":00");
-					var endTime = NewDate(endTime + ":00");
-					var se =
-						endTime.getTime() -
-						startTime.getTime() -
-						totalRestTimeLong; // 毫秒
-					var tfl = se / (3600 * 1000);
-					$("#entries").jqGrid(
-						"setCell",
-						rowid,
-						"applyOTTime",
-						tfl
-					);
-					that.getOTContrlParams(rowid);
-				}
-			},
-			afterEditCell: function (rowid, cellname, value, iRow, iCol) {
-				_self.calculateTotal();
-				if (
-					cellname == "otType" &&
-					that.OTContrlParams[rowid] &&
-					that.OTContrlParams[rowid].isOtrolByDateType
-				) {
-					$("#" + iRow + "_otType").shrPromptBox("disable");
-				}
-				if (cellname == "otCompens") {
-					if (that.filter[rowid] == undefined) {
-						// R20221006-0542 修复选择加班费后 再点击“补偿方式”F7就变成了调休的问题
-						// that.changeOTCompens(rowid);
-					}
-					if (that.filter[rowid]) {
-						//						$("#"+rowid+"_otCompens").shrPromptBox("setFilter",that.filter[rowid]);
-						$(
-							"#" +
-							$("#entries").jqGrid(
-								"getCell",
-								rowid,
-								"rn"
-							) +
-							"_otCompens"
-						).shrPromptBox("setFilter", that.filter[rowid]);
-					}
-				}
-				if (cellname == "person") {
-					var hrOrgUnitId = $("#hrOrgUnit_el").val();
-					$("#" + rowid + "_person")
-						.shrPromptBox()
-						.attr("data-params", hrOrgUnitId);
-					$("#" + iRow + "_person").shrPromptBox("option", {
-						onchange: function (e, value) {
-							$("#entries").jqGrid(
-								"setCell",
-								rowid,
-								"person.number",
-								value.current
-									? value.current["person.number"]
-									: ""
-							);
-						}
-					});
-
-				}
-				if (cellname == "attAdminOrgUnit") {
-					var personId = $("#entries").jqGrid("getCell", rowid, "person").id;
-					var attendanceDate = $("#entries").jqGrid("getCell", rowid, "otDate");
-
-					if (!(personId && attendanceDate)) {
-						shr.showInfo({ message: jsBizMultLan.atsManager_atsOverTimeBillEdit_YM_999 });
-						return false;
-					} else {
-						//$("#"+rowid+"_attPosition").shrPromptBox().attr("data-params", adminOrg);
-						$("#" + iRow + "_attAdminOrgUnit").shrPromptBox("setOtherParams", {
-							personId: personId,
-							attendanceDate: attendanceDate
-						});
-					}
-				}
-			}
-			, footerrow: function (rowid, cellname, value, iRow, iCol) {
-			}
-		});
-		$(".ui-jqgrid-sdiv").show();
-		// $(".footrow-ltr td:first").html('合计').parent().css("border-color", "#EEE");
-		$(".footrow-ltr").last().find("td:first").html('合计').parent().css("border-color", "#EEE");
-		_self.calculateTotal();
-
-	},
-
-	calculateTotal() {
-		var count = 0;
-		var ids = $("#entries").jqGrid('getDataIDs');
-		for (var i = 0; i < ids.length; i++) {
-			var rowData = $('#entries').jqGrid('getRowData', ids[i]);
-			count = count + Number(rowData.applyOTTime);
-		}
-		$("#count").val(count.toFixed(2));
-		$("#entries").footerData("set", { "applyOTTime": count.toFixed(2) }); //	
-	}, //去除个性化展示,每次校验前去除
-	removePreShowError: function (rowid) {
-		var rnColNum = this.getColNumIndex();
-		var rows = $("#entries").getGridParam("reccount");
-		var td = $("#entries").find("tr[id='" + rowid + "'] td:eq(" + rnColNum + ")");
-		td.attr(
-			"title",
-			""
-		);
-		td.html(
-			$("#entries").find("tr[id='" + rowid + "']")[0].rowIndex
-		);
-		td.css(
-			"color",
-			"rgb(153, 153, 153)"
-		);
-		$("#entries").find("tr[id='" + rowid + "']").css(
-			"color",
-			"rgb(153, 153, 153)"
-		); //如果设置成css("color","initial")会变成黑色,而原界面为灰色
-	},
-	changeOverTimeType: function (rowid) {
-		var that = this;
-		var otDate;
-		var personId;
-		if (!$("#entries").jqGrid("getCell", rowid, "otDate")) {
-			return;
-		} else {
-			otDate = $("#entries").jqGrid("getCell", rowid, "otDate");
-		}
-
-		if (!$("#entries").jqGrid("getCell", rowid, "person")) {
-			return;
-		} else {
-			personId = $("#entries").jqGrid("getCell", rowid, "person").id;
-		}
-		that.getOverTimeType(rowid, otDate, personId);
-	},
-	getOverTimeType: function (rowid, otDate, personId) {
-		var _self = this;
-		var tDate = otDate;
-		var url =
-			shr.getContextPath() +
-			"/dynamic.do?method=getOverTimeTypeAndOtCompens";
-		url +=
-			"&otDate=" +
-			encodeURIComponent(otDate) +
-			"&personId=" +
-			encodeURIComponent(personId)+"&uipk="+shr.getUrlRequestParam('uipk');
-		$.ajax({
-			url: url,
-			async: false,
-			success: function (response) {
-				if (
-					response.otTypeValue != null &&
-					response.otTypeValue != undefined &&
-					response.otTypeValue != ""
-				) {
-					var responseObejct = {
-						id: response.otTypeValue,
-						name: response.otTypeText
-					};
-					if (_self.isOtTypeEffective(response.otTypeValue)) {
-						// $('#entries').restoreCell(rowid,4); // 先恢复单元格状态再重新赋值,可以避免
-						$("#entries").jqGrid(
-							"setCell",
-							rowid,
-							"otType",
-							responseObejct
-						);
-						//设置该加班类型的补偿方式过滤
-						var otCompensIds = _self.getOTCompensByOTType(
-							personId,
-							response.otTypeValue,
-							tDate
-						);
-						if (otCompensIds) {
-							var otCompensIdsStr = _self
-								.getOTCompensByOTType(
-									personId,
-									response.otTypeValue,
-									tDate
-								)
-								.replace(/(,)/g, "','");
-							_self.filter[rowid] =
-								"BaseInfo.id in ('" +
-								otCompensIdsStr +
-								"')";
-						}
-
-						var compens = response.compensInfo;
-						if (compens != null) {
-							var defaultJson = {
-								id: compens.id,
-								name: compens.name
-							};
-							$("#entries").jqGrid(
-								"setCell",
-								rowid,
-								"otCompens",
-								defaultJson
-							);
-						}
-					} else {
-						$("#entries").jqGrid(
-							"setCell",
-							rowid,
-							"otType",
-							null
-						);
-					}
-				}
-			},
-			error: function (response) {}
-		});
-	},
-	getOTContrlParams: function (rowid) {
-		var personId;
-		if (!$("#entries").jqGrid("getCell", rowid, "person")) {
-			return;
-		} else {
-			personId = $("#entries").jqGrid("getCell", rowid, "person").id;
-		}
-		var otDate;
-		if (!$("#entries").jqGrid("getCell", rowid, "otDate")) {
-			return;
-		} else {
-			otDate = $("#entries").jqGrid("getCell", rowid, "otDate");
-		}
-		var that = this;
-
-		var url =
-			shr.getContextPath() +
-			"/dynamic.do?handler=com.kingdee.shr.ats.bill.util.BillBizUtil&method=getOTContrlParam";
-		shr.ajax({
-			type: "post",
-			async: false,
-			url: url,
-			data: { personId: personId, otDate: otDate },
-			success: function (res) {
-				if (res) {
-					that.OTContrlParams[rowid] = res;
-					//					isOTControl=res.isOTControl;
-					//					isOtrolByDateType=res.isOtrolByDateType;
-				}
-			}
-		});
-	},
-
-})

+ 617 - 0
js/addon/custom/ats/js/atsOverTimeBillBatchEditEx.js

@@ -0,0 +1,617 @@
+shr.defineClass("shr.ats.AtsOverTimeBillBatchEditEx", shr.ats.AtsOverTimeBillBatchEdit, {
+    initalizeDOM: function () {
+        shr.ats.AtsOverTimeBillBatchEditEx.superClass.initalizeDOM.call(this);
+        // 编辑表格合计
+        var _self = this;
+        var that = this;
+        $("#changeOTEntry").hide();
+        $("#deleteOTEntry").hide();
+        if (
+            shr.getUrlParam("fromCalDetail") != null &&
+            shr.getUrlParam("fromCalDetail") == "1"
+        ) {
+            $("#save").hide();
+            $("#submit").hide();
+            $("#cancelAll").hide();
+            $("#import").hide();
+            $("#orgfill").hide();
+            $(".view_manager_header > div > div").eq(0).remove();
+            $("#submitEffect").addClass("shrbtn-primary");
+            $('#workAreaDiv .ui-jqgrid-bdiv').css('max-height','253px') // 当页面作为弹框时 表格过长则隐藏滑动
+
+        }
+        var billState = $("#billState").val();
+        if ('3'===billState){
+            $("#changeOTEntry").show();
+            $("#deleteOTEntry").show();
+        }
+
+        var entries_cont = waf("#entries");
+        entries_cont.jqGrid("option", {
+            onChange: function (rowid, cellname, value, iRow, iCol) {
+                console.log(rowid, cellname, value, iRow, iCol, 123123);
+            },
+            beforeSaveCell: function (
+                rowid,
+                cellname,
+                value,
+                iRow,
+                iCol
+            ) {
+            },
+            afterSaveCell: function (rowid, cellname, value, iRow, iCol) {
+
+                if (value["adminOrgUnit.id"]) {
+                    $("#entries").jqGrid(
+                        "setCell",
+                        rowid,
+                        "adminOrgUnit.id",
+                        value["adminOrgUnit.id"]
+                    );
+                }
+
+                that.removePreShowError(rowid);
+                if (cellname == "otDate") {
+                    var val = value;
+                    if (val.length <= 10) {
+                        val = val + " 00:00:00";
+                    }
+                    val &&
+                    $("#entries").jqGrid(
+                        "setCell",
+                        rowid,
+                        "startTime",
+                        val
+                    );
+                    val &&
+                    $("#entries").jqGrid(
+                        "setCell",
+                        rowid,
+                        "endTime",
+                        val
+                    );
+                    that.changeOverTimeType(rowid);
+                    that.calRestTimeLen(rowid);
+                    that.getOTContrlParams(rowid);
+                }
+
+                if (cellname == "otType") {
+                    that.changeOTCompens(rowid);
+                }
+                // 添加 开始时间  结束时间   休息时长(分钟) 响应时间
+                if (
+                    cellname == "startTime" ||
+                    cellname == "endTime" ||
+                    cellname == "restTime"
+                ) {
+
+                    if (cellname != "restTime") {
+                        that.calRestTimeLen(rowid);
+                    }
+                    that.calculateOTtimes(rowid);
+                }
+                if (cellname == "person") {
+                    that.calRestTimeLen(rowid);
+                    that.getOTContrlParams(rowid);
+                }
+                if (cellname == "applyOTTime") {
+                    _self.calculateTotal();
+
+                    // 加班小时数  发生改变就给予提示
+                    that.changOtTimeTipInfo(rowid);
+                }
+                if (
+                    cellname == "restStartTime" ||
+                    cellname == "restStartTime2" ||
+                    cellname == "restEndTime" ||
+                    cellname == "restEndTime2"
+                ) {
+                    //计算休息时间,加班时间
+                    var startTime = $("#entries").jqGrid(
+                        "getCell",
+                        rowid,
+                        "startTime"
+                    );
+                    var endTime = $("#entries").jqGrid(
+                        "getCell",
+                        rowid,
+                        "endTime"
+                    );
+                    var restStartTime = $("#entries").jqGrid(
+                        "getCell",
+                        rowid,
+                        "restStartTime"
+                    );
+                    var restEndTime = $("#entries").jqGrid(
+                        "getCell",
+                        rowid,
+                        "restEndTime"
+                    );
+                    var restStartTime2 = $("#entries").jqGrid(
+                        "getCell",
+                        rowid,
+                        "restStartTime2"
+                    );
+                    var restEndTime2 = $("#entries").jqGrid(
+                        "getCell",
+                        rowid,
+                        "restEndTime2"
+                    );
+                    if (startTime == "" || endTime == "") {
+                        return;
+                    }
+
+                    var totalRestTime = 0;
+                    var totalRestTimeLong = 0;
+                    var restStartTimeOfDate;
+                    var restEndTimeOfDate;
+                    if (shr.getBowserInfo().browser === 'IE' || shr.getBowserInfo().browser === 'Safari') {
+                        restStartTime = restStartTime.replace(/-/g, '/');
+                        restEndTime = restEndTime.replace(/-/g, '/');
+                        restStartTime2 = restStartTime2.replace(/-/g, '/');
+                        restEndTime2 = restEndTime2.replace(/-/g, '/');
+                    }
+                    if (restStartTime != "" && restEndTime != "") {
+                        restStartTimeOfDate = new Date(restStartTime);
+                        restEndTimeOfDate = new Date(restEndTime);
+                        var times =
+                            restEndTimeOfDate.getTime() -
+                            restStartTimeOfDate.getTime();
+                        if (times < 0) {
+                            times = 0;
+                        }
+                        totalRestTimeLong += times;
+                        times = times / 1000 / 60;
+                        totalRestTime += times;
+                    }
+                    if (restStartTime2 != "" && restEndTime2 != "") {
+                        var restStartTime2OfDate = new Date(restStartTime2);
+                        var restEndTime2OfDate = new Date(restEndTime2);
+                        if (
+                            (restStartTime != "" &&
+                                restEndTime2OfDate.getTime() >
+                                restStartTimeOfDate.getTime() &&
+                                restStartTimeOfDate.getTime() >=
+                                restStartTime2OfDate.getTime()) ||
+                            (restEndTime != "" &&
+                                restEndTimeOfDate.getTime() <=
+                                restEndTime2OfDate.getTime() &&
+                                restStartTime2OfDate.getTime() <
+                                restEndTimeOfDate.getTime()) ||
+                            (restStartTime != "" &&
+                                restEndTime != "" &&
+                                restEndTimeOfDate.getTime() >=
+                                restEndTime2OfDate.getTime() &&
+                                restStartTime2OfDate.getTime() >=
+                                restStartTimeOfDate.getTime())
+                        ) {
+                            //时间有交叉
+                            $("#entries").jqGrid(
+                                "setCell",
+                                rowid,
+                                "restEndTime2",
+                                restStartTime2
+                            );
+                        } else {
+                            var times =
+                                restEndTime2OfDate.getTime() -
+                                restStartTime2OfDate.getTime();
+                            if (times < 0) {
+                                times = 0;
+                            }
+                            totalRestTimeLong += times;
+                            times = times / 1000 / 60;
+                            totalRestTime += times;
+                        }
+                    }
+                    var t1 = totalRestTime.toFixed(
+                        atsMlUtile.getSysDecimalPlace()
+                    );
+                    $("#entries").jqGrid("setCell", rowid, "restTime", t1);
+                    var startTime = NewDate(startTime + ":00");
+                    var endTime = NewDate(endTime + ":00");
+                    var se =
+                        endTime.getTime() -
+                        startTime.getTime() -
+                        totalRestTimeLong; // 毫秒
+                    var tfl = se / (3600 * 1000);
+                    $("#entries").jqGrid(
+                        "setCell",
+                        rowid,
+                        "applyOTTime",
+                        tfl
+                    );
+                    that.getOTContrlParams(rowid);
+                }
+            },
+            afterEditCell: function (rowid, cellname, value, iRow, iCol) {
+                _self.calculateTotal();
+                if (
+                    cellname == "otType" &&
+                    that.OTContrlParams[rowid] &&
+                    that.OTContrlParams[rowid].isOtrolByDateType
+                ) {
+                    $("#" + iRow + "_otType").shrPromptBox("disable");
+                }
+                if (cellname == "otCompens") {
+                    if (that.filter[rowid] == undefined) {
+                        // R20221006-0542 修复选择加班费后 再点击“补偿方式”F7就变成了调休的问题
+                        // that.changeOTCompens(rowid);
+                    }
+                    if (that.filter[rowid]) {
+                        //						$("#"+rowid+"_otCompens").shrPromptBox("setFilter",that.filter[rowid]);
+                        $(
+                            "#" +
+                            $("#entries").jqGrid(
+                                "getCell",
+                                rowid,
+                                "rn"
+                            ) +
+                            "_otCompens"
+                        ).shrPromptBox("setFilter", that.filter[rowid]);
+                    }
+                }
+                if (cellname == "person") {
+                    var hrOrgUnitId = $("#hrOrgUnit_el").val();
+                    $("#" + rowid + "_person")
+                        .shrPromptBox()
+                        .attr("data-params", hrOrgUnitId);
+                    $("#" + iRow + "_person").shrPromptBox("option", {
+                        onchange: function (e, value) {
+                            $("#entries").jqGrid(
+                                "setCell",
+                                rowid,
+                                "person.number",
+                                value.current
+                                    ? value.current["person.number"]
+                                    : ""
+                            );
+                        }
+                    });
+
+                }
+                if (cellname == "attAdminOrgUnit") {
+                    var personId = $("#entries").jqGrid("getCell", rowid, "person").id;
+                    var attendanceDate = $("#entries").jqGrid("getCell", rowid, "otDate");
+
+                    if (!(personId && attendanceDate)) {
+                        shr.showInfo({message: jsBizMultLan.atsManager_atsOverTimeBillEdit_YM_999});
+                        return false;
+                    } else {
+                        //$("#"+rowid+"_attPosition").shrPromptBox().attr("data-params", adminOrg);
+                        $("#" + iRow + "_attAdminOrgUnit").shrPromptBox("setOtherParams", {
+                            personId: personId,
+                            attendanceDate: attendanceDate
+                        });
+                    }
+                }
+            }
+            , footerrow: function (rowid, cellname, value, iRow, iCol) {
+            }
+        });
+        $(".ui-jqgrid-sdiv").show();
+        // $(".footrow-ltr td:first").html('合计').parent().css("border-color", "#EEE");
+        $(".footrow-ltr").last().find("td:first").html('合计').parent().css("border-color", "#EEE");
+        _self.calculateTotal();
+
+    },
+
+    calculateTotal() {
+        var count = 0;
+        var ids = $("#entries").jqGrid('getDataIDs');
+        for (var i = 0; i < ids.length; i++) {
+            var rowData = $('#entries').jqGrid('getRowData', ids[i]);
+            count = count + Number(rowData.applyOTTime);
+        }
+        $("#count").val(count.toFixed(2));
+        $("#entries").footerData("set", {"applyOTTime": count.toFixed(2)}); //
+    }, //去除个性化展示,每次校验前去除
+    removePreShowError: function (rowid) {
+        var rnColNum = this.getColNumIndex();
+        var rows = $("#entries").getGridParam("reccount");
+        var td = $("#entries").find("tr[id='" + rowid + "'] td:eq(" + rnColNum + ")");
+        td.attr(
+            "title",
+            ""
+        );
+        td.html(
+            $("#entries").find("tr[id='" + rowid + "']")[0].rowIndex
+        );
+        td.css(
+            "color",
+            "rgb(153, 153, 153)"
+        );
+        $("#entries").find("tr[id='" + rowid + "']").css(
+            "color",
+            "rgb(153, 153, 153)"
+        ); //如果设置成css("color","initial")会变成黑色,而原界面为灰色
+    },
+    changeOverTimeType: function (rowid) {
+        var that = this;
+        var otDate;
+        var personId;
+        if (!$("#entries").jqGrid("getCell", rowid, "otDate")) {
+            return;
+        } else {
+            otDate = $("#entries").jqGrid("getCell", rowid, "otDate");
+        }
+
+        if (!$("#entries").jqGrid("getCell", rowid, "person")) {
+            return;
+        } else {
+            personId = $("#entries").jqGrid("getCell", rowid, "person").id;
+        }
+        that.getOverTimeType(rowid, otDate, personId);
+    },
+    getOverTimeType: function (rowid, otDate, personId) {
+        var _self = this;
+        var tDate = otDate;
+        var url =
+            shr.getContextPath() +
+            "/dynamic.do?method=getOverTimeTypeAndOtCompens";
+        url +=
+            "&otDate=" +
+            encodeURIComponent(otDate) +
+            "&personId=" +
+            encodeURIComponent(personId) + "&uipk=" + shr.getUrlRequestParam('uipk');
+        $.ajax({
+            url: url,
+            async: false,
+            success: function (response) {
+                if (
+                    response.otTypeValue != null &&
+                    response.otTypeValue != undefined &&
+                    response.otTypeValue != ""
+                ) {
+                    var responseObejct = {
+                        id: response.otTypeValue,
+                        name: response.otTypeText
+                    };
+                    if (_self.isOtTypeEffective(response.otTypeValue)) {
+                        // $('#entries').restoreCell(rowid,4); // 先恢复单元格状态再重新赋值,可以避免
+                        $("#entries").jqGrid(
+                            "setCell",
+                            rowid,
+                            "otType",
+                            responseObejct
+                        );
+                        //设置该加班类型的补偿方式过滤
+                        var otCompensIds = _self.getOTCompensByOTType(
+                            personId,
+                            response.otTypeValue,
+                            tDate
+                        );
+                        if (otCompensIds) {
+                            var otCompensIdsStr = _self
+                                .getOTCompensByOTType(
+                                    personId,
+                                    response.otTypeValue,
+                                    tDate
+                                )
+                                .replace(/(,)/g, "','");
+                            _self.filter[rowid] =
+                                "BaseInfo.id in ('" +
+                                otCompensIdsStr +
+                                "')";
+                        }
+
+                        var compens = response.compensInfo;
+                        if (compens != null) {
+                            var defaultJson = {
+                                id: compens.id,
+                                name: compens.name
+                            };
+                            $("#entries").jqGrid(
+                                "setCell",
+                                rowid,
+                                "otCompens",
+                                defaultJson
+                            );
+                        }
+                    } else {
+                        $("#entries").jqGrid(
+                            "setCell",
+                            rowid,
+                            "otType",
+                            null
+                        );
+                    }
+                }
+            },
+            error: function (response) {
+            }
+        });
+    },
+    getOTContrlParams: function (rowid) {
+        var personId;
+        if (!$("#entries").jqGrid("getCell", rowid, "person")) {
+            return;
+        } else {
+            personId = $("#entries").jqGrid("getCell", rowid, "person").id;
+        }
+        var otDate;
+        if (!$("#entries").jqGrid("getCell", rowid, "otDate")) {
+            return;
+        } else {
+            otDate = $("#entries").jqGrid("getCell", rowid, "otDate");
+        }
+        var that = this;
+
+        var url =
+            shr.getContextPath() +
+            "/dynamic.do?handler=com.kingdee.shr.ats.bill.util.BillBizUtil&method=getOTContrlParam";
+        shr.ajax({
+            type: "post",
+            async: false,
+            url: url,
+            data: {personId: personId, otDate: otDate},
+            success: function (res) {
+                if (res) {
+                    that.OTContrlParams[rowid] = res;
+                    //					isOTControl=res.isOTControl;
+                    //					isOtrolByDateType=res.isOtrolByDateType;
+                }
+            }
+        });
+    },
+
+    /**
+     * 选择条件
+     */
+    changeOTEntryAction: function () {
+        var _self = this;
+        var wafentries = waf("#entries");
+        var billID = this.billId;
+        var entryId = wafentries.jqGrid("getSelectedRows").toString();
+        if (entryId) {
+
+            var person = wafentries.jqGrid("getCell", entryId, 'person');
+            var personName = (person.name ? person.name : person.name_l2);
+            var startTime = wafentries.jqGrid("getCell", entryId, 'startTime');
+            var endTime = wafentries.jqGrid("getCell", entryId, 'endTime');
+
+            shr.showConfirm("是否變更&lt;" + personName + "&gt;,&lt;" + startTime + "&gt;至&lt;" + endTime + "&gt;加班單?", function () {
+                _self.remoteCall({
+                    type: "post",
+                    method: "changeOTEntry",
+                    param: {
+                        billID: billID,
+                        entryId: entryId
+                    },
+                    async: true,
+                    success: function (res) {
+                        if (res && 'err' === res.code) {
+                            shr.showWarning({
+                                message: res.msg,
+                                hideAfter: 6
+                            });
+                        } else {
+
+                            var serviceId = shr.getUrlRequestParam("serviceId");
+                            var url = shr.getContextPath() +
+                                "/dynamic.do?&uipk=com.kingdee.eas.hr.ats.app.AtsOverTimeBillAllForm.change";
+                            url += "&serviceId=" + encodeURIComponent(serviceId);
+                            url += "&oldBillID=" + billID + "&oldEntryId=" + entryId;
+                            url += "&billId=" + res.billID+ "&entryId=" + res.entryId;
+                            url += "&method=edit&debug=true";
+                            $("#changeFillDiv").attr("src", url);
+
+                            $("#changeFillDiv").dialog({
+                                title: '變更' + personName + '加班單',
+                                width: 1020,
+                                height: 450,
+                                modal: true,
+                                resizable: false,
+                                position: {
+                                    my: "center",
+                                    at: "top+20%",
+                                    of: window
+                                },
+                                open: function (event, ui) {
+                                },
+                                close: function(event, ui) {
+                                    $("#changeFillDiv").empty();
+                                    _self.unChangeOTEntry(_self,res.billID,res.entryId);
+
+                                    window.document.location.reload();
+                                },
+                                buttons: [
+                                    {
+                                        text:
+                                            "提交",
+                                        click: function () {
+                                            $(window.frames["changeFillDiv"].document).find("#save").click();
+                                        }
+                                    },
+                                    {
+                                        text:
+                                            "取消",
+                                        click: function () {
+                                            $($(window.parent.document).find(".ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close")).click()
+                                        }
+                                    }
+                                ]
+                            });
+
+                            $("#changeFillDiv").attr("style", "width:1020px;height:550px;");
+                        }
+                    }
+                });
+            });
+        }else{
+            shr.showWarning({
+                message: "請選擇要變更的行",
+                hideAfter: 3
+            });
+        }
+    },
+
+    unChangeOTEntry: function (_self,billID,entryId){
+        _self.remoteCall({
+            type: "post",
+            method: "unChangeOTEntry",
+            param: {
+                billID: billID,
+                entryId: entryId
+            },
+            async: true,
+            success: function (res) {
+                if (res) {
+                    // shr.showWarning({
+                    //     message: res.msg,
+                    //     hideAfter: 6
+                    // });
+
+                }
+            }
+        });
+    },
+    /**
+     * 选择条件
+     */
+    deleteOTEntryAction: function () {
+        var _self = this;
+        var wafentries = waf("#entries");
+        var entryId = wafentries.jqGrid("getSelectedRows").toString();
+        if (entryId) {
+
+            var person = wafentries.jqGrid("getCell", entryId, 'person');
+            var personName = (person.name ? person.name : person.name_l2);
+            var startTime = wafentries.jqGrid("getCell", entryId, 'startTime');
+            var endTime = wafentries.jqGrid("getCell", entryId, 'endTime');
+            shr.showConfirm("是否取消&lt;" + personName + "&gt;,&lt;" + startTime + "&gt;至&lt;" + endTime + "&gt;加班單?", function () {
+
+                _self.remoteCall({
+                    type: "post",
+                    method: "deleteOTEntry",
+                    param: {
+                        billID: this.billId,
+                        entryId: entryId
+                    },
+                    async: true,
+                    success: function (res) {
+                        if (res && 'err' === res.code) {
+                            shr.showWarning({
+                                message: res.msg,
+                                hideAfter: 6
+                            });
+                        }else {
+                            shr.showWarning({
+                                message: "刪除成功",
+                                hideAfter: 6
+                            });
+                            wafentries.jqGrid("delRowData",entryId)
+                        }
+                    }
+                });
+            });
+        }else {
+            shr.showWarning({
+                message: "請選擇要刪除的行",
+                hideAfter: 3
+            });
+        }
+    },
+
+})
+

+ 24 - 0
js/addon/custom/ats/js/atsOverTimeBillEditEx.js

@@ -0,0 +1,24 @@
+shr.defineClass("shr.ats.AtsOverTimeBillEditEx", shr.ats.AtsOverTimeBillEdit, {
+    initalizeDOM:function(){
+        shr.ats.AtsOverTimeBillEditEx.superClass.initalizeDOM.call(this);
+        $("#save").hide()
+    },
+    /**
+     * 组装保存时传至服务端的数据
+     */
+    assembleSaveData: function(action) {
+        var _self = this;
+        var data = shr.ats.AtsOverTimeBillEditEx.superClass.assembleSaveData.call(this,action);
+        var oldEntryId = shr.getUrlRequestParam("oldEntryId");
+        var oldBillID = shr.getUrlRequestParam("oldBillID");
+        data.oldEntryId=oldEntryId;
+        data.oldBillID=oldBillID;
+        return data;
+    },
+    /**
+     * 保存完成回调
+     */
+    viewAction: function(options) {
+        $($(window.parent.document).find(".ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close")).click()
+    },
+});

+ 91 - 0
websrc/com/kingdee/eas/custom/ot/handler/AtsOverTimeBillBatchEditHandlerEx.java

@@ -0,0 +1,91 @@
+package com.kingdee.eas.custom.ot.handler;
+
+import com.kingdee.bos.Context;
+import com.kingdee.eas.custom.ot.util.OverTimeAgainstApproveUtil;
+import com.kingdee.shr.ats.web.handler.AtsOverTimeBillBatchEditHandler;
+import com.kingdee.shr.base.syssetting.context.SHRContext;
+import com.kingdee.shr.base.syssetting.exception.SHRWebException;
+import org.springframework.ui.ModelMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+
+/**
+ * 多人加班单审核通过的单据分录,删除、变更实现
+ * @author lhbj
+ */
+public class AtsOverTimeBillBatchEditHandlerEx extends AtsOverTimeBillBatchEditHandler {
+    /**
+     * 核通过的单据分录删除
+     * @param request
+     * @param response
+     * @param modelMap
+     * @return
+     * @throws SHRWebException
+     */
+    public String deleteOTEntryAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
+        try {
+            Context ctx = SHRContext.getInstance().getContext();
+            String billid = this.getBillId(request);
+            String entryId = request.getParameter("entryId");
+            OverTimeAgainstApproveUtil u = new OverTimeAgainstApproveUtil();
+            Map<String, Object> map = u.deleteOTEntry(ctx, billid, entryId);
+            System.out.println("deleteOTEntryAction:"+map);
+            this.writeSuccessData(map);
+        }catch (Exception e){
+            e.printStackTrace();
+            throw new SHRWebException(e);
+        }
+        return null;
+    }
+    /**
+     * 核通过的单据分录变更
+     * @param request
+     * @param response
+     * @param modelMap
+     * @return
+     * @throws SHRWebException
+     */
+    public String changeOTEntryAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
+
+        try {
+            Context ctx = SHRContext.getInstance().getContext();
+            String billid = this.getBillId(request);
+            String entryId = request.getParameter("entryId");
+            OverTimeAgainstApproveUtil u = new OverTimeAgainstApproveUtil();
+            Map<String, Object> map = u.changeOTEntry(ctx, billid, entryId);
+            this.writeSuccessData(map);
+        }catch (Exception e){
+            e.printStackTrace();
+            throw new SHRWebException(e);
+        }
+
+        return null;
+    }
+    /**
+     * 取消核通过的单据分录变更
+     * @param request
+     * @param response
+     * @param modelMap
+     * @return
+     * @throws SHRWebException
+     */
+    public String unChangeOTEntryAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
+
+        try {
+            Context ctx = SHRContext.getInstance().getContext();
+            String billid = this.getBillId(request);
+            String entryId = request.getParameter("entryId");
+            OverTimeAgainstApproveUtil u = new OverTimeAgainstApproveUtil();
+            Map<String, Object> map = u.unChangeOTEntry(ctx, billid, entryId);
+            this.writeSuccessData(map);
+        }catch (Exception e){
+            e.printStackTrace();
+            throw new SHRWebException(e);
+        }
+
+        return null;
+    }
+
+}

+ 68 - 0
websrc/com/kingdee/eas/custom/ot/handler/AtsOverTimeBillEditHandlerEx.java

@@ -0,0 +1,68 @@
+package com.kingdee.eas.custom.ot.handler;
+
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.bos.util.BOSUuid;
+
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.ot.util.OverTimeAgainstApproveUtil;
+import com.kingdee.eas.framework.CoreBaseInfo;
+import com.kingdee.eas.hr.ats.AtsOverTimeBillInfo;
+import com.kingdee.eas.util.app.DbUtil;
+import com.kingdee.shr.ats.web.handler.AtsOverTimeBillEditHandler;
+import com.kingdee.shr.base.syssetting.context.SHRContext;
+import com.kingdee.shr.base.syssetting.exception.SHRWebException;
+import org.springframework.ui.ModelMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+
+/**
+ * 多人加班单审核通过的单据分录变更后保存新增单据的实现
+ * @author lhbj
+ */
+public class AtsOverTimeBillEditHandlerEx extends AtsOverTimeBillEditHandler {
+    protected void beforeSave(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model) throws SHRWebException {
+        //处理原单分录,以跳过标准校验
+        AtsOverTimeBillInfo billInfo = (AtsOverTimeBillInfo)model;
+        Context ctx = SHRContext.getInstance().getContext();
+        String oldEntryId = request.getParameter("oldEntryId");
+        String oldBillID = request.getParameter("oldBillID");
+        String updEntry = "update T_HR_ATS_OverTimeBillEntry set fbillid=? where fid=?";
+        String newId = String.valueOf(BOSUuid.create(billInfo.getBOSType()));
+        try {
+            DbUtil.execute(ctx, updEntry, new String[]{newId.toString(), oldEntryId});
+        } catch (BOSException e) {
+            throw new RuntimeException(e);
+        }
+        super.beforeSave(request, response, model);
+    }
+    protected void afterSave(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model) throws SHRWebException {
+        super.afterSave(request, response, model);
+        //处理原单分录,以跳过标准校验
+        AtsOverTimeBillInfo billInfo = (AtsOverTimeBillInfo)model;
+        Context ctx = SHRContext.getInstance().getContext();
+        String oldEntryId = request.getParameter("oldEntryId");
+        String oldBillID = request.getParameter("oldBillID");
+
+        String newId = billInfo.getId().toString();
+        try {
+            String updBill = "update T_HR_ATS_OverTimeBill set FBillState=3 where fid=?";
+            DbUtil.execute(ctx, updBill, new String[]{newId});
+            String updEntry = "update T_HR_ATS_OverTimeBillEntry set fbillid=? where fid=?";
+            DbUtil.execute(ctx, updEntry, new String[]{oldBillID, oldEntryId});
+            //生成新单据完成后,删除原单据分录数据,然后触发计算
+            OverTimeAgainstApproveUtil u = new OverTimeAgainstApproveUtil();
+            Map<String, Object> map = u.deleteOTEntry(ctx, oldBillID, oldEntryId);
+            System.out.println("afterSave:"+map);
+        } catch (BOSException e) {
+            throw new RuntimeException(e);
+        } catch (EASBizException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    public String saveAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
+       return super.saveAction(request, response, modelMap);
+    }
+}

+ 592 - 0
websrc/com/kingdee/eas/custom/ot/util/OverTimeAgainstApproveUtil.java

@@ -0,0 +1,592 @@
+package com.kingdee.eas.custom.ot.util;
+
+import com.google.common.collect.Maps;
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.bos.dao.ObjectNotFoundException;
+import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
+import com.kingdee.bos.metadata.entity.SelectorItemCollection;
+import com.kingdee.bos.metadata.entity.SelectorItemInfo;
+import com.kingdee.bos.util.BOSUuid;
+import com.kingdee.eas.base.permission.UserInfo;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.framework.CoreBaseCollection;
+import com.kingdee.eas.hr.ats.*;
+import com.kingdee.eas.hr.ats.dataLog.util.DataLogsRecordUtil;
+import com.kingdee.eas.hr.ats.takeWorkLimit.impl.GenerateTakeWorkLimit;
+import com.kingdee.eas.hr.ats.thread.ExecutorService.TaskPool;
+import com.kingdee.eas.hr.ats.thread.executor.Callable;
+import com.kingdee.eas.hr.ats.util.AtsDateUtils;
+import com.kingdee.eas.hr.ats.util.AtsServerCalUtils;
+import com.kingdee.eas.hr.ats.util.SHRBillServerUtil;
+import com.kingdee.eas.hr.ats.util.common.MLUtile;
+import com.kingdee.eas.util.app.DbUtil;
+import com.kingdee.jdbc.rowset.IRowSet;
+import com.kingdee.shr.ats.bill.util.AtsBillSourceTypeUtil;
+import com.kingdee.shr.ats.service.result.AttendCalculateParent;
+import com.kingdee.shr.ats.service.vo.AtsOverTimeVo;
+import com.kingdee.shr.base.syssetting.app.osf.OSFAppUtil;
+import com.kingdee.shr.base.syssetting.exception.SHRWebException;
+import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+
+import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * 加班单
+ * 反审批
+ *
+ * @ lhbj
+ */
+public class OverTimeAgainstApproveUtil {
+    private static Logger logger = Logger.getLogger(OverTimeAgainstApproveUtil.class);
+
+    public String getBillIds(HttpServletRequest request) throws ShrWebBizException {
+        String billId = (String) request.getAttribute("billId");
+        if (StringUtils.isEmpty(billId)) {
+            billId = request.getParameter("billId");
+        }
+
+        if (StringUtils.isEmpty(billId)) {
+            billId = request.getParameter("billID");
+        }
+        if (StringUtils.isEmpty(billId)) {
+            billId = (String) request.getAttribute("billID");
+        }
+        if (StringUtils.isEmpty(billId)) {
+            throw new ShrWebBizException(new AtsCommonBizException(AtsCommonBizException.NULLBILLID));
+        } else {
+            return billId;
+        }
+    }
+
+    /**
+     * 取消核通过的单据分录变更
+     * @param ctx
+     * @param billId
+     * @param entryId
+     * @return
+     * @throws SHRWebException
+     */
+    public Map<String, Object> unChangeOTEntry(Context ctx, String billId, String entryId) throws BOSException {
+        Map<String, Object> res = Maps.newHashMap();
+//        IAtsOverTimeBill iBill = AtsOverTimeBillFactory.getLocalInstance(ctx);
+//        IAtsOverTimeBillEntry iBillEntry = AtsOverTimeBillEntryFactory.getLocalInstance(ctx);
+        //删除新单据分录
+        String updEntry2 = "delete from T_HR_ATS_OverTimeBillEntry where fid=?";
+        DbUtil.execute(ctx, updEntry2, new String[]{entryId.toString()});
+        //新单据
+//        String delNewBill = "delete from T_HR_ATS_OverTimeBill where fid=?";
+//        DbUtil.execute(ctx, delNewBill, new String[]{billId.toString()});
+        return res;
+    }
+
+    /**
+     * 变更审批通过的分录
+     * 第一步:生成一样数据进行
+     *
+     * @param ctx
+     * @param billId
+     * @param entryId
+     * @return
+     */
+    public Map<String, Object> changeOTEntry(Context ctx, String billId, String entryId) throws BOSException {
+        System.out.println("changeOTEntry");
+        Map<String, Object> res = Maps.newHashMap();
+        IAtsOverTimeBill iBill = AtsOverTimeBillFactory.getLocalInstance(ctx);
+        IAtsOverTimeBillEntry iBillEntry = AtsOverTimeBillEntryFactory.getLocalInstance(ctx);
+        //更新id
+        BOSUuid newId = null;
+        BOSUuid newEntryId = null;
+
+        res.put("code", "err");
+        res.put("msg", "失败");
+        try {
+            System.out.println("changeOTEntry:" + billId + "-" + entryId);
+            SelectorItemCollection selectorItemCollection = new SelectorItemCollection();
+            selectorItemCollection.add(new SelectorItemInfo("*"));
+            //获取原单分录
+            AtsOverTimeBillEntryInfo oldEntryInfo = iBillEntry.getAtsOverTimeBillEntryInfo(new ObjectUuidPK(entryId), selectorItemCollection);
+            //获取原单
+            AtsOverTimeBillInfo oldBillInfo = iBill.getAtsOverTimeBillInfo(new ObjectUuidPK(billId), selectorItemCollection);
+            System.out.println("changeOTEntry");
+            //创建新单
+            AtsOverTimeBillInfo newBillInfo = (AtsOverTimeBillInfo) oldBillInfo.clone();
+            newBillInfo.setSourceBillId(newBillInfo.getId().toString());
+            //更新为单人编辑界面
+            newBillInfo.setBillSubmitType(BillSubmitTypeEnum.common);
+            System.out.println("changeOTEntry");
+            //更新id
+            newId = BOSUuid.create(oldBillInfo.getBOSType());
+            newBillInfo.setId(newId);
+            //创建新单分录集合
+            AtsOverTimeBillEntryCollection newEntryCollection = new AtsOverTimeBillEntryCollection();
+            //添加待变更分录
+            AtsOverTimeBillEntryInfo newEntryInfo = (AtsOverTimeBillEntryInfo) oldEntryInfo.clone();
+            //变更分录id
+            newEntryId = BOSUuid.create(oldEntryInfo.getBOSType());
+            newEntryInfo.setId(newEntryId);
+            newEntryInfo.setBill(newBillInfo);
+            newEntryCollection.add(newEntryInfo);
+            newBillInfo.put("entries", newEntryCollection);
+            System.out.println("changeOTEntry4" + newBillInfo);
+            iBill.addnew(new ObjectUuidPK(newId), newBillInfo);
+            //更新新单为审批通过
+            String updBill = "update T_HR_ATS_OverTimeBill set FBillState=3 where fid=?";
+            DbUtil.execute(ctx, updBill, new String[]{newId.toString()});
+            System.out.println("changeOTEntry5" + newId.toString());
+            //反审批校验
+            Map<String, Object> bres = this.beforeAgainstApproveAction(ctx, newId.toString());
+            System.out.println("changeOTEntry6" + bres.toString());
+            res.putAll(bres);
+            String errorMsgList = (String) bres.get("errorMsgList");
+            if (StringUtils.isNotBlank(errorMsgList)) {
+                //校验失败
+                res.put("code", "err");
+                res.put("msg", errorMsgList);
+            } else {
+                //更新新单为未提交状态
+                String updBill2 = "update T_HR_ATS_OverTimeBill set FBillState=0 where fid=?";
+                DbUtil.execute(ctx, updBill2, new String[]{newId.toString()});
+                res.put("msg", "成功");
+                res.put("billID", newId.toString());
+                res.put("entryId", newEntryId.toString());
+                res.put("oldBillID", billId.toString());
+                res.put("oldEntryId", entryId.toString());
+                res.put("code", "ses");
+            }
+            //反审批失败处理
+            if ("err".equals(res.get("code"))) {
+                //删除新单据分录
+                String updEntry2 = "delete from T_HR_ATS_OverTimeBillEntry where fid=?";
+                DbUtil.execute(ctx, updEntry2, new String[]{newEntryId.toString()});
+                //新单据
+                String delNewBill = "delete from T_HR_ATS_OverTimeBill where fid=?";
+                DbUtil.execute(ctx, delNewBill, new String[]{newId.toString()});
+            } else {
+                //需要等待专员变更后处理
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            res.put("msg", e.getMessage());
+            //删除新单据分录
+            String updEntry2 = "delete from T_HR_ATS_OverTimeBillEntry where fid=?";
+            DbUtil.execute(ctx, updEntry2, new String[]{newEntryId.toString()});
+            //新单据
+            String delNewBill = "delete from T_HR_ATS_OverTimeBill where fid=?";
+            DbUtil.execute(ctx, delNewBill, new String[]{newId.toString()});
+            logger.error(e);
+        } finally {
+            System.out.println("deleteOTEntry.finally:" + res);
+        }
+        return res;
+    }
+
+    /**
+     * 删除审批通过的分录
+     *
+     * @param ctx
+     * @param billId
+     * @param entryId
+     * @return
+     */
+    public Map<String, Object> deleteOTEntry(Context ctx, String billId, String entryId) throws BOSException, EASBizException {
+        System.out.println("deleteOTEntry");
+        Map<String, Object> res = Maps.newHashMap();
+        IAtsOverTimeBill iBill = AtsOverTimeBillFactory.getLocalInstance(ctx);
+        IAtsOverTimeBillEntry iBillEntry = AtsOverTimeBillEntryFactory.getLocalInstance(ctx);
+        //更新id
+        BOSUuid newId = null;
+        res.put("code", "err");
+        res.put("msg", "失败");
+        try {
+            System.out.println("deleteOTEntry:" + billId + "-" + entryId);
+            SelectorItemCollection selectorItemCollection = new SelectorItemCollection();
+            selectorItemCollection.add(new SelectorItemInfo("*"));
+            //获取原单分录
+            AtsOverTimeBillEntryInfo oldEntryInfo = iBillEntry.getAtsOverTimeBillEntryInfo(new ObjectUuidPK(entryId), selectorItemCollection);
+            //获取原单
+            AtsOverTimeBillInfo oldBillInfo = iBill.getAtsOverTimeBillInfo(new ObjectUuidPK(billId), selectorItemCollection);
+            System.out.println("deleteOTEntry1");
+            //创建新单
+            AtsOverTimeBillInfo newBillInfo = (AtsOverTimeBillInfo) oldBillInfo.clone();
+            newBillInfo.setSourceBillId(newBillInfo.getId().toString());
+            System.out.println("deleteOTEntry2");
+            //更新id
+            newId = BOSUuid.create(oldBillInfo.getBOSType());
+            newBillInfo.setId(newId);
+            //创建新单分录集合
+            AtsOverTimeBillEntryCollection newEntryCollection = new AtsOverTimeBillEntryCollection();
+            //添加待删除分录
+            newBillInfo.put("entries", newEntryCollection);
+            System.out.println("deleteOTEntry4" + newBillInfo);
+            iBill.addnew(new ObjectUuidPK(newId), newBillInfo);
+            //更新原单分录为新单据分录
+            String updEntry = "update T_HR_ATS_OverTimeBillEntry set fbillid=? where fid=?";
+            DbUtil.execute(ctx, updEntry, new String[]{newId.toString(), entryId});
+            System.out.println("deleteOTEntry3");
+
+            //更新新单为审批通过
+            String updBill = "update T_HR_ATS_OverTimeBill set FBillState=3 where fid=?";
+            DbUtil.execute(ctx, updBill, new String[]{newId.toString()});
+            System.out.println("deleteOTEntry5" + newId.toString());
+            //反审批校验
+            Map<String, Object> bres = this.beforeAgainstApproveAction(ctx, newId.toString());
+            System.out.println("deleteOTEntry6" + bres.toString());
+            res.putAll(bres);
+            String errorMsgList = (String) bres.get("errorMsgList");
+            if (StringUtils.isNotBlank(errorMsgList)) {
+                //校验失败
+                res.put("code", "err");
+                res.put("msg", errorMsgList);
+            } else {
+                Map<String, Object> ares = this.againstApproveAction(ctx, "删除分录", newId.toString());
+                res.putAll(ares);
+                Set<String> successIds = (Set<String>) ares.get("successIds");
+                if (1 != successIds.size()) {
+                    //反审批失败
+                    res.put("code", "err");
+                } else {
+                    res.put("code", "ses");
+                }
+            }
+            //反审批失败处理
+            if ("err".equals(res.get("code"))) {
+                //更新新单据分录为原单分录
+                String updEntry2 = "update T_HR_ATS_OverTimeBillEntry set fbillid=? where fid=?";
+                DbUtil.execute(ctx, updEntry2, new String[]{billId, entryId});
+                //新单据
+                String delNewBill = "delete from T_HR_ATS_OverTimeBill where fid=?";
+                DbUtil.execute(ctx, delNewBill, new String[]{newId.toString()});
+            } else {
+                //新单据
+                String delNewBill = "delete from T_HR_ATS_OverTimeBill where fid=?";
+                DbUtil.execute(ctx, delNewBill, new String[]{newId.toString()});
+                //新单据
+                String delNewEntry = "delete from T_HR_ATS_OverTimeBillEntry where fid=?";
+                DbUtil.execute(ctx, delNewEntry, new String[]{entryId.toString()});
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            res.put("msg", e.getMessage());
+            //更新新单据分录为原单分录
+            String updEntry2 = "update T_HR_ATS_OverTimeBillEntry set fbillid=? where fid=?";
+            DbUtil.execute(ctx, updEntry2, new String[]{billId, entryId});
+            logger.error(e);
+        } finally {
+            System.out.println("deleteOTEntry.finally:" + res);
+            String delNewBill = "delete from T_HR_ATS_OverTimeBill where fid=?";
+            DbUtil.execute(ctx, delNewBill, new String[]{newId.toString()});
+        }
+        return res;
+    }
+
+
+    /**
+     * 反审批前校验
+     *
+     * @param ctx
+     * @param billIds
+     * @return {"turned":15,"errorMsgList":"[贺加贝]的选中记录中存在加班单参与了加班转调休计算,反审批后调休额度的剩余额度小于0且假期制度不允许超额请假,请先将请假单反审批再操作!","turnedInfos":"[刘光辉 2025-07-01]、[Mike 2025-07-01]、[王斌 2025-07-01]、[周芳 2025-07-01]、[刘浔 2025-07-01]、[simone 2025-07-01]、[曹浪 2025-07-01]、[唐建强 2025-07-01]、[田文立 2025-07-01]、[张晗 2025-07-01]、[张大利 2025-07-01]、[Vincent 2025-07-01]、[高爽 2025-07-01]、[贺加贝 2025-07-01]、[张三01 2025-07-01]"}
+     * @throws SHRWebException
+     * @throws BOSException
+     * @throws EASBizException
+     */
+    public Map<String, Object> beforeAgainstApproveAction(Context ctx, String billIds) throws SHRWebException, BOSException, EASBizException {
+        Map<String, Object> res = new HashMap();
+        String flag = "true";
+
+        if (StringUtils.isBlank(billIds)) {
+            throw new ShrWebBizException(new AtsCommonBizException(AtsCommonBizException.ILLEGALID));
+        } else {
+            IAtsOverTimeBill iAtsOverTimeInfo = AtsOverTimeBillFactory.getRemoteInstance();
+            String[] ids = billIds.split(",");
+            Map<String, BigDecimal> limitDeductMap = new HashMap();
+            if (ids != null && ids.length > 0) {
+                for (int i = 0; i < ids.length; ++i) {
+                    String billId = ids[i];
+                    if ("true".equals(flag)) {
+                        StringBuffer checkSB = new StringBuffer("");
+                        checkSB.append("select sum.fid from T_HR_ATS_AttendanceResultSum sum inner join T_HR_ATS_OverTimeBillEntry lbe on lbe.fpersonId = sum.fproposerId and lbe.fadminOrgUnitId = sum.fadminOrgUnitId and sum.FSalaryStatus = 1 ");
+                        checkSB.append("inner join T_HR_ATS_OverTimeBill lb on lb.fid = lbe.FBillID inner join T_HR_ATS_AttendancePeriod ap on ap.fid = sum.FAttendancePeriodID and lbe.FRealEndTime < DATEADD(DAY,1,ap.FEndDate) ");
+                        checkSB.append(" where lb.fid = '" + billId + "' ");
+                        IRowSet row = DbUtil.executeQuery(ctx, checkSB.toString());
+                        if (row.size() > 0) {
+                            throw new ShrWebBizException(new AtsAgainstApprove(AtsAgainstApprove.EXCEPTIONOVER));
+                        }
+                    }
+
+                    AtsOverTimeBillInfo billInfo = iAtsOverTimeInfo.getAtsOverTimeBillInfo(new ObjectUuidPK(billId));
+                    if (billInfo.getBillState().getValue() != 3) {
+                        throw new ShrWebBizException(new AtsOTBizException(AtsOTBizException.CANCERAUDITNOTMATHAUDIT));
+                    }
+
+                    this.isTurned(ctx, billInfo, res, limitDeductMap);
+                }
+
+                String turnedInfos = (String) res.get("turnedInfos");
+                if (turnedInfos != null && turnedInfos.length() > 0) {
+                    turnedInfos = turnedInfos.substring(0, turnedInfos.length() - 1);
+                    res.put("turnedInfos", turnedInfos);
+                }
+            }
+
+            return res;
+        }
+    }
+
+    public void isTurned(Context ctx, AtsOverTimeBillInfo billInfo, Map<String, Object> res, Map<String, BigDecimal> limitDeductMap) {
+        Map<String, OTtoTakeWorkDetailInfo> toTakeWorkDetailMap = new HashMap();
+        AtsOverTimeBillEntryCollection entries = billInfo.getEntries();
+        Map<String, Date> otDates = new HashMap();
+        Set<String> entryPersonIds = new HashSet();
+        Map<String, BigDecimal> detailInfosMap = new HashMap();
+        if (entries != null && entries.size() > 0) {
+            for (int i = 0; i < entries.size(); ++i) {
+                String personId = entries.get(i).getPerson().getId().toString();
+                entryPersonIds.add(personId);
+                otDates.put(personId, entries.get(i).getOtDate());
+
+                try {
+                    OTtoTakeWorkDetailCollection detailInfos = OTtoTakeWorkDetailFactory.getLocalInstance(ctx).getOTtoTakeWorkDetailCollection("select id, proposer.id,proposer.name,proposer.number,limit,limitValue where sourceBillID = '" + entries.get(i).getId() + "' and state = 0 ");
+                    if (detailInfos != null && detailInfos.size() > 0) {
+                        toTakeWorkDetailMap.put(personId, detailInfos.get(0));
+                        String limitId = detailInfos.get(0).getLimit();
+                        if (limitDeductMap.get(limitId) == null) {
+                            limitDeductMap.put(limitId, detailInfos.get(0).getLimitValue());
+                        } else {
+                            limitDeductMap.put(limitId, ((BigDecimal) limitDeductMap.get(limitId)).add(detailInfos.get(0).getLimitValue()));
+                        }
+                    } else {
+                        AttendanceResultCollection results = AttendanceResultFactory.getLocalInstance(ctx).getAttendanceResultCollection("select id where attenceDate = '" + entries.get(i).getOtDate() + "' and proposer.id = '" + entries.get(i).getPerson().getId().toString() + "'");
+                        if (results.size() > 0) {
+                            detailInfos = OTtoTakeWorkDetailFactory.getLocalInstance(ctx).getOTtoTakeWorkDetailCollection("select id, proposer.id,proposer.name,proposer.number,limit,limitValue where sourceBillID = '" + results.get(0).getId() + "' and state = 0 ");
+                            if (detailInfos.size() > 0) {
+                                toTakeWorkDetailMap.put(personId, detailInfos.get(0));
+                                if (detailInfosMap.get(detailInfos.get(0).getId().toString()) == null) {
+                                    String limitId = detailInfos.get(0).getLimit();
+                                    detailInfosMap.put(detailInfos.get(0).getId().toString(), detailInfos.get(0).getLimitValue());
+                                    if (limitDeductMap.get(limitId) == null) {
+                                        limitDeductMap.put(limitId, detailInfos.get(0).getLimitValue());
+                                    } else {
+                                        limitDeductMap.put(limitId, ((BigDecimal) limitDeductMap.get(limitId)).add(detailInfos.get(0).getLimitValue()));
+                                    }
+                                }
+                            }
+                        }
+                    }
+                } catch (ObjectNotFoundException e) {
+                    e.printStackTrace();
+                } catch (BOSException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+
+        int turned = res.get("turned") == null ? 0 : (Integer) res.get("turned");
+        String turnedInfos = res.get("turnedInfos") == null ? "" : (String) res.get("turnedInfos");
+        if (!toTakeWorkDetailMap.isEmpty()) {
+            for (String key : toTakeWorkDetailMap.keySet()) {
+                ++turned;
+                turnedInfos = turnedInfos + "[" + ((OTtoTakeWorkDetailInfo) toTakeWorkDetailMap.get(key)).getProposer().getName() + " " + AtsDateUtils.dateShortToString((Date) otDates.get(key)) + "]、";
+            }
+
+            this.checkRemainLimit(ctx, res, limitDeductMap);
+        }
+
+        res.put("turned", turned);
+        res.put("turnedInfos", turnedInfos);
+    }
+
+    private void checkRemainLimit(Context ctx, Map<String, Object> res, Map<String, BigDecimal> limitDeductMap) {
+        StringBuffer sb = new StringBuffer();
+
+        try {
+            IRowSet rs = DbUtil.executeQuery(ctx, "SELECT LI.FREMAINLIMIT,LI.FID ,PO.FIsOver, PERSON.FNAME" + MLUtile.getMlFlag(ctx) + " AS personName FROM T_HR_ATS_HOLIDAYLIMIT LI  INNER JOIN T_HR_ATS_HolidayPolicy PO ON LI.FHOLIDAYPOLICYID = PO.FID  INNER JOIN T_BD_PERSON PERSON ON PERSON.FID = LI.FPROPOSERID  WHERE LI.FID IN (" + AtsUtil.convertSetToString(limitDeductMap.keySet()) + ")");
+
+            while (rs.next()) {
+                String limitId = rs.getString("FID");
+                BigDecimal remainLimit = rs.getBigDecimal("FREMAINLIMIT");
+                int isOver = rs.getInt("FIsOver");
+                BigDecimal deductLimit = (BigDecimal) limitDeductMap.get(limitId);
+                if (deductLimit != null && isOver == 0 && remainLimit.subtract(deductLimit).compareTo(BigDecimal.ZERO) < 0) {
+                    sb.append("[" + rs.getString("personName") + "]");
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        if (StringUtils.isNotEmpty(sb.toString())) {
+            res.put("errorMsgList", MLUtile.getRes(AtsOverTimeBillResEnum.existsOTDetailAndRemainLimitLessThanZero, ctx, new Object[]{sb.toString()}));
+        }
+
+    }
+
+    public String doAgainApprove(Context ctx, String billId, String aiReason) throws EASBizException, BOSException, SHRWebException {
+        IAtsOverTimeBill iAtsOverTimeInfo = AtsOverTimeBillFactory.getRemoteInstance();
+        AtsOverTimeBillInfo billInfo = iAtsOverTimeInfo.getAtsOverTimeBillInfo(new ObjectUuidPK(billId));
+        CoreBaseCollection detailColl = new CoreBaseCollection();
+        AtsOverTimeBillEntryCollection entries = billInfo.getEntries();
+        boolean isCreateTagISAuto = false;
+        if (entries != null && entries.size() > 0) {
+            for (int i = 0; i < entries.size(); ++i) {
+                OverTimeCreateTag createTag = entries.get(i).getCreateTag();
+                entries.get(i).setCreateTag(OverTimeCreateTag.userCreate);
+                if (null != createTag && createTag.getValue() == 3) {
+                    isCreateTagISAuto = true;
+                }
+
+                if (null != createTag && createTag.getValue() == 2) {
+                    isCreateTagISAuto = true;
+                }
+
+                OTtoTakeWorkDetailInfo detailInfo = null;
+
+                try {
+                    detailInfo = OTtoTakeWorkDetailFactory.getLocalInstance(ctx).getOTtoTakeWorkDetailInfo(" where sourceBillID = '" + entries.get(i).getId().toString() + "' and state = 0 ");
+                } catch (ObjectNotFoundException e) {
+                    e.printStackTrace();
+                }
+
+                if (detailInfo != null) {
+                    detailInfo.setState(OTtoTakeWorkDetailStatus.invalid);
+                    detailColl.add(detailInfo);
+                }
+            }
+        }
+
+        OTtoTakeWorkDetailFactory.getLocalInstance(ctx).save(detailColl);
+        if (SHRBillServerUtil.overTimeControl(ctx, billInfo.getHrOrgUnit().getId().toString()) && !isCreateTagISAuto) {
+            try {
+                String serviceName = "calculatePersonOTLimit";
+                Map param = new HashMap();
+                param.put("billId", billId);
+                param.put("operator", "against");
+                OSFAppUtil.callService(ctx, serviceName, (HashMap) param);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        String successId = this.callOverTimeBillAgainstApproveJob(ctx, billInfo, aiReason);
+        AtsBillSourceTypeUtil.uptBillSourceTypeWithBack(ctx, billId);
+        DataLogsRecordUtil.processListObjectsLog(billInfo, OperActionEnum.againstApprove, ctx);
+        return successId;
+    }
+
+    private String callOverTimeBillAgainstApproveJob(Context ctx, AtsOverTimeBillInfo billInfo, String aiReason) throws EASBizException, BOSException {
+        AtsOverTimeBillEntryCollection entrysInfo = billInfo.getEntries();
+        IAtsOverTimeBillEntry iAtsOverTimeBillEntry = AtsOverTimeBillEntryFactory.getRemoteInstance();
+        CoreBaseCollection colls = new CoreBaseCollection();
+        List<String> personIds = new ArrayList();
+        Date minOtDate = null;
+        Date maxOtDate = null;
+
+        for (int i = 0; i < entrysInfo.size(); ++i) {
+            AtsOverTimeBillEntryInfo entryInfo = entrysInfo.get(i);
+            entryInfo.setCalculateState(false);
+            entryInfo.setHolidayLimit((HolidayLimitInfo) null);
+            entryInfo.setLastUpdateUser((UserInfo) ctx.get("UserInfo"));
+            entryInfo.setLastUpdateTime(AtsDateUtils.dateToTimestamp(new Date()));
+            colls.add(entryInfo);
+            personIds.add(entryInfo.getPerson().getId().toString());
+            if (null == minOtDate) {
+                minOtDate = entryInfo.getOtDate();
+                maxOtDate = entryInfo.getOtDate();
+            } else {
+                if (entryInfo.getOtDate().compareTo(minOtDate) < 0) {
+                    minOtDate = entryInfo.getOtDate();
+                }
+
+                if (entryInfo.getOtDate().compareTo(maxOtDate) > 0) {
+                    maxOtDate = entryInfo.getOtDate();
+                }
+            }
+        }
+
+        if (!colls.isEmpty()) {
+            iAtsOverTimeBillEntry.update(colls);
+        }
+
+        String billId = billInfo.getId().toString();
+        String sql = " update t_hr_ats_overTimeBill set fbillstate = 0,faireason=? ,fLastUpdateTime=?,fLastUpdateUserId=? where fid = ?";
+        Object[] params = new Object[]{aiReason, new Timestamp(System.currentTimeMillis()), ctx.getCaller().toString(), billId};
+        DbUtil.execute(ctx, sql, params);
+        AtsOverTimeVo atsOverTimeVo = new AtsOverTimeVo();
+        atsOverTimeVo.setMaxOtDate(maxOtDate);
+        atsOverTimeVo.setMinOtDate(minOtDate);
+        atsOverTimeVo.setPersonIds(personIds);
+        atsOverTimeVo.setEntrysInfo(entrysInfo);
+
+        try {
+            ThreadPoolExecutor pool = TaskPool.getFixedInstance("updateHolidayLimit", 1, 10L);
+            pool.submit((Callable) (new Callable<Object>() {
+                public Object call() throws Exception {
+                    AtsOverTimeVo overTimeVo = (AtsOverTimeVo) this.getDependency();
+                    AttendCalculateParent cal = new AttendCalculateParent();
+                    String personIdsStr = AtsServerCalUtils.getPersonIdsNoQuote(overTimeVo.getPersonIds());
+                    cal.calAttendResultByAdminOrgPersonAndDate(this.ctx, overTimeVo.getMinOtDate(), overTimeVo.getMaxOtDate(), 1, (String) null, personIdsStr, 0, "", 1);
+                    AtsOverTimeBillEntryCollection entrysInfo = overTimeVo.getEntrysInfo();
+
+                    for (int i = 0; i < entrysInfo.size(); ++i) {
+                        Map<String, String> param = new HashMap();
+                        param.put("adminOrgUnitNum", "");
+                        param.put("personNum", entrysInfo.get(i).getPerson().getId().toString());
+                        param.put("cycleDate", AtsDateUtils.dateShortToString(entrysInfo.get(i).getOtDate()));
+                        GenerateTakeWorkLimit service = new GenerateTakeWorkLimit(this.ctx);
+                        service.generateTakeWorkLimitBackGround(this.ctx, param);
+                    }
+
+                    return null;
+                }
+            }).setDependency(atsOverTimeVo).setCtx(ctx));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return billId;
+    }
+
+    /**
+     * 反审批
+     *
+     * @param ctx
+     * @param aiReason
+     * @param billIds
+     * @return
+     * @throws SHRWebException
+     * @throws BOSException
+     * @throws EASBizException
+     */
+    public Map<String, Object> againstApproveAction(Context ctx, String aiReason, String billIds) throws SHRWebException, BOSException, EASBizException {
+        List<String> atsInfoIds = new ArrayList();
+        Map<String, Object> res = new HashMap();
+
+        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+        aiReason = sf.format(new Date()) + "," + ctx.getUserName() + ":" + aiReason;
+        Set<String> successIds = new HashSet();
+        res.put("successIds", successIds);
+
+        String[] ids = billIds.split(",");
+        if (ids != null && ids.length > 0) {
+            for (int t = 0; t < ids.length; ++t) {
+                String billId = ids[t].trim();
+                if (!atsInfoIds.contains(billId)) {
+                    atsInfoIds.add(billId);
+                    successIds.add(this.doAgainApprove(ctx, billId, aiReason));
+                }
+            }
+        }
+
+        res.put("msg", MLUtile.getRes(AtsOverTimeBillResEnum.againstApproveSuccess, ctx));
+
+        return res;
+    }
+}