Commit 02b5f427 by yubin

修改

parent c2f1eeab
...@@ -54,7 +54,15 @@ public class KeyDmLeaveServiceImpl { ...@@ -54,7 +54,15 @@ public class KeyDmLeaveServiceImpl {
if (map == null) map = new HashMap<>(); if (map == null) map = new HashMap<>();
return commonService.findList(namespace + "selectTransferApprovalList", map); return commonService.findList(namespace + "selectTransferApprovalList", map);
} }
@ApiOperation(value = "待审核列表", desc = "查询待审核数据")
public String deleteById(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
int aff = commonService.update(namespace + "deleteById", map);
commonService.findList(approvalRecordNamespace + "deleteById", map);
if (aff < 0) throw new CustomException("审批失败");
return SUCCESS;
}
@ApiOperation(value = "保存请假申请", desc = "新增或修改,请假单保存") @ApiOperation(value = "保存请假申请", desc = "新增或修改,请假单保存")
public String save(Map<String, Object> map) { public String save(Map<String, Object> map) {
if (map == null) throw new CustomException("参数不能为空"); if (map == null) throw new CustomException("参数不能为空");
...@@ -75,35 +83,6 @@ public class KeyDmLeaveServiceImpl { ...@@ -75,35 +83,6 @@ public class KeyDmLeaveServiceImpl {
map.put("leave_type_name", typeName); map.put("leave_type_name", typeName);
map.put("status", 0); // 默认保存状态为0 map.put("status", 0); // 默认保存状态为0
Object startDateObj = map.get("start_time");
Object endDateObj = map.get("end_time");
double durationDays = 0; // 初始化天数为0
// 1. 非空判断 + 计算天数
if (startDateObj != null && endDateObj != null) {
try {
// 1. 解析字符串时间为DateTime
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
DateTime startDate = formatter.parseDateTime(startDateObj.toString());
DateTime endDate = formatter.parseDateTime(endDateObj.toString());
// 2. 计算时间差(毫秒),转成带小数的天数
Duration durationObj = new Duration(startDate, endDate);
long totalMillis = durationObj.getMillis();
// 关键:用86400000.0(浮点数)做除法,保留小数
durationDays = totalMillis / 86400000.0;
// 可选:保留1位小数(比如0.1天、4.5天),避免小数位数过多
durationDays = Math.round(durationDays * 10) / 10.0;
// 3. 存入map(小数天数)
map.put("duration", durationDays);
} catch (IllegalArgumentException e) {
throw new CustomException("时间格式错误,应为yyyy-MM-dd HH:mm:ss");
}
} else {
// 空值时默认存0.0,保持类型统一
map.put("duration", 0.0);
}
if (commonService.insert(namespace + "insert", map) != 1) { if (commonService.insert(namespace + "insert", map) != 1) {
throw new CustomException("保存失败"); throw new CustomException("保存失败");
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
FROM jl_key_dm_leave_application FROM jl_key_dm_leave_application
<where> <where>
AND is_used = 1 AND is_used = 1
AND status !=0
<if test="params.user_name != null and params.user_name != ''"> <if test="params.user_name != null and params.user_name != ''">
AND user_name LIKE CONCAT('%', #{params.user_name}, '%') AND user_name LIKE CONCAT('%', #{params.user_name}, '%')
</if> </if>
...@@ -77,7 +78,7 @@ ...@@ -77,7 +78,7 @@
AND a.status = #{params.params.status} AND a.status = #{params.params.status}
</if> </if>
</where> </where>
ORDER BY a.submit_time DESC ORDER BY a.status ASC
</select> </select>
<select id="selectPendingList" parameterType="page" resultType="map"> <select id="selectPendingList" parameterType="page" resultType="map">
...@@ -230,6 +231,11 @@ ...@@ -230,6 +231,11 @@
WHERE id = #{leave_id} WHERE id = #{leave_id}
</update> </update>
<update id="deleteById" parameterType="map">
UPDATE jl_key_dm_leave_application set is_used=0 WHERE id = #{leave_id}
</update>
<!-- 提交:设置 status=1 (审核中),submit_time=NOW() --> <!-- 提交:设置 status=1 (审核中),submit_time=NOW() -->
<update id="submit" parameterType="map"> <update id="submit" parameterType="map">
UPDATE jl_key_dm_leave_application UPDATE jl_key_dm_leave_application
......
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
<insert id="insert" parameterType="map"> <insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_leave_approval_record( INSERT INTO jl_key_dm_leave_approval_record(
id,leave_id,node_index,node_type,approver_id,approver_name,approver_result,approver_time,status,comment,transfer_to_id,transfer_to_name,transfer_reason,is_used,create_by,create_time,order_no id,leave_id,node_index,node_type,approver_id,approver_name,approver_result,status,comment,transfer_to_id,transfer_to_name,transfer_reason,is_used,create_by,create_time,order_no
) VALUES ( ) VALUES (
#{id},#{leave_id},#{node_index},#{node_type},#{approver_id},#{approver_name},#{approver_result},NOW(),#{status},#{comment},#{transfer_to_id},#{transfer_to_name},#{transfer_reason},1,#{_user.id},NOW(),#{order_no} #{id},#{leave_id},#{node_index},#{node_type},#{approver_id},#{approver_name},#{approver_result},#{status},#{comment},#{transfer_to_id},#{transfer_to_name},#{transfer_reason},1,#{_user.id},NOW(),#{order_no}
) )
</insert> </insert>
...@@ -82,7 +82,9 @@ ...@@ -82,7 +82,9 @@
SET status = 2, approver_time = NOW(), update_by = #{_user.id}, update_time = NOW(),approver_result = -1 SET status = 2, approver_time = NOW(), update_by = #{_user.id}, update_time = NOW(),approver_result = -1
WHERE id = #{id} WHERE id = #{id}
</update> </update>
<delete id="deleteById" parameterType="map">
UPDATE jl_key_dm_leave_approval_record set is_used=0 WHERE id = #{id}
</delete>
<update id="update" parameterType="map"> <update id="update" parameterType="map">
UPDATE jl_key_dm_leave_approval_record UPDATE jl_key_dm_leave_approval_record
SET SET
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论