Merge branch 'wcd' into wcd-2411-update
1 files added
21 files modified
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.annotation; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * @author Zheng Jie |
| | | * @date 2019-6-4 13:52:30 |
| | | */ |
| | | @Target(ElementType.FIELD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface Query { |
| | | |
| | | // Dong ZhaoYang 2017/8/7 基本对象的属性名 |
| | | String propName() default ""; |
| | | // Dong ZhaoYang 2017/8/7 查询方式 |
| | | Type type() default Type.EQUAL; |
| | | |
| | | /** |
| | | * 连接查询的属性名,如User类中的dept |
| | | */ |
| | | String joinName() default ""; |
| | | |
| | | /** |
| | | * 默认左连接 |
| | | */ |
| | | Join join() default Join.LEFT; |
| | | |
| | | /** |
| | | * 多字段模糊搜索,仅支持String类型字段,多个用逗号隔开, 如@Query(blurry = "email,username") |
| | | */ |
| | | String blurry() default ""; |
| | | |
| | | //wcd加 |
| | | String isOr() default ""; |
| | | // |
| | | |
| | | enum Type { |
| | | // jie 2019/6/4 相等 |
| | | EQUAL |
| | | // Dong ZhaoYang 2017/8/7 大于等于 |
| | | , GREATER_THAN |
| | | // Dong ZhaoYang 2017/8/7 小于等于 |
| | | , LESS_THAN |
| | | // Dong ZhaoYang 2017/8/7 中模糊查询 |
| | | , INNER_LIKE |
| | | // Dong ZhaoYang 2017/8/7 左模糊查询 |
| | | , LEFT_LIKE |
| | | // Dong ZhaoYang 2017/8/7 右模糊查询 |
| | | , RIGHT_LIKE |
| | | // Dong ZhaoYang 2017/8/7 小于 |
| | | , LESS_THAN_NQ |
| | | // jie 2019/6/4 包含 |
| | | , IN |
| | | // 不包含 |
| | | , NOT_IN |
| | | // 不等于 |
| | | ,NOT_EQUAL |
| | | // between |
| | | ,BETWEEN |
| | | // 不为空 |
| | | ,NOT_NULL |
| | | // 为空 |
| | | ,IS_NULL |
| | | } |
| | | |
| | | /** |
| | | * @author Zheng Jie |
| | | * 适用于简单连接查询,复杂的请自定义该注解,或者使用sql查询 |
| | | */ |
| | | enum Join { |
| | | /** jie 2019-6-4 13:18:30 */ |
| | | LEFT, RIGHT, INNER |
| | | } |
| | | |
| | | } |
| | | |
| | | /*
|
| | | * Copyright 2019-2020 Zheng Jie
|
| | | *
|
| | | * Licensed under the Apache License, Version 2.0 (the "License");
|
| | | * you may not use this file except in compliance with the License.
|
| | | * You may obtain a copy of the License at
|
| | | *
|
| | | * http://www.apache.org/licenses/LICENSE-2.0
|
| | | *
|
| | | * Unless required by applicable law or agreed to in writing, software
|
| | | * distributed under the License is distributed on an "AS IS" BASIS,
|
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| | | * See the License for the specific language governing permissions and
|
| | | * limitations under the License.
|
| | | */
|
| | | package me.zhengjie.annotation;
|
| | |
|
| | | import java.lang.annotation.ElementType;
|
| | | import java.lang.annotation.Retention;
|
| | | import java.lang.annotation.RetentionPolicy;
|
| | | import java.lang.annotation.Target;
|
| | |
|
| | | /**
|
| | | * @author Zheng Jie
|
| | | * @date 2019-6-4 13:52:30
|
| | | */
|
| | | @Target(ElementType.FIELD)
|
| | | @Retention(RetentionPolicy.RUNTIME)
|
| | | public @interface Query {
|
| | |
|
| | | // Dong ZhaoYang 2017/8/7 基本对象的属性名
|
| | | String propName() default "";
|
| | | // Dong ZhaoYang 2017/8/7 查询方式
|
| | | Type type() default Type.EQUAL;
|
| | |
|
| | | /**
|
| | | * 连接查询的属性名,如User类中的dept
|
| | | */
|
| | | String joinName() default "";
|
| | |
|
| | | /**
|
| | | * 默认左连接
|
| | | */
|
| | | Join join() default Join.LEFT;
|
| | |
|
| | | /**
|
| | | * 多字段模糊搜索,仅支持String类型字段,多个用逗号隔开, 如@Query(blurry = "email,username")
|
| | | */
|
| | | String blurry() default "";
|
| | |
|
| | | //wcd加
|
| | | String isOr() default "";
|
| | | //
|
| | |
|
| | | String orGroup() default "";
|
| | |
|
| | | enum Type {
|
| | | // jie 2019/6/4 相等
|
| | | EQUAL
|
| | | // Dong ZhaoYang 2017/8/7 大于等于
|
| | | , GREATER_THAN
|
| | | // Dong ZhaoYang 2017/8/7 小于等于
|
| | | , LESS_THAN
|
| | | // Dong ZhaoYang 2017/8/7 中模糊查询
|
| | | , INNER_LIKE
|
| | | // Dong ZhaoYang 2017/8/7 左模糊查询
|
| | | , LEFT_LIKE
|
| | | // Dong ZhaoYang 2017/8/7 右模糊查询
|
| | | , RIGHT_LIKE
|
| | | // Dong ZhaoYang 2017/8/7 小于
|
| | | , LESS_THAN_NQ
|
| | | // jie 2019/6/4 包含
|
| | | , IN
|
| | | // 不包含
|
| | | , NOT_IN
|
| | | // 不等于
|
| | | ,NOT_EQUAL
|
| | | // between
|
| | | ,BETWEEN
|
| | | // 不为空
|
| | | ,NOT_NULL
|
| | | // 为空
|
| | | ,IS_NULL
|
| | | }
|
| | |
|
| | | /**
|
| | | * @author Zheng Jie
|
| | | * 适用于简单连接查询,复杂的请自定义该注解,或者使用sql查询
|
| | | */
|
| | | enum Join {
|
| | | /** jie 2019-6-4 13:18:30 */
|
| | | LEFT, RIGHT, INNER
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.utils; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import me.zhengjie.annotation.DataPermission; |
| | | import me.zhengjie.annotation.Query; |
| | | import javax.persistence.criteria.*; |
| | | import java.lang.reflect.Field; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author Zheng Jie |
| | | * @date 2019-6-4 14:59:48 |
| | | */ |
| | | @Slf4j |
| | | @SuppressWarnings({"unchecked","all"}) |
| | | public class QueryHelp { |
| | | |
| | | public static <R, Q> Predicate getPredicate(Root<R> root, Q query, CriteriaBuilder cb) { |
| | | List<Predicate> list = new ArrayList<>(); |
| | | if(query == null){ |
| | | return cb.and(list.toArray(new Predicate[0])); |
| | | } |
| | | // 数据权限验证 |
| | | DataPermission permission = query.getClass().getAnnotation(DataPermission.class); |
| | | if(permission != null){ |
| | | // 获取数据权限 |
| | | List<Long> dataScopes = SecurityUtils.getCurrentUserDataScope(); |
| | | if(CollectionUtil.isNotEmpty(dataScopes)){ |
| | | if(StringUtils.isNotBlank(permission.joinName()) && StringUtils.isNotBlank(permission.fieldName())) { |
| | | Join join = root.join(permission.joinName(), JoinType.LEFT); |
| | | list.add(getExpression(permission.fieldName(),join, root).in(dataScopes)); |
| | | } else if (StringUtils.isBlank(permission.joinName()) && StringUtils.isNotBlank(permission.fieldName())) { |
| | | list.add(getExpression(permission.fieldName(),null, root).in(dataScopes)); |
| | | } |
| | | } |
| | | } |
| | | try { |
| | | List<Field> fields = getAllFields(query.getClass(), new ArrayList<>()); |
| | | for (Field field : fields) { |
| | | boolean accessible = field.isAccessible(); |
| | | // 设置对象的访问权限,保证对private的属性的访 |
| | | field.setAccessible(true); |
| | | Query q = field.getAnnotation(Query.class); |
| | | if (q != null) { |
| | | String propName = q.propName(); |
| | | String joinName = q.joinName(); |
| | | String blurry = q.blurry(); |
| | | // wcd加 |
| | | String isOr = q.isOr(); |
| | | // |
| | | String attributeName = isBlank(propName) ? field.getName() : propName; |
| | | Class<?> fieldType = field.getType(); |
| | | Object val = field.get(query); |
| | | if (ObjectUtil.isNull(val) || "".equals(val)) { |
| | | continue; |
| | | } |
| | | Join join = null; |
| | | // 模糊多字段 |
| | | if (ObjectUtil.isNotEmpty(blurry)) { |
| | | String[] blurrys = blurry.split(","); |
| | | List<Predicate> orPredicate = new ArrayList<>(); |
| | | for (String s : blurrys) { |
| | | String[] joinNames = s.split(">"); |
| | | if (joinNames.length == 2) { |
| | | orPredicate.add(cb.like(root.join(joinNames[0], JoinType.LEFT).get(joinNames[1]) |
| | | .as(String.class), "%" + val.toString() + "%")); |
| | | } else { |
| | | orPredicate.add(cb.like(root.get(joinNames[0]) |
| | | .as(String.class), "%" + val.toString() + "%")); |
| | | } |
| | | } |
| | | Predicate[] p = new Predicate[orPredicate.size()]; |
| | | list.add(cb.or(orPredicate.toArray(p))); |
| | | continue; |
| | | } |
| | | if (ObjectUtil.isNotEmpty(joinName)) { |
| | | String[] joinNames = joinName.split(">"); |
| | | for (String name : joinNames) { |
| | | switch (q.join()) { |
| | | case LEFT: |
| | | if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){ |
| | | join = join.join(name, JoinType.LEFT); |
| | | } else { |
| | | join = root.join(name, JoinType.LEFT); |
| | | } |
| | | break; |
| | | case RIGHT: |
| | | if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){ |
| | | join = join.join(name, JoinType.RIGHT); |
| | | } else { |
| | | join = root.join(name, JoinType.RIGHT); |
| | | } |
| | | break; |
| | | case INNER: |
| | | if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){ |
| | | join = join.join(name, JoinType.INNER); |
| | | } else { |
| | | join = root.join(name, JoinType.INNER); |
| | | } |
| | | break; |
| | | default: break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // wcd加 |
| | | if (ObjectUtil.isNotEmpty(isOr)) { |
| | | String[] isOrs = isOr.split(","); |
| | | List<Predicate> orP = new ArrayList<>(); |
| | | for (String s : isOrs) { |
| | | orP.add(cb.equal(root.get(s) |
| | | .as(String.class), val)); |
| | | } |
| | | Predicate[] orpr = new Predicate[orP.size()]; |
| | | list.add(cb.or(orP.toArray(orpr))); |
| | | continue; |
| | | } |
| | | // |
| | | |
| | | switch (q.type()) { |
| | | case EQUAL: |
| | | list.add(cb.equal(getExpression(attributeName,join,root) |
| | | .as((Class<? extends Comparable>) fieldType),val)); |
| | | break; |
| | | case GREATER_THAN: |
| | | list.add(cb.greaterThanOrEqualTo(getExpression(attributeName,join,root) |
| | | .as((Class<? extends Comparable>) fieldType), (Comparable) val)); |
| | | break; |
| | | case LESS_THAN: |
| | | list.add(cb.lessThanOrEqualTo(getExpression(attributeName,join,root) |
| | | .as((Class<? extends Comparable>) fieldType), (Comparable) val)); |
| | | break; |
| | | case LESS_THAN_NQ: |
| | | list.add(cb.lessThan(getExpression(attributeName,join,root) |
| | | .as((Class<? extends Comparable>) fieldType), (Comparable) val)); |
| | | break; |
| | | case INNER_LIKE: |
| | | list.add(cb.like(getExpression(attributeName,join,root) |
| | | .as(String.class), "%" + val.toString() + "%")); |
| | | break; |
| | | case LEFT_LIKE: |
| | | list.add(cb.like(getExpression(attributeName,join,root) |
| | | .as(String.class), "%" + val.toString())); |
| | | break; |
| | | case RIGHT_LIKE: |
| | | list.add(cb.like(getExpression(attributeName,join,root) |
| | | .as(String.class), val.toString() + "%")); |
| | | break; |
| | | case IN: |
| | | if (CollUtil.isNotEmpty((Collection<Object>)val)) { |
| | | list.add(getExpression(attributeName,join,root).in((Collection<Object>) val)); |
| | | } |
| | | break; |
| | | case NOT_IN: |
| | | if (CollUtil.isNotEmpty((Collection<Object>)val)) { |
| | | list.add(getExpression(attributeName,join,root).in((Collection<Object>) val).not()); |
| | | } |
| | | break; |
| | | case NOT_EQUAL: |
| | | list.add(cb.notEqual(getExpression(attributeName,join,root), val)); |
| | | break; |
| | | case NOT_NULL: |
| | | list.add(cb.isNotNull(getExpression(attributeName,join,root))); |
| | | break; |
| | | case IS_NULL: |
| | | list.add(cb.isNull(getExpression(attributeName,join,root))); |
| | | break; |
| | | case BETWEEN: |
| | | List<Object> between = new ArrayList<>((List<Object>)val); |
| | | list.add(cb.between(getExpression(attributeName, join, root).as((Class<? extends Comparable>) between.get(0).getClass()), |
| | | (Comparable) between.get(0), (Comparable) between.get(1))); |
| | | break; |
| | | default: break; |
| | | } |
| | | } |
| | | field.setAccessible(accessible); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | int size = list.size(); |
| | | return cb.and(list.toArray(new Predicate[size])); |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | private static <T, R> Expression<T> getExpression(String attributeName, Join join, Root<R> root) { |
| | | if (ObjectUtil.isNotEmpty(join)) { |
| | | return join.get(attributeName); |
| | | } else { |
| | | return root.get(attributeName); |
| | | } |
| | | } |
| | | |
| | | private static boolean isBlank(final CharSequence cs) { |
| | | int strLen; |
| | | if (cs == null || (strLen = cs.length()) == 0) { |
| | | return true; |
| | | } |
| | | for (int i = 0; i < strLen; i++) { |
| | | if (!Character.isWhitespace(cs.charAt(i))) { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | public static List<Field> getAllFields(Class clazz, List<Field> fields) { |
| | | if (clazz != null) { |
| | | fields.addAll(Arrays.asList(clazz.getDeclaredFields())); |
| | | getAllFields(clazz.getSuperclass(), fields); |
| | | } |
| | | return fields; |
| | | } |
| | | } |
| | | /*
|
| | | * Copyright 2019-2020 Zheng Jie
|
| | | *
|
| | | * Licensed under the Apache License, Version 2.0 (the "License");
|
| | | * you may not use this file except in compliance with the License.
|
| | | * You may obtain a copy of the License at
|
| | | *
|
| | | * http://www.apache.org/licenses/LICENSE-2.0
|
| | | *
|
| | | * Unless required by applicable law or agreed to in writing, software
|
| | | * distributed under the License is distributed on an "AS IS" BASIS,
|
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| | | * See the License for the specific language governing permissions and
|
| | | * limitations under the License.
|
| | | */
|
| | | package me.zhengjie.utils;
|
| | |
|
| | | import cn.hutool.core.collection.CollUtil;
|
| | | import cn.hutool.core.collection.CollectionUtil;
|
| | | import cn.hutool.core.util.ObjectUtil;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import me.zhengjie.annotation.DataPermission;
|
| | | import me.zhengjie.annotation.Query;
|
| | | import javax.persistence.criteria.*;
|
| | | import java.lang.reflect.Field;
|
| | | import java.util.*;
|
| | |
|
| | | /**
|
| | | * @author Zheng Jie
|
| | | * @date 2019-6-4 14:59:48
|
| | | */
|
| | | @Slf4j
|
| | | @SuppressWarnings({"unchecked","all"})
|
| | | public class QueryHelp {
|
| | |
|
| | | public static <R, Q> Predicate getPredicate(Root<R> root, Q query, CriteriaBuilder cb) {
|
| | | List<Predicate> list = new ArrayList<>();
|
| | | if(query == null){
|
| | | return cb.and(list.toArray(new Predicate[0]));
|
| | | }
|
| | | // 数据权限验证
|
| | | DataPermission permission = query.getClass().getAnnotation(DataPermission.class);
|
| | | if(permission != null){
|
| | | // 获取数据权限
|
| | | List<Long> dataScopes = SecurityUtils.getCurrentUserDataScope();
|
| | | if(CollectionUtil.isNotEmpty(dataScopes)){
|
| | | if(StringUtils.isNotBlank(permission.joinName()) && StringUtils.isNotBlank(permission.fieldName())) {
|
| | | Join join = root.join(permission.joinName(), JoinType.LEFT);
|
| | | list.add(getExpression(permission.fieldName(),join, root).in(dataScopes));
|
| | | } else if (StringUtils.isBlank(permission.joinName()) && StringUtils.isNotBlank(permission.fieldName())) {
|
| | | list.add(getExpression(permission.fieldName(),null, root).in(dataScopes));
|
| | | }
|
| | | }
|
| | | }
|
| | | try {
|
| | | List<Field> fields = getAllFields(query.getClass(), new ArrayList<>());
|
| | |
|
| | | Map<String, List<Predicate>> orGroupMap = new HashMap<String, List<Predicate>>();
|
| | |
|
| | | for (Field field : fields) {
|
| | | boolean accessible = field.isAccessible();
|
| | | // 设置对象的访问权限,保证对private的属性的访
|
| | | field.setAccessible(true);
|
| | | Query q = field.getAnnotation(Query.class);
|
| | | if (q != null) {
|
| | | String propName = q.propName();
|
| | | String joinName = q.joinName();
|
| | | String blurry = q.blurry();
|
| | | // wcd加
|
| | | String isOr = q.isOr();
|
| | | //
|
| | | String attributeName = isBlank(propName) ? field.getName() : propName;
|
| | | Class<?> fieldType = field.getType();
|
| | | Object val = field.get(query);
|
| | | if (ObjectUtil.isNull(val) || "".equals(val)) {
|
| | | continue;
|
| | | }
|
| | | Join join = null;
|
| | | // 模糊多字段
|
| | | if (ObjectUtil.isNotEmpty(blurry)) {
|
| | | String[] blurrys = blurry.split(",");
|
| | | List<Predicate> orPredicate = new ArrayList<>();
|
| | | for (String s : blurrys) {
|
| | | String[] joinNames = s.split(">");
|
| | | if (joinNames.length == 2) {
|
| | | orPredicate.add(cb.like(root.join(joinNames[0], JoinType.LEFT).get(joinNames[1])
|
| | | .as(String.class), "%" + val.toString() + "%"));
|
| | | } else {
|
| | | orPredicate.add(cb.like(root.get(joinNames[0])
|
| | | .as(String.class), "%" + val.toString() + "%"));
|
| | | }
|
| | | }
|
| | | Predicate[] p = new Predicate[orPredicate.size()];
|
| | | list.add(cb.or(orPredicate.toArray(p)));
|
| | | continue;
|
| | | }
|
| | | if (ObjectUtil.isNotEmpty(joinName)) {
|
| | | String[] joinNames = joinName.split(">");
|
| | | for (String name : joinNames) {
|
| | | switch (q.join()) {
|
| | | case LEFT:
|
| | | if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){
|
| | | join = join.join(name, JoinType.LEFT);
|
| | | } else {
|
| | | join = root.join(name, JoinType.LEFT);
|
| | | }
|
| | | break;
|
| | | case RIGHT:
|
| | | if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){
|
| | | join = join.join(name, JoinType.RIGHT);
|
| | | } else {
|
| | | join = root.join(name, JoinType.RIGHT);
|
| | | }
|
| | | break;
|
| | | case INNER:
|
| | | if(ObjectUtil.isNotNull(join) && ObjectUtil.isNotNull(val)){
|
| | | join = join.join(name, JoinType.INNER);
|
| | | } else {
|
| | | join = root.join(name, JoinType.INNER);
|
| | | }
|
| | | break;
|
| | | default: break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // wcd加
|
| | | if (ObjectUtil.isNotEmpty(isOr)) {
|
| | | String[] isOrs = isOr.split(",");
|
| | | List<Predicate> orP = new ArrayList<>();
|
| | | for (String s : isOrs) {
|
| | | orP.add(cb.equal(root.get(s)
|
| | | .as(String.class), val));
|
| | | }
|
| | | Predicate[] orpr = new Predicate[orP.size()];
|
| | | list.add(cb.or(orP.toArray(orpr)));
|
| | | continue;
|
| | | }
|
| | | //
|
| | |
|
| | | String orGroup = q.orGroup();
|
| | | if (ObjectUtil.isNotEmpty(orGroup)) {
|
| | | if (orGroupMap.get(orGroup) == null) {
|
| | | orGroupMap.put(orGroup, new ArrayList<Predicate>());
|
| | | }
|
| | | List<Predicate> predicates = orGroupMap.get(orGroup);
|
| | | switch (q.type()) {
|
| | | case EQUAL:
|
| | | predicates.add(cb.equal(getExpression(attributeName,join,root)
|
| | | .as((Class<? extends Comparable>) fieldType),val));
|
| | | break;
|
| | | case GREATER_THAN:
|
| | | predicates.add(cb.greaterThanOrEqualTo(getExpression(attributeName,join,root)
|
| | | .as((Class<? extends Comparable>) fieldType), (Comparable) val));
|
| | | break;
|
| | | case LESS_THAN:
|
| | | predicates.add(cb.lessThanOrEqualTo(getExpression(attributeName,join,root)
|
| | | .as((Class<? extends Comparable>) fieldType), (Comparable) val));
|
| | | break;
|
| | | case LESS_THAN_NQ:
|
| | | predicates.add(cb.lessThan(getExpression(attributeName,join,root)
|
| | | .as((Class<? extends Comparable>) fieldType), (Comparable) val));
|
| | | break;
|
| | | case INNER_LIKE:
|
| | | predicates.add(cb.like(getExpression(attributeName,join,root)
|
| | | .as(String.class), "%" + val.toString() + "%"));
|
| | | break;
|
| | | case LEFT_LIKE:
|
| | | predicates.add(cb.like(getExpression(attributeName,join,root)
|
| | | .as(String.class), "%" + val.toString()));
|
| | | break;
|
| | | case RIGHT_LIKE:
|
| | | predicates.add(cb.like(getExpression(attributeName,join,root)
|
| | | .as(String.class), val.toString() + "%"));
|
| | | break;
|
| | | case IN:
|
| | | if (CollUtil.isNotEmpty((Collection<Object>)val)) {
|
| | | predicates.add(getExpression(attributeName,join,root).in((Collection<Object>) val));
|
| | | }
|
| | | break;
|
| | | case NOT_IN:
|
| | | if (CollUtil.isNotEmpty((Collection<Object>)val)) {
|
| | | predicates.add(getExpression(attributeName,join,root).in((Collection<Object>) val).not());
|
| | | }
|
| | | break;
|
| | | case NOT_EQUAL:
|
| | | predicates.add(cb.notEqual(getExpression(attributeName,join,root), val));
|
| | | break;
|
| | | case NOT_NULL:
|
| | | predicates.add(cb.isNotNull(getExpression(attributeName,join,root)));
|
| | | break;
|
| | | case IS_NULL:
|
| | | predicates.add(cb.isNull(getExpression(attributeName,join,root)));
|
| | | break;
|
| | | case BETWEEN:
|
| | | List<Object> between = new ArrayList<>((List<Object>)val);
|
| | | predicates.add(cb.between(getExpression(attributeName, join, root).as((Class<? extends Comparable>) between.get(0).getClass()),
|
| | | (Comparable) between.get(0), (Comparable) between.get(1)));
|
| | | break;
|
| | | default: break;
|
| | | }
|
| | | } else {
|
| | | switch (q.type()) {
|
| | | case EQUAL:
|
| | | list.add(cb.equal(getExpression(attributeName,join,root)
|
| | | .as((Class<? extends Comparable>) fieldType),val));
|
| | | break;
|
| | | case GREATER_THAN:
|
| | | list.add(cb.greaterThanOrEqualTo(getExpression(attributeName,join,root)
|
| | | .as((Class<? extends Comparable>) fieldType), (Comparable) val));
|
| | | break;
|
| | | case LESS_THAN:
|
| | | list.add(cb.lessThanOrEqualTo(getExpression(attributeName,join,root)
|
| | | .as((Class<? extends Comparable>) fieldType), (Comparable) val));
|
| | | break;
|
| | | case LESS_THAN_NQ:
|
| | | list.add(cb.lessThan(getExpression(attributeName,join,root)
|
| | | .as((Class<? extends Comparable>) fieldType), (Comparable) val));
|
| | | break;
|
| | | case INNER_LIKE:
|
| | | list.add(cb.like(getExpression(attributeName,join,root)
|
| | | .as(String.class), "%" + val.toString() + "%"));
|
| | | break;
|
| | | case LEFT_LIKE:
|
| | | list.add(cb.like(getExpression(attributeName,join,root)
|
| | | .as(String.class), "%" + val.toString()));
|
| | | break;
|
| | | case RIGHT_LIKE:
|
| | | list.add(cb.like(getExpression(attributeName,join,root)
|
| | | .as(String.class), val.toString() + "%"));
|
| | | break;
|
| | | case IN:
|
| | | if (CollUtil.isNotEmpty((Collection<Object>)val)) {
|
| | | list.add(getExpression(attributeName,join,root).in((Collection<Object>) val));
|
| | | }
|
| | | break;
|
| | | case NOT_IN:
|
| | | if (CollUtil.isNotEmpty((Collection<Object>)val)) {
|
| | | list.add(getExpression(attributeName,join,root).in((Collection<Object>) val).not());
|
| | | }
|
| | | break;
|
| | | case NOT_EQUAL:
|
| | | list.add(cb.notEqual(getExpression(attributeName,join,root), val));
|
| | | break;
|
| | | case NOT_NULL:
|
| | | list.add(cb.isNotNull(getExpression(attributeName,join,root)));
|
| | | break;
|
| | | case IS_NULL:
|
| | | list.add(cb.isNull(getExpression(attributeName,join,root)));
|
| | | break;
|
| | | case BETWEEN:
|
| | | List<Object> between = new ArrayList<>((List<Object>)val);
|
| | | list.add(cb.between(getExpression(attributeName, join, root).as((Class<? extends Comparable>) between.get(0).getClass()),
|
| | | (Comparable) between.get(0), (Comparable) between.get(1)));
|
| | | break;
|
| | | default: break;
|
| | | }
|
| | | }
|
| | | }
|
| | | field.setAccessible(accessible);
|
| | | }
|
| | | orGroupMap.values().forEach(predicates -> list.add(cb.or(predicates.toArray(new Predicate[0]))));
|
| | | } catch (Exception e) {
|
| | | log.error(e.getMessage(), e);
|
| | | }
|
| | | int size = list.size();
|
| | | return cb.and(list.toArray(new Predicate[size]));
|
| | | }
|
| | |
|
| | | @SuppressWarnings("unchecked")
|
| | | private static <T, R> Expression<T> getExpression(String attributeName, Join join, Root<R> root) {
|
| | | if (ObjectUtil.isNotEmpty(join)) {
|
| | | return join.get(attributeName);
|
| | | } else {
|
| | | return root.get(attributeName);
|
| | | }
|
| | | }
|
| | |
|
| | | private static boolean isBlank(final CharSequence cs) {
|
| | | int strLen;
|
| | | if (cs == null || (strLen = cs.length()) == 0) {
|
| | | return true;
|
| | | }
|
| | | for (int i = 0; i < strLen; i++) {
|
| | | if (!Character.isWhitespace(cs.charAt(i))) {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | public static List<Field> getAllFields(Class clazz, List<Field> fields) {
|
| | | if (clazz != null) {
|
| | | fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
|
| | | getAllFields(clazz.getSuperclass(), fields);
|
| | | }
|
| | | return fields;
|
| | | }
|
| | | }
|
| | |
| | | @ApiModelProperty(value = "出差类别")
|
| | | private String category;
|
| | |
|
| | | @Column(name = "`project_id`")
|
| | | @ApiModelProperty(value = "项目ID")
|
| | | private Long projectId;
|
| | |
|
| | | @Column(name = "`approval_status`",nullable = false)
|
| | | @NotBlank
|
| | | @ApiModelProperty(value = "审批状态")
|
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.attendance.domain.Attendance; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceRepository; |
| | | import me.zhengjie.modules.attendance.service.AttendanceService; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceDto; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceQueryCriteria; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.data.domain.Pageable; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2022-12-14 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "考勤记录管理") |
| | | @RequestMapping("/api/attendance") |
| | | public class AttendanceController { |
| | | |
| | | private final AttendanceService attendanceService; |
| | | private final AttendanceRepository attendanceRepository; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('attendance:download')") |
| | | public void exportAttendance(HttpServletResponse response, AttendanceQueryCriteria criteria) throws IOException { |
| | | attendanceService.download(attendanceService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询考勤记录") |
| | | @ApiOperation("查询考勤记录") |
| | | @PreAuthorize("@el.check('attendance:list')") |
| | | public ResponseEntity<Object> queryAttendance(AttendanceQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(attendanceService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/all") |
| | | @Log("查询考勤记录") |
| | | @ApiOperation("查询考勤记录") |
| | | @PreAuthorize("@el.check('attendance:list')") |
| | | public ResponseEntity<Object> queryAttendance(AttendanceQueryCriteria criteria){ |
| | | return new ResponseEntity<>(attendanceService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增考勤记录") |
| | | @ApiOperation("新增考勤记录") |
| | | @PreAuthorize("@el.check('attendance:add')") |
| | | public ResponseEntity<Object> createAttendance(@Validated @RequestBody Attendance resources){ |
| | | return new ResponseEntity<>(attendanceService.create(resources),HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改考勤记录") |
| | | @ApiOperation("修改考勤记录") |
| | | @PreAuthorize("@el.check('attendance:edit')") |
| | | public ResponseEntity<Object> updateAttendance(@Validated @RequestBody Attendance resources){ |
| | | attendanceService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除考勤记录") |
| | | @ApiOperation("删除考勤记录") |
| | | @PreAuthorize("@el.check('attendance:del')") |
| | | public ResponseEntity<Object> deleteAttendance(@RequestBody Long[] ids) { |
| | | attendanceService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/attendanceHours") |
| | | @Log("查询某月出勤小时数") |
| | | @ApiOperation("查询某月出勤小时数") |
| | | @PreAuthorize("@el.check('attendance:list')") |
| | | public ResponseEntity<Object> queryAttendanceHours(AttendanceQueryCriteria criteria) { |
| | | return new ResponseEntity<>(attendanceService.queryAttendanceHours(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/queryAttendanceHours") |
| | | @Log("查询某天出勤小时数") |
| | | @ApiOperation("查询某天出勤小时数") |
| | | @PreAuthorize("@el.check('attendance:list')") |
| | | public ResponseEntity<Object> queryAttendanceHours(Long userId, String date) { |
| | | return new ResponseEntity<>(attendanceService.queryAttendanceHours(userId, date),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping(value = "/getUserMakeUpCard") |
| | | @Log("补卡判断登录人") |
| | | @ApiOperation("补卡判断登录人") |
| | | public ResponseEntity<Object> getUserMakeUpCard(@Validated @RequestBody String userId){ |
| | | attendanceService.getUserMakeUpCard(userId); |
| | | return new ResponseEntity<>(HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PostMapping(value = "/addAttendanceInfo") |
| | | @Log("考勤信息补充") |
| | | @ApiOperation("考勤信息补充") |
| | | public ResponseEntity<Object> addAttendanceInfo(@Validated @RequestBody Attendance attendance) throws Exception { |
| | | attendanceService.addAttendanceInfo(attendance); |
| | | return new ResponseEntity<>(HttpStatus.CREATED); |
| | | } |
| | | /*
|
| | | * Copyright 2019-2020 Zheng Jie
|
| | | *
|
| | | * Licensed under the Apache License, Version 2.0 (the "License");
|
| | | * you may not use this file except in compliance with the License.
|
| | | * You may obtain a copy of the License at
|
| | | *
|
| | | * http://www.apache.org/licenses/LICENSE-2.0
|
| | | *
|
| | | * Unless required by applicable law or agreed to in writing, software
|
| | | * distributed under the License is distributed on an "AS IS" BASIS,
|
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| | | * See the License for the specific language governing permissions and
|
| | | * limitations under the License.
|
| | | */
|
| | | package me.zhengjie.modules.attendance.rest;
|
| | |
|
| | | import me.zhengjie.annotation.Log;
|
| | | import me.zhengjie.modules.attendance.domain.Attendance;
|
| | | import me.zhengjie.modules.attendance.repository.AttendanceRepository;
|
| | | import me.zhengjie.modules.attendance.service.AttendanceService;
|
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceDto;
|
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceQueryCriteria;
|
| | | import org.apache.commons.lang3.ObjectUtils;
|
| | | import org.springframework.data.domain.Pageable;
|
| | | import lombok.RequiredArgsConstructor;
|
| | | import org.springframework.http.HttpStatus;
|
| | | import org.springframework.http.ResponseEntity;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | | import io.swagger.annotations.*;
|
| | | import java.io.IOException;
|
| | | import java.util.List;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | /**
|
| | | * @website https://eladmin.vip
|
| | | * @author wcd
|
| | | * @date 2022-12-14
|
| | | **/
|
| | | @RestController
|
| | | @RequiredArgsConstructor
|
| | | @Api(tags = "考勤记录管理")
|
| | | @RequestMapping("/api/attendance")
|
| | | public class AttendanceController {
|
| | |
|
| | | private final AttendanceService attendanceService;
|
| | | private final AttendanceRepository attendanceRepository;
|
| | |
|
| | | @Log("导出数据")
|
| | | @ApiOperation("导出数据")
|
| | | @GetMapping(value = "/download")
|
| | | @PreAuthorize("@el.check('attendance:download')")
|
| | | public void exportAttendance(HttpServletResponse response, AttendanceQueryCriteria criteria) throws IOException {
|
| | | attendanceService.download(attendanceService.queryAll(criteria), response);
|
| | | }
|
| | |
|
| | | @GetMapping
|
| | | @Log("查询考勤记录")
|
| | | @ApiOperation("查询考勤记录")
|
| | | @PreAuthorize("@el.check('attendance:list')")
|
| | | public ResponseEntity<Object> queryAttendance(AttendanceQueryCriteria criteria, Pageable pageable){
|
| | | return new ResponseEntity<>(attendanceService.queryAll(criteria,pageable),HttpStatus.OK);
|
| | | }
|
| | |
|
| | | @GetMapping("/notNormal")
|
| | | @Log("查询考勤记录")
|
| | | @ApiOperation("查询考勤记录")
|
| | | @PreAuthorize("@el.check('attendance:list')")
|
| | | public ResponseEntity<Object> queryAttendanceNotNormal(AttendanceQueryCriteria criteria, Pageable pageable){
|
| | | return new ResponseEntity<>(attendanceService.queryAllNotNormal(criteria,pageable),HttpStatus.OK);
|
| | | }
|
| | |
|
| | | @GetMapping(value = "/all")
|
| | | @Log("查询考勤记录")
|
| | | @ApiOperation("查询考勤记录")
|
| | | @PreAuthorize("@el.check('attendance:list')")
|
| | | public ResponseEntity<Object> queryAttendance(AttendanceQueryCriteria criteria){
|
| | | return new ResponseEntity<>(attendanceService.queryAll(criteria),HttpStatus.OK);
|
| | | }
|
| | |
|
| | | @PostMapping
|
| | | @Log("新增考勤记录")
|
| | | @ApiOperation("新增考勤记录")
|
| | | @PreAuthorize("@el.check('attendance:add')")
|
| | | public ResponseEntity<Object> createAttendance(@Validated @RequestBody Attendance resources){
|
| | | return new ResponseEntity<>(attendanceService.create(resources),HttpStatus.CREATED);
|
| | | }
|
| | |
|
| | | @PutMapping
|
| | | @Log("修改考勤记录")
|
| | | @ApiOperation("修改考勤记录")
|
| | | @PreAuthorize("@el.check('attendance:edit')")
|
| | | public ResponseEntity<Object> updateAttendance(@Validated @RequestBody Attendance resources){
|
| | | attendanceService.update(resources);
|
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
| | | }
|
| | |
|
| | | @DeleteMapping
|
| | | @Log("删除考勤记录")
|
| | | @ApiOperation("删除考勤记录")
|
| | | @PreAuthorize("@el.check('attendance:del')")
|
| | | public ResponseEntity<Object> deleteAttendance(@RequestBody Long[] ids) {
|
| | | attendanceService.deleteAll(ids);
|
| | | return new ResponseEntity<>(HttpStatus.OK);
|
| | | }
|
| | |
|
| | | @GetMapping(value = "/attendanceHours")
|
| | | @Log("查询某月出勤小时数")
|
| | | @ApiOperation("查询某月出勤小时数")
|
| | | @PreAuthorize("@el.check('attendance:list')")
|
| | | public ResponseEntity<Object> queryAttendanceHours(AttendanceQueryCriteria criteria) {
|
| | | return new ResponseEntity<>(attendanceService.queryAttendanceHours(criteria),HttpStatus.OK);
|
| | | }
|
| | |
|
| | | @GetMapping(value = "/queryAttendanceHours")
|
| | | @Log("查询某天出勤小时数")
|
| | | @ApiOperation("查询某天出勤小时数")
|
| | | @PreAuthorize("@el.check('attendance:list')")
|
| | | public ResponseEntity<Object> queryAttendanceHours(Long userId, String date) {
|
| | | return new ResponseEntity<>(attendanceService.queryAttendanceHours(userId, date),HttpStatus.OK);
|
| | | }
|
| | |
|
| | | @PostMapping(value = "/getUserMakeUpCard")
|
| | | @Log("补卡判断登录人")
|
| | | @ApiOperation("补卡判断登录人")
|
| | | public ResponseEntity<Object> getUserMakeUpCard(@Validated @RequestBody String userId){
|
| | | attendanceService.getUserMakeUpCard(userId);
|
| | | return new ResponseEntity<>(HttpStatus.CREATED);
|
| | | }
|
| | |
|
| | | @PostMapping(value = "/addAttendanceInfo")
|
| | | @Log("考勤信息补充")
|
| | | @ApiOperation("考勤信息补充")
|
| | | public ResponseEntity<Object> addAttendanceInfo(@Validated @RequestBody Attendance attendance) throws Exception {
|
| | | attendanceService.addAttendanceInfo(attendance);
|
| | | return new ResponseEntity<>(HttpStatus.CREATED);
|
| | | }
|
| | | } |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.attendance.domain.AgreeUpdateRequest; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceLeave; |
| | | import me.zhengjie.modules.attendance.service.AttendanceLeaveService; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2022-12-16 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "请假管理") |
| | | @RequestMapping("/api/attendanceLeave") |
| | | public class AttendanceLeaveController { |
| | | |
| | | private final AttendanceLeaveService attendanceLeaveService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('attendanceLeave:download')") |
| | | public void exportAttendanceLeave(HttpServletResponse response, AttendanceLeaveQueryCriteria criteria) throws IOException { |
| | | attendanceLeaveService.download(attendanceLeaveService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询请假") |
| | | @ApiOperation("查询请假") |
| | | @PreAuthorize("@el.check('attendanceLeave:list')") |
| | | public ResponseEntity<Object> queryAttendanceLeave(AttendanceLeaveQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(attendanceLeaveService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/all") |
| | | @Log("查询请假") |
| | | @ApiOperation("查询请假") |
| | | @PreAuthorize("@el.check('attendanceLeave:list')") |
| | | public ResponseEntity<Object> queryAttendanceLeave(AttendanceLeaveQueryCriteria criteria){ |
| | | return new ResponseEntity<>(attendanceLeaveService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增请假") |
| | | @ApiOperation("新增请假") |
| | | @PreAuthorize("@el.check('attendanceLeave:add')") |
| | | public ResponseEntity<Object> createAttendanceLeave(@Validated @RequestBody AttendanceLeave resources) throws Exception { |
| | | return new ResponseEntity<>(attendanceLeaveService.create(resources),HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改请假") |
| | | @ApiOperation("修改请假") |
| | | @PreAuthorize("@el.check('attendanceLeave:edit')") |
| | | public ResponseEntity<Object> updateAttendanceLeave(@Validated @RequestBody AttendanceLeave resources){ |
| | | attendanceLeaveService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @PostMapping(value = "/calcTimeLength") |
| | | @Log("计算请假时长") |
| | | @ApiOperation("计算请假时长") |
| | | public ResponseEntity<Object> calcTimeLength(@RequestBody AttendanceLeave resources) throws Exception { |
| | | return new ResponseEntity<>(attendanceLeaveService.calcTimeLength(resources), HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping(value = "/getYearTimeLength") |
| | | @Log("获取年假时长") |
| | | @ApiOperation("获取年假时长") |
| | | public ResponseEntity<Object> getYearTimeLength(@RequestBody Long userId) throws ParseException { |
| | | return new ResponseEntity<>(attendanceLeaveService.getYearTimeLength(userId), HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping(value = "/getOverTimeLength") |
| | | @Log("获取调休假时长") |
| | | @ApiOperation("获取调休假时长") |
| | | public ResponseEntity<Object> getOverTimeLength(@RequestBody Long userId) throws ParseException { |
| | | return new ResponseEntity<>(attendanceLeaveService.getOverTimeLength(userId), HttpStatus.OK); |
| | | } |
| | | |
| | | @PutMapping(value = "/approve") |
| | | @Log("审核功能") |
| | | @ApiOperation("审核功能") |
| | | @PreAuthorize("@el.check('attendanceLeave:approve')") |
| | | public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceLeave resources) throws Exception { |
| | | attendanceLeaveService.updateApprove(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除请假") |
| | | @ApiOperation("删除请假") |
| | | @PreAuthorize("@el.check('attendanceLeave:del')") |
| | | public ResponseEntity<Object> deleteAttendanceLeave(@RequestBody Long[] ids) { |
| | | attendanceLeaveService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | |
| | | @PutMapping(value = "/updateAgree") |
| | | @Log("批量审核") |
| | | @ApiOperation("批量审核") |
| | | @PreAuthorize("@el.check('attendanceLeave:updateAgree')") |
| | | public ResponseEntity<Object> editIsAgree(@Validated @RequestBody AgreeUpdateRequest request) throws Exception { |
| | | attendanceLeaveService.updateAgree(request); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | /*
|
| | | * Copyright 2019-2020 Zheng Jie
|
| | | *
|
| | | * Licensed under the Apache License, Version 2.0 (the "License");
|
| | | * you may not use this file except in compliance with the License.
|
| | | * You may obtain a copy of the License at
|
| | | *
|
| | | * http://www.apache.org/licenses/LICENSE-2.0
|
| | | *
|
| | | * Unless required by applicable law or agreed to in writing, software
|
| | | * distributed under the License is distributed on an "AS IS" BASIS,
|
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| | | * See the License for the specific language governing permissions and
|
| | | * limitations under the License.
|
| | | */
|
| | | package me.zhengjie.modules.attendance.rest;
|
| | |
|
| | | import me.zhengjie.annotation.Log;
|
| | | import me.zhengjie.modules.attendance.domain.AgreeUpdateRequest;
|
| | | import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement;
|
| | | import me.zhengjie.modules.attendance.domain.AttendanceLeave;
|
| | | import me.zhengjie.modules.attendance.service.AttendanceLeaveService;
|
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveQueryCriteria;
|
| | | import org.springframework.data.domain.Pageable;
|
| | | import lombok.RequiredArgsConstructor;
|
| | | import org.springframework.http.HttpStatus;
|
| | | import org.springframework.http.ResponseEntity;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.validation.annotation.Validated;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | | import io.swagger.annotations.*;
|
| | | import java.io.IOException;
|
| | | import java.text.ParseException;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | /**
|
| | | * @website https://eladmin.vip
|
| | | * @author wcd
|
| | | * @date 2022-12-16
|
| | | **/
|
| | | @RestController
|
| | | @RequiredArgsConstructor
|
| | | @Api(tags = "请假管理")
|
| | | @RequestMapping("/api/attendanceLeave")
|
| | | public class AttendanceLeaveController {
|
| | |
|
| | | private final AttendanceLeaveService attendanceLeaveService;
|
| | |
|
| | | @Log("导出数据")
|
| | | @ApiOperation("导出数据")
|
| | | @GetMapping(value = "/download")
|
| | | @PreAuthorize("@el.check('attendanceLeave:download')")
|
| | | public void exportAttendanceLeave(HttpServletResponse response, AttendanceLeaveQueryCriteria criteria) throws IOException {
|
| | | attendanceLeaveService.download(attendanceLeaveService.queryAll(criteria), response);
|
| | | }
|
| | |
|
| | | @GetMapping
|
| | | @Log("查询请假")
|
| | | @ApiOperation("查询请假")
|
| | | @PreAuthorize("@el.check('attendanceLeave:list')")
|
| | | public ResponseEntity<Object> queryAttendanceLeave(AttendanceLeaveQueryCriteria criteria, Pageable pageable){
|
| | | return new ResponseEntity<>(attendanceLeaveService.queryAll(criteria,pageable),HttpStatus.OK);
|
| | | }
|
| | |
|
| | | @GetMapping(value = "/all")
|
| | | @Log("查询请假")
|
| | | @ApiOperation("查询请假")
|
| | | @PreAuthorize("@el.check('attendanceLeave:list')")
|
| | | public ResponseEntity<Object> queryAttendanceLeave(AttendanceLeaveQueryCriteria criteria){
|
| | | return new ResponseEntity<>(attendanceLeaveService.queryAll(criteria),HttpStatus.OK);
|
| | | }
|
| | |
|
| | | @PostMapping
|
| | | @Log("新增请假")
|
| | | @ApiOperation("新增请假")
|
| | | @PreAuthorize("@el.check('attendanceLeave:add')")
|
| | | public ResponseEntity<Object> createAttendanceLeave(@Validated @RequestBody AttendanceLeave resources) throws Exception {
|
| | | return new ResponseEntity<>(attendanceLeaveService.create(resources),HttpStatus.CREATED);
|
| | | }
|
| | |
|
| | | @PutMapping
|
| | | @Log("修改请假")
|
| | | @ApiOperation("修改请假")
|
| | | @PreAuthorize("@el.check('attendanceLeave:edit')")
|
| | | public ResponseEntity<Object> updateAttendanceLeave(@Validated @RequestBody AttendanceLeave resources){
|
| | | attendanceLeaveService.update(resources);
|
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
| | | }
|
| | |
|
| | | @PostMapping(value = "/calcTimeLength")
|
| | | @Log("计算请假时长")
|
| | | @ApiOperation("计算请假时长")
|
| | | public ResponseEntity<Object> calcTimeLength(@RequestBody AttendanceLeave resources) throws Exception {
|
| | | return new ResponseEntity<>(attendanceLeaveService.calcTimeLength(resources), HttpStatus.OK);
|
| | | }
|
| | |
|
| | | @PostMapping(value = "/getYearTimeLength/{userId}")
|
| | | @Log("获取年假时长")
|
| | | @ApiOperation("获取年假时长")
|
| | | public ResponseEntity<Object> getYearTimeLength(@PathVariable Long userId, @RequestBody String year) throws ParseException {
|
| | | return new ResponseEntity<>(attendanceLeaveService.getYearTimeLength(userId, year), HttpStatus.OK);
|
| | | }
|
| | |
|
| | | @PostMapping(value = "/getOverTimeLength/{userId}")
|
| | | @Log("获取调休假时长")
|
| | | @ApiOperation("获取调休假时长")
|
| | | public ResponseEntity<Object> getOverTimeLength(@PathVariable Long userId, @RequestBody String yearMonth) throws ParseException {
|
| | | Double overTimeLength = attendanceLeaveService.getOverTimeLength(userId, yearMonth);
|
| | | Double overTimeCloseLength = attendanceLeaveService.getOverTimeCloseLength(userId, yearMonth);
|
| | | return new ResponseEntity<>(overTimeLength + overTimeCloseLength, HttpStatus.OK);
|
| | | }
|
| | |
|
| | | @PutMapping(value = "/approve")
|
| | | @Log("审核功能")
|
| | | @ApiOperation("审核功能")
|
| | | @PreAuthorize("@el.check('attendanceLeave:approve')")
|
| | | public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceLeave resources) throws Exception {
|
| | | attendanceLeaveService.updateApprove(resources);
|
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
| | | }
|
| | |
|
| | | @DeleteMapping
|
| | | @Log("删除请假")
|
| | | @ApiOperation("删除请假")
|
| | | @PreAuthorize("@el.check('attendanceLeave:del')")
|
| | | public ResponseEntity<Object> deleteAttendanceLeave(@RequestBody Long[] ids) {
|
| | | attendanceLeaveService.deleteAll(ids);
|
| | | return new ResponseEntity<>(HttpStatus.OK);
|
| | | }
|
| | |
|
| | | @PutMapping(value = "/updateAgree")
|
| | | @Log("批量审核")
|
| | | @ApiOperation("批量审核")
|
| | | @PreAuthorize("@el.check('attendanceLeave:updateAgree')")
|
| | | public ResponseEntity<Object> editIsAgree(@Validated @RequestBody AgreeUpdateRequest request) throws Exception {
|
| | | attendanceLeaveService.updateAgree(request);
|
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
| | | }
|
| | | } |
| | |
| | | Double getYearTimeLength(Long userId) throws ParseException;
|
| | |
|
| | | /**
|
| | | *获取剩余年假
|
| | | * @return
|
| | | * @throws ParseException
|
| | | */
|
| | | Double getYearTimeLength(Long userId, String year) throws ParseException;
|
| | |
|
| | | /**
|
| | | *获取剩余调休假
|
| | | * @return
|
| | | * @throws ParseException
|
| | | */
|
| | | Double getOverTimeLength(Long userId) throws ParseException;
|
| | |
|
| | | Double getOverTimeLength(Long userId, String yearMonth) throws ParseException;
|
| | |
|
| | | Double getOverTimeCloseLength(Long userId);
|
| | |
|
| | | Double getOverTimeCloseLength(Long userId, String yearMonth);
|
| | |
|
| | | /**
|
| | | * 审核功能
|
| | | * @param resources /
|
| | |
| | | Map<String,Object> queryAll(AttendanceQueryCriteria criteria, Pageable pageable);
|
| | |
|
| | | /**
|
| | | * 查询数据分页
|
| | | * @param criteria 条件
|
| | | * @param pageable 分页参数
|
| | | * @return Map<String,Object>
|
| | | */
|
| | | Map<String,Object> queryAllNotNormal(AttendanceQueryCriteria criteria, Pageable pageable);
|
| | |
|
| | | /**
|
| | | * 查询所有数据不分页
|
| | | * @param criteria 条件参数
|
| | | * @return List<AttendanceDto>
|
| | |
| | | */
|
| | | void addAttendanceInfo(Attendance attendance) throws Exception;
|
| | |
|
| | | void generateAttendance(Long id, String startDate, String endDate);
|
| | | } |
| | |
| | | /** 出差类别 */
|
| | | private String category;
|
| | |
|
| | | /** 项目ID */
|
| | | private Long projectId;
|
| | |
|
| | | /** 审批状态 */
|
| | | private String approvalStatus;
|
| | |
|
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.service.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | import me.zhengjie.annotation.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2022-12-14 |
| | | **/ |
| | | @Data |
| | | public class AttendanceQueryCriteria { |
| | | |
| | | /** 精确查询姓名 */ |
| | | @Query |
| | | private Long userId; |
| | | |
| | | /** 时间区间查询 */ |
| | | @Query(type = Query.Type.BETWEEN, propName = "attendanceDate") |
| | | private List<String> attendanceDate; |
| | | |
| | | /* 开始位置精确查询 */ |
| | | @Query(type = Query.Type.EQUAL, propName = "startLocationResults") |
| | | private String startLocationResults; |
| | | |
| | | /* 结束位置精确查询 */ |
| | | @Query(type = Query.Type.EQUAL, propName = "endLocationResults") |
| | | private String endLocationResults; |
| | | |
| | | /* 开始打卡精确查询 */ |
| | | @Query(type = Query.Type.EQUAL, propName = "startClockResults") |
| | | private String startClockResults; |
| | | |
| | | /* 结束打卡精确查询 */ |
| | | @Query(type = Query.Type.EQUAL, propName = "endClockResults") |
| | | private String endClockResults; |
| | | |
| | | /* 模糊 */ |
| | | @Query(propName = "attendanceDate", type = Query.Type.INNER_LIKE) |
| | | private String attendanceDateLike; |
| | | |
| | | private String targetYearMonth; |
| | | /*
|
| | | * Copyright 2019-2020 Zheng Jie
|
| | | *
|
| | | * Licensed under the Apache License, Version 2.0 (the "License");
|
| | | * you may not use this file except in compliance with the License.
|
| | | * You may obtain a copy of the License at
|
| | | *
|
| | | * http://www.apache.org/licenses/LICENSE-2.0
|
| | | *
|
| | | * Unless required by applicable law or agreed to in writing, software
|
| | | * distributed under the License is distributed on an "AS IS" BASIS,
|
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| | | * See the License for the specific language governing permissions and
|
| | | * limitations under the License.
|
| | | */
|
| | | package me.zhengjie.modules.attendance.service.dto;
|
| | |
|
| | | import lombok.Data;
|
| | |
|
| | | import java.util.List;
|
| | | import me.zhengjie.annotation.Query;
|
| | |
|
| | | /**
|
| | | * @website https://eladmin.vip
|
| | | * @author wcd
|
| | | * @date 2022-12-14
|
| | | **/
|
| | | @Data
|
| | | public class AttendanceQueryCriteria {
|
| | |
|
| | | /** 精确查询姓名 */
|
| | | @Query
|
| | | private Long userId;
|
| | |
|
| | | /** 时间区间查询 */
|
| | | @Query(type = Query.Type.BETWEEN, propName = "attendanceDate")
|
| | | private List<String> attendanceDate;
|
| | |
|
| | | /* 开始位置精确查询 */
|
| | | @Query(type = Query.Type.EQUAL, propName = "startLocationResults")
|
| | | private String startLocationResults;
|
| | |
|
| | | /* 结束位置精确查询 */
|
| | | @Query(type = Query.Type.EQUAL, propName = "endLocationResults")
|
| | | private String endLocationResults;
|
| | |
|
| | | /* 开始打卡精确查询 */
|
| | | @Query(type = Query.Type.EQUAL, propName = "startClockResults")
|
| | | private String startClockResults;
|
| | |
|
| | | /* 结束打卡精确查询 */
|
| | | @Query(type = Query.Type.EQUAL, propName = "endClockResults")
|
| | | private String endClockResults;
|
| | |
|
| | | /* 开始打卡模糊查询 */
|
| | | @Query(orGroup = "NotNormal", type = Query.Type.IN, propName = "startClockResults")
|
| | | private List<String> startClockResultsList;
|
| | |
|
| | | /* 结束打卡模糊查询 */
|
| | | @Query(orGroup = "NotNormal", type = Query.Type.IN, propName = "endClockResults")
|
| | | private List<String> endClockResultsList;
|
| | |
|
| | | /* 模糊 */
|
| | | @Query(propName = "attendanceDate", type = Query.Type.INNER_LIKE)
|
| | | private String attendanceDateLike;
|
| | |
|
| | | @Query(propName = "userId", type = Query.Type.IN)
|
| | | private List<Long> userIds;
|
| | |
|
| | | private String targetYearMonth;
|
| | | } |
| | |
| | | /*
|
| | | * Copyright 2019-2020 Zheng Jie
|
| | | *
|
| | | * Licensed under the Apache License, Version 2.0 (the "License");
|
| | | * you may not use this file except in compliance with the License.
|
| | | * You may obtain a copy of the License at
|
| | | *
|
| | | * http://www.apache.org/licenses/LICENSE-2.0
|
| | | *
|
| | | * Unless required by applicable law or agreed to in writing, software
|
| | | * distributed under the License is distributed on an "AS IS" BASIS,
|
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| | | * See the License for the specific language governing permissions and
|
| | | * limitations under the License.
|
| | | */
|
| | | * Copyright 2019-2020 Zheng Jie
|
| | | *
|
| | | * Licensed under the Apache License, Version 2.0 (the "License");
|
| | | * you may not use this file except in compliance with the License.
|
| | | * You may obtain a copy of the License at
|
| | | *
|
| | | * http://www.apache.org/licenses/LICENSE-2.0
|
| | | *
|
| | | * Unless required by applicable law or agreed to in writing, software
|
| | | * distributed under the License is distributed on an "AS IS" BASIS,
|
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| | | * See the License for the specific language governing permissions and
|
| | | * limitations under the License.
|
| | | */
|
| | | package me.zhengjie.modules.attendance.service.impl;
|
| | |
|
| | | import lombok.RequiredArgsConstructor;
|
| | |
| | |
|
| | | /**
|
| | | * @author wcd
|
| | | * @website https://eladmin.vip
|
| | | * @description 服务实现
|
| | | * @date 2022-12-16
|
| | | **/
|
| | | * @website https://eladmin.vip
|
| | | * @description 服务实现
|
| | | * @date 2022-12-16
|
| | | **/
|
| | | @Service
|
| | | @RequiredArgsConstructor
|
| | | public class AttendanceLeaveServiceImpl implements AttendanceLeaveService {
|
| | |
| | | private final TemplateControlFieldService templateControlFieldService;
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> queryAll(AttendanceLeaveQueryCriteria criteria, Pageable pageable) {
|
| | | Page<AttendanceLeave> page = attendanceLeaveRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
| | | public Map<String,Object> queryAll(AttendanceLeaveQueryCriteria criteria, Pageable pageable){
|
| | | Page<AttendanceLeave> page = attendanceLeaveRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
| | | //将实体转换为Dto(重写)
|
| | | Function<AttendanceLeave, AttendanceLeaveDto> func = new Function<AttendanceLeave, AttendanceLeaveDto>() {
|
| | | Function<AttendanceLeave, AttendanceLeaveDto> func = new Function<AttendanceLeave, AttendanceLeaveDto>(){
|
| | |
|
| | | @Override
|
| | | public AttendanceLeaveDto apply(AttendanceLeave attendanceLeave) {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<AttendanceLeaveDto> queryAll(AttendanceLeaveQueryCriteria criteria) {
|
| | | public List<AttendanceLeaveDto> queryAll(AttendanceLeaveQueryCriteria criteria){
|
| | | List<AttendanceLeaveDto> attendanceLeaveDtoList = attendanceLeaveMapper.toDto(attendanceLeaveRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
|
| | | attendanceLeaveDtoList.forEach(attendanceLeaveDto -> {
|
| | | //查询用户信息
|
| | |
| | | @Transactional
|
| | | public AttendanceLeaveDto findById(Long id) {
|
| | | AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(id).orElseGet(AttendanceLeave::new);
|
| | | ValidationUtil.isNull(attendanceLeave.getId(), "AttendanceLeave", "id", id);
|
| | | ValidationUtil.isNull(attendanceLeave.getId(),"AttendanceLeave","id",id);
|
| | | return attendanceLeaveMapper.toDto(attendanceLeave);
|
| | | }
|
| | |
|
| | |
| | | String LeaStartTime = df.format(resources.getLeaveStartTime());
|
| | | String LeaEndTime = df.format(resources.getLeaveEndTime());
|
| | | // 如果按天为单位请假拼接请假时间的时分秒,取上下班基准时间
|
| | | if (resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_DAY)) {
|
| | | if(resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_DAY)) {
|
| | | //查询用户的排班时间
|
| | | User user = userRepository.getOne(resources.getUserId());
|
| | | LeaStartTime = LeaStartTime.substring(0, 10) + " " + user.getSysRostering().getWorkStartTime().toString() + ":00";
|
| | | LeaEndTime = LeaEndTime.substring(0, 10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00";
|
| | | LeaStartTime = LeaStartTime.substring(0,10) + " " + user.getSysRostering().getWorkStartTime().toString() + ":00";
|
| | | LeaEndTime = LeaEndTime.substring(0,10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00";
|
| | | }
|
| | | // 查询其他状态的表是否有重复
|
| | | // repeatValidation(LeaStartTime, LeaEndTime, resources.getUserId());
|
| | | // 验证请假时间是否冲突
|
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(LeaStartTime, LeaEndTime, resources.getUserId());
|
| | | if (attendanceLeaveList.size() > 0) {
|
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(LeaStartTime,LeaEndTime, resources.getUserId());
|
| | | if(attendanceLeaveList.size() > 0){
|
| | | AttendanceLeave errTime = attendanceLeaveList.get(0);
|
| | | //LocalDateTime转换为Date
|
| | | LocalDateTime strartTime = errTime.getLeaveStartTime().toLocalDateTime();
|
| | |
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | | throw new BadRequestException("请假时间冲突," + errorFormat.format(strTime) + "至" + errorFormat.format(endTim)
|
| | | + "已经存在请假记录,请调整时间");
|
| | | } else {
|
| | | }else {
|
| | | // 获取当前登陆人信息,设置为请假发起人
|
| | | User user = userRepository.getOne(resources.getUserId());
|
| | | User approvalUser = userRepository.getOne(resources.getApprovalUserId());
|
| | | List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>();
|
| | | // 查询节假日
|
| | | List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll();
|
| | | for (SysConfigHoliday sysConfigHoliday : sysConfigHolidayList) {
|
| | | if (sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_WEEKDAY)) {
|
| | | for(SysConfigHoliday sysConfigHoliday : sysConfigHolidayList){
|
| | | if(sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_WEEKDAY)){
|
| | | //工作日
|
| | | isWork.add(sysConfigHoliday.getHolidayDate().toString().substring(0, 10));
|
| | | } else {
|
| | | holiday.add(sysConfigHoliday.getHolidayDate().toString().substring(0, 10));
|
| | | isWork.add(sysConfigHoliday.getHolidayDate().toString().substring(0,10));
|
| | | }else{
|
| | | holiday.add(sysConfigHoliday.getHolidayDate().toString().substring(0,10));
|
| | | }
|
| | | }
|
| | | // 循环添加开始时间到结束时间的每一天
|
| | | List<String> dateList = getBetweenDate(resources.getLeaveStartTime().toLocalDateTime().toString(), resources.getLeaveEndTime().toLocalDateTime().toString());
|
| | | List<String> dateList = getBetweenDate(resources.getLeaveStartTime().toLocalDateTime().toString(),resources.getLeaveEndTime().toLocalDateTime().toString());
|
| | | int i = 0;
|
| | | for (String date : dateList) {
|
| | | for(String date : dateList){
|
| | | LocalDate localDate = LocalDate.parse(date);
|
| | | Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
|
| | | // 不是周末并且节假日表中不存在在创建
|
| | | if ((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))) {
|
| | | AttendanceLeave attendanceLeave = getAttendanceLeave(resources, date, user, i, LeaStartTime, LeaEndTime, null);
|
| | | if((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))){
|
| | | AttendanceLeave attendanceLeave = getAttendanceLeave(resources,date,user,i,LeaStartTime,LeaEndTime,null);
|
| | |
|
| | | // 判断是否提交企微审批
|
| | | List<DictDetail> siteTypes = dictDetailRepository.findByDictName(Constant.APPROVAL_SITE_TYPE).stream().filter(siteType -> siteType.getValue().toLowerCase().equals("wecom")).collect(Collectors.toList());
|
| | |
| | | * @param LeaEndTime
|
| | | * @return
|
| | | */
|
| | | public AttendanceLeave getAttendanceLeave(AttendanceLeave resources, String date, User user, int i, String LeaStartTime, String LeaEndTime, Long resUserId) {
|
| | | public AttendanceLeave getAttendanceLeave(AttendanceLeave resources,String date,User user,int i,String LeaStartTime,String LeaEndTime,Long resUserId){
|
| | | DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
| | | AttendanceLeave attendanceLeave = new AttendanceLeave();
|
| | | //resUserId为null说明是添加,反之
|
| | | if (resUserId == null) {
|
| | | if(resUserId == null){
|
| | | resources.setUserId(user.getId());
|
| | | } else {
|
| | | }else{
|
| | | resources.setUserId(resUserId);
|
| | | }
|
| | | //日期时间单位是小时
|
| | | if (resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_HOUR)) {
|
| | | if(resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_HOUR)){
|
| | | Calculate calculate = new Calculate();
|
| | | String startTime = date + " " + LeaStartTime.substring(11, 19);
|
| | | String endTime = date + " " + LeaEndTime.substring(11, 19);
|
| | | String startTime = date + " " + LeaStartTime.substring(11,19);
|
| | | String endTime = date + " " + LeaEndTime.substring(11,19);
|
| | | //请假开始时间结束时间不相等的情况
|
| | | if (!LeaStartTime.substring(0, 10).equals(LeaEndTime.substring(0, 10))) {
|
| | | if(!LeaStartTime.substring(0,10).equals(LeaEndTime.substring(0,10))){
|
| | | //第一次循环用下班基准时间和请假开始时间算时长
|
| | | if (i == 0) {
|
| | | calculate.setStart(LocalDateTime.parse(startTime, sdf));
|
| | | calculate.setEnd(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkEndTime() + ":00", sdf));
|
| | | if(i == 0){
|
| | | calculate.setStart(LocalDateTime.parse(startTime,sdf));
|
| | | calculate.setEnd(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkEndTime() + ":00",sdf));
|
| | | resources.setLeaveStartTime(Timestamp.valueOf(startTime));
|
| | | resources.setLeaveEndTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkEndTime() + ":00"));
|
| | | } else if (date.equals(LeaEndTime.substring(0, 10))) {
|
| | | }else if(date.equals(LeaEndTime.substring(0,10))){
|
| | | //最后一次循环
|
| | | calculate.setStart(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkStartTime() + ":00", sdf));
|
| | | calculate.setEnd(LocalDateTime.parse(endTime, sdf));
|
| | | calculate.setStart(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkStartTime() + ":00",sdf));
|
| | | calculate.setEnd(LocalDateTime.parse(endTime,sdf));
|
| | | resources.setLeaveStartTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkStartTime() + ":00"));
|
| | | resources.setLeaveEndTime(Timestamp.valueOf(endTime));
|
| | | } else {
|
| | | calculate.setStart(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkStartTime() + ":00", sdf));
|
| | | calculate.setEnd(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkEndTime() + ":00", sdf));
|
| | | }else{
|
| | | calculate.setStart(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkStartTime() + ":00",sdf));
|
| | | calculate.setEnd(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkEndTime() + ":00",sdf));
|
| | | resources.setLeaveStartTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkStartTime() + ":00"));
|
| | | resources.setLeaveEndTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkEndTime() + ":00"));
|
| | | }
|
| | |
| | | Double result = Double.valueOf(new BigDecimal((float) timeSeconds / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
| | | resources.setLeaveDuration(result);
|
| | | }
|
| | | } else {
|
| | | }else{
|
| | | String startTime = date + " " + user.getSysRostering().getWorkStartTime() + ":00";
|
| | | String endTime = date + " " + user.getSysRostering().getWorkEndTime() + ":00";
|
| | | resources.setLeaveStartTime(Timestamp.valueOf(startTime));
|
| | |
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void update(AttendanceLeave resources) {
|
| | | AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(resources.getId()).orElseGet(AttendanceLeave::new);
|
| | | ValidationUtil.isNull(attendanceLeave.getId(), "AttendanceLeave", "id", resources.getId());
|
| | | ValidationUtil.isNull( attendanceLeave.getId(),"AttendanceLeave","id",resources.getId());
|
| | | attendanceLeave.copy(resources);
|
| | |
|
| | | //审核通过或者退回不能删除
|
| | | if (attendanceLeave.getApprovalStatus().equals(Constant.APPROVAL_STATUS_PASSED) || attendanceLeave.getApprovalStatus().equals(Constant.APPROVAL_STATUS_RETURNED)) {
|
| | | if(attendanceLeave.getApprovalStatus().equals(Constant.APPROVAL_STATUS_PASSED) || attendanceLeave.getApprovalStatus().equals(Constant.APPROVAL_STATUS_RETURNED)){
|
| | | throw new BadRequestException("审核通过或退回的不能进行修改");
|
| | | }
|
| | |
|
| | |
| | | User user1 = userRepository.getOne(SecurityUtils.getCurrentUserId());
|
| | | Role role = user1.getRoles().iterator().next();
|
| | | //除超管、总经理只能修改自己信息
|
| | | if (role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL) {
|
| | | if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())) {
|
| | | if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){
|
| | | if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){
|
| | | throw new BadRequestException("只能修改自己的记录");
|
| | | }
|
| | | }
|
| | |
| | | String LeaStartTime = df.format(resources.getLeaveStartTime());
|
| | | String LeaEndTime = df.format(resources.getLeaveEndTime());
|
| | | // 如果按天为单位请假拼接请假时间的时分秒,取上下班基准时间
|
| | | if (resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_DAY)) {
|
| | | if(resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_DAY)){
|
| | | //查询用户的排班时间
|
| | | User user = userRepository.getOne(resources.getUserId());
|
| | | LeaStartTime = LeaStartTime.substring(0, 10) + " " + user.getSysRostering().getWorkStartTime().toString() + ":00";
|
| | | LeaEndTime = LeaEndTime.substring(0, 10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00";
|
| | | LeaStartTime = LeaStartTime.substring(0,10) + " " + user.getSysRostering().getWorkStartTime().toString() + ":00";
|
| | | LeaEndTime = LeaEndTime.substring(0,10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00";
|
| | | }
|
| | | // 查询其他状态的表是否有重复
|
| | | // repeatValidation(LeaStartTime, LeaEndTime, resources.getUserId());
|
| | |
| | | if (attendanceLeaveList.size() > 0) {
|
| | | AttendanceLeave errorSysAskForLeave = attendanceLeaveList.get(0);
|
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
|
| | | throw new BadRequestException("请假时间冲突," + errorFormat.format(errorSysAskForLeave.getLeaveStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getLeaveEndTime())
|
| | | + "已经存在请假记录,请调整时间");
|
| | | } else {
|
| | | throw new BadRequestException("请假时间冲突," + errorFormat.format(errorSysAskForLeave.getLeaveStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getLeaveEndTime())
|
| | | + "已经存在请假记录,请调整时间");
|
| | | }else{
|
| | | //暂存userId
|
| | | Long resUserId = attendanceLeave.getUserId();
|
| | | // 删除以前的记录
|
| | |
| | | List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>();
|
| | | // 查询节假日
|
| | | List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll();
|
| | | for (SysConfigHoliday sysConfigHoliday : sysConfigHolidayList) {
|
| | | if (sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_WEEKDAY)) {
|
| | | for(SysConfigHoliday sysConfigHoliday : sysConfigHolidayList){
|
| | | if(sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_WEEKDAY)){
|
| | | //工作日
|
| | | isWork.add(sysConfigHoliday.getHolidayDate().toString().substring(0, 10));
|
| | | } else {
|
| | | holiday.add(sysConfigHoliday.getHolidayDate().toString().substring(0, 10));
|
| | | isWork.add(sysConfigHoliday.getHolidayDate().toString().substring(0,10));
|
| | | }else{
|
| | | holiday.add(sysConfigHoliday.getHolidayDate().toString().substring(0,10));
|
| | | }
|
| | | }
|
| | | // 循环添加开始时间到结束时间的每一天
|
| | | List<String> dateList = getBetweenDate(resources.getLeaveStartTime().toLocalDateTime().toString(), resources.getLeaveEndTime().toLocalDateTime().toString());
|
| | | List<String> dateList = getBetweenDate(resources.getLeaveStartTime().toLocalDateTime().toString(),resources.getLeaveEndTime().toLocalDateTime().toString());
|
| | | int i = 0;
|
| | | for (String date : dateList) {
|
| | | for(String date : dateList){
|
| | | LocalDate localDate = LocalDate.parse(date);
|
| | | Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
|
| | | // 不是周末并且节假日表中不存在在创建
|
| | | if ((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))) {
|
| | | AttendanceLeave attendanceLeave1 = getAttendanceLeave(resources, date, user, i, LeaStartTime, LeaEndTime, resUserId);
|
| | | if((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))){
|
| | | AttendanceLeave attendanceLeave1 = getAttendanceLeave(resources,date,user,i,LeaStartTime,LeaEndTime,resUserId);
|
| | | i++;
|
| | | attendanceLeaveRepository.save(attendanceLeave1);
|
| | | }
|
| | |
| | | * @param endTime
|
| | | * @param userId
|
| | | */
|
| | | public void repeatValidation(String startTime, String endTime, Long userId) {
|
| | | public void repeatValidation(String startTime, String endTime, Long userId){
|
| | | // 查询外出表
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateTime(startTime, endTime, userId);
|
| | | if (attendanceGoOutList.size() > 0) {
|
| | | if(attendanceGoOutList.size() > 0) {
|
| | | AttendanceGoOut errorSysAskForLeave = attendanceGoOutList.get(0);
|
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
|
| | | throw new BadRequestException("外出时间冲突," + errorFormat.format(errorSysAskForLeave.getOutStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getOutEndTime())
|
| | | + "已经存在外出记录,请调整时间");
|
| | | }
|
| | | // 查询出差表
|
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(startTime.substring(0, 10), endTime.substring(0, 10), userId);
|
| | | if (attendanceBusinessTravelList.size() > 0) {
|
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(startTime.substring(0,10),endTime.substring(0,10), userId);
|
| | | if(attendanceBusinessTravelList.size() > 0){
|
| | | AttendanceBusinessTravel errorSysAskForLeave = attendanceBusinessTravelList.get(0);
|
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
|
| | | throw new BadRequestException("出差时间冲突," + errorFormat.format(errorSysAskForLeave.getTravelStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getTravelEndTime())
|
| | |
| | | * @param endTime
|
| | | * @return
|
| | | */
|
| | | public List<String> getBetweenDate(String startTime, String endTime) {
|
| | | public List<String> getBetweenDate(String startTime, String endTime){
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
| | | // 声明保存日期集合
|
| | | List<String> list = new ArrayList<String>();
|
| | |
| | |
|
| | | //用Calendar 进行日期比较判断
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | while (startDate.getTime() <= endDate.getTime()) {
|
| | | while (startDate.getTime()<=endDate.getTime()) {
|
| | | // 把日期添加到集合
|
| | | list.add(sdf.format(startDate));
|
| | | // 设置日期
|
| | |
| | | //把日期增加一天
|
| | | calendar.add(Calendar.DATE, 1);
|
| | | // 获取增加后的日期
|
| | | startDate = calendar.getTime();
|
| | | startDate=calendar.getTime();
|
| | | }
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | |
| | | //根据字典名称查询
|
| | | List<DictDetail> dictDetailList = dictDetailRepository.findByDictName("leave_type");
|
| | | List<String> leaveTypes = new ArrayList<>();
|
| | | for (DictDetail dictDetail : dictDetailList) {
|
| | | if (dictDetail.getValue().equals(Constant.LEAVE_TYPE_ANNUAL_LEAVE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_REPLACE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_COMPASSIONATE_LEAVE)) {
|
| | | for(DictDetail dictDetail : dictDetailList){
|
| | | if(dictDetail.getValue().equals(Constant.LEAVE_TYPE_ANNUAL_LEAVE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_REPLACE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_COMPASSIONATE_LEAVE)){
|
| | | //事假和年假
|
| | | leaveTypes.add(dictDetail.getValue());
|
| | | }
|
| | |
| | | calculate.setEnd(resources.getLeaveEndTime().toLocalDateTime());
|
| | | Double result = new Double(0.00);
|
| | | //判断集合是否包含年假或事假,包含计算以时为单位,反之以天为单位进行计算
|
| | | if (leaveTypes.contains(resources.getLeaveType())) {
|
| | | if(leaveTypes.contains(resources.getLeaveType())){
|
| | | Integer timeSeconds = attendanceService.calculateTimes(calculate, SecurityUtils.getCurrentUserId());
|
| | | result = Double.valueOf(new BigDecimal((float) timeSeconds / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
| | | attendanceLeaveDto.setLeaveDurationUnit(Constant.LEAVE_TIME_TYPE_HOUR);
|
| | | } else {
|
| | | }else{
|
| | | Integer days = attendanceService.calculateDays(calculate);
|
| | | result = Double.valueOf(new BigDecimal(days).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
| | | attendanceLeaveDto.setLeaveDurationUnit(Constant.LEAVE_TIME_TYPE_DAY);
|
| | |
| | | for (SysUserLevelOther sysUserLevelOther : sysUserLevelOtherList) {
|
| | | // 获取今年
|
| | | int year = Calendar.getInstance().get(Calendar.YEAR);
|
| | | if (!sysUserLevelOther.getYearMonth().isEmpty() && sysUserLevelOther.getYearMonth().substring(0, 4).equals(String.valueOf(year))) {
|
| | | if (!sysUserLevelOther.getYearMonth().isEmpty() && sysUserLevelOther.getYearMonth().substring(0,4).equals(String.valueOf(year))) {
|
| | | //年假总时长
|
| | | Double yearTime = Double.valueOf(sysUserLevelOther.getAnnualLeaveDays() == null ? 0 : sysUserLevelOther.getAnnualLeaveDays() * 8);
|
| | |
|
| | | String startTime = year + "-01-01 00:00:00";
|
| | | String endTime = year + "-12-31 23:59:59";
|
| | | Double usedYearTime = attendanceLeaveRepository.getSurplusYearTime(sysUserLevelOther.getUserId(), startTime, endTime);
|
| | |
|
| | | surplusYearTime = yearTime - (usedYearTime == null ? 0.0 : usedYearTime);
|
| | | }
|
| | | }
|
| | | }
|
| | | return surplusYearTime;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取用户年假剩余时长
|
| | | */
|
| | | @Override
|
| | | public Double getYearTimeLength(Long userId, String year) {
|
| | | //获取年假剩余(新)
|
| | | Double surplusYearTime = new Double(0.00);
|
| | | // 根据用户查询
|
| | | List<SysUserLevelOther> sysUserLevelOtherList = sysUserLevelOtherRepository.findByUserId(userId);
|
| | | if (sysUserLevelOtherList.size() > 0) {
|
| | | for (SysUserLevelOther sysUserLevelOther : sysUserLevelOtherList) {
|
| | | if (!sysUserLevelOther.getYearMonth().isEmpty() && sysUserLevelOther.getYearMonth().substring(0,4).equals(String.valueOf(year))) {
|
| | | //年假总时长
|
| | | Double yearTime = Double.valueOf(sysUserLevelOther.getAnnualLeaveDays() == null ? 0 : sysUserLevelOther.getAnnualLeaveDays() * 8);
|
| | |
|
| | |
| | | */
|
| | | @Override
|
| | | public Double getOverTimeLength(Long userId) {
|
| | | //获取调休假剩余时长
|
| | | Double surplusYearTime = new Double(0.00);
|
| | |
|
| | | LocalDate localDateStart = LocalDate.now().withDayOfMonth(1).minusMonths(3);
|
| | | LocalDate localDateEnd = LocalDate.now().plusDays(1);
|
| | |
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay());
|
| | | if (!attendanceOvertimeList.isEmpty()) {
|
| | | surplusYearTime = attendanceOvertimeList.stream()
|
| | | .filter(attendanceOvertime -> !attendanceOvertime.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS))
|
| | | .map(attendanceOvertime -> attendanceOvertime.getOvertimeDuration()).reduce(0.0, (o1, o2) -> o1 + o2);
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime > 0) {
|
| | | surplusYearTime = surplusYearTime - usedTime;
|
| | | }
|
| | | LocalDate localDateStart = LocalDate.of(2024, 1, 1);
|
| | | LocalDate localDateMiddle = LocalDate.now().withDayOfMonth(1).minusMonths(3);
|
| | | Double overTimeLast = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
|
| | | if (overTimeLast == null) {
|
| | | overTimeLast = 0.0;
|
| | | }
|
| | | LocalDate localDateEnd = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| | |
|
| | | Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateMiddle.atStartOfDay(), localDateEnd.atStartOfDay());
|
| | | if (surplusYearTime == null) {
|
| | | surplusYearTime = 0.0;
|
| | | }
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime == null) {
|
| | | usedTime = 0.0;
|
| | | }
|
| | | if (overTimeLast > usedTime) {
|
| | | return surplusYearTime;
|
| | | }
|
| | | surplusYearTime = surplusYearTime + overTimeLast - usedTime;
|
| | |
|
| | | if (surplusYearTime <= 0.0) {
|
| | | return 0.0;
|
| | | }
|
| | | return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Double getOverTimeLength(Long userId, String yearMonth) {
|
| | | LocalDate localDateStart = LocalDate.of(2024, 1, 1);
|
| | | LocalDate localDateMiddle = LocalDate.parse(yearMonth + "-01").minusMonths(3);
|
| | | Double overTimeLast = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
|
| | | if (overTimeLast == null) {
|
| | | overTimeLast = 0.0;
|
| | | }
|
| | | LocalDate localDateEnd = LocalDate.parse(yearMonth + "-01").plusMonths(1).withDayOfMonth(1);
|
| | |
|
| | | Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateMiddle.atStartOfDay(), localDateEnd.atStartOfDay());
|
| | | if (surplusYearTime == null) {
|
| | | surplusYearTime = 0.0;
|
| | | }
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime == null) {
|
| | | usedTime = 0.0;
|
| | | }
|
| | | if (overTimeLast > usedTime) {
|
| | | return surplusYearTime;
|
| | | }
|
| | | surplusYearTime = surplusYearTime + overTimeLast - usedTime;
|
| | |
|
| | | if (surplusYearTime <= 0.0) {
|
| | | return 0.0;
|
| | | }
|
| | |
| | | */
|
| | | @Override
|
| | | public Double getOverTimeCloseLength(Long userId) {
|
| | | //获取年假剩余(新)
|
| | | Double surplusYearTime = new Double(0.00);
|
| | |
|
| | | LocalDate localDateStart = LocalDate.now().withDayOfMonth(1).minusMonths(4);
|
| | | LocalDate localDateEnd = LocalDate.now().plusDays(1);
|
| | |
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, localDateStart.atStartOfDay(), localDateStart.plusMonths(1).withDayOfMonth(1).atStartOfDay());
|
| | | if (!attendanceOvertimeList.isEmpty()) {
|
| | | surplusYearTime = attendanceOvertimeList.stream()
|
| | | .filter(attendanceOvertime -> !attendanceOvertime.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS))
|
| | | .map(attendanceOvertime -> attendanceOvertime.getOvertimeDuration()).reduce(0.0, (o1, o2) -> o1 + o2);
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime > 0) {
|
| | | surplusYearTime = surplusYearTime - usedTime;
|
| | | }
|
| | | LocalDate localDateStart = LocalDate.of(2024, 1, 1);
|
| | | LocalDate localDateMiddle = LocalDate.now().withDayOfMonth(1).minusMonths(3);
|
| | | Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
|
| | | if (surplusYearTime == null) {
|
| | | surplusYearTime = 0.0;
|
| | | }
|
| | | if (surplusYearTime <= 0.0) {
|
| | | LocalDate localDateEnd = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime == null) {
|
| | | usedTime = 0.0;
|
| | | }
|
| | | if (surplusYearTime <= usedTime) {
|
| | | return 0.0;
|
| | | }
|
| | | surplusYearTime = surplusYearTime - usedTime;
|
| | | return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Double getOverTimeCloseLength(Long userId, String yearMonth) {
|
| | | LocalDate localDateStart = LocalDate.of(2024, 1, 1);
|
| | | LocalDate localDateMiddle = LocalDate.parse(yearMonth + "-01").minusMonths(3);
|
| | | Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
|
| | | if (surplusYearTime == null) {
|
| | | surplusYearTime = 0.0;
|
| | | }
|
| | | LocalDate localDateEnd = LocalDate.parse(yearMonth + "-01").plusMonths(1).withDayOfMonth(1);
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime == null) {
|
| | | usedTime = 0.0;
|
| | | }
|
| | | if (surplusYearTime <= usedTime) {
|
| | | return 0.0;
|
| | | }
|
| | | surplusYearTime = surplusYearTime - usedTime;
|
| | | return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
| | | }
|
| | |
|
| | |
| | | @Override
|
| | | public void updateApprove(AttendanceLeave resources) throws Exception {
|
| | | AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(resources.getId()).orElseGet(AttendanceLeave::new);
|
| | | ValidationUtil.isNull(attendanceLeave.getId(), "AttendanceLeave", "id", resources.getId());
|
| | | ValidationUtil.isNull( attendanceLeave.getId(),"AttendanceLeave","id",resources.getId());
|
| | | attendanceLeave.copy(resources);
|
| | | attendanceLeaveRepository.save(attendanceLeave);
|
| | | // 调用定时任务修改考勤记录
|
| | | List<User> userList = new ArrayList<>();
|
| | | if (ObjectUtils.isNotEmpty(attendanceLeave.getUserId())) {
|
| | | if(ObjectUtils.isNotEmpty(attendanceLeave.getUserId())){
|
| | | User user = userRepository.findById(attendanceLeave.getUserId()).orElseGet(User::new);
|
| | | userList.add(user);
|
| | | }
|
| | | if (attendanceLeave.getLeaveStartTime().before(new Date())) {
|
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
| | | String attendanceDate = df.format(attendanceLeave.getLeaveStartTime());
|
| | | weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate, userList);
|
| | | weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate,userList);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | //根据id查询记录
|
| | | Optional<AttendanceLeave> attendanceLeave = attendanceLeaveRepository.findById(id);
|
| | | //审核通过或者退回不能删除
|
| | | if (attendanceLeave.get().getApprovalStatus().equals(Constant.APPROVAL_STATUS_PASSED) || attendanceLeave.get().getApprovalStatus().equals(Constant.APPROVAL_STATUS_RETURNED)) {
|
| | | if(attendanceLeave.get().getApprovalStatus().equals(Constant.APPROVAL_STATUS_PASSED) || attendanceLeave.get().getApprovalStatus().equals(Constant.APPROVAL_STATUS_RETURNED)){
|
| | | throw new BadRequestException("审核通过或退回的不能进行删除");
|
| | | }
|
| | |
|
| | |
| | | //根据id查询记录
|
| | | Optional<AttendanceLeave> attendanceLeave1 = attendanceLeaveRepository.findById(id);
|
| | | //除超管、总经理只能删除自己信息
|
| | | if (role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL) {
|
| | | if (!Long.valueOf(attendanceLeave1.get().getUserId()).equals(SecurityUtils.getCurrentUserId())) {
|
| | | if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){
|
| | | if (!Long.valueOf(attendanceLeave1.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){
|
| | | throw new BadRequestException("只能删除自己的记录");
|
| | | }
|
| | | }
|
| | |
| | | // 循环ID列表
|
| | | for (Long id : request.getIds()) {
|
| | | AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(id).orElseGet(AttendanceLeave::new);
|
| | | ValidationUtil.isNull(attendanceLeave.getId(), "AttendanceLeave", "id", id);
|
| | | ValidationUtil.isNull( attendanceLeave.getId(),"AttendanceLeave","id",id);
|
| | | if (request.getNum().equals(Long.valueOf(1))) {
|
| | | attendanceLeave.setApprovalStatus(Constant.APPROVAL_STATUS_PASSED);
|
| | | } else {
|
| | |
| | | attendanceLeaveRepository.save(attendanceLeave);
|
| | | // 调用定时任务修改考勤记录
|
| | | List<User> userList = new ArrayList<>();
|
| | | if (ObjectUtils.isNotEmpty(attendanceLeave.getUserId())) {
|
| | | if(ObjectUtils.isNotEmpty(attendanceLeave.getUserId())){
|
| | | User user = userRepository.findById(attendanceLeave.getUserId()).orElseGet(User::new);
|
| | | userList.add(user);
|
| | | }
|
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
| | | String attendanceDate = df.format(attendanceLeave.getLeaveStartTime());
|
| | | weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate, userList);
|
| | | weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate,userList);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | for (AttendanceLeaveDto attendanceLeave : all) {
|
| | | String leavrType = attendanceLeave.getLeaveType() != null ? dictDetailRepository.findByDictNameAndValue(Constant.LEAVE_TYPE, attendanceLeave.getLeaveType()).getLabel() : "";
|
| | | String leaveStatus = attendanceLeave.getApprovalStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.APPROVAL_STATUS, attendanceLeave.getApprovalStatus()).getLabel() : "";
|
| | | Map<String, Object> map = new LinkedHashMap<>();
|
| | | Map<String,Object> map = new LinkedHashMap<>();
|
| | | map.put("申请者", attendanceLeave.getUserName());
|
| | | map.put("审批者", attendanceLeave.getAppUserName());
|
| | | map.put("请假类型", leavrType);
|
| | |
| | | import me.zhengjie.modules.attendance.service.mapstruct.AttendanceMapper;
|
| | | import me.zhengjie.modules.constant.Constant;
|
| | | import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
|
| | | import me.zhengjie.modules.system.domain.Role;
|
| | | import me.zhengjie.modules.system.domain.SysConfigHoliday;
|
| | | import me.zhengjie.modules.system.domain.SysRostering;
|
| | | import me.zhengjie.modules.system.domain.User;
|
| | | import me.zhengjie.modules.system.repository.DictDetailRepository;
|
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
|
| | | import me.zhengjie.modules.system.repository.UserRepository;
|
| | | import me.zhengjie.modules.system.domain.*;
|
| | | import me.zhengjie.modules.system.repository.*;
|
| | | import me.zhengjie.modules.system.service.dto.SysConfigHolidayQueryCriteria;
|
| | | import me.zhengjie.utils.*;
|
| | | import org.apache.commons.lang3.ObjectUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.data.domain.Page;
|
| | | import org.springframework.data.domain.Pageable;
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | attendanceDto.setUserName(user.getNickName());
|
| | | return attendanceDto;
|
| | | }
|
| | | };
|
| | | return PageUtil.toPage(page.map(func));
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Map<String,Object> queryAllNotNormal(AttendanceQueryCriteria criteria, Pageable pageable) {
|
| | |
|
| | | if (criteria.getUserId() == null) {
|
| | | List<String> wecomExcludeList = dictDetailRepository.findByDictName("wecom_exclude_list").stream().map(DictDetail::getValue).collect(Collectors.toList());
|
| | | criteria.setUserIds(userRepository.findAllByEnabled(true).stream().filter(user ->!wecomExcludeList.contains(user.getWeComId())).map(User::getId).collect(Collectors.toList()));
|
| | | }
|
| | |
|
| | | criteria.setStartClockResultsList(Arrays.asList(Constant.ATTENDANCE_START_EARLY, Constant.ATTENDANCE_START_LATE, Constant.ATTENDANCE_STATE_WAITFOR, Constant.ATTENDANCE_STATE_NOTSIGNED, Constant.ATTENDANCE_STATE_LACK_OF_TIME));
|
| | | criteria.setEndClockResultsList(Arrays.asList(Constant.ATTENDANCE_START_EARLY, Constant.ATTENDANCE_START_LATE, Constant.ATTENDANCE_STATE_WAITFOR, Constant.ATTENDANCE_STATE_NOTSIGNED, Constant.ATTENDANCE_STATE_LACK_OF_TIME));
|
| | | Page<Attendance> page = attendanceRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
| | | //将实体转换为Dto(重写)
|
| | | Function<Attendance, AttendanceDto> func = attendance -> {
|
| | | // 将实体类转换成DTO
|
| | | AttendanceDto attendanceDto = attendanceMapper.toDto(attendance);
|
| | | //查询用户信息
|
| | | User user = userRepository.findById(attendanceDto.getUserId()).orElseGet(User::new);
|
| | | attendanceDto.setUserName(user.getNickName());
|
| | | return attendanceDto;
|
| | | };
|
| | | return PageUtil.toPage(page.map(func));
|
| | | }
|
| | |
| | | weComService.getWeComAttendanceList(attendance.getAttendanceDate(), userList);
|
| | | // 选择日期和员工更新员工的考勤信息,未选择员工则更新所有人
|
| | | weComService.getWeComAttendanceListOfNoonOrNight(attendanceDate, userList);
|
| | | }
|
| | |
|
| | | @Autowired
|
| | | private SysRosteringRepository sysRosteringRepository;
|
| | |
|
| | | @Override
|
| | | public void generateAttendance(Long id, String startDate, String endDate) {
|
| | | Stream.iterate(LocalDate.parse(startDate), date -> date.plusDays(1))
|
| | | .limit(ChronoUnit.DAYS.between(LocalDate.parse(startDate), LocalDate.parse(endDate)) + 1).forEach(date -> {
|
| | | User user = userRepository.findById(id).get();
|
| | | // 用户排班
|
| | | SysRostering sysRostering = sysRosteringRepository.findByRosId(user.getSysRostering().getId());
|
| | | // 考勤记录
|
| | | Attendance attendance = new Attendance();
|
| | |
|
| | | SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
| | |
|
| | | // 时间格式化
|
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
| | |
|
| | | // 考勤记录
|
| | | attendance.setUserId(user.getId());
|
| | | attendance.setAttendanceDate(Timestamp.valueOf(date.atStartOfDay()));
|
| | | // 考勤日期类是否是周末、节假日、工作日
|
| | | if (sysConfigHoliday == null && (date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY)) {
|
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | // 考勤记录:日期类型-双休
|
| | | attendance.setDateType(Constant.DATE_TYPE_WEEKEND);
|
| | | } else if (sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)) {
|
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | // 考勤记录:日期类型-节假日
|
| | | attendance.setDateType(Constant.DATE_TYPE_LEGAL_HOLIDAYS);
|
| | | } else if (sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS)) {
|
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | // 考勤记录:日期类型-法定节假日
|
| | | attendance.setDateType(Constant.DATE_TYPE_HOLIDAYS);
|
| | | } else {
|
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_NORMAL);
|
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_NORMAL);
|
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NORMAL);
|
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NORMAL);
|
| | |
|
| | | attendance.setActualWorkStartTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getWorkStartTime())));
|
| | | attendance.setActualWorkEndTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getWorkEndTime())));
|
| | |
|
| | | // 考勤记录:日期类型-工作日
|
| | | attendance.setDateType(Constant.DATE_TYPE_WEEKDAY);
|
| | | }
|
| | |
|
| | | // 考勤记
|
| | | attendance.setRosteringWorkStartTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getWorkStartTime())));
|
| | | attendance.setRosteringWorkEndTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getWorkEndTime())));
|
| | | attendance.setRosteringLunchStartTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getLunchStartTime())));
|
| | | attendance.setRosteringLunchEndTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getLunchEndTime())));
|
| | |
|
| | | // 保存
|
| | | attendanceRepository.save(attendance);
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | List<Calculate> breakParts = new ArrayList<>();
|
| | | breakParts.add(new Calculate(rosteringLunchStartTime, rosteringLunchEndTime));
|
| | |
|
| | | // 请假信息
|
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(criteria.getUserId(), startOfDate, endOfDate);
|
| | | breakParts.addAll(
|
| | | attendanceLeaveList.stream().map(attendanceLeave -> {
|
| | | LocalDateTime attendanceLeaveStart = attendanceLeave.getLeaveStartTime().toLocalDateTime();
|
| | | LocalDateTime attendanceLeaveEnd = attendanceLeave.getLeaveEndTime().toLocalDateTime();
|
| | | if (attendanceLeaveStart.isBefore(rosteringWorkStartTime)) {
|
| | | attendanceLeaveStart = rosteringWorkStartTime;
|
| | | }
|
| | | if (attendanceLeaveEnd.isAfter(rosteringWorkEndTime)) {
|
| | | attendanceLeaveEnd = rosteringWorkEndTime;
|
| | | }
|
| | | return new Calculate(attendanceLeaveStart, attendanceLeaveEnd);
|
| | | }
|
| | | ).filter(calculate -> calculate.getStart().isBefore(calculate.getEnd())).collect(Collectors.toList())
|
| | | );
|
| | | // 合并请假时间
|
| | | List<Calculate> finalBreakParts = breakParts.stream().sorted().reduce(new Stack<>(), (result, current) -> {
|
| | | // 删除重复时间,合并相连的时间段
|
| | | if (result.empty()) {
|
| | | result.push(current);
|
| | | return result;
|
| | | }
|
| | | Calculate last = result.peek();
|
| | | if (last.getEnd().isBefore(current.getStart())) {
|
| | | result.push(current);
|
| | | } else if (last.getEnd().isBefore(current.getEnd())) {
|
| | | last.setEnd(current.getEnd());
|
| | | }
|
| | | return result;
|
| | | }, (o1, o2) -> null);
|
| | |
|
| | | // 外出信息
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), startOfDate, endOfDate);
|
| | | attendanceParts.addAll(
|
| | |
| | | return result;
|
| | | }, (o1, o2) -> null).forEach(calculate -> {
|
| | | // 去除休息时间:午休等
|
| | | for (Calculate breakPart : breakParts) {
|
| | | for (Calculate breakPart : finalBreakParts) {
|
| | | if ((calculate.getStart().isBefore(breakPart.getStart()) && calculate.getEnd().isAfter(breakPart.getStart()))
|
| | | || (calculate.getStart().isBefore(breakPart.getEnd()) && calculate.getEnd().isAfter(breakPart.getEnd()))) {
|
| | | Calculate calculate1 = new Calculate(calculate.getStart(), breakPart.getStart());
|
| | |
| | | (total, current) -> total.add(BigDecimal.valueOf(current)),
|
| | | (o1, o2) -> null).divide(BigDecimal.valueOf(3600), 2, RoundingMode.HALF_UP
|
| | | );
|
| | |
|
| | | // 请假信息
|
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(criteria.getUserId(), startOfDate, endOfDate);
|
| | | // 年假不扣工时
|
| | | BigDecimal annualLeaveHours = attendanceLeaveList.stream()
|
| | | .filter(attendanceLeave -> Constant.LEAVE_TYPE_ANNUAL_LEAVE.equals(attendanceLeave.getLeaveType())
|
| | |
| | | // 如果是周六或者周日或节假日,打卡状态为等待的话,就改状态为休息(oapiDingTalkRecordResultList为空的情况下)
|
| | | if (ObjectUtils.isNotEmpty(attendance) && (calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS))) {
|
| | | // 开始打卡结果
|
| | | if(attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){
|
| | | if(attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR) || attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_LACK_OF_TIME)){
|
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setActualWorkStartTime(null);
|
| | | }
|
| | | // 结束打卡结果
|
| | | if(attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){
|
| | | if(attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR) || attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_LACK_OF_TIME)){
|
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setActualWorkEndTime(null);
|
| | |
| | | }
|
| | | // 修改考勤打卡状态
|
| | | if (ObjectUtils.isNotEmpty(attendance)) {
|
| | | attendance = updateRecord(user, attendance, true, attendDate);
|
| | | getMornOrNoon(user,attendance,attendDate,attendance.getRosteringWorkStartTime(),attendance.getRosteringWorkEndTime(), true);
|
| | | // attendance = updateRecord(user, attendance, true, attendDate);
|
| | | attendanceRepository.save(attendance);
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | // 修改考勤打卡状态
|
| | | if (ObjectUtils.isNotEmpty(attendance)) {
|
| | | attendance = updateRecord(user, attendance, false, attendDate);
|
| | | getMornOrNoon(user,attendance,attendDate,attendance.getRosteringWorkStartTime(),attendance.getRosteringWorkEndTime(), false);
|
| | | // attendance = updateRecord(user, attendance, false, attendDate);
|
| | | attendanceRepository.save(attendance);
|
| | | }
|
| | | }
|
| | |
| | | Double outDuration = new Double(0.00);
|
| | | Double outStartDuration = new Double(0.00);// 考勤按钮的时长
|
| | | Double outEndDuration = new Double(0.00);// 考勤按钮的时长
|
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList){
|
| | | // attendDate不等于null 说明是考勤信息按钮
|
| | | if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
|
| | | // 上午时长、下午时长
|
| | | outStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | outEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | //调用方法修改考勤打卡状态
|
| | | updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_GOOUT,day,outStartDuration,outEndDuration);
|
| | | }else{
|
| | | // 上午or下午总时长
|
| | | outDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
|
| | | updateAttendanceRecord(outDuration,attendance,Constant.ATTENDANCE_STATE_GOOUT, day,null,null);
|
| | | outStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(), attendanceGoOut.getOutEndTime(), attendance);
|
| | | outEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(), attendanceGoOut.getOutEndTime(), attendance);
|
| | | }
|
| | | //调用方法修改考勤打卡状态
|
| | | updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_GOOUT,day,outStartDuration,outEndDuration);
|
| | | }else{
|
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
|
| | | // 上午or下午总时长
|
| | | outDuration += getDuration(attendanceGoOut.getOutStartTime(), attendanceGoOut.getOutEndTime(), attendance, day);
|
| | | }
|
| | | updateAttendanceRecord(outDuration,attendance,Constant.ATTENDANCE_STATE_GOOUT, day,null,null);
|
| | | }
|
| | | // for(AttendanceGoOut attendanceGoOut : attendanceGoOutList){
|
| | | // // attendDate不等于null 说明是考勤信息按钮
|
| | | // if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | // // 上午时长、下午时长
|
| | | // outStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | // outEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | // //调用方法修改考勤打卡状态
|
| | | // updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_GOOUT,day,outStartDuration,outEndDuration);
|
| | | // }else{
|
| | | // // 上午or下午总时长
|
| | | // outDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
|
| | | // updateAttendanceRecord(outDuration,attendance,Constant.ATTENDANCE_STATE_GOOUT, day,null,null);
|
| | | // }
|
| | | // }
|
| | | }else{
|
| | | if(ObjectUtils.isNotEmpty(attendanceBusinessTravel)){
|
| | | // attendDate不等于null 说明是考勤信息按钮
|
| | |
| | | }else{
|
| | | // 查询考勤外出表
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(),attendance.getRosteringWorkStartTime().toLocalDateTime(),attendance.getRosteringWorkEndTime().toLocalDateTime());
|
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList){
|
| | | // attendDate不等于null 说明是考勤信息按钮
|
| | | if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | // attendDate不等于null 说明是考勤信息按钮
|
| | | if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
|
| | | // 上午时长、下午时长
|
| | | leaveStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | leaveEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | }else{
|
| | | // 上午or下午总时长
|
| | | leaveDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
|
| | | }
|
| | | }
|
| | | for(AttendanceLeave attendanceLeave : attendanceLeaveList){
|
| | | // attendDate不等于null 说明是考勤信息按钮
|
| | | if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | for(AttendanceLeave attendanceLeave : attendanceLeaveList){
|
| | | // 上午总时长、下午总时长
|
| | | leaveStartDuration += getStartDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance);
|
| | | leaveEndDuration += getEndDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance);
|
| | | //调用方法修改考勤打卡状态
|
| | | updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,leaveStartDuration,leaveEndDuration);
|
| | | }else{
|
| | | }
|
| | | //调用方法修改考勤打卡状态
|
| | | updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,leaveStartDuration,leaveEndDuration);
|
| | | } else {
|
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
|
| | | // 上午or下午总时长
|
| | | leaveDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
|
| | | }
|
| | | for(AttendanceLeave attendanceLeave : attendanceLeaveList){
|
| | | // 上午or下午总时长
|
| | | leaveDuration += getDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance,day);
|
| | | //调用方法修改考勤打卡状态
|
| | | updateAttendanceRecord(leaveDuration,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,null,null);
|
| | | }
|
| | | //调用方法修改考勤打卡状态
|
| | | updateAttendanceRecord(leaveDuration,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,null,null);
|
| | | }
|
| | | // for(AttendanceGoOut attendanceGoOut : attendanceGoOutList){
|
| | | // // attendDate不等于null 说明是考勤信息按钮
|
| | | // if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | // // 上午时长、下午时长
|
| | | // leaveStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | // leaveEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | // }else{
|
| | | // // 上午or下午总时长
|
| | | // leaveDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
|
| | | // }
|
| | | // }
|
| | | // for(AttendanceLeave attendanceLeave : attendanceLeaveList){
|
| | | // // attendDate不等于null 说明是考勤信息按钮
|
| | | // if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | // // 上午总时长、下午总时长
|
| | | // leaveStartDuration += getStartDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance);
|
| | | // leaveEndDuration += getEndDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance);
|
| | | // //调用方法修改考勤打卡状态
|
| | | // updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,leaveStartDuration,leaveEndDuration);
|
| | | // }else{
|
| | | // // 上午or下午总时长
|
| | | // leaveDuration += getDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance,day);
|
| | | // //调用方法修改考勤打卡状态
|
| | | // updateAttendanceRecord(leaveDuration,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,null,null);
|
| | | // }
|
| | | // }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.system.service.impl; |
| | | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.system.domain.SysLevel; |
| | | import me.zhengjie.modules.system.domain.SysUserLevelOther; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.SysLevelRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.modules.treatment.domain.CmnLevel; |
| | | import me.zhengjie.modules.treatment.repository.CmnLevelRepository; |
| | | import me.zhengjie.utils.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.system.repository.SysUserLevelOtherRepository; |
| | | import me.zhengjie.modules.system.service.SysUserLevelOtherService; |
| | | import me.zhengjie.modules.system.service.dto.SysUserLevelOtherDto; |
| | | import me.zhengjie.modules.system.service.dto.SysUserLevelOtherQueryCriteria; |
| | | import me.zhengjie.modules.system.service.mapstruct.SysUserLevelOtherMapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * @author 赵士淞 |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @date 2022-12-26 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class SysUserLevelOtherServiceImpl implements SysUserLevelOtherService { |
| | | |
| | | private final SysUserLevelOtherRepository sysUserLevelOtherRepository; |
| | | private final SysUserLevelOtherMapper sysUserLevelOtherMapper; |
| | | private final UserRepository userRepository; |
| | | private final SysLevelRepository sysLevelRepository; |
| | | private final CmnLevelRepository cmnLevelRepository; |
| | | |
| | | @Override |
| | | public Map<String, Object> queryAll(SysUserLevelOtherQueryCriteria criteria, Pageable pageable) { |
| | | Page<SysUserLevelOther> page = sysUserLevelOtherRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); |
| | | // 将实体类转换为DTO(重写) |
| | | Function<SysUserLevelOther, SysUserLevelOtherDto> func = new Function<SysUserLevelOther, SysUserLevelOtherDto>() { |
| | | @Override |
| | | public SysUserLevelOtherDto apply(SysUserLevelOther t) { |
| | | // 将实体类转换成DTO |
| | | SysUserLevelOtherDto sysUserLevelOtherDto = sysUserLevelOtherMapper.toDto(t); |
| | | // 根据用户ID查询用户信息 |
| | | User user = userRepository.findById(sysUserLevelOtherDto.getUserId()).orElseGet(User::new); |
| | | ValidationUtil.isNull(user.getId(), "User", "id", sysUserLevelOtherDto.getUserId()); |
| | | // 用户昵称 |
| | | sysUserLevelOtherDto.setUserNickName(user.getNickName()); |
| | | // 根据级别ID查询级别信息 |
| | | CmnLevel sysLevel = cmnLevelRepository.findById(sysUserLevelOtherDto.getLevelId()).orElseGet(CmnLevel::new); |
| | | ValidationUtil.isNull(sysLevel.getId(), "SysLevel", "id", sysUserLevelOtherDto.getLevelId()); |
| | | // 级别名称 |
| | | sysUserLevelOtherDto.setLevelName(sysLevel.getName()); |
| | | // 返回处理好的DTO |
| | | return sysUserLevelOtherDto; |
| | | } |
| | | }; |
| | | return PageUtil.toPage(page.map(func)); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysUserLevelOtherDto> queryAll(SysUserLevelOtherQueryCriteria criteria) { |
| | | return sysUserLevelOtherMapper.toDto(sysUserLevelOtherRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | public SysUserLevelOtherDto queryTargetYearMonth(SysUserLevelOtherQueryCriteria criteria) { |
| | | |
| | | // 明年月初 |
| | | // 查询级别其他,year_month大于等于选中的日期小于明年月初的日期 |
| | | SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findByUserIdAndData(criteria.getUserId(), criteria.getTargetYearMonth().substring(0,7) ); |
| | | if (sysUserLevelOther == null) { |
| | | throw new BadRequestException("没有获取到当前员工的级别信息!"); |
| | | } |
| | | |
| | | return sysUserLevelOtherMapper.toDto(sysUserLevelOther); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public SysUserLevelOtherDto findById(Long id) { |
| | | SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findById(id).orElseGet(SysUserLevelOther::new); |
| | | ValidationUtil.isNull(sysUserLevelOther.getId(), "SysUserLevelOther", "id", id); |
| | | return sysUserLevelOtherMapper.toDto(sysUserLevelOther); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public SysUserLevelOtherDto create(SysUserLevelOther resources) throws Exception { |
| | | // // 查询旧用户级别其他 |
| | | // SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId()); |
| | | // // 判断旧用户级别其他是否为空 |
| | | // if (oldSysUserLevelOther != null) { |
| | | // // 旧日期字符串 |
| | | // String oldDateString = oldSysUserLevelOther.getStartDate().toString().substring(0,10); |
| | | // // 新日期字符串 |
| | | // String newDateString = resources.getStartDate().toString().substring(0,10); |
| | | // // 判断新、旧日期字符串 |
| | | // if (oldDateString.equals(newDateString)) { |
| | | // throw new BadRequestException("每天只能调整一次用户级别其他,请更换日期再试!"); |
| | | // } |
| | | // if (new SimpleDateFormat("yyyy-MM-dd").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM-dd").parse(newDateString).getTime()) { |
| | | // throw new BadRequestException("日期必须大于最新用户级别其他日期,请更换日期再试!"); |
| | | // } |
| | | // // 创建Calendar实例 |
| | | // Calendar previousCalendar = Calendar.getInstance(); |
| | | // // 设置新日期时间 |
| | | // previousCalendar.setTime(resources.getStartDate()); |
| | | // // 设置前一天时间 |
| | | // previousCalendar.add(Calendar.DATE, -1); |
| | | // // 旧用户级别其他 |
| | | // oldSysUserLevelOther.setEndDate(new Timestamp(previousCalendar.getTime().getTime())); |
| | | // // 保存 |
| | | // sysUserLevelOtherRepository.save(oldSysUserLevelOther); |
| | | // } |
| | | |
| | | // // 查询旧用户级别其他(新) |
| | | // SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId()); |
| | | // // 判断旧用户级别其他是否为空 |
| | | // if (oldSysUserLevelOther != null) { |
| | | // // 旧日期字符串 |
| | | // String oldDateString = oldSysUserLevelOther.getYearMonth(); |
| | | // // 新日期字符串 |
| | | // String newDateString = resources.getYearMonth(); |
| | | // if (new SimpleDateFormat("yyyy-MM").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM").parse(newDateString).getTime()) { |
| | | // throw new BadRequestException("日期必须大于最新用户级别其他日期,请更换日期再试!"); |
| | | // } |
| | | // } |
| | | // 保存 |
| | | return sysUserLevelOtherMapper.toDto(sysUserLevelOtherRepository.save(resources)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(SysUserLevelOther resources) throws Exception { |
| | | // // 查询旧用户级别其他 |
| | | // SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId()); |
| | | // // 判断旧用户级别其他是否为空 |
| | | // if (oldSysUserLevelOther != null) { |
| | | // // 判断修改的是否是最新履历 |
| | | // if (oldSysUserLevelOther.getId() != resources.getId()) { |
| | | // throw new BadRequestException("旧用户级别其他无法进行修改,请选择最新用户级别其他再试!"); |
| | | // } |
| | | // // 旧日期字符串 |
| | | // String oldDateString = oldSysUserLevelOther.getStartDate().toString().substring(0,10); |
| | | // // 获取当前日期 |
| | | // Date nowDate = new Date(); |
| | | // // 创建Calendar实例 |
| | | // Calendar nowCalendar = Calendar.getInstance(); |
| | | // // 设置当前时间 |
| | | // nowCalendar.setTime(nowDate); |
| | | // // 新日期字符串 |
| | | // String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0,10); |
| | | // // 判断新、旧日期字符串 |
| | | // if (new SimpleDateFormat("yyyy-MM-dd").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM-dd").parse(nowDateString).getTime()) { |
| | | // // 复制 |
| | | // oldSysUserLevelOther.copy(resources); |
| | | // // 保存 |
| | | // sysUserLevelOtherRepository.save(oldSysUserLevelOther); |
| | | // } else { |
| | | // // 新用户级别其他 |
| | | // resources.setId(null); |
| | | // resources.setStartDate(new Timestamp(nowCalendar.getTime().getTime())); |
| | | // // 保存 |
| | | // sysUserLevelOtherRepository.save(resources); |
| | | // // 设置前一天时间 |
| | | // nowCalendar.add(Calendar.DATE, -1); |
| | | // // 旧用户级别其他 |
| | | // oldSysUserLevelOther.setEndDate(new Timestamp(nowCalendar.getTime().getTime())); |
| | | // // 保存 |
| | | // sysUserLevelOtherRepository.save(oldSysUserLevelOther); |
| | | // } |
| | | // } else { |
| | | // throw new BadRequestException("未找到最新用户级别其他,请稍后再试!"); |
| | | // } |
| | | |
| | | // 查询旧用户级别其他(新) |
| | | SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId()); |
| | | // 判断旧用户级别其他是否为空 |
| | | if (oldSysUserLevelOther != null) { |
| | | // 判断修改的是否是最新履历 |
| | | if (oldSysUserLevelOther.getId() != resources.getId()) { |
| | | throw new BadRequestException("旧用户级别其他无法进行修改,请选择最新用户级别其他再试!"); |
| | | } |
| | | // 旧日期字符串 |
| | | String oldDateString = oldSysUserLevelOther.getYearMonth(); |
| | | // 获取当前日期 |
| | | Date nowDate = new Date(); |
| | | // 创建Calendar实例 |
| | | Calendar nowCalendar = Calendar.getInstance(); |
| | | // 设置当前时间 |
| | | nowCalendar.setTime(nowDate); |
| | | // 新日期字符串 |
| | | String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0, 7); |
| | | // 判断新、旧日期字符串 |
| | | // if (new SimpleDateFormat("yyyy-MM").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM").parse(nowDateString).getTime()) { |
| | | // 复制 |
| | | oldSysUserLevelOther.copy(resources); |
| | | // 保存 |
| | | sysUserLevelOtherRepository.save(oldSysUserLevelOther); |
| | | // } |
| | | } else { |
| | | throw new BadRequestException("未找到最新用户级别其他,请稍后再试!"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | sysUserLevelOtherRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<SysUserLevelOtherDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (SysUserLevelOtherDto sysUserLevelOther : all) { |
| | | String nickName = sysUserLevelOther.getUserId() != null ? userRepository.findById(sysUserLevelOther.getUserId()).orElseGet(User::new).getNickName() : ""; |
| | | String levelName = sysUserLevelOther.getLevelId() != null ? sysLevelRepository.findById(sysUserLevelOther.getLevelId()).orElseGet(SysLevel::new).getName() : ""; |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("用户昵称", nickName); |
| | | map.put("级别名称", levelName); |
| | | map.put("开始日期", sysUserLevelOther.getStartDate()); |
| | | map.put("结束日期", sysUserLevelOther.getEndDate()); |
| | | map.put("个人业绩比例", sysUserLevelOther.getPersonalPerformanceProportion()); |
| | | map.put("年假天数", sysUserLevelOther.getAnnualLeaveDays()); |
| | | map.put("备注", sysUserLevelOther.getRemarks()); |
| | | map.put("创建者", sysUserLevelOther.getCreateBy()); |
| | | map.put("创建时间", sysUserLevelOther.getCreateTime()); |
| | | map.put("更新者", sysUserLevelOther.getUpdateBy()); |
| | | map.put("更新时间", sysUserLevelOther.getUpdateTime()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | |
| | | /** |
| | | * 查询旧用户级别其他 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | private SysUserLevelOther selectOldUserLevelOther(Long userId) { |
| | | // // 旧用户级别其他 |
| | | // SysUserLevelOther oldSysUserLevelOther = sysUserLevelOtherRepository.findLastByUserId(userId); |
| | | |
| | | // 旧用户级别其他(新) |
| | | SysUserLevelOther oldSysUserLevelOther = sysUserLevelOtherRepository.findByNewUserId(userId); |
| | | |
| | | // 判断旧用户级别其他是否为空 |
| | | if (oldSysUserLevelOther != null && oldSysUserLevelOther.getId() != null) { |
| | | return oldSysUserLevelOther; |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | /*
|
| | | * Copyright 2019-2020 Zheng Jie
|
| | | *
|
| | | * Licensed under the Apache License, Version 2.0 (the "License");
|
| | | * you may not use this file except in compliance with the License.
|
| | | * You may obtain a copy of the License at
|
| | | *
|
| | | * http://www.apache.org/licenses/LICENSE-2.0
|
| | | *
|
| | | * Unless required by applicable law or agreed to in writing, software
|
| | | * distributed under the License is distributed on an "AS IS" BASIS,
|
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| | | * See the License for the specific language governing permissions and
|
| | | * limitations under the License.
|
| | | */
|
| | | package me.zhengjie.modules.system.service.impl;
|
| | |
|
| | | import me.zhengjie.exception.BadRequestException;
|
| | | import me.zhengjie.modules.system.domain.SysLevel;
|
| | | import me.zhengjie.modules.system.domain.SysUserLevelOther;
|
| | | import me.zhengjie.modules.system.domain.User;
|
| | | import me.zhengjie.modules.system.repository.SysLevelRepository;
|
| | | import me.zhengjie.modules.system.repository.UserRepository;
|
| | | import me.zhengjie.modules.treatment.domain.CmnLevel;
|
| | | import me.zhengjie.modules.treatment.repository.CmnLevelRepository;
|
| | | import me.zhengjie.utils.*;
|
| | | import lombok.RequiredArgsConstructor;
|
| | | import me.zhengjie.modules.system.repository.SysUserLevelOtherRepository;
|
| | | import me.zhengjie.modules.system.service.SysUserLevelOtherService;
|
| | | import me.zhengjie.modules.system.service.dto.SysUserLevelOtherDto;
|
| | | import me.zhengjie.modules.system.service.dto.SysUserLevelOtherQueryCriteria;
|
| | | import me.zhengjie.modules.system.service.mapstruct.SysUserLevelOtherMapper;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.data.domain.Page;
|
| | | import org.springframework.data.domain.Pageable;
|
| | |
|
| | | import java.sql.Timestamp;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.*;
|
| | | import java.io.IOException;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | | import java.util.function.Function;
|
| | |
|
| | | /**
|
| | | * @author 赵士淞
|
| | | * @website https://eladmin.vip
|
| | | * @description 服务实现
|
| | | * @date 2022-12-26
|
| | | **/
|
| | | @Service
|
| | | @RequiredArgsConstructor
|
| | | public class SysUserLevelOtherServiceImpl implements SysUserLevelOtherService {
|
| | |
|
| | | private final SysUserLevelOtherRepository sysUserLevelOtherRepository;
|
| | | private final SysUserLevelOtherMapper sysUserLevelOtherMapper;
|
| | | private final UserRepository userRepository;
|
| | | private final SysLevelRepository sysLevelRepository;
|
| | | private final CmnLevelRepository cmnLevelRepository;
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> queryAll(SysUserLevelOtherQueryCriteria criteria, Pageable pageable) {
|
| | | Page<SysUserLevelOther> page = sysUserLevelOtherRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
| | | // 将实体类转换为DTO(重写)
|
| | | Function<SysUserLevelOther, SysUserLevelOtherDto> func = new Function<SysUserLevelOther, SysUserLevelOtherDto>() {
|
| | | @Override
|
| | | public SysUserLevelOtherDto apply(SysUserLevelOther t) {
|
| | | // 将实体类转换成DTO
|
| | | SysUserLevelOtherDto sysUserLevelOtherDto = sysUserLevelOtherMapper.toDto(t);
|
| | | // 根据用户ID查询用户信息
|
| | | User user = userRepository.findById(sysUserLevelOtherDto.getUserId()).orElseGet(User::new);
|
| | | ValidationUtil.isNull(user.getId(), "User", "id", sysUserLevelOtherDto.getUserId());
|
| | | // 用户昵称
|
| | | sysUserLevelOtherDto.setUserNickName(user.getNickName());
|
| | | // 根据级别ID查询级别信息
|
| | | CmnLevel sysLevel = cmnLevelRepository.findById(sysUserLevelOtherDto.getLevelId()).orElseGet(CmnLevel::new);
|
| | | ValidationUtil.isNull(sysLevel.getId(), "SysLevel", "id", sysUserLevelOtherDto.getLevelId());
|
| | | // 级别名称
|
| | | sysUserLevelOtherDto.setLevelName(sysLevel.getName());
|
| | | // 返回处理好的DTO
|
| | | return sysUserLevelOtherDto;
|
| | | }
|
| | | };
|
| | | return PageUtil.toPage(page.map(func));
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<SysUserLevelOtherDto> queryAll(SysUserLevelOtherQueryCriteria criteria) {
|
| | | return sysUserLevelOtherMapper.toDto(sysUserLevelOtherRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
|
| | | }
|
| | |
|
| | | @Override
|
| | | public SysUserLevelOtherDto queryTargetYearMonth(SysUserLevelOtherQueryCriteria criteria) {
|
| | |
|
| | | // 明年月初
|
| | | // 查询级别其他,year_month大于等于选中的日期小于明年月初的日期
|
| | | SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findByUserIdAndData(criteria.getUserId(), criteria.getTargetYearMonth().substring(0,7) );
|
| | | if (sysUserLevelOther == null) {
|
| | | throw new BadRequestException("没有获取到当前员工的级别信息!");
|
| | | }
|
| | |
|
| | | return sysUserLevelOtherMapper.toDto(sysUserLevelOther);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public SysUserLevelOtherDto findById(Long id) {
|
| | | SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findById(id).orElseGet(SysUserLevelOther::new);
|
| | | ValidationUtil.isNull(sysUserLevelOther.getId(), "SysUserLevelOther", "id", id);
|
| | | return sysUserLevelOtherMapper.toDto(sysUserLevelOther);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public SysUserLevelOtherDto create(SysUserLevelOther resources) throws Exception {
|
| | | // // 查询旧用户级别其他
|
| | | // SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId());
|
| | | // // 判断旧用户级别其他是否为空
|
| | | // if (oldSysUserLevelOther != null) {
|
| | | // // 旧日期字符串
|
| | | // String oldDateString = oldSysUserLevelOther.getStartDate().toString().substring(0,10);
|
| | | // // 新日期字符串
|
| | | // String newDateString = resources.getStartDate().toString().substring(0,10);
|
| | | // // 判断新、旧日期字符串
|
| | | // if (oldDateString.equals(newDateString)) {
|
| | | // throw new BadRequestException("每天只能调整一次用户级别其他,请更换日期再试!");
|
| | | // }
|
| | | // if (new SimpleDateFormat("yyyy-MM-dd").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM-dd").parse(newDateString).getTime()) {
|
| | | // throw new BadRequestException("日期必须大于最新用户级别其他日期,请更换日期再试!");
|
| | | // }
|
| | | // // 创建Calendar实例
|
| | | // Calendar previousCalendar = Calendar.getInstance();
|
| | | // // 设置新日期时间
|
| | | // previousCalendar.setTime(resources.getStartDate());
|
| | | // // 设置前一天时间
|
| | | // previousCalendar.add(Calendar.DATE, -1);
|
| | | // // 旧用户级别其他
|
| | | // oldSysUserLevelOther.setEndDate(new Timestamp(previousCalendar.getTime().getTime()));
|
| | | // // 保存
|
| | | // sysUserLevelOtherRepository.save(oldSysUserLevelOther);
|
| | | // }
|
| | |
|
| | | // // 查询旧用户级别其他(新)
|
| | | // SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId());
|
| | | // // 判断旧用户级别其他是否为空
|
| | | // if (oldSysUserLevelOther != null) {
|
| | | // // 旧日期字符串
|
| | | // String oldDateString = oldSysUserLevelOther.getYearMonth();
|
| | | // // 新日期字符串
|
| | | // String newDateString = resources.getYearMonth();
|
| | | // if (new SimpleDateFormat("yyyy-MM").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM").parse(newDateString).getTime()) {
|
| | | // throw new BadRequestException("日期必须大于最新用户级别其他日期,请更换日期再试!");
|
| | | // }
|
| | | // }
|
| | | // 保存
|
| | | resources.setStartDate(new Timestamp(new SimpleDateFormat("yyyy-MM-dd").parse(resources.getYearMonth() + "-01").getTime()));
|
| | | return sysUserLevelOtherMapper.toDto(sysUserLevelOtherRepository.save(resources));
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void update(SysUserLevelOther resources) throws Exception {
|
| | | // // 查询旧用户级别其他
|
| | | // SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId());
|
| | | // // 判断旧用户级别其他是否为空
|
| | | // if (oldSysUserLevelOther != null) {
|
| | | // // 判断修改的是否是最新履历
|
| | | // if (oldSysUserLevelOther.getId() != resources.getId()) {
|
| | | // throw new BadRequestException("旧用户级别其他无法进行修改,请选择最新用户级别其他再试!");
|
| | | // }
|
| | | // // 旧日期字符串
|
| | | // String oldDateString = oldSysUserLevelOther.getStartDate().toString().substring(0,10);
|
| | | // // 获取当前日期
|
| | | // Date nowDate = new Date();
|
| | | // // 创建Calendar实例
|
| | | // Calendar nowCalendar = Calendar.getInstance();
|
| | | // // 设置当前时间
|
| | | // nowCalendar.setTime(nowDate);
|
| | | // // 新日期字符串
|
| | | // String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0,10);
|
| | | // // 判断新、旧日期字符串
|
| | | // if (new SimpleDateFormat("yyyy-MM-dd").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM-dd").parse(nowDateString).getTime()) {
|
| | | // // 复制
|
| | | // oldSysUserLevelOther.copy(resources);
|
| | | // // 保存
|
| | | // sysUserLevelOtherRepository.save(oldSysUserLevelOther);
|
| | | // } else {
|
| | | // // 新用户级别其他
|
| | | // resources.setId(null);
|
| | | // resources.setStartDate(new Timestamp(nowCalendar.getTime().getTime()));
|
| | | // // 保存
|
| | | // sysUserLevelOtherRepository.save(resources);
|
| | | // // 设置前一天时间
|
| | | // nowCalendar.add(Calendar.DATE, -1);
|
| | | // // 旧用户级别其他
|
| | | // oldSysUserLevelOther.setEndDate(new Timestamp(nowCalendar.getTime().getTime()));
|
| | | // // 保存
|
| | | // sysUserLevelOtherRepository.save(oldSysUserLevelOther);
|
| | | // }
|
| | | // } else {
|
| | | // throw new BadRequestException("未找到最新用户级别其他,请稍后再试!");
|
| | | // }
|
| | |
|
| | | // 查询旧用户级别其他(新)
|
| | | SysUserLevelOther oldSysUserLevelOther = selectOldUserLevelOther(resources.getUserId());
|
| | | // 判断旧用户级别其他是否为空
|
| | | if (oldSysUserLevelOther != null) {
|
| | | // 判断修改的是否是最新履历
|
| | | if (oldSysUserLevelOther.getId() != resources.getId()) {
|
| | | throw new BadRequestException("旧用户级别其他无法进行修改,请选择最新用户级别其他再试!");
|
| | | }
|
| | | // 旧日期字符串
|
| | | String oldDateString = oldSysUserLevelOther.getYearMonth();
|
| | | // 获取当前日期
|
| | | Date nowDate = new Date();
|
| | | // 创建Calendar实例
|
| | | Calendar nowCalendar = Calendar.getInstance();
|
| | | // 设置当前时间
|
| | | nowCalendar.setTime(nowDate);
|
| | | // 新日期字符串
|
| | | String nowDateString = new Timestamp(nowCalendar.getTime().getTime()).toString().substring(0, 7);
|
| | | // 判断新、旧日期字符串
|
| | | // if (new SimpleDateFormat("yyyy-MM").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM").parse(nowDateString).getTime()) {
|
| | | // 复制
|
| | | oldSysUserLevelOther.copy(resources);
|
| | | // 保存
|
| | | sysUserLevelOtherRepository.save(oldSysUserLevelOther);
|
| | | // }
|
| | | } else {
|
| | | throw new BadRequestException("未找到最新用户级别其他,请稍后再试!");
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteAll(Long[] ids) {
|
| | | for (Long id : ids) {
|
| | | sysUserLevelOtherRepository.deleteById(id);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void download(List<SysUserLevelOtherDto> all, HttpServletResponse response) throws IOException {
|
| | | List<Map<String, Object>> list = new ArrayList<>();
|
| | | for (SysUserLevelOtherDto sysUserLevelOther : all) {
|
| | | String nickName = sysUserLevelOther.getUserId() != null ? userRepository.findById(sysUserLevelOther.getUserId()).orElseGet(User::new).getNickName() : "";
|
| | | String levelName = sysUserLevelOther.getLevelId() != null ? sysLevelRepository.findById(sysUserLevelOther.getLevelId()).orElseGet(SysLevel::new).getName() : "";
|
| | | Map<String, Object> map = new LinkedHashMap<>();
|
| | | map.put("用户昵称", nickName);
|
| | | map.put("级别名称", levelName);
|
| | | map.put("开始日期", sysUserLevelOther.getStartDate());
|
| | | map.put("结束日期", sysUserLevelOther.getEndDate());
|
| | | map.put("个人业绩比例", sysUserLevelOther.getPersonalPerformanceProportion());
|
| | | map.put("年假天数", sysUserLevelOther.getAnnualLeaveDays());
|
| | | map.put("备注", sysUserLevelOther.getRemarks());
|
| | | map.put("创建者", sysUserLevelOther.getCreateBy());
|
| | | map.put("创建时间", sysUserLevelOther.getCreateTime());
|
| | | map.put("更新者", sysUserLevelOther.getUpdateBy());
|
| | | map.put("更新时间", sysUserLevelOther.getUpdateTime());
|
| | | list.add(map);
|
| | | }
|
| | | FileUtil.downloadExcel(list, response);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 查询旧用户级别其他
|
| | | *
|
| | | * @param userId
|
| | | * @return
|
| | | */
|
| | | private SysUserLevelOther selectOldUserLevelOther(Long userId) {
|
| | | // // 旧用户级别其他
|
| | | // SysUserLevelOther oldSysUserLevelOther = sysUserLevelOtherRepository.findLastByUserId(userId);
|
| | |
|
| | | // 旧用户级别其他(新)
|
| | | SysUserLevelOther oldSysUserLevelOther = sysUserLevelOtherRepository.findByNewUserId(userId);
|
| | |
|
| | | // 判断旧用户级别其他是否为空
|
| | | if (oldSysUserLevelOther != null && oldSysUserLevelOther.getId() != null) {
|
| | | return oldSysUserLevelOther;
|
| | | } else {
|
| | | return null;
|
| | | }
|
| | | }
|
| | | } |
| | |
| | | }
|
| | | returnData.put("onDutyDays", numDay);
|
| | | // 剩余年假
|
| | | Double yearTimes = attendanceLeaveService.getYearTimeLength(userId);
|
| | | Double yearTimes = attendanceLeaveService.getYearTimeLength(userId, sdfDate.substring(0, 4));
|
| | | returnData.put("annualLeave", yearTimes);
|
| | | // 查询当月的补卡记录的条数
|
| | | Integer count = attendanceCardreplacementRepository.count(userId, sdfDate.substring(0, 7));
|
| | |
| | | package me.zhengjie.modules.task.service.impl;
|
| | |
|
| | | import lombok.RequiredArgsConstructor;
|
| | | import me.zhengjie.exception.BadRequestException;
|
| | | import me.zhengjie.modules.constant.Constant;
|
| | | import me.zhengjie.modules.project.domain.Project;
|
| | | import me.zhengjie.modules.project.repository.ProjectRepository;
|
| | |
| | | @CacheEvict(cacheNames = "ChildrenTask", allEntries = true)
|
| | | public TaskMongo create(Long userId, TaskMongo resources) {
|
| | | resources.setTaskStatus(Constant.TASK_STATUS_NOT_STARTED);
|
| | | boolean existed = mongoTemplate.exists(Query.query(Criteria.where("name").is(resources.getName()).and("projectId").is(resources.getProjectId())), TaskMongo.class);
|
| | | if (existed) {
|
| | | throw new BadRequestException("任务名称重复");
|
| | | }
|
| | | synchronized (lock) {
|
| | | // 查询最大的old_id值
|
| | | Query query = new Query();
|
| | |
| | | //
|
| | | // containUserList.addAll(userIdList.stream().filter(o -> !containUserList.contains(o)).collect(Collectors.toList()));
|
| | |
|
| | |
|
| | | boolean existed = mongoTemplate.exists(Query.query(Criteria.where("name").is(resources.getName()).and("projectId").is(resources.getProjectId()).and("id").ne(resources.getId())), TaskMongo.class);
|
| | | if (existed) {
|
| | | throw new BadRequestException("任务名称重复");
|
| | | }
|
| | | return mongoTemplate.save(resources);
|
| | |
|
| | | }
|
| | |
| | | Map<String, Double> attendanceBusinessTravelMap = attendanceBusinessTravelList.stream().collect(Collectors.groupingBy(AttendanceBusinessTravel::getCategory, Collectors.summingDouble(AttendanceBusinessTravel::getTravelDuration)));
|
| | |
|
| | | BigDecimal travelSubsidy = new BigDecimal(0.0);
|
| | | // 出差补助金
|
| | | attendanceBusinessTravelMap.forEach((key, value) -> {
|
| | | if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL)) {
|
| | | for (Map.Entry<String, Double> entry : attendanceBusinessTravelMap.entrySet()) {
|
| | | if (entry.getKey().equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL)) {
|
| | | // 出差补助金
|
| | | SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("出差补助金额");
|
| | | travelSubsidy.add(BigDecimal.valueOf(value * sysConfigProportion.getProportion()));
|
| | | } else if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE)) {
|
| | | travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(entry.getValue() * sysConfigProportion.getProportion()));
|
| | | } else if (entry.getKey().equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE)) {
|
| | | // 客户现场补助金
|
| | | // SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("客户现场补助金额");
|
| | | travelSubsidy.add(BigDecimal.valueOf(value * 30)); // 按30元/天计算 TODO 待调整
|
| | | travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(entry.getValue() * 30)); // 按30元/天计算 TODO 待调整
|
| | | }
|
| | | });
|
| | | }
|
| | | // // 出差补助金
|
| | | // attendanceBusinessTravelMap.forEach((key, value) -> {
|
| | | // if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL)) {
|
| | | // // 出差补助金
|
| | | // SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("出差补助金额");
|
| | | // travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(value * sysConfigProportion.getProportion()));
|
| | | // } else if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE)) {
|
| | | // // 客户现场补助金
|
| | | //// SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("客户现场补助金额");
|
| | | // travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(value * 30)); // 按30元/天计算 TODO 待调整
|
| | | // }
|
| | | // });
|
| | | return travelSubsidy.doubleValue();
|
| | | }
|
| | |
|
| | |
| | | }) |
| | | } |
| | | |
| | | export function getYearTimeLength(data) { |
| | | export function getYearTimeLength(userId, data) { |
| | | return request({ |
| | | url: 'api/attendanceLeave/getYearTimeLength', |
| | | url: 'api/attendanceLeave/getYearTimeLength/' + userId, |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function getOverTimeLength(data) { |
| | | export function getOverTimeLength(userId, data) { |
| | | return request({ |
| | | url: 'api/attendanceLeave/getOverTimeLength', |
| | | url: 'api/attendanceLeave/getOverTimeLength/' + userId, |
| | | method: 'post', |
| | | data |
| | | }) |
| | |
| | | crudUser.getAll().then(res => { |
| | | this.users = res |
| | | }) |
| | | // 资产 |
| | | // 资产 response.data |
| | | crudAssetManagement.getAll().then(res => { |
| | | this.assetManagements = res |
| | | }) |
| | |
| | | " |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="关联项目" prop="projectId"> |
| | | <el-select |
| | | v-model="form.projectId" |
| | | filterable |
| | | clearable |
| | | placeholder="请选择" |
| | | style="width: 340px;" |
| | | :disabled=" |
| | | form.approvalStatus == dictGoOutAgree || |
| | | form.approvalStatus == dictGoOutReturn |
| | | " |
| | | > |
| | | <el-option |
| | | v-for="item in projects" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="出差分类" prop="category"> |
| | | <el-select |
| | | v-model="form.category" |
| | |
| | | show-overflow-tooltip |
| | | /> |
| | | <el-table-column |
| | | prop="category" |
| | | label="出差分类" |
| | | width="80" |
| | | show-overflow-tooltip |
| | | > |
| | | <template slot-scope="scope"> |
| | | {{ dict.label[dictBusinessTravelCategory][scope.row.category] }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="approvalStatus" |
| | | label="审批状态" |
| | | width="80" |
| | |
| | | <script> |
| | | import crudAttendanceBusinessTravel from '@/api/attendance/attendanceBusinessTravel' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import crudProject from '@/api/project/project' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudUser from '@/api/system/user' |
| | | import { mapGetters } from 'vuex' |
| | |
| | | departureCity: null, |
| | | arrivalCity: null, |
| | | category: null, |
| | | projectId: null, |
| | | approvalStatus: null, |
| | | approvalDescription: null, |
| | | remarks: null, |
| | |
| | | ], |
| | | approvalStatus: [ |
| | | { required: true, message: '审批状态不能为空', trigger: 'change' } |
| | | ], |
| | | projectId: [ |
| | | { required: true, message: '请选择项目', trigger: 'change' } |
| | | ] |
| | | }, |
| | | users: [], |
| | | approvalUsers: [], |
| | | // 项目列表 |
| | | projects: [], |
| | | dictBussinessStatus: constant.BUSSINESS_APPROVE_STATUS, |
| | | dictGoOutAppRev: constant.BUSSINESS_APPROVE_STATUS_REVIEWED, |
| | | dictGoOutAgree: constant.BUSSINESS_APPROVE_STATUS_AGREE, |
| | |
| | | const userRolesLevel = this.user.roles.map(({ level }) => level) |
| | | // 用户最大角色级别 |
| | | this.userRolesLevelMin = Math.min(...userRolesLevel) |
| | | // 获取项目列表 |
| | | this.getProjects() |
| | | return true |
| | | }, |
| | | // 钩子:新建 - 之前 |
| | |
| | | return true |
| | | } |
| | | }, |
| | | // 获取项目列表 |
| | | getProjects() { |
| | | // 获取项目列表 |
| | | crudProject.getRelevant({ |
| | | 'projectStatusIn': ['project_status_not_started', 'project_status_under_way'], |
| | | 'approve_status': 'approve_status_acknowledged' |
| | | }).then(res => { |
| | | // 项目列表 |
| | | this.projects = res |
| | | }) |
| | | }, |
| | | // 查询员工 |
| | | getUsers() { |
| | | crudUser.getAll().then(res => { |
| | |
| | | return |
| | | } |
| | | // 获取年假剩余时长 |
| | | crudAttendanceLeave.getYearTimeLength((this.form.userId == null ? 1 : this.form.userId)).then(res => { |
| | | crudAttendanceLeave.getYearTimeLength((this.form.userId == null ? 1 : this.form.userId), this.form.leaveStartTime.substring(0, 4)).then(res => { |
| | | this.yearTimeLenght = res |
| | | }) |
| | | // 获取调休假剩余时长 |
| | | crudAttendanceLeave.getOverTimeLength((this.form.userId == null ? 1 : this.form.userId)).then(res => { |
| | | crudAttendanceLeave.getOverTimeLength((this.form.userId == null ? 1 : this.form.userId), this.form.leaveStartTime.substring(0, 7)).then(res => { |
| | | this.OverTimeLenght = res |
| | | }) |
| | | // 通过后台计算时长 |
| New file |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-row :gutter="40" class="panel-group"> |
| | | <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col"> |
| | | <div class="card-panel"> |
| | | <div class="card-panel-icon-wrapper icon-people"> |
| | | <svg-icon icon-class="visits" class-name="card-panel-icon" /> |
| | | </div> |
| | | <div class="card-panel-description"> |
| | | <div class="card-panel-text"> |
| | | 补卡未承认 |
| | | </div> |
| | | <count-to |
| | | :start-val="0" |
| | | :end-val="100" |
| | | :duration="1" |
| | | class="card-panel-num" |
| | | /> |
| | | </div> |
| | | </div> |
| | | </el-col> |
| | | <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col"> |
| | | <div class="card-panel"> |
| | | <div class="card-panel-icon-wrapper icon-permission"> |
| | | <svg-icon icon-class="people" class-name="card-panel-icon" /> |
| | | </div> |
| | | <div class="card-panel-description"> |
| | | <div class="card-panel-text"> |
| | | 请假未承认 |
| | | </div> |
| | | <count-to |
| | | :start-val="0" |
| | | :end-val="100" |
| | | :duration="3000" |
| | | :decimals="2" |
| | | class="card-panel-num" |
| | | /> |
| | | </div> |
| | | </div> |
| | | </el-col> |
| | | <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col"> |
| | | <div class="card-panel"> |
| | | <div class="card-panel-icon-wrapper icon-message"> |
| | | <svg-icon icon-class="message" class-name="card-panel-icon" /> |
| | | </div> |
| | | <div class="card-panel-description"> |
| | | <div class="card-panel-text"> |
| | | 外出未承认 |
| | | </div> |
| | | <count-to |
| | | :start-val="0" |
| | | :end-val="100" |
| | | :duration="3600" |
| | | class="card-panel-num" |
| | | /> |
| | | </div> |
| | | </div> |
| | | </el-col> |
| | | <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col"> |
| | | <div class="card-panel"> |
| | | <div class="card-panel-icon-wrapper icon-timings"> |
| | | <svg-icon icon-class="timing" class-name="card-panel-icon" /> |
| | | </div> |
| | | <div class="card-panel-description"> |
| | | <div class="card-panel-text"> |
| | | 出差未承认 |
| | | </div> |
| | | <count-to |
| | | :start-val="0" |
| | | :end-val="100" |
| | | :decimals="2" |
| | | :duration="3600" |
| | | class="card-panel-num" |
| | | /> |
| | | <span class="card-panel-texts">/</span> |
| | | <count-to |
| | | :start-val="0" |
| | | :end-val="100" |
| | | :duration="3600" |
| | | class="card-panel-num" |
| | | /> |
| | | </div> |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | <!--工具栏--> |
| | | <div class="head-container"> |
| | | <div> |
| | | <el-select v-model="query.userId" filterable clearable placeholder="所属员工" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-date-picker |
| | | v-model="query.attendanceDate" |
| | | type="daterange" |
| | | clearable |
| | | class="filter-item" |
| | | value-format="yyyy-MM-dd" |
| | | placeholder="请选择考勤日期" |
| | | range-separator=" ~ " |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | style="width: 285px;" |
| | | /> |
| | | <rrOperation /> |
| | | </div> |
| | | <!--表格渲染--> |
| | | <el-table ref="table" v-loading="crud.loading" :data="crud.data" row-key="id" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column prop="userName" label="所属员工" fixed="left" width="100" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.userName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="attendanceDate" label="考勤日期" fixed="left" width="100" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toDate(scope.row.attendanceDate) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="rosteringWorkStartTime" min-width="140" label="排班工作开始时间" show-overflow-tooltip /> |
| | | <el-table-column prop="actualWorkStartTime" min-width="140" label="实际工作开始时间" show-overflow-tooltip /> |
| | | <el-table-column prop="startLocationResults" min-width="100" label="开始位置结果" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.startLocationResults === dictlocationResultsNormal" type="success">{{ dict.label[lacationResules][scope.row.startLocationResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startLocationResults === dictlocationResultsOutside" type="warning">{{ dict.label[lacationResules][scope.row.startLocationResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startLocationResults === dictlocationResultsNotSigned" type="danger">{{ dict.label[lacationResules][scope.row.startLocationResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startLocationResults === dictlocationResultsRest" type="warning">{{ dict.label[lacationResules][scope.row.startLocationResults] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="startClockResults" min-width="100" label="开始打卡结果" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.startClockResults === dictAttendanceStateWaitFor" type="warning">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startClockResults === dictAttendanceStateNormal" type="success">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startClockResults === dictAttendanceStateNotSigned" type="danger">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startClockResults === dictAttendanceStateGoOut" type="success">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startClockResults === dictAttendanceStateBusiness" type="success">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startClockResults === dictAttendanceStateLeave" type="success">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startClockResults === dictAttendanceStateRest" type="warning">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startClockResults === dictEndanceStateLackOfTime" type="danger">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startClockResults === dictStartLate" type="warning">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="rosteringWorkEndTime" min-width="140" label="排班工作结束时间" show-overflow-tooltip /> |
| | | <el-table-column prop="actualWorkEndTime" min-width="140" label="实际工作结束时间" show-overflow-tooltip /> |
| | | <el-table-column prop="endLocationResults" min-width="100" label="结束位置结果" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.endLocationResults === dictlocationResultsNormal" type="success">{{ dict.label[lacationResules][scope.row.endLocationResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endLocationResults === dictlocationResultsOutside" type="warning">{{ dict.label[lacationResules][scope.row.endLocationResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endLocationResults === dictlocationResultsNotSigned" type="danger">{{ dict.label[lacationResules][scope.row.endLocationResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endLocationResults === dictlocationResultsRest" type="warning">{{ dict.label[lacationResules][scope.row.endLocationResults] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="endClockResults" min-width="100" label="结束打卡结果" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.endClockResults === dictAttendanceStateWaitFor" type="warning">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endClockResults === dictAttendanceStateNormal" type="success">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endClockResults === dictAttendanceStateNotSigned" type="danger">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endClockResults === dictAttendanceStateGoOut" type="success">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endClockResults === dictAttendanceStateBusiness" type="success">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endClockResults === dictAttendanceStateLeave" type="success">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endClockResults === dictAttendanceStateRest" type="warning">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endClockResults === dictEndanceStateLackOfTime" type="danger">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endClockResults === dictStartEarly" type="warning">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="dateType" min-width="80" label="日期类型" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[dateType][scope.row.dateType] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import crudAttendance from '@/api/attendance/attendance' |
| | | import crudAttendanceCardreplacement from '@/api/attendance/attendanceCardreplacement' |
| | | import crudAttendanceGoOut from '@/api/attendance/attendanceGoOut' |
| | | import crudAttendanceBusinessTravel from '@/api/attendance/attendanceBusinessTravel' |
| | | import crudUser from '@/api/system/user' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import constant from '@/utils/constant' |
| | | |
| | | const defaultForm = { id: null, userId: null, attendanceDate: null, rosteringWorkStartTime: null, actualWorkStartTime: null, startLocationResults: null, startClockResults: null, rosteringWorkEndTime: null, actualWorkEndTime: null, endLocationResults: null, endClockResults: null, dateType: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'AttendanceTotal', |
| | | components: { pagination, rrOperation }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | cruds() { |
| | | return CRUD({ title: '考勤记录', url: 'api/attendance/notNormal', idField: 'id', sort: 'attendanceDate,desc', crudMethod: { ...crudAttendance }}) |
| | | }, |
| | | // 数据字典 |
| | | dicts: [constant.ATTENDANCE_STATE, constant.DATE_TYPE, constant.LOCATION_RESULTS, constant.CARD_REPLACEMENT_DIFFERENTIATION, constant.CARD_APPROVE_STATUS, constant.LEAVE_TIME_TYPE, constant.GO_OUT_TYPE], |
| | | data() { |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'attendance:add'], |
| | | edit: ['admin', 'attendance:edit'], |
| | | del: ['admin', 'attendance:del'], |
| | | download: ['admin', 'attendance:download'], |
| | | addAttendanceInfo: ['admin', 'attendance:addAttendanceInfo'] |
| | | }, |
| | | attendanceState: constant.ATTENDANCE_STATE, |
| | | lacationResules: constant.LOCATION_RESULTS, |
| | | dateType: constant.DATE_TYPE, |
| | | dictlocationResultsNormal: constant.LOCATION_RESULTS_NORMAL, |
| | | dictlocationResultsOutside: constant.LOCATION_RESULTS_OUTSIDE, |
| | | dictlocationResultsNotSigned: constant.LOCATION_RESULTS_NOTSIGNED, |
| | | dictlocationResultsRest: constant.LOCATION_RESULTS_REST, |
| | | dictAttendanceStateWaitFor: constant.ATTENDANCE_STATE_WAITFOR, |
| | | dictAttendanceStateNormal: constant.ATTENDANCE_STATE_NORMAL, |
| | | dictAttendanceStateNotSigned: constant.ATTENDANCE_STATE_NOTSIGNED, |
| | | dictAttendanceStateGoOut: constant.ATTENDANCE_STATE_GOOUT, |
| | | dictAttendanceStateBusiness: constant.ATTENDANCE_STATE_BUSINESS, |
| | | dictAttendanceStateLeave: constant.ATTENDANCE_STATE_LEAVE, |
| | | dictAttendanceStateRest: constant.ATTENDANCE_STATE_REST, |
| | | dictEndanceStateLackOfTime: constant.ATTENDANCE_STATE_LACK_OF_TIME, |
| | | dictStartEarly: constant.ATTENDANCE_STATE_EARLY, |
| | | dictStartLate: constant.ATTENDANCE_STATE_LATE, |
| | | users: [], |
| | | users1: [], |
| | | approvalUsers: [], |
| | | goOutVisible: false, |
| | | goSuccessLoading: false, |
| | | dictLeaveTimeType: constant.LEAVE_TIME_TYPE, |
| | | dictGoOutTypr: constant.GO_OUT_TYPE, |
| | | dictLeaveTimeTypeHour: constant.LEAVE_TIME_TYPE_HOUR, |
| | | dictLeaveTimeTypeDay: constant.LEAVE_TIME_TYPE_DAY, |
| | | } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | this.getUsers() |
| | | this.getUsers1() |
| | | this.getApprovalUsers() |
| | | return true |
| | | }, |
| | | // 查询员工 |
| | | getUsers() { |
| | | crudUser.getAll().then(res => { |
| | | this.users = res |
| | | }) |
| | | }, |
| | | // 查询员工 |
| | | getUsers1() { |
| | | crudUser.getUserInfose().then(res => { |
| | | this.users1 = res |
| | | }) |
| | | }, |
| | | // 查询审核人 |
| | | getApprovalUsers() { |
| | | crudUser.getApprovalUsers().then(res => { |
| | | this.approvalUsers = res |
| | | }) |
| | | }, |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | .attCss { |
| | | font-size: 12px; |
| | | text-align: center; |
| | | } |
| | | |
| | | .panel-group { |
| | | margin-top: 18px; |
| | | |
| | | .card-panel-col { |
| | | margin-bottom: 32px; |
| | | } |
| | | |
| | | .card-panel { |
| | | height: 108px; |
| | | cursor: pointer; |
| | | font-size: 12px; |
| | | position: relative; |
| | | overflow: hidden; |
| | | color: #666; |
| | | background: #fff; |
| | | box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05); |
| | | border-color: rgba(0, 0, 0, 0.05); |
| | | |
| | | &:hover { |
| | | .card-panel-icon-wrapper { |
| | | color: #fff; |
| | | } |
| | | |
| | | .icon-people { |
| | | background: #40c9c6; |
| | | } |
| | | |
| | | .icon-message { |
| | | background: #36a3f7; |
| | | } |
| | | |
| | | .icon-permission { |
| | | background: #34bfa3; |
| | | } |
| | | |
| | | .icon-timings { |
| | | background: #f4516c; |
| | | } |
| | | } |
| | | |
| | | .icon-people { |
| | | color: #40c9c6; |
| | | } |
| | | |
| | | .icon-message { |
| | | color: #36a3f7; |
| | | } |
| | | |
| | | .icon-permission { |
| | | color: #34bfa3; |
| | | } |
| | | |
| | | .card-panel-icon-wrapper { |
| | | float: left; |
| | | margin: 14px 0 0 14px; |
| | | padding: 16px; |
| | | transition: all 0.38s ease-out; |
| | | border-radius: 6px; |
| | | } |
| | | |
| | | .card-panel-icon { |
| | | float: left; |
| | | font-size: 48px; |
| | | } |
| | | |
| | | .card-panel-description { |
| | | float: right; |
| | | font-weight: bold; |
| | | margin: 26px; |
| | | margin-left: 0px; |
| | | |
| | | .card-panel-text { |
| | | line-height: 18px; |
| | | color: rgba(0, 0, 0, 0.45); |
| | | font-size: 16px; |
| | | margin-bottom: 12px; |
| | | } |
| | | |
| | | .card-panel-texts { |
| | | font-size: 20px; |
| | | } |
| | | |
| | | .card-panel-num { |
| | | font-size: 20px; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @media (max-width: 550px) { |
| | | .card-panel-description { |
| | | display: none; |
| | | } |
| | | |
| | | .card-panel-icon-wrapper { |
| | | float: none !important; |
| | | width: 100%; |
| | | height: 100%; |
| | | margin: 0 !important; |
| | | |
| | | .svg-icon { |
| | | display: block; |
| | | margin: 14px auto !important; |
| | | float: none !important; |
| | | } |
| | | } |
| | | } |
| | | </style> |
| | |
| | | 当前任务:<i> {{ selectedTaskName }} </i> |
| | | <span |
| | | v-if="taskTotal.performanceType" |
| | | style="magin: right 10px;" |
| | | style="margin: right 10px;" |
| | | ><i> |
| | | (绩效类型: |
| | | {{ |